@tofrankie/agents-sync 0.0.2 → 0.0.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/CHANGELOG.md +8 -0
- package/README.md +2 -0
- package/dist/cli.mjs +20 -12
- package/package.json +1 -1
- package/README.local.md +0 -218
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -3,3 +3,5 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@tofrankie/agents-sync) [](https://nodejs.org) [](https://github.com/tofrankie/agents-sync/blob/main/LICENSE) [](https://www.npmjs.com/package/@tofrankie/agents-sync)
|
|
4
4
|
|
|
5
5
|
🤯 WIP...
|
|
6
|
+
|
|
7
|
+
> Maybe [Rulesync](https://github.com/dyoshikawa/rulesync) is what you're looking for.
|
package/dist/cli.mjs
CHANGED
|
@@ -269,18 +269,18 @@ async function runMcpCommand(cwd, options) {
|
|
|
269
269
|
}
|
|
270
270
|
const sourceFile = await resolveMcpSourceFile(runtime.source);
|
|
271
271
|
if (!sourceFile) {
|
|
272
|
-
printSkip(`No MCP config file found in ${runtime.source}.`);
|
|
272
|
+
printSkip(`No MCP config file found in ${c.dim(runtime.source)}.`);
|
|
273
273
|
return;
|
|
274
274
|
}
|
|
275
275
|
const rendered = renderMcpConfigByAgent(await normalizeMcpConfig(sourceFile), runtime.targetAgent);
|
|
276
276
|
const targetFile = resolveMcpTargetFile(cwd);
|
|
277
277
|
if (runtime.dryRun) {
|
|
278
|
-
process.stdout.write(`dry-run: MCP sync target => ${targetFile}\n`);
|
|
278
|
+
process.stdout.write(`dry-run: MCP sync target => ${c.dim(targetFile)}\n`);
|
|
279
279
|
return;
|
|
280
280
|
}
|
|
281
281
|
await fs.mkdir(path.dirname(targetFile), { recursive: true });
|
|
282
282
|
await fs.writeFile(targetFile, rendered, "utf8");
|
|
283
|
-
process.stdout.write(`done: MCP synced to ${targetFile}\n`);
|
|
283
|
+
process.stdout.write(`done: MCP synced to ${c.dim(targetFile)}\n`);
|
|
284
284
|
}
|
|
285
285
|
//#endregion
|
|
286
286
|
//#region src/cli/commands/rule.ts
|
|
@@ -292,7 +292,7 @@ async function runRuleCommand(cwd, options) {
|
|
|
292
292
|
}
|
|
293
293
|
const files = await discoverRuleFiles(runtime.source);
|
|
294
294
|
if (files.length === 0) {
|
|
295
|
-
printSkip(`No rule files found in ${runtime.source}.`);
|
|
295
|
+
printSkip(`No rule files found in ${c.dim(runtime.source)}.`);
|
|
296
296
|
return;
|
|
297
297
|
}
|
|
298
298
|
printSummary("rules", await copyRuleFiles(files, resolveRulesTargetDir(cwd), {
|
|
@@ -302,28 +302,36 @@ async function runRuleCommand(cwd, options) {
|
|
|
302
302
|
}
|
|
303
303
|
//#endregion
|
|
304
304
|
//#region src/cli/commands/skill.ts
|
|
305
|
+
/** Multiselect sentinel: not a filesystem path. When selected, every skill is synced. */
|
|
306
|
+
const MULTISELECT_ALL_SKILLS = "__agents-sync:all-skills__";
|
|
305
307
|
async function runSkillCommand(cwd, options) {
|
|
306
308
|
const runtime = resolveOptions(await loadUserConfig(cwd, options.config), options);
|
|
307
309
|
const skillDirs = await discoverSkills(runtime.source);
|
|
308
310
|
if (skillDirs.length === 0) {
|
|
309
|
-
printSkip(`No syncable skills found in ${runtime.source}.`);
|
|
311
|
+
printSkip(`No syncable skills found in ${c.dim(runtime.source)}.`);
|
|
310
312
|
return;
|
|
311
313
|
}
|
|
312
314
|
let selected = skillDirs;
|
|
313
315
|
if (!runtime.yes) {
|
|
316
|
+
const skillOptions = skillDirs.map((dir) => ({
|
|
317
|
+
label: path.basename(dir),
|
|
318
|
+
value: dir
|
|
319
|
+
}));
|
|
320
|
+
const options = skillDirs.length > 1 ? [{
|
|
321
|
+
label: "All skills",
|
|
322
|
+
value: MULTISELECT_ALL_SKILLS
|
|
323
|
+
}, ...skillOptions] : skillOptions;
|
|
314
324
|
const picked = await p.multiselect({
|
|
315
|
-
message: `Select ${c.green("skills")} to sync ${c.dim(runtime.source)}`,
|
|
316
|
-
options
|
|
317
|
-
label: path.basename(dir),
|
|
318
|
-
value: dir
|
|
319
|
-
})),
|
|
325
|
+
message: `Select one or more ${c.green("skills")} to sync from ${c.dim(runtime.source)}`,
|
|
326
|
+
options,
|
|
320
327
|
required: false
|
|
321
328
|
});
|
|
322
329
|
if (p.isCancel(picked)) {
|
|
323
330
|
p.cancel("Operation canceled.");
|
|
324
331
|
return;
|
|
325
332
|
}
|
|
326
|
-
|
|
333
|
+
const values = picked;
|
|
334
|
+
selected = values.includes(MULTISELECT_ALL_SKILLS) ? skillDirs : values;
|
|
327
335
|
}
|
|
328
336
|
if (selected.length === 0) {
|
|
329
337
|
printSkip("No skills selected.");
|
|
@@ -355,7 +363,7 @@ async function runSkillCommand(cwd, options) {
|
|
|
355
363
|
//#endregion
|
|
356
364
|
//#region package.json
|
|
357
365
|
var name = "@tofrankie/agents-sync";
|
|
358
|
-
var version = "0.0.
|
|
366
|
+
var version = "0.0.4";
|
|
359
367
|
//#endregion
|
|
360
368
|
//#region src/cli/index.ts
|
|
361
369
|
main().catch((error) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tofrankie/agents-sync",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"description": "Sync skills, rules, and MCP from a configurable source into your project",
|
|
6
6
|
"author": "Frankie <1426203851@qq.com> (https://github.com/tofrankie)",
|
|
7
7
|
"license": "MIT",
|
package/README.local.md
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
# @tofrankie/agents-sync (Local Draft)
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@tofrankie/agents-sync) [](https://nodejs.org) [](https://github.com/tofrankie/agents-sync/blob/main/LICENSE) [](https://www.npmjs.com/package/@tofrankie/agents-sync)
|
|
4
|
-
|
|
5
|
-
`agents-sync` 是一个用于同步 AI Agent 相关资源的 CLI 工具。当前版本聚焦于:
|
|
6
|
-
|
|
7
|
-
- `skill`:多 Agent 兼容同步(统一落到项目 `.agents/skills`)
|
|
8
|
-
- `rule`:首版仅支持 Cursor(写入 `.cursor/rules`)
|
|
9
|
-
- `mcp`:首版仅支持 Cursor(写入 `.cursor/mcp.json`)
|
|
10
|
-
|
|
11
|
-
> 当前文档是本地草稿,暂不对外发布。
|
|
12
|
-
|
|
13
|
-
## 1. 设计目标
|
|
14
|
-
|
|
15
|
-
- 从统一来源(默认 `~/.agents`)同步可复用的能力资产
|
|
16
|
-
- 在不同 Agent 生态之间,尽量用最少心智成本管理 skills
|
|
17
|
-
- 对差异较大的 rules / mcp,先收敛范围,确保首版稳定
|
|
18
|
-
|
|
19
|
-
## 2. 当前能力边界(v1)
|
|
20
|
-
|
|
21
|
-
- `skill`
|
|
22
|
-
- 支持目标 Agent:`cursor | claude | codex | gemini`
|
|
23
|
-
- 默认仍写入项目 `./.agents/skills/<skill-name>/`
|
|
24
|
-
- `rule`
|
|
25
|
-
- 仅支持目标 Agent:`cursor`
|
|
26
|
-
- 目标目录:`./.cursor/rules/`
|
|
27
|
-
- 源文件若为 `.md`,落盘会转为 `.mdc`
|
|
28
|
-
- `mcp`
|
|
29
|
-
- 仅支持目标 Agent:`cursor`
|
|
30
|
-
- 目标文件:`./.cursor/mcp.json`
|
|
31
|
-
- 对不支持的组合(如 `rule --target-agent codex`):
|
|
32
|
-
- 输出友好提示并跳过,不中断整个流程
|
|
33
|
-
|
|
34
|
-
## 3. 安装与运行
|
|
35
|
-
|
|
36
|
-
### 3.1 本地开发
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
pnpm install
|
|
40
|
-
pnpm dev
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### 3.2 构建
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
pnpm build
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
构建产物默认在 `dist/`,并通过 `bin` 暴露 `agents-sync` 命令。
|
|
50
|
-
|
|
51
|
-
## 4. 命令总览
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
agents-sync skill [options]
|
|
55
|
-
agents-sync rule [options]
|
|
56
|
-
agents-sync mcp [options]
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### 4.1 公共参数
|
|
60
|
-
|
|
61
|
-
- `-s, --source <path>`:源路径(默认 `~/.agents`)
|
|
62
|
-
- `-t, --target-agent <agent>`:目标 Agent(默认 `cursor`)
|
|
63
|
-
- `--scope <project|user>`:作用域(默认 `project`)
|
|
64
|
-
- `-c, --config <path>`:显式配置文件路径
|
|
65
|
-
- `--dry-run`:仅展示计划,不落盘
|
|
66
|
-
- `-y, --yes`:跳过交互,并在冲突时按覆盖策略执行
|
|
67
|
-
|
|
68
|
-
## 5. 使用示例
|
|
69
|
-
|
|
70
|
-
### 5.1 同步 skills(交互选择)
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
agents-sync skill
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
行为:
|
|
77
|
-
|
|
78
|
-
- 从 `~/.agents` 发现 skill
|
|
79
|
-
- 交互多选
|
|
80
|
-
- 同步到 `./.agents/skills/`
|
|
81
|
-
|
|
82
|
-
### 5.2 同步 Cursor rules
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
agents-sync rule --target-agent cursor
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### 5.3 同步 Cursor MCP(先预览)
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
agents-sync mcp --dry-run
|
|
92
|
-
agents-sync mcp
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## 6. 配置文件
|
|
96
|
-
|
|
97
|
-
支持自动发现以下文件名:
|
|
98
|
-
|
|
99
|
-
- `agents-sync.config.js`
|
|
100
|
-
- `agents-sync.config.cjs`
|
|
101
|
-
- `agents-sync.config.mjs`
|
|
102
|
-
- `agents-sync.config.ts`
|
|
103
|
-
- `agents-sync.config.cts`
|
|
104
|
-
- `agents-sync.config.mts`
|
|
105
|
-
|
|
106
|
-
也可通过 `--config` 显式指定。
|
|
107
|
-
|
|
108
|
-
### 6.1 配置示例
|
|
109
|
-
|
|
110
|
-
```ts
|
|
111
|
-
import { defineConfig } from '@tofrankie/agents-sync'
|
|
112
|
-
|
|
113
|
-
export default defineConfig({
|
|
114
|
-
sourceDir: ['~/.agents'],
|
|
115
|
-
agent: 'cursor',
|
|
116
|
-
conflictPolicy: 'ask',
|
|
117
|
-
mapping: {
|
|
118
|
-
cursor: {
|
|
119
|
-
skillsDir: '.agents/skills',
|
|
120
|
-
rulesDir: '.cursor/rules',
|
|
121
|
-
mcpFile: '.cursor/mcp.json',
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
})
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
说明:
|
|
128
|
-
|
|
129
|
-
- 配置 key:`sourceDir`、`agent`
|
|
130
|
-
- `sourceDir` 与 `agent` 支持字符串或字符串数组(数组取第一个值)
|
|
131
|
-
|
|
132
|
-
### 6.2 参数优先级
|
|
133
|
-
|
|
134
|
-
1. CLI 参数
|
|
135
|
-
2. 配置文件
|
|
136
|
-
3. 内置默认值
|
|
137
|
-
|
|
138
|
-
## 7. 同步策略说明
|
|
139
|
-
|
|
140
|
-
### 7.1 skills
|
|
141
|
-
|
|
142
|
-
- 发现源目录中的技能目录(需包含 `SKILL.md`)
|
|
143
|
-
- 文件级复制
|
|
144
|
-
- 冲突时:
|
|
145
|
-
- `--yes`:覆盖
|
|
146
|
-
- 无 `--yes`:跳过冲突文件,但继续同步同 skill 下其他文件
|
|
147
|
-
|
|
148
|
-
### 7.2 rules(Cursor)
|
|
149
|
-
|
|
150
|
-
- 发现 `.md`/`.mdc` 规则文件
|
|
151
|
-
- 落盘到 `.cursor/rules/`
|
|
152
|
-
- `.md` 自动转 `.mdc` 后缀
|
|
153
|
-
|
|
154
|
-
### 7.3 mcp(Cursor)
|
|
155
|
-
|
|
156
|
-
- 读取源 `mcp.json`(或 `.cursor/mcp.json`)
|
|
157
|
-
- 标准化后渲染为 Cursor 可用 JSON
|
|
158
|
-
- 写入 `.cursor/mcp.json`
|
|
159
|
-
|
|
160
|
-
## 8. 路径映射与导入约定
|
|
161
|
-
|
|
162
|
-
- TS 路径别名:`@/* -> src/*`
|
|
163
|
-
- 源码采用 `@/` 导入
|
|
164
|
-
- `test/` 目录保持相对路径导入(便于测试语义清晰)
|
|
165
|
-
|
|
166
|
-
## 9. 测试与质量保障
|
|
167
|
-
|
|
168
|
-
```bash
|
|
169
|
-
pnpm test
|
|
170
|
-
pnpm typecheck
|
|
171
|
-
pnpm lint
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
当前已覆盖:
|
|
175
|
-
|
|
176
|
-
- 配置解析优先级与默认值
|
|
177
|
-
- home 路径展开
|
|
178
|
-
- skills/rules/mcp 核心同步路径
|
|
179
|
-
- mcp 渲染目标限制
|
|
180
|
-
|
|
181
|
-
## 10. 已知限制与后续计划
|
|
182
|
-
|
|
183
|
-
- v1 的 `rule/mcp` 仅支持 Cursor
|
|
184
|
-
- 其他 Agent 的 rules/mcp 路径仅做档案保留,后续扩展
|
|
185
|
-
- 后续可增强:
|
|
186
|
-
- `--diff` 冲突前预览
|
|
187
|
-
- 更细粒度覆盖策略
|
|
188
|
-
- 更多资源类型(prompts/templates 等)
|
|
189
|
-
|
|
190
|
-
## 11. 目录结构(当前实现)
|
|
191
|
-
|
|
192
|
-
```text
|
|
193
|
-
src/
|
|
194
|
-
cli/
|
|
195
|
-
commands/
|
|
196
|
-
skill.ts
|
|
197
|
-
rule.ts
|
|
198
|
-
mcp.ts
|
|
199
|
-
common.ts
|
|
200
|
-
core/
|
|
201
|
-
agent-profiles.ts
|
|
202
|
-
config-loader.ts
|
|
203
|
-
sync-engine.ts
|
|
204
|
-
path.ts
|
|
205
|
-
types/
|
|
206
|
-
core.ts
|
|
207
|
-
config.ts
|
|
208
|
-
index.ts
|
|
209
|
-
test/
|
|
210
|
-
*.test.ts
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
## 12. 对外发布前建议
|
|
214
|
-
|
|
215
|
-
- 补充英文版 README
|
|
216
|
-
- 增加 CLI 帮助输出截图/示例
|
|
217
|
-
- 明确 changelog 中的“支持矩阵”
|
|
218
|
-
- 补一组命令级集成测试(尤其错误与跳过提示)
|