dsh-agent-team-playbook 1.22.0 → 1.22.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 +9 -0
- package/bin/cli.mjs +126 -1
- package/package.json +1 -1
- package/skills/agent-team-playbook/SKILL.md +15 -2
package/README.md
CHANGED
|
@@ -107,6 +107,15 @@ npx dsh-agent-team-playbook init --dry-run # 先看计划
|
|
|
107
107
|
npx dsh-agent-team-playbook init # 交互式安装
|
|
108
108
|
```
|
|
109
109
|
|
|
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` 维护一个**受管区块**(块外内容不动,幂等更新) |
|
|
116
|
+
|
|
117
|
+
> **为什么必须写文件**:DSH 的指令加载器(`dsh-agent-instructions`)只认文件(项目根/子目录/用户全局的 `AGENTS.md`、`CLAUDE.md`、`*.local.md`),**没有插件注入通道**。所以「常驻上下文」= 文件;skill 只是「按需查阅」。
|
|
118
|
+
|
|
110
119
|
冲突处理是本命令的核心设计:
|
|
111
120
|
|
|
112
121
|
| 情况 | 行为 |
|
package/bin/cli.mjs
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* [--force | --skip-conflicts]
|
|
15
15
|
*/
|
|
16
16
|
import { createInterface } from 'node:readline/promises'
|
|
17
|
+
import os from 'node:os'
|
|
17
18
|
import { stdin, stdout } from 'node:process'
|
|
18
19
|
import { readFile, writeFile, mkdir, stat, readdir } from 'node:fs/promises'
|
|
19
20
|
import { existsSync } from 'node:fs'
|
|
@@ -36,13 +37,23 @@ const C = {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
function parseArgs(argv) {
|
|
39
|
-
const opts = {
|
|
40
|
+
const opts = {
|
|
41
|
+
dir: process.cwd(),
|
|
42
|
+
dryRun: false,
|
|
43
|
+
force: false,
|
|
44
|
+
skipConflicts: false,
|
|
45
|
+
help: false,
|
|
46
|
+
global: false,
|
|
47
|
+
yes: false,
|
|
48
|
+
}
|
|
40
49
|
for (let i = 0; i < argv.length; i += 1) {
|
|
41
50
|
const a = argv[i]
|
|
42
51
|
if (a === '--dir') opts.dir = path.resolve(argv[(i += 1)] ?? '.')
|
|
43
52
|
else if (a === '--dry-run') opts.dryRun = true
|
|
44
53
|
else if (a === '--force' || a === '-f') opts.force = true
|
|
45
54
|
else if (a === '--skip-conflicts') opts.skipConflicts = true
|
|
55
|
+
else if (a === '--global' || a === '-g') opts.global = true
|
|
56
|
+
else if (a === '--yes' || a === '-y') opts.yes = true
|
|
46
57
|
else if (a === '--help' || a === '-h') opts.help = true
|
|
47
58
|
else if (a === 'init') continue
|
|
48
59
|
else {
|
|
@@ -61,11 +72,21 @@ ${C.bold('用法')}
|
|
|
61
72
|
|
|
62
73
|
${C.bold('选项')}
|
|
63
74
|
--dir <路径> 目标目录(默认当前目录)
|
|
75
|
+
--global, -g 装成用户全局指令:复制到 $DSH_HOME/agent-team-playbook/,
|
|
76
|
+
并在 $DSH_HOME/AGENTS.md 追加一个受管区块(不覆盖原有内容)
|
|
77
|
+
--yes, -y 非交互确认(--global 追加区块用)
|
|
64
78
|
--dry-run 只显示计划,不写任何文件
|
|
65
79
|
--force, -f 冲突时全部覆盖(不询问)
|
|
66
80
|
--skip-conflicts 冲突时全部跳过(不询问)
|
|
67
81
|
-h, --help 显示本帮助
|
|
68
82
|
|
|
83
|
+
${C.bold('两种安装方式的区别(重要)')}
|
|
84
|
+
· 项目安装(默认):写 <项目>/AGENTS.md + docs/。
|
|
85
|
+
工作区 AGENTS.md 会被 DSH 每轮自动注入 ⇒ 成为**所有 agent 的固定上下文**。
|
|
86
|
+
· 全局安装(--global):复制到 $DSH_HOME/agent-team-playbook/,
|
|
87
|
+
仅往 $DSH_HOME/AGENTS.md 追加一个受管区块(可重复执行,原地更新)。
|
|
88
|
+
适用于"本机所有项目都按这套规程走"。
|
|
89
|
+
|
|
69
90
|
${C.bold('行为')}
|
|
70
91
|
· 交互模式下,每个冲突单独询问:覆盖 / 改名 / 跳过 / 剩余全部覆盖 / 中止
|
|
71
92
|
· 选"改名"时,文档里对它的引用会同步改写
|
|
@@ -124,6 +145,106 @@ function rewriteReferences(text, renames) {
|
|
|
124
145
|
return out
|
|
125
146
|
}
|
|
126
147
|
|
|
148
|
+
/** 受管区块标记:重复执行时原地更新,绝不碰区块外内容。 */
|
|
149
|
+
const BLOCK_START = '<!-- agent-team-playbook:start -->'
|
|
150
|
+
const BLOCK_END = '<!-- agent-team-playbook:end -->'
|
|
151
|
+
|
|
152
|
+
function managedBlock(destAbs) {
|
|
153
|
+
return [
|
|
154
|
+
BLOCK_START,
|
|
155
|
+
'## 多智能体协作规程(agent-team-playbook)',
|
|
156
|
+
'',
|
|
157
|
+
`本机所有项目按以下规程协作:\`${destAbs}/AGENTS.md\`(常驻核心,先读它)。`,
|
|
158
|
+
`分册细则在 \`${destAbs}/docs/workflow/\`,按核心 §8 索引按需查阅。`,
|
|
159
|
+
'',
|
|
160
|
+
'> 本节由 `npx dsh-agent-team-playbook init --global` 维护,块内内容会被自动覆盖;块外内容不受影响。',
|
|
161
|
+
BLOCK_END,
|
|
162
|
+
].join('\n')
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* 全局安装:把 playbook 复制到 $DSH_HOME/agent-team-playbook/,
|
|
167
|
+
* 并只在 $DSH_HOME/AGENTS.md 里维护一个受管区块(不覆盖用户已有内容)。
|
|
168
|
+
*
|
|
169
|
+
* 这是让规程成为「所有工作区的常驻上下文」的唯一途径——DSH 的指令加载器只认文件,
|
|
170
|
+
* 没有插件注入通道。
|
|
171
|
+
*/
|
|
172
|
+
async function runGlobalMode(opts) {
|
|
173
|
+
const home = process.env.DSH_HOME || path.join(os.homedir(), '.dsh')
|
|
174
|
+
const destDir = path.join(home, 'agent-team-playbook')
|
|
175
|
+
const instrFile = path.join(home, 'AGENTS.md')
|
|
176
|
+
const block = managedBlock(destDir)
|
|
177
|
+
|
|
178
|
+
const rels = [ROOT_FILE, ...(await walk(ROOT_DIR))]
|
|
179
|
+
console.log(C.bold('全局安装计划'))
|
|
180
|
+
console.log(` 复制 ${rels.length} 个文件 → ${destDir}`)
|
|
181
|
+
console.log(` 维护受管区块 → ${instrFile}`)
|
|
182
|
+
|
|
183
|
+
let existing = ''
|
|
184
|
+
if (existsSync(instrFile)) {
|
|
185
|
+
existing = await readFile(instrFile, 'utf8')
|
|
186
|
+
const hasBlock = existing.includes(BLOCK_START)
|
|
187
|
+
console.log(
|
|
188
|
+
C.dim(` ${instrFile} 已存在(${existing.length} 字节),`) +
|
|
189
|
+
(hasBlock ? C.green('检测到本插件的受管区块 → 原地更新') : C.yellow('没有受管区块 → 需追加')),
|
|
190
|
+
)
|
|
191
|
+
if (!hasBlock && !opts.yes && !opts.force) {
|
|
192
|
+
if (!(stdin.isTTY && stdout.isTTY)) {
|
|
193
|
+
console.error(C.red('\n✗ 该文件已存在且不含本插件区块,非交互模式下不追加。'))
|
|
194
|
+
console.error(' 确认可追加请加 --yes;或先手动查看该文件。')
|
|
195
|
+
process.exit(1)
|
|
196
|
+
}
|
|
197
|
+
const rl = createInterface({ input: stdin, output: stdout })
|
|
198
|
+
try {
|
|
199
|
+
const a = (await rl.question(`\n在 ${instrFile} 末尾追加受管区块?(已有内容不会被改动)[y/N] > `)).trim().toLowerCase()
|
|
200
|
+
if (a !== 'y' && a !== 'yes') {
|
|
201
|
+
console.log('已取消,未写入任何文件。')
|
|
202
|
+
process.exit(1)
|
|
203
|
+
}
|
|
204
|
+
} finally {
|
|
205
|
+
rl.close()
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
} else {
|
|
209
|
+
console.log(C.dim(` ${instrFile} 不存在 → 新建`))
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (opts.dryRun) {
|
|
213
|
+
console.log(C.dim('\n将要追加的区块:'))
|
|
214
|
+
console.log(block.split('\n').map((l) => ` ${C.dim('│')} ${l}`).join('\n'))
|
|
215
|
+
console.log(C.dim('\n(--dry-run 结束)'))
|
|
216
|
+
return
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// 1) 复制 playbook(命名空间目录,整体刷新;不触碰用户其它文件)
|
|
220
|
+
let copied = 0
|
|
221
|
+
for (const rel of rels) {
|
|
222
|
+
const srcAbs = path.join(SOURCE_ROOT, rel)
|
|
223
|
+
const destAbs = path.join(destDir, rel)
|
|
224
|
+
await mkdir(path.dirname(destAbs), { recursive: true })
|
|
225
|
+
await writeFile(destAbs, await readFile(srcAbs))
|
|
226
|
+
copied += 1
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// 2) 维护受管区块
|
|
230
|
+
let next
|
|
231
|
+
if (existing.includes(BLOCK_START) && existing.includes(BLOCK_END)) {
|
|
232
|
+
const re = new RegExp(`${BLOCK_START.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[\\s\\S]*?${BLOCK_END.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`)
|
|
233
|
+
next = existing.replace(re, block)
|
|
234
|
+
} else if (existing.length > 0) {
|
|
235
|
+
next = `${existing.replace(/\s*$/, '')}\n\n${block}\n`
|
|
236
|
+
} else {
|
|
237
|
+
next = `${block}\n`
|
|
238
|
+
}
|
|
239
|
+
await mkdir(path.dirname(instrFile), { recursive: true })
|
|
240
|
+
await writeFile(instrFile, next, 'utf8')
|
|
241
|
+
|
|
242
|
+
console.log(C.green(`\n✓ 完成:复制 ${copied} 个文件到 ${destDir}`))
|
|
243
|
+
console.log(C.green(`✓ 已维护受管区块:${instrFile}`))
|
|
244
|
+
console.log(C.dim(' 重载/新开会话后,所有工作区都会带上这段常驻指令。'))
|
|
245
|
+
console.log(C.dim(' 卸载:删掉上述两个路径,或删除 AGENTS.md 里 agent-team-playbook 标记之间的内容。'))
|
|
246
|
+
}
|
|
247
|
+
|
|
127
248
|
async function main() {
|
|
128
249
|
const opts = parseArgs(process.argv.slice(2))
|
|
129
250
|
if (opts.help) return printHelp()
|
|
@@ -132,6 +253,10 @@ async function main() {
|
|
|
132
253
|
console.error(C.red(`✗ 找不到包内 skill 目录:${SOURCE_ROOT}`))
|
|
133
254
|
process.exit(1)
|
|
134
255
|
}
|
|
256
|
+
if (opts.global) {
|
|
257
|
+
return runGlobalMode(opts)
|
|
258
|
+
}
|
|
259
|
+
|
|
135
260
|
if (!existsSync(opts.dir)) {
|
|
136
261
|
console.error(C.red(`✗ 目标目录不存在:${opts.dir}`))
|
|
137
262
|
process.exit(1)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-agent-team-playbook",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.1",
|
|
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",
|
|
@@ -43,13 +43,26 @@ whenToUse: 用户要求组队/多 agent 协作;或强调要流程严谨、要
|
|
|
43
43
|
|
|
44
44
|
## 落地到用户项目时
|
|
45
45
|
|
|
46
|
+
**先分清两件事(很重要)**:
|
|
47
|
+
|
|
48
|
+
| 形态 | 是否常驻上下文 |
|
|
49
|
+
|---|---|
|
|
50
|
+
| 本 skill | ❌ **按需加载**——agent 觉得相关才读 |
|
|
51
|
+
| 工作区 `AGENTS.md` | ✅ 每轮自动注入 = **所有 agent 的固定上下文** |
|
|
52
|
+
| 用户全局 `$DSH_HOME/AGENTS.md` | ✅ 对所有工作区生效 |
|
|
53
|
+
|
|
54
|
+
DSH 的指令加载器**只认文件**(没有插件注入通道),所以要"让团队每个 agent 都默认遵守",必须写成文件。
|
|
55
|
+
|
|
46
56
|
插件安装**不会**写用户任何文件。真要写入:
|
|
47
57
|
|
|
48
58
|
```bash
|
|
49
|
-
npx dsh-agent-team-playbook init
|
|
59
|
+
npx dsh-agent-team-playbook init # 装进当前项目(AGENTS.md + docs/)
|
|
50
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 追加受管区块
|
|
51
63
|
```
|
|
52
64
|
|
|
53
65
|
- 遇到同名文件/目录会**逐个询问**,不会静默覆盖。
|
|
54
66
|
- 选「改名」时,写出的文件里对它的引用会**同步改写**,不会留下断链。
|
|
55
|
-
-
|
|
67
|
+
- `--global` 只维护标记之间的区块,**块外内容一律不动**,可重复执行(幂等更新)。
|
|
68
|
+
- 非交互环境(CI)默认遇到冲突就中止,需显式 `--force` / `--skip-conflicts` / `--yes`。
|