dsh-chief 1.6.0 → 1.7.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 +31 -0
- package/README.en.md +277 -123
- package/README.md +283 -129
- package/api-routes.js +193 -2
- package/board-actions.js +1452 -2060
- package/board-handoff.js +709 -0
- package/board-schema.js +35 -2
- package/chief-approvals.js +6 -2
- package/chief-commands.js +1884 -3486
- package/chief-executor.js +6 -1
- package/chief-network.js +1098 -869
- package/chief-review.js +193 -3
- package/chief-state.js +1996 -3078
- package/chief-view.js +7 -4
- package/client.js +12237 -8021
- package/command-helpers.js +568 -0
- package/command-ops.js +1226 -0
- package/digest.js +25 -3
- package/index.js +6 -0
- package/locale/en.json +4 -4
- package/locale/zh.json +4 -4
- package/model-tools.js +40 -2
- package/network-harness.js +1047 -0
- package/package.json +8 -2
- package/runtime-hooks.js +69 -2
- package/safety/guard-walls.js +5 -0
- package/safety/invariant-guards.js +125 -6
- package/safety/tool-gate.js +2 -0
- package/state-media.js +173 -0
- package/state-schema.js +1505 -0
- package/subagent-runtime.js +57 -3
package/board-schema.js
CHANGED
|
@@ -8,7 +8,7 @@ import { normalizeMemory } from './memory.js'
|
|
|
8
8
|
|
|
9
9
|
export const API = '/api/dsh-chief'
|
|
10
10
|
|
|
11
|
-
export const BACKEND_BUILD = '1.
|
|
11
|
+
export const BACKEND_BUILD = '1.7.0'
|
|
12
12
|
|
|
13
13
|
export const BOARD_VERSION = 1
|
|
14
14
|
|
|
@@ -406,6 +406,39 @@ function normalizeGoalApproval(raw) {
|
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
408
|
|
|
409
|
+
const CURSOR_BLOCKED_REAL_CONTRAST_RE = /(?:但|但是|不过|然而|仍|依然|还是).{0,12}(?:卡在|卡住|阻塞|受阻|无法|失败|报错|错误|缺少|缺失|无权限|权限拒绝|拒绝|冲突|超限|超时|未通过)|\b(?:but|however|still)\b.{0,24}\b(?:blocked|stalled|fail(?:ed|ing)?|error|missing|denied|cannot|can't|unable|timeout)\b/i
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Normalize `board.cursor.blocked` so non-blocking / cleared / user-approved remarks
|
|
413
|
+
* (e.g. "无", "无(已获用户批准执行)", "用户已接受当前配置…", "None (approved)")
|
|
414
|
+
* collapse to `""` instead of lighting up a false-positive red alarm pill, while
|
|
415
|
+
* preserving genuine blockers (e.g. "无法连接", "无权限", "没有找到", "等待用户批准",
|
|
416
|
+
* "None of the tests passed", or contrast clauses like "用户已确认,但仍缺少…").
|
|
417
|
+
*/
|
|
418
|
+
export function normalizeCursorBlocked(raw) {
|
|
419
|
+
const s = String(raw === null || raw === undefined ? '' : raw).replace(/\s+/g, ' ').trim()
|
|
420
|
+
if (!s) return ''
|
|
421
|
+
const unwrapped = s.replace(/^[\s\-—–_\/.,;:!?~`'"“”‘’()()【】\[\]{}]+|[\s\-—–_\/.,;:!?~`'"“”‘’()()【】\[\]{}]+$/g, '').trim()
|
|
422
|
+
if (!unwrapped) return ''
|
|
423
|
+
if (/^(?:无|暂无|没有|木有|空|正常|无阻塞|无卡点|无阻碍|无受阻|无障碍|未受阻|未阻塞|不阻塞|不受阻|非阻塞|目前无阻塞|当前无阻塞|暂无阻塞|暂无卡点|没有阻塞|没有卡点|无异常|无报错|已解除|已解决|已清空|已清零|已放行|已通过|已恢复|已批准|已获批|已获批准|已获用户批准|已获用户批准执行|已确认|已同意|none|no|n\/?a|nil|null|empty|nothing|false|ok|clear|cleared|resolved|unblocked|not\s+blocked|no\s+blockers?|no\s+issues?|approved|user\s+approved)$/i.test(unwrapped)) {
|
|
424
|
+
return ''
|
|
425
|
+
}
|
|
426
|
+
if (CURSOR_BLOCKED_REAL_CONTRAST_RE.test(s)) {
|
|
427
|
+
return s.slice(0, 400)
|
|
428
|
+
}
|
|
429
|
+
if (
|
|
430
|
+
/^(?:(?:目前|当前)?(?:无|暂无)(?=$|[\s((【\[,,;;::。.\-—/、])|(?:目前|当前)?(?:无|暂无|没有|未|不|非)(?:明显|任何)?(?:阻塞|卡点|阻碍|受阻|障碍|卡住|异常|报错|问题)(?=$|[\s((【\[,,;;::。.\-—/、])|(?:已解除|已解决|已放行|已清空|已清零|已恢复|已获(?:用户)?批(?:准)?(?:执行)?|已由用户(?:批准|确认|同意|接受)|用户已(?:接受|批准|确认|同意|拍板|放行|认可)))/.test(s)
|
|
431
|
+
) {
|
|
432
|
+
return ''
|
|
433
|
+
}
|
|
434
|
+
if (
|
|
435
|
+
/^(?:(?:none|n\/?a|nil|null|nothing)(?=$|\s*[(\[.,;:\-\/])|(?:not\s+blocked|no\s+blockers?(?:\s+found|\s+now|\s+remaining)?|unblocked|resolved|cleared|approved(?:\s+by\s+user)?|user\s+(?:approved|accepted|confirmed))(?=$|[\s(\[.,;:\-\/]))/i.test(s)
|
|
436
|
+
) {
|
|
437
|
+
return ''
|
|
438
|
+
}
|
|
439
|
+
return s.slice(0, 400)
|
|
440
|
+
}
|
|
441
|
+
|
|
409
442
|
export function normalizeBoard(raw) {
|
|
410
443
|
const board = raw && typeof raw === 'object' ? raw : {}
|
|
411
444
|
const plan = Array.isArray(board.plan) ? board.plan : []
|
|
@@ -455,7 +488,7 @@ export function normalizeBoard(raw) {
|
|
|
455
488
|
at: board.cursor && typeof board.cursor.at === 'number' ? board.cursor.at : 0,
|
|
456
489
|
step: str(board.cursor && board.cursor.step, '').slice(0, 400),
|
|
457
490
|
next: str(board.cursor && board.cursor.next, '').slice(0, 400),
|
|
458
|
-
blocked:
|
|
491
|
+
blocked: normalizeCursorBlocked(board.cursor && board.cursor.blocked),
|
|
459
492
|
by: str(board.cursor && board.cursor.by, ''),
|
|
460
493
|
session: str(board.cursor && board.cursor.session, ''),
|
|
461
494
|
},
|
package/chief-approvals.js
CHANGED
|
@@ -417,6 +417,7 @@ export async function executeBatchSuggestions(deps, {
|
|
|
417
417
|
command: cmdSample,
|
|
418
418
|
args: { text: sug.draftText || '', title: sug.title || '' },
|
|
419
419
|
board,
|
|
420
|
+
safetyGuardEnabled: !(effCfg && effCfg.tacticalModes && effCfg.tacticalModes.safetyGuardEnabled === false),
|
|
420
421
|
})
|
|
421
422
|
if (guardRes.blocked) {
|
|
422
423
|
mutateChiefState((st) => {
|
|
@@ -532,6 +533,7 @@ export async function handleApprovalDecision(deps, {
|
|
|
532
533
|
let found = null
|
|
533
534
|
let currentMode = DEFAULT_CHIEF_PERMISSION_MODE
|
|
534
535
|
let effPolicyPlugins = []
|
|
536
|
+
let effSafetyGuardEnabled = true
|
|
535
537
|
let existingNonPending = false
|
|
536
538
|
let hashMismatch = false
|
|
537
539
|
|
|
@@ -541,6 +543,7 @@ export async function handleApprovalDecision(deps, {
|
|
|
541
543
|
const eff = resolveWorkspaceConfig(state, rootId)
|
|
542
544
|
currentMode = normalizePermissionMode(eff.permissionMode, { requireAck: true, hasChiefRiskAck: ackOk })
|
|
543
545
|
effPolicyPlugins = Array.isArray(eff.policyPlugins) ? eff.policyPlugins : []
|
|
546
|
+
effSafetyGuardEnabled = !(eff && eff.tacticalModes && eff.tacticalModes.safetyGuardEnabled === false)
|
|
544
547
|
const item = (ws.pendingApprovals || []).find(a => a && a.id === approvalId && a.status === 'pending')
|
|
545
548
|
if (!item) {
|
|
546
549
|
existingNonPending = (ws.pendingApprovals || []).some(a => a && a.id === approvalId)
|
|
@@ -689,6 +692,7 @@ export async function handleApprovalDecision(deps, {
|
|
|
689
692
|
permissionMode: currentMode === 'chief' ? 'chief' : 'strategist',
|
|
690
693
|
hasChiefRiskAck: currentMode === 'chief',
|
|
691
694
|
policyPlugins: effPolicyPlugins,
|
|
695
|
+
safetyGuardEnabled: effSafetyGuardEnabled,
|
|
692
696
|
capabilityScope: resolvedScope,
|
|
693
697
|
approvedOnce: true,
|
|
694
698
|
board,
|
|
@@ -709,7 +713,7 @@ export async function handleApprovalDecision(deps, {
|
|
|
709
713
|
resultMsg = scopeCheck.error
|
|
710
714
|
appendChiefAuditLog(rootId, { mode: currentMode, stage: 'scope_guard', rule: scopeCheck.rule, decision: 'rejected', operation: found.operationLabel, target: found.targetLabel, reason: scopeCheck.error, outcome: 'rejected', by: 'operator' })
|
|
711
715
|
} else {
|
|
712
|
-
const guardRes = evaluateSafetyGuardHardRules({ tool: 'relay', opClass: 'workflow', command: payload.text || '', board })
|
|
716
|
+
const guardRes = evaluateSafetyGuardHardRules({ tool: 'relay', opClass: 'workflow', command: payload.text || '', board, safetyGuardEnabled: effSafetyGuardEnabled })
|
|
713
717
|
if (guardRes.blocked) {
|
|
714
718
|
execOk = false
|
|
715
719
|
execRes = { ok: false, blockedBySafetyGuard: true, error: guardRes.reason }
|
|
@@ -753,7 +757,7 @@ export async function handleApprovalDecision(deps, {
|
|
|
753
757
|
}
|
|
754
758
|
}
|
|
755
759
|
} else if (found.kind === 'compact') {
|
|
756
|
-
const guardRes = evaluateSafetyGuardHardRules({ tool: 'session_compact', opClass: 'workflow', board })
|
|
760
|
+
const guardRes = evaluateSafetyGuardHardRules({ tool: 'session_compact', opClass: 'workflow', board, safetyGuardEnabled: effSafetyGuardEnabled })
|
|
757
761
|
if (guardRes.blocked) {
|
|
758
762
|
execOk = false
|
|
759
763
|
execRes = { ok: false, blockedBySafetyGuard: true, error: guardRes.reason }
|