workbuddy-cli 1.1.0 → 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/README.md +154 -128
- package/README.zh-CN.md +227 -0
- package/bin/acp-server.mjs +739 -0
- package/bin/sessions.mjs +92 -0
- package/bin/workbuddy.mjs +451 -66
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,59 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
> Call 40+ top LLMs (Hunyuan 4.0, DeepSeek-V3/V4, GLM-5.3, Kimi-K3, MiniMax, Xiaomi MiMo, Step-5) directly from your terminal or scripts without setting up API keys!
|
|
3
|
+
# workbuddy-cli
|
|
5
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
|
+
[](https://www.npmjs.com/package/workbuddy-cli)
|
|
6
8
|
[](LICENSE)
|
|
7
9
|
[](https://nodejs.org)
|
|
8
10
|
[](package.json)
|
|
9
11
|
|
|
12
|
+
[English](README.md) · [简体中文](README.zh-CN.md)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
10
16
|
---
|
|
11
17
|
|
|
12
|
-
##
|
|
18
|
+
## Why `workbuddy-cli`?
|
|
13
19
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* **最新旗舰**:DeepSeek-V4.1 Flash、GLM-5.3、Kimi-K3.1 Pro、MiniMax-M3.1 Flash、小米 MiMo-V2.6 Pro、阶跃星辰 Step-5
|
|
20
|
-
* 🔄 **流式管道与脚本友好**:
|
|
21
|
-
* 支持标准 Unix 管道(`cat file | workbuddy`)
|
|
22
|
-
* 支持结构化 JSON 输出(`--json`)
|
|
23
|
-
* 支持系统提示词(`-s / --system`)
|
|
24
|
-
* 完美适配 Shell 脚本、Raycast / Alfred 扩展以及 AI Agent 调度中台。
|
|
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
25
|
|
|
26
26
|
---
|
|
27
27
|
|
|
28
|
-
##
|
|
28
|
+
## Quick Start
|
|
29
29
|
|
|
30
|
-
###
|
|
30
|
+
### 1. Install
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
**Via npm (recommended):**
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
|
|
35
|
+
npm install -g workbuddy-cli
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
### 方式 2:使用 npm 全局安装
|
|
38
|
+
Or run without installing:
|
|
43
39
|
|
|
44
40
|
```bash
|
|
45
|
-
|
|
41
|
+
npx workbuddy-cli login
|
|
46
42
|
```
|
|
47
43
|
|
|
48
|
-
|
|
44
|
+
<details>
|
|
45
|
+
<summary>Alternative install methods (one-line script / from source)</summary>
|
|
46
|
+
|
|
47
|
+
**One-line installer (macOS / Linux):**
|
|
49
48
|
|
|
50
49
|
```bash
|
|
51
|
-
|
|
50
|
+
curl -fsSL https://raw.githubusercontent.com/backtomyfuture/workbuddy-cli/main/install.sh | bash
|
|
52
51
|
```
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
### 方式 3:手动克隆仓库
|
|
53
|
+
**From source:**
|
|
57
54
|
|
|
58
55
|
```bash
|
|
59
56
|
git clone https://github.com/backtomyfuture/workbuddy-cli.git
|
|
@@ -63,139 +60,168 @@ ln -sf "$(pwd)/bin/workbuddy.mjs" ~/.local/bin/workbuddy
|
|
|
63
60
|
ln -sf "$(pwd)/bin/workbuddy.mjs" ~/.local/bin/wb
|
|
64
61
|
```
|
|
65
62
|
|
|
66
|
-
|
|
63
|
+
</details>
|
|
67
64
|
|
|
68
|
-
|
|
65
|
+
### 2. Log in & Chat
|
|
69
66
|
|
|
70
|
-
### 0. 独立登录 / 退出(无需保持桌面端运行)
|
|
71
67
|
```bash
|
|
72
|
-
#
|
|
68
|
+
# Authenticate in your browser (only needed once)
|
|
73
69
|
workbuddy login
|
|
74
70
|
|
|
75
|
-
#
|
|
76
|
-
workbuddy
|
|
71
|
+
# Discover all models available to your account
|
|
72
|
+
workbuddy models
|
|
77
73
|
|
|
78
|
-
#
|
|
79
|
-
|
|
74
|
+
# Start chatting (shorthand alias `wb` also works)
|
|
75
|
+
wb "Write a generic LRU cache in Python"
|
|
80
76
|
```
|
|
81
77
|
|
|
82
|
-
|
|
78
|
+
---
|
|
83
79
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
|
90
113
|
|
|
91
|
-
### 2. 指定模型(使用简写别名)
|
|
92
114
|
```bash
|
|
93
|
-
#
|
|
94
|
-
|
|
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"
|
|
95
119
|
|
|
96
|
-
#
|
|
97
|
-
|
|
120
|
+
# Pass any newly released model ID from `workbuddy models` directly
|
|
121
|
+
wb -m <any-new-model-id> "Hello!"
|
|
98
122
|
|
|
99
|
-
#
|
|
100
|
-
|
|
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"
|
|
101
126
|
|
|
102
|
-
#
|
|
103
|
-
|
|
127
|
+
# System prompt + JSON output
|
|
128
|
+
wb -s "You are a senior Go engineer" --json "How do I prevent goroutine leaks?"
|
|
104
129
|
|
|
105
|
-
#
|
|
106
|
-
|
|
107
|
-
```
|
|
130
|
+
# Include reasoning trace in stderr
|
|
131
|
+
WORKBUDDY_SHOW_REASONING=1 wb -m deep "Solve this logic puzzle..."
|
|
108
132
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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"
|
|
113
137
|
```
|
|
114
138
|
|
|
115
|
-
|
|
116
|
-
```bash
|
|
117
|
-
workbuddy -s "你是一名资深Go开发专家" "如何避免goroutine泄漏?"
|
|
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.
|
|
118
140
|
|
|
119
|
-
|
|
120
|
-
workbuddy --json "1+1=?"
|
|
121
|
-
```
|
|
141
|
+
---
|
|
122
142
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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.
|
|
129
174
|
|
|
130
|
-
|
|
131
|
-
|
|
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 └────────────────────────┘
|
|
132
190
|
```
|
|
133
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
|
+
|
|
134
195
|
---
|
|
135
196
|
|
|
136
|
-
##
|
|
137
|
-
|
|
138
|
-
| 厂商 / 系列 | 模型 ID / 标识符 | CLI 简写别名 | 特点 / 额度 |
|
|
139
|
-
| :--- | :--- | :--- | :--- |
|
|
140
|
-
| **智能调度** | `auto` | `auto` | 客户端智能调度 |
|
|
141
|
-
| | `fast-model` / `balanced-model` / `deep-model` | `fast` / `balanced` / `deep` | 极速 / 均衡 / 深度推理 |
|
|
142
|
-
| **腾讯混元** | `hy4` / `hy4free` | `hy4` | **混元 4.0 [免费]**(客户端同款) |
|
|
143
|
-
| | `hy4std` | - | 混元 4.0 标准版(扣付费包) |
|
|
144
|
-
| | `hy4-preview` | - | 混元 4.0 尝鲜内测版 |
|
|
145
|
-
| | `hy3` | `hy3` | 混元 3.0 [免费] |
|
|
146
|
-
| | `hunyuan-chat` | - | 混元 Turbos 极速版 |
|
|
147
|
-
| **DeepSeek** | `deepseek-v3-2-volc` | `deepseek`, `ds`, `v3` | **DeepSeek-V3.2**(默认模型) |
|
|
148
|
-
| | `deepseek-v4.1-flash` | `deepseek-v4`, `v4` | **DeepSeek-V4.1 Flash** 极速旗舰 |
|
|
149
|
-
| | `deepseek-v4-pro` | - | DeepSeek-V4 Pro 高阶专业版 |
|
|
150
|
-
| **智谱 GLM** | `glm-5.3` | `glm` | **GLM-5.3** 最新旗舰 |
|
|
151
|
-
| | `glm-5.3-flash` | `glm-flash` | GLM-5.3 Flash |
|
|
152
|
-
| | `glm-5v-turbo` | `glm-5v` | GLM-5v 视觉多模态 |
|
|
153
|
-
| **月之暗面 Kimi** | `kimi-k3.1-pro` | `kimi-pro` | **Kimi-K3.1-Pro** 最新旗舰 |
|
|
154
|
-
| | `kimi-k3-1` / `kimi-k3-2` | `kimi-k3` | Kimi-K3 系列 |
|
|
155
|
-
| | `kimi-k2.7` | - | Kimi-K2.7-Code 代码专精 |
|
|
156
|
-
| | `kimi-k2.5` | `kimi` | Kimi-K2.5 |
|
|
157
|
-
| **MiniMax** | `minimax-m3.1-flash` | `minimax-flash` | **MiniMax-M3.1-Flash** |
|
|
158
|
-
| | `minimax-m2.7` | `minimax` | MiniMax-M2.7 |
|
|
159
|
-
| **其他厂商** | `mimo-v2.6-pro` | `mimo` | **小米 Xiaomi MiMo-V2.6-Pro** |
|
|
160
|
-
| | `step-5-preview` | `step` | **阶跃星辰 Step-5-Preview** |
|
|
161
|
-
| **代码辅助** | `codewise-rewrite` | - | 代码重构专精 |
|
|
162
|
-
| | `codewise-jump` | - | 符号跳转与定义查找 |
|
|
197
|
+
## Upgrading
|
|
163
198
|
|
|
164
|
-
|
|
199
|
+
```bash
|
|
200
|
+
# npm global install
|
|
201
|
+
npm install -g workbuddy-cli@latest
|
|
165
202
|
|
|
166
|
-
|
|
203
|
+
# One-line script install
|
|
204
|
+
curl -fsSL https://raw.githubusercontent.com/backtomyfuture/workbuddy-cli/main/install.sh | bash
|
|
167
205
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
│ workbuddy-cli │ ─────────────────────────────────────────> │ WorkBuddy Desktop │
|
|
171
|
-
│ (Pure Node.js) │ <───────────────────────────────────────── │ (Electron App) │
|
|
172
|
-
└─────────────────┘ HMAC-SHA256 Handshake + JSON-RPC └───────────┬────────────┘
|
|
173
|
-
│
|
|
174
|
-
Authorized Proxy Fetch
|
|
175
|
-
│
|
|
176
|
-
▼
|
|
177
|
-
┌────────────────────────┐
|
|
178
|
-
│ Tencent Cloud Backend │
|
|
179
|
-
│ (https://workbuddy.cn) │
|
|
180
|
-
└────────────────────────┘
|
|
206
|
+
# Git clone
|
|
207
|
+
git pull
|
|
181
208
|
```
|
|
182
209
|
|
|
183
|
-
1. **自动发现**:CLI 自动读取 `~/.workbuddy/wbipc/endpoint.json`,获取当前运行中 WorkBuddy 实例的 Unix 套接字与握手 Ticket。
|
|
184
|
-
2. **安全握手**:客户端发起 `session_hello`,服务端下发随机 Nonce 挑战,CLI 计算 HMAC-SHA256 签名通过验证。
|
|
185
|
-
3. **管线代理**:CLI 绑定 `wb.request` 管线,利用内部 `http.fetch` 发起对话请求,直接继承桌面端已登录会话的鉴权与配额。
|
|
186
|
-
|
|
187
210
|
---
|
|
188
211
|
|
|
189
|
-
##
|
|
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.
|
|
190
216
|
|
|
191
|
-
**
|
|
192
|
-
|
|
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.
|
|
193
219
|
|
|
194
|
-
**
|
|
195
|
-
|
|
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.
|
|
196
222
|
|
|
197
223
|
---
|
|
198
224
|
|
|
199
|
-
##
|
|
225
|
+
## License
|
|
200
226
|
|
|
201
|
-
|
|
227
|
+
[MIT](LICENSE)
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# workbuddy-cli
|
|
4
|
+
|
|
5
|
+
**零依赖的腾讯 WorkBuddy 命令行工具 —— 支持独立浏览器登录、实时扫描最新模型,无需保持桌面端常驻。**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/workbuddy-cli)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
[](https://nodejs.org)
|
|
10
|
+
[](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)
|