ronds_ai 0.1.13 → 0.1.14
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 +324 -324
- package/bin/ronds_ai.js +265 -265
- package/lib/code_record.js +925 -918
- package/lib/doctor.js +89 -89
- package/lib/skills_install.js +226 -226
- package/lib/skills_prompt.js +130 -130
- package/lib/skills_targets.js +81 -81
- package/package.json +16 -16
package/README.md
CHANGED
|
@@ -1,324 +1,324 @@
|
|
|
1
|
-
# ronds_ai
|
|
2
|
-
|
|
3
|
-
`ronds_ai` 是一个命令行工具,主要用于两类事情:
|
|
4
|
-
|
|
5
|
-
- 接收 Claude / Cursor 的 hook 事件,整理成统一的代码变更事件并上报
|
|
6
|
-
- 帮助项目写入对应的 hook 配置,以及安装 Skills 到 Claude / Codex / Cursor
|
|
7
|
-
|
|
8
|
-
## Requirements
|
|
9
|
-
|
|
10
|
-
- Node.js `>=16`
|
|
11
|
-
- `git`
|
|
12
|
-
- `unzip`
|
|
13
|
-
|
|
14
|
-
`git` 主要用于读取仓库信息和用户邮箱;`unzip` 用于 `skills install` 解压技能包。
|
|
15
|
-
|
|
16
|
-
## Install
|
|
17
|
-
|
|
18
|
-
按一次性执行使用:
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
npx ronds_ai@latest <command>
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
或全局安装:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
npm install -g ronds_ai
|
|
28
|
-
ronds_ai <command>
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Commands
|
|
32
|
-
|
|
33
|
-
### `check record`
|
|
34
|
-
|
|
35
|
-
检查 `record` 命令运行所需的基础环境。
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
ronds_ai check record
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
示例:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
npx ronds_ai@latest check record
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
当前会检查并输出:
|
|
48
|
-
|
|
49
|
-
- 当前 Node 版本
|
|
50
|
-
- Node 是否满足 `>=16`
|
|
51
|
-
- 当前目录下读取到的 `git user.email`
|
|
52
|
-
- 当前 `MCP_TRACKER_WORKER_ID` 的来源和取值
|
|
53
|
-
- `~/.profile` 路径
|
|
54
|
-
|
|
55
|
-
输出 JSON 后,命令还会继续在终端里显示当前 `MCP_TRACKER_WORKER_ID`,并询问是否要修改。
|
|
56
|
-
如果选择修改:
|
|
57
|
-
|
|
58
|
-
- Windows:写入用户级持久环境变量,新的终端可直接读取
|
|
59
|
-
- Linux:写入 `~/.profile`,新的 shell 可读取
|
|
60
|
-
|
|
61
|
-
如果不想进入交互流程,可加上:
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
ronds_ai check record --no-prompt
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
或:
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
npx ronds_ai@latest check record --no-prompt
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
交互式修改后,命令会再次显示更新后的 `MCP_TRACKER_WORKER_ID`。
|
|
74
|
-
|
|
75
|
-
输出是一个 JSON,例如:
|
|
76
|
-
|
|
77
|
-
```json
|
|
78
|
-
{
|
|
79
|
-
"ok": true,
|
|
80
|
-
"targetDir": "/path/to/project",
|
|
81
|
-
"node": {
|
|
82
|
-
"version": "v20.19.0",
|
|
83
|
-
"requirement": ">=16",
|
|
84
|
-
"satisfied": true
|
|
85
|
-
},
|
|
86
|
-
"gitUserEmail": "name@example.com",
|
|
87
|
-
"workerId": {
|
|
88
|
-
"name": "MCP_TRACKER_WORKER_ID",
|
|
89
|
-
"value": "worker-123",
|
|
90
|
-
"source": "env"
|
|
91
|
-
},
|
|
92
|
-
"profileFile": "/Users/you/.profile"
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
如果 Node 版本不满足要求,命令会返回非 0 退出码。
|
|
97
|
-
|
|
98
|
-
### `record`
|
|
99
|
-
|
|
100
|
-
从标准输入读取 Claude、Codex 或 Cursor 的 hook payload,转换为统一事件后发送到服务端。
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
ronds_ai record <tool>
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
支持的 `tool`:
|
|
107
|
-
|
|
108
|
-
- `claude`
|
|
109
|
-
- `codex`
|
|
110
|
-
- `cursor`
|
|
111
|
-
|
|
112
|
-
示例:
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
npx ronds_ai@latest record claude
|
|
116
|
-
npx ronds_ai@latest record codex
|
|
117
|
-
npx ronds_ai@latest record cursor
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
这个命令通常不是手工执行,而是被 Claude / Codex / Cursor 的 hook 配置调用。
|
|
121
|
-
|
|
122
|
-
行为说明:
|
|
123
|
-
|
|
124
|
-
- 从 `stdin` 读取一段 JSON
|
|
125
|
-
- 根据来源提取文件路径、变更内容、增删行数、仓库信息、worker_id
|
|
126
|
-
- 组装事件后通过 HTTP POST 上报
|
|
127
|
-
- 成功时输出一行 JSON
|
|
128
|
-
- 失败时会把事件写入本地失败日志,并输出保存位置
|
|
129
|
-
|
|
130
|
-
成功输出示例:
|
|
131
|
-
|
|
132
|
-
```json
|
|
133
|
-
{"status":"sent","event_id":"...","response_status":200}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
`dry-run` 输出示例:
|
|
137
|
-
|
|
138
|
-
```json
|
|
139
|
-
{"status":"dry-run","event_id":"...","response_status":0}
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
失败保存输出示例:
|
|
143
|
-
|
|
144
|
-
```json
|
|
145
|
-
{"status":"saved","event_id":"...","saved_path":"/Users/you/.ronds_ai/failed-events/20260409-claude-error.jsonl"}
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
目前支持的 hook 事件:
|
|
149
|
-
|
|
150
|
-
- Claude: `PostToolUse`
|
|
151
|
-
- Codex: `UserPromptSubmit` + `Stop`(两阶段处理)
|
|
152
|
-
- Cursor: `afterFileEdit`
|
|
153
|
-
|
|
154
|
-
其中 Claude 仅处理这些工具产生的事件:
|
|
155
|
-
|
|
156
|
-
- `Write`
|
|
157
|
-
- `Edit`
|
|
158
|
-
- `MultiEdit`
|
|
159
|
-
|
|
160
|
-
Codex 使用 `UserPromptSubmit` 和 `Stop` 两个 hook 阶段:前者保存当前 turn 的快照,后者基于快照计算变更事件;失败事件同样写入 `~/.ronds_ai/failed-events`。
|
|
161
|
-
|
|
162
|
-
### `doctor`
|
|
163
|
-
|
|
164
|
-
检查当前目录下的 hook 配置和最近错误日志,方便排查接入问题。
|
|
165
|
-
|
|
166
|
-
```bash
|
|
167
|
-
ronds_ai doctor <tool>
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
支持的 `tool`:
|
|
171
|
-
|
|
172
|
-
- `claude`
|
|
173
|
-
- `codex`
|
|
174
|
-
- `cursor`
|
|
175
|
-
|
|
176
|
-
示例:
|
|
177
|
-
|
|
178
|
-
```bash
|
|
179
|
-
npx ronds_ai@latest doctor claude
|
|
180
|
-
npx ronds_ai@latest doctor codex
|
|
181
|
-
npx ronds_ai@latest doctor cursor
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
输出内容包括:
|
|
185
|
-
|
|
186
|
-
- 当前检查的工具类型
|
|
187
|
-
- 当前目标目录
|
|
188
|
-
- 当前目录下的 `git user.email`
|
|
189
|
-
- 关键配置文件是否存在
|
|
190
|
-
- 今天的最近错误日志内容
|
|
191
|
-
|
|
192
|
-
Claude 会检查:
|
|
193
|
-
|
|
194
|
-
- `.claude/settings.json`
|
|
195
|
-
- `.claude/settings.local.json`
|
|
196
|
-
|
|
197
|
-
Codex 会检查:
|
|
198
|
-
|
|
199
|
-
- `.codex/hooks.json`
|
|
200
|
-
|
|
201
|
-
Cursor 会检查:
|
|
202
|
-
|
|
203
|
-
- `.cursor/hooks.json`
|
|
204
|
-
|
|
205
|
-
### `hooks deploy`
|
|
206
|
-
|
|
207
|
-
在当前项目目录生成或更新 Claude / Codex / Cursor 的 hook 配置。
|
|
208
|
-
|
|
209
|
-
```bash
|
|
210
|
-
ronds_ai hooks deploy
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
示例:
|
|
214
|
-
|
|
215
|
-
```bash
|
|
216
|
-
npx ronds_ai@latest hooks deploy
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
这个命令会做的事情:
|
|
220
|
-
|
|
221
|
-
- 在 `.cursor/hooks.json` 中确保存在 `npx ronds_ai@latest record cursor`
|
|
222
|
-
- 在 `.claude/settings.json` 中确保存在 `npx ronds_ai@latest record claude`
|
|
223
|
-
- 在 `.codex/hooks.json` 中确保存在 `npx ronds_ai@latest record codex`(`UserPromptSubmit` + `Stop` 两个 hook)
|
|
224
|
-
- 在 `.codex/config.toml` 中确保存在 `[features] codex_hooks = true`,启用 Codex hooks
|
|
225
|
-
- 清理旧版 hook 脚本文件
|
|
226
|
-
- 如果存在 `.claude/settings.local.json`,会移除其中由本工具管理的旧 hook,避免重复触发
|
|
227
|
-
- 所有工具的失败事件统一写入 `~/.ronds_ai/failed-events`
|
|
228
|
-
|
|
229
|
-
输出是一个 JSON,对应本次操作中:
|
|
230
|
-
|
|
231
|
-
- `createdFiles`
|
|
232
|
-
- `updatedFiles`
|
|
233
|
-
- `removedFiles`
|
|
234
|
-
|
|
235
|
-
### `skills install`
|
|
236
|
-
|
|
237
|
-
下载一个技能包并安装到 Claude / Codex / Cursor 对应的技能目录。
|
|
238
|
-
|
|
239
|
-
```bash
|
|
240
|
-
ronds_ai skills install <name> [--tool claude,codex,cursor] [--scope project|global] [--project-dir <path>] [--force]
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
示例:
|
|
244
|
-
|
|
245
|
-
```bash
|
|
246
|
-
npx ronds_ai@latest skills install demo-skill
|
|
247
|
-
npx ronds_ai@latest skills install demo-skill --tool claude --scope global
|
|
248
|
-
npx ronds_ai@latest skills install demo-skill --tool codex,cursor --scope project
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
参数说明:
|
|
252
|
-
|
|
253
|
-
- `name`: 要安装的 skill 名称
|
|
254
|
-
- `--tool`: 目标工具,可传 `claude`、`codex`、`cursor`,多个值用逗号分隔
|
|
255
|
-
- `--scope`: 安装范围,可选 `project` 或 `global`
|
|
256
|
-
- `--project-dir`: 当 `scope=project` 时指定项目目录;默认是当前目录
|
|
257
|
-
- `--force`: 目标目录已存在时覆盖
|
|
258
|
-
|
|
259
|
-
如果没有传 `--tool` 或 `--scope`,CLI 会进入交互式提示。
|
|
260
|
-
|
|
261
|
-
安装目录规则:
|
|
262
|
-
|
|
263
|
-
- `claude` + `project`: `<project>/.claude/skills/<name>`
|
|
264
|
-
- `claude` + `global`: `~/.claude/skills/<name>`
|
|
265
|
-
- `codex` + `project`: `<project>/.agents/skills/<name>`
|
|
266
|
-
- `codex` + `global`: `~/.agents/skills/<name>`
|
|
267
|
-
- `cursor` + `project`: `<project>/.agents/skills/<name>`
|
|
268
|
-
- `cursor` + `global`: `~/.agents/skills/<name>`
|
|
269
|
-
|
|
270
|
-
输出是一个 JSON,包含:
|
|
271
|
-
|
|
272
|
-
- 安装的 skill 名称
|
|
273
|
-
- 安装范围
|
|
274
|
-
- 项目目录
|
|
275
|
-
- 下载地址
|
|
276
|
-
- 实际安装到的目标路径列表
|
|
277
|
-
|
|
278
|
-
## Environment Variables
|
|
279
|
-
|
|
280
|
-
### `record` 相关
|
|
281
|
-
|
|
282
|
-
- `HOOK_REPORT_URL`: 上报地址
|
|
283
|
-
- `CHANGE_REPORT_URL`: 上报地址,作为 `HOOK_REPORT_URL` 的备用读取项
|
|
284
|
-
- `HOOK_REPORT_TIMEOUT_MS`: 请求超时时间,默认 `10000`
|
|
285
|
-
- `HOOK_REPORT_TOKEN`: 如果设置,会以 `Authorization: Bearer <token>` 发送
|
|
286
|
-
- `HOOK_REPORT_HEADERS`: 额外请求头,要求是 JSON 字符串
|
|
287
|
-
- `HOOK_REQUEST_DRY_RUN=1`: 不发请求,只把事件打印到标准输出
|
|
288
|
-
|
|
289
|
-
默认上报地址:
|
|
290
|
-
|
|
291
|
-
```text
|
|
292
|
-
https://aihub.ronds.com/api/api/v1/ai-code-events
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
### `worker_id` 解析顺序
|
|
296
|
-
|
|
297
|
-
`record` 在构建事件时,会按下面顺序寻找 `worker_id`:
|
|
298
|
-
|
|
299
|
-
1. `process.cwd()/.ai_config/config.json` 中的 `worker_id`
|
|
300
|
-
2. Git 仓库根目录下 `.ai_config/config.json` 中的 `worker_id`
|
|
301
|
-
3. 环境变量 `MCP_TRACKER_WORKER_ID`
|
|
302
|
-
4. 环境变量 `WORKER_ID`
|
|
303
|
-
5. 当前系统用户名
|
|
304
|
-
|
|
305
|
-
## Error Logs
|
|
306
|
-
|
|
307
|
-
命令运行失败或上报失败时,会把信息保存到:
|
|
308
|
-
|
|
309
|
-
```text
|
|
310
|
-
~/.ronds_ai/failed-events
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
常见文件名格式:
|
|
314
|
-
|
|
315
|
-
- `YYYYMMDD-claude-error.jsonl`
|
|
316
|
-
- `YYYYMMDD-codex-error.jsonl`
|
|
317
|
-
- `YYYYMMDD-cursor-error.jsonl`
|
|
318
|
-
- `YYYYMMDD-cli-error.jsonl`
|
|
319
|
-
|
|
320
|
-
## Notes
|
|
321
|
-
|
|
322
|
-
- `record` 和 `doctor` 目前支持 `claude`、`codex` 与 `cursor`
|
|
323
|
-
- `skills install` 支持 `claude`、`codex`、`cursor`
|
|
324
|
-
- 不支持的命令或参数会直接报错,并把错误写入 CLI 错误日志
|
|
1
|
+
# ronds_ai
|
|
2
|
+
|
|
3
|
+
`ronds_ai` 是一个命令行工具,主要用于两类事情:
|
|
4
|
+
|
|
5
|
+
- 接收 Claude / Cursor 的 hook 事件,整理成统一的代码变更事件并上报
|
|
6
|
+
- 帮助项目写入对应的 hook 配置,以及安装 Skills 到 Claude / Codex / Cursor
|
|
7
|
+
|
|
8
|
+
## Requirements
|
|
9
|
+
|
|
10
|
+
- Node.js `>=16`
|
|
11
|
+
- `git`
|
|
12
|
+
- `unzip`
|
|
13
|
+
|
|
14
|
+
`git` 主要用于读取仓库信息和用户邮箱;`unzip` 用于 `skills install` 解压技能包。
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
按一次性执行使用:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npx ronds_ai@latest <command>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
或全局安装:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install -g ronds_ai
|
|
28
|
+
ronds_ai <command>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Commands
|
|
32
|
+
|
|
33
|
+
### `check record`
|
|
34
|
+
|
|
35
|
+
检查 `record` 命令运行所需的基础环境。
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
ronds_ai check record
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
示例:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx ronds_ai@latest check record
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
当前会检查并输出:
|
|
48
|
+
|
|
49
|
+
- 当前 Node 版本
|
|
50
|
+
- Node 是否满足 `>=16`
|
|
51
|
+
- 当前目录下读取到的 `git user.email`
|
|
52
|
+
- 当前 `MCP_TRACKER_WORKER_ID` 的来源和取值
|
|
53
|
+
- `~/.profile` 路径
|
|
54
|
+
|
|
55
|
+
输出 JSON 后,命令还会继续在终端里显示当前 `MCP_TRACKER_WORKER_ID`,并询问是否要修改。
|
|
56
|
+
如果选择修改:
|
|
57
|
+
|
|
58
|
+
- Windows:写入用户级持久环境变量,新的终端可直接读取
|
|
59
|
+
- Linux:写入 `~/.profile`,新的 shell 可读取
|
|
60
|
+
|
|
61
|
+
如果不想进入交互流程,可加上:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
ronds_ai check record --no-prompt
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
或:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npx ronds_ai@latest check record --no-prompt
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
交互式修改后,命令会再次显示更新后的 `MCP_TRACKER_WORKER_ID`。
|
|
74
|
+
|
|
75
|
+
输出是一个 JSON,例如:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"ok": true,
|
|
80
|
+
"targetDir": "/path/to/project",
|
|
81
|
+
"node": {
|
|
82
|
+
"version": "v20.19.0",
|
|
83
|
+
"requirement": ">=16",
|
|
84
|
+
"satisfied": true
|
|
85
|
+
},
|
|
86
|
+
"gitUserEmail": "name@example.com",
|
|
87
|
+
"workerId": {
|
|
88
|
+
"name": "MCP_TRACKER_WORKER_ID",
|
|
89
|
+
"value": "worker-123",
|
|
90
|
+
"source": "env"
|
|
91
|
+
},
|
|
92
|
+
"profileFile": "/Users/you/.profile"
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
如果 Node 版本不满足要求,命令会返回非 0 退出码。
|
|
97
|
+
|
|
98
|
+
### `record`
|
|
99
|
+
|
|
100
|
+
从标准输入读取 Claude、Codex 或 Cursor 的 hook payload,转换为统一事件后发送到服务端。
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
ronds_ai record <tool>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
支持的 `tool`:
|
|
107
|
+
|
|
108
|
+
- `claude`
|
|
109
|
+
- `codex`
|
|
110
|
+
- `cursor`
|
|
111
|
+
|
|
112
|
+
示例:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
npx ronds_ai@latest record claude
|
|
116
|
+
npx ronds_ai@latest record codex
|
|
117
|
+
npx ronds_ai@latest record cursor
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
这个命令通常不是手工执行,而是被 Claude / Codex / Cursor 的 hook 配置调用。
|
|
121
|
+
|
|
122
|
+
行为说明:
|
|
123
|
+
|
|
124
|
+
- 从 `stdin` 读取一段 JSON
|
|
125
|
+
- 根据来源提取文件路径、变更内容、增删行数、仓库信息、worker_id
|
|
126
|
+
- 组装事件后通过 HTTP POST 上报
|
|
127
|
+
- 成功时输出一行 JSON
|
|
128
|
+
- 失败时会把事件写入本地失败日志,并输出保存位置
|
|
129
|
+
|
|
130
|
+
成功输出示例:
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{"status":"sent","event_id":"...","response_status":200}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
`dry-run` 输出示例:
|
|
137
|
+
|
|
138
|
+
```json
|
|
139
|
+
{"status":"dry-run","event_id":"...","response_status":0}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
失败保存输出示例:
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{"status":"saved","event_id":"...","saved_path":"/Users/you/.ronds_ai/failed-events/20260409-claude-error.jsonl"}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
目前支持的 hook 事件:
|
|
149
|
+
|
|
150
|
+
- Claude: `PostToolUse`
|
|
151
|
+
- Codex: `UserPromptSubmit` + `Stop`(两阶段处理)
|
|
152
|
+
- Cursor: `afterFileEdit`
|
|
153
|
+
|
|
154
|
+
其中 Claude 仅处理这些工具产生的事件:
|
|
155
|
+
|
|
156
|
+
- `Write`
|
|
157
|
+
- `Edit`
|
|
158
|
+
- `MultiEdit`
|
|
159
|
+
|
|
160
|
+
Codex 使用 `UserPromptSubmit` 和 `Stop` 两个 hook 阶段:前者保存当前 turn 的快照,后者基于快照计算变更事件;失败事件同样写入 `~/.ronds_ai/failed-events`。
|
|
161
|
+
|
|
162
|
+
### `doctor`
|
|
163
|
+
|
|
164
|
+
检查当前目录下的 hook 配置和最近错误日志,方便排查接入问题。
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
ronds_ai doctor <tool>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
支持的 `tool`:
|
|
171
|
+
|
|
172
|
+
- `claude`
|
|
173
|
+
- `codex`
|
|
174
|
+
- `cursor`
|
|
175
|
+
|
|
176
|
+
示例:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
npx ronds_ai@latest doctor claude
|
|
180
|
+
npx ronds_ai@latest doctor codex
|
|
181
|
+
npx ronds_ai@latest doctor cursor
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
输出内容包括:
|
|
185
|
+
|
|
186
|
+
- 当前检查的工具类型
|
|
187
|
+
- 当前目标目录
|
|
188
|
+
- 当前目录下的 `git user.email`
|
|
189
|
+
- 关键配置文件是否存在
|
|
190
|
+
- 今天的最近错误日志内容
|
|
191
|
+
|
|
192
|
+
Claude 会检查:
|
|
193
|
+
|
|
194
|
+
- `.claude/settings.json`
|
|
195
|
+
- `.claude/settings.local.json`
|
|
196
|
+
|
|
197
|
+
Codex 会检查:
|
|
198
|
+
|
|
199
|
+
- `.codex/hooks.json`
|
|
200
|
+
|
|
201
|
+
Cursor 会检查:
|
|
202
|
+
|
|
203
|
+
- `.cursor/hooks.json`
|
|
204
|
+
|
|
205
|
+
### `hooks deploy`
|
|
206
|
+
|
|
207
|
+
在当前项目目录生成或更新 Claude / Codex / Cursor 的 hook 配置。
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
ronds_ai hooks deploy
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
示例:
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
npx ronds_ai@latest hooks deploy
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
这个命令会做的事情:
|
|
220
|
+
|
|
221
|
+
- 在 `.cursor/hooks.json` 中确保存在 `npx ronds_ai@latest record cursor`
|
|
222
|
+
- 在 `.claude/settings.json` 中确保存在 `npx ronds_ai@latest record claude`
|
|
223
|
+
- 在 `.codex/hooks.json` 中确保存在 `npx ronds_ai@latest record codex`(`UserPromptSubmit` + `Stop` 两个 hook)
|
|
224
|
+
- 在 `.codex/config.toml` 中确保存在 `[features] codex_hooks = true`,启用 Codex hooks
|
|
225
|
+
- 清理旧版 hook 脚本文件
|
|
226
|
+
- 如果存在 `.claude/settings.local.json`,会移除其中由本工具管理的旧 hook,避免重复触发
|
|
227
|
+
- 所有工具的失败事件统一写入 `~/.ronds_ai/failed-events`
|
|
228
|
+
|
|
229
|
+
输出是一个 JSON,对应本次操作中:
|
|
230
|
+
|
|
231
|
+
- `createdFiles`
|
|
232
|
+
- `updatedFiles`
|
|
233
|
+
- `removedFiles`
|
|
234
|
+
|
|
235
|
+
### `skills install`
|
|
236
|
+
|
|
237
|
+
下载一个技能包并安装到 Claude / Codex / Cursor 对应的技能目录。
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
ronds_ai skills install <name> [--tool claude,codex,cursor] [--scope project|global] [--project-dir <path>] [--force]
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
示例:
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
npx ronds_ai@latest skills install demo-skill
|
|
247
|
+
npx ronds_ai@latest skills install demo-skill --tool claude --scope global
|
|
248
|
+
npx ronds_ai@latest skills install demo-skill --tool codex,cursor --scope project
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
参数说明:
|
|
252
|
+
|
|
253
|
+
- `name`: 要安装的 skill 名称
|
|
254
|
+
- `--tool`: 目标工具,可传 `claude`、`codex`、`cursor`,多个值用逗号分隔
|
|
255
|
+
- `--scope`: 安装范围,可选 `project` 或 `global`
|
|
256
|
+
- `--project-dir`: 当 `scope=project` 时指定项目目录;默认是当前目录
|
|
257
|
+
- `--force`: 目标目录已存在时覆盖
|
|
258
|
+
|
|
259
|
+
如果没有传 `--tool` 或 `--scope`,CLI 会进入交互式提示。
|
|
260
|
+
|
|
261
|
+
安装目录规则:
|
|
262
|
+
|
|
263
|
+
- `claude` + `project`: `<project>/.claude/skills/<name>`
|
|
264
|
+
- `claude` + `global`: `~/.claude/skills/<name>`
|
|
265
|
+
- `codex` + `project`: `<project>/.agents/skills/<name>`
|
|
266
|
+
- `codex` + `global`: `~/.agents/skills/<name>`
|
|
267
|
+
- `cursor` + `project`: `<project>/.agents/skills/<name>`
|
|
268
|
+
- `cursor` + `global`: `~/.agents/skills/<name>`
|
|
269
|
+
|
|
270
|
+
输出是一个 JSON,包含:
|
|
271
|
+
|
|
272
|
+
- 安装的 skill 名称
|
|
273
|
+
- 安装范围
|
|
274
|
+
- 项目目录
|
|
275
|
+
- 下载地址
|
|
276
|
+
- 实际安装到的目标路径列表
|
|
277
|
+
|
|
278
|
+
## Environment Variables
|
|
279
|
+
|
|
280
|
+
### `record` 相关
|
|
281
|
+
|
|
282
|
+
- `HOOK_REPORT_URL`: 上报地址
|
|
283
|
+
- `CHANGE_REPORT_URL`: 上报地址,作为 `HOOK_REPORT_URL` 的备用读取项
|
|
284
|
+
- `HOOK_REPORT_TIMEOUT_MS`: 请求超时时间,默认 `10000`
|
|
285
|
+
- `HOOK_REPORT_TOKEN`: 如果设置,会以 `Authorization: Bearer <token>` 发送
|
|
286
|
+
- `HOOK_REPORT_HEADERS`: 额外请求头,要求是 JSON 字符串
|
|
287
|
+
- `HOOK_REQUEST_DRY_RUN=1`: 不发请求,只把事件打印到标准输出
|
|
288
|
+
|
|
289
|
+
默认上报地址:
|
|
290
|
+
|
|
291
|
+
```text
|
|
292
|
+
https://aihub.ronds.com/api/api/v1/ai-code-events
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### `worker_id` 解析顺序
|
|
296
|
+
|
|
297
|
+
`record` 在构建事件时,会按下面顺序寻找 `worker_id`:
|
|
298
|
+
|
|
299
|
+
1. `process.cwd()/.ai_config/config.json` 中的 `worker_id`
|
|
300
|
+
2. Git 仓库根目录下 `.ai_config/config.json` 中的 `worker_id`
|
|
301
|
+
3. 环境变量 `MCP_TRACKER_WORKER_ID`
|
|
302
|
+
4. 环境变量 `WORKER_ID`
|
|
303
|
+
5. 当前系统用户名
|
|
304
|
+
|
|
305
|
+
## Error Logs
|
|
306
|
+
|
|
307
|
+
命令运行失败或上报失败时,会把信息保存到:
|
|
308
|
+
|
|
309
|
+
```text
|
|
310
|
+
~/.ronds_ai/failed-events
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
常见文件名格式:
|
|
314
|
+
|
|
315
|
+
- `YYYYMMDD-claude-error.jsonl`
|
|
316
|
+
- `YYYYMMDD-codex-error.jsonl`
|
|
317
|
+
- `YYYYMMDD-cursor-error.jsonl`
|
|
318
|
+
- `YYYYMMDD-cli-error.jsonl`
|
|
319
|
+
|
|
320
|
+
## Notes
|
|
321
|
+
|
|
322
|
+
- `record` 和 `doctor` 目前支持 `claude`、`codex` 与 `cursor`
|
|
323
|
+
- `skills install` 支持 `claude`、`codex`、`cursor`
|
|
324
|
+
- 不支持的命令或参数会直接报错,并把错误写入 CLI 错误日志
|