dsh-agent-team-playbook 1.23.0 → 1.23.1
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 +5 -5
- package/bin/cli.mjs +101 -23
- package/cordis.patch.yml +5 -5
- package/lib/index.js +12 -9
- package/package.json +5 -5
- package/scripts/{sync-skill.mjs → sync-playbook.mjs} +22 -6
package/README.md
CHANGED
|
@@ -96,14 +96,14 @@ docs/workflow/practices/ 经验与做法库
|
|
|
96
96
|
dsh plugin --profile web add dsh-agent-team-playbook
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
装好后多一个只读命令 `/atp`(agent-team-playbook 的缩写;取名短而少见,因为 DSH 对重名命令是硬报错):
|
|
100
100
|
|
|
101
101
|
| 命令 | 作用 |
|
|
102
102
|
|---|---|
|
|
103
|
-
| `/
|
|
104
|
-
| `/
|
|
105
|
-
| `/
|
|
106
|
-
| `/
|
|
103
|
+
| `/atp` | 规程摘要(档位、四问、收尾三问)+ 安装方式 |
|
|
104
|
+
| `/atp core` | 输出核心全文,读完即在本轮按它协作 |
|
|
105
|
+
| `/atp paths` | 各分册的绝对路径,按需查阅 |
|
|
106
|
+
| `/atp help` | 用法 |
|
|
107
107
|
|
|
108
108
|
插件**不写任何文件**、也**不挂 skill**——skill 的目录摘要会常驻占用上下文(约 300 tokens/轮),而分册本来就不会自动进上下文,用命令按需取更划算。
|
|
109
109
|
|
package/bin/cli.mjs
CHANGED
|
@@ -2,21 +2,23 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* dsh-agent-team-playbook CLI
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* 插件安装本身**不写用户任何文件**(插件只注册只读命令)。本命令是唯一的写文件入口,
|
|
6
6
|
* 因此它必须对"覆盖用户已有文件"这件事极其保守:
|
|
7
7
|
*
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
8
|
+
* - 每个冲突都单独询问:覆盖已有 / 改名已有(备份你的文件) / 改名我们的 / 跳过 / 中止
|
|
9
|
+
* - 选「改名我们的」时,写出的文件里对它的引用一并改写,不留断链
|
|
10
|
+
* - 选「改名已有」时,你的原文件被加上后缀保留,我们占用原路径
|
|
11
|
+
* - 非交互环境遇到冲突默认中止,必须显式 --force / --skip-conflicts / --backup-existing
|
|
11
12
|
*
|
|
12
13
|
* 用法:
|
|
13
14
|
* npx dsh-agent-team-playbook init [--dir <目标目录>] [--dry-run]
|
|
14
|
-
*
|
|
15
|
+
* [--force | --skip-conflicts | --backup-existing]
|
|
16
|
+
* npx dsh-agent-team-playbook init --global [--inline-core] [--yes] [--dry-run]
|
|
15
17
|
*/
|
|
16
18
|
import { createInterface } from 'node:readline/promises'
|
|
17
19
|
import os from 'node:os'
|
|
18
20
|
import { stdin, stdout } from 'node:process'
|
|
19
|
-
import { readFile, writeFile, mkdir, stat, readdir } from 'node:fs/promises'
|
|
21
|
+
import { readFile, writeFile, mkdir, stat, readdir, rename } from 'node:fs/promises'
|
|
20
22
|
import { existsSync } from 'node:fs'
|
|
21
23
|
import path from 'node:path'
|
|
22
24
|
import { fileURLToPath } from 'node:url'
|
|
@@ -30,7 +32,7 @@ process.stdout.on('error', (err) => {
|
|
|
30
32
|
})
|
|
31
33
|
const SOURCE_ROOT = path.join(PACKAGE_ROOT, 'playbook')
|
|
32
34
|
|
|
33
|
-
/** 会被安装进用户项目的条目:playbook
|
|
35
|
+
/** 会被安装进用户项目的条目:playbook 本体(核心 + 分册)。 */
|
|
34
36
|
const ROOT_FILE = 'AGENTS.md'
|
|
35
37
|
const ROOT_DIR = 'docs'
|
|
36
38
|
|
|
@@ -52,6 +54,7 @@ function parseArgs(argv) {
|
|
|
52
54
|
global: false,
|
|
53
55
|
yes: false,
|
|
54
56
|
inlineCore: false,
|
|
57
|
+
backupExisting: false,
|
|
55
58
|
}
|
|
56
59
|
for (let i = 0; i < argv.length; i += 1) {
|
|
57
60
|
const a = argv[i]
|
|
@@ -62,6 +65,7 @@ function parseArgs(argv) {
|
|
|
62
65
|
else if (a === '--global' || a === '-g') opts.global = true
|
|
63
66
|
else if (a === '--yes' || a === '-y') opts.yes = true
|
|
64
67
|
else if (a === '--inline-core') opts.inlineCore = true
|
|
68
|
+
else if (a === '--backup-existing') opts.backupExisting = true
|
|
65
69
|
else if (a === '--help' || a === '-h') opts.help = true
|
|
66
70
|
else if (a === 'init') continue
|
|
67
71
|
else {
|
|
@@ -86,6 +90,7 @@ ${C.bold('选项')}
|
|
|
86
90
|
默认只写指针(约 200 tokens,agent 需先读一次文件)
|
|
87
91
|
--yes, -y 非交互确认(--global 追加区块用)
|
|
88
92
|
--dry-run 只显示计划,不写任何文件
|
|
93
|
+
--backup-existing 冲突时把已有项改名为 *<后缀>,再装我们的(不询问)
|
|
89
94
|
--force, -f 冲突时全部覆盖(不询问)
|
|
90
95
|
--skip-conflicts 冲突时全部跳过(不询问)
|
|
91
96
|
-h, --help 显示本帮助
|
|
@@ -98,7 +103,8 @@ ${C.bold('两种安装方式的区别(重要)')}
|
|
|
98
103
|
适用于"本机所有项目都按这套规程走"。
|
|
99
104
|
|
|
100
105
|
${C.bold('行为')}
|
|
101
|
-
·
|
|
106
|
+
· 交互模式下,每个冲突单独询问:
|
|
107
|
+
覆盖已有 / 改名已有(备份你的文件) / 改名我们的 / 跳过 / 剩余全部覆盖 / 中止
|
|
102
108
|
· 选"改名"时,文档里对它的引用会同步改写
|
|
103
109
|
· 非交互模式(管道、CI)遇到冲突默认中止,不会静默覆盖
|
|
104
110
|
`)
|
|
@@ -122,18 +128,24 @@ async function walk(relDir) {
|
|
|
122
128
|
return out.sort()
|
|
123
129
|
}
|
|
124
130
|
|
|
125
|
-
/**
|
|
126
|
-
|
|
131
|
+
/**
|
|
132
|
+
* 目标路径的冲突详情。`target` 是"改已有文件名"时要动的那个路径:
|
|
133
|
+
* - 同名文件已存在 → 改名该文件
|
|
134
|
+
* - 同名位置是目录 → 改名该目录(风险高,调用处需提示)
|
|
135
|
+
* - 上级是文件导致建不了目录 → 改名那个上级文件
|
|
136
|
+
*/
|
|
137
|
+
async function inspectConflict(destAbs) {
|
|
127
138
|
if (existsSync(destAbs)) {
|
|
128
139
|
const s = await stat(destAbs)
|
|
129
|
-
return s.isDirectory()
|
|
140
|
+
return s.isDirectory()
|
|
141
|
+
? { reason: '同名位置已是目录', kind: 'dir', target: destAbs }
|
|
142
|
+
: { reason: '文件已存在', kind: 'file', target: destAbs }
|
|
130
143
|
}
|
|
131
|
-
// 逐级检查父目录是否是文件
|
|
132
144
|
let p = path.dirname(destAbs)
|
|
133
145
|
while (p && p !== path.dirname(p)) {
|
|
134
146
|
if (existsSync(p)) {
|
|
135
147
|
const s = await stat(p)
|
|
136
|
-
if (!s.isDirectory()) return `上级 ${path.basename(p)}
|
|
148
|
+
if (!s.isDirectory()) return { reason: `上级 ${path.basename(p)} 是文件,无法创建目录`, kind: 'parent-file', target: p }
|
|
137
149
|
break
|
|
138
150
|
}
|
|
139
151
|
p = path.dirname(p)
|
|
@@ -141,6 +153,14 @@ async function describeConflict(destAbs) {
|
|
|
141
153
|
return null
|
|
142
154
|
}
|
|
143
155
|
|
|
156
|
+
/** 生成不冲突的备份路径。 */
|
|
157
|
+
function uniqueBackupPath(target, suffix) {
|
|
158
|
+
let to = `${target}${suffix}`
|
|
159
|
+
let i = 1
|
|
160
|
+
while (existsSync(to)) to = `${target}${suffix}-${i++}`
|
|
161
|
+
return to
|
|
162
|
+
}
|
|
163
|
+
|
|
144
164
|
/** 把引用改写应用到文本内容:先改目录前缀,再改根文件名。 */
|
|
145
165
|
function rewriteReferences(text, renames) {
|
|
146
166
|
let out = text
|
|
@@ -177,7 +197,6 @@ function managedBlock(destAbs, inlineCore, coreText) {
|
|
|
177
197
|
|
|
178
198
|
// 内联:核心全文进区块;相对路径改写为绝对路径,保证在任意工作区都能读到
|
|
179
199
|
const rewritten = coreText
|
|
180
|
-
.replace(/\(^\)/, '') // 不裁剪开头
|
|
181
200
|
.replace(/(^|[^/\w.-])AGENTS\.md(?![.\w-])/g, (_m, pre) => `${pre}${destAbs}/AGENTS.md`)
|
|
182
201
|
.split('docs/').join(`${destAbs}/docs/`)
|
|
183
202
|
|
|
@@ -215,7 +234,7 @@ async function runGlobalMode(opts) {
|
|
|
215
234
|
existing = await readFile(instrFile, 'utf8')
|
|
216
235
|
const hasBlock = existing.includes(BLOCK_START)
|
|
217
236
|
console.log(
|
|
218
|
-
C.dim(` ${instrFile} 已存在(${existing.length}
|
|
237
|
+
C.dim(` ${instrFile} 已存在(${existing.length} 字符),`) +
|
|
219
238
|
(hasBlock ? C.green('检测到本插件的受管区块 → 原地更新') : C.yellow('没有受管区块 → 需追加')),
|
|
220
239
|
)
|
|
221
240
|
if (!hasBlock && !opts.yes && !opts.force) {
|
|
@@ -291,19 +310,31 @@ async function main() {
|
|
|
291
310
|
console.error(C.red(`✗ 目标目录不存在:${opts.dir}`))
|
|
292
311
|
process.exit(1)
|
|
293
312
|
}
|
|
313
|
+
if (!(await stat(opts.dir)).isDirectory()) {
|
|
314
|
+
console.error(C.red(`✗ --dir 不是目录:${opts.dir}`))
|
|
315
|
+
process.exit(1)
|
|
316
|
+
}
|
|
294
317
|
|
|
295
318
|
// ── 1. 组装安装计划 ───────────────────────────────────────────────
|
|
296
319
|
const files = [{ rel: ROOT_FILE, group: ROOT_FILE }]
|
|
297
|
-
|
|
320
|
+
const docRels = await walk(ROOT_DIR)
|
|
321
|
+
if (docRels.length === 0) {
|
|
322
|
+
console.error(C.red(`✗ 包内缺少分册:${path.join(SOURCE_ROOT, ROOT_DIR)} 为空或不存在`))
|
|
323
|
+
process.exit(1)
|
|
324
|
+
}
|
|
325
|
+
for (const rel of docRels) files.push({ rel, group: ROOT_DIR })
|
|
298
326
|
|
|
299
327
|
// ── 2. 检测冲突(按 group 归并,避免逐文件轰炸式提问) ──────────────
|
|
300
328
|
const groups = new Map()
|
|
301
329
|
for (const f of files) {
|
|
302
330
|
const dest = path.join(opts.dir, f.rel)
|
|
303
|
-
const
|
|
304
|
-
if (
|
|
305
|
-
if (!groups.has(f.group)) groups.set(f.group, { reason, files: [] })
|
|
306
|
-
groups.get(f.group)
|
|
331
|
+
const c = await inspectConflict(dest)
|
|
332
|
+
if (c === null) continue
|
|
333
|
+
if (!groups.has(f.group)) groups.set(f.group, { reason: c.reason, kind: c.kind, targets: new Set(), files: [] })
|
|
334
|
+
const g = groups.get(f.group)
|
|
335
|
+
g.targets.add(c.target)
|
|
336
|
+
g.kind = g.kind === 'dir' ? 'dir' : c.kind
|
|
337
|
+
g.files.push(f.rel)
|
|
307
338
|
}
|
|
308
339
|
|
|
309
340
|
if (groups.size === 0) {
|
|
@@ -312,6 +343,7 @@ async function main() {
|
|
|
312
343
|
console.log(C.yellow(`⚠ 检测到 ${groups.size} 处冲突:`))
|
|
313
344
|
for (const [g, info] of groups) {
|
|
314
345
|
console.log(` · ${C.bold(g)} —— ${info.reason},影响 ${info.files.length} 个文件`)
|
|
346
|
+
for (const target of info.targets) console.log(C.dim(` 已有:${path.relative(opts.dir, target)}`))
|
|
315
347
|
}
|
|
316
348
|
}
|
|
317
349
|
|
|
@@ -319,6 +351,9 @@ async function main() {
|
|
|
319
351
|
const renames = []
|
|
320
352
|
const skipped = new Set()
|
|
321
353
|
const overwrite = new Set()
|
|
354
|
+
/** 被改名的"已有文件/目录":{from, to}。安装后原路径归我们使用。 */
|
|
355
|
+
const existingRenames = []
|
|
356
|
+
const defaultSuffix = `.bak-${new Date().toISOString().replace(/[-:T]/g, '').slice(0, 14)}`
|
|
322
357
|
|
|
323
358
|
const interactive = stdin.isTTY && stdout.isTTY
|
|
324
359
|
|
|
@@ -329,9 +364,18 @@ async function main() {
|
|
|
329
364
|
} else if (opts.skipConflicts) {
|
|
330
365
|
for (const g of groups.keys()) skipped.add(g)
|
|
331
366
|
console.log(C.dim(' --skip-conflicts:全部跳过'))
|
|
367
|
+
} else if (opts.backupExisting) {
|
|
368
|
+
for (const [g, info] of groups) {
|
|
369
|
+
for (const target of info.targets) {
|
|
370
|
+
const to = uniqueBackupPath(target, defaultSuffix)
|
|
371
|
+
existingRenames.push({ from: target, to, group: g })
|
|
372
|
+
}
|
|
373
|
+
overwrite.add(g)
|
|
374
|
+
}
|
|
375
|
+
console.log(C.dim(` --backup-existing:已有冲突项将改名为 *${defaultSuffix}`))
|
|
332
376
|
} else if (!interactive) {
|
|
333
377
|
console.error(C.red('\n✗ 非交互环境下检测到冲突,已中止(不会静默覆盖)。'))
|
|
334
|
-
console.error(' 可选:--force
|
|
378
|
+
console.error(' 可选:--force 全部覆盖|--skip-conflicts 全部跳过|--backup-existing 备份已有项后安装|或手动指定 --dir。')
|
|
335
379
|
process.exit(1)
|
|
336
380
|
} else {
|
|
337
381
|
const rl = createInterface({ input: stdin, output: stdout })
|
|
@@ -346,14 +390,34 @@ async function main() {
|
|
|
346
390
|
console.log(`\n${C.bold('冲突:')}${g}${isDir ? '(目录)' : ''}`)
|
|
347
391
|
const answer = (
|
|
348
392
|
await rl.question(
|
|
349
|
-
` ${C.bold('[o]')}
|
|
393
|
+
` ${C.bold('[o]')} 覆盖已有 ${C.bold('[e]')} 改名已有 ${C.bold('[r]')} 改名我们的 ${C.bold('[s]')} 跳过 ${C.bold('[a]')} 剩余全部覆盖 ${C.bold('[q]')} 中止 > `,
|
|
350
394
|
)
|
|
351
395
|
)
|
|
352
396
|
.trim()
|
|
353
397
|
.toLowerCase()
|
|
354
398
|
|
|
355
399
|
if (answer === 'o') overwrite.add(g)
|
|
356
|
-
else if (answer === '
|
|
400
|
+
else if (answer === 'e') {
|
|
401
|
+
const targets = [...groups.get(g).targets]
|
|
402
|
+
const risky = groups.get(g).kind === 'dir'
|
|
403
|
+
if (risky) {
|
|
404
|
+
console.log(C.yellow(' ⚠ 同名位置是目录:改名后你项目里对它的引用会指向我们的版本,请自行确认。'))
|
|
405
|
+
}
|
|
406
|
+
const suffix = (await rl.question(` 给已有项加的后缀(默认 ${defaultSuffix})> `)).trim() || defaultSuffix
|
|
407
|
+
if (!/^[.A-Za-z0-9_-]+$/.test(suffix)) {
|
|
408
|
+
console.log(C.yellow(' 后缀只能含字母数字点下划线横线,按跳过处理。'))
|
|
409
|
+
skipped.add(g)
|
|
410
|
+
continue
|
|
411
|
+
}
|
|
412
|
+
for (const target of targets) {
|
|
413
|
+
const to = uniqueBackupPath(target, suffix)
|
|
414
|
+
existingRenames.push({ from: target, to, group: g })
|
|
415
|
+
}
|
|
416
|
+
overwrite.add(g)
|
|
417
|
+
for (const r of existingRenames.filter((r) => r.group === g)) {
|
|
418
|
+
console.log(C.dim(` → ${path.relative(opts.dir, r.from)} 改名为 ${path.relative(opts.dir, r.to)}`))
|
|
419
|
+
}
|
|
420
|
+
} else if (answer === 'a') {
|
|
357
421
|
overwrite.add(g)
|
|
358
422
|
overwriteRest = true
|
|
359
423
|
} else if (answer === 's') skipped.add(g)
|
|
@@ -410,12 +474,26 @@ async function main() {
|
|
|
410
474
|
if (refRenames.length > 0) {
|
|
411
475
|
console.log(C.dim(`\n引用同步改写:${refRenames.map((r) => `${r.from} → ${r.to}`).join(',')}`))
|
|
412
476
|
}
|
|
477
|
+
if (existingRenames.length > 0) {
|
|
478
|
+
console.log(C.dim(`已有项改名:${existingRenames.map((r) => `${path.relative(opts.dir, r.from)} → ${path.relative(opts.dir, r.to)}`).join(',')}`))
|
|
479
|
+
}
|
|
413
480
|
|
|
414
481
|
if (opts.dryRun) {
|
|
415
482
|
console.log(C.dim('\n(dry-run 结束)'))
|
|
416
483
|
return
|
|
417
484
|
}
|
|
418
485
|
|
|
486
|
+
// ── 5.5 先腾出原路径(改名已有项),再写我们的 ────────────────────
|
|
487
|
+
for (const r of existingRenames) {
|
|
488
|
+
try {
|
|
489
|
+
await mkdir(path.dirname(r.to), { recursive: true })
|
|
490
|
+
await rename(r.from, r.to)
|
|
491
|
+
} catch (error) {
|
|
492
|
+
console.error(C.red(`✗ 改名失败:${r.from} → ${r.to}(${error.message})。后续文件未写入。`))
|
|
493
|
+
process.exit(1)
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
419
497
|
let written = 0
|
|
420
498
|
for (const item of plan) {
|
|
421
499
|
const srcAbs = path.join(SOURCE_ROOT, item.rel)
|
package/cordis.patch.yml
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# dsh-agent-team-playbook —— DSH bundle patch
|
|
2
2
|
#
|
|
3
|
-
# 挂载本插件,注册只读命令 `/
|
|
4
|
-
# /
|
|
5
|
-
# /
|
|
6
|
-
# /
|
|
7
|
-
# /
|
|
3
|
+
# 挂载本插件,注册只读命令 `/atp`:
|
|
4
|
+
# /atp 规程摘要 + 安装方式
|
|
5
|
+
# /atp core 核心全文(读完即在本轮遵循)
|
|
6
|
+
# /atp paths 分册绝对路径
|
|
7
|
+
# /atp help 用法
|
|
8
8
|
#
|
|
9
9
|
# 本插件不写任何文件,也不挂载 skill:
|
|
10
10
|
# · 不挂 skill 是因为 skill 的目录摘要会常驻占用上下文(约 300 tokens/轮),
|
package/lib/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dsh-agent-team-playbook — DSH 命令插件(Host 半身)
|
|
3
3
|
*
|
|
4
|
-
* 提供一个只读命令 `/agent-team
|
|
5
|
-
* /
|
|
6
|
-
* /
|
|
7
|
-
* /
|
|
8
|
-
* /
|
|
4
|
+
* 提供一个只读命令 `/atp`(agent-team-playbook 缩写),把多智能体协作规程带进对话:
|
|
5
|
+
* /atp 摘要(档位、四问、收尾三问、如何装成常驻)
|
|
6
|
+
* /atp core 核心全文(读完即在本轮遵循)
|
|
7
|
+
* /atp paths 各分册的绝对路径
|
|
8
|
+
* /atp help 用法
|
|
9
|
+
*
|
|
10
|
+
* 命令名刻意取得短而少见:DSH 对重名命令是**硬报错**(plugin 加载失败),
|
|
11
|
+
* 用 `agent-team` 这种通用词容易被其他插件或后续官方功能占用。
|
|
9
12
|
*
|
|
10
13
|
* 本插件**不写任何文件**。要让规程成为每个 agent 每轮的固定上下文,
|
|
11
14
|
* 用 CLI 安装:`npx dsh-agent-team-playbook init`(项目级)或 `init --global`(全局)。
|
|
@@ -30,7 +33,7 @@ const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)),
|
|
|
30
33
|
const PLAYBOOK_DIR = path.join(PACKAGE_ROOT, 'playbook')
|
|
31
34
|
|
|
32
35
|
const USAGE = [
|
|
33
|
-
'用法:/
|
|
36
|
+
'用法:/atp [core|paths|help]',
|
|
34
37
|
'',
|
|
35
38
|
' (无参数) 规程摘要与安装方式',
|
|
36
39
|
' core 输出核心全文(约 5k 字符),读完即在本轮按它协作',
|
|
@@ -65,7 +68,7 @@ function readPlaybook(rel) {
|
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
70
|
|
|
68
|
-
/** 列出分册路径(用于 /
|
|
71
|
+
/** 列出分册路径(用于 /atp paths)。 */
|
|
69
72
|
function renderPaths() {
|
|
70
73
|
const rulesDir = path.join(PLAYBOOK_DIR, 'docs/workflow/rules')
|
|
71
74
|
const lines = [`核心:\`${path.join(PLAYBOOK_DIR, 'AGENTS.md')}\``, '', '分册:']
|
|
@@ -137,8 +140,8 @@ function handleCommand(invocation) {
|
|
|
137
140
|
export function apply(ctx) {
|
|
138
141
|
ctx.commands.register({
|
|
139
142
|
definitionId: 'dsh-agent-team-playbook',
|
|
140
|
-
name: '
|
|
141
|
-
description: '
|
|
143
|
+
name: 'atp',
|
|
144
|
+
description: '多智能体协作规程(agent-team-playbook):摘要 / 核心全文 / 分册路径(只读)',
|
|
142
145
|
input: { hint: '[core|paths|help]' },
|
|
143
146
|
handler: handleCommand,
|
|
144
147
|
})
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-agent-team-playbook",
|
|
3
|
-
"version": "1.23.
|
|
4
|
-
"description": "DeepSeek Harness
|
|
3
|
+
"version": "1.23.1",
|
|
4
|
+
"description": "DeepSeek Harness plugin that brings an executable multi-agent collaboration workflow (charter, triage tiers, six-stage pipeline, audit gates, experience library): a read-only /agent-team command plus a collision-aware installer for the documents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "ChongCyrus",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"node": ">=20"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
|
-
"sync": "node scripts/sync-
|
|
46
|
-
"check": "node scripts/sync-
|
|
47
|
-
"prepack": "node scripts/sync-
|
|
45
|
+
"sync": "node scripts/sync-playbook.mjs",
|
|
46
|
+
"check": "node scripts/sync-playbook.mjs --check",
|
|
47
|
+
"prepack": "node scripts/sync-playbook.mjs"
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* 绝不碰手写文件。
|
|
11
11
|
*
|
|
12
12
|
* 用法:
|
|
13
|
-
* node scripts/sync-
|
|
14
|
-
* node scripts/sync-
|
|
13
|
+
* node scripts/sync-playbook.mjs # 生成/更新
|
|
14
|
+
* node scripts/sync-playbook.mjs --check # 只校验,不一致则退出码 1
|
|
15
15
|
*/
|
|
16
16
|
import { readFile, writeFile, mkdir, rm, readdir } from 'node:fs/promises'
|
|
17
17
|
import { existsSync } from 'node:fs'
|
|
@@ -20,7 +20,7 @@ import { fileURLToPath } from 'node:url'
|
|
|
20
20
|
|
|
21
21
|
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
22
22
|
const DEST_DIR = path.join(ROOT, 'playbook')
|
|
23
|
-
const MANIFEST = path.join(ROOT, '.
|
|
23
|
+
const MANIFEST = path.join(ROOT, '.playbook-sync.json')
|
|
24
24
|
const CHECK = process.argv.includes('--check')
|
|
25
25
|
|
|
26
26
|
/** 需要同步的源文件(相对仓库根),保持目录结构以让文档内的相对引用继续有效。 */
|
|
@@ -63,7 +63,7 @@ async function readManifest() {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
async function main() {
|
|
66
|
-
await mkdir(DEST_DIR, { recursive: true })
|
|
66
|
+
if (!CHECK) await mkdir(DEST_DIR, { recursive: true })
|
|
67
67
|
|
|
68
68
|
const wanted = new Set(SOURCES)
|
|
69
69
|
for (const dir of SOURCE_DIRS) {
|
|
@@ -108,12 +108,28 @@ async function main() {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
if (CHECK) {
|
|
111
|
-
|
|
111
|
+
// 目标目录里不该有清单外的文件(防残留,例如已废弃的 SKILL.md)
|
|
112
|
+
const unexpected = []
|
|
113
|
+
const walkDest = async (relDir) => {
|
|
114
|
+
const abs = path.join(DEST_DIR, relDir)
|
|
115
|
+
if (!existsSync(abs)) return
|
|
116
|
+
for (const entry of await readdir(abs, { withFileTypes: true })) {
|
|
117
|
+
const rel = relDir === '' ? entry.name : path.posix.join(relDir, entry.name)
|
|
118
|
+
if (entry.isDirectory()) await walkDest(rel)
|
|
119
|
+
else if (!wanted.has(rel)) unexpected.push(rel)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
await walkDest('')
|
|
123
|
+
const problems = [
|
|
124
|
+
...missing,
|
|
125
|
+
...drifted.map((rel) => `未同步:${rel}`),
|
|
126
|
+
...unexpected.map((rel) => `多余文件:${rel}`),
|
|
127
|
+
]
|
|
112
128
|
if (stale.length > 0) problems.push(`残留:${stale.join(', ')}`)
|
|
113
129
|
if (problems.length > 0) {
|
|
114
130
|
console.error('✗ playbook/ 与源文档不一致:')
|
|
115
131
|
for (const p of problems) console.error(' -', p)
|
|
116
|
-
console.error(' 修复:node scripts/sync-
|
|
132
|
+
console.error(' 修复:node scripts/sync-playbook.mjs')
|
|
117
133
|
process.exit(1)
|
|
118
134
|
}
|
|
119
135
|
console.log(`✓ playbook 内容与源文档一致(${files.length} 个文件)`)
|