dsh-compact-relay 0.5.0 → 0.5.2
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 +380 -0
- package/README.en.md +4 -3
- package/README.md +23 -5
- package/TUTORIAL.md +31 -5
- package/lib/actions/force-archive.js +113 -0
- package/lib/actions/handoff.js +58 -43
- package/lib/actions/pin.js +7 -6
- package/lib/actions/relay-chain.js +17 -0
- package/lib/actions/state.js +138 -16
- package/lib/adapters/http.js +88 -2
- package/lib/client.js +1496 -178
- package/lib/core/clip.js +92 -0
- package/lib/core/config-schema.js +2 -2
- package/lib/core/errors.js +3 -1
- package/lib/core/native-line.js +27 -0
- package/lib/core/native-pin-risk.js +106 -0
- package/lib/core/pin-anchors.js +3 -1
- package/lib/core/pin-health.js +112 -0
- package/lib/core/relay-record.js +128 -0
- package/lib/dsh/compaction-log.js +16 -9
- package/lib/dsh/compaction-pair.js +27 -1
- package/lib/dsh/diag-counters.js +4 -1
- package/lib/dsh/diagnostics.js +3 -1
- package/lib/dsh/handoff-archive.js +47 -1
- package/lib/dsh/handoff-writer.js +1 -1
- package/lib/dsh/model-task.js +14 -10
- package/lib/dsh/native-compaction.js +60 -4
- package/lib/dsh/relay-chain.js +238 -0
- package/lib/dsh/relay.js +108 -4
- package/lib/dsh/route.js +19 -0
- package/lib/dsh/session-view.js +16 -10
- package/lib/dsh/sessions.js +19 -12
- package/package.json +2 -2
package/lib/dsh/session-view.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { latestCompressHint } from '../core/compress-hint.js';
|
|
8
8
|
import { latestPinnedSeqs } from '../core/pins.js';
|
|
9
|
-
import { scanCompactionLog } from './compaction-pair.js';
|
|
9
|
+
import { isCommittedCompaction, scanCompactionLog } from './compaction-pair.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* 0.4 BUG-013:checkpoint 判定的默认实现(漏传第二个参数时也不再静默失效)。
|
|
@@ -68,23 +68,29 @@ export function firstCompactableIdx(session) {
|
|
|
68
68
|
*
|
|
69
69
|
* 以前数所有 compaction/summary,事务在 summary 之后失败会留下「幽灵摘要」,
|
|
70
70
|
* 把 advice 提前推到交接、6 次后提前打开合并旧摘要模式。
|
|
71
|
-
* 现在按 compactionId 配对:summary + 无 error 的 end + 覆盖该 summary 的 replace
|
|
72
|
-
*
|
|
71
|
+
* 现在按 compactionId 配对:summary + 无 error 的 end + 覆盖该 summary 的 replace 才算一次。
|
|
72
|
+
*
|
|
73
|
+
* 0.5.1 D01:**口径与 `dsh/compaction-log.collectCompactions` 合并**(唯一实现
|
|
74
|
+
* `compaction-pair.isCommittedCompaction`)。以前的宽松分支(没有 compactionId 的
|
|
75
|
+
* 旧日志直接 +1、不看 replace)会与面板的 committed 打架 —— 同一份日志
|
|
76
|
+
* countSummaries=1 / committed=false。现在旧日志同样要求 replace。
|
|
73
77
|
*/
|
|
74
78
|
export function countSummaries(session) {
|
|
75
|
-
//
|
|
79
|
+
// 配对扫描 + 「已提交」判定都与 dsh/compaction-log 共用(见 compaction-pair.js)。
|
|
76
80
|
const { summaries, ends, replaceByCoveredSeq } = scanCompactionLog(sessionLog(session));
|
|
77
81
|
let count = 0;
|
|
78
82
|
for (const summary of summaries) {
|
|
79
83
|
const id = summary.data?.compactionId;
|
|
80
|
-
|
|
84
|
+
const hasId = typeof id === 'string';
|
|
85
|
+
if (
|
|
86
|
+
isCommittedCompaction({
|
|
87
|
+
compactionId: hasId ? id : null,
|
|
88
|
+
end: hasId ? ends.get(id) : undefined,
|
|
89
|
+
replace: replaceByCoveredSeq.get(summary.seq),
|
|
90
|
+
})
|
|
91
|
+
) {
|
|
81
92
|
count += 1;
|
|
82
|
-
continue;
|
|
83
93
|
}
|
|
84
|
-
const end = ends.get(id);
|
|
85
|
-
if (end === undefined || end.error !== undefined) continue;
|
|
86
|
-
if (!replaceByCoveredSeq.has(summary.seq)) continue;
|
|
87
|
-
count += 1;
|
|
88
94
|
}
|
|
89
95
|
return count;
|
|
90
96
|
}
|
package/lib/dsh/sessions.js
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
truncateTitleUtf8,
|
|
29
29
|
} from '../core/relay.js';
|
|
30
30
|
import { HANDOFF_PREAMBLE } from '../core/prompts.js';
|
|
31
|
+
import { childRelayRecordOf } from '../core/relay-record.js';
|
|
31
32
|
import { localIso } from './diag-counters.js';
|
|
32
33
|
import { cacheControls, routeOf } from './route.js';
|
|
33
34
|
import { relayRecordOf, writeRelayRecord } from './relay.js';
|
|
@@ -444,20 +445,26 @@ export async function createHandoffSession({ ctx, engine, session, agent, doc, t
|
|
|
444
445
|
// 0.5.0 补:交接单已由调用方落盘,path 一并写进子记录 —— 接力条在子会话里直接
|
|
445
446
|
// 拿到「查看交接单」的路径,父会话未加载/已归档时不再退化为「暂无交接单」。
|
|
446
447
|
// path 拿不到(旧调用方/失败)就不写这个键,不猜、不写空串。
|
|
448
|
+
// 0.5.2 S2:record 形状(含键顺序、不写父会话侧字段、条件 path)由
|
|
449
|
+
// core/relay-record 的唯一构造器负责,这里只传语义参数。
|
|
447
450
|
const titlePlan = plan ?? handoffTitlePlanOf(ctx, session);
|
|
448
451
|
const relayAt = Date.now();
|
|
449
|
-
const relayWrote = writeRelayRecord(
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
452
|
+
const relayWrote = writeRelayRecord(
|
|
453
|
+
engine,
|
|
454
|
+
childSession,
|
|
455
|
+
childRelayRecordOf({
|
|
456
|
+
parentId: session.id,
|
|
457
|
+
childId,
|
|
458
|
+
ordinal: titlePlan.index,
|
|
459
|
+
baseTitle: titlePlan.baseTitle,
|
|
460
|
+
title,
|
|
461
|
+
scheme: titlePlan.scheme,
|
|
462
|
+
titleSeq,
|
|
463
|
+
path,
|
|
464
|
+
at: relayAt,
|
|
465
|
+
atIso: localIso(new Date(relayAt)),
|
|
466
|
+
}),
|
|
467
|
+
);
|
|
461
468
|
if (!relayWrote) {
|
|
462
469
|
log?.warn?.(`compact-relay: 新会话 ${childId} 接力链记录写入失败(下次从该会话交接将回退到标题解析)`);
|
|
463
470
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-compact-relay",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "DeepSeek Harness 上下文指示器插件:提供容量监控、压缩预览与确认、九段式交接单生成及消息锁定功能。 · Context indicator for DSH: preview-then-confirm compaction, 9-section session handoff, and pinned messages.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"node": ">=22"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
|
-
"test": "node scripts/build-client.mjs --check && node --check lib/client.js && node test/smoke.mjs && node test/handoff.mjs && node test/plugin-load.mjs && node test/contract.mjs && node test/compact-log.mjs && node test/compress-cue.mjs && node test/state-passive.mjs && node test/native-compaction.mjs && node test/markdown-lite.mjs && node test/diagnostics.mjs && node test/pin-contract.mjs && node test/ledger.mjs && node test/handoff-p2.mjs && node test/relay-title-scheme.mjs && node test/relay-chain.mjs && node test/handoff-naming.mjs && node test/native-line.mjs && node test/handoff-guard.mjs && node test/settings-ux.mjs && node test/archive.mjs && node test/relay-bar.mjs",
|
|
56
|
+
"test": "node scripts/build-client.mjs --check && node --check lib/client.js && node test/smoke.mjs && node test/handoff.mjs && node test/plugin-load.mjs && node test/contract.mjs && node test/compact-log.mjs && node test/compress-cue.mjs && node test/state-passive.mjs && node test/native-compaction.mjs && node test/markdown-lite.mjs && node test/clip.mjs && node test/diagnostics.mjs && node test/pin-contract.mjs && node test/ledger.mjs && node test/handoff-p2.mjs && node test/relay-title-scheme.mjs && node test/relay-chain.mjs && node test/relay-chain-endpoint.mjs && node test/handoff-naming.mjs && node test/native-line.mjs && node test/handoff-guard.mjs && node test/settings-ux.mjs && node test/pin-health.mjs && node test/archive.mjs && node test/force-archive.mjs && node test/relay-bar.mjs && node test/relay-record.mjs && node test/contract-golden.mjs",
|
|
57
57
|
"test:e2e": "node test/e2e/smoke.mjs",
|
|
58
58
|
"test:e2e:settings": "node test/e2e/settings-ui.mjs",
|
|
59
59
|
"test:e2e:settings-ux": "node test/e2e/settings-ux.mjs",
|