From 3dbcd4486f5e7fa468fd7804e2d74425929013e7 Mon Sep 17 00:00:00 2001 From: TASTEMAKER Date: Tue, 7 Apr 2026 13:34:17 +0800 Subject: [PATCH] docs: explain daemon token setup and upgrade hints --- README.ja.md | 11 +++++++++ README.md | 11 +++++++++ README.zh.md | 11 +++++++++ crates/autocli-browser/src/lib.rs | 1 + crates/autocli-cli/src/commands/doctor.rs | 30 +++++++++++++++-------- 5 files changed, 54 insertions(+), 10 deletions(-) diff --git a/README.ja.md b/README.ja.md index 989752b..c17626b 100644 --- a/README.ja.md +++ b/README.ja.md @@ -110,6 +110,14 @@ cp target/release/autocli /usr/local/bin/ # macOS / Linux 5. 「パッケージ化されていない拡張機能を読み込む」をクリックし、解凍したフォルダを選択 6. 拡張機能は自動的に autocli daemon に接続されます +### Daemon 認証とアップグレード時の注意 + +- ブラウザモードのコマンドは、`~/.autocli/daemon-token` に保存されたトークンでローカル daemon に接続します +- CLI はこのトークンを自動で読み込むため、通常のローカル構成では手動コピーは不要です +- 旧バージョンの AutoCLI からアップグレードした場合は、`chrome://extensions` で unpacked extension を一度リロードして、daemon token で再接続させてください +- カスタム構成では `AUTOCLI_DAEMON_TOKEN` でトークンを上書きできます +- `autocli doctor` は daemon token のパスと daemon / 拡張機能の接続状態を表示します + > Public モードのコマンド(hackernews、devto、lobsters など)は拡張機能なしで使用できます。 ## Skill インストール @@ -144,6 +152,9 @@ autocli twitter search "rust lang" --limit 10 # 診断を実行 autocli doctor +# daemon token のパス / 拡張機能の接続状態を確認 +# (doctor の出力に含まれます) + # シェル補完を生成 autocli completion bash >> ~/.bashrc autocli completion zsh >> ~/.zshrc diff --git a/README.md b/README.md index c834e41..3a47802 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,14 @@ Simply re-run the install command or download the latest release to overwrite th 5. Click "Load unpacked" and select the extracted folder 6. The extension will automatically connect to the autocli daemon +### Daemon Auth and Upgrade Notes + +- Browser-mode commands now authenticate to the local daemon with a token stored at `~/.autocli/daemon-token` +- The CLI loads this token automatically; no manual copy/paste is required for the default local setup +- If you upgraded from an older AutoCLI build, reload the unpacked Chrome extension once in `chrome://extensions` so it reconnects with the daemon token +- For custom setups, you can override the token with `AUTOCLI_DAEMON_TOKEN` +- `autocli doctor` prints the daemon token path together with daemon and extension connectivity + > Public mode commands (hackernews, devto, lobsters, etc.) work without the extension. ## Skill Install @@ -144,6 +152,9 @@ autocli twitter search "rust lang" --limit 10 # Run diagnostics autocli doctor +# Review daemon token path / extension connectivity +# (included in doctor output) + # Generate shell completions autocli completion bash >> ~/.bashrc autocli completion zsh >> ~/.zshrc diff --git a/README.zh.md b/README.zh.md index b406bf2..b7c446e 100644 --- a/README.zh.md +++ b/README.zh.md @@ -110,6 +110,14 @@ cp target/release/autocli /usr/local/bin/ # macOS / Linux 5. 点击「加载已解压的扩展程序」,选择解压后的文件夹 6. 扩展安装后会自动连接 autocli daemon +### Daemon 鉴权与升级说明 + +- 浏览器模式命令现在会使用保存在 `~/.autocli/daemon-token` 的 token 访问本地 daemon +- CLI 会自动读取这个 token,默认本地安装场景下无需手动复制 +- 如果你是从旧版 AutoCLI 升级,请到 `chrome://extensions` 里把已加载的扩展手动重载一次,让它用新的 daemon token 重新连接 +- 自定义部署场景可通过 `AUTOCLI_DAEMON_TOKEN` 覆盖 token +- `autocli doctor` 会输出 daemon token 路径,以及 daemon / 扩展连接状态 + > Public 模式命令(hackernews、devto、lobsters 等)无需安装扩展即可使用。 ## Skill 安装 @@ -144,6 +152,9 @@ autocli twitter search "rust lang" --limit 10 # 运行诊断 autocli doctor +# 查看 daemon token 路径 / 扩展连接状态 +# (包含在 doctor 输出中) + # 生成 Shell 补全 autocli completion bash >> ~/.bashrc autocli completion zsh >> ~/.zshrc diff --git a/crates/autocli-browser/src/lib.rs b/crates/autocli-browser/src/lib.rs index a4848e9..a9b8057 100644 --- a/crates/autocli-browser/src/lib.rs +++ b/crates/autocli-browser/src/lib.rs @@ -12,6 +12,7 @@ pub mod bridge; pub mod cdp; pub use bridge::BrowserBridge; +pub use auth::daemon_token_path; pub use page::DaemonPage; pub use cdp::CdpPage; pub use daemon::Daemon; diff --git a/crates/autocli-cli/src/commands/doctor.rs b/crates/autocli-cli/src/commands/doctor.rs index e0cf2b4..d0fe5b7 100644 --- a/crates/autocli-cli/src/commands/doctor.rs +++ b/crates/autocli-cli/src/commands/doctor.rs @@ -1,6 +1,6 @@ -use colored::Colorize; -use autocli_browser::DaemonClient; +use autocli_browser::{daemon_token_path, DaemonClient}; use autocli_external::is_binary_installed; +use colored::Colorize; pub async fn run_doctor() { println!("{}", "autocli diagnostics".bold()); @@ -34,15 +34,25 @@ pub async fn run_doctor() { let daemon_running = client.is_running().await; print_check("Daemon running", daemon_running); - // 3. Check extension connected - if daemon_running { - let ext_connected = client.is_extension_connected().await; - print_check("Chrome extension connected", ext_connected); + // 3. Check local daemon token state + let token_path = daemon_token_path(); + print_check("Daemon token file", token_path.exists()); + println!(" Path: {}", token_path.display()); + + // 4. Check extension connected + let ext_connected = if daemon_running { + client.is_extension_connected().await } else { - print_check("Chrome extension connected", false); + false + }; + print_check("Chrome extension connected", ext_connected); + if daemon_running && !ext_connected { + println!( + " Hint: If you upgraded from an older AutoCLI build, reload the unpacked Chrome extension once." + ); } - // 4. Check external CLIs + // 5. Check external CLIs println!(); println!("{}", "External CLIs:".bold()); for name in &["gh", "docker", "kubectl"] { @@ -50,14 +60,14 @@ pub async fn run_doctor() { print_check(name, installed); } - // 5. Check CDP endpoint + // 6. Check CDP endpoint let cdp = std::env::var("AUTOCLI_CDP_ENDPOINT").ok(); if let Some(endpoint) = cdp { println!(); println!("CDP endpoint: {}", endpoint); } - // 6. Print adapter stats + // 7. Print adapter stats println!(); println!("{}", "Adapter stats:".bold()); // Will be filled in by main.rs passing registry info