ronds_ai 0.1.7 → 0.1.9
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 +289 -0
- package/bin/ronds_ai.js +24 -1
- package/lib/check_record.js +106 -0
- package/lib/skills_install.js +63 -5
- package/lib/skills_prompt.js +7 -3
- package/package.json +4 -1
package/README.md
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
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
|
+
- 当前 `worker_id` 配置来源和取值
|
|
53
|
+
- `~/.profile` 路径
|
|
54
|
+
|
|
55
|
+
输出是一个 JSON,例如:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"ok": true,
|
|
60
|
+
"targetDir": "/path/to/project",
|
|
61
|
+
"node": {
|
|
62
|
+
"version": "v20.19.0",
|
|
63
|
+
"requirement": ">=16",
|
|
64
|
+
"satisfied": true
|
|
65
|
+
},
|
|
66
|
+
"gitUserEmail": "name@example.com",
|
|
67
|
+
"workerId": {
|
|
68
|
+
"name": "MCP_TRACKER_WORKER_ID",
|
|
69
|
+
"value": "worker-123",
|
|
70
|
+
"source": "env"
|
|
71
|
+
},
|
|
72
|
+
"profileFile": "/Users/you/.profile"
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
如果 Node 版本不满足要求,命令会返回非 0 退出码。
|
|
77
|
+
|
|
78
|
+
### `record`
|
|
79
|
+
|
|
80
|
+
从标准输入读取 Claude 或 Cursor 的 hook payload,转换为统一事件后发送到服务端。
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
ronds_ai record <tool>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
支持的 `tool`:
|
|
87
|
+
|
|
88
|
+
- `claude`
|
|
89
|
+
- `cursor`
|
|
90
|
+
|
|
91
|
+
示例:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npx ronds_ai@latest record claude
|
|
95
|
+
npx ronds_ai@latest record cursor
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
这个命令通常不是手工执行,而是被 Claude / Cursor 的 hook 配置调用。
|
|
99
|
+
|
|
100
|
+
行为说明:
|
|
101
|
+
|
|
102
|
+
- 从 `stdin` 读取一段 JSON
|
|
103
|
+
- 根据来源提取文件路径、变更内容、增删行数、仓库信息、worker_id
|
|
104
|
+
- 组装事件后通过 HTTP POST 上报
|
|
105
|
+
- 成功时输出一行 JSON
|
|
106
|
+
- 失败时会把事件写入本地失败日志,并输出保存位置
|
|
107
|
+
|
|
108
|
+
成功输出示例:
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{"status":"sent","event_id":"...","response_status":200}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`dry-run` 输出示例:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{"status":"dry-run","event_id":"...","response_status":0}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
失败保存输出示例:
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{"status":"saved","event_id":"...","saved_path":"/Users/you/.ronds_ai/failed-events/20260409-claude-error.jsonl"}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
目前支持的 hook 事件:
|
|
127
|
+
|
|
128
|
+
- Claude: `PostToolUse`
|
|
129
|
+
- Cursor: `afterFileEdit`
|
|
130
|
+
|
|
131
|
+
其中 Claude 仅处理这些工具产生的事件:
|
|
132
|
+
|
|
133
|
+
- `Write`
|
|
134
|
+
- `Edit`
|
|
135
|
+
- `MultiEdit`
|
|
136
|
+
|
|
137
|
+
### `doctor`
|
|
138
|
+
|
|
139
|
+
检查当前目录下的 hook 配置和最近错误日志,方便排查接入问题。
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
ronds_ai doctor <tool>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
支持的 `tool`:
|
|
146
|
+
|
|
147
|
+
- `claude`
|
|
148
|
+
- `cursor`
|
|
149
|
+
|
|
150
|
+
示例:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
npx ronds_ai@latest doctor claude
|
|
154
|
+
npx ronds_ai@latest doctor cursor
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
输出内容包括:
|
|
158
|
+
|
|
159
|
+
- 当前检查的工具类型
|
|
160
|
+
- 当前目标目录
|
|
161
|
+
- 当前目录下的 `git user.email`
|
|
162
|
+
- 关键配置文件是否存在
|
|
163
|
+
- 今天的最近错误日志内容
|
|
164
|
+
|
|
165
|
+
Claude 会检查:
|
|
166
|
+
|
|
167
|
+
- `.claude/settings.json`
|
|
168
|
+
- `.claude/settings.local.json`
|
|
169
|
+
|
|
170
|
+
Cursor 会检查:
|
|
171
|
+
|
|
172
|
+
- `.cursor/hooks.json`
|
|
173
|
+
|
|
174
|
+
### `hooks deploy`
|
|
175
|
+
|
|
176
|
+
在当前项目目录生成或更新 Claude / Cursor 的 hook 配置。
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
ronds_ai hooks deploy
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
示例:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
npx ronds_ai@latest hooks deploy
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
这个命令会做的事情:
|
|
189
|
+
|
|
190
|
+
- 在 `.cursor/hooks.json` 中确保存在 `npx ronds_ai@latest record cursor`
|
|
191
|
+
- 在 `.claude/settings.json` 中确保存在 `npx ronds_ai@latest record claude`
|
|
192
|
+
- 清理旧版 hook 脚本文件
|
|
193
|
+
- 如果存在 `.claude/settings.local.json`,会移除其中由本工具管理的旧 hook,避免重复触发
|
|
194
|
+
|
|
195
|
+
输出是一个 JSON,对应本次操作中:
|
|
196
|
+
|
|
197
|
+
- `createdFiles`
|
|
198
|
+
- `updatedFiles`
|
|
199
|
+
- `removedFiles`
|
|
200
|
+
|
|
201
|
+
### `skills install`
|
|
202
|
+
|
|
203
|
+
下载一个技能包并安装到 Claude / Codex / Cursor 对应的技能目录。
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
ronds_ai skills install <name> [--tool claude,codex,cursor] [--scope project|global] [--project-dir <path>] [--force]
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
示例:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
npx ronds_ai@latest skills install demo-skill
|
|
213
|
+
npx ronds_ai@latest skills install demo-skill --tool claude --scope global
|
|
214
|
+
npx ronds_ai@latest skills install demo-skill --tool codex,cursor --scope project
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
参数说明:
|
|
218
|
+
|
|
219
|
+
- `name`: 要安装的 skill 名称
|
|
220
|
+
- `--tool`: 目标工具,可传 `claude`、`codex`、`cursor`,多个值用逗号分隔
|
|
221
|
+
- `--scope`: 安装范围,可选 `project` 或 `global`
|
|
222
|
+
- `--project-dir`: 当 `scope=project` 时指定项目目录;默认是当前目录
|
|
223
|
+
- `--force`: 目标目录已存在时覆盖
|
|
224
|
+
|
|
225
|
+
如果没有传 `--tool` 或 `--scope`,CLI 会进入交互式提示。
|
|
226
|
+
|
|
227
|
+
安装目录规则:
|
|
228
|
+
|
|
229
|
+
- `claude` + `project`: `<project>/.claude/skills/<name>`
|
|
230
|
+
- `claude` + `global`: `~/.claude/skills/<name>`
|
|
231
|
+
- `codex` + `project`: `<project>/.agents/skills/<name>`
|
|
232
|
+
- `codex` + `global`: `~/.agents/skills/<name>`
|
|
233
|
+
- `cursor` + `project`: `<project>/.agents/skills/<name>`
|
|
234
|
+
- `cursor` + `global`: `~/.agents/skills/<name>`
|
|
235
|
+
|
|
236
|
+
输出是一个 JSON,包含:
|
|
237
|
+
|
|
238
|
+
- 安装的 skill 名称
|
|
239
|
+
- 安装范围
|
|
240
|
+
- 项目目录
|
|
241
|
+
- 下载地址
|
|
242
|
+
- 实际安装到的目标路径列表
|
|
243
|
+
|
|
244
|
+
## Environment Variables
|
|
245
|
+
|
|
246
|
+
### `record` 相关
|
|
247
|
+
|
|
248
|
+
- `HOOK_REPORT_URL`: 上报地址
|
|
249
|
+
- `CHANGE_REPORT_URL`: 上报地址,作为 `HOOK_REPORT_URL` 的备用读取项
|
|
250
|
+
- `HOOK_REPORT_TIMEOUT_MS`: 请求超时时间,默认 `10000`
|
|
251
|
+
- `HOOK_REPORT_TOKEN`: 如果设置,会以 `Authorization: Bearer <token>` 发送
|
|
252
|
+
- `HOOK_REPORT_HEADERS`: 额外请求头,要求是 JSON 字符串
|
|
253
|
+
- `HOOK_REQUEST_DRY_RUN=1`: 不发请求,只把事件打印到标准输出
|
|
254
|
+
|
|
255
|
+
默认上报地址:
|
|
256
|
+
|
|
257
|
+
```text
|
|
258
|
+
https://aihub.ronds.com/api/api/v1/ai-code-events
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### `worker_id` 解析顺序
|
|
262
|
+
|
|
263
|
+
`record` 在构建事件时,会按下面顺序寻找 `worker_id`:
|
|
264
|
+
|
|
265
|
+
1. `process.cwd()/.ai_config/config.json` 中的 `worker_id`
|
|
266
|
+
2. Git 仓库根目录下 `.ai_config/config.json` 中的 `worker_id`
|
|
267
|
+
3. 环境变量 `MCP_TRACKER_WORKER_ID`
|
|
268
|
+
4. 环境变量 `WORKER_ID`
|
|
269
|
+
5. 当前系统用户名
|
|
270
|
+
|
|
271
|
+
## Error Logs
|
|
272
|
+
|
|
273
|
+
命令运行失败或上报失败时,会把信息保存到:
|
|
274
|
+
|
|
275
|
+
```text
|
|
276
|
+
~/.ronds_ai/failed-events
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
常见文件名格式:
|
|
280
|
+
|
|
281
|
+
- `YYYYMMDD-claude-error.jsonl`
|
|
282
|
+
- `YYYYMMDD-cursor-error.jsonl`
|
|
283
|
+
- `YYYYMMDD-cli-error.jsonl`
|
|
284
|
+
|
|
285
|
+
## Notes
|
|
286
|
+
|
|
287
|
+
- `record` 和 `doctor` 目前只支持 `claude` 与 `cursor`
|
|
288
|
+
- `skills install` 支持 `claude`、`codex`、`cursor`
|
|
289
|
+
- 不支持的命令或参数会直接报错,并把错误写入 CLI 错误日志
|
package/bin/ronds_ai.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { runCodeRecord, saveCliError } = require('../lib/code_record');
|
|
4
|
+
const { runCheckRecord } = require('../lib/check_record');
|
|
4
5
|
const { runDoctor } = require('../lib/doctor');
|
|
5
6
|
const { deployHooks } = require('../lib/hooks_deploy');
|
|
6
|
-
const { runSkillsInstall } = require('../lib/skills_install');
|
|
7
7
|
|
|
8
8
|
const SUPPORTED_SOURCES = new Set(['claude', 'cursor']);
|
|
9
9
|
|
|
@@ -11,6 +11,7 @@ function printUsage() {
|
|
|
11
11
|
process.stderr.write([
|
|
12
12
|
'Usage:',
|
|
13
13
|
' ronds_ai record <tool>',
|
|
14
|
+
' ronds_ai check record',
|
|
14
15
|
' ronds_ai doctor <tool>',
|
|
15
16
|
' ronds_ai hooks deploy',
|
|
16
17
|
' ronds_ai skills install <name> [--tool claude,codex,cursor] [--scope project|global] [--project-dir <path>] [--force]',
|
|
@@ -23,6 +24,7 @@ function printUsage() {
|
|
|
23
24
|
'Examples:',
|
|
24
25
|
' npx ronds_ai@latest record claude',
|
|
25
26
|
' npx ronds_ai@latest record cursor',
|
|
27
|
+
' npx ronds_ai@latest check record',
|
|
26
28
|
' npx ronds_ai@latest doctor claude',
|
|
27
29
|
' npx ronds_ai@latest doctor cursor',
|
|
28
30
|
' npx ronds_ai@latest hooks deploy',
|
|
@@ -44,6 +46,21 @@ async function runHooksCommand(args) {
|
|
|
44
46
|
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
45
47
|
}
|
|
46
48
|
|
|
49
|
+
async function runCheckCommand(args) {
|
|
50
|
+
const [target] = args;
|
|
51
|
+
|
|
52
|
+
if (target !== 'record') {
|
|
53
|
+
throw new Error('Unsupported check command');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const result = runCheckRecord(process.cwd());
|
|
57
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
58
|
+
|
|
59
|
+
if (!result.ok) {
|
|
60
|
+
process.exitCode = 1;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
47
64
|
function parseSkillsInstallArgs(args) {
|
|
48
65
|
const options = {
|
|
49
66
|
tool: '',
|
|
@@ -113,6 +130,7 @@ function parseSkillsInstallArgs(args) {
|
|
|
113
130
|
}
|
|
114
131
|
|
|
115
132
|
async function runSkillsCommand(args) {
|
|
133
|
+
const { runSkillsInstall } = require('../lib/skills_install');
|
|
116
134
|
const [action, ...rest] = args;
|
|
117
135
|
|
|
118
136
|
if (action !== 'install') {
|
|
@@ -152,6 +170,11 @@ async function run() {
|
|
|
152
170
|
return;
|
|
153
171
|
}
|
|
154
172
|
|
|
173
|
+
if (command === 'check') {
|
|
174
|
+
await runCheckCommand(args);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
155
178
|
if (command === 'hooks') {
|
|
156
179
|
await runHooksCommand(args);
|
|
157
180
|
return;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const os = require('os');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { execFileSync } = require('child_process');
|
|
5
|
+
|
|
6
|
+
const ENVIRONMENT_VARIABLE_NAME = process.env.ENVIRONMENT_VARIABLE_NAME || 'MCP_TRACKER_WORKER_ID';
|
|
7
|
+
const MINIMUM_NODE_MAJOR = 16;
|
|
8
|
+
|
|
9
|
+
function readGitUserEmail(baseDir) {
|
|
10
|
+
try {
|
|
11
|
+
return execFileSync('git', ['config', 'user.email'], {
|
|
12
|
+
cwd: baseDir,
|
|
13
|
+
encoding: 'utf8',
|
|
14
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
15
|
+
})
|
|
16
|
+
.trim()
|
|
17
|
+
.replace(/^["'“”]+/, '')
|
|
18
|
+
.replace(/["'“”]+$/, '');
|
|
19
|
+
} catch {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getProfileFilePath() {
|
|
25
|
+
return path.join(os.homedir(), '.profile');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getCurrentWorkerId() {
|
|
29
|
+
const envValue = String(process.env[ENVIRONMENT_VARIABLE_NAME] || '').trim();
|
|
30
|
+
if (envValue) {
|
|
31
|
+
return {
|
|
32
|
+
name: ENVIRONMENT_VARIABLE_NAME,
|
|
33
|
+
value: envValue,
|
|
34
|
+
source: 'env',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const profileFile = getProfileFilePath();
|
|
39
|
+
if (!fs.existsSync(profileFile)) {
|
|
40
|
+
return {
|
|
41
|
+
name: ENVIRONMENT_VARIABLE_NAME,
|
|
42
|
+
value: '',
|
|
43
|
+
source: '',
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const lines = fs.readFileSync(profileFile, 'utf8').split('\n');
|
|
48
|
+
const prefix = `export ${ENVIRONMENT_VARIABLE_NAME}=`;
|
|
49
|
+
|
|
50
|
+
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
|
51
|
+
const line = lines[index].trim();
|
|
52
|
+
if (!line.startsWith(prefix)) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const value = line
|
|
57
|
+
.slice(prefix.length)
|
|
58
|
+
.trim()
|
|
59
|
+
.replace(/^"/, '')
|
|
60
|
+
.replace(/"$/, '');
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
name: ENVIRONMENT_VARIABLE_NAME,
|
|
64
|
+
value,
|
|
65
|
+
source: 'profile',
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
name: ENVIRONMENT_VARIABLE_NAME,
|
|
71
|
+
value: '',
|
|
72
|
+
source: '',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function parseNodeMajor(version) {
|
|
77
|
+
const normalized = String(version || '').trim();
|
|
78
|
+
const match = normalized.match(/^v?(\d+)/);
|
|
79
|
+
return match ? Number(match[1]) : 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function runCheckRecord(targetDir = process.cwd()) {
|
|
83
|
+
const baseDir = path.resolve(targetDir);
|
|
84
|
+
const nodeVersion = process.version;
|
|
85
|
+
const nodeMajor = parseNodeMajor(nodeVersion);
|
|
86
|
+
const gitUserEmail = readGitUserEmail(baseDir);
|
|
87
|
+
const worker = getCurrentWorkerId();
|
|
88
|
+
const nodeSatisfied = nodeMajor >= MINIMUM_NODE_MAJOR;
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
ok: nodeSatisfied,
|
|
92
|
+
targetDir: baseDir,
|
|
93
|
+
node: {
|
|
94
|
+
version: nodeVersion,
|
|
95
|
+
requirement: `>=${MINIMUM_NODE_MAJOR}`,
|
|
96
|
+
satisfied: nodeSatisfied,
|
|
97
|
+
},
|
|
98
|
+
gitUserEmail,
|
|
99
|
+
workerId: worker,
|
|
100
|
+
profileFile: getProfileFilePath(),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
module.exports = {
|
|
105
|
+
runCheckRecord,
|
|
106
|
+
};
|
package/lib/skills_install.js
CHANGED
|
@@ -10,10 +10,68 @@ const { promptForScope, promptForTools } = require('./skills_prompt');
|
|
|
10
10
|
const SKILL_DOWNLOAD_BASE_URL = 'https://aihub.ronds.com/api/api/v1/skills/download';
|
|
11
11
|
const MAX_REDIRECTS = 5;
|
|
12
12
|
|
|
13
|
-
function
|
|
13
|
+
function parseJson(raw, label) {
|
|
14
|
+
try {
|
|
15
|
+
return JSON.parse(raw);
|
|
16
|
+
} catch (error) {
|
|
17
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
18
|
+
throw new Error(`${label} is not valid JSON: ${detail}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function loadDownloadConfig() {
|
|
23
|
+
const token = String(process.env.SKILL_DOWNLOAD_TOKEN || '').trim();
|
|
24
|
+
const extraHeaders = process.env.SKILL_DOWNLOAD_HEADERS
|
|
25
|
+
? parseJson(process.env.SKILL_DOWNLOAD_HEADERS, 'SKILL_DOWNLOAD_HEADERS')
|
|
26
|
+
: {};
|
|
27
|
+
|
|
28
|
+
const headers = {
|
|
29
|
+
...extraHeaders,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
if (token) {
|
|
33
|
+
headers.authorization = `Bearer ${token}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return { headers };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function copyDirectoryRecursive(sourceDir, destinationDir) {
|
|
40
|
+
const entries = fs.readdirSync(sourceDir, { withFileTypes: true });
|
|
41
|
+
fs.mkdirSync(destinationDir, { recursive: true });
|
|
42
|
+
|
|
43
|
+
for (const entry of entries) {
|
|
44
|
+
const sourcePath = path.join(sourceDir, entry.name);
|
|
45
|
+
const destinationPath = path.join(destinationDir, entry.name);
|
|
46
|
+
|
|
47
|
+
if (entry.isDirectory()) {
|
|
48
|
+
copyDirectoryRecursive(sourcePath, destinationPath);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (entry.isSymbolicLink()) {
|
|
53
|
+
const targetPath = fs.readlinkSync(sourcePath);
|
|
54
|
+
fs.symlinkSync(targetPath, destinationPath);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
fs.copyFileSync(sourcePath, destinationPath);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function copyDirectory(sourceDir, destinationDir) {
|
|
63
|
+
if (typeof fs.cpSync === 'function') {
|
|
64
|
+
fs.cpSync(sourceDir, destinationDir, { recursive: true });
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
copyDirectoryRecursive(sourceDir, destinationDir);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function streamToFile(url, destinationPath, config, redirectCount = 0) {
|
|
14
72
|
return new Promise((resolve, reject) => {
|
|
15
73
|
const transport = String(url).startsWith('http://') ? http : https;
|
|
16
|
-
const request = transport.get(url, (response) => {
|
|
74
|
+
const request = transport.get(url, { headers: config.headers }, (response) => {
|
|
17
75
|
if (response.statusCode && response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
|
|
18
76
|
response.resume();
|
|
19
77
|
if (redirectCount >= MAX_REDIRECTS) {
|
|
@@ -22,7 +80,7 @@ function streamToFile(url, destinationPath, redirectCount = 0) {
|
|
|
22
80
|
}
|
|
23
81
|
|
|
24
82
|
const nextUrl = new URL(response.headers.location, url).toString();
|
|
25
|
-
streamToFile(nextUrl, destinationPath, redirectCount + 1).then(resolve, reject);
|
|
83
|
+
streamToFile(nextUrl, destinationPath, config, redirectCount + 1).then(resolve, reject);
|
|
26
84
|
return;
|
|
27
85
|
}
|
|
28
86
|
|
|
@@ -51,7 +109,7 @@ function streamToFile(url, destinationPath, redirectCount = 0) {
|
|
|
51
109
|
async function downloadSkillArchive(name, workingDir) {
|
|
52
110
|
const archivePath = path.join(workingDir, `${name}.zip`);
|
|
53
111
|
const url = `${SKILL_DOWNLOAD_BASE_URL}/${encodeURIComponent(name)}`;
|
|
54
|
-
await streamToFile(url, archivePath);
|
|
112
|
+
await streamToFile(url, archivePath, loadDownloadConfig());
|
|
55
113
|
return {
|
|
56
114
|
url,
|
|
57
115
|
archivePath,
|
|
@@ -98,7 +156,7 @@ function copySkill(sourceDir, destinationDir, force) {
|
|
|
98
156
|
}
|
|
99
157
|
|
|
100
158
|
fs.mkdirSync(path.dirname(destinationDir), { recursive: true });
|
|
101
|
-
|
|
159
|
+
copyDirectory(sourceDir, destinationDir);
|
|
102
160
|
}
|
|
103
161
|
|
|
104
162
|
async function resolveInstallOptions(options) {
|
package/lib/skills_prompt.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const readline = require('readline
|
|
1
|
+
const readline = require('readline');
|
|
2
2
|
|
|
3
3
|
const TOOL_CHOICES = ['claude', 'codex', 'cursor'];
|
|
4
4
|
const SCOPE_CHOICES = ['project', 'global'];
|
|
@@ -42,7 +42,9 @@ async function promptForTools() {
|
|
|
42
42
|
].join('\n'));
|
|
43
43
|
process.stderr.write('\n');
|
|
44
44
|
|
|
45
|
-
const answer = await
|
|
45
|
+
const answer = await new Promise((resolve) => {
|
|
46
|
+
rl.question('> ', resolve);
|
|
47
|
+
});
|
|
46
48
|
return normalizeChoiceInput(answer);
|
|
47
49
|
} finally {
|
|
48
50
|
rl.close();
|
|
@@ -64,7 +66,9 @@ async function promptForScope() {
|
|
|
64
66
|
].join('\n'));
|
|
65
67
|
process.stderr.write('\n');
|
|
66
68
|
|
|
67
|
-
const answer = String(await
|
|
69
|
+
const answer = String(await new Promise((resolve) => {
|
|
70
|
+
rl.question('> ', resolve);
|
|
71
|
+
})).trim().toLowerCase();
|
|
68
72
|
if (answer === '1') {
|
|
69
73
|
return 'project';
|
|
70
74
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ronds_ai",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "CLI for reporting AI code edit events.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"ronds_ai": "bin/ronds_ai.js"
|
|
@@ -9,5 +9,8 @@
|
|
|
9
9
|
"bin",
|
|
10
10
|
"lib"
|
|
11
11
|
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=16"
|
|
14
|
+
},
|
|
12
15
|
"license": "MIT"
|
|
13
16
|
}
|