dsh-agent-team-playbook 1.28.0 → 1.30.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 +7 -2
  2. package/client.js +94 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -108,10 +108,15 @@ dsh plugin --profile web add dsh-agent-team-playbook
108
108
  | `/atp apply 1=覆盖 2=备份 3=改名:x` | 对 install 列出的冲突**逐项决定**(覆盖 / 备份你的文件 / 我们这侧改名并同步引用) |
109
109
  | `/atp help` | 用法 |
110
110
 
111
- **Web / 桌面端还会多一个设置面板**(设置 → 协作规程):
111
+ **Web / 桌面端有两个入口**:
112
+
113
+ 1. **首页 chip 行**(与「音乐制作 / 标准模式」并排)的「协作规程」——有冲突时角标显示数量,点一下:有冲突弹出处理框、无冲突直接安装
114
+ 2. **设置 → 协作规程** 面板:
112
115
 
113
116
  - 显示当前工作区是否已安装、有无同名冲突
114
- - 有冲突时点「**逐项处理冲突…**」弹出对话框:每项可选 **覆盖 / 备份 / 改名**,底部「应用」
117
+ - 点「**安装到工作区**」:无冲突直接装;**有冲突会直接弹出处理对话框**(不用先执行命令)
118
+ - 打开面板时若已存在冲突,也会**自动弹一次**
119
+ - 对话框每项可选 **覆盖 / 备份 / 改名**,底部「应用」
115
120
  - 应用时会执行一条 `/atp apply …` 命令(与手动输入**等价**,会在会话里留下审计记录),因此插件**不新增任何写文件接口**
116
121
  - 也可以只复制建议命令,自己粘贴执行
117
122
 
package/client.js CHANGED
@@ -43,6 +43,7 @@ window.__ModuleLoader__.load({
43
43
  store.listeners.add(fn)
44
44
  return () => store.listeners.delete(fn)
45
45
  }
46
+ let autoOpened = ''
46
47
  const useStore = () => {
47
48
  const [snap, setSnap] = React.useState(readStore)
48
49
  React.useEffect(() => subscribeStore(() => setSnap(readStore())), [])
@@ -108,6 +109,29 @@ window.__ModuleLoader__.load({
108
109
  }
109
110
  }
110
111
 
112
+ /**
113
+ * 共享动作:检测当前工作区 → 有冲突打开弹窗,没有就直接装。
114
+ * 面板按钮与首页 chip 都走这一条路径。
115
+ * @returns {Promise<{started: boolean, conflicts: number, error?: string}>}
116
+ */
117
+ async function detectThenInstall(ctx, onDone) {
118
+ try {
119
+ const { sessionId, cwd } = currentSession(ctx)
120
+ const data = await fetchStatus(cwd)
121
+ const found = data?.conflicts ?? []
122
+ const execute = (sid, line) => ctx?.remote?.commands?.execute?.(sid, line, [])
123
+ if (found.length > 0) {
124
+ writeStore({ open: true, conflicts: found, cwd: cwd ?? '', sessionId: sessionId ?? '', execute, afterApply: onDone })
125
+ return { started: true, conflicts: found.length }
126
+ }
127
+ await execute(sessionId, '/atp install')
128
+ if (typeof onDone === 'function') await onDone()
129
+ return { started: true, conflicts: 0 }
130
+ } catch (error) {
131
+ return { started: false, conflicts: 0, error: String(error?.message ?? error) }
132
+ }
133
+ }
134
+
111
135
  /** 单个冲突的选择行:覆盖 / 备份 / 改名 + 名字输入。 */
112
136
  function ChoiceRow({ index, conflict, choice, onChoose, renameEnabled, onRename }) {
113
137
  const btn = (action, text) => {
@@ -232,6 +256,45 @@ window.__ModuleLoader__.load({
232
256
  return h(Modal, { open: true, onClose: () => writeStore({ open: false }), title: '处理同名内容', closeLabel: '取消', footer }, body)
233
257
  }
234
258
 
259
+ /** 首页 chip 行入口:和「音乐制作 / 标准模式」并排。 */
260
+ function HeroEntry() {
261
+ const [badge, setBadge] = React.useState('')
262
+ const [busy, setBusy] = React.useState(false)
263
+
264
+ React.useEffect(() => {
265
+ let alive = true
266
+ ;(async () => {
267
+ try {
268
+ const { cwd } = currentSession(HeroEntry.ctx)
269
+ const data = await fetchStatus(cwd)
270
+ const n = data?.conflicts?.length ?? 0
271
+ if (alive && n > 0) setBadge(` · ${n}`)
272
+ } catch {
273
+ /* 静默:首页 chip 不该因为检测失败而打扰 */
274
+ }
275
+ })()
276
+ return () => {
277
+ alive = false
278
+ }
279
+ }, [])
280
+
281
+ const onClick = async () => {
282
+ if (busy) return
283
+ setBusy(true)
284
+ try {
285
+ await detectThenInstall(HeroEntry.ctx, undefined)
286
+ } finally {
287
+ setBusy(false)
288
+ }
289
+ }
290
+
291
+ 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)
296
+ }
297
+
235
298
  function Panel() {
236
299
  const [state, setState] = useState({ phase: 'loading' })
237
300
  const [copied, setCopied] = useState('')
@@ -251,6 +314,20 @@ window.__ModuleLoader__.load({
251
314
  void refresh()
252
315
  }, [refresh])
253
316
 
317
+ // 首次进入且已有冲突 → 自动弹一次;同一组冲突只自动弹一次
318
+ useEffect(() => {
319
+ if (state.phase !== 'ready') return
320
+ const found = state.data?.conflicts ?? []
321
+ if (found.length === 0) return
322
+ const fingerprint = `${state.cwd ?? ''}|${found.map((c) => c.rel).join(',')}`
323
+ if (autoOpened === fingerprint) return
324
+ autoOpened = fingerprint
325
+ const ctx = Panel.ctx
326
+ const { sessionId, cwd } = currentSession(ctx)
327
+ const execute = async (sid, line) => ctx?.remote?.commands?.execute?.(sid, line, [])
328
+ writeStore({ open: true, conflicts: found, cwd: cwd ?? '', sessionId: sessionId ?? '', execute, afterApply: refresh })
329
+ }, [state, refresh])
330
+
254
331
  const conflicts = state.phase === 'ready' ? state.data?.conflicts ?? [] : []
255
332
 
256
333
  const suggestion = useMemo(() => {
@@ -320,8 +397,15 @@ window.__ModuleLoader__.load({
320
397
  }
321
398
  }
322
399
 
400
+ // 安装:无冲突直接装;有冲突**直接弹窗**(等价于"install 后自动弹 UI")
401
+ const install = useCallback(async () => {
402
+ const result = await detectThenInstall(Panel.ctx, refresh)
403
+ if (!result.started && result.error) setState({ phase: 'error', message: result.error })
404
+ }, [refresh])
405
+
323
406
  children.push(
324
- h('div', { key: 'actions', style: { marginTop: 10, display: 'flex', gap: 8 } },
407
+ h('div', { key: 'actions', style: { marginTop: 10, display: 'flex', gap: 8, flexWrap: 'wrap' } },
408
+ h(LinkButton, { onClick: () => void install() }, '安装到工作区'),
325
409
  h(LinkButton, { onClick: () => void refresh() }, '重新检测'),
326
410
  h(LinkButton, { onClick: () => void copy('/atp install') }, copied === '/atp install' ? '已复制 ✓' : '复制 /atp install')),
327
411
  )
@@ -343,6 +427,15 @@ window.__ModuleLoader__.load({
343
427
  label: () => '协作规程',
344
428
  }, () => h(Panel, null)))
345
429
 
430
+ // 首页 chip 行入口:和「音乐制作 / 标准模式」并排
431
+ HeroEntry.ctx = ctx
432
+ ctx.slots.inject('conversation.hero.options', () => ctx.slots.register({
433
+ name: 'conversation.hero.options',
434
+ id: 'agent-team-playbook.entry',
435
+ order: 20,
436
+ label: () => '协作规程',
437
+ }, () => h(HeroEntry, null)))
438
+
346
439
  // 冲突处理弹窗:常驻挂载,关闭时渲染 null
347
440
  ctx.slots.inject('shell.overlay', () => ctx.slots.register({
348
441
  name: 'shell.overlay',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agent-team-playbook",
3
- "version": "1.28.0",
3
+ "version": "1.30.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",