ace-tool-windows 0.2.4 → 0.2.6

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 CHANGED
@@ -1,266 +1,243 @@
1
- # ace-tool-windows
2
-
3
- Rust + Win32 MCP Server(stdio),提供 `search_context` 与 `enhance_prompt`,用原生 Win32 GUI 替代浏览器交互。
4
- ![alt text](image.png)
5
-
6
- > 原项目:https://github.com/eastxiaodong/ace-tool
7
-
8
- ## 快速开始
9
-
10
- ### 1) 安装
11
-
12
- ```powershell
13
- npm i -g ace-tool-windows
14
- ```
15
-
16
- ### 2) 直接运行(本地验证)
17
-
18
- ```powershell
19
- ace-tool-win --base-url <URL> --token <TOKEN> [--enable-log]
20
- ```
21
-
22
- ### 3) 配置为 MCP Server
23
-
24
- > 不同 MCP 客户端字段名可能是 `mcpServers` 或 `servers`,以客户端文档为准。
25
-
26
- **mcpServers 格式(常见)**
27
-
28
- ```json
29
- {
30
- "mcpServers": {
31
- "ace-tool-windows": {
32
- "command": "ace-tool-win",
33
- "args": ["--base-url", "https://acemcp.heroman.wtf/relay/", "--token", "<TOKEN>"]
34
- }
35
- }
36
- }
37
- ```
38
-
39
- **使用本地 exe 路径**
40
-
41
- ```json
42
- {
43
- "mcpServers": {
44
- "ace-tool-windows": {
45
- "command": "C:\\path\\to\\ace-tool-win.exe",
46
- "args": ["--base-url", "<URL>", "--token", "<TOKEN>"]
47
- }
48
- }
49
- }
50
- ```
51
-
52
- **servers 格式(兼容模式)**
53
-
54
- ```json
55
- {
56
- "servers": {
57
- "ace-tool-windows": {
58
- "command": "ace-tool-win",
59
- "args": ["--base-url", "<URL>", "--token", "<TOKEN>"]
60
- }
61
- }
62
- }
63
- ```
64
-
65
- ### 常见客户端配置示例
66
-
67
- 以下仅展示配置片段,具体放置位置以对应客户端文档为准。
68
-
69
- **Claude Code**
70
-
71
- ```json
72
- {
73
- "mcpServers": {
74
- "ace-tool-windows": {
75
- "command": "ace-tool-win",
76
- "args": ["--base-url", "https://acemcp.heroman.wtf/relay/", "--token", "<TOKEN>"]
77
- }
78
- }
79
- }
80
- ```
81
-
82
- **Codex CLI(codex)**
83
-
84
- ```toml
85
- [mcpServers."ace-tool-windows"]
86
- command = "ace-tool-win"
87
- args = ["--base-url", "https://acemcp.heroman.wtf/relay/", "--token", "<TOKEN>"]
88
- ```
89
-
90
- 配置完成后,在 AI CLI 中输入 `xxxxx -enhancer` 即可触发 `enhance_prompt`(同样支持 `-enhancer`)。
91
-
92
- ## 项目简介
93
-
94
- 本仓库是 ace-tool 的 Rust + Win32 重写版本,目标与 Node 版本功能 1:1 对齐,同时保持 MCP stdio 兼容,供 Codex / MCP 客户端调用。
95
-
96
- ## 功能特性
97
-
98
- - MCP JSON-RPC over stdio,支持工具列举与调用
99
- - `search_context`:索引 + 检索代码库上下文
100
- - `enhance_prompt`:调用远端增强服务,支持中文/英文自动判断
101
- - Win32 GUI 交互窗口,提供继续增强 / 使用原始 / 结束对话
102
- - 本地索引与日志输出(`.ace-tool/`)
103
-
104
- ## 环境要求
105
-
106
- - Windows 10/11(Win32 GUI)
107
- - Rust 工具链(建议稳定版)
108
- - Node.js + npm(用于发布到 npm)
109
-
110
- ## 配置说明
111
-
112
- ### CLI 参数
113
-
114
- - `--base-url` 必填,服务地址;未写协议会自动补 `https://`
115
- - `--token` 必填,ACE 服务 Token(在 https://acemcp.heroman.wtf 获取)
116
- - `--enable-log` 可选,写入 `.ace-tool/ace-tool.log`
117
-
118
- ### 环境变量(可选)
119
-
120
- - `ACE_TOOL_HEADLESS=1`:跳过 UI,直接返回增强结果
121
- - `ACE_TOOL_HEADLESS_ACTION=enhanced|end|timeout`:headless 模式返回策略,默认 enhanced
122
- - `ACE_TOOL_DEBUG=1`:输出 MCP 调试日志(stderr + 文件)
123
- - `ACE_TOOL_DEBUG_VERBOSE=1`:输出更详细的帧解析日志
124
- - `ACE_TOOL_DEBUG_FILE=<path>`:调试日志路径,默认 `%TEMP%\\ace-tool-mcp.log`
125
-
126
- ### 超时规则(重要)
127
-
128
- - 本项目默认不提供自定义超时参数。
129
- - MCP 调用超时以客户端(Codex)配置为准,例如 `tool_timeout_sec` / `startup_timeout_sec`。
130
- - 如需调整,请在 Codex 客户端配置中修改,不建议在服务端再做一套超时逻辑。
131
-
132
- ## MCP 工具说明
133
-
134
- ### search_context
135
-
136
- - 传入项目根路径与检索 query
137
- - 自动进行索引(`.ace-tool/index.json`)
138
- - 调用 `/agents/codebase-retrieval` 返回 formatted_retrieval
139
-
140
- ### enhance_prompt
141
-
142
- - 调用 `/prompt-enhancer`
143
- - 语言检测:中文输入 -> 中文输出;英文输入 -> 英文输出
144
- - 工具名映射:`codebase-retrieval` -> `search_context`
145
- - 8 分钟超时回退到原始 prompt
146
- - 默认弹 Win32 窗口,等待用户点击后返回
147
- - 如需无 UI,可设置 `ACE_TOOL_HEADLESS=1`
148
-
149
- ## 从源码运行
150
-
151
- ```powershell
152
- # 在仓库根目录
153
- cargo run -- --base-url <URL> --token <TOKEN> [--enable-log]
154
- ```
155
-
156
- ## npm 打包与发布
157
-
158
- 构建 + 拷贝 exe:
159
-
160
- ```powershell
161
- npm run build:bin
162
- ```
163
-
164
- 本地打包验证:
165
-
166
- ```powershell
167
- npm run pack:local
168
- ```
169
-
170
- 发布到 npm(首次需登录):
171
-
172
- ```powershell
173
- npm publish --access public
174
- ```
175
-
176
- ## 项目结构
177
-
178
- ```text
179
- ace-tool-windows/
180
- - Cargo.toml
181
- - package.json
182
- - README.md
183
- - src/
184
- - main.rs
185
- - mcp/
186
- - index/
187
- - enhancer/
188
- - ui/
189
- - utils/
190
- - tests/
191
- ```
192
-
193
- ## 对齐清单(Node 版本)
194
-
195
- ### MCP 协议
196
- - [ ] 基于 stdio 的 JSON-RPC
197
- - [ ] ListTools 返回 search_context + enhance_prompt schema
198
- - [ ] CallTool 按名称分发并返回 content[].text
199
- - [ ] MCP logging 通道推送(level + data)
200
-
201
- ### CLI / 配置
202
- - [ ] 必填参数:--base-url、--token
203
- - [ ] 可选参数:--enable-log
204
- - [ ] base_url 自动规范化(必须 https,去掉末尾 /)
205
-
206
- ### 项目数据
207
- - [ ] 项目根目录创建 .ace-tool/
208
- - [ ] index.json 写入 .ace-tool/
209
- - [ ] --enable-log 时写入 ace-tool.log
210
- - [ ] .ace-tool 自动加入 .gitignore
211
-
212
- ### search_context 工具
213
- - [ ] project_root_path / query 输入校验
214
- - [ ] 路径统一为正斜杠
215
- - [ ] 目录存在性与类型检查
216
- - [ ] 检索前自动索引
217
- - [ ] POST {baseUrl}/agents/codebase-retrieval
218
- - [ ] 返回 formatted_retrieval 或友好错误信息
219
-
220
- ### 索引行为
221
- - [ ] 默认文本后缀与排除规则与 Node 一致
222
- - [ ] 读取编码兜底(utf-8、gbk、gb2312、latin1)
223
- - [ ] 二进制内容检测并跳过
224
- - [ ] 清洗控制字符
225
- - [ ] 按 maxLinesPerBlob 分片(默认 800)
226
- - [ ] Blob 名称 hash:SHA-256(path + content)
227
- - [ ] MAX_BLOB_SIZE:单 blob 500KB
228
- - [ ] MAX_BATCH_SIZE:单批 5MB
229
- - [ ] 基于 index.json 的增量索引
230
- - [ ] 按 blob 数量自适应上传策略(batch size + 并发)
231
- - [ ] 指数退避重试 + 友好错误映射
232
-
233
- ### enhance_prompt 工具
234
- - [ ] POST {baseUrl}/prompt-enhancer(payload 含 nodes/chat_history/blobs)
235
- - [ ] 语言检测(中文输入 -> 中文输出;英文输入 -> 英文输出)
236
- - [ ] 工具名映射:codebase-retrieval -> search_context
237
- - [ ] 8 分钟超时并回退到原始 prompt
238
-
239
- ### Win32 UI(替代浏览器 UI)
240
- - [ ] 四个动作:发送增强 / 使用原始 / 继续增强 / 结束对话
241
- - [ ] Session 状态:pending / completed / timeout
242
- - [ ] UI 与增强流程通过通道协作
243
-
244
- ### 错误提示
245
- - [ ] Token 无效(401)/ 访问被拒绝(403)
246
- - [ ] SSL 错误 / 非 https / DNS / 超时 / 连接被拒绝
247
- - [ ] 路径不存在 / 非目录 / 空索引
248
-
249
- ### 日志格式
250
- - [ ] MCP logging 推送(level + data)
251
- - [ ] 文件日志行格式:"YYYY-MM-DD HH:MM:SS | LEVEL | message"
252
- - [ ] 新日志流写入 Session 分隔符
253
-
254
- ## 测试
255
-
256
- ```powershell
257
- cargo test
258
- ```
259
-
260
- ## License
261
-
1
+ # ace-tool-windows
2
+
3
+ Windows 平台的 ACE MCP Server(Rust + Win32,stdio 模式),提供 `search_context` 与 `enhance_prompt`。
4
+
5
+ > 原项目:<https://github.com/eastxiaodong/ace-tool>
6
+
7
+ ## 1. 安装
8
+
9
+ ```powershell
10
+ npm i -g ace-tool-windows
11
+ ```
12
+
13
+ ## 2. 获取 Token
14
+
15
+ 在 <https://acemcp.heroman.wtf> 生成并复制 `token`。
16
+
17
+ 建议:
18
+ - 不要把 token 提交到 Git 仓库。
19
+ - 优先通过环境变量或本地 MCP 配置注入。
20
+ - 即便使用 `codex` provider,`search_context` 仍依赖远端服务,必须配置 token。
21
+
22
+ ## 3. 本地快速验证
23
+
24
+ 远端增强(`remote`,默认):
25
+
26
+ ```powershell
27
+ ace-tool-win --base-url https://acemcp.heroman.wtf/relay/ --token <YOUR_TOKEN>
28
+ ```
29
+
30
+ 本地 Codex 增强(需要已安装可执行的 `codex` CLI):
31
+
32
+ ```powershell
33
+ ace-tool-win --base-url https://acemcp.heroman.wtf/relay/ --token <YOUR_TOKEN> --provider codex --codex-cmd codex
34
+ ```
35
+
36
+ 可选参数:
37
+ - `--enable-log`:写入项目 `.ace-tool/ace-tool.log`
38
+ - `--provider remote|codex`:默认 `remote`
39
+ - `--codex-cmd codex`:Codex 命令,支持绝对路径
40
+ - `--codex-reasoning-effort <none|minimal|low|medium|high|xhigh>`:Codex 推理强度,默认 `low`
41
+ - `--enhance-timeout-sec 90`:增强调用超时(10-600 秒);未显式配置时 `remote` 默认 90 秒,`codex` 默认 180 秒
42
+
43
+ Windows 说明:
44
+ - 当前版本不会写死单一路径:`args.codex_cmd` > 启动参数/环境变量 > 默认 `codex`,再按“直接路径 -> PATH 查找 -> Windows 常见位置(Volta/npm)”解析可执行文件。
45
+ - 调用 Codex 时默认附加 `-c "mcp_servers.mcp-router.enabled=false"`,避免 Codex 内部 `mcp-router` 启动抖动影响首轮增强。
46
+ - Codex 超时时会自动降级重试一次 `reasoning_effort=none`(仅在首轮超时时触发)。
47
+ - `--ui-timeout-sec 480`:UI 会话超时(30-3600 秒)
48
+ - UI 窗口支持自适应布局(拖拽/缩放窗口时,编辑区与按钮区域会自动重排)。
49
+
50
+ ## 4. 配置为 MCP Server
51
+
52
+ ### 通用 JSON(mcpServers)
53
+
54
+ ```json
55
+ {
56
+ "mcpServers": {
57
+ "ace-tool-windows": {
58
+ "command": "ace-tool-win",
59
+ "args": [
60
+ "--base-url", "https://acemcp.heroman.wtf/relay/",
61
+ "--token", "<YOUR_TOKEN>",
62
+ "--provider", "remote"
63
+ ]
64
+ }
65
+ }
66
+ }
67
+ ```
68
+
69
+ ### Claude Code(JSON)
70
+
71
+ ```json
72
+ {
73
+ "mcpServers": {
74
+ "ace-tool-windows": {
75
+ "command": "ace-tool-win",
76
+ "args": [
77
+ "--base-url", "https://acemcp.heroman.wtf/relay/",
78
+ "--token", "<YOUR_TOKEN>",
79
+ "--provider", "remote"
80
+ ]
81
+ }
82
+ }
83
+ }
84
+ ```
85
+
86
+ ### Codex CLI(TOML)
87
+
88
+ ```toml
89
+ [mcpServers."ace-tool-windows"]
90
+ command = "ace-tool-win"
91
+ args = [
92
+ "--base-url", "https://acemcp.heroman.wtf/relay/",
93
+ "--token", "<YOUR_TOKEN>",
94
+ "--provider", "remote"
95
+ ]
96
+ ```
97
+
98
+ 如果使用 `codex` provider,请在 `args` 中追加:
99
+ - `--provider`, `codex`
100
+ - `--codex-cmd`, `<codex 可执行路径或命令>`
101
+
102
+ ## 5. Provider 选择(remote / codex)
103
+
104
+ 优先级:
105
+ 1. 启动参数 `--provider` / 环境变量
106
+ 2. 默认 `remote`
107
+ 3. `enhance_prompt` 调用参数 `provider` 只做一致性校验,不用于切换
108
+
109
+ 注意:
110
+ - 仅 `enhance_prompt` 使用 provider 配置;`search_context` 始终使用远端。
111
+ - `provider` 只允许 `remote` / `codex`,非法值会导致启动报错。
112
+ - 请求级 `provider` 不允许与启动 provider 不一致;不一致会直接报错并拒绝执行(默认强约束,避免会话中途切到 remote)。
113
+ - `codex` provider 需要本地 `codex` CLI 可执行(可用 `--codex-cmd` 指定路径)。
114
+ - `codex_cmd` 不是固定绝对路径,默认会按当前机器环境自动解析;跨设备建议先用 `codex`,失败再改绝对路径。
115
+
116
+ `enhance_prompt` 示例(可选 `provider`):
117
+
118
+ ```json
119
+ {
120
+ "prompt": "为当前项目添加登录功能 -enhance",
121
+ "conversation_history": "User: ...\nAssistant: ...",
122
+ "project_root_path": "F:/GitlabProjects/ace-tool-windows",
123
+ "provider": "codex",
124
+ "codex_cmd": "C:/Users/X1/AppData/Local/Volta/bin/codex"
125
+ }
126
+ ```
127
+
128
+ 说明:
129
+ - `codex_cmd` `enhance_prompt` 的可选外部覆盖参数,优先级高于启动参数和环境变量。
130
+ - 用户输入里的触发后缀(`-enhance` / `-enhancer`)会在增强前自动剥离,不会进入最终增强文本。
131
+
132
+ ## 6. 在 AI CLI 中触发增强
133
+
134
+ 配置好 MCP 后,输入包含 `-enhance` 或 `-enhancer` 的请求即可触发 `enhance_prompt`。
135
+
136
+ 示例:
137
+
138
+ ```text
139
+ 为当前项目的代码添加详细注释 -enhance
140
+ ```
141
+
142
+ 补充:
143
+ - 增强文本默认遵循“语义自适应”的排版策略:优先保留原语义并细化细节;可用分段/小标题/列表提升可读性,但不强制固定模板。
144
+ - 当前工具名同时支持 `enhance_prompt` `enhancer`(别名),用于提高不同客户端的工具路由命中率。
145
+
146
+ ## 7. 常用环境变量
147
+
148
+ - `ACE_TOOL_ENHANCE_PROVIDER=remote|codex`
149
+ - `ACE_TOOL_CODEX_CMD=codex`
150
+ - `ACE_TOOL_CODEX_REASONING_EFFORT=low`
151
+ - `ACE_TOOL_ENHANCE_TIMEOUT_SEC=90`(未设置时 `remote` 默认 90 秒,`codex` 默认 180 秒)
152
+ - `ACE_TOOL_UI_TIMEOUT_SEC=480`
153
+ - `ACE_TOOL_HEADLESS=1`
154
+ - `ACE_TOOL_HEADLESS_ACTION=enhanced|end|timeout`
155
+ - `ACE_TOOL_DEBUG=1`
156
+ - `ACE_TOOL_DEBUG_VERBOSE=1`
157
+ - `ACE_TOOL_DEBUG_FILE=<path>`
158
+
159
+ ## 8. 超时规则
160
+
161
+ - `--enhance-timeout-sec` / `ACE_TOOL_ENHANCE_TIMEOUT_SEC`:增强请求超时,范围 10-600 秒;未显式配置时 `remote` 默认 90 秒,`codex` 默认 180 秒。
162
+ - `--ui-timeout-sec` / `ACE_TOOL_UI_TIMEOUT_SEC`:UI 会话超时(默认 480 秒,范围 30-3600)。
163
+ - 超出范围的配置会回退到默认值。
164
+ - 交互模式下 UI 超时会回退到原始 prompt;headless 模式不显示 UI,由 `ACE_TOOL_HEADLESS_ACTION` 决定动作。
165
+ - `codex` provider 在首轮超时时会自动重试一次(`reasoning_effort=none`),用于降低“首次增强卡住”的概率。
166
+
167
+ ## 9. 故障排查
168
+
169
+ ### 9.1 MCP 启动超时 / 连接失败
170
+
171
+ 检查项:
172
+ - 必须使用 stdio 模式。
173
+ - `command` 路径可执行(绝对路径优先)。
174
+ - `--base-url` 与 `--token` 是否正确。
175
+ - 开启 `ACE_TOOL_DEBUG=1` 查看日志链路。
176
+
177
+ ### 9.2 窗口不弹出或卡住
178
+
179
+ 检查项:
180
+ - 是否启用了 `ACE_TOOL_HEADLESS=1`。
181
+ - Windows 权限或安全软件是否拦截窗口创建。
182
+ - 调试日志中是否出现 `enhance_prompt: opening ui`。
183
+
184
+ ### 9.3 Token 认证失败
185
+
186
+ 典型返回:401 / 403。
187
+
188
+ 处理:
189
+ - 到 <https://acemcp.heroman.wtf> 重新生成 token。
190
+ - 更新 MCP 配置后重启客户端。
191
+
192
+ ### 9.4 中文显示异常 / 乱码
193
+
194
+ 当前版本已增加 UTF-8/BOM/GBK 等解码兜底。若仍异常:
195
+ - 确认终端与编辑器编码为 UTF-8。
196
+ - 打开 `ACE_TOOL_DEBUG=1`,附带日志定位具体节点。
197
+
198
+ ### 9.5 Codex provider 无法执行 / 退出码非 0
199
+
200
+ 检查项:
201
+ - `--codex-cmd` 是否指向可执行文件,PATH 是否包含 `codex`。
202
+ - 使用相同命令在终端直接执行一次,确认 CLI 可运行。
203
+ - 开启 `ACE_TOOL_DEBUG=1` 查看退出码与错误类型(timeout/auth/network 等)。
204
+
205
+ ### 9.6 Codex 首次增强慢 / 高概率超时
206
+
207
+ 检查项:
208
+ - 日志是否长时间停在 `mcp: mcp-router starting`(已默认禁用内部 mcp-router;若仍出现,确认当前进程已重启到新版本)。
209
+ - `--codex-reasoning-effort` 临时降到 `none` 或 `low` 观察改善幅度。
210
+ - 适当提高 `--enhance-timeout-sec`(例如 240)验证是否为纯耗时问题。
211
+
212
+ ## 10. 从源码构建
213
+
214
+ ```powershell
215
+ # release
216
+ npm run release
217
+
218
+ # 构建并拷贝 bin/ace-tool-win.exe
219
+ npm run build:bin
220
+
221
+ # 本地打包验证
222
+ npm run pack:local
223
+ ```
224
+
225
+ ## 11. 发布到 npm
226
+
227
+ ```powershell
228
+ npm publish --access public
229
+ ```
230
+
231
+ > 若启用 npm 2FA,请使用支持 publish 的 token 或完成二次验证。
232
+
233
+ ## 12. 发布前检查清单
234
+
235
+ - [ ] `npm run release` error / warning
236
+ - [ ] MCP 可启动并能成功 `tools/list`
237
+ - [ ] `enhance_prompt` `remote` 与 `codex` 均可回包
238
+ - [ ] 中文增强回归通过(无 `???`)
239
+ - [ ] README 中配置示例可在新机器复现
240
+
241
+ ## License
242
+
262
243
  Apache-2.0
263
-
264
- ## 致谢
265
-
266
- - 原项目:ace-tool(https://github.com/eastxiaodong/ace-tool)
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ace-tool-windows",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "ACE MCP server for Windows (Win32)",
5
5
  "bin": {
6
6
  "ace-tool-win": "bin/ace-tool-win.exe"
@@ -17,11 +17,12 @@
17
17
  "LICENSE"
18
18
  ],
19
19
  "license": "Apache-2.0",
20
- "scripts": {
21
- "release": "cargo build --release",
22
- "build:bin": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/build-bin.ps1",
23
- "pack:local": "npm run build:bin && npm pack"
24
- },
20
+ "scripts": {
21
+ "release": "cargo build --release",
22
+ "check:release": "npm run release && cargo test --lib",
23
+ "build:bin": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/build-bin.ps1",
24
+ "pack:local": "npm run build:bin && npm pack"
25
+ },
25
26
  "repository": {
26
27
  "type": "git",
27
28
  "url": "git+https://github.com/doudouHubs/ace-tool-windows.git"