dsh-agent-team-playbook 1.22.2 → 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.
Files changed (22) hide show
  1. package/README.md +22 -14
  2. package/bin/cli.mjs +139 -31
  3. package/cordis.patch.yml +15 -18
  4. package/lib/index.js +125 -53
  5. package/package.json +8 -8
  6. package/scripts/{sync-skill.mjs → sync-playbook.mjs} +31 -15
  7. package/skills/agent-team-playbook/SKILL.md +0 -68
  8. /package/{skills/agent-team-playbook → playbook}/AGENTS.md +0 -0
  9. /package/{skills/agent-team-playbook → playbook}/docs/assets/architecture.svg +0 -0
  10. /package/{skills/agent-team-playbook → playbook}/docs/workflow/practices/001-/345/244/232/346/231/272/350/203/275/344/275/223/346/226/207/346/241/243/347/232/204/350/207/252/346/210/221/350/206/250/350/203/200.md" +0 -0
  11. /package/{skills/agent-team-playbook → playbook}/docs/workflow/practices/002-/346/213/206/345/210/206/345/220/216/345/274/225/347/224/250/345/244/261/346/225/210.md" +0 -0
  12. /package/{skills/agent-team-playbook → playbook}/docs/workflow/practices/003-/346/211/271/351/207/217/346/233/277/346/215/242/344/270/216/346/224/271/345/220/215/345/220/216/347/232/204/345/206/205/345/256/271/345/244/261/347/234/237.md" +0 -0
  13. /package/{skills/agent-team-playbook → playbook}/docs/workflow/practices/README.md +0 -0
  14. /package/{skills/agent-team-playbook → playbook}/docs/workflow/rules/01-/346/200/273/347/272/262/347/273/206/345/210/231.md" +0 -0
  15. /package/{skills/agent-team-playbook → playbook}/docs/workflow/rules/02-/346/225/210/347/216/207/344/270/216/346/241/243/344/275/215/350/257/246/350/247/243.md" +0 -0
  16. /package/{skills/agent-team-playbook → playbook}/docs/workflow/rules/03-/346/265/201/346/260/264/347/272/277.md" +0 -0
  17. /package/{skills/agent-team-playbook → playbook}/docs/workflow/rules/04-/344/273/273/345/212/241/344/271/246/346/250/241/346/235/277.md" +0 -0
  18. /package/{skills/agent-team-playbook → playbook}/docs/workflow/rules/05-/344/273/273/345/212/241/346/235/277.md" +0 -0
  19. /package/{skills/agent-team-playbook → playbook}/docs/workflow/rules/06-/345/215/217/344/275/234/347/273/206/345/210/231.md" +0 -0
  20. /package/{skills/agent-team-playbook → playbook}/docs/workflow/rules/07-/347/224/250/346/210/267/344/272/244/344/272/222/344/270/216/345/272/246/351/207/217.md" +0 -0
  21. /package/{skills/agent-team-playbook → playbook}/docs/workflow/rules/08-/345/217/215/346/250/241/345/274/217/344/270/216/351/200/237/346/237/245.md" +0 -0
  22. /package/{skills/agent-team-playbook → playbook}/docs/workflow/rules/09-/347/216/257/345/242/203/351/200/202/351/205/215/344/270/216/345/217/230/346/233/264/350/256/260/345/275/225.md" +0 -0
package/README.md CHANGED
@@ -90,31 +90,39 @@ docs/workflow/practices/ 经验与做法库
90
90
 
91
91
  ## 安装
92
92
 
93
- ### 作为 DSH skill(推荐,只读、零侵入)
93
+ ### ① 作为 DSH 插件(只读命令,零写入)
94
94
 
95
95
  ```bash
96
96
  dsh plugin --profile web add dsh-agent-team-playbook
97
97
  ```
98
98
 
99
- - 插件的**全部作用**是把本 playbook 挂成一个 skill(`agent-team-playbook`),让 agent 在需要时按需加载。
100
- - **不会写你任何文件**:skill 内容只读地放在包里,通过官方 `dsh-skill-filesystem` 提供器挂载。
101
- - 如果已有同名 skill,DSH 对同名 skill **不报错、只静默择优**——本插件会在启动时检测并在被其他来源遮蔽时给出 warn 提示。
99
+ 装好后多一个只读命令 `/atp`(agent-team-playbook 的缩写;取名短而少见,因为 DSH 对重名命令是硬报错):
102
100
 
103
- ### 把 playbook 装进项目(可选,会写文件)
101
+ | 命令 | 作用 |
102
+ |---|---|
103
+ | `/atp` | 规程摘要(档位、四问、收尾三问)+ 安装方式 |
104
+ | `/atp core` | 输出核心全文,读完即在本轮按它协作 |
105
+ | `/atp paths` | 各分册的绝对路径,按需查阅 |
106
+ | `/atp help` | 用法 |
107
+
108
+ 插件**不写任何文件**、也**不挂 skill**——skill 的目录摘要会常驻占用上下文(约 300 tokens/轮),而分册本来就不会自动进上下文,用命令按需取更划算。
109
+
110
+ ### ② 装成"常驻上下文"(会写文件,核心价值)
104
111
 
105
112
  ```bash
106
113
  npx dsh-agent-team-playbook init --dry-run # 先看计划
107
- npx dsh-agent-team-playbook init # 交互式安装
114
+ npx dsh-agent-team-playbook init # 装进当前项目
115
+ npx dsh-agent-team-playbook init --global # 用户全局:受管区块(指针,约 300 字符)
116
+ npx dsh-agent-team-playbook init --global --inline-core # 用户全局:内联核心全文(真常驻)
108
117
  ```
109
118
 
110
- **两种安装方式的区别(重要)**:
111
-
112
- | 方式 | 效果 |
113
- |---|---|
114
- | `init`(默认) | 写 `<项目>/AGENTS.md` + `docs/` → 工作区 AGENTS.md 被 DSH 每轮自动注入 = **所有 agent 的固定上下文** |
115
- | `init --global` | 复制到 `$DSH_HOME/agent-team-playbook/`,并在 `$DSH_HOME/AGENTS.md` 维护一个**受管区块**(块外内容不动,幂等更新) |
119
+ | 方式 | 效果 | 常驻成本 |
120
+ |---|---|---|
121
+ | `init`(项目级) | 写 `<项目>/AGENTS.md` + `docs/` → DSH 每轮自动注入 | 约 5.3k 字符/轮 |
122
+ | `init --global` | 复制到 `$DSH_HOME/agent-team-playbook/`,在 `$DSH_HOME/AGENTS.md` 维护受管区块(指针) | 约 300 字符/轮 |
123
+ | `init --global --inline-core` | 同上,但区块内联核心全文(路径自动绝对化) | 约 6.3k 字符/轮 |
116
124
 
117
- > **为什么必须写文件**:DSH 的指令加载器(`dsh-agent-instructions`)只认文件(项目根/子目录/用户全局的 `AGENTS.md`、`CLAUDE.md`、`*.local.md`),**没有插件注入通道**。所以「常驻上下文」= 文件;skill 只是「按需查阅」。
125
+ > **为什么必须写文件**:DSH 的指令加载器(`dsh-agent-instructions`)只认文件(项目根/子目录/用户全局的 `AGENTS.md`、`CLAUDE.md`、`*.local.md`),**没有插件注入通道**。所以「常驻上下文」只能靠文件;命令和分册都是按需取。
118
126
 
119
127
  冲突处理是本命令的核心设计:
120
128
 
@@ -123,7 +131,7 @@ npx dsh-agent-team-playbook init # 交互式安装
123
131
  | 目标目录没有同名内容 | 直接安装 `AGENTS.md` + `docs/` |
124
132
  | 检测到冲突 | **逐个询问**:覆盖 / 改名 / 跳过 / 剩余全部覆盖 / 中止 |
125
133
  | 选了「改名」 | 写出的文件里对它的引用**同步改写**(如 `AGENTS.md` → `AGENTS.playbook.md`、`docs/` → `team-docs/`),不留断链 |
126
- | 管道 / CI(非交互) | **默认中止**,绝不静默覆盖;需显式 `--force` 或 `--skip-conflicts` |
134
+ | 管道 / CI(非交互) | **默认中止**,绝不静默覆盖;需显式 `--force` / `--skip-conflicts` / `--yes` |
127
135
 
128
136
  ## 快速开始
129
137
 
package/bin/cli.mjs CHANGED
@@ -2,29 +2,37 @@
2
2
  /**
3
3
  * dsh-agent-team-playbook CLI
4
4
  *
5
- * 插件安装本身**不写用户任何文件**(skill 是只读挂载)。本命令是唯一的写文件入口,
5
+ * 插件安装本身**不写用户任何文件**(插件只注册只读命令)。本命令是唯一的写文件入口,
6
6
  * 因此它必须对"覆盖用户已有文件"这件事极其保守:
7
7
  *
8
- * - 每个冲突都单独询问:覆盖 / 改名 / 跳过 / 剩余全部覆盖 / 中止
9
- * - 选"改名"时,写出的文件里对它的引用一并改写,不留断链
10
- * - 非交互环境(CI / 管道)遇到冲突默认中止,必须显式 --force 或 --skip-conflicts
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
- * [--force | --skip-conflicts]
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'
23
25
 
24
26
  const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
25
- const SOURCE_ROOT = path.join(PACKAGE_ROOT, 'skills', 'agent-team-playbook')
26
27
 
27
- /** 会被安装进用户项目的条目:playbook 本体,不含 SKILL.md(那是 skill 入口)与同步清单。 */
28
+ // 管道被下游提前关闭(如 | head)时安静退出,不抛未捕获错误
29
+ process.stdout.on('error', (err) => {
30
+ if (err?.code === 'EPIPE') process.exit(0)
31
+ throw err
32
+ })
33
+ const SOURCE_ROOT = path.join(PACKAGE_ROOT, 'playbook')
34
+
35
+ /** 会被安装进用户项目的条目:playbook 本体(核心 + 分册)。 */
28
36
  const ROOT_FILE = 'AGENTS.md'
29
37
  const ROOT_DIR = 'docs'
30
38
 
@@ -45,6 +53,8 @@ function parseArgs(argv) {
45
53
  help: false,
46
54
  global: false,
47
55
  yes: false,
56
+ inlineCore: false,
57
+ backupExisting: false,
48
58
  }
49
59
  for (let i = 0; i < argv.length; i += 1) {
50
60
  const a = argv[i]
@@ -54,6 +64,8 @@ function parseArgs(argv) {
54
64
  else if (a === '--skip-conflicts') opts.skipConflicts = true
55
65
  else if (a === '--global' || a === '-g') opts.global = true
56
66
  else if (a === '--yes' || a === '-y') opts.yes = true
67
+ else if (a === '--inline-core') opts.inlineCore = true
68
+ else if (a === '--backup-existing') opts.backupExisting = true
57
69
  else if (a === '--help' || a === '-h') opts.help = true
58
70
  else if (a === 'init') continue
59
71
  else {
@@ -74,8 +86,11 @@ ${C.bold('选项')}
74
86
  --dir <路径> 目标目录(默认当前目录)
75
87
  --global, -g 装成用户全局指令:复制到 $DSH_HOME/agent-team-playbook/,
76
88
  并在 $DSH_HOME/AGENTS.md 追加一个受管区块(不覆盖原有内容)
89
+ --inline-core 配合 --global:把核心全文内联进区块(每轮真常驻,约 3.3k tokens),
90
+ 默认只写指针(约 200 tokens,agent 需先读一次文件)
77
91
  --yes, -y 非交互确认(--global 追加区块用)
78
92
  --dry-run 只显示计划,不写任何文件
93
+ --backup-existing 冲突时把已有项改名为 *<后缀>,再装我们的(不询问)
79
94
  --force, -f 冲突时全部覆盖(不询问)
80
95
  --skip-conflicts 冲突时全部跳过(不询问)
81
96
  -h, --help 显示本帮助
@@ -88,7 +103,8 @@ ${C.bold('两种安装方式的区别(重要)')}
88
103
  适用于"本机所有项目都按这套规程走"。
89
104
 
90
105
  ${C.bold('行为')}
91
- · 交互模式下,每个冲突单独询问:覆盖 / 改名 / 跳过 / 剩余全部覆盖 / 中止
106
+ · 交互模式下,每个冲突单独询问:
107
+ 覆盖已有 / 改名已有(备份你的文件) / 改名我们的 / 跳过 / 剩余全部覆盖 / 中止
92
108
  · 选"改名"时,文档里对它的引用会同步改写
93
109
  · 非交互模式(管道、CI)遇到冲突默认中止,不会静默覆盖
94
110
  `)
@@ -112,18 +128,24 @@ async function walk(relDir) {
112
128
  return out.sort()
113
129
  }
114
130
 
115
- /** 目标路径当前是否被占用(含"父级是文件"这种无法创建目录的情况)。 */
116
- async function describeConflict(destAbs) {
131
+ /**
132
+ * 目标路径的冲突详情。`target` 是"改已有文件名"时要动的那个路径:
133
+ * - 同名文件已存在 → 改名该文件
134
+ * - 同名位置是目录 → 改名该目录(风险高,调用处需提示)
135
+ * - 上级是文件导致建不了目录 → 改名那个上级文件
136
+ */
137
+ async function inspectConflict(destAbs) {
117
138
  if (existsSync(destAbs)) {
118
139
  const s = await stat(destAbs)
119
- return s.isDirectory() ? '目录已存在' : '文件已存在'
140
+ return s.isDirectory()
141
+ ? { reason: '同名位置已是目录', kind: 'dir', target: destAbs }
142
+ : { reason: '文件已存在', kind: 'file', target: destAbs }
120
143
  }
121
- // 逐级检查父目录是否是文件
122
144
  let p = path.dirname(destAbs)
123
145
  while (p && p !== path.dirname(p)) {
124
146
  if (existsSync(p)) {
125
147
  const s = await stat(p)
126
- if (!s.isDirectory()) return `上级 ${path.basename(p)} 是文件,无法创建目录`
148
+ if (!s.isDirectory()) return { reason: `上级 ${path.basename(p)} 是文件,无法创建目录`, kind: 'parent-file', target: p }
127
149
  break
128
150
  }
129
151
  p = path.dirname(p)
@@ -131,6 +153,14 @@ async function describeConflict(destAbs) {
131
153
  return null
132
154
  }
133
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
+
134
164
  /** 把引用改写应用到文本内容:先改目录前缀,再改根文件名。 */
135
165
  function rewriteReferences(text, renames) {
136
166
  let out = text
@@ -149,15 +179,32 @@ function rewriteReferences(text, renames) {
149
179
  const BLOCK_START = '<!-- agent-team-playbook:start -->'
150
180
  const BLOCK_END = '<!-- agent-team-playbook:end -->'
151
181
 
152
- function managedBlock(destAbs) {
182
+ function managedBlock(destAbs, inlineCore, coreText) {
183
+ const footer = '> 本节由 `npx dsh-agent-team-playbook init --global` 维护,块内内容会被自动覆盖;块外内容不受影响。'
184
+
185
+ if (!inlineCore) {
186
+ return [
187
+ BLOCK_START,
188
+ '## 多智能体协作规程(agent-team-playbook)',
189
+ '',
190
+ `本机所有项目按以下规程协作:\`${destAbs}/AGENTS.md\`(常驻核心,先读它)。`,
191
+ `分册细则在 \`${destAbs}/docs/workflow/\`,按核心 §8 索引按需查阅。`,
192
+ '',
193
+ footer,
194
+ BLOCK_END,
195
+ ].join('\n')
196
+ }
197
+
198
+ // 内联:核心全文进区块;相对路径改写为绝对路径,保证在任意工作区都能读到
199
+ const rewritten = coreText
200
+ .replace(/(^|[^/\w.-])AGENTS\.md(?![.\w-])/g, (_m, pre) => `${pre}${destAbs}/AGENTS.md`)
201
+ .split('docs/').join(`${destAbs}/docs/`)
202
+
153
203
  return [
154
204
  BLOCK_START,
155
- '## 多智能体协作规程(agent-team-playbook)',
156
- '',
157
- `本机所有项目按以下规程协作:\`${destAbs}/AGENTS.md\`(常驻核心,先读它)。`,
158
- `分册细则在 \`${destAbs}/docs/workflow/\`,按核心 §8 索引按需查阅。`,
205
+ rewritten.replace(/\s+$/, ''),
159
206
  '',
160
- '> 本节由 `npx dsh-agent-team-playbook init --global` 维护,块内内容会被自动覆盖;块外内容不受影响。',
207
+ footer,
161
208
  BLOCK_END,
162
209
  ].join('\n')
163
210
  }
@@ -173,10 +220,12 @@ async function runGlobalMode(opts) {
173
220
  const home = process.env.DSH_HOME || path.join(os.homedir(), '.dsh')
174
221
  const destDir = path.join(home, 'agent-team-playbook')
175
222
  const instrFile = path.join(home, 'AGENTS.md')
176
- const block = managedBlock(destDir)
223
+ const coreText = await readFile(path.join(SOURCE_ROOT, 'AGENTS.md'), 'utf8')
224
+ const block = managedBlock(destDir, opts.inlineCore, coreText)
177
225
 
178
226
  const rels = [ROOT_FILE, ...(await walk(ROOT_DIR))]
179
227
  console.log(C.bold('全局安装计划'))
228
+ console.log(C.dim(` 区块模式:${opts.inlineCore ? '内联核心全文(每轮真常驻)' : '指针(默认,agent 需先读一次文件)'}`))
180
229
  console.log(` 复制 ${rels.length} 个文件 → ${destDir}`)
181
230
  console.log(` 维护受管区块 → ${instrFile}`)
182
231
 
@@ -185,7 +234,7 @@ async function runGlobalMode(opts) {
185
234
  existing = await readFile(instrFile, 'utf8')
186
235
  const hasBlock = existing.includes(BLOCK_START)
187
236
  console.log(
188
- C.dim(` ${instrFile} 已存在(${existing.length} 字节),`) +
237
+ C.dim(` ${instrFile} 已存在(${existing.length} 字符),`) +
189
238
  (hasBlock ? C.green('检测到本插件的受管区块 → 原地更新') : C.yellow('没有受管区块 → 需追加')),
190
239
  )
191
240
  if (!hasBlock && !opts.yes && !opts.force) {
@@ -250,7 +299,7 @@ async function main() {
250
299
  if (opts.help) return printHelp()
251
300
 
252
301
  if (!existsSync(SOURCE_ROOT)) {
253
- console.error(C.red(`✗ 找不到包内 skill 目录:${SOURCE_ROOT}`))
302
+ console.error(C.red(`✗ 找不到包内 playbook 目录:${SOURCE_ROOT}`))
254
303
  process.exit(1)
255
304
  }
256
305
  if (opts.global) {
@@ -261,19 +310,31 @@ async function main() {
261
310
  console.error(C.red(`✗ 目标目录不存在:${opts.dir}`))
262
311
  process.exit(1)
263
312
  }
313
+ if (!(await stat(opts.dir)).isDirectory()) {
314
+ console.error(C.red(`✗ --dir 不是目录:${opts.dir}`))
315
+ process.exit(1)
316
+ }
264
317
 
265
318
  // ── 1. 组装安装计划 ───────────────────────────────────────────────
266
319
  const files = [{ rel: ROOT_FILE, group: ROOT_FILE }]
267
- for (const rel of await walk(ROOT_DIR)) files.push({ rel, group: ROOT_DIR })
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 })
268
326
 
269
327
  // ── 2. 检测冲突(按 group 归并,避免逐文件轰炸式提问) ──────────────
270
328
  const groups = new Map()
271
329
  for (const f of files) {
272
330
  const dest = path.join(opts.dir, f.rel)
273
- const reason = await describeConflict(dest)
274
- if (reason === null) continue
275
- if (!groups.has(f.group)) groups.set(f.group, { reason, files: [] })
276
- groups.get(f.group).files.push(f.rel)
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)
277
338
  }
278
339
 
279
340
  if (groups.size === 0) {
@@ -282,6 +343,7 @@ async function main() {
282
343
  console.log(C.yellow(`⚠ 检测到 ${groups.size} 处冲突:`))
283
344
  for (const [g, info] of groups) {
284
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)}`))
285
347
  }
286
348
  }
287
349
 
@@ -289,6 +351,9 @@ async function main() {
289
351
  const renames = []
290
352
  const skipped = new Set()
291
353
  const overwrite = new Set()
354
+ /** 被改名的"已有文件/目录":{from, to}。安装后原路径归我们使用。 */
355
+ const existingRenames = []
356
+ const defaultSuffix = `.bak-${new Date().toISOString().replace(/[-:T]/g, '').slice(0, 14)}`
292
357
 
293
358
  const interactive = stdin.isTTY && stdout.isTTY
294
359
 
@@ -299,9 +364,18 @@ async function main() {
299
364
  } else if (opts.skipConflicts) {
300
365
  for (const g of groups.keys()) skipped.add(g)
301
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}`))
302
376
  } else if (!interactive) {
303
377
  console.error(C.red('\n✗ 非交互环境下检测到冲突,已中止(不会静默覆盖)。'))
304
- console.error(' 可选:--force 全部覆盖,或 --skip-conflicts 全部跳过,或手动指定 --dir。')
378
+ console.error(' 可选:--force 全部覆盖|--skip-conflicts 全部跳过|--backup-existing 备份已有项后安装|或手动指定 --dir。')
305
379
  process.exit(1)
306
380
  } else {
307
381
  const rl = createInterface({ input: stdin, output: stdout })
@@ -316,14 +390,34 @@ async function main() {
316
390
  console.log(`\n${C.bold('冲突:')}${g}${isDir ? '(目录)' : ''}`)
317
391
  const answer = (
318
392
  await rl.question(
319
- ` ${C.bold('[o]')} 覆盖 ${C.bold('[r]')} 改名 ${C.bold('[s]')} 跳过 ${C.bold('[a]')} 剩余全部覆盖 ${C.bold('[q]')} 中止 > `,
393
+ ` ${C.bold('[o]')} 覆盖已有 ${C.bold('[e]')} 改名已有 ${C.bold('[r]')} 改名我们的 ${C.bold('[s]')} 跳过 ${C.bold('[a]')} 剩余全部覆盖 ${C.bold('[q]')} 中止 > `,
320
394
  )
321
395
  )
322
396
  .trim()
323
397
  .toLowerCase()
324
398
 
325
399
  if (answer === 'o') overwrite.add(g)
326
- else if (answer === 'a') {
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') {
327
421
  overwrite.add(g)
328
422
  overwriteRest = true
329
423
  } else if (answer === 's') skipped.add(g)
@@ -380,12 +474,26 @@ async function main() {
380
474
  if (refRenames.length > 0) {
381
475
  console.log(C.dim(`\n引用同步改写:${refRenames.map((r) => `${r.from} → ${r.to}`).join(',')}`))
382
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
+ }
383
480
 
384
481
  if (opts.dryRun) {
385
482
  console.log(C.dim('\n(dry-run 结束)'))
386
483
  return
387
484
  }
388
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
+
389
497
  let written = 0
390
498
  for (const item of plan) {
391
499
  const srcAbs = path.join(SOURCE_ROOT, item.rel)
package/cordis.patch.yml CHANGED
@@ -1,26 +1,23 @@
1
1
  # dsh-agent-team-playbook —— DSH bundle patch
2
2
  #
3
- # 挂载方式:不复制、不改写用户任何文件。两件事:
4
- # 1) 用官方 skill provider 把本包 skills/ 目录里的 playbook 挂进 skill 目录;
5
- # 2) 挂本包自己的 guard 入口,启动时检查「同名 skill 被别的来源抢走」并给出提示
6
- # (DSH 对同名 skill 不报错,只按 rank 静默择优,所以必须主动提示)。
3
+ # 挂载本插件,注册只读命令 `/atp`:
4
+ # /atp 规程摘要 + 安装方式
5
+ # /atp core 核心全文(读完即在本轮遵循)
6
+ # /atp paths 分册绝对路径
7
+ # /atp help 用法
8
+ #
9
+ # 本插件不写任何文件,也不挂载 skill:
10
+ # · 不挂 skill 是因为 skill 的目录摘要会常驻占用上下文(约 300 tokens/轮),
11
+ # 而分册本来就不自动进上下文,用命令按需取更划算;
12
+ # · 要让规程成为每轮固定上下文,用 CLI:
13
+ # npx dsh-agent-team-playbook init # 项目级,写 AGENTS.md + docs/
14
+ # npx dsh-agent-team-playbook init --global # 全局,受管区块(指针)
15
+ # npx dsh-agent-team-playbook init --global --inline-core # 全局,内联核心全文
7
16
  #
8
17
  # 安装:dsh plugin --profile web add dsh-agent-team-playbook
9
18
  # 本地开发:dsh plugin --profile web add link:<本目录绝对路径>
10
- #
11
- # skills 路径从包安装位置推算,因此 npm 安装 / GitHub 安装 / 本地 link 都能工作。
12
19
 
13
20
  - insert:
14
- - id: dsh-agent-team-playbook-skills
15
- name: '@deepseek-ai/dsh-skill-filesystem'
16
- config:
17
- providerName: agent-team-playbook
18
- includeDefaultRoots: false
19
- watch: false
20
- customSkillDirs:
21
- - !!js "process.getBuiltinModule('node:path').join(process.getBuiltinModule('node:module').createRequire(baseUrl).resolve('dsh-agent-team-playbook/package.json'), '..', 'skills')"
22
-
23
- - id: dsh-agent-team-playbook-guard
21
+ - id: dsh-agent-team-playbook
24
22
  name: dsh-agent-team-playbook
25
- config:
26
- skillName: agent-team-playbook
23
+ config: {}
package/lib/index.js CHANGED
@@ -1,79 +1,151 @@
1
1
  /**
2
- * dsh-agent-team-playbook — guard half.
2
+ * dsh-agent-team-playbook — DSH 命令插件(Host 半身)
3
3
  *
4
- * 本包的主体是一个只读 skill(挂在 skills/agent-team-playbook/),不需要任何代码。
5
- * 这一半只做一件事:**发现同名 skill 被别人抢走时给出提示**。
4
+ * 提供一个只读命令 `/atp`(agent-team-playbook 缩写),把多智能体协作规程带进对话:
5
+ * /atp 摘要(档位、四问、收尾三问、如何装成常驻)
6
+ * /atp core 核心全文(读完即在本轮遵循)
7
+ * /atp paths 各分册的绝对路径
8
+ * /atp help 用法
6
9
  *
7
- * 为什么需要它:DSH 的 skill 注册表对同名条目不报错,只按 rank 静默择优
8
- * (见 @deepseek-ai/dsh-skill:「the nearest layer's entry wins a duplicate name
9
- * outright」)。也就是说,如果用户自己已经有 skills/agent-team-playbook/,
10
- * 或者另一个插件也提供同名 skill,谁生效是静默发生的,用户无从察觉。
10
+ * 命令名刻意取得短而少见:DSH 对重名命令是**硬报错**(plugin 加载失败),
11
+ * 用 `agent-team` 这种通用词容易被其他插件或后续官方功能占用。
11
12
  *
12
- * 本模块不写用户任何文件、不改任何配置,只读 skill 目录并在需要时打一条 warn。
13
+ * 本插件**不写任何文件**。要让规程成为每个 agent 每轮的固定上下文,
14
+ * 用 CLI 安装:`npx dsh-agent-team-playbook init`(项目级)或 `init --global`(全局)。
15
+ *
16
+ * 为什么不做成 skill:skill 的目录摘要会常驻占用上下文(约 300 tokens/轮),
17
+ * 而分册本来就不会自动进上下文(只有被读取时才消耗),所以用命令按需取更划算。
13
18
  *
14
19
  * @module lib/index.js
15
20
  */
16
21
 
22
+ import { readFileSync, existsSync, readdirSync } from 'node:fs'
23
+ import path from 'node:path'
24
+ import { fileURLToPath } from 'node:url'
25
+
26
+ /** 插件名(与 cordis.patch.yml 中的 name 对应)。 */
17
27
  export const name = 'dsh-agent-team-playbook'
18
28
 
19
- /** 本插件提供的 skill 名与 provider 名(与 cordis.patch.yml 保持一致)。 */
20
- const DEFAULT_SKILL_NAME = 'agent-team-playbook'
21
- const OUR_PROVIDER = 'agent-team-playbook'
29
+ /** 只依赖命令注册表;缺失时插件不加载,不会拖累 composition。 */
30
+ export const inject = ['commands']
22
31
 
23
- /** 等所有 provider 注册完、首轮发现跑完再检查;这只是提示,晚一点没有副作用。 */
24
- const CHECK_DELAY_MS = 2500
32
+ const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
33
+ const PLAYBOOK_DIR = path.join(PACKAGE_ROOT, 'playbook')
25
34
 
26
- /**
27
- * 检查同名 skill 的最终归属;被别的来源抢走时告警。
28
- * 全程 try/catch:提示失败绝不能影响插件加载。
29
- */
30
- async function reportShadowing(ctx, skillName) {
31
- try {
32
- const skills = ctx.skills
33
- if (skills === undefined || typeof skills.list !== 'function') return
35
+ const USAGE = [
36
+ '用法:/atp [core|paths|help]',
37
+ '',
38
+ ' (无参数) 规程摘要与安装方式',
39
+ ' core 输出核心全文(约 5k 字符),读完即在本轮按它协作',
40
+ ' paths 各分册的绝对路径,便于按需查阅',
41
+ ' help 显示本说明',
42
+ ].join('\n')
34
43
 
35
- const list = await skills.list({})
36
- if (!Array.isArray(list)) return
44
+ /** 摘要:刻意短,够判断"该用哪一档、先做什么"即可。 */
45
+ const SUMMARY = [
46
+ '## 多智能体协作规程(agent-team-playbook)',
47
+ '',
48
+ '**档位**:快速 15–30 分钟(单点可逆、自审)|标准 半天(S0–S6、源码级+短测)|严格 1–2 天/子任务(全流程+红队+双重审计)',
49
+ '',
50
+ '**动手前**:验收标准可判真假?档位定了吗?方案过四问了吗——可行性 / 合理性 / **完整性** / 优越性?',
51
+ '',
52
+ '**修复型任务**:先调查根因再改,不允许"没复现就动手"。',
53
+ '',
54
+ '**完成** = 实现 + 自检 + **证据**;审计要全面系统并追到根因,别只修表象。',
55
+ '',
56
+ '**审计产出的问题**分高/中/低:高的本轮修,中低出轮,回流深度上限 1 层。',
57
+ '',
58
+ '**收尾三问**:哪里最慢?哪里最痛?哪条规则该改?有效经验必须写「已固化到哪」。',
59
+ ].join('\n')
37
60
 
38
- const hit = list.find((entry) => entry && entry.name === skillName)
39
- if (hit === undefined) return
61
+ function readPlaybook(rel) {
62
+ const abs = path.join(PLAYBOOK_DIR, rel)
63
+ if (!existsSync(abs)) return undefined
64
+ try {
65
+ return readFileSync(abs, 'utf8')
66
+ } catch {
67
+ return undefined
68
+ }
69
+ }
40
70
 
41
- // 我们自己的 provider 赢了:正常,不打扰用户。
42
- if (hit.provider === OUR_PROVIDER) return
71
+ /** 列出分册路径(用于 /atp paths)。 */
72
+ function renderPaths() {
73
+ const rulesDir = path.join(PLAYBOOK_DIR, 'docs/workflow/rules')
74
+ const lines = [`核心:\`${path.join(PLAYBOOK_DIR, 'AGENTS.md')}\``, '', '分册:']
75
+ if (existsSync(rulesDir)) {
76
+ const files = readdirSafe(rulesDir).filter((f) => f.endsWith('.md')).sort()
77
+ for (const f of files) lines.push(` \`${path.join(rulesDir, f)}\``)
78
+ } else {
79
+ lines.push(' (未找到分册目录)')
80
+ }
81
+ lines.push('', `经验库:\`${path.join(PLAYBOOK_DIR, 'docs/workflow/practices')}\``)
82
+ return lines.join('\n')
83
+ }
43
84
 
44
- const where = typeof hit.path === 'string' ? `(${hit.path})` : ''
45
- ctx.logger.warn(
46
- `skill "${skillName}" 当前由其他来源提供${where},本插件的同名 skill 未生效。` +
47
- '若想用 dsh-agent-team-playbook 的版本,请移走或重命名上述 skill 后重载;' +
48
- `若本来就想用自己的版本,可忽略本提示。`,
49
- )
50
- } catch (error) {
51
- // 只读检查,失败不抛。
52
- ctx.logger?.debug?.(`dsh-agent-team-playbook: skill check skipped (${error?.message ?? error})`)
85
+ function readdirSafe(dir) {
86
+ try {
87
+ return readdirSync(dir)
88
+ } catch {
89
+ return []
53
90
  }
54
91
  }
55
92
 
56
93
  /**
57
- * Plugin entry point.
58
- * @param {import('@deepseek-ai/cordis').Context} ctx
59
- * @param {{ skillName?: string } | undefined} config
94
+ * 安装提示:让用户知道"摘要 ≠ 常驻"。
60
95
  */
61
- export function apply(ctx, config) {
62
- const skillName = config?.skillName ?? DEFAULT_SKILL_NAME
96
+ function renderInstallHint() {
97
+ return [
98
+ '---',
99
+ '**让规程变成每轮的固定上下文**(本命令只是按需调用):',
100
+ '',
101
+ '```bash',
102
+ 'npx dsh-agent-team-playbook init # 写 <项目>/AGENTS.md + docs/',
103
+ 'npx dsh-agent-team-playbook init --global # 用户全局:受管区块(指针)',
104
+ 'npx dsh-agent-team-playbook init --global --inline-core # 全局内联核心全文',
105
+ '```',
106
+ ].join('\n')
107
+ }
63
108
 
64
- // skills 服务在部分 composition 里可能不存在;用 inject 等它出现,缺失时不报错。
65
- ctx.inject(['skills'], (ctx) => {
66
- const run = () => reportShadowing(ctx, skillName)
109
+ /**
110
+ * 命令处理器。
111
+ * @returns {{kind: 'success'|'error', text: string}}
112
+ */
113
+ function handleCommand(invocation) {
114
+ const raw = String(invocation?.rawInput ?? '').trim()
115
+ const sub = raw.toLowerCase()
67
116
 
68
- if (typeof ctx.effect === 'function') {
69
- ctx.effect(() => {
70
- const timer = setTimeout(run, CHECK_DELAY_MS)
71
- if (typeof timer?.unref === 'function') timer.unref()
72
- return () => clearTimeout(timer)
73
- })
74
- } else {
75
- const timer = setTimeout(run, CHECK_DELAY_MS)
76
- if (typeof timer?.unref === 'function') timer.unref()
117
+ if (sub === '' || sub === 'summary') {
118
+ return { kind: 'success', text: `${SUMMARY}\n\n${renderInstallHint()}` }
119
+ }
120
+ if (sub === 'help' || sub === '?') {
121
+ return { kind: 'success', text: USAGE }
122
+ }
123
+ if (sub === 'paths') {
124
+ return { kind: 'success', text: renderPaths() }
125
+ }
126
+ if (sub === 'core' || sub === 'full') {
127
+ const core = readPlaybook('AGENTS.md')
128
+ if (core === undefined) {
129
+ return { kind: 'error', text: `未找到核心文件:${path.join(PLAYBOOK_DIR, 'AGENTS.md')}` }
77
130
  }
131
+ return { kind: 'success', text: core }
132
+ }
133
+ return { kind: 'error', text: `未知参数:${raw}\n\n${USAGE}` }
134
+ }
135
+
136
+ /**
137
+ * Plugin entry point.
138
+ * @param {import('@deepseek-ai/cordis').Context} ctx
139
+ */
140
+ export function apply(ctx) {
141
+ ctx.commands.register({
142
+ definitionId: 'dsh-agent-team-playbook',
143
+ name: 'atp',
144
+ description: '多智能体协作规程(agent-team-playbook):摘要 / 核心全文 / 分册路径(只读)',
145
+ input: { hint: '[core|paths|help]' },
146
+ handler: handleCommand,
78
147
  })
79
148
  }
149
+
150
+ /** 供测试直接调用。 */
151
+ export { handleCommand as _handleCommand, PLAYBOOK_DIR as _PLAYBOOK_DIR }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-agent-team-playbook",
3
- "version": "1.22.2",
4
- "description": "DeepSeek Harness skill bundle: an executable multi-agent collaboration workflow for groups of AI teammates — charter, triage tiers, six-stage pipeline, audit gates, problem triage and an experience library.",
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",
@@ -20,7 +20,7 @@
20
20
  "scripts",
21
21
  "cordis.patch.yml",
22
22
  "assets",
23
- "skills",
23
+ "playbook",
24
24
  "README.md",
25
25
  "LICENSE"
26
26
  ],
@@ -32,18 +32,18 @@
32
32
  "keywords": [
33
33
  "dsh-plugin",
34
34
  "dsh-bundle",
35
- "agent-skill",
36
35
  "multi-agent",
37
36
  "workflow",
38
37
  "agents-md",
39
- "playbook"
38
+ "playbook",
39
+ "dsh-command"
40
40
  ],
41
41
  "engines": {
42
42
  "node": ">=20"
43
43
  },
44
44
  "scripts": {
45
- "sync": "node scripts/sync-skill.mjs",
46
- "check": "node scripts/sync-skill.mjs --check",
47
- "prepack": "node scripts/sync-skill.mjs"
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
  }
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * 把仓库里的 playbook 文档同步进 skill 目录,供 npm 包携带。
3
+ * 把仓库里的 playbook 文档同步进 playbook/ 目录,供 npm 包携带。
4
4
  *
5
5
  * 为什么要有这一步:文档的权威位置在仓库根目录(`AGENTS.md` + `docs/`),
6
- * 而 DSH 的 skill 必须是一个自包含目录(`skills/<name>/SKILL.md`)。
6
+ * 而 npm 包需要一个自包含、路径固定的副本供 CLI 安装。
7
7
  * 直接复制会漂移,所以用本脚本单向同步,并提供 `--check` 供发布前校验。
8
8
  *
9
9
  * 生成的文件清单记录在 `.synced.json`,下次同步只删自己生成的东西,
10
- * 绝不碰 `SKILL.md` 之类手写文件。
10
+ * 绝不碰手写文件。
11
11
  *
12
12
  * 用法:
13
- * node scripts/sync-skill.mjs # 生成/更新
14
- * node scripts/sync-skill.mjs --check # 只校验,不一致则退出码 1
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'
@@ -19,8 +19,8 @@ import path from 'node:path'
19
19
  import { fileURLToPath } from 'node:url'
20
20
 
21
21
  const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
22
- const SKILL_DIR = path.join(ROOT, 'skills', 'agent-team-playbook')
23
- const MANIFEST = path.join(ROOT, '.skill-sync.json')
22
+ const DEST_DIR = path.join(ROOT, 'playbook')
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(SKILL_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) {
@@ -77,7 +77,7 @@ async function main() {
77
77
  // 删除上次生成、这次不再需要的文件(只限清单里记录的,手写文件不受影响)。
78
78
  if (!CHECK) {
79
79
  for (const rel of stale) {
80
- await rm(path.join(SKILL_DIR, rel), { force: true })
80
+ await rm(path.join(DEST_DIR, rel), { force: true })
81
81
  }
82
82
  }
83
83
 
@@ -86,7 +86,7 @@ async function main() {
86
86
 
87
87
  for (const rel of files) {
88
88
  const src = path.join(ROOT, rel)
89
- const dest = path.join(SKILL_DIR, rel)
89
+ const dest = path.join(DEST_DIR, rel)
90
90
 
91
91
  if (!existsSync(src)) {
92
92
  missing.push(`源文件缺失:${rel}`)
@@ -108,21 +108,37 @@ async function main() {
108
108
  }
109
109
 
110
110
  if (CHECK) {
111
- const problems = [...missing, ...drifted.map((rel) => `未同步:${rel}`)]
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
- console.error('✗ skills/agent-team-playbook 与源文档不一致:')
130
+ console.error('✗ playbook/ 与源文档不一致:')
115
131
  for (const p of problems) console.error(' -', p)
116
- console.error(' 修复:node scripts/sync-skill.mjs')
132
+ console.error(' 修复:node scripts/sync-playbook.mjs')
117
133
  process.exit(1)
118
134
  }
119
- console.log(`✓ skill 内容与源文档一致(${files.length} 个文件)`)
135
+ console.log(`✓ playbook 内容与源文档一致(${files.length} 个文件)`)
120
136
  return
121
137
  }
122
138
 
123
139
  await writeFile(MANIFEST, JSON.stringify({ files, generatedAt: new Date().toISOString() }, null, 2) + '\n')
124
140
 
125
- console.log(`✓ 已同步 ${files.length} 个文件到 skills/agent-team-playbook/`)
141
+ console.log(`✓ 已同步 ${files.length} 个文件到 playbook/`)
126
142
  if (stale.length > 0) console.log(` 清理 ${stale.length} 个过期文件:${stale.join(', ')}`)
127
143
  for (const m of missing) console.error(' ✗', m)
128
144
  if (missing.length > 0) process.exit(1)
@@ -1,68 +0,0 @@
1
- ---
2
- name: agent-team-playbook
3
- description: 一套给「Lead + 多名 AI 队友」用的多智能体协作工作流:怎么定档(快速/标准/严格)、怎么分工与写范围互斥、怎么写任务书、怎么做审计与问题分级、怎么验收、怎么复盘并把经验固化。当任务需要多个 agent 协作、或需要跨轮次保持一致的流程纪律、或用户提到「多智能体」「agent 团队」「协作规程」「流水线」「审计/复盘制度」时使用。Use when coordinating a team of agents or when the user wants a repeatable engineering workflow (triage tiers, task briefs, audit gates, retro loops) rather than ad-hoc work. 也适用于单 agent 但需要严谨流程(数据/支付/不可逆改动)的场景。
4
- whenToUse: 用户要求组队/多 agent 协作;或强调要流程严谨、要防返工、要有审计与复盘;或要在项目里建立长期遵守的工作约定(AGENTS.md 类)。不要用于一次性脚本或闲聊。
5
- ---
6
-
7
- # Agent Team Playbook(多智能体协作工作流)
8
-
9
- **这是只读参考资料,不要自动把文件复制进用户项目。** 需要落到项目里时,明确告知用户并走
10
- `dsh-agent-team-playbook init`(带冲突询问)或征得同意后再写。
11
-
12
- ## 先看什么
13
-
14
- | 想知道 | 读这里(相对本 skill 目录) |
15
- |---|---|
16
- | 最高原则、铁律、档位速查、索引 | `AGENTS.md`(约 5k 字符,先读这个) |
17
- | 流水线 S0–S6 细节、审计清单、事故善后 | `docs/workflow/rules/03-流水线.md` |
18
- | 修复型任务怎么先查根因 | `docs/workflow/rules/03-流水线.md` 的 S1 调查段 |
19
- | 档位怎么选、时间盒、优先级 | `docs/workflow/rules/02-效率与档位详解.md` |
20
- | 任务书模板 | `docs/workflow/rules/04-任务书模板.md` |
21
- | 任务板与回流子条目 | `docs/workflow/rules/05-任务板.md` |
22
- | 组队、Lead/队友职责、沟通 | `docs/workflow/rules/06-协作细则.md` |
23
- | 反馈三类、度量、复盘 | `docs/workflow/rules/01-总纲细则.md`、`07-用户交互与度量.md` |
24
- | 反模式与速查卡 | `docs/workflow/rules/08-反模式与速查.md` |
25
- | 经验库写法 | `docs/workflow/practices/README.md` |
26
- | 总览图 | `docs/assets/architecture.svg` |
27
-
28
- ## 最短上手路径
29
-
30
- 1. **接活先定两件事**:可判真假的验收标准 + 档位(快速 15–30 分钟 / 标准 半天 / 严格 1–2 天每子任务)。
31
- 2. **动手前先策划**,方案过四问:可行性、合理性、**完整性**(有没有漏分支/失败路径/回滚)、优越性。
32
- 3. **修复型任务先调查根因**再改,不允许"没复现就动手"。
33
- 4. **完成 = 实现 + 自检 + 证据**,无证据不算完成。
34
- 5. **收尾三问**:哪里最慢?哪里最痛?哪条规则该改?有效经验必须写「已固化到哪」。
35
-
36
- ## 几条最容易踩的
37
-
38
- - **审计要全面系统、不要抽样**,且必须追根因——修完要问「还有没有同类隐藏 bug」。
39
- - **审计发现的问题要分级**(高/中/低):高的本轮修,中低出轮,回流深度上限 1 层。
40
- - **CI 门禁与真机验证可并行,但判定是 AND**,且必须验同一个版本。
41
- - **长任务挂后台**,不要阻塞与用户的对话。
42
- - **别把"能跑"当完成**:还有合理性、优越性、健壮性、完整性、必要的完善与防御性、用户视角、需求补全。
43
-
44
- ## 落地到用户项目时
45
-
46
- **先分清两件事(很重要)**:
47
-
48
- | 形态 | 是否常驻上下文 |
49
- |---|---|
50
- | 本 skill | ❌ **按需加载**——agent 觉得相关才读 |
51
- | 工作区 `AGENTS.md` | ✅ 每轮自动注入 = **所有 agent 的固定上下文** |
52
- | 用户全局 `$DSH_HOME/AGENTS.md` | ✅ 对所有工作区生效 |
53
-
54
- DSH 的指令加载器**只认文件**(没有插件注入通道),所以要"让团队每个 agent 都默认遵守",必须写成文件。
55
-
56
- 插件安装**不会**写用户任何文件。真要写入:
57
-
58
- ```bash
59
- npx dsh-agent-team-playbook init # 装进当前项目(AGENTS.md + docs/)
60
- npx dsh-agent-team-playbook init --dry-run # 只看计划,不写
61
- npx dsh-agent-team-playbook init --global # 用户全局:复制到 $DSH_HOME/agent-team-playbook/,
62
- # 并在 $DSH_HOME/AGENTS.md 追加受管区块
63
- ```
64
-
65
- - 遇到同名文件/目录会**逐个询问**,不会静默覆盖。
66
- - 选「改名」时,写出的文件里对它的引用会**同步改写**,不会留下断链。
67
- - `--global` 只维护标记之间的区块,**块外内容一律不动**,可重复执行(幂等更新)。
68
- - 非交互环境(CI)默认遇到冲突就中止,需显式 `--force` / `--skip-conflicts` / `--yes`。