dsh-chief 1.0.0 → 1.2.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/CHANGELOG.md +72 -0
- package/README.en.md +113 -64
- package/README.md +124 -89
- package/archives.js +1999 -165
- package/auto-continue.js +627 -0
- package/chief-executor.js +861 -0
- package/chief.js +4751 -475
- package/client.js +12015 -6611
- package/digest.js +67 -21
- package/handoff.js +3 -3
- package/index.js +1780 -138
- package/package.json +7 -3
package/digest.js
CHANGED
|
@@ -43,7 +43,7 @@ function boundsLines(board) {
|
|
|
43
43
|
if (!forbidden.length && !allowed.length && !notes.length) return []
|
|
44
44
|
const lines = ['⚖️ 当前生效边界(📌=全局定住跨任务铁律,其余为本任务边界;全体主子代理必须严守):']
|
|
45
45
|
if (forbidden.length) lines.push(' 🚫 禁止红线: ' + forbidden.slice(0, 6).map(s => fmtItem('forbidden', s)).join(' ; '))
|
|
46
|
-
if (allowed.length) lines.push(' ✅
|
|
46
|
+
if (allowed.length) lines.push(' ✅ 必做事项: ' + allowed.slice(0, 5).map(s => fmtItem('allowed', s)).join(' ; '))
|
|
47
47
|
if (notes.length) lines.push(' 💡 边界注意: ' + notes.slice(0, 4).map(s => fmtItem('notes', s)).join(' ; '))
|
|
48
48
|
return lines
|
|
49
49
|
}
|
|
@@ -305,28 +305,55 @@ function cursorLines(board) {
|
|
|
305
305
|
return lines
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
+
function linkedPeersLines(extras, limit = 4) {
|
|
309
|
+
const peers = extras && Array.isArray(extras.linkedPeersProgress) ? extras.linkedPeersProgress : []
|
|
310
|
+
if (!peers.length) return []
|
|
311
|
+
const shown = peers.slice(0, limit)
|
|
312
|
+
const lines = ['🌐 协同网络共享进度(当前联动 ' + peers.length + ' 个主对话 · 退出协同后自动清零):']
|
|
313
|
+
for (const p of shown) {
|
|
314
|
+
const label = clamp(p.name || ownerName(p.rootId), 26)
|
|
315
|
+
const obj = p.objective ? '目标=' + clamp(p.objective, 52) : '暂无总目标'
|
|
316
|
+
const counts = '任务 ' + (Number(p.doneCount) || 0) + '完/' + (Number(p.doingCount) || 0) + '做/' + (Number(p.blockedCount) || 0) + '阻'
|
|
317
|
+
const cur = p.cursorStep ? ' · 断点=' + clamp(p.cursorStep, 36) : ''
|
|
318
|
+
lines.push(' · [' + label + '] ' + obj + ' | ' + counts + cur)
|
|
319
|
+
}
|
|
320
|
+
if (peers.length > shown.length) {
|
|
321
|
+
lines.push(' …另有 ' + (peers.length - shown.length) + ' 个联动对话')
|
|
322
|
+
}
|
|
323
|
+
return lines
|
|
324
|
+
}
|
|
325
|
+
|
|
308
326
|
function takenOutArchiveLines(extras, limit, budget) {
|
|
309
327
|
const taken = extras && Array.isArray(extras.takenOutArchives) ? extras.takenOutArchives : []
|
|
310
|
-
|
|
311
|
-
if (!taken.length) return []
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
lines
|
|
328
|
+
const briefs = extras && Array.isArray(extras.sessionArchiveBriefs) ? extras.sessionArchiveBriefs : []
|
|
329
|
+
if (!taken.length && !briefs.length) return []
|
|
330
|
+
const linesOut = []
|
|
331
|
+
if (taken.length) {
|
|
332
|
+
const shown = taken.slice(0, limit || 4)
|
|
333
|
+
const header = '📌 当前摆上桌面备选(重点强调,主模型与参谋长共同关注) ' + taken.length + ' 份:'
|
|
334
|
+
const total = Number.isFinite(budget) ? Math.max(200, budget) : ANCHOR_BUDGET
|
|
335
|
+
const build = perItem =>
|
|
336
|
+
[header].concat(
|
|
337
|
+
shown.map(item => {
|
|
338
|
+
const pts = (Array.isArray(item.points) ? item.points : []).slice(0, 3).map(p => clamp(p.title, 26)).join(' / ')
|
|
339
|
+
const bodyBit = clamp(item.summary || item.body || '', perItem)
|
|
340
|
+
return ' · 《' + clamp(item.title || '未命名', 36) + '》: ' + bodyBit + (pts ? ' [要点: ' + pts + ']' : '')
|
|
341
|
+
}),
|
|
342
|
+
)
|
|
343
|
+
let perItem = 180
|
|
344
|
+
let lines = build(perItem)
|
|
345
|
+
while (lines.join('\n').length > total && perItem > 60) {
|
|
346
|
+
perItem = Math.max(60, Math.floor(perItem * 0.72))
|
|
347
|
+
lines = build(perItem)
|
|
348
|
+
}
|
|
349
|
+
linesOut.push(...lines)
|
|
328
350
|
}
|
|
329
|
-
|
|
351
|
+
if (briefs.length) {
|
|
352
|
+
const idxText = briefs.slice(0, 6).map(b => `《${clamp(b.title || '未命名', 28)}》`).join('、')
|
|
353
|
+
const more = briefs.length > 6 ? ` 等共 ${briefs.length} 份` : ''
|
|
354
|
+
linesOut.push(`🗂️ 本会话档案柜封存索引:${idxText}${more}(按需调用 chief_board({ action: "archive.search" }) 检索)`)
|
|
355
|
+
}
|
|
356
|
+
return linesOut
|
|
330
357
|
}
|
|
331
358
|
|
|
332
359
|
function anchorLines(board, limit, budget) {
|
|
@@ -382,12 +409,27 @@ function teamTaskLines(tasks, max) {
|
|
|
382
409
|
return lines
|
|
383
410
|
}
|
|
384
411
|
|
|
412
|
+
function chiefPostureLine(permissionMode) {
|
|
413
|
+
const mode = String(permissionMode || 'danger-full-access').trim()
|
|
414
|
+
if (mode === 'read-only') {
|
|
415
|
+
return '🛡️ 权限 posture=仅可查看 (read-only):参谋长只读核验与建言;主模型/子代理严守禁止红线,禁止未经授权直接改盘。'
|
|
416
|
+
}
|
|
417
|
+
if (mode === 'workspace-write') {
|
|
418
|
+
return '🛡️ 权限 posture=工作区内修改 (workspace-write):参谋长与主模型/子代理限当前工作区内安全读写并严格守红线,禁止越界写盘或高危命令。'
|
|
419
|
+
}
|
|
420
|
+
if (mode === 'auto-review') {
|
|
421
|
+
return '🛡️ 权限 posture=自动审查 (auto-review EXP):常规工作区内推进;高风险终端命令与越界改动须经参谋长双人复核。'
|
|
422
|
+
}
|
|
423
|
+
return '🛡️ 权限 posture=完全权限 (danger-full-access):参谋长拥有最高实权(全盘读写、测试核验、调度子代理、强介入与压缩);主模型/子代理在能力边界与禁止红线内协作。'
|
|
424
|
+
}
|
|
425
|
+
|
|
385
426
|
/** The injected section. Never throws: a broken digest must not break a prompt. */
|
|
386
427
|
export function renderDigest(board, extras) {
|
|
387
428
|
try {
|
|
388
429
|
const head = ['## 参谋看板(DSH 参谋长指挥看板 · 父子代理与跨对话互通)']
|
|
389
430
|
const mode = modeLine(board)
|
|
390
431
|
if (mode) head.push(mode)
|
|
432
|
+
head.push(chiefPostureLine(extras && extras.chiefPermissionMode))
|
|
391
433
|
if (board.objective) {
|
|
392
434
|
const owner = board.objectiveBy ? '(' + ownerName(board.objectiveBy) + ' 设定)' : ''
|
|
393
435
|
head.push('目标' + owner + ': ' + clamp(board.objective, 200))
|
|
@@ -418,6 +460,7 @@ export function renderDigest(board, extras) {
|
|
|
418
460
|
{ key: '规划', build: () => planLines(board, 6), hold: ANCHOR_RESERVE },
|
|
419
461
|
{ key: '断点', build: () => cursorLines(board), hold: ANCHOR_RESERVE },
|
|
420
462
|
{ key: '待办', build: () => taskLines(board, 10), hold: ANCHOR_RESERVE },
|
|
463
|
+
{ key: '协同进度', build: () => linkedPeersLines(extras, 4), hold: ANCHOR_RESERVE },
|
|
421
464
|
{ key: '团队任务', build: () => teamTaskLines(extras && extras.teamTasks, 8), hold: ANCHOR_RESERVE },
|
|
422
465
|
{
|
|
423
466
|
key: '取出档案',
|
|
@@ -460,7 +503,10 @@ export function renderDigest(board, extras) {
|
|
|
460
503
|
'【强制执行铁律 · 严禁只说不调工具】\n'
|
|
461
504
|
+ ' 1. 逢变必记:定目标、拆任务、切换推进(doing)/受阻(blocked)/完成(done)、产出结论或断点时,必须当轮调用 chief_board(graph.plan / task.update / cursor.set / note.write)或 chief_memory 落盘,纯文字口头宣告无效。\n'
|
|
462
505
|
+ ' 2. 逢协必传:派发子代理、给子代理/主代理/联动窗口传话同步关键发现时,必须调用 chief_board 的 task.dispatch / team.steer / mail.send(务必写明目标代理名)。\n'
|
|
463
|
-
+ ' 3.
|
|
506
|
+
+ ' 3. 撞墙必奏(宰相边界机制):执行中若撞墙(权限被拒、沙箱受限、目录禁改、路线死胡同)或用户要求总结工作边界(禁止红线/必做事项/注意事项),必须调用 chief_board({ action: "bounds.propose", field: "forbidden"|"allowed"|"notes", item: "简明边界条文", reason: "撞墙原因" }) 呈交 DSH 参谋长(注:allowed 列即「必做事项」,notes 列即「注意事项」),由参谋长请示用户批准后注入全局边界。'
|
|
507
|
+
+ (extras && extras.smartCompactActive
|
|
508
|
+
? '\n 4. 智选压缩协同:当前已启用「✦ 智选」无阈值共管(硬阈值不触发);当完成阶段大步、切换任务阶段或上下文已明显臃肿时,调用 chief_board({ action: "context.compact", text: "本阶段关键事实与断点摘要" }),由参谋长归档入本会话档案柜并执行高质量压缩。'
|
|
509
|
+
: ''),
|
|
464
510
|
)
|
|
465
511
|
if (dropped.length) {
|
|
466
512
|
head.push('预算不够,这些段没进:' + dropped.join('、') + '。需要就用 chief_board snapshot 取全量。')
|
package/handoff.js
CHANGED
|
@@ -296,15 +296,15 @@ export function renderHandoff(board, boundaries, budget = 5200, viewer = '', ext
|
|
|
296
296
|
lines.push('- 本会话目录:' + (limits.sessionWorkingDirectory || limits.workingDirectory || '—'))
|
|
297
297
|
lines.push('- 部署默认可写根(会话没有 cwd 时用它):' + (limits.workspaceRoot || '—') + (limits.extraWritableRoots ? ' + ' + limits.extraWritableRoots.join(', ') : ''))
|
|
298
298
|
const items = []
|
|
299
|
-
//
|
|
299
|
+
// 顺序就是优先级:空间不够时先丢「注意」,绝不先丢「禁止」与「必做」。
|
|
300
300
|
// 板子对每个数组各有 20 条上限,所以最坏是 60 条,挤爆时必须靠这个次序活着。
|
|
301
301
|
for (const forbidden of bounds.forbidden) items.push({ label: '禁止', cap: 200, text: forbidden })
|
|
302
|
+
for (const allowed of bounds.allowed) items.push({ label: '必做', cap: 200, text: allowed })
|
|
302
303
|
for (const note of bounds.notes) items.push({ label: '注意', cap: 240, text: note })
|
|
303
|
-
for (const allowed of bounds.allowed) items.push({ label: '允许', cap: 200, text: allowed })
|
|
304
304
|
if (!items.length) return lines
|
|
305
305
|
const left = room - lines.join('\n').length - 2
|
|
306
306
|
// 先按「每条都至少还读得懂」的下限排;排不下就让 takeWhole 从队尾丢
|
|
307
|
-
//
|
|
307
|
+
// (队尾就是「注意」),并写明还有几条没列出。
|
|
308
308
|
// 反面教材:把 60 条全压到 24 字,一条条都是「禁止 第1条:bbbb…」,
|
|
309
309
|
// 读者既不知道禁的是什么,也不知道自己漏了什么,比少列几条贵得多。
|
|
310
310
|
const share = Math.floor(left / items.length) - 8
|