dsh-agent-team-playbook 1.22.2 → 1.23.0

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 +39 -9
  3. package/cordis.patch.yml +15 -18
  4. package/lib/index.js +122 -53
  5. package/package.json +4 -4
  6. package/scripts/sync-skill.mjs +10 -10
  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
+ 装好后多一个只读命令:
102
100
 
103
- ### 把 playbook 装进项目(可选,会写文件)
101
+ | 命令 | 作用 |
102
+ |---|---|
103
+ | `/agent-team` | 规程摘要(档位、四问、收尾三问)+ 安装方式 |
104
+ | `/agent-team core` | 输出核心全文,读完即在本轮按它协作 |
105
+ | `/agent-team paths` | 各分册的绝对路径,按需查阅 |
106
+ | `/agent-team 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
@@ -22,7 +22,13 @@ import path from 'node:path'
22
22
  import { fileURLToPath } from 'node:url'
23
23
 
24
24
  const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
25
- const SOURCE_ROOT = path.join(PACKAGE_ROOT, 'skills', 'agent-team-playbook')
25
+
26
+ // 管道被下游提前关闭(如 | head)时安静退出,不抛未捕获错误
27
+ process.stdout.on('error', (err) => {
28
+ if (err?.code === 'EPIPE') process.exit(0)
29
+ throw err
30
+ })
31
+ const SOURCE_ROOT = path.join(PACKAGE_ROOT, 'playbook')
26
32
 
27
33
  /** 会被安装进用户项目的条目:playbook 本体,不含 SKILL.md(那是 skill 入口)与同步清单。 */
28
34
  const ROOT_FILE = 'AGENTS.md'
@@ -45,6 +51,7 @@ function parseArgs(argv) {
45
51
  help: false,
46
52
  global: false,
47
53
  yes: false,
54
+ inlineCore: false,
48
55
  }
49
56
  for (let i = 0; i < argv.length; i += 1) {
50
57
  const a = argv[i]
@@ -54,6 +61,7 @@ function parseArgs(argv) {
54
61
  else if (a === '--skip-conflicts') opts.skipConflicts = true
55
62
  else if (a === '--global' || a === '-g') opts.global = true
56
63
  else if (a === '--yes' || a === '-y') opts.yes = true
64
+ else if (a === '--inline-core') opts.inlineCore = true
57
65
  else if (a === '--help' || a === '-h') opts.help = true
58
66
  else if (a === 'init') continue
59
67
  else {
@@ -74,6 +82,8 @@ ${C.bold('选项')}
74
82
  --dir <路径> 目标目录(默认当前目录)
75
83
  --global, -g 装成用户全局指令:复制到 $DSH_HOME/agent-team-playbook/,
76
84
  并在 $DSH_HOME/AGENTS.md 追加一个受管区块(不覆盖原有内容)
85
+ --inline-core 配合 --global:把核心全文内联进区块(每轮真常驻,约 3.3k tokens),
86
+ 默认只写指针(约 200 tokens,agent 需先读一次文件)
77
87
  --yes, -y 非交互确认(--global 追加区块用)
78
88
  --dry-run 只显示计划,不写任何文件
79
89
  --force, -f 冲突时全部覆盖(不询问)
@@ -149,15 +159,33 @@ function rewriteReferences(text, renames) {
149
159
  const BLOCK_START = '<!-- agent-team-playbook:start -->'
150
160
  const BLOCK_END = '<!-- agent-team-playbook:end -->'
151
161
 
152
- function managedBlock(destAbs) {
162
+ function managedBlock(destAbs, inlineCore, coreText) {
163
+ const footer = '> 本节由 `npx dsh-agent-team-playbook init --global` 维护,块内内容会被自动覆盖;块外内容不受影响。'
164
+
165
+ if (!inlineCore) {
166
+ return [
167
+ BLOCK_START,
168
+ '## 多智能体协作规程(agent-team-playbook)',
169
+ '',
170
+ `本机所有项目按以下规程协作:\`${destAbs}/AGENTS.md\`(常驻核心,先读它)。`,
171
+ `分册细则在 \`${destAbs}/docs/workflow/\`,按核心 §8 索引按需查阅。`,
172
+ '',
173
+ footer,
174
+ BLOCK_END,
175
+ ].join('\n')
176
+ }
177
+
178
+ // 内联:核心全文进区块;相对路径改写为绝对路径,保证在任意工作区都能读到
179
+ const rewritten = coreText
180
+ .replace(/\(^\)/, '') // 不裁剪开头
181
+ .replace(/(^|[^/\w.-])AGENTS\.md(?![.\w-])/g, (_m, pre) => `${pre}${destAbs}/AGENTS.md`)
182
+ .split('docs/').join(`${destAbs}/docs/`)
183
+
153
184
  return [
154
185
  BLOCK_START,
155
- '## 多智能体协作规程(agent-team-playbook)',
156
- '',
157
- `本机所有项目按以下规程协作:\`${destAbs}/AGENTS.md\`(常驻核心,先读它)。`,
158
- `分册细则在 \`${destAbs}/docs/workflow/\`,按核心 §8 索引按需查阅。`,
186
+ rewritten.replace(/\s+$/, ''),
159
187
  '',
160
- '> 本节由 `npx dsh-agent-team-playbook init --global` 维护,块内内容会被自动覆盖;块外内容不受影响。',
188
+ footer,
161
189
  BLOCK_END,
162
190
  ].join('\n')
163
191
  }
@@ -173,10 +201,12 @@ async function runGlobalMode(opts) {
173
201
  const home = process.env.DSH_HOME || path.join(os.homedir(), '.dsh')
174
202
  const destDir = path.join(home, 'agent-team-playbook')
175
203
  const instrFile = path.join(home, 'AGENTS.md')
176
- const block = managedBlock(destDir)
204
+ const coreText = await readFile(path.join(SOURCE_ROOT, 'AGENTS.md'), 'utf8')
205
+ const block = managedBlock(destDir, opts.inlineCore, coreText)
177
206
 
178
207
  const rels = [ROOT_FILE, ...(await walk(ROOT_DIR))]
179
208
  console.log(C.bold('全局安装计划'))
209
+ console.log(C.dim(` 区块模式:${opts.inlineCore ? '内联核心全文(每轮真常驻)' : '指针(默认,agent 需先读一次文件)'}`))
180
210
  console.log(` 复制 ${rels.length} 个文件 → ${destDir}`)
181
211
  console.log(` 维护受管区块 → ${instrFile}`)
182
212
 
@@ -250,7 +280,7 @@ async function main() {
250
280
  if (opts.help) return printHelp()
251
281
 
252
282
  if (!existsSync(SOURCE_ROOT)) {
253
- console.error(C.red(`✗ 找不到包内 skill 目录:${SOURCE_ROOT}`))
283
+ console.error(C.red(`✗ 找不到包内 playbook 目录:${SOURCE_ROOT}`))
254
284
  process.exit(1)
255
285
  }
256
286
  if (opts.global) {
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
+ # 挂载本插件,注册只读命令 `/agent-team`:
4
+ # /agent-team 规程摘要 + 安装方式
5
+ # /agent-team core 核心全文(读完即在本轮遵循)
6
+ # /agent-team paths 分册绝对路径
7
+ # /agent-team 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,148 @@
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
+ * 提供一个只读命令 `/agent-team`,把多智能体协作规程带进对话:
5
+ * /agent-team 摘要(档位、四问、收尾三问、如何装成常驻)
6
+ * /agent-team core 核心全文(读完即在本轮遵循)
7
+ * /agent-team paths 各分册的绝对路径
8
+ * /agent-team 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
+ * 本插件**不写任何文件**。要让规程成为每个 agent 每轮的固定上下文,
11
+ * 用 CLI 安装:`npx dsh-agent-team-playbook init`(项目级)或 `init --global`(全局)。
11
12
  *
12
- * 本模块不写用户任何文件、不改任何配置,只读 skill 目录并在需要时打一条 warn。
13
+ * 为什么不做成 skill:skill 的目录摘要会常驻占用上下文(约 300 tokens/轮),
14
+ * 而分册本来就不会自动进上下文(只有被读取时才消耗),所以用命令按需取更划算。
13
15
  *
14
16
  * @module lib/index.js
15
17
  */
16
18
 
19
+ import { readFileSync, existsSync, readdirSync } from 'node:fs'
20
+ import path from 'node:path'
21
+ import { fileURLToPath } from 'node:url'
22
+
23
+ /** 插件名(与 cordis.patch.yml 中的 name 对应)。 */
17
24
  export const name = 'dsh-agent-team-playbook'
18
25
 
19
- /** 本插件提供的 skill 名与 provider 名(与 cordis.patch.yml 保持一致)。 */
20
- const DEFAULT_SKILL_NAME = 'agent-team-playbook'
21
- const OUR_PROVIDER = 'agent-team-playbook'
26
+ /** 只依赖命令注册表;缺失时插件不加载,不会拖累 composition。 */
27
+ export const inject = ['commands']
22
28
 
23
- /** 等所有 provider 注册完、首轮发现跑完再检查;这只是提示,晚一点没有副作用。 */
24
- const CHECK_DELAY_MS = 2500
29
+ const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
30
+ const PLAYBOOK_DIR = path.join(PACKAGE_ROOT, 'playbook')
25
31
 
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
32
+ const USAGE = [
33
+ '用法:/agent-team [core|paths|help]',
34
+ '',
35
+ ' (无参数) 规程摘要与安装方式',
36
+ ' core 输出核心全文(约 5k 字符),读完即在本轮按它协作',
37
+ ' paths 各分册的绝对路径,便于按需查阅',
38
+ ' help 显示本说明',
39
+ ].join('\n')
34
40
 
35
- const list = await skills.list({})
36
- if (!Array.isArray(list)) return
41
+ /** 摘要:刻意短,够判断"该用哪一档、先做什么"即可。 */
42
+ const SUMMARY = [
43
+ '## 多智能体协作规程(agent-team-playbook)',
44
+ '',
45
+ '**档位**:快速 15–30 分钟(单点可逆、自审)|标准 半天(S0–S6、源码级+短测)|严格 1–2 天/子任务(全流程+红队+双重审计)',
46
+ '',
47
+ '**动手前**:验收标准可判真假?档位定了吗?方案过四问了吗——可行性 / 合理性 / **完整性** / 优越性?',
48
+ '',
49
+ '**修复型任务**:先调查根因再改,不允许"没复现就动手"。',
50
+ '',
51
+ '**完成** = 实现 + 自检 + **证据**;审计要全面系统并追到根因,别只修表象。',
52
+ '',
53
+ '**审计产出的问题**分高/中/低:高的本轮修,中低出轮,回流深度上限 1 层。',
54
+ '',
55
+ '**收尾三问**:哪里最慢?哪里最痛?哪条规则该改?有效经验必须写「已固化到哪」。',
56
+ ].join('\n')
37
57
 
38
- const hit = list.find((entry) => entry && entry.name === skillName)
39
- if (hit === undefined) return
58
+ function readPlaybook(rel) {
59
+ const abs = path.join(PLAYBOOK_DIR, rel)
60
+ if (!existsSync(abs)) return undefined
61
+ try {
62
+ return readFileSync(abs, 'utf8')
63
+ } catch {
64
+ return undefined
65
+ }
66
+ }
40
67
 
41
- // 我们自己的 provider 赢了:正常,不打扰用户。
42
- if (hit.provider === OUR_PROVIDER) return
68
+ /** 列出分册路径(用于 /agent-team paths)。 */
69
+ function renderPaths() {
70
+ const rulesDir = path.join(PLAYBOOK_DIR, 'docs/workflow/rules')
71
+ const lines = [`核心:\`${path.join(PLAYBOOK_DIR, 'AGENTS.md')}\``, '', '分册:']
72
+ if (existsSync(rulesDir)) {
73
+ const files = readdirSafe(rulesDir).filter((f) => f.endsWith('.md')).sort()
74
+ for (const f of files) lines.push(` \`${path.join(rulesDir, f)}\``)
75
+ } else {
76
+ lines.push(' (未找到分册目录)')
77
+ }
78
+ lines.push('', `经验库:\`${path.join(PLAYBOOK_DIR, 'docs/workflow/practices')}\``)
79
+ return lines.join('\n')
80
+ }
43
81
 
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})`)
82
+ function readdirSafe(dir) {
83
+ try {
84
+ return readdirSync(dir)
85
+ } catch {
86
+ return []
53
87
  }
54
88
  }
55
89
 
56
90
  /**
57
- * Plugin entry point.
58
- * @param {import('@deepseek-ai/cordis').Context} ctx
59
- * @param {{ skillName?: string } | undefined} config
91
+ * 安装提示:让用户知道"摘要 ≠ 常驻"。
60
92
  */
61
- export function apply(ctx, config) {
62
- const skillName = config?.skillName ?? DEFAULT_SKILL_NAME
93
+ function renderInstallHint() {
94
+ return [
95
+ '---',
96
+ '**让规程变成每轮的固定上下文**(本命令只是按需调用):',
97
+ '',
98
+ '```bash',
99
+ 'npx dsh-agent-team-playbook init # 写 <项目>/AGENTS.md + docs/',
100
+ 'npx dsh-agent-team-playbook init --global # 用户全局:受管区块(指针)',
101
+ 'npx dsh-agent-team-playbook init --global --inline-core # 全局内联核心全文',
102
+ '```',
103
+ ].join('\n')
104
+ }
63
105
 
64
- // skills 服务在部分 composition 里可能不存在;用 inject 等它出现,缺失时不报错。
65
- ctx.inject(['skills'], (ctx) => {
66
- const run = () => reportShadowing(ctx, skillName)
106
+ /**
107
+ * 命令处理器。
108
+ * @returns {{kind: 'success'|'error', text: string}}
109
+ */
110
+ function handleCommand(invocation) {
111
+ const raw = String(invocation?.rawInput ?? '').trim()
112
+ const sub = raw.toLowerCase()
67
113
 
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()
114
+ if (sub === '' || sub === 'summary') {
115
+ return { kind: 'success', text: `${SUMMARY}\n\n${renderInstallHint()}` }
116
+ }
117
+ if (sub === 'help' || sub === '?') {
118
+ return { kind: 'success', text: USAGE }
119
+ }
120
+ if (sub === 'paths') {
121
+ return { kind: 'success', text: renderPaths() }
122
+ }
123
+ if (sub === 'core' || sub === 'full') {
124
+ const core = readPlaybook('AGENTS.md')
125
+ if (core === undefined) {
126
+ return { kind: 'error', text: `未找到核心文件:${path.join(PLAYBOOK_DIR, 'AGENTS.md')}` }
77
127
  }
128
+ return { kind: 'success', text: core }
129
+ }
130
+ return { kind: 'error', text: `未知参数:${raw}\n\n${USAGE}` }
131
+ }
132
+
133
+ /**
134
+ * Plugin entry point.
135
+ * @param {import('@deepseek-ai/cordis').Context} ctx
136
+ */
137
+ export function apply(ctx) {
138
+ ctx.commands.register({
139
+ definitionId: 'dsh-agent-team-playbook',
140
+ name: 'agent-team',
141
+ description: '多智能体协作规程:摘要 / 核心全文 / 分册路径(只读)',
142
+ input: { hint: '[core|paths|help]' },
143
+ handler: handleCommand,
78
144
  })
79
145
  }
146
+
147
+ /** 供测试直接调用。 */
148
+ export { handleCommand as _handleCommand, PLAYBOOK_DIR as _PLAYBOOK_DIR }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agent-team-playbook",
3
- "version": "1.22.2",
3
+ "version": "1.23.0",
4
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.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -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,11 +32,11 @@
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"
@@ -1,13 +1,13 @@
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
13
  * node scripts/sync-skill.mjs # 生成/更新
@@ -19,7 +19,7 @@ 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')
22
+ const DEST_DIR = path.join(ROOT, 'playbook')
23
23
  const MANIFEST = path.join(ROOT, '.skill-sync.json')
24
24
  const CHECK = process.argv.includes('--check')
25
25
 
@@ -63,7 +63,7 @@ async function readManifest() {
63
63
  }
64
64
 
65
65
  async function main() {
66
- await mkdir(SKILL_DIR, { recursive: true })
66
+ 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}`)
@@ -111,18 +111,18 @@ async function main() {
111
111
  const problems = [...missing, ...drifted.map((rel) => `未同步:${rel}`)]
112
112
  if (stale.length > 0) problems.push(`残留:${stale.join(', ')}`)
113
113
  if (problems.length > 0) {
114
- console.error('✗ skills/agent-team-playbook 与源文档不一致:')
114
+ console.error('✗ playbook/ 与源文档不一致:')
115
115
  for (const p of problems) console.error(' -', p)
116
116
  console.error(' 修复:node scripts/sync-skill.mjs')
117
117
  process.exit(1)
118
118
  }
119
- console.log(`✓ skill 内容与源文档一致(${files.length} 个文件)`)
119
+ console.log(`✓ playbook 内容与源文档一致(${files.length} 个文件)`)
120
120
  return
121
121
  }
122
122
 
123
123
  await writeFile(MANIFEST, JSON.stringify({ files, generatedAt: new Date().toISOString() }, null, 2) + '\n')
124
124
 
125
- console.log(`✓ 已同步 ${files.length} 个文件到 skills/agent-team-playbook/`)
125
+ console.log(`✓ 已同步 ${files.length} 个文件到 playbook/`)
126
126
  if (stale.length > 0) console.log(` 清理 ${stale.length} 个过期文件:${stale.join(', ')}`)
127
127
  for (const m of missing) console.error(' ✗', m)
128
128
  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`。