jinzd-ai-cli 0.2.2 → 0.2.4
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 +315 -236
- package/README.zh-CN.md +328 -161
- package/dist/{chunk-YSHQDGVZ.js → chunk-2WCLXWAH.js} +1 -1
- package/dist/{chunk-NGGVPDNF.js → chunk-HTXJ23TX.js} +31 -4
- package/dist/index.js +4 -4
- package/dist/{run-tests-3Y3P7QTJ.js → run-tests-L5G4W7EB.js} +1 -1
- package/dist/{server-KZ472I7D.js → server-N2LG3A4M.js} +2 -2
- package/package.json +10 -11
- package/CLAUDE.md +0 -2124
- package/dist/.icon-ico/icon.ico +0 -0
- package/dist/electron-server.js +0 -8033
package/README.zh-CN.md
CHANGED
|
@@ -1,161 +1,328 @@
|
|
|
1
|
-
[English](README.md) | **中文**
|
|
2
|
-
|
|
3
|
-
# ai-cli
|
|
4
|
-
|
|
5
|
-
> 跨平台
|
|
6
|
-
|
|
7
|
-
[](https://www.npmjs.com/package/jinzd-ai-cli)
|
|
8
|
-
[](LICENSE)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
|
45
|
-
|
|
46
|
-
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
|
53
|
-
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
|
144
|
-
|
|
145
|
-
| `
|
|
146
|
-
|
|
|
147
|
-
| `
|
|
148
|
-
| `
|
|
149
|
-
| `
|
|
150
|
-
| `
|
|
151
|
-
| `
|
|
152
|
-
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
1
|
+
[English](README.md) | **中文**
|
|
2
|
+
|
|
3
|
+
# ai-cli
|
|
4
|
+
|
|
5
|
+
> 跨平台 AI 编程助手 — CLI 终端、Web 界面、桌面应用三合一,支持 7 大 Provider 与 Agentic 工具调用
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/jinzd-ai-cli)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
[](https://nodejs.org)
|
|
10
|
+
[]()
|
|
11
|
+
[](https://github.com/jinzhengdong/ai-cli/releases)
|
|
12
|
+
|
|
13
|
+
## 特性亮点
|
|
14
|
+
|
|
15
|
+
- **7 大内置 Provider** — Claude、Gemini、DeepSeek、OpenAI、智谱 GLM、Kimi、OpenRouter(300+ 模型)
|
|
16
|
+
- **三种使用方式** — 终端 CLI、浏览器 Web UI(`aicli web`)、Electron 桌面应用
|
|
17
|
+
- **Agentic 工具调用** — AI 自主执行 bash 命令、读写文件、搜索代码、抓取网页、运行测试(每轮最多 25 次)
|
|
18
|
+
- **流式工具调用** — 实时流式展示 AI 推理过程和工具调用
|
|
19
|
+
- **子代理系统** — 将复杂子任务委派给独立子代理执行
|
|
20
|
+
- **深度推理** — Claude Extended Thinking,`/think` 一键切换
|
|
21
|
+
- **规划模式** — `/plan` 进入只读规划,AI 先分析后执行
|
|
22
|
+
- **MCP 协议** — 接入外部 MCP 服务器,动态发现工具
|
|
23
|
+
- **多用户认证** — Web UI 支持多用户密码登录
|
|
24
|
+
- **PWA 支持** — Web UI 可安装为桌面/移动应用,支持局域网访问
|
|
25
|
+
- **三层级上下文** — 全局 / 项目 / 子目录上下文文件自动注入
|
|
26
|
+
- **无头模式** — `aicli -p "提示词"` 用于 CI/CD 管道和脚本
|
|
27
|
+
- **35+ REPL 命令** — 会话管理、检查点、代码审查、脚手架等
|
|
28
|
+
- **跨平台** — Windows、macOS、Linux
|
|
29
|
+
|
|
30
|
+
## 安装
|
|
31
|
+
|
|
32
|
+
### npm 安装(推荐)
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install -g jinzd-ai-cli
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
需要 Node.js >= 20。安装后使用 `aicli` 启动。
|
|
39
|
+
|
|
40
|
+
### Electron 桌面应用(Windows)
|
|
41
|
+
|
|
42
|
+
从 [GitHub Releases](https://github.com/jinzhengdong/ai-cli/releases) 下载安装包,无需 Node.js:
|
|
43
|
+
|
|
44
|
+
| 平台 | 下载 |
|
|
45
|
+
|------|------|
|
|
46
|
+
| Windows x64 | [`ai-cli-setup.exe`](https://github.com/jinzhengdong/ai-cli/releases/latest) |
|
|
47
|
+
|
|
48
|
+
### 独立可执行文件
|
|
49
|
+
|
|
50
|
+
预编译 CLI 二进制(无需 Node.js,约 56 MB):
|
|
51
|
+
|
|
52
|
+
| 平台 | 文件 |
|
|
53
|
+
|------|------|
|
|
54
|
+
| Windows x64 | `ai-cli-win.exe` |
|
|
55
|
+
| macOS arm64 | `ai-cli-mac` |
|
|
56
|
+
| macOS x64 | `ai-cli-mac-x64` |
|
|
57
|
+
| Linux x64 | `ai-cli-linux` |
|
|
58
|
+
|
|
59
|
+
## 快速开始
|
|
60
|
+
|
|
61
|
+
### 终端 CLI
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
aicli
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
首次运行会进入交互式配置向导,选择 Provider 并输入 API Key。配置保存在 `~/.aicli/config.json`。
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
[deepseek] > 你好!帮我分析一下这个项目
|
|
71
|
+
[deepseek] > @src/main.ts 审查这个文件有没有 bug
|
|
72
|
+
[deepseek] > @screenshot.png 这张图片里有什么?
|
|
73
|
+
[deepseek] > /help
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
使用 `@文件路径` 在提示词中引用文件或图片。
|
|
77
|
+
|
|
78
|
+
### Web UI
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
aicli web # 在 localhost:3456 启动
|
|
82
|
+
aicli web --port 8080 # 自定义端口
|
|
83
|
+
aicli web --host 0.0.0.0 # 局域网访问(手机/平板)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
功能:多 Tab 会话、文件树面板、拖拽/粘贴图片、Prompt 模板库、8 套 DaisyUI 主题、PWA 可安装、键盘快捷键、Diff 语法高亮。
|
|
87
|
+
|
|
88
|
+
### 用户管理
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
aicli user create admin # 创建用户(启用认证)
|
|
92
|
+
aicli user list # 列出所有用户
|
|
93
|
+
aicli user reset-password x # 重置密码
|
|
94
|
+
aicli user delete x # 删除用户
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## 支持的 Provider
|
|
98
|
+
|
|
99
|
+
| Provider | 模型 | 获取 API Key |
|
|
100
|
+
|----------|------|-------------|
|
|
101
|
+
| **Claude** | Opus 4, Sonnet 4, Haiku 4 | [console.anthropic.com](https://console.anthropic.com) |
|
|
102
|
+
| **Gemini** | 2.5 Pro, 2.5 Flash | [aistudio.google.com](https://aistudio.google.com) |
|
|
103
|
+
| **DeepSeek** | DeepSeek-Chat (V3), Reasoner (R1) | [platform.deepseek.com](https://platform.deepseek.com) |
|
|
104
|
+
| **OpenAI** | GPT-5.4, GPT-4o, o3, o4-mini | [platform.openai.com](https://platform.openai.com) |
|
|
105
|
+
| **OpenRouter** | 300+ 模型(Claude/GPT/Gemini/Llama/Qwen/Mistral...) | [openrouter.ai](https://openrouter.ai) |
|
|
106
|
+
| **智谱清言** | GLM-4, GLM-5 | [open.bigmodel.cn](https://open.bigmodel.cn) |
|
|
107
|
+
| **Kimi** | Moonshot, Kimi-K2 | [platform.moonshot.cn](https://platform.moonshot.cn) |
|
|
108
|
+
|
|
109
|
+
也可通过 `customBaseUrls` 配置接入任意 OpenAI 兼容 API。
|
|
110
|
+
|
|
111
|
+
## 内置工具(Agentic 能力)
|
|
112
|
+
|
|
113
|
+
AI 在对话中可自主调用 16 个工具:
|
|
114
|
+
|
|
115
|
+
| 工具 | 安全级别 | 说明 |
|
|
116
|
+
|------|---------|------|
|
|
117
|
+
| `bash` | 动态判断 | 执行 shell 命令(Windows: PowerShell,Unix: $SHELL) |
|
|
118
|
+
| `read_file` | 安全 | 读取文件内容(10 MB 限制,支持图片) |
|
|
119
|
+
| `write_file` | 写入 | 创建/覆盖文件(diff 预览 + 确认) |
|
|
120
|
+
| `edit_file` | 写入 | 精确字符串替换,模糊匹配提示 |
|
|
121
|
+
| `list_dir` | 安全 | 列出目录内容 |
|
|
122
|
+
| `grep_files` | 安全 | 正则搜索文件内容 |
|
|
123
|
+
| `glob_files` | 安全 | 按 glob 模式匹配文件 |
|
|
124
|
+
| `web_fetch` | 安全 | 抓取网页转 Markdown(防 SSRF) |
|
|
125
|
+
| `google_search` | 安全 | Google 自定义搜索 |
|
|
126
|
+
| `run_interactive` | 安全 | 运行交互式程序并输入 |
|
|
127
|
+
| `run_tests` | 安全 | 自动检测并运行测试(JUnit XML 解析) |
|
|
128
|
+
| `spawn_agent` | 安全 | 委派子任务给隔离子代理 |
|
|
129
|
+
| `ask_user` | 安全 | 暂停并向用户提问 |
|
|
130
|
+
| `save_memory` | 安全 | 跨会话持久化重要信息 |
|
|
131
|
+
| `write_todos` | 安全 | 任务拆解,终端实时渲染进度 |
|
|
132
|
+
| `save_last_response` | 写入 | 保存 AI 回复到文件 |
|
|
133
|
+
|
|
134
|
+
**安全级别**:`安全` = 自动执行,`写入` = diff 预览 + 确认,`破坏性` = 醒目警告 + 确认。
|
|
135
|
+
|
|
136
|
+
## 主要 REPL 命令
|
|
137
|
+
|
|
138
|
+
| 命令 | 说明 |
|
|
139
|
+
|------|------|
|
|
140
|
+
| `/provider` | 切换 AI Provider |
|
|
141
|
+
| `/model` | 切换模型 |
|
|
142
|
+
| `/plan` | 进入只读规划模式 |
|
|
143
|
+
| `/think` | 切换 Claude 深度推理 |
|
|
144
|
+
| `/test` | 自动检测并运行测试 |
|
|
145
|
+
| `/review` | AI 代码审查 git diff |
|
|
146
|
+
| `/scaffold <描述>` | AI 生成项目骨架 |
|
|
147
|
+
| `/init` | AI 生成项目上下文文件 |
|
|
148
|
+
| `/compact` | 压缩对话历史 |
|
|
149
|
+
| `/session` | 会话管理(new / list / load) |
|
|
150
|
+
| `/checkpoint` | 保存/恢复会话检查点 |
|
|
151
|
+
| `/fork` | 从当前位置或检查点分叉对话 |
|
|
152
|
+
| `/search <关键词>` | 跨会话全文搜索 |
|
|
153
|
+
| `/skill` | 管理 Agent 技能包 |
|
|
154
|
+
| `/mcp` | 查看 MCP 服务器状态 |
|
|
155
|
+
| `/cost` | 显示 Token 用量统计 |
|
|
156
|
+
| `/undo` | 撤销上次文件操作 |
|
|
157
|
+
| `/doctor` | 健康检查(API Key、MCP、上下文) |
|
|
158
|
+
| `/export` | 导出会话为 Markdown 或 JSON |
|
|
159
|
+
| `/config` | 打开配置向导 |
|
|
160
|
+
| `/help` | 显示所有命令 |
|
|
161
|
+
|
|
162
|
+
完整命令参考见 [使用说明](USAGE.md)。
|
|
163
|
+
|
|
164
|
+
## CLI 参数
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
aicli [选项]
|
|
168
|
+
|
|
169
|
+
选项:
|
|
170
|
+
--provider <名称> 设置 AI Provider
|
|
171
|
+
-m, --model <名称> 设置模型
|
|
172
|
+
-p, --prompt <文本> 无头模式:单次提问后退出
|
|
173
|
+
--system <提示词> 覆盖 system prompt
|
|
174
|
+
--json 输出 JSON(无头模式)
|
|
175
|
+
--output-format <格式> text | streaming-json (NDJSON)
|
|
176
|
+
--resume <id> 恢复之前的会话
|
|
177
|
+
--allowed-tools <列表> 逗号分隔的工具白名单
|
|
178
|
+
--blocked-tools <列表> 逗号分隔的工具黑名单
|
|
179
|
+
--no-stream 禁用流式输出
|
|
180
|
+
|
|
181
|
+
子命令:
|
|
182
|
+
aicli web [选项] 启动 Web UI 服务器
|
|
183
|
+
aicli config 运行配置向导
|
|
184
|
+
aicli providers 列出所有 Provider
|
|
185
|
+
aicli sessions 列出最近会话
|
|
186
|
+
aicli user <操作> 管理 Web UI 用户
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### 无头模式
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
# 单次提问
|
|
193
|
+
aicli -p "用一句话解释递归"
|
|
194
|
+
|
|
195
|
+
# 管道输入
|
|
196
|
+
cat src/main.ts | aicli -p "审查这段代码"
|
|
197
|
+
|
|
198
|
+
# JSON 输出用于脚本
|
|
199
|
+
aicli -p "hello" --json
|
|
200
|
+
|
|
201
|
+
# 流式 JSON (NDJSON)
|
|
202
|
+
aicli -p "写一首诗" --output-format streaming-json
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## 配置
|
|
206
|
+
|
|
207
|
+
配置文件位于 `~/.aicli/config.json`。运行 `aicli config` 打开交互式向导,或直接编辑:
|
|
208
|
+
|
|
209
|
+
```json
|
|
210
|
+
{
|
|
211
|
+
"defaultProvider": "deepseek",
|
|
212
|
+
"apiKeys": {
|
|
213
|
+
"deepseek": "sk-...",
|
|
214
|
+
"claude": "sk-ant-...",
|
|
215
|
+
"openrouter": "sk-or-..."
|
|
216
|
+
},
|
|
217
|
+
"proxy": "http://127.0.0.1:10809",
|
|
218
|
+
"mcpServers": { },
|
|
219
|
+
"ui": {
|
|
220
|
+
"theme": "dark",
|
|
221
|
+
"wordWrap": 0,
|
|
222
|
+
"notificationThreshold": 10000
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### 代理配置(国内用户)
|
|
228
|
+
|
|
229
|
+
Gemini、Claude 等在国内需要代理:
|
|
230
|
+
|
|
231
|
+
**方式一:配置文件(持久)**
|
|
232
|
+
```json
|
|
233
|
+
{
|
|
234
|
+
"proxy": "http://127.0.0.1:10809"
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
运行 `aicli config` → 选择 `Configure proxy` 即可配置。
|
|
239
|
+
|
|
240
|
+
**方式二:环境变量(临时)**
|
|
241
|
+
```bash
|
|
242
|
+
# Windows
|
|
243
|
+
set HTTPS_PROXY=http://127.0.0.1:10809
|
|
244
|
+
aicli
|
|
245
|
+
|
|
246
|
+
# macOS / Linux
|
|
247
|
+
HTTPS_PROXY=http://127.0.0.1:10809 aicli
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### 环境变量
|
|
251
|
+
|
|
252
|
+
| 变量 | 说明 |
|
|
253
|
+
|------|------|
|
|
254
|
+
| `AICLI_API_KEY_CLAUDE` | Claude API Key |
|
|
255
|
+
| `AICLI_API_KEY_GEMINI` | Gemini API Key |
|
|
256
|
+
| `AICLI_API_KEY_DEEPSEEK` | DeepSeek API Key |
|
|
257
|
+
| `AICLI_API_KEY_OPENAI` | OpenAI API Key |
|
|
258
|
+
| `AICLI_API_KEY_OPENROUTER` | OpenRouter API Key |
|
|
259
|
+
| `AICLI_API_KEY_ZHIPU` | 智谱 API Key |
|
|
260
|
+
| `AICLI_API_KEY_KIMI` | Kimi API Key |
|
|
261
|
+
| `AICLI_PROVIDER` | 默认 Provider |
|
|
262
|
+
| `AICLI_NO_STREAM` | 设为 `1` 禁用流式输出 |
|
|
263
|
+
| `HTTPS_PROXY` / `HTTP_PROXY` | 代理地址 |
|
|
264
|
+
|
|
265
|
+
### 三层级上下文文件
|
|
266
|
+
|
|
267
|
+
ai-cli 自动发现并注入上下文文件到 system prompt:
|
|
268
|
+
|
|
269
|
+
| 层级 | 路径 | 用途 |
|
|
270
|
+
|------|------|------|
|
|
271
|
+
| 全局层 | `~/.aicli/AICLI.md` | 所有项目通用的个人偏好 |
|
|
272
|
+
| 项目层 | `<git-root>/AICLI.md` | 项目级规则(提交到 git 供团队共享) |
|
|
273
|
+
| 子目录层 | `<cwd>/AICLI.md` | 当前子目录的特定指令 |
|
|
274
|
+
|
|
275
|
+
每层也支持 `CLAUDE.md` 作为备选文件名。
|
|
276
|
+
|
|
277
|
+
### MCP 集成
|
|
278
|
+
|
|
279
|
+
接入外部 [MCP](https://modelcontextprotocol.io/) 服务器,动态发现工具。配置格式兼容 Claude Desktop:
|
|
280
|
+
|
|
281
|
+
```json
|
|
282
|
+
{
|
|
283
|
+
"mcpServers": {
|
|
284
|
+
"filesystem": {
|
|
285
|
+
"command": "npx",
|
|
286
|
+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path"],
|
|
287
|
+
"timeout": 30000
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
支持项目级 `.mcp.json`,与全局配置自动合并。
|
|
294
|
+
|
|
295
|
+
## Web UI 功能
|
|
296
|
+
|
|
297
|
+
Web UI(`aicli web`)提供功能完备的浏览器界面:
|
|
298
|
+
|
|
299
|
+
- **多 Tab 会话** — 多个浏览器标签页并行对话
|
|
300
|
+
- **文件树面板** — 浏览项目目录,点击插入 `@path` 引用
|
|
301
|
+
- **图片上传** — 拖拽或 Ctrl+V 粘贴图片到聊天
|
|
302
|
+
- **Prompt 模板库** — CRUD + 标签 + 搜索 + 导入导出
|
|
303
|
+
- **8 套主题** — DaisyUI 主题,代码高亮自动联动
|
|
304
|
+
- **Diff 语法高亮** — 工具确认对话框中彩色 diff
|
|
305
|
+
- **键盘快捷键** — `Esc` 停止、`Ctrl+L` 清屏、`↑↓` 历史
|
|
306
|
+
- **导出** — `/export md` 或 `/export json` 浏览器下载
|
|
307
|
+
- **PWA** — 可安装为桌面/移动应用
|
|
308
|
+
- **局域网访问** — `--host 0.0.0.0` 供手机/平板访问
|
|
309
|
+
- **多用户认证** — 密码认证 + 用户数据隔离
|
|
310
|
+
- **自动重连** — 心跳 + 指数退避重连
|
|
311
|
+
|
|
312
|
+
## 测试
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
npm test # 运行全部 138 个测试
|
|
316
|
+
npm run test:watch # 监听模式
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
8 个测试套件覆盖:认证、会话、工具类型与危险级别、权限、输出截断、diff 渲染、edit-file 相似度、错误层级。
|
|
320
|
+
|
|
321
|
+
## 文档
|
|
322
|
+
|
|
323
|
+
- [完整使用说明](USAGE.md) — 所有功能的详细参考
|
|
324
|
+
- [English README](README.md) — English documentation
|
|
325
|
+
|
|
326
|
+
## License
|
|
327
|
+
|
|
328
|
+
[MIT](LICENSE)
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
SUBAGENT_MAX_ROUNDS_LIMIT,
|
|
17
17
|
VERSION,
|
|
18
18
|
runTestsTool
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-2WCLXWAH.js";
|
|
20
20
|
|
|
21
21
|
// src/config/config-manager.ts
|
|
22
22
|
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
|
|
@@ -2704,11 +2704,14 @@ Important rules:
|
|
|
2704
2704
|
1. Each bash call runs in an independent subprocess; cd commands do not persist. To run in a specific directory, use the cwd parameter, or combine commands: e.g. "cd mydir; ls" or "mkdir mydir; cd mydir; New-Item file.txt".
|
|
2705
2705
|
2. If a command fails (returns an error or non-zero exit code), stop immediately, report the error to the user, and do not retry the same or similar commands.
|
|
2706
2706
|
3. Multiple commands can be combined with semicolons in a single call to reduce rounds.
|
|
2707
|
-
4. To delete directories, use Remove-Item -Recurse (the system will automatically optimize to a more reliable method)
|
|
2707
|
+
4. To delete directories, use Remove-Item -Recurse (the system will automatically optimize to a more reliable method).
|
|
2708
|
+
5. IMPORTANT: On Windows, "curl" is an alias for Invoke-WebRequest and does NOT support curl flags like -s, -X, -H. Use Invoke-RestMethod instead for HTTP requests. Example: Invoke-RestMethod -Uri "http://localhost:3000/api/health" -Method Get
|
|
2709
|
+
6. For long-running server commands (node server.js, npm run dev, etc.), use Start-Process -NoNewWindow to run in background, otherwise the tool will block until timeout.` : `Execute commands in ${SHELL}.
|
|
2708
2710
|
Important rules:
|
|
2709
2711
|
1. Each bash call runs in an independent subprocess; cd commands do not persist. To run in a specific directory, use the cwd parameter, or combine commands: e.g. "cd mydir && ls" or "mkdir -p mydir && touch mydir/file.txt".
|
|
2710
2712
|
2. If a command fails (returns an error or non-zero exit code), stop immediately, report the error to the user, and do not retry the same or similar commands.
|
|
2711
|
-
3. Multiple commands can be combined with && in a single call to reduce rounds
|
|
2713
|
+
3. Multiple commands can be combined with && in a single call to reduce rounds.
|
|
2714
|
+
4. For long-running server commands (node server.js, npm start, npm run dev, etc.), run in background with & or nohup, otherwise the tool will block until timeout.`,
|
|
2712
2715
|
parameters: {
|
|
2713
2716
|
command: {
|
|
2714
2717
|
type: "string",
|
|
@@ -3228,10 +3231,11 @@ var editFileTool = {
|
|
|
3228
3231
|
definition: {
|
|
3229
3232
|
name: "edit_file",
|
|
3230
3233
|
description: `Precisely edit file contents. Supports three modes:
|
|
3231
|
-
1. String replace (most common): Provide old_str and new_str to replace an exact match. old_str must appear exactly once in the file.
|
|
3234
|
+
1. String replace (most common): Provide old_str and new_str to replace an exact match. old_str must appear exactly once in the file (unless replace_all is true).
|
|
3232
3235
|
2. Line insert: Provide insert_after_line (1-based line number) and insert_content to insert after that line.
|
|
3233
3236
|
3. Line delete: Provide delete_from_line and delete_to_line (inclusive) to delete that range.
|
|
3234
3237
|
Optional ignore_whitespace: true to match ignoring indentation differences.
|
|
3238
|
+
Optional replace_all: true to replace ALL occurrences of old_str in the file at once (saves tool rounds when renaming variables/functions).
|
|
3235
3239
|
Note: Path can be absolute or relative to the current working directory.`,
|
|
3236
3240
|
parameters: {
|
|
3237
3241
|
path: {
|
|
@@ -3254,6 +3258,11 @@ Note: Path can be absolute or relative to the current working directory.`,
|
|
|
3254
3258
|
description: "[Replace mode] Whether to ignore leading/trailing whitespace per line when matching, defaults to false",
|
|
3255
3259
|
required: false
|
|
3256
3260
|
},
|
|
3261
|
+
replace_all: {
|
|
3262
|
+
type: "boolean",
|
|
3263
|
+
description: "[Replace mode] Replace ALL occurrences of old_str instead of requiring unique match. Useful for renaming variables/functions across the file in one call.",
|
|
3264
|
+
required: false
|
|
3265
|
+
},
|
|
3257
3266
|
insert_after_line: {
|
|
3258
3267
|
type: "number",
|
|
3259
3268
|
description: "[Insert mode] Insert after this line number (1-based), 0 means insert at the beginning",
|
|
@@ -3293,6 +3302,7 @@ Note: Path can be absolute or relative to the current working directory.`,
|
|
|
3293
3302
|
const oldStr = String(args["old_str"]);
|
|
3294
3303
|
const newStr = String(args["new_str"] ?? "");
|
|
3295
3304
|
const ignoreWs = Boolean(args["ignore_whitespace"]);
|
|
3305
|
+
const replaceAll = Boolean(args["replace_all"]);
|
|
3296
3306
|
if (oldStr === "") throw new Error("old_str cannot be empty");
|
|
3297
3307
|
if (ignoreWs) {
|
|
3298
3308
|
const fileLines = original.split("\n");
|
|
@@ -3320,6 +3330,23 @@ Please read the file first and use exact text.`;
|
|
|
3320
3330
|
Replaced: ${searchLines.length} line(s) \u2192 ${newStr.split("\n").length} line(s)
|
|
3321
3331
|
Old: ${truncatePreview(oldStr)}
|
|
3322
3332
|
New: ${truncatePreview(newStr)}`;
|
|
3333
|
+
}
|
|
3334
|
+
if (replaceAll) {
|
|
3335
|
+
const occurrences = original.split(oldStr).length - 1;
|
|
3336
|
+
if (occurrences === 0) {
|
|
3337
|
+
const similar = findSimilarLines(original, oldStr);
|
|
3338
|
+
const hint = similar.length > 0 ? `
|
|
3339
|
+
Similar lines found (did you mean?):
|
|
3340
|
+
${similar.join("\n")}` : "";
|
|
3341
|
+
return `ERROR: old_str not found in file.${hint}
|
|
3342
|
+
Please read the file first and use exact text.`;
|
|
3343
|
+
}
|
|
3344
|
+
undoStack.push(filePath, `edit_file (replace_all): ${filePath}`);
|
|
3345
|
+
const updated2 = original.split(oldStr).join(newStr);
|
|
3346
|
+
writeFileSync5(filePath, updated2, encoding);
|
|
3347
|
+
return `Successfully edited ${filePath} (replace_all)
|
|
3348
|
+
Replaced: ${occurrences} occurrence(s) of ${truncatePreview(oldStr)}
|
|
3349
|
+
With: ${truncatePreview(newStr)}`;
|
|
3323
3350
|
}
|
|
3324
3351
|
const firstIndex = original.indexOf(oldStr);
|
|
3325
3352
|
if (firstIndex === -1) {
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
theme,
|
|
36
36
|
truncateOutput,
|
|
37
37
|
undoStack
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-HTXJ23TX.js";
|
|
39
39
|
import {
|
|
40
40
|
AGENTIC_BEHAVIOR_GUIDELINE,
|
|
41
41
|
AUTHOR,
|
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
REPO_URL,
|
|
56
56
|
SKILLS_DIR_NAME,
|
|
57
57
|
VERSION
|
|
58
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-2WCLXWAH.js";
|
|
59
59
|
|
|
60
60
|
// src/index.ts
|
|
61
61
|
import { program } from "commander";
|
|
@@ -1904,7 +1904,7 @@ ${hint}` : "")
|
|
|
1904
1904
|
description: "Run project tests and show structured report",
|
|
1905
1905
|
usage: "/test [command|filter]",
|
|
1906
1906
|
async execute(args, _ctx) {
|
|
1907
|
-
const { executeTests } = await import("./run-tests-
|
|
1907
|
+
const { executeTests } = await import("./run-tests-L5G4W7EB.js");
|
|
1908
1908
|
const argStr = args.join(" ").trim();
|
|
1909
1909
|
let testArgs = {};
|
|
1910
1910
|
if (argStr) {
|
|
@@ -5292,7 +5292,7 @@ program.command("web").description("Start Web UI server with browser-based chat
|
|
|
5292
5292
|
console.error("Error: Invalid port number. Must be between 1 and 65535.");
|
|
5293
5293
|
process.exit(1);
|
|
5294
5294
|
}
|
|
5295
|
-
const { startWebServer } = await import("./server-
|
|
5295
|
+
const { startWebServer } = await import("./server-N2LG3A4M.js");
|
|
5296
5296
|
await startWebServer({ port, host: options.host });
|
|
5297
5297
|
});
|
|
5298
5298
|
program.command("user [action] [username]").description("Manage Web UI users (list | create <name> | delete <name> | reset-password <name> | migrate <name>)").action(async (action, username) => {
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
setupProxy,
|
|
24
24
|
spawnAgentContext,
|
|
25
25
|
truncateOutput
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-HTXJ23TX.js";
|
|
27
27
|
import {
|
|
28
28
|
AGENTIC_BEHAVIOR_GUIDELINE,
|
|
29
29
|
CONTEXT_FILE_CANDIDATES,
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
PLAN_MODE_SYSTEM_ADDON,
|
|
36
36
|
SKILLS_DIR_NAME,
|
|
37
37
|
VERSION
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-2WCLXWAH.js";
|
|
39
39
|
import {
|
|
40
40
|
AuthManager
|
|
41
41
|
} from "./chunk-CPLT6CD3.js";
|