dsh-agent-team-playbook 1.30.2 → 1.31.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 (3) hide show
  1. package/README.md +2 -1
  2. package/client.js +233 -101
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -114,7 +114,8 @@ dsh plugin --profile web add dsh-agent-team-playbook
114
114
  2. **设置 → 协作规程** 面板:
115
115
 
116
116
  - 显示当前工作区是否已安装、有无同名冲突
117
- - 点「**安装到工作区**」:无冲突直接装;**有冲突会直接弹出处理对话框**(不用先执行命令)
117
+ - 点 chip 弹出**下拉菜单**(与「标准模式」同款材质):安装到工作区 / 覆盖式安装 / 检查冲突… / 复制命令
118
+ - 冲突面板:**限高可滚动**(`max-height: min(60vh,520px)`),逐项点「覆盖 / 备份 / 改名…」后**该行立即消失**,全部定案后自动执行一条 `/atp apply`;也可「全部覆盖 / 全部备份」一键定案
118
119
  - 打开面板时若已存在冲突,也会**自动弹一次**
119
120
  - 对话框每项可选 **覆盖 / 备份 / 改名**,底部「应用」
120
121
  - 应用时会执行一条 `/atp apply …` 命令(与手动输入**等价**,会在会话里留下审计记录),因此插件**不新增任何写文件接口**
package/client.js CHANGED
@@ -58,6 +58,59 @@ window.__ModuleLoader__.load({
58
58
  .atp-chip .atp-chip-glyph{ flex: none; color: var(--dsw-alias-label-primary, inherit); }
59
59
  /* heroOptions 容器原生是 margin-left:auto(靠右);把我们那行拉回左对齐,紧跟「标准模式」后面 */
60
60
  div:has(> .atp-chip){ margin-left: 0 !important; }
61
+
62
+ /* chip 包裹层:给下拉菜单做定位基准 */
63
+ .atp-wrap{ position: relative; display: inline-flex; }
64
+
65
+ /* 下拉菜单:沿用原生菜单的材质变量 */
66
+ .atp-menu{
67
+ position: absolute;
68
+ top: calc(100% + 6px);
69
+ left: 0;
70
+ z-index: 60;
71
+ min-width: 200px;
72
+ padding: 4px;
73
+ border-radius: var(--dsw-radius-md, 10px);
74
+ box-shadow: var(--dsw-elevation-panel, 0 8px 24px rgba(0,0,0,.32));
75
+ background: var(--dsw-specific-menu, rgba(40,40,40,.98));
76
+ backdrop-filter: var(--dsw-menu-backdrop-filter, blur(12px));
77
+ }
78
+ .atp-menu-item{
79
+ width: 100%;
80
+ min-height: 32px;
81
+ padding: 0 10px;
82
+ border: 0;
83
+ border-radius: var(--dsw-radius-sm, 8px);
84
+ background: none;
85
+ color: var(--dsw-alias-label-primary, inherit);
86
+ font: inherit;
87
+ font-size: 13px;
88
+ text-align: left;
89
+ display: flex;
90
+ align-items: center;
91
+ gap: 8px;
92
+ cursor: pointer;
93
+ }
94
+ .atp-menu-item:hover{ background: var(--dsw-alias-interactive-bg-hover, rgba(127,127,127,.16)); }
95
+ .atp-menu-item[data-danger="true"]{ color: var(--dsw-alias-label-danger, #e06c5a); }
96
+ .atp-menu-hint{ padding: 6px 10px; font-size: 12px; opacity: .6; }
97
+
98
+ /* 冲突面板:限高 + 内部滚动,避免撑满整屏 */
99
+ .atp-conflict-body{
100
+ max-height: min(60vh, 520px);
101
+ overflow-y: auto;
102
+ overscroll-behavior: contain;
103
+ padding-right: 4px;
104
+ }
105
+ .atp-conflict-row{ display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-top: 1px solid rgba(127,127,127,.18); }
106
+ .atp-conflict-row:first-child{ border-top: none; }
107
+ .atp-conflict-path{ flex: 1 1 auto; min-width: 0; word-break: break-all; font-size: 13px; }
108
+ .atp-conflict-actions{ flex: none; display: flex; gap: 6px; flex-wrap: wrap; }
109
+ .atp-pill{ min-height: 26px; padding: 0 8px; border-radius: var(--dsw-radius-sm, 8px); border: 1px solid rgba(127,127,127,.35);
110
+ background: none; color: inherit; font: inherit; font-size: 12px; cursor: pointer; }
111
+ .atp-pill:hover{ background: var(--dsw-alias-interactive-bg-hover, rgba(127,127,127,.16)); }
112
+ .atp-toolbar{ display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
113
+ .atp-muted{ opacity: .6; font-size: 12px; }
61
114
  `
62
115
  const CHIP_STYLE_ID = 'agent-team-playbook/chip.css'
63
116
 
@@ -190,134 +243,149 @@ div:has(> .atp-chip){ margin-left: 0 !important; }
190
243
  }
191
244
  }
192
245
 
193
- /** 单个冲突的选择行:覆盖 / 备份 / 改名 + 名字输入。 */
194
- function ChoiceRow({ index, conflict, choice, onChoose, renameEnabled, onRename }) {
195
- const btn = (action, text) => {
196
- const active = choice?.action === action
197
- const props = { key: action, onClick: () => onChoose(index, action) }
198
- if (typeof Button === 'function') return h(Button, { ...props, variant: active ? 'primary' : 'outline' }, text)
199
- return h('button', { ...props, type: 'button', style: { fontWeight: active ? 700 : 400 } }, text)
200
- }
201
- const children = [
202
- h('div', { key: 'label', style: { wordBreak: 'break-all', marginBottom: 4 } }, `${index + 1}. ${conflict.rel}`),
203
- h('div', { key: 'reason', style: { opacity: 0.6, fontSize: 12, marginBottom: 6 } }, conflict.reason),
204
- h('div', { key: 'btns', style: { display: 'flex', gap: 6, flexWrap: 'wrap' } },
205
- btn('overwrite', '覆盖'),
206
- btn('backup', '备份'),
207
- renameEnabled ? btn('rename', '改名…') : null),
208
- ]
209
- if (choice?.action === 'rename') {
210
- children.push(
211
- h('div', { key: 'rename', style: { marginTop: 6 } },
212
- h('input', {
213
- value: choice.name ?? '',
214
- placeholder: '新名字(如 team-docs / AGENTS.team.md)',
215
- onChange: (e) => onRename(index, e.target.value),
216
- style: { width: '100%', padding: '6px 8px', borderRadius: 6, border: '1px solid rgba(127,127,127,0.4)', background: 'transparent', color: 'inherit' },
217
- }),
218
- h('div', { style: { opacity: 0.55, fontSize: 12, marginTop: 4 } }, '整份改名:同一类(核心/分册)只需填一次'),
219
- ),
220
- )
221
- }
222
- return h('div', { key: `row${index}`, style: { padding: '8px 0', borderTop: index === 0 ? 'none' : '1px solid rgba(127,127,127,0.18)' } }, children)
246
+ /**
247
+ * 单个冲突行:点「覆盖 / 备份」立即定案(该行随即消失);
248
+ * 点「改名…」展开名字输入,确认后定案。
249
+ */
250
+ function ChoiceRow({ index, conflict, onDecide }) {
251
+ const [renaming, setRenaming] = React.useState(false)
252
+ const [name, setName] = React.useState('')
253
+
254
+ const pill = (text, onClick, key) => h('button', { key, type: 'button', className: 'atp-pill', onClick }, text)
255
+
256
+ return h('div', { className: 'atp-conflict-row' },
257
+ h('div', { className: 'atp-conflict-path' },
258
+ h('div', null, `${index + 1}. ${conflict.rel}`),
259
+ h('div', { className: 'atp-muted' }, conflict.reason),
260
+ renaming
261
+ ? h('div', { style: { display: 'flex', gap: 6, marginTop: 6 } },
262
+ h('input', {
263
+ value: name,
264
+ placeholder: '新名字,如 team-docs / AGENTS.team.md',
265
+ onChange: (e) => setName(e.target.value),
266
+ style: { flex: '1 1 auto', minWidth: 0, height: 26, padding: '0 8px', borderRadius: 6, border: '1px solid rgba(127,127,127,.4)', background: 'transparent', color: 'inherit', font: 'inherit', fontSize: 12 },
267
+ }),
268
+ pill('确定', () => {
269
+ const clean = String(name).trim()
270
+ if (clean !== '') onDecide(index, 'rename', clean)
271
+ }, 'ok'),
272
+ pill('取消', () => setRenaming(false), 'cancel'))
273
+ : null),
274
+ h('div', { className: 'atp-conflict-actions' },
275
+ pill('覆盖', () => onDecide(index, 'overwrite'), 'ow'),
276
+ pill('备份', () => onDecide(index, 'backup'), 'bk'),
277
+ renaming ? null : pill('改名…', () => setRenaming(true), 'rn')))
223
278
  }
224
279
 
225
- /** 冲突处理弹窗(挂在 shell.overlay 上,关闭时渲染 null)。 */
280
+ /**
281
+ * 冲突处理面板:限高可滚动;逐项点击即定案、该行消失;
282
+ * 全部定案后自动合成一条 /atp apply 执行。
283
+ */
226
284
  function ResolveDialog() {
227
285
  const state = useStore()
228
- const [choices, setChoices] = React.useState([])
286
+ const decidedRef = React.useRef(new Map())
287
+ const [decidedCount, setDecidedCount] = React.useState(0)
229
288
  const [error, setError] = React.useState('')
289
+ const runningRef = React.useRef(false)
230
290
 
231
291
  React.useEffect(() => {
232
292
  if (!state.open) return
293
+ decidedRef.current = new Map()
294
+ setDecidedCount(0)
233
295
  setError('')
234
- setChoices((state.conflicts ?? []).map(() => ({ action: 'overwrite' })))
296
+ runningRef.current = false
235
297
  }, [state.open, state.conflicts])
236
298
 
237
299
  if (!state.open) return null
238
300
 
239
- const isCoreRel = (rel) => rel === 'AGENTS.md'
240
- const onChoose = (i, action) => {
241
- setChoices((prev) => {
242
- const next = [...prev]
243
- next[i] = { ...(next[i] ?? {}), action }
244
- return next
245
- })
301
+ const conflicts = state.conflicts ?? []
302
+
303
+ const decide = (index, action, name) => {
304
+ decidedRef.current.set(index, { action, name })
305
+ setDecidedCount(decidedRef.current.size)
306
+ void maybeApply()
246
307
  }
247
- const onRename = (i, name) => {
248
- setChoices((prev) => {
249
- const next = [...prev]
250
- next[i] = { ...(next[i] ?? {}), action: 'rename', name }
251
- // 同一单元(核心/分册)共享同一个改名值
252
- const unit = isCoreRel((state.conflicts ?? [])[i]?.rel ?? '')
253
- next.forEach((c, j) => {
254
- if (j !== i && isCoreRel((state.conflicts ?? [])[j]?.rel ?? '') === unit) next[j] = { ...(next[j] ?? {}), name }
255
- })
256
- return next
308
+
309
+ const decideAll = (action) => {
310
+ conflicts.forEach((_, i) => {
311
+ if (!decidedRef.current.has(i)) decidedRef.current.set(i, { action })
257
312
  })
313
+ setDecidedCount(decidedRef.current.size)
314
+ void maybeApply()
258
315
  }
259
316
 
260
- const apply = async () => {
261
- const conflicts = state.conflicts ?? []
262
- const missing = choices.findIndex((c, i) => c?.action === 'rename' && !String(c.name ?? '').trim())
263
- if (missing >= 0) {
264
- setError(`第 ${missing + 1} 项选了改名但没填名字`)
265
- return
266
- }
267
- if (!state.sessionId || typeof state.execute !== 'function') {
268
- setError('拿不到当前会话,无法执行;请改用 /atp apply 命令')
269
- return
270
- }
317
+ const maybeApply = async () => {
318
+ if (runningRef.current) return
319
+ if (decidedRef.current.size < conflicts.length) return
320
+ runningRef.current = true
271
321
  try {
272
- writeStore({ busy: true })
273
- const line = buildApplySpec(choices)
322
+ // 同一单元(核心/分册)共享改名值
323
+ const choices = conflicts.map((c, i) => {
324
+ const d = decidedRef.current.get(i) ?? { action: 'overwrite' }
325
+ return d
326
+ })
327
+ const coreName = choices.find((c, i) => c.action === 'rename' && conflicts[i].rel === 'AGENTS.md')?.name
328
+ const docsName = choices.find((c, i) => c.action === 'rename' && conflicts[i].rel !== 'AGENTS.md')?.name
329
+ const normalized = conflicts.map((c, i) => {
330
+ const d = choices[i]
331
+ if (d.action !== 'rename') return d
332
+ return { action: 'rename', name: c.rel === 'AGENTS.md' ? coreName : docsName }
333
+ })
334
+ if (normalized.some((c) => c.action === 'rename' && !String(c.name ?? '').trim())) {
335
+ setError('改名项缺少名字')
336
+ runningRef.current = false
337
+ return
338
+ }
339
+ const line = buildApplySpec(normalized)
274
340
  const result = await state.execute(state.sessionId, line)
275
341
  if (result && result.ok === false) throw new Error(result?.error?.message ?? '命令执行失败')
276
- writeStore({ open: false, busy: false, message: `已执行:${line}` })
342
+ writeStore({ open: false })
277
343
  if (typeof state.afterApply === 'function') await state.afterApply()
278
344
  } catch (e) {
279
345
  setError(String(e?.message ?? e))
280
- writeStore({ busy: false })
346
+ runningRef.current = false
281
347
  }
282
348
  }
283
349
 
350
+ const rows = conflicts
351
+ .map((conflict, index) => ({ conflict, index }))
352
+ .filter(({ index }) => !decidedRef.current.has(index))
353
+ .map(({ conflict, index }) => h(ChoiceRow, { key: `c${index}`, index, conflict, onDecide: decide }))
354
+
284
355
  const footer = h('div', { style: { display: 'flex', gap: 8, justifyContent: 'flex-end' } },
285
356
  typeof Button === 'function'
286
357
  ? h(Button, { variant: 'outline', onClick: () => writeStore({ open: false }) }, '取消')
287
- : h('button', { type: 'button', onClick: () => writeStore({ open: false }) }, '取消'),
288
- typeof Button === 'function'
289
- ? h(Button, { variant: 'primary', disabled: state.busy, onClick: () => void apply() }, state.busy ? '执行中…' : '应用')
290
- : h('button', { type: 'button', disabled: state.busy, onClick: () => void apply() }, '应用'),
291
- )
358
+ : h('button', { type: 'button', onClick: () => writeStore({ open: false }) }, '取消'))
292
359
 
293
360
  const body = [
294
- h('div', { key: 'cwd', style: { opacity: 0.65, fontSize: 12, marginBottom: 10, wordBreak: 'break-all' } }, state.cwd),
295
- ...(state.conflicts ?? []).map((conflict, i) =>
296
- h(ChoiceRow, {
297
- key: `c${i}`,
298
- index: i,
299
- conflict,
300
- choice: choices[i],
301
- onChoose,
302
- renameEnabled: true,
303
- onRename,
304
- })),
305
- error ? h('div', { key: 'err', style: { color: 'var(--dsh-danger, #c0563b)', marginTop: 10 } }, error) : null,
306
- h('div', { key: 'hint', style: { opacity: 0.55, fontSize: 12, marginTop: 12 } },
307
- '点"应用"会执行一条 /atp apply 命令(与手动输入等价,可在会话里看到审计记录)。'),
361
+ h('div', { key: 'cwd', className: 'atp-muted', style: { marginBottom: 8, wordBreak: 'break-all' } }, state.cwd),
362
+ h('div', { key: 'bar', className: 'atp-toolbar' },
363
+ h('span', { className: 'atp-muted' }, `还剩 ${conflicts.length - decidedCount} 项`),
364
+ h('button', { type: 'button', className: 'atp-pill', onClick: () => decideAll('overwrite') }, '全部覆盖'),
365
+ h('button', { type: 'button', className: 'atp-pill', onClick: () => decideAll('backup') }, '全部备份')),
366
+ h('div', { key: 'list', className: 'atp-conflict-body' }, rows.length > 0 ? rows : h('div', { className: 'atp-muted' }, '已全部决定,正在执行…')),
367
+ error ? h('div', { key: 'err', style: { color: 'var(--dsh-alias-label-danger, #e06c5a)', marginTop: 8 } }, error) : null,
368
+ h('div', { key: 'hint', className: 'atp-muted', style: { marginTop: 8 } },
369
+ '每点一项即定案;全部决定后自动执行一条 /atp apply 命令(与手打等价,可在会话里看到)。'),
308
370
  ].filter(Boolean)
309
371
 
310
372
  if (typeof Modal !== 'function') {
311
- return h('div', { style: { position: 'fixed', inset: 0, background: 'rgba(0,0,0,0.5)', zIndex: 9999, padding: 20, overflow: 'auto' } },
312
- h('div', { style: { background: 'var(--dsh-surface, #1b1b1b)', padding: 16, borderRadius: 10 } }, body, footer))
373
+ return h('div', { style: { position: 'fixed', inset: 0, background: 'rgba(0,0,0,.5)', zIndex: 9999, padding: 16, overflow: 'auto' } },
374
+ h('div', { style: { background: 'var(--dsw-specific-menu, #1b1b1b)', padding: 16, borderRadius: 10, maxHeight: '80vh' } }, body, footer))
313
375
  }
314
376
  return h(Modal, { open: true, onClose: () => writeStore({ open: false }), title: '处理同名内容', closeLabel: '取消', footer }, body)
315
377
  }
316
378
 
317
- /** 首页 chip 行入口:和「音乐制作 / 标准模式」并排。 */
379
+
380
+ /**
381
+ * 首页 chip + 下拉菜单(菜单样式沿用原生菜单材质变量)。
382
+ * 菜单项:安装 / 覆盖式安装 / 检查冲突 / 复制命令。
383
+ */
318
384
  function HeroEntry() {
319
385
  const [badge, setBadge] = React.useState('')
386
+ const [open, setOpen] = React.useState(false)
320
387
  const [busy, setBusy] = React.useState(false)
388
+ const wrapRef = React.useRef(null)
321
389
 
322
390
  React.useEffect(() => {
323
391
  let alive = true
@@ -328,7 +396,7 @@ div:has(> .atp-chip){ margin-left: 0 !important; }
328
396
  const n = data?.conflicts?.length ?? 0
329
397
  if (alive && n > 0) setBadge(` · ${n}`)
330
398
  } catch {
331
- /* 静默:首页 chip 不该因为检测失败而打扰 */
399
+ /* 静默:chip 不该因为检测失败而打扰 */
332
400
  }
333
401
  })()
334
402
  return () => {
@@ -336,28 +404,92 @@ div:has(> .atp-chip){ margin-left: 0 !important; }
336
404
  }
337
405
  }, [])
338
406
 
339
- const onClick = async () => {
407
+ // 点外部关闭
408
+ React.useEffect(() => {
409
+ if (!open) return
410
+ const onPointerDown = (event) => {
411
+ const node = wrapRef.current
412
+ if (node !== null && node.contains(event.target)) return
413
+ setOpen(false)
414
+ }
415
+ document.addEventListener('pointerdown', onPointerDown, true)
416
+ return () => document.removeEventListener('pointerdown', onPointerDown, true)
417
+ }, [open])
418
+
419
+ const run = async (fn) => {
420
+ setOpen(false)
340
421
  if (busy) return
341
422
  setBusy(true)
342
423
  try {
343
- await detectThenInstall(HeroEntry.ctx, undefined)
424
+ await fn()
344
425
  } finally {
345
426
  setBusy(false)
346
427
  }
347
428
  }
348
429
 
349
- const label = busy ? '协作规程…' : `协作规程${badge}`
430
+ const items = [
431
+ {
432
+ key: 'install',
433
+ label: '安装到工作区',
434
+ onSelect: () => detectThenInstall(HeroEntry.ctx, undefined),
435
+ },
436
+ {
437
+ key: 'force',
438
+ label: '覆盖式安装',
439
+ danger: true,
440
+ onSelect: async () => {
441
+ const { sessionId } = currentSession(HeroEntry.ctx)
442
+ await remoteExecute(HeroEntry.ctx, sessionId, '/atp install force')
443
+ },
444
+ },
445
+ {
446
+ key: 'check',
447
+ label: '检查冲突…',
448
+ onSelect: () => detectThenInstall(HeroEntry.ctx, undefined),
449
+ },
450
+ {
451
+ key: 'copy',
452
+ label: '复制 /atp install',
453
+ onSelect: async () => {
454
+ try {
455
+ await navigator.clipboard.writeText('/atp install')
456
+ } catch {
457
+ /* 剪贴板不可用就算了 */
458
+ }
459
+ },
460
+ },
461
+ ]
462
+
350
463
  const Icon = primitives?.IconChecklistOutlineRegular
351
- // 结构照抄原生 chip:button + 16px 图标 + 文本(无边框、透明底、hover 才出底色)
352
- return h('button', {
353
- type: 'button',
354
- className: 'atp-chip',
355
- disabled: busy,
356
- 'aria-label': '多智能体协作规程',
357
- onClick: () => void onClick(),
358
- },
359
- Icon !== undefined ? h(Icon, { className: 'atp-chip-glyph', size: 16 }) : null,
360
- h('span', { className: 'atp-chip-label' }, label))
464
+ const label = busy ? '协作规程…' : `协作规程${badge}`
465
+
466
+ return h('div', { className: 'atp-wrap', ref: wrapRef },
467
+ h('button', {
468
+ type: 'button',
469
+ className: 'atp-chip',
470
+ disabled: busy,
471
+ 'aria-label': '多智能体协作规程',
472
+ 'aria-expanded': open,
473
+ 'aria-haspopup': 'menu',
474
+ onClick: () => setOpen((v) => !v),
475
+ },
476
+ Icon !== undefined ? h(Icon, { className: 'atp-chip-glyph', size: 16 }) : null,
477
+ h('span', { className: 'atp-chip-label' }, label),
478
+ h('span', { className: 'atp-chip-glyph', style: { fontSize: 10 } }, '▾')),
479
+
480
+ open
481
+ ? h('div', { className: 'atp-menu', role: 'menu' },
482
+ ...items.map((item) =>
483
+ h('button', {
484
+ key: item.key,
485
+ type: 'button',
486
+ role: 'menuitem',
487
+ className: 'atp-menu-item',
488
+ 'data-danger': item.danger === true ? 'true' : undefined,
489
+ onClick: () => void run(item.onSelect),
490
+ }, item.label)),
491
+ h('div', { className: 'atp-menu-hint' }, '覆盖式安装会先把你的原件暂存,失败可回滚'))
492
+ : null)
361
493
  }
362
494
 
363
495
  function Panel() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agent-team-playbook",
3
- "version": "1.30.2",
3
+ "version": "1.31.0",
4
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",