dsh-agent-team-playbook 1.30.1 → 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 +296 -98
  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
@@ -28,6 +28,105 @@ window.__ModuleLoader__.load({
28
28
  const { useCallback, useEffect, useMemo, useState } = React
29
29
 
30
30
  const NAME = 'dsh-agent-team-playbook'
31
+
32
+ /**
33
+ * chip 样式:数值照抄原生的 `.workspace`(HeroShell 的 workspace chip),
34
+ * 这样和「音乐制作 / 标准模式」在同一行时视觉一致。
35
+ */
36
+ const CHIP_CSS = `
37
+ .atp-chip{
38
+ border-radius: var(--dsw-radius-sm, 8px);
39
+ max-width: min(100%, 360px);
40
+ min-height: 28px;
41
+ color: var(--dsw-alias-label-primary, inherit);
42
+ cursor: pointer;
43
+ background: 0 0;
44
+ border: none;
45
+ align-items: center;
46
+ gap: 4px;
47
+ padding: 0 8px;
48
+ font: inherit;
49
+ font-size: 13px;
50
+ font-weight: 500;
51
+ line-height: 20px;
52
+ display: inline-flex;
53
+ }
54
+ .atp-chip[aria-expanded="true"]{ background: var(--dsw-alias-interactive-bg-hover, rgba(127,127,127,.14)); }
55
+ @media (hover:hover){ .atp-chip:not(:disabled):hover{ background: var(--dsw-alias-interactive-bg-hover, rgba(127,127,127,.14)); } }
56
+ .atp-chip:disabled{ cursor: default; opacity: .6; }
57
+ .atp-chip .atp-chip-label{ text-overflow: ellipsis; white-space: nowrap; min-width: 0; overflow: hidden; }
58
+ .atp-chip .atp-chip-glyph{ flex: none; color: var(--dsw-alias-label-primary, inherit); }
59
+ /* heroOptions 容器原生是 margin-left:auto(靠右);把我们那行拉回左对齐,紧跟「标准模式」后面 */
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; }
114
+ `
115
+ const CHIP_STYLE_ID = 'agent-team-playbook/chip.css'
116
+
117
+ /** 注入一次样式(幂等)。 */
118
+ function ensureStyle() {
119
+ try {
120
+ if (typeof document === 'undefined') return
121
+ if (document.querySelector(`style[data-plugin-css="${CHIP_STYLE_ID}"]`) !== null) return
122
+ const tag = document.createElement('style')
123
+ tag.setAttribute('data-plugin-css', CHIP_STYLE_ID)
124
+ tag.textContent = CHIP_CSS
125
+ document.head.appendChild(tag)
126
+ } catch {
127
+ /* 样式注入失败不影响功能 */
128
+ }
129
+ }
31
130
  const API = '/api/agent-team-playbook/status'
32
131
  const Button = primitives?.Button
33
132
  const Modal = primitives?.Modal
@@ -96,6 +195,18 @@ window.__ModuleLoader__.load({
96
195
  }
97
196
 
98
197
  /** 解析"当前会话"的 cwd 与 sessionId(客户端 sessions 快照)。 */
198
+ /** 安全取 remote.commands.execute:声明缺失时返回 undefined 而不是抛错。 */
199
+ function remoteExecute(ctx, sessionId, line) {
200
+ try {
201
+ const remote = ctx?.remote ?? (typeof ctx?.get === 'function' ? ctx.get('remote', false) : undefined)
202
+ const commands = remote?.commands ?? (typeof ctx?.get === 'function' ? ctx.get('remote.commands', false) : undefined)
203
+ if (typeof commands?.execute !== 'function') return Promise.resolve({ ok: false, error: { message: '当前 composition 没有远程命令服务,请改用 /atp apply 命令' } })
204
+ return commands.execute(sessionId, line, [])
205
+ } catch (error) {
206
+ return Promise.resolve({ ok: false, error: { message: String(error?.message ?? error) } })
207
+ }
208
+ }
209
+
99
210
  function currentSession(ctx) {
100
211
  try {
101
212
  const rows = ctx?.sessions?.list?.getSnapshot?.()?.byId ?? {}
@@ -119,7 +230,7 @@ window.__ModuleLoader__.load({
119
230
  const { sessionId, cwd } = currentSession(ctx)
120
231
  const data = await fetchStatus(cwd)
121
232
  const found = data?.conflicts ?? []
122
- const execute = (sid, line) => ctx?.remote?.commands?.execute?.(sid, line, [])
233
+ const execute = (sid, line) => remoteExecute(ctx, sid, line)
123
234
  if (found.length > 0) {
124
235
  writeStore({ open: true, conflicts: found, cwd: cwd ?? '', sessionId: sessionId ?? '', execute, afterApply: onDone })
125
236
  return { started: true, conflicts: found.length }
@@ -132,134 +243,149 @@ window.__ModuleLoader__.load({
132
243
  }
133
244
  }
134
245
 
135
- /** 单个冲突的选择行:覆盖 / 备份 / 改名 + 名字输入。 */
136
- function ChoiceRow({ index, conflict, choice, onChoose, renameEnabled, onRename }) {
137
- const btn = (action, text) => {
138
- const active = choice?.action === action
139
- const props = { key: action, onClick: () => onChoose(index, action) }
140
- if (typeof Button === 'function') return h(Button, { ...props, variant: active ? 'primary' : 'outline' }, text)
141
- return h('button', { ...props, type: 'button', style: { fontWeight: active ? 700 : 400 } }, text)
142
- }
143
- const children = [
144
- h('div', { key: 'label', style: { wordBreak: 'break-all', marginBottom: 4 } }, `${index + 1}. ${conflict.rel}`),
145
- h('div', { key: 'reason', style: { opacity: 0.6, fontSize: 12, marginBottom: 6 } }, conflict.reason),
146
- h('div', { key: 'btns', style: { display: 'flex', gap: 6, flexWrap: 'wrap' } },
147
- btn('overwrite', '覆盖'),
148
- btn('backup', '备份'),
149
- renameEnabled ? btn('rename', '改名…') : null),
150
- ]
151
- if (choice?.action === 'rename') {
152
- children.push(
153
- h('div', { key: 'rename', style: { marginTop: 6 } },
154
- h('input', {
155
- value: choice.name ?? '',
156
- placeholder: '新名字(如 team-docs / AGENTS.team.md)',
157
- onChange: (e) => onRename(index, e.target.value),
158
- style: { width: '100%', padding: '6px 8px', borderRadius: 6, border: '1px solid rgba(127,127,127,0.4)', background: 'transparent', color: 'inherit' },
159
- }),
160
- h('div', { style: { opacity: 0.55, fontSize: 12, marginTop: 4 } }, '整份改名:同一类(核心/分册)只需填一次'),
161
- ),
162
- )
163
- }
164
- 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')))
165
278
  }
166
279
 
167
- /** 冲突处理弹窗(挂在 shell.overlay 上,关闭时渲染 null)。 */
280
+ /**
281
+ * 冲突处理面板:限高可滚动;逐项点击即定案、该行消失;
282
+ * 全部定案后自动合成一条 /atp apply 执行。
283
+ */
168
284
  function ResolveDialog() {
169
285
  const state = useStore()
170
- const [choices, setChoices] = React.useState([])
286
+ const decidedRef = React.useRef(new Map())
287
+ const [decidedCount, setDecidedCount] = React.useState(0)
171
288
  const [error, setError] = React.useState('')
289
+ const runningRef = React.useRef(false)
172
290
 
173
291
  React.useEffect(() => {
174
292
  if (!state.open) return
293
+ decidedRef.current = new Map()
294
+ setDecidedCount(0)
175
295
  setError('')
176
- setChoices((state.conflicts ?? []).map(() => ({ action: 'overwrite' })))
296
+ runningRef.current = false
177
297
  }, [state.open, state.conflicts])
178
298
 
179
299
  if (!state.open) return null
180
300
 
181
- const isCoreRel = (rel) => rel === 'AGENTS.md'
182
- const onChoose = (i, action) => {
183
- setChoices((prev) => {
184
- const next = [...prev]
185
- next[i] = { ...(next[i] ?? {}), action }
186
- return next
187
- })
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()
188
307
  }
189
- const onRename = (i, name) => {
190
- setChoices((prev) => {
191
- const next = [...prev]
192
- next[i] = { ...(next[i] ?? {}), action: 'rename', name }
193
- // 同一单元(核心/分册)共享同一个改名值
194
- const unit = isCoreRel((state.conflicts ?? [])[i]?.rel ?? '')
195
- next.forEach((c, j) => {
196
- if (j !== i && isCoreRel((state.conflicts ?? [])[j]?.rel ?? '') === unit) next[j] = { ...(next[j] ?? {}), name }
197
- })
198
- return next
308
+
309
+ const decideAll = (action) => {
310
+ conflicts.forEach((_, i) => {
311
+ if (!decidedRef.current.has(i)) decidedRef.current.set(i, { action })
199
312
  })
313
+ setDecidedCount(decidedRef.current.size)
314
+ void maybeApply()
200
315
  }
201
316
 
202
- const apply = async () => {
203
- const conflicts = state.conflicts ?? []
204
- const missing = choices.findIndex((c, i) => c?.action === 'rename' && !String(c.name ?? '').trim())
205
- if (missing >= 0) {
206
- setError(`第 ${missing + 1} 项选了改名但没填名字`)
207
- return
208
- }
209
- if (!state.sessionId || typeof state.execute !== 'function') {
210
- setError('拿不到当前会话,无法执行;请改用 /atp apply 命令')
211
- return
212
- }
317
+ const maybeApply = async () => {
318
+ if (runningRef.current) return
319
+ if (decidedRef.current.size < conflicts.length) return
320
+ runningRef.current = true
213
321
  try {
214
- writeStore({ busy: true })
215
- 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)
216
340
  const result = await state.execute(state.sessionId, line)
217
341
  if (result && result.ok === false) throw new Error(result?.error?.message ?? '命令执行失败')
218
- writeStore({ open: false, busy: false, message: `已执行:${line}` })
342
+ writeStore({ open: false })
219
343
  if (typeof state.afterApply === 'function') await state.afterApply()
220
344
  } catch (e) {
221
345
  setError(String(e?.message ?? e))
222
- writeStore({ busy: false })
346
+ runningRef.current = false
223
347
  }
224
348
  }
225
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
+
226
355
  const footer = h('div', { style: { display: 'flex', gap: 8, justifyContent: 'flex-end' } },
227
356
  typeof Button === 'function'
228
357
  ? h(Button, { variant: 'outline', onClick: () => writeStore({ open: false }) }, '取消')
229
- : h('button', { type: 'button', onClick: () => writeStore({ open: false }) }, '取消'),
230
- typeof Button === 'function'
231
- ? h(Button, { variant: 'primary', disabled: state.busy, onClick: () => void apply() }, state.busy ? '执行中…' : '应用')
232
- : h('button', { type: 'button', disabled: state.busy, onClick: () => void apply() }, '应用'),
233
- )
358
+ : h('button', { type: 'button', onClick: () => writeStore({ open: false }) }, '取消'))
234
359
 
235
360
  const body = [
236
- h('div', { key: 'cwd', style: { opacity: 0.65, fontSize: 12, marginBottom: 10, wordBreak: 'break-all' } }, state.cwd),
237
- ...(state.conflicts ?? []).map((conflict, i) =>
238
- h(ChoiceRow, {
239
- key: `c${i}`,
240
- index: i,
241
- conflict,
242
- choice: choices[i],
243
- onChoose,
244
- renameEnabled: true,
245
- onRename,
246
- })),
247
- error ? h('div', { key: 'err', style: { color: 'var(--dsh-danger, #c0563b)', marginTop: 10 } }, error) : null,
248
- h('div', { key: 'hint', style: { opacity: 0.55, fontSize: 12, marginTop: 12 } },
249
- '点"应用"会执行一条 /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 命令(与手打等价,可在会话里看到)。'),
250
370
  ].filter(Boolean)
251
371
 
252
372
  if (typeof Modal !== 'function') {
253
- return h('div', { style: { position: 'fixed', inset: 0, background: 'rgba(0,0,0,0.5)', zIndex: 9999, padding: 20, overflow: 'auto' } },
254
- 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))
255
375
  }
256
376
  return h(Modal, { open: true, onClose: () => writeStore({ open: false }), title: '处理同名内容', closeLabel: '取消', footer }, body)
257
377
  }
258
378
 
259
- /** 首页 chip 行入口:和「音乐制作 / 标准模式」并排。 */
379
+
380
+ /**
381
+ * 首页 chip + 下拉菜单(菜单样式沿用原生菜单材质变量)。
382
+ * 菜单项:安装 / 覆盖式安装 / 检查冲突 / 复制命令。
383
+ */
260
384
  function HeroEntry() {
261
385
  const [badge, setBadge] = React.useState('')
386
+ const [open, setOpen] = React.useState(false)
262
387
  const [busy, setBusy] = React.useState(false)
388
+ const wrapRef = React.useRef(null)
263
389
 
264
390
  React.useEffect(() => {
265
391
  let alive = true
@@ -270,7 +396,7 @@ window.__ModuleLoader__.load({
270
396
  const n = data?.conflicts?.length ?? 0
271
397
  if (alive && n > 0) setBadge(` · ${n}`)
272
398
  } catch {
273
- /* 静默:首页 chip 不该因为检测失败而打扰 */
399
+ /* 静默:chip 不该因为检测失败而打扰 */
274
400
  }
275
401
  })()
276
402
  return () => {
@@ -278,21 +404,92 @@ window.__ModuleLoader__.load({
278
404
  }
279
405
  }, [])
280
406
 
281
- 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)
282
421
  if (busy) return
283
422
  setBusy(true)
284
423
  try {
285
- await detectThenInstall(HeroEntry.ctx, undefined)
424
+ await fn()
286
425
  } finally {
287
426
  setBusy(false)
288
427
  }
289
428
  }
290
429
 
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
+
463
+ const Icon = primitives?.IconChecklistOutlineRegular
291
464
  const label = busy ? '协作规程…' : `协作规程${badge}`
292
- if (typeof Button === 'function') {
293
- return h(Button, { variant: 'outline', disabled: busy, onClick: () => void onClick() }, label)
294
- }
295
- return h('button', { type: 'button', disabled: busy, onClick: () => void onClick() }, label)
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)
296
493
  }
297
494
 
298
495
  function Panel() {
@@ -324,7 +521,7 @@ window.__ModuleLoader__.load({
324
521
  autoOpened = fingerprint
325
522
  const ctx = Panel.ctx
326
523
  const { sessionId, cwd } = currentSession(ctx)
327
- const execute = async (sid, line) => ctx?.remote?.commands?.execute?.(sid, line, [])
524
+ const execute = async (sid, line) => remoteExecute(ctx, sid, line)
328
525
  writeStore({ open: true, conflicts: found, cwd: cwd ?? '', sessionId: sessionId ?? '', execute, afterApply: refresh })
329
526
  }, [state, refresh])
330
527
 
@@ -378,7 +575,7 @@ window.__ModuleLoader__.load({
378
575
  onClick: () => {
379
576
  const ctx = Panel.ctx
380
577
  const { sessionId, cwd } = currentSession(ctx)
381
- const execute = async (sid, line) => ctx?.remote?.commands?.execute?.(sid, line, [])
578
+ const execute = async (sid, line) => remoteExecute(ctx, sid, line)
382
579
  writeStore({ open: true, conflicts, cwd: cwd ?? '', sessionId: sessionId ?? '', execute, afterApply: refresh })
383
580
  },
384
581
  }, '逐项处理冲突…')
@@ -419,6 +616,7 @@ window.__ModuleLoader__.load({
419
616
  }
420
617
 
421
618
  function apply(ctx) {
619
+ ensureStyle()
422
620
  Panel.ctx = ctx
423
621
  ctx.slots.inject('settings.section', () => ctx.slots.register({
424
622
  name: 'settings.section',
@@ -444,7 +642,7 @@ window.__ModuleLoader__.load({
444
642
  }
445
643
 
446
644
  exports.apply = apply
447
- exports.inject = ['slots', 'sessions', 'remote.commands']
645
+ exports.inject = ['slots', 'sessions', 'remote', 'remote.commands']
448
646
  exports.name = NAME
449
647
  // 测试缝:拼命令是纯函数,单独可测
450
648
  exports.__test = { buildApplySpec, detectThenInstall, ResolveDialog, ChoiceRow, readStore }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agent-team-playbook",
3
- "version": "1.30.1",
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",