dsh-chief 1.5.0 → 1.6.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.
package/digest.js CHANGED
@@ -115,7 +115,10 @@ function planLines(board, limit) {
115
115
  const open = steps.filter(step => !step.done)
116
116
  const shown = open.slice(0, limit)
117
117
  const lines = ['规划 ' + done + '/' + steps.length + (open.length > shown.length ? '(未完成 ' + open.length + ',此处列前 ' + shown.length + ')' : '') + ':']
118
- for (const step of shown) lines.push(' [ ] ' + clamp(step.text, 90))
118
+ for (const step of shown) {
119
+ const idx = steps.indexOf(step) + 1
120
+ lines.push(' [ ] ' + idx + '. (id:' + step.id + ') ' + clamp(step.text, 86))
121
+ }
119
122
  lines.push(
120
123
  ' ↳ 每轮先按顺序读这一段:做完的步 plan.set 标 done;新发现的步补进去;'
121
124
  + '不再做的旧步删掉;需要拆解子代理并行时用 graph.plan 建任务图并用 task.dispatch 派发。',
package/idle-guard.js CHANGED
@@ -121,6 +121,10 @@ const LOOP_REPEAT = 4
121
121
  /** A session's recent calls, capped, so one long turn cannot grow it forever. */
122
122
  const callTrail = new Map()
123
123
 
124
+ /** Per-session mid-turn spin & consecutive tool-error tracker (capped at 64 sessions). */
125
+ const spinState = new Map()
126
+ const MID_TURN_SPIN_COOLDOWN_MS = 15_000
127
+
124
128
  /** Tools whose identical repetition is ordinary, not a stuck loop. */
125
129
  const READ_ONLY_ACTION = /"action"\s*:\s*"(?:snapshot|memory\.ask)"/u
126
130
 
@@ -139,6 +143,47 @@ function hashCall(name, argumentsValue) {
139
143
  return hash.toString(36) + ':' + text.length.toString(36)
140
144
  }
141
145
 
146
+ function fuzzyNormalizeArgs(argumentsValue) {
147
+ let text = String(argumentsValue === undefined || argumentsValue === null ? '' : argumentsValue)
148
+ text = text.replace(/(?:^|\s)(?:\/\/|#)[^\n\r]*/g, '')
149
+ text = text.replace(/\b[0-9a-fA-F]{6,}(?:-[0-9a-fA-F]{4,}){0,4}\b/g, '#HEX#')
150
+ text = text.replace(/\d+(?:\.\d+)?/g, '#')
151
+ return text.replace(/\s+/g, ' ').trim()
152
+ }
153
+
154
+ function getSpinEntry(sessionId, create = true) {
155
+ const id = String(sessionId || '')
156
+ if (!id) return null
157
+ let st = spinState.get(id)
158
+ if (!st && create) {
159
+ st = {
160
+ consecutiveErrors: 0,
161
+ lastErrorTool: '',
162
+ lastErrorPreview: '',
163
+ callsSinceActed: 0,
164
+ lastActedAt: 0,
165
+ }
166
+ spinState.set(id, st)
167
+ if (spinState.size > 64) {
168
+ const oldest = spinState.keys().next().value
169
+ if (oldest !== undefined && oldest !== id) spinState.delete(oldest)
170
+ }
171
+ }
172
+ return st || null
173
+ }
174
+
175
+ function extractToolResultText(data) {
176
+ if (!data || typeof data !== 'object') return typeof data === 'string' ? data : ''
177
+ if (typeof data.error === 'string' && data.error) return data.error
178
+ if (data.error && typeof data.error === 'object' && typeof data.error.message === 'string') return data.error.message
179
+ const raw = data.result ?? data.output ?? data.text ?? data.content ?? ''
180
+ if (typeof raw === 'string') return raw
181
+ if (Array.isArray(raw)) {
182
+ return raw.map(b => (b && typeof b.text === 'string' ? b.text : '')).filter(Boolean).join('\n')
183
+ }
184
+ return ''
185
+ }
186
+
142
187
  export function noteCallTrail(sessionId, name, argumentsValue) {
143
188
  const id = String(sessionId || '')
144
189
  let trail = callTrail.get(id)
@@ -152,16 +197,140 @@ export function noteCallTrail(sessionId, name, argumentsValue) {
152
197
  }
153
198
  trail.push({
154
199
  key: hashCall(name, argumentsValue),
200
+ fuzzyKey: hashCall(name, fuzzyNormalizeArgs(argumentsValue)),
155
201
  name: String(name || ''),
156
202
  readOnly: isReadOnlyCall(name, argumentsValue),
203
+ planWrite: isPlanWrite(name, argumentsValue),
157
204
  preview: String(argumentsValue === undefined || argumentsValue === null ? '' : argumentsValue).slice(0, 120),
158
205
  })
159
206
  if (trail.length > 16) trail.splice(0, trail.length - 16)
207
+ const st = getSpinEntry(id, true)
208
+ if (st) st.callsSinceActed += 1
209
+ }
210
+
211
+ /** Track consecutive failing tool results so mid-turn error thrashing is caught live. */
212
+ export function noteCallResult(sessionId, data = {}) {
213
+ const id = String(sessionId || '')
214
+ if (!id) return
215
+ const st = getSpinEntry(id, true)
216
+ if (!st) return
217
+ const text = extractToolResultText(data)
218
+ const isFailure = Boolean(data && (data.isError === true || data.error))
219
+ || /^\s*(?:Error:|ENOENT\b|EPERM\b|failed\b|Exit code\b)/i.test(text)
220
+ if (isFailure) {
221
+ st.consecutiveErrors += 1
222
+ st.lastErrorTool = String((data && (data.name || data.toolName)) || st.lastErrorTool || 'tool')
223
+ st.lastErrorPreview = String(text || (data && data.message) || '').replace(/\s+/g, ' ').trim().slice(0, 120)
224
+ } else {
225
+ st.consecutiveErrors = 0
226
+ st.lastErrorTool = ''
227
+ st.lastErrorPreview = ''
228
+ }
160
229
  }
161
230
 
162
231
  /** Read-only repeats get a higher bar: re-reading after each edit is normal. */
163
232
  const LOOP_REPEAT_READ = LOOP_REPEAT + 3
164
233
 
234
+ /**
235
+ * Detect live mid-turn spinning across three patterns: exact loop, varying-arg
236
+ * polling loop (`fuzzyKey`), and consecutive failing tool calls (`error-thrash`).
237
+ */
238
+ export function detectMidTurnSpin(sessionId, { strongIntervention = false } = {}) {
239
+ const id = String(sessionId || '')
240
+ if (!id) return null
241
+ const st = getSpinEntry(id, false)
242
+ if (st && st.lastActedAt > 0 && Date.now() - st.lastActedAt < MID_TURN_SPIN_COOLDOWN_MS && st.callsSinceActed < 3) {
243
+ return null
244
+ }
245
+ const trail = callTrail.get(id)
246
+ if (trail && trail.length > 0) {
247
+ const last = trail[trail.length - 1]
248
+ let exactCount = 0
249
+ for (let index = trail.length - 1; index >= 0; index -= 1) {
250
+ if (trail[index].key !== last.key) break
251
+ exactCount += 1
252
+ }
253
+ const exactLimit = last.readOnly ? (strongIntervention ? 6 : LOOP_REPEAT_READ) : (strongIntervention ? 3 : LOOP_REPEAT)
254
+ if (exactCount >= exactLimit) {
255
+ return { kind: 'exact-loop', name: last.name, preview: last.preview, count: exactCount }
256
+ }
257
+ if (!last.planWrite) {
258
+ let fuzzyCount = 0
259
+ for (let index = trail.length - 1; index >= 0; index -= 1) {
260
+ if (trail[index].fuzzyKey !== last.fuzzyKey || trail[index].planWrite) break
261
+ fuzzyCount += 1
262
+ }
263
+ const fuzzyLimit = (strongIntervention ? 4 : 6) + (last.readOnly ? 2 : 0)
264
+ if (fuzzyCount >= fuzzyLimit) {
265
+ return { kind: 'fuzzy-loop', name: last.name, preview: last.preview, count: fuzzyCount }
266
+ }
267
+ }
268
+ }
269
+ const errLimit = strongIntervention ? 4 : 5
270
+ if (st && st.consecutiveErrors >= errLimit) {
271
+ return {
272
+ kind: 'error-thrash',
273
+ name: st.lastErrorTool || 'tool',
274
+ preview: st.lastErrorPreview || '',
275
+ count: st.consecutiveErrors,
276
+ }
277
+ }
278
+ return null
279
+ }
280
+
281
+ /** Record mid-turn intervention cooldown and trim tail repeat streak to prevent double firing. */
282
+ export function markMidTurnSpinActed(sessionId) {
283
+ const id = String(sessionId || '')
284
+ if (!id) return
285
+ const st = getSpinEntry(id, true)
286
+ if (st) {
287
+ st.lastActedAt = Date.now()
288
+ st.callsSinceActed = 0
289
+ st.consecutiveErrors = 0
290
+ }
291
+ const trail = callTrail.get(id)
292
+ if (trail && trail.length > 1) trail.splice(0, trail.length - 1)
293
+ }
294
+
295
+ /** Reset per-turn spin counters on turn/start while avoiding false positives across turns. */
296
+ export function clearMidTurnSpin(sessionId) {
297
+ const id = String(sessionId || '')
298
+ if (!id) {
299
+ spinState.clear()
300
+ callTrail.clear()
301
+ return
302
+ }
303
+ spinState.delete(id)
304
+ callTrail.delete(id)
305
+ }
306
+
307
+ /** Build steer notice for a live running agent spinning mid-turn. */
308
+ export function buildMidTurnSpinNotice(spin, board) {
309
+ const s = spin && typeof spin === 'object' ? spin : { kind: 'exact-loop', name: '?', preview: '', count: 0 }
310
+ const obj = String((board && board.objective) || '').trim().slice(0, 120)
311
+ const lines = ['[参谋看板 · 运行中空转急刹]']
312
+ if (s.kind === 'error-thrash') {
313
+ lines.push(
314
+ `检测到本轮工具已连续报错 ${s.count} 次(最近一次:${s.name}${s.preview ? ' -> ' + s.preview : ''}),继续硬撞不会成功。`,
315
+ )
316
+ } else if (s.kind === 'fuzzy-loop') {
317
+ lines.push(
318
+ `检测到你连续 ${s.count} 次以高度相似参数反复轮询/重试 ${s.name}${s.preview ? ' (' + s.preview + ')' : ''},疑似原地轮询空转。`,
319
+ )
320
+ } else {
321
+ lines.push(
322
+ `检测到同一调用连续重复 ${s.count} 次(${s.name}${s.preview ? ' ' + s.preview : ''}),没有产生新推进。`,
323
+ )
324
+ }
325
+ if (obj) lines.push(`当前锁定核心目标:${obj}`)
326
+ lines.push(
327
+ '请立刻停止同类重复尝试,马上二选一:',
328
+ '1) 读取真实错误/服务状态并切换完全不同的修复路径或参数,同时用 chief_board 更新断点进度;',
329
+ '2) 若确认当前环境或依赖已卡死无法突破,立即停止重试,用 chief_board cursor.set(blocked) 标明卡点,并直接汇报阻塞原因请求人工/参谋处理。',
330
+ )
331
+ return buildMessage(lines.join('\n'))
332
+ }
333
+
165
334
  /**
166
335
  * The tail of this Session's calls when the same (name, arguments) pair has
167
336
  * just repeated. Returns null for anything less: the same tool with different
@@ -309,7 +478,7 @@ export function turnHadToolCall(sessionId, turn, session) {
309
478
  * reader can use, which is exactly what the guard exists for.
310
479
  */
311
480
  export function readAnswer(session, turn) {
312
- const result = { hasMessage: false, chars: 0, thoughtChars: 0 }
481
+ const result = { hasMessage: false, chars: 0, thoughtChars: 0, lastText: '' }
313
482
  if (!session || typeof session.snapshotEvents !== 'function') return result
314
483
  try {
315
484
  const events = session.snapshotEvents()
@@ -321,8 +490,13 @@ export function readAnswer(session, turn) {
321
490
  if (message && Array.isArray(message.content)) {
322
491
  for (const block of message.content) {
323
492
  if (!block || typeof block.text !== 'string') continue
324
- if (block.type === 'text') result.chars += block.text.length
325
- else if (block.type === 'reasoning') result.thoughtChars += block.text.length
493
+ if (block.type === 'text') {
494
+ result.chars += block.text.length
495
+ const trimmed = block.text.trim()
496
+ if (trimmed) result.lastText = trimmed.slice(0, 400)
497
+ } else if (block.type === 'reasoning') {
498
+ result.thoughtChars += block.text.length
499
+ }
326
500
  }
327
501
  }
328
502
  }
@@ -330,6 +504,38 @@ export function readAnswer(session, turn) {
330
504
  return result
331
505
  }
332
506
 
507
+ const PREMATURE_ASK_OR_STOP_RE = /(?:请确认|请选择|是否继续|需要您|您看|请指示|请拍板|全部完成|已交付完毕|已完成交付|本轮无进展|卡住了,因为|已暂停待命|优雅退出|收工待命)/
508
+ const COMPLETED_ACTION_PHRASE_RE = /(?:(?:已|已经|刚|刚刚|刚才)?(?:重启|拉起|补跑|续跑|写入?|跑)(?:完成|完毕|好了?|了|成功)|(?:重启|补跑|拉起)前|已(?:重启|拉起|补跑|续跑|写完|完成)|无需(?:重启|补跑|继续))/g
509
+ const PREMATURE_PROMISE_CUE_RE = /(?:重启|拉起|补跑|续跑|继续跑|继续执行|开始跑|开始写|写[^\n。]{0,20}驱动|接下来(?:我|先|去|开始|将)|下面(?:我|先|开始)|马上(?:去|执行|重启|补跑|修复)|这就去|现在(?:去|开始|重启|补跑))/
510
+
511
+ /**
512
+ * Detect short wrap-up answers that merely promise the next concrete action
513
+ * (e.g. "重启 ComfyUI 补跑。" / "写 round-5 驱动。") while stopping the turn.
514
+ */
515
+ export function detectPrematurePromiseText(text) {
516
+ const clean = String(text || '').replace(/\s+/g, ' ').trim()
517
+ if (!clean || clean.length > 320) return ''
518
+ if (/[??]\s*$/.test(clean) || PREMATURE_ASK_OR_STOP_RE.test(clean)) return ''
519
+ const segs = clean.split(/[。!?\n]+/).map(s => s.trim()).filter(Boolean)
520
+ const tailSegs = segs.slice(-2)
521
+ for (let idx = tailSegs.length - 1; idx >= 0; idx -= 1) {
522
+ const seg = tailSegs[idx]
523
+ const pendingPart = seg.replace(COMPLETED_ACTION_PHRASE_RE, ' ').trim()
524
+ if (PREMATURE_PROMISE_CUE_RE.test(pendingPart)) {
525
+ return seg.slice(0, 120)
526
+ }
527
+ }
528
+ return ''
529
+ }
530
+
531
+ function resolveEffectiveMaxPerSession(limits, { strongIntervention = false, maxInterventionTurns = 0 } = {}) {
532
+ const baseMax = limits.maxPerSession
533
+ if (!strongIntervention || baseMax === 0) return baseMax
534
+ const n = Number(maxInterventionTurns)
535
+ if (n === 0) return Math.max(baseMax, 16)
536
+ return Math.max(baseMax, Math.min(20, Math.round(n || baseMax)))
537
+ }
538
+
333
539
  /** Open work on the board: unfinished plan steps and tasks that are not done. */
334
540
  export function openWork(board) {
335
541
  const steps = Array.isArray(board && board.plan) ? board.plan.filter(step => !step.done) : []
@@ -341,7 +547,7 @@ export function openWork(board) {
341
547
  * Decide whether this close is premature. Every condition must hold, so the
342
548
  * guard stays out of ordinary conversation.
343
549
  */
344
- export function shouldGuard({ board, session, sessionId, turn, settings }) {
550
+ export function shouldGuard({ board, session, sessionId, turn, settings, strongIntervention = false, maxInterventionTurns = 0 }) {
345
551
  const flags = settings || {}
346
552
  if (flags.guardIdle === false) return null
347
553
  // One nudge per turn: steering re-opens the same turn, so a second close in
@@ -350,7 +556,8 @@ export function shouldGuard({ board, session, sessionId, turn, settings }) {
350
556
 
351
557
  const used = interventions.get(String(sessionId)) || 0
352
558
  const limits = guardLimits(flags)
353
- if (used >= limits.maxPerSession) return null
559
+ const effectiveMax = resolveEffectiveMaxPerSession(limits, { strongIntervention, maxInterventionTurns })
560
+ if (used >= effectiveMax) return null
354
561
 
355
562
  const answer = readAnswer(session, turn)
356
563
  // No committed answer means the turn produced nothing for the reader yet;
@@ -378,6 +585,13 @@ export function shouldGuard({ board, session, sessionId, turn, settings }) {
378
585
  return { kind: 'no-goal', work, answer }
379
586
  }
380
587
 
588
+ // Shape 6, premature-promise: closed turn right after verbally promising the
589
+ // next concrete execution action ("重启 XX 补跑 / 写驱动"), even if it updated the board.
590
+ if (work.total > 0 || Boolean(objective)) {
591
+ const promiseCue = detectPrematurePromiseText(answer.lastText)
592
+ if (promiseCue) return { kind: 'premature-promise', work, answer, promiseCue }
593
+ }
594
+
381
595
  // Shape 3, no-plan: the board never held a plan or task graph, so nothing can
382
596
  // be "open". A turn that actually did work leaves the reader with no record
383
597
  // of what it was doing or what comes next.
@@ -414,7 +628,7 @@ export function shouldGuard({ board, session, sessionId, turn, settings }) {
414
628
  * busy turn "you did not call any tool" would be a lie the model can disprove
415
629
  * from its own transcript, which is the fastest way to lose its attention.
416
630
  */
417
- export function buildNotice({ kind, work, answer, loop, board }) {
631
+ export function buildNotice({ kind, work, answer, loop, promiseCue, board }) {
418
632
  const steps = work.steps.slice(0, 3).map(step => '· ' + String(step.text).slice(0, 80))
419
633
  const tasks = work.tasks.slice(0, 3).map(task => '· ' + String(task.title).slice(0, 80))
420
634
  const counting = '(' + work.steps.length + ' 个规划步骤 / ' + work.tasks.length + ' 条待办)'
@@ -433,6 +647,10 @@ export function buildNotice({ kind, work, answer, loop, board }) {
433
647
  + ' 项 ' + counting + ',却没有一句能说明这些动作是为了什么。'
434
648
  + '没有目标,步骤列表接着改也只是原地打转。',
435
649
  )
650
+ } else if (kind === 'premature-promise') {
651
+ lines.push(
652
+ '你刚才只用文字预告了下一步动作(『' + String(promiseCue || '').slice(0, 80) + '』),却直接结束回合而未调用工具执行,请立刻调用工具落实并验证。',
653
+ )
436
654
  } else if (kind === 'no-plan') {
437
655
  lines.push(
438
656
  '这个会话还没写过规划:这轮动手了,参谋看板上却连一条规划都没有(记忆里也没有下一步)。'
@@ -467,6 +685,12 @@ export function buildNotice({ kind, work, answer, loop, board }) {
467
685
  '2) 目标写完后,回答「目标有没有真的前进」,没前进就明说没前进、卡在哪;',
468
686
  '3) 如果这活本来就是一串可勾的步骤、不需要持续目标,用 mode.set 回到 plan,别让空目标一直挂着。',
469
687
  )
688
+ } else if (kind === 'premature-promise') {
689
+ lines.push(
690
+ '禁止只做口头预告就停手交卷。现在立刻落实:',
691
+ '1) 立即调用对应工具执行你刚才提到的操作(重启服务 / 补跑脚本 / 写入文件 / 验证结果),',
692
+ '2) 执行完毕后更新 chief_board 状态并汇报可核验证据;若确实遇外部阻塞必须由人类处理,请明确写「卡住了,因为 …」并标记 cursor.set(blocked)。',
693
+ )
470
694
  } else if (kind === 'no-plan') {
471
695
  lines.push(
472
696
  '不要就这样结束。下一步至少做一件,然后才收工:',
@@ -530,7 +754,8 @@ export function clearInterventions(sessionId) {
530
754
  }
531
755
 
532
756
  /** Whether this Session still has interventions left (for reporting). */
533
- export function remainingInterventions(sessionId, settings) {
757
+ export function remainingInterventions(sessionId, settings, opts = {}) {
534
758
  const limits = guardLimits(settings)
535
- return Math.max(0, limits.maxPerSession - (interventions.get(String(sessionId || '')) || 0))
759
+ const max = resolveEffectiveMaxPerSession(limits, opts)
760
+ return Math.max(0, max - (interventions.get(String(sessionId || '')) || 0))
536
761
  }
package/locale/en.json CHANGED
@@ -2,5 +2,76 @@
2
2
  "meta": {
3
3
  "title": "DSH Chief",
4
4
  "description": "Let AI manage AI — it minds the flow itself and stops a runaway before it costs you. No screen-sitting, no repeated confirmations; it keeps working while you are away, and asks before touching your workspace."
5
+ },
6
+ "ui": {
7
+ "brandName": "DSH Chief",
8
+ "tabs": {
9
+ "chief": "Chief",
10
+ "tasks": "Tasks",
11
+ "peers": "Peers",
12
+ "archive": "Archives",
13
+ "boundaries": "Guards"
14
+ },
15
+ "runModes": {
16
+ "off": "⏸ Off",
17
+ "patrol": "🛡 Patrol",
18
+ "managed": "🤖 Managed"
19
+ },
20
+ "perms": {
21
+ "advisor": "L0 · Advisor",
22
+ "assistant": "L1 · Assistant",
23
+ "strategist": "L2 · Strategist",
24
+ "chief": "L3 · Chief"
25
+ },
26
+ "presets": {
27
+ "title": "🚀 One-Click Scenario Presets",
28
+ "observer": {
29
+ "title": "👁 Read-Only Observer",
30
+ "tag": "L0 · ⏸ Off",
31
+ "desc": "Zero background burn or edits; read-only digest & low-effort summaries."
32
+ },
33
+ "collab": {
34
+ "title": "🤝 Daily Co-Pilot",
35
+ "tag": "L2 · 🛡 Patrol",
36
+ "desc": "0 idle cost; wakes only on errors/walls with per-action approval popups."
37
+ },
38
+ "away": {
39
+ "title": "🚀 Away Managed",
40
+ "tag": "L3 · 🤖 Managed",
41
+ "desc": "Continuous supervision, 80% auto-compact, 30-call/300K budget cap & alerts."
42
+ }
43
+ },
44
+ "notify": {
45
+ "title": "🔔 Away Alerts & Gentle Chime",
46
+ "desktopToggle": "Desktop notifications at key milestones",
47
+ "soundToggle": "Gentle chime sound (off by default)",
48
+ "testBtn": "Test alert",
49
+ "permGranted": "Permission granted",
50
+ "permDefault": "Click to authorize",
51
+ "permDenied": "Blocked in browser",
52
+ "permUnsupported": "In-panel toast alerts"
53
+ },
54
+ "ledger": {
55
+ "title": "📊 Chief LLM Ledger & Hard Budget Cap",
56
+ "totalCalls": "Total calls",
57
+ "totalTokens": "Total tokens",
58
+ "catChat": "Q&A",
59
+ "catReview": "Patrol",
60
+ "catDream": "Dream Roam",
61
+ "managedCallsCap": "Managed call cap / run",
62
+ "managedTokensCap": "Managed token cap / run",
63
+ "resetManaged": "Reset run counter",
64
+ "tripped": "🛑 Hard budget cap reached — auto-stopped to protect tokens"
65
+ },
66
+ "report": {
67
+ "exportMd": "📄 Export Report (.md)",
68
+ "copyMd": "📋 Copy Markdown Report"
69
+ },
70
+ "lang": {
71
+ "title": "🌐 Interface Language / 界面语言",
72
+ "auto": "Auto",
73
+ "zh": "简体中文",
74
+ "en": "English"
75
+ }
5
76
  }
6
77
  }
package/locale/zh.json CHANGED
@@ -2,5 +2,76 @@
2
2
  "meta": {
3
3
  "title": "DSH 参谋长",
4
4
  "description": "AI 管 AI,你当甩手掌柜 —— 它自己盯流程,跑崩了先拦住。不用守着屏幕,也不用反复确认;你不在的时候它照样跑,越权改工作区会先问你。"
5
+ },
6
+ "ui": {
7
+ "brandName": "DSH 参谋长",
8
+ "tabs": {
9
+ "chief": "参谋",
10
+ "tasks": "任务",
11
+ "peers": "协同",
12
+ "archive": "档案",
13
+ "boundaries": "边界"
14
+ },
15
+ "runModes": {
16
+ "off": "⏸ 关停",
17
+ "patrol": "🛡 巡检",
18
+ "managed": "🤖 托管"
19
+ },
20
+ "perms": {
21
+ "advisor": "L0 · 顾问模式",
22
+ "assistant": "L1 · 助手模式",
23
+ "strategist": "L2 · 参谋模式",
24
+ "chief": "L3 · 参谋长模式"
25
+ },
26
+ "presets": {
27
+ "title": "🚀 一键开箱场景预设",
28
+ "observer": {
29
+ "title": "👁 只读旁观",
30
+ "tag": "L0 · ⏸ 关停",
31
+ "desc": "零打扰零介入,低强度总结摘要,纯看护不改文件与工作流。"
32
+ },
33
+ "collab": {
34
+ "title": "🤝 日常协作",
35
+ "tag": "L2 · 🛡 巡检",
36
+ "desc": "平时 0 后台消耗,报错/撞墙自动唤醒,重要写改逐项弹窗审批。"
37
+ },
38
+ "away": {
39
+ "title": "🚀 离桌托管",
40
+ "tag": "L3 · 🤖 托管",
41
+ "desc": "持续督导 + 80% 自动压缩 + 30次/300K 硬预算熔断 + 关键节点通知。"
42
+ }
43
+ },
44
+ "notify": {
45
+ "title": "🔔 离桌通知与轻提示音",
46
+ "desktopToggle": "关键节点桌面通知",
47
+ "soundToggle": "轻柔提示音(默认关)",
48
+ "testBtn": "试响 / 测试提醒",
49
+ "permGranted": "已授权桌面通知",
50
+ "permDefault": "待点击授权",
51
+ "permDenied": "浏览器已拦截通知",
52
+ "permUnsupported": "面板 Toast 提醒"
53
+ },
54
+ "ledger": {
55
+ "title": "📊 参谋长 LLM 账本与托管硬预算",
56
+ "totalCalls": "累计调用",
57
+ "totalTokens": "累计 Token",
58
+ "catChat": "问答",
59
+ "catReview": "巡检",
60
+ "catDream": "梦境漫游",
61
+ "managedCallsCap": "单次托管次数上限",
62
+ "managedTokensCap": "单次托管 Token 上限",
63
+ "resetManaged": "重置本轮托管计数",
64
+ "tripped": "🛑 已触及硬预算上限并自动熔断停机"
65
+ },
66
+ "report": {
67
+ "exportMd": "📄 导出复盘战报 (.md)",
68
+ "copyMd": "📋 复制战报 Markdown"
69
+ },
70
+ "lang": {
71
+ "title": "🌐 界面语言 / Language",
72
+ "auto": "自动 Auto",
73
+ "zh": "简体中文",
74
+ "en": "English"
75
+ }
5
76
  }
6
77
  }
package/model-tools.js CHANGED
@@ -105,7 +105,8 @@ export function createModelTools(deps) {
105
105
  ],
106
106
  description:
107
107
  'Board operation (MUST be called whenever recording tasks/status/conclusions or relaying messages; plain text alone does NOT update the board or notify peers). '
108
- + 'Use "graph.plan" (or "task.batch") to plan a hierarchical/DAG task graph in one call (supports parentId, blockedBy, owner/subagent, intent, evidence). '
108
+ + 'Use "graph.plan" (or "task.batch") to plan a hierarchical/DAG task graph in one call (supports parentId, blockedBy, planStepId, targetPlanStepId, owner/subagent, intent, evidence). '
109
+ + 'For multi-step workflows, define ordered steps via "plan.set" first and bind tasks/subagents with "planStepId" (and optional "targetPlanStepId") so the workflow topology displays step-by-step progress and subagent return arrows. '
109
110
  + 'Use "task.dispatch" to spawn or message a subagent, "team.steer" to steer a subagent, and "mail.send" to relay messages across lead/subagents/sessions. '
110
111
  + 'Use "inquiry.reply" (inquiryId, text) whenever you see a priority [INQUIRY #id] from DSH Chief — answer accurately and continue your current work immediately without stopping. '
111
112
  + 'Use "chief.request" (subject, text) to ask DSH Chief for cross-session coordination, permission elevation, to report exploration & planning results, or when blocked by an insurmountable guard wall that cannot be bypassed safely. '
@@ -125,6 +126,8 @@ export function createModelTools(deps) {
125
126
  id: { type: 'string', description: 'Task id or temporary symbolic key (e.g. "t1", "api-design") referenced by parentId or blockedBy.' },
126
127
  title: { type: 'string', description: 'Short task title.' },
127
128
  parentId: { type: 'string', description: 'Parent task id/key for hierarchical decomposition.' },
129
+ planStepId: { type: 'string', description: 'Optional plan step id (from board.plan) this task or subagent branch belongs to; auto-binds to the current active step if omitted.' },
130
+ targetPlanStepId: { type: 'string', description: 'Optional plan step id that this task/subagent reports back to upon completion (defaults to planStepId; set to a later step for cross-step handoff).' },
128
131
  blockedBy: { type: 'array', items: { type: 'string' }, description: 'Upstream task ids/keys that must finish (done) before this task unlocks.' },
129
132
  owner: { type: 'string', description: 'Assigned subagent name (e.g. "researcher", "coder", "verifier") or owner.' },
130
133
  subagent: { type: 'string', description: 'Subagent name to bind to this task.' },
@@ -227,6 +230,8 @@ export function createModelTools(deps) {
227
230
  taskId: { type: 'string', description: 'task id for task.update / task.claim / task.release / task.remove / task.verify / task.dispatch (alias for id).' },
228
231
  target: { type: 'string', description: 'task.add / task.update / task.dispatch: who this task is assigned to — visible in tree view as owner label.' },
229
232
  parentId: { type: 'string', description: 'task.add / task.update: parent task id for tree hierarchy — renders the child indented under its parent.' },
233
+ planStepId: { type: 'string', description: 'task.add / task.update / task.dispatch: optional plan step id (from board.plan) this task or subagent belongs to; auto-binds to the current active step if omitted.' },
234
+ targetPlanStepId: { type: 'string', description: 'task.add / task.update / task.dispatch: optional plan step id that this task/subagent reports back to upon completion (defaults to planStepId).' },
230
235
  status: { type: 'string', enum: STATUSES, description: 'Task status.' },
231
236
  priority: { type: 'string', enum: PRIORITIES, description: 'Task priority.' },
232
237
  field: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-chief",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "icon": "icon.svg",
5
5
  "type": "module",
6
6
  "description": "Right-sidebar supervisor for DeepSeek Harness (DSH): prevents context-compaction amnesia, monitors subagent DAGs, gates file edits and shell commands behind per-action approvals, breaks runaway loops, and hands off long sessions without bloating prompt tokens.",
@@ -55,7 +55,9 @@
55
55
  "thinking-effort",
56
56
  "dream-roam",
57
57
  "认知桌面",
58
- "物理驻墙"
58
+ "物理驻墙",
59
+ "workflow-topology",
60
+ "bilingual"
59
61
  ],
60
62
  "engines": {
61
63
  "node": ">=22.13.0",
@@ -66,8 +68,8 @@
66
68
  "build:client": "node ./scripts/build-client.mjs",
67
69
  "check:client": "node ./scripts/build-client.mjs --check",
68
70
  "check:syntax": "node -e \"const fs=require('fs'),path=require('path'),cp=require('child_process');const walk=d=>{for(const e of fs.readdirSync(d,{withFileTypes:true})){const p=path.join(d,e.name);if(e.isDirectory()&&(e.name==='safety'||e.name==='src'||e.name==='client'))walk(p);else if(e.isFile()&&e.name.endsWith('.js'))cp.execFileSync(process.execPath,['--check',p]);}};walk('.');\"",
69
- "test:ci": "npm run check:client && npm run check:syntax && node ./tests/verify-v130-release-gate.mjs && node ./tests/verify-v140-safety-gate.mjs && node ./tests/verify-v140-collab-gate.mjs && node ./tests/verify-v150-final-gate.mjs",
70
- "test": "node ./tests/verify-v130-release-gate.mjs && node ./tests/verify-v140-safety-gate.mjs && node ./tests/verify-v140-collab-gate.mjs && node ./tests/verify-v150-final-gate.mjs && node -e \"const fs=require('fs'),path=require('path'),cp=require('child_process');if(fs.existsSync('../tools')){for(const s of ['verify-chief-facade-split.mjs','verify-index-modular-split.mjs','verify-archives-modular-split.mjs','verify-client-modular-build.mjs','verify-v121-permissions-and-ui.mjs','verify-compaction-and-blank-chat.mjs','check-action-surface.mjs','verify-v130-four-chains.mjs']){cp.execFileSync(process.execPath,[path.resolve('..','tools',s)],{stdio:'inherit'});}}\""
71
+ "test:ci": "npm run check:client && npm run check:syntax && node ./tests/verify-v130-release-gate.mjs && node ./tests/verify-v140-safety-gate.mjs && node ./tests/verify-v140-collab-gate.mjs && node ./tests/verify-v150-final-gate.mjs && node ./tests/verify-v160-flow-gate.mjs",
72
+ "test": "node ./tests/verify-v130-release-gate.mjs && node ./tests/verify-v140-safety-gate.mjs && node ./tests/verify-v140-collab-gate.mjs && node ./tests/verify-v150-final-gate.mjs && node ./tests/verify-v160-flow-gate.mjs && node -e \"const fs=require('fs'),path=require('path'),cp=require('child_process');if(fs.existsSync('../tools')){for(const s of ['verify-chief-facade-split.mjs','verify-index-modular-split.mjs','verify-archives-modular-split.mjs','verify-client-modular-build.mjs','verify-v121-permissions-and-ui.mjs','verify-compaction-and-blank-chat.mjs','check-action-surface.mjs','verify-v130-four-chains.mjs']){cp.execFileSync(process.execPath,[path.resolve('..','tools',s)],{stdio:'inherit'});}}\""
71
73
  },
72
74
  "exports": {
73
75
  ".": "./index.js",