dsh-chief 1.4.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/chief-view.js CHANGED
@@ -25,6 +25,7 @@ import {
25
25
  beginChiefActiveWork,
26
26
  endChiefActiveWork,
27
27
  getChiefActiveWork,
28
+ summarizeLlmLedger,
28
29
  } from './chief-state.js'
29
30
  import { listChiefModels, callChiefLlm } from './chief-models.js'
30
31
  import { collectClusterPeerProgress, listPeerDirectory } from './chief-network.js'
@@ -263,28 +264,30 @@ function buildNarrativeInput({ board, facts, cluster, targets, peerProgress = []
263
264
  const dGlob = Array.isArray(archiveDigest.deskGlobalItems) ? archiveDigest.deskGlobalItems : []
264
265
  const dFlip = Array.isArray(archiveDigest.deskFlippedItems) ? archiveDigest.deskFlippedItems : []
265
266
  const mGlob = Array.isArray(archiveDigest.mountedGlobalItems) ? archiveDigest.mountedGlobalItems : []
266
- const sw = archiveDigest.sealedWatch || {}
267
+ const sAll = Array.isArray(archiveDigest.sessionItems) ? archiveDigest.sessionItems : []
268
+ const gHooks = Array.isArray(archiveDigest.globalHookIndex) ? archiveDigest.globalHookIndex : []
269
+ const recentWatch = Array.isArray(archiveDigest.recentlyUnpinnedWatch) ? archiveDigest.recentlyUnpinnedWatch : []
267
270
  const deskAll = [
268
271
  ...dSess.map(it => `[桌面·本局(主可见)] 《${clamp(it.title, 40)}》:${clamp(it.summary || it.body, 140)}`),
269
272
  ...dGlob.map(it => `[桌面·全局(主可见)] 《${clamp(it.title, 40)}》:${clamp(it.summary || it.body, 140)}`),
270
- ...dFlip.map(it => `[桌面·沉淀(主可见)] 《${clamp(it.title, 40)}》:${clamp(it.summary || it.rawBody, 140)}`),
273
+ ...dFlip.map(it => `[桌面·冷藏已翻牌(主可见)] 《${clamp(it.title, 40)}》:${clamp(it.summary || it.rawBody, 140)}`),
271
274
  ]
272
275
  if (deskAll.length > 0) {
273
- lines.push('', '【当前摆上桌面备选(重点强调,主对话与参谋长共同可见)】', ...deskAll.slice(0, 8).map(x => '- ' + x))
276
+ lines.push('', '【当前认知桌面置顶(主对话与参谋长共同可见)】', ...deskAll.slice(0, 6).map(x => '- ' + x))
274
277
  }
275
278
  if (mGlob.length > 0) {
276
- lines.push('', '【参谋长单独参阅中的全局档案(主对话不可见)】')
279
+ lines.push('', '【参谋长已拉阅的全局档案(主对话不可见)】')
277
280
  for (const it of mGlob.slice(0, 5)) {
278
281
  lines.push(`- [全局参阅] 《${clamp(it.title, 40)}》:${clamp(it.summary || it.body, 120)}`)
279
282
  }
280
283
  }
281
- const sealedLines = [
282
- ...((sw.sessionSealed || []).slice(0, 4).map(it => `- [本局封存·仅参谋关注] 《${clamp(it.title, 36)}》:${clamp(it.summary, 90)}`)),
283
- ...((sw.globalSealed || []).slice(0, 4).map(it => `- [全局封存·仅参谋关注] 《${clamp(it.title, 36)}》:${clamp(it.summary, 90)}`)),
284
- ...((sw.precipSealed || []).slice(0, 3).map(it => `- [沉淀封存·仅参谋关注] 《${clamp(it.title, 36)}》:${clamp(it.summary, 90)}`)),
284
+ const vaultIndexLines = [
285
+ ...sAll.filter(it => !it.takenOut).slice(0, 6).map(it => `- [本局档案·参谋随时可读] 《${clamp(it.title, 36)}》${it.hasHook ? '🪝[' + (it.hookKeywords || []).slice(0, 3).join('·') + ']' : '(待织钩)'}:${clamp(it.summary, 90)}`),
286
+ ...gHooks.slice(0, 5).map(it => `- [全局钩子·参谋见钩可拉] 《${clamp(it.title, 36)}》🪝[${(it.hookKeywords || []).slice(0, 3).join('·')}] ${clamp(it.hookCue, 60)}`),
287
+ ...recentWatch.slice(0, 3).map(w => `- [近期撤下桌面·待观察] 《${clamp(w.title, 36)}》`),
285
288
  ]
286
- if (sealedLines.length > 0) {
287
- lines.push('', '【参谋长后台守望的三库封存索引(主对话上下文零注入)】', ...sealedLines)
289
+ if (vaultIndexLines.length > 0) {
290
+ lines.push('', '【参谋长后台档案柜与钩子索引(未置顶桌面,主对话不注入)】', ...vaultIndexLines)
288
291
  }
289
292
  }
290
293
 
@@ -370,7 +373,7 @@ export async function getChiefView(deps, sessionId, { regenerate = false, autoSu
370
373
  const view = clusterView(state, rootId)
371
374
  const modelsInfo = await listChiefModels(deps, false, rootId)
372
375
  const effCfgBefore = resolveWorkspaceConfig(state, rootId)
373
- const paceMode = effCfgBefore.paceMode || 'manual'
376
+ const runMode = effCfgBefore.runMode || 'off'
374
377
  const isConciseBrief = Boolean(effCfgBefore.tacticalModes && effCfgBefore.tacticalModes.conciseBrief)
375
378
  const currentSig = view.clusterSig || computeClusterSig(directory.cluster)
376
379
  const peerProgress = directory.cluster.length > 1
@@ -402,7 +405,7 @@ export async function getChiefView(deps, sessionId, { regenerate = false, autoSu
402
405
  const isFresh = !rawInput || (hasSaved && view.narrative.hash === inputHash)
403
406
  const cooledForAuto = Date.now() - lastSummaryAt >= AUTO_SUMMARY_COOLDOWN_MS
404
407
  const cooledForChat = Date.now() - lastSummaryAt >= CHAT_OPPORTUNISTIC_SUMMARY_COOLDOWN_MS
405
- const allowBackgroundSummary = paceMode === 'auto' && autoSummarize && !isFresh && cooledForAuto
408
+ const allowBackgroundSummary = runMode === 'managed' && autoSummarize && !isFresh && cooledForAuto
406
409
  const allowChatSummary = Boolean(chatTriggered) && !isFresh && cooledForChat
407
410
 
408
411
  // Opportunistically refresh stale narrative in background after Chief chats (60s debounce),
@@ -417,6 +420,7 @@ export async function getChiefView(deps, sessionId, { regenerate = false, autoSu
417
420
  : NARRATIVE_SYSTEM
418
421
  const res = await callChiefLlm(deps, {
419
422
  sessionId: rootId,
423
+ reasonKind: chatTriggered ? 'chat_summary' : 'auto_summary',
420
424
  system: sysPrompt,
421
425
  prompt: rawInput + (isConciseBrief
422
426
  ? '\n\n请开启【极简战报模式】:分结构列出多个简明短句,不写具体数字参数,精确概括现状:'
@@ -500,8 +504,8 @@ export async function getChiefView(deps, sessionId, { regenerate = false, autoSu
500
504
  !_skipAutoPilotCheck
501
505
  && rootId
502
506
  && rootId !== 'global'
503
- && effectiveConfigBeforeStop.autoPilot
504
- && effectiveConfigBeforeStop.paceMode === 'auto'
507
+ && (effectiveConfigBeforeStop.autoPilot || effectiveConfigBeforeStop.runMode === 'managed')
508
+ && effectiveConfigBeforeStop.runMode === 'managed'
505
509
  && !effectiveConfigBeforeStop.stopped
506
510
  ) {
507
511
  if (idleAutoPilotHook) {
@@ -563,6 +567,8 @@ export async function getChiefView(deps, sessionId, { regenerate = false, autoSu
563
567
  inquiries: (Array.isArray(ownWs.inquiries) ? ownWs.inquiries : []).slice(-12).reverse(),
564
568
  guardWalls: listGuardWalls({ cwd: resolveSessionWorkspaceCwd(deps, rootId) }),
565
569
  activeWork: getChiefActiveWork(rootId),
570
+ llmLedger: summarizeLlmLedger(ownWs.llmLedger, effectiveConfig),
571
+ alertEvents: (Array.isArray(ownWs.alertEvents) ? ownWs.alertEvents : []).slice(-12),
566
572
  auditLog: (Array.isArray(ownWs.auditLog) ? ownWs.auditLog : []).slice(-50).reverse(),
567
573
  }
568
574
  }