workbuddy-cli 0.0.0-stage → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 backtomyfuture
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,227 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # workbuddy-cli
4
+
5
+ **Zero-dependency CLI for Tencent WorkBuddy — chat with top LLMs directly from your terminal, with standalone browser login and live model discovery.**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/workbuddy-cli.svg)](https://www.npmjs.com/package/workbuddy-cli)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
9
+ [![Node: >=18](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org)
10
+ [![Zero Dependencies](https://img.shields.io/badge/dependencies-0-success.svg)](package.json)
11
+
12
+ [English](README.md) · [简体中文](README.zh-CN.md)
13
+
14
+ </div>
15
+
16
+ ---
17
+
18
+ ## Why `workbuddy-cli`?
19
+
20
+ - **Standalone Auth (No Desktop App Required)**: Run `workbuddy login` once via your browser and close the WorkBuddy Electron client for good. Tokens are stored locally with `0600` permissions and refreshed automatically.
21
+ - **Zero Dependencies**: Built 100% on Node.js built-in modules (`fetch`, `net`, `crypto`, `child_process`). Instant startup, tiny footprint.
22
+ - **Live Model Discovery**: Run `workbuddy models` to query the backend for every model currently available to your account — including credit multipliers, capabilities, and newly launched models — without waiting for CLI updates.
23
+ - **Dual-Mode Transport**: Uses direct HTTPS when logged in via CLI, and seamlessly falls back to the local WorkBuddy desktop socket (WBIPC) if you prefer not to log in separately.
24
+ - **Script & Pipe Friendly**: Native support for Unix pipes (`cat log | workbuddy`), structured `--json` output, custom `--system` prompts, and short `wb` alias.
25
+
26
+ ---
27
+
28
+ ## Quick Start
29
+
30
+ ### 1. Install
31
+
32
+ **Via npm (recommended):**
33
+
34
+ ```bash
35
+ npm install -g workbuddy-cli
36
+ ```
37
+
38
+ Or run without installing:
39
+
40
+ ```bash
41
+ npx workbuddy-cli login
42
+ ```
43
+
44
+ <details>
45
+ <summary>Alternative install methods (one-line script / from source)</summary>
46
+
47
+ **One-line installer (macOS / Linux):**
48
+
49
+ ```bash
50
+ curl -fsSL https://raw.githubusercontent.com/backtomyfuture/workbuddy-cli/main/install.sh | bash
51
+ ```
52
+
53
+ **From source:**
54
+
55
+ ```bash
56
+ git clone https://github.com/backtomyfuture/workbuddy-cli.git
57
+ cd workbuddy-cli
58
+ mkdir -p ~/.local/bin
59
+ ln -sf "$(pwd)/bin/workbuddy.mjs" ~/.local/bin/workbuddy
60
+ ln -sf "$(pwd)/bin/workbuddy.mjs" ~/.local/bin/wb
61
+ ```
62
+
63
+ </details>
64
+
65
+ ### 2. Log in & Chat
66
+
67
+ ```bash
68
+ # Authenticate in your browser (only needed once)
69
+ workbuddy login
70
+
71
+ # Discover all models available to your account
72
+ workbuddy models
73
+
74
+ # Start chatting (shorthand alias `wb` also works)
75
+ wb "Write a generic LRU cache in Python"
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Usage
81
+
82
+ ### Commands
83
+
84
+ | Command | Description |
85
+ | :--- | :--- |
86
+ | `workbuddy login` | Authenticate via browser (`--no-browser` prints URL for SSH/headless) |
87
+ | `workbuddy logout` | Revoke server session and remove local CLI credentials |
88
+ | `workbuddy status` / `whoami` | Show CLI auth state, token expiry, and desktop WBIPC status |
89
+ | `workbuddy models` / `-l` | Fetch live available models from server (`--all`, `--json`, `--static`) |
90
+ | `workbuddy sessions` | List conversations saved by this CLI |
91
+ | `workbuddy continue` / `-c` | Continue the latest conversation in the current directory |
92
+ | `workbuddy resume [id]` / `-r` | Resume a conversation by id, or list them when the id is omitted |
93
+ | `workbuddy acp` | ACP stdio server for T3 Code |
94
+ | `workbuddy [options] <prompt>` | Send a prompt to the selected model |
95
+
96
+ ### Options
97
+
98
+ | Flag | Description |
99
+ | :--- | :--- |
100
+ | `-c, --continue` | Continue the latest conversation in this directory |
101
+ | `-r, --resume [id]` | Resume one conversation; without an id, list saved conversations |
102
+ | `--session-id <id>` | Use this id when starting a new conversation |
103
+ | `-m, --model <id>` | Model ID or shorthand alias (default: `deepseek-v3-2-volc`) |
104
+ | `-s, --system <prompt>` | Set a system prompt |
105
+ | `-p, --print` | Print response and exit (default behavior) |
106
+ | `--json` | Output structured JSON (includes `reasoning` when available) |
107
+ | `--all` | Include specialized tags (e.g. `text-to-image`) in `models` |
108
+ | `--static` | Show built-in static alias list without querying server |
109
+ | `--no-browser` | Print login URL instead of opening a browser automatically |
110
+ | `-h, --help` | Show help message |
111
+
112
+ ### Examples
113
+
114
+ ```bash
115
+ # Use a specific model or shorthand alias
116
+ wb -m hy4 "Draft a polite follow-up email"
117
+ wb -m deepseek-v4 "Analyze the time complexity of this algorithm"
118
+ wb -m glm "Explain Raft consensus in 3 bullet points"
119
+
120
+ # Pass any newly released model ID from `workbuddy models` directly
121
+ wb -m <any-new-model-id> "Hello!"
122
+
123
+ # Unix pipes
124
+ cat server.log | wb -p "Extract all 500 errors and summarize root causes"
125
+ git diff | wb -p "Generate a conventional commit message"
126
+
127
+ # System prompt + JSON output
128
+ wb -s "You are a senior Go engineer" --json "How do I prevent goroutine leaks?"
129
+
130
+ # Include reasoning trace in stderr
131
+ WORKBUDDY_SHOW_REASONING=1 wb -m deep "Solve this logic puzzle..."
132
+
133
+ # Continue the latest chat in this directory, or pick one by id
134
+ wb -c "Turn that into an iterative version"
135
+ wb sessions
136
+ wb resume wb_abc123 "Add tests"
137
+ ```
138
+
139
+ > **Shorthand Aliases**: Common aliases such as `auto`, `fast`, `balanced`, `deep`, `hy4`, `ds` (`deepseek`), `deepseek-v4`, `glm`, `kimi`, `kimi-pro`, `minimax-flash`, `mimo`, and `step` are mapped automatically. Run `workbuddy models` to see the full live catalog for your account.
140
+
141
+ ---
142
+
143
+ ## Continue a conversation
144
+
145
+ Each successful prompt is stored under `~/.workbuddy-cli/sessions/`. The next prompt in the same directory with `-c` / `continue` sends the previous messages back to `/v2/chat/completions`. `resume <id>` opens a specific transcript; a unique id prefix is enough. `--json` includes `sessionId`.
146
+
147
+ This history belongs to `workbuddy-cli`. It is separate from the desktop app's CodeBuddy sessions (`codebuddy -c` / `codebuddy -r`).
148
+
149
+ ## Use it from T3 Code
150
+
151
+ T3 Code starts a local ACP agent as a subprocess and speaks newline-delimited JSON-RPC on stdin/stdout.
152
+
153
+ 1. Install this CLI so `workbuddy` is on the PATH used by the T3 Code server (`npm install -g`, or the symlink from `install.sh`).
154
+ 2. Run `workbuddy login` once as that same user.
155
+ 3. In T3 Code open **Settings → Providers → Add provider → Show more → Local ACP command**.
156
+ 4. Command: `workbuddy`. Argument: `acp`. Name it `WorkBuddy`.
157
+
158
+ The server negotiates ACP v1 and implements:
159
+
160
+ | Method | Behavior |
161
+ | :--- | :--- |
162
+ | `initialize` | Announces ACP v1, `loadSession`, and text prompts. If the CLI is logged out, advertises a terminal login that runs `workbuddy login`. |
163
+ | `authenticate` / `auth/logout` | Terminal login is not an RPC. Logout revokes the CLI credential. |
164
+ | `session/new` | Creates a conversation bound to the workspace `cwd`. |
165
+ | `session/load`, `session/resume` | Reloads a saved transcript and replays it. |
166
+ | `session/list` | Lists saved conversations. |
167
+ | `session/prompt` | Streams `agent_message_chunk` / `agent_thought_chunk`, then returns `stopReason`. |
168
+ | `session/cancel` | Aborts the in-flight turn. |
169
+ | `session/close` | Drops the in-memory session. The transcript stays on disk. |
170
+ | `session/set_model`, `session/set_config_option` | Changes the model for later turns. |
171
+ | `session/set_mode` | `plan` disables edits and shell commands. |
172
+
173
+ During a turn the agent can call `read_file`, `list_dir`, `write_file`, and `bash`. Writes, shell commands, and reads ask `session/request_permission`, then use the client's `fs/*` or `terminal` capability when T3 advertises it.
174
+
175
+ The desktop CodeBuddy binary already speaks ACP too (`codebuddy --acp`). On this machine the unpacked entrypoint only loads if `CODEBUDDY_FORCE_LITE_WB_BUNDLE=1`. `workbuddy acp` is the integration that uses this CLI's own login and transcript store.
176
+
177
+ ## Architecture
178
+
179
+ ```text
180
+ Mode A (Default when logged in): Standalone Direct HTTPS
181
+ ┌─────────────────┐ HTTPS + Bearer Token (Auto-Refresh) ┌────────────────────────┐
182
+ │ workbuddy-cli │ ───────────────────────────────────────────────> │ Tencent Cloud Backend │
183
+ │ (Pure Node.js) │ <─────────────────────────────────────────────── │ (www.workbuddy.cn) │
184
+ └─────────────────┘ ~/.workbuddy-cli/auth.json (0600 isolated) └────────────────────────┘
185
+
186
+ Mode B (Fallback): Local Desktop WBIPC
187
+ ┌─────────────────┐ Unix Domain Socket (WBIPC) ┌────────────────────────┐
188
+ │ workbuddy-cli │ ───────────────────────────────────> │ WorkBuddy Desktop │
189
+ └─────────────────┘ HMAC-SHA256 Handshake + JSON-RPC └────────────────────────┘
190
+ ```
191
+
192
+ 1. **Standalone Mode**: `workbuddy login` completes browser OAuth polling and stores credentials in `~/.workbuddy-cli/auth.json` (`0600` permissions, isolated from the desktop app). Requests hit `/v2/chat/completions` and `/v2/enterprises/.../models` directly and auto-refresh expired tokens.
193
+ 2. **WBIPC Fallback**: If no CLI session exists, `workbuddy-cli` discovers `~/.workbuddy/wbipc/endpoint.json`, completes an HMAC-SHA256 challenge-response handshake, and proxies requests through the running desktop app's `wb.request` pipe.
194
+
195
+ ---
196
+
197
+ ## Upgrading
198
+
199
+ ```bash
200
+ # npm global install
201
+ npm install -g workbuddy-cli@latest
202
+
203
+ # One-line script install
204
+ curl -fsSL https://raw.githubusercontent.com/backtomyfuture/workbuddy-cli/main/install.sh | bash
205
+
206
+ # Git clone
207
+ git pull
208
+ ```
209
+
210
+ ---
211
+
212
+ ## FAQ
213
+
214
+ **Can I run `workbuddy-cli` without keeping the WorkBuddy desktop app open?**
215
+ Yes. Run `workbuddy login` once and you can quit the desktop app completely.
216
+
217
+ **How do I use new models added on the server?**
218
+ Run `workbuddy models` to scan the live catalog, then pass any returned model ID with `-m <model_id>`. No CLI upgrade needed.
219
+
220
+ **How do I log in on a remote server or over SSH?**
221
+ Run `workbuddy login --no-browser`, open the printed URL in your local browser, and complete authorization.
222
+
223
+ ---
224
+
225
+ ## License
226
+
227
+ [MIT](LICENSE)
@@ -0,0 +1,227 @@
1
+ <div align="center">
2
+
3
+ # workbuddy-cli
4
+
5
+ **零依赖的腾讯 WorkBuddy 命令行工具 —— 支持独立浏览器登录、实时扫描最新模型,无需保持桌面端常驻。**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/workbuddy-cli.svg)](https://www.npmjs.com/package/workbuddy-cli)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
9
+ [![Node: >=18](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org)
10
+ [![Zero Dependencies](https://img.shields.io/badge/dependencies-0-success.svg)](package.json)
11
+
12
+ [English](README.md) · [简体中文](README.zh-CN.md)
13
+
14
+ </div>
15
+
16
+ ---
17
+
18
+ ## 为什么选择 `workbuddy-cli`?
19
+
20
+ - **独立登录,无需开着客户端**:运行一次 `workbuddy login` 完成浏览器授权后,即可彻底关闭 WorkBuddy 桌面端。凭据以 `0600` 权限独立保存并在过期时自动刷新。
21
+ - **零第三方依赖**:100% 基于 Node.js 原生内置模块(`fetch`、`net`、`crypto`、`child_process`),启动极速,体积极小。
22
+ - **实时扫描可用模型**:运行 `workbuddy models` 直接从服务端拉取当前账号可用模型、积分倍率与能力标签,上新模型无需等待 CLI 更新即可调用。
23
+ - **双通道自动容错**:CLI 已登录时直连 HTTPS;未登录时自动回退复用本地运行中的 WorkBuddy 桌面端 WBIPC 通道。
24
+ - **管道与脚本友好**:原生支持 Unix 管道(`cat log | workbuddy`)、结构化 `--json` 输出、自定义 `--system` 提示词及超短别名 `wb`。
25
+
26
+ ---
27
+
28
+ ## 快速开始
29
+
30
+ ### 1. 安装
31
+
32
+ **通过 npm 全局安装(推荐):**
33
+
34
+ ```bash
35
+ npm install -g workbuddy-cli
36
+ ```
37
+
38
+ 或免安装直接运行:
39
+
40
+ ```bash
41
+ npx workbuddy-cli login
42
+ ```
43
+
44
+ <details>
45
+ <summary>其他安装方式(一键脚本 / 源码安装)</summary>
46
+
47
+ **一键脚本安装(macOS / Linux):**
48
+
49
+ ```bash
50
+ curl -fsSL https://raw.githubusercontent.com/backtomyfuture/workbuddy-cli/main/install.sh | bash
51
+ ```
52
+
53
+ **手动克隆仓库:**
54
+
55
+ ```bash
56
+ git clone https://github.com/backtomyfuture/workbuddy-cli.git
57
+ cd workbuddy-cli
58
+ mkdir -p ~/.local/bin
59
+ ln -sf "$(pwd)/bin/workbuddy.mjs" ~/.local/bin/workbuddy
60
+ ln -sf "$(pwd)/bin/workbuddy.mjs" ~/.local/bin/wb
61
+ ```
62
+
63
+ </details>
64
+
65
+ ### 2. 登录并开始对话
66
+
67
+ ```bash
68
+ # 浏览器扫码/账号授权登录(只需一次)
69
+ workbuddy login
70
+
71
+ # 实时扫描服务端当前可用模型
72
+ workbuddy models
73
+
74
+ # 开始对话(也可使用超短别名 wb)
75
+ wb "用 Python 写一个支持泛型的 LRU 缓存"
76
+ ```
77
+
78
+ ---
79
+
80
+ ## 使用指南
81
+
82
+ ### 子命令
83
+
84
+ | 命令 | 说明 |
85
+ | :--- | :--- |
86
+ | `workbuddy login` | 通过浏览器登录(SSH/无界面环境可加 `--no-browser` 打印链接) |
87
+ | `workbuddy logout` | 注销服务端会话并删除本地 CLI 凭据 |
88
+ | `workbuddy status` / `whoami` | 查看当前 CLI 登录状态、Token 过期时间及桌面端 WBIPC 状态 |
89
+ | `workbuddy models` / `-l` | 从服务端实时扫描可用模型(支持 `--all`、`--json`、`--static`) |
90
+ | `workbuddy sessions` | 列出本 CLI 保存的对话 |
91
+ | `workbuddy continue` / `-c` | 继续当前目录里最近的一条对话 |
92
+ | `workbuddy resume [id]` / `-r` | 按 id 继续某一条;省略 id 时列出对话 |
93
+ | `workbuddy acp` | 给 T3 Code 用的 ACP stdio 服务 |
94
+ | `workbuddy [选项] <提问内容>` | 向指定模型发起对话 |
95
+
96
+ ### 常用选项
97
+
98
+ | 参数 | 说明 |
99
+ | :--- | :--- |
100
+ | `-c, --continue` | 继续当前目录最近的一条对话 |
101
+ | `-r, --resume [id]` | 按 id 继续;不写 id 时列出已保存对话 |
102
+ | `--session-id <id>` | 新建对话时指定 id |
103
+ | `-m, --model <id>` | 指定模型 ID 或简写别名(默认:`deepseek-v3-2-volc`) |
104
+ | `-s, --system <prompt>` | 设定 System Prompt |
105
+ | `-p, --print` | 打印结果后退出(默认行为) |
106
+ | `--json` | 输出结构化 JSON(包含完整 `reasoning` 思考过程) |
107
+ | `--all` | 在 `models` 中包含生图等特殊标签模型 |
108
+ | `--static` | 不请求服务端,直接显示内置简写列表 |
109
+ | `--no-browser` | 不自动打开浏览器,仅打印登录链接 |
110
+ | `-h, --help` | 显示帮助信息 |
111
+
112
+ ### 使用示例
113
+
114
+ ```bash
115
+ # 指定模型或简写别名
116
+ wb -m hy4 "帮我写一封礼貌的英文跟进邮件"
117
+ wb -m deepseek-v4 "分析这段代码的时空复杂度"
118
+ wb -m glm "用三句话解释 Raft 共识算法"
119
+
120
+ # 直接调用 workbuddy models 扫描出的任意新模型 ID
121
+ wb -m <任意新模型ID> "你好!"
122
+
123
+ # 标准 Unix 管道
124
+ cat server.log | wb -p "提取所有 500 错误并分析原因"
125
+ git diff | wb -p "根据变更生成规范的 Commit Message"
126
+
127
+ # 设定 System Prompt 并输出 JSON
128
+ wb -s "你是一名资深 Go 开发专家" --json "如何避免 goroutine 泄漏?"
129
+
130
+ # 在 stderr 中附带模型思考过程
131
+ WORKBUDDY_SHOW_REASONING=1 wb -m deep "推理一下这道逻辑题..."
132
+
133
+ # 继续当前目录最近一次对话,或按 id 接着问
134
+ wb -c "把刚才的例子改成迭代版本"
135
+ wb sessions
136
+ wb resume wb_abc123 "补上测试"
137
+ ```
138
+
139
+ > **常用简写别名**:内置支持 `auto`、`fast`、`balanced`、`deep`、`hy4`、`ds`(`deepseek`)、`deepseek-v4`、`glm`、`kimi`、`kimi-pro`、`minimax-flash`、`mimo`、`step` 等常见简写。完整实时模型列表请直接运行 `workbuddy models` 查看。
140
+
141
+ ---
142
+
143
+ ## 继续对话
144
+
145
+ 每次成功的提问都会写到 `~/.workbuddy-cli/sessions/`。同一目录里再用 `-c` / `continue`,会把之前的消息一并送给 `/v2/chat/completions`。`resume <id>` 打开指定记录,id 写唯一前缀即可。`--json` 的结果里带 `sessionId`。
146
+
147
+ 这些记录只属于 `workbuddy-cli`,和桌面端 CodeBuddy 自己的会话(`codebuddy -c` / `codebuddy -r`)不是同一份。
148
+
149
+ ## 接到 T3 Code
150
+
151
+ T3 Code 会把本地 ACP 代理拉成子进程,用换行分隔的 JSON-RPC 走 stdin/stdout。
152
+
153
+ 1. 让 T3 Code 服务所用的那个用户能在 PATH 里找到 `workbuddy`。
154
+ 2. 用同一用户执行一次 `workbuddy login`。
155
+ 3. 打开 **Settings → Providers → Add provider → Show more → Local ACP command**。
156
+ 4. 命令填 `workbuddy`,参数填一行 `acp`,名称填 `WorkBuddy`。
157
+
158
+ 服务端按 ACP v1 应答,常用方法如下:
159
+
160
+ | 方法 | 行为 |
161
+ | :--- | :--- |
162
+ | `initialize` | 声明 ACP v1、`loadSession` 和文本提示。未登录时广告终端登录,实际运行 `workbuddy login`。 |
163
+ | `authenticate` / `auth/logout` | 终端登录不走 RPC。logout 会注销 CLI 凭据。 |
164
+ | `session/new` | 按工作区 `cwd` 新建对话。 |
165
+ | `session/load`、`session/resume` | 读回记录并重放历史。 |
166
+ | `session/list` | 列出已保存对话。 |
167
+ | `session/prompt` | 流式发送 `agent_message_chunk` / `agent_thought_chunk`,结束后返回 `stopReason`。 |
168
+ | `session/cancel` | 中断当前这一轮。 |
169
+ | `session/close` | 只卸掉内存中的会话,磁盘记录还在。 |
170
+ | `session/set_model`、`session/set_config_option` | 切换后续轮次的模型。 |
171
+ | `session/set_mode` | `plan` 时不改文件、不跑命令。 |
172
+
173
+ 一轮对话里模型可以调用 `read_file`、`list_dir`、`write_file` 和 `bash`。写文件、跑命令和读文件会先发 `session/request_permission`;T3 声明了 `fs/*` 时,读写走客户端,不直接碰磁盘。
174
+
175
+ 桌面端自带的 CodeBuddy 也能说 ACP(`codebuddy --acp`)。这台机器上未解包的完整包需要 `CODEBUDDY_FORCE_LITE_WB_BUNDLE=1` 才能从现有入口启动。`workbuddy acp` 用的是本 CLI 自己的登录态和会话记录。
176
+
177
+ ## 工作原理
178
+
179
+ ```text
180
+ 模式 A(推荐):CLI 独立直连(无需启动桌面端)
181
+ ┌─────────────────┐ HTTPS + Bearer Token (+ 自动刷新) ┌────────────────────────┐
182
+ │ workbuddy-cli │ ───────────────────────────────────────────────> │ Tencent Cloud Backend │
183
+ │ (Pure Node.js) │ <─────────────────────────────────────────────── │ (www.workbuddy.cn) │
184
+ └─────────────────┘ ~/.workbuddy-cli/auth.json (0600 权限隔离) └────────────────────────┘
185
+
186
+ 模式 B(回退):未登录 CLI 时自动复用桌面端 WBIPC
187
+ ┌─────────────────┐ Unix Domain Socket (WBIPC) ┌────────────────────────┐
188
+ │ workbuddy-cli │ ───────────────────────────────────> │ WorkBuddy Desktop │
189
+ └─────────────────┘ HMAC-SHA256 Handshake + JSON-RPC └────────────────────────┘
190
+ ```
191
+
192
+ 1. **独立直连模式**:`workbuddy login` 通过外部链接授权轮询获取 Token 与账号信息,以 `0600` 权限保存在 `~/.workbuddy-cli/auth.json`(与桌面端配置完全隔离)。后续请求直接调用 `/v2/chat/completions` 与 `/v2/enterprises/.../models`,并在 Token 临期或返回 `401` 时自动刷新。
193
+ 2. **WBIPC 桌面端回退**:若未执行 `workbuddy login`,CLI 会自动检测 `~/.workbuddy/wbipc/endpoint.json`,通过 HMAC-SHA256 握手经桌面端 `wb.request` 管线代理请求。
194
+
195
+ ---
196
+
197
+ ## 版本更新
198
+
199
+ ```bash
200
+ # npm 全局安装用户
201
+ npm install -g workbuddy-cli@latest
202
+
203
+ # 一键脚本安装用户
204
+ curl -fsSL https://raw.githubusercontent.com/backtomyfuture/workbuddy-cli/main/install.sh | bash
205
+
206
+ # Git 克隆用户
207
+ git pull
208
+ ```
209
+
210
+ ---
211
+
212
+ ## 常见问题
213
+
214
+ **Q:可以完全不开启 WorkBuddy 桌面端使用吗?**
215
+ A:可以。运行一次 `workbuddy login` 完成浏览器授权后,即可彻底关闭 WorkBuddy 客户端。
216
+
217
+ **Q:服务端上新模型后需要升级 CLI 吗?**
218
+ A:不需要。运行 `workbuddy models` 即可实时扫描出所有新模型,直接通过 `-m <model_id>` 调用即可。
219
+
220
+ **Q:如何在远程服务器或 SSH 环境下登录?**
221
+ A:运行 `workbuddy login --no-browser`,将终端打印的授权链接复制到本地浏览器打开完成登录即可。
222
+
223
+ ---
224
+
225
+ ## 开源协议
226
+
227
+ [MIT](LICENSE)