dsh-live-compact 1.1.8 → 1.1.10

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # 版本变更
2
2
 
3
+ ## 1.1.10
4
+
5
+ - **billion-context 兼容保持**:保留对方接管官方压缩时的让位边界。
6
+ - **真实 CLI 轮末小切修复**:在 DSH `agent/turn-stopping` 的 live-agent 窗口执行维护与 catch-up;CLI agent 随后 dispose 时,已开始的本地小切不再被 `runMaintenance` 吞掉。`turn/end` 继续作为兜底。
7
+ - **真实验证**:GLM 5.3 Flash 隔离 DSH session 在 51,827 tokens 时提交一刀,切段 12,162 tokens,实际 saved 10,701 tokens;定向回归 10/10,完整 gate 与 Cordis 兼容门禁随发布重跑。
8
+
9
+ ## 1.1.9
10
+
11
+ - **billion-context 兼容保持**:保留 1.1.7/1.1.8 的让位边界;检测到 billion-context 接管官方压缩时,Live Compact 不改写对方正在接管的会话。
12
+ - **恢复低水位小切**:恢复 1.0.6 的合法尾段扩展规则,切点会在不越过用户边界、checkpoint 或不平衡工具对的前提下向左扩展到 `chunkMax`;长读候选不再无条件抢占更大的普通合法跨度。
13
+ - **回归证据**:新增“长读与普通跨度竞争”和“合法尾段扩展”定向回归;当前定向桥接与 v1.0.7 兼容检查 9/9 通过。1.1.8 的 WebUniverse 只验证到单题真实小切,完整模型重测不作为本版发布门槛。
14
+
3
15
  ## 1.1.8
4
16
 
5
17
  - **DSH 轮末兼容**:把原生 `turn/end` 的 `max-tokens` 也视为已收尾边界;即使下一轮已经开始,已发布的上一轮边界仍会进入维护。
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  完整数据、原始口径和限制见 [docs/benchmarks.md](docs/benchmarks.md),结构化数字见 [docs/benchmark-results.json](docs/benchmark-results.json)。
10
10
 
11
11
  - **1.0.5 失忆对比**:同一真实 DeepSeek 会话,15 道回忆题两边都是 15/15;Live Compact 的日志中段细节两次都是 3/3,原版一次 1/3、一次 3/3。
12
- - **历史 DSH 长链路**:早期 150 道短题和 20 道 WebUniverse 连续任务都保留了原版/Live Compact 对照表;它们是历史实测,不是 1.1.8 的新验收。
12
+ - **历史 DSH 长链路**:早期 150 道短题和 20 道 WebUniverse 连续任务都保留了原版/Live Compact 对照表;它们是历史实测,不是 1.1.10 的新验收。
13
13
  - **OpenCode 移植参考**:独立项目 [opencode-live-compact](https://github.com/Haoming9527/opencode-live-compact) 把插件移植到 OpenCode,和 OpenCode 自带的 autocompact 做了对照:在 OpenCode 2.2.6 + GPT-6 Luna 上跑 Aider 150 和 Web-Bench React 20,任务分别 150/150、20/20 且最终浏览器测试 59/59;估算费用分别低 14.3% 和 42.1%。这是 OpenCode 项目的结果,用来说明移植后的可复核测评方法,不冒充 DSH 运行结果。
14
14
 
15
15
  ![早期 DSH 两场实测](docs/slide-results.jpg)
@@ -31,13 +31,13 @@
31
31
  headless:
32
32
 
33
33
  ```sh
34
- dsh plugin --profile headless add dsh-live-compact@1.1.8
34
+ dsh plugin --profile headless add dsh-live-compact@1.1.10
35
35
  ```
36
36
 
37
37
  网页端:
38
38
 
39
39
  ```sh
40
- dsh plugin --profile web add dsh-live-compact@1.1.8
40
+ dsh plugin --profile web add dsh-live-compact@1.1.10
41
41
  ```
42
42
 
43
43
  想先装到本机看版本:
@@ -189,8 +189,8 @@ Windows 会重新设置备份访问权限,失败时停止写备份并保留原
189
189
  从 npm 装。headless 和网页是两个 profile,要各装一次。桌面端是另一个 profile,普通 `dsh plugin --profile desktop` 会被拒绝。
190
190
 
191
191
  ```sh
192
- dsh plugin --profile headless add dsh-live-compact@1.1.8
193
- dsh plugin --profile web add dsh-live-compact@1.1.8
192
+ dsh plugin --profile headless add dsh-live-compact@1.1.10
193
+ dsh plugin --profile web add dsh-live-compact@1.1.10
194
194
  ```
195
195
 
196
196
  想先装到本机看版本:
@@ -203,9 +203,9 @@ dsh-live-compact --version
203
203
  上不了 npm 时的镜像安装命令:
204
204
 
205
205
  ```sh
206
- dsh plugin --profile headless add https://download.merkyorlynn.com/downloads/plugins/dsh-live-compact-1.1.8.tgz
207
- dsh plugin --profile web add https://download.merkyorlynn.com/downloads/plugins/dsh-live-compact-1.1.8.tgz
208
- npm install -g --force "https://download.merkyorlynn.com/downloads/plugins/dsh-live-compact-1.1.8.tgz"
206
+ dsh plugin --profile headless add https://download.merkyorlynn.com/downloads/plugins/dsh-live-compact-1.1.10.tgz
207
+ dsh plugin --profile web add https://download.merkyorlynn.com/downloads/plugins/dsh-live-compact-1.1.10.tgz
208
+ npm install -g --force "https://download.merkyorlynn.com/downloads/plugins/dsh-live-compact-1.1.10.tgz"
209
209
  dsh-live-compact --version
210
210
  ```
211
211
 
package/index.js CHANGED
@@ -571,19 +571,34 @@ function selectNewestChunk(session, measurement, key = DEFAULT_KEY, context = {}
571
571
  };
572
572
  let usedLongCut = false;
573
573
  let picked = null;
574
+ let longPicked = null;
574
575
  const fallbackWithoutLongRead = () => context.disableLongRead
575
576
  ? null
576
577
  : selectNewestChunk(session, measurement, key, { ...context, disableLongRead: true });
577
578
  if (longSpan) {
578
- const longPicked = cutLongReadRound(items, longSpan.start, longSpan.end, cutOptions);
579
- if (longPicked && longPicked.start >= longSpan.start && longPicked.end <= longSpan.end) {
579
+ const candidate = cutLongReadRound(items, longSpan.start, longSpan.end, cutOptions);
580
+ if (candidate && candidate.start >= longSpan.start && candidate.end <= longSpan.end) {
581
+ longPicked = candidate;
582
+ }
583
+ }
584
+ let ordinaryPicked = null;
585
+ if (end >= first && !isCheckpoint(session, nodes[end])) {
586
+ ordinaryPicked = selectCutIndexes(items, cutOptions);
587
+ }
588
+ if (longPicked && ordinaryPicked) {
589
+ const longTokens = longPicked.tokens || 0;
590
+ const ordinaryTokens = ordinaryPicked.tokens || 0;
591
+ if (ordinaryTokens >= longTokens) {
592
+ picked = ordinaryPicked;
593
+ } else {
580
594
  picked = longPicked;
581
595
  usedLongCut = true;
582
596
  }
583
- }
584
- if (!picked) {
585
- if (end < first || isCheckpoint(session, nodes[end])) return null;
586
- picked = selectCutIndexes(items, cutOptions);
597
+ } else if (ordinaryPicked) {
598
+ picked = ordinaryPicked;
599
+ } else if (longPicked) {
600
+ picked = longPicked;
601
+ usedLongCut = true;
587
602
  }
588
603
  if (!picked) return null;
589
604
  if (picked.pointerOnly) {
@@ -606,6 +621,42 @@ function selectNewestChunk(session, measurement, key = DEFAULT_KEY, context = {}
606
621
  picked.start = pairStart;
607
622
  }
608
623
  if (usedLongCut && (picked.start < longSpan.start || picked.end > longSpan.end)) return fallbackWithoutLongRead();
624
+
625
+ // 1.0.6 selected the newest legal end, then grew the cut left until the
626
+ // 32K rail, a user/checkpoint, an unbalanced tool pair, or an incomplete
627
+ // card stopped it. Returning the first >= CHUNK_MIN phase leaves a tiny
628
+ // 1.9K tail in a long drain and defeats the low-water goal. Restore that
629
+ // core selection rule while keeping the newer source and checkpoint guards.
630
+ if (!picked.pointerOnly) {
631
+ let expandedStart = picked.start;
632
+ let expandedTokens = items.slice(expandedStart, picked.end + 1)
633
+ .reduce((sum, item) => sum + (item.tokens || 0), 0);
634
+ while (expandedStart > first) {
635
+ const previous = expandedStart - 1;
636
+ if (isCheckpoint(session, nodes[previous])) break;
637
+ if (classifications[previous].isGenuineUserBoundary) break;
638
+ if (usedLongCut && previous < longSpan.start) break;
639
+ const nextTokens = expandedTokens + (priced[previous].tokens || 0);
640
+ if (nextTokens > settings.chunkMax) break;
641
+ const trialPieces = spanPieces(previous, picked.end);
642
+ const trialCard = buildCard(
643
+ trialPieces.map((piece) => piece.text).join("\n"),
644
+ liveText(previous, picked.end),
645
+ trialPieces,
646
+ extras,
647
+ );
648
+ if (trialCard.ok !== true) break;
649
+ expandedStart = previous;
650
+ expandedTokens = nextTokens;
651
+ }
652
+ while (expandedStart <= picked.end &&
653
+ !cutOk(toolPairingBalancedBefore, session, nodes[expandedStart])) {
654
+ expandedTokens -= priced[expandedStart].tokens || 0;
655
+ expandedStart += 1;
656
+ }
657
+ if (expandedStart > picked.end) return usedLongCut ? fallbackWithoutLongRead() : null;
658
+ picked.start = expandedStart;
659
+ }
609
660
  const start = picked.start;
610
661
  end = picked.end;
611
662
  const tokens = items.slice(start, end + 1).reduce((sum, item) => sum + item.tokens, 0);
@@ -740,6 +791,9 @@ export default class SpineCompactionEngine extends BasicCompactionEngine {
740
791
  await this.waitForMaintenance(agent, signal);
741
792
  return typeof next === "function" ? next() : undefined;
742
793
  });
794
+ ctx.on("agent/turn-stopping", async ({ agent, signal }) => {
795
+ await this.runTurnStoppingMaintenance(agent, signal);
796
+ });
743
797
  } catch (error) {
744
798
  const message = error instanceof Error ? error.message : String(error);
745
799
  ctx.logger?.warn?.(`spine: 本会话未接管自动小切。${message}`);
@@ -833,6 +887,36 @@ export default class SpineCompactionEngine extends BasicCompactionEngine {
833
887
  this.pendingCuts.add(job);
834
888
  }
835
889
 
890
+ async runTurnStoppingMaintenance(agent, signal) {
891
+ if (this.standDown?.() || signal?.aborted) return;
892
+ const state = this.stateFor(agent);
893
+ if (state.warming) {
894
+ state.turnEndPending = true;
895
+ return;
896
+ }
897
+ state.warming = true;
898
+ try {
899
+ const settings = readSettings(this.liveConfig);
900
+ const events = agent.session.snapshotEvents();
901
+ let catchup = { finished: true, progressed: false, retryRequested: false };
902
+ if (events.length > CAPTURE_EVENT_BATCH) {
903
+ catchup = this.scheduleCaptureCatchup(agent, events, settings, { freezeSnapshot: true });
904
+ } else {
905
+ await this.flushPendingCaptures();
906
+ this.captureNew(agent.session, events, settings);
907
+ }
908
+ if (catchup?.promise && !catchup.finished) await catchup.promise;
909
+ await this.flushPendingCaptures();
910
+ await this.finishTurn(agent, events, { maintenanceRetry: true, skipCapture: true });
911
+ } finally {
912
+ state.warming = false;
913
+ if (state.turnEndPending) {
914
+ state.turnEndPending = false;
915
+ this.scheduleTurnEndMaintenance(agent, state.turnEndSeq);
916
+ }
917
+ }
918
+ }
919
+
836
920
  scheduleTurnEndMaintenance(agent, seq, boundaryEvent = null) {
837
921
  if (this.standDown?.()) return;
838
922
  const state = this.stateFor(agent);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-live-compact",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
4
4
  "description": "In-place newest-turn compaction for DeepSeek Harness. Compress while the task runs and keep the prefix.",
5
5
  "license": "MIT",
6
6
  "author": "MerkyorLynn <268568828+MerkyorLynn@users.noreply.github.com>",