dsh-live-compact 1.1.12 → 1.1.14

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,24 @@
1
1
  # 版本变更
2
2
 
3
+ ## 1.1.14
4
+
5
+ - #51 在已有 shadow 根记录轮末维护何时开始、延期、结束或取消,以及本次提交的小切数。状态日志保留最近 256 KiB 的完整记录。
6
+ - #56 宿主拒绝无效的模型压缩预算时,即使尚未备份工具结果,也会尝试将拒绝原因写进私有决策日志。每个会话只去重已经写入的拒绝。
7
+ - #73 在 POSIX 上读回备份权限。目录须为 0700,文件须为 0600。正文和捕获游标写入前核对打开的文件身份及权限,不符时拒绝备份并保留原文。
8
+ - #71 用统计锁串行更新逐刀明细。每个 shadow 根最多保留 1 MiB 最新完整记录,累计统计继续保存在 `spine-stats.json`。
9
+ - #72 同一备份根可分别恢复多个已确认进程退出的锁。记录按完整锁身份保存,原锁及已有恢复记录保留。进程仍存活或无法确认时继续拒绝备份并记录原因。
10
+ - #74 兼容使用根上下文符号的 DSH/Cordis。Live Compact 完成初始化后才移交宿主原版压缩,激活失败会保留原版并记录原因,停用后按原配置恢复。
11
+
12
+ ## 1.1.13
13
+
14
+ - 已执行工具的任务触及单步输出上限后,宿主队列可继续原任务。若首次续接只有思考输出并再次触顶,插件会最后续接一次,提示模型从小工具调用开始。归档保留每次截断和续接的结束状态。
15
+ - #56 在已有 shadow 目录记录宿主压力预算拒绝的具体原因。小切替换后归档写入失败时保留原始错误。
16
+ - **#67 Windows 子进程兼容**:固定 ACL 脚本由 PowerShell 5.1 的 `-Command` 接收。路径和 SID 通过子进程环境传递,备份前验读实际 DACL。
17
+ - **#68 雷霆正文预算**:按 CJK 权重估算假名、谚文、扩展汉字和兼容汉字,并在完整码点处截断正文。
18
+ - **#69 宿主注入边界**:`time-context`、`tool-jobs`、`skill-catalog`、`runtime-context`、`subagent-settled`、`retry`、`goal` 和 `tool-goal` 这八类 DSH `user/message` bookkeeping 事件不再阻断小切回溯;未知来源、缺失来源和真实 `user` 消息仍保持硬边界。
19
+ - **#69 续接上下文**:小切归档保留宿主原生快照和技能目录的来源记录,续接由 DSH 重新投影当前说明,卡片只保留任务内容与证据。
20
+ - **#62 回归保护**:保留 shadow worker 的 eval/import 启动、`already-pruned` 游标推进和 `captureBlocked` 维护重试路径,并在候选门禁中继续覆盖。
21
+
3
22
  ## 1.1.12
4
23
 
5
24
  - **#62 Worker 启动与游标修复**:用 eval import 引导 shadow worker,保留宿主原生启动参数;`already-pruned` 结果标为不可恢复并推进 capture cursor,后续事件继续捕获。
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  一段对话做久了,读过的日志、跑过的命令和工具输出会越积越多。Live Compact 会在每轮结束时检查,能安全收短的长输出就整理一下。这一步在本机做,无需再请求模型。只替换选中的一段,切点前面的内容保持原样。整理前会备份原文,备份失败就保留原来的内容。
4
4
 
5
- 版本变更见 [CHANGELOG.md](CHANGELOG.md)。
5
+ 当前稳定版 [v1.1.14](https://github.com/Tranquillitatis-Lab/dsh-live-compact/releases/tag/v1.1.14)。版本变更见 [CHANGELOG.md](CHANGELOG.md)。
6
6
 
7
7
  ## 测评实证
8
8
 
@@ -16,7 +16,7 @@
16
16
 
17
17
  ![OpenCode Aider / Web-Bench 对照](docs/benchmarks-opencode-2026-11-09.png)
18
18
 
19
- ![1.1.7 GLM-5.3 Flash Web-Bench React 20 对照](docs/benchmark-1.1.7-webbench-react20.png)
19
+ ![1.1.12 GLM-5.3 Flash:DSH 原版、DSH Billion 与 Live Compact 三方对照](docs/benchmark-dsh-three-way-glm53-1.1.12-2026-11-17.png)
20
20
 
21
21
 
22
22
  ## 云端和本地怎么用
@@ -26,18 +26,20 @@
26
26
 
27
27
  默认到 2 万 token,插件才开始检查有没有合适的内容可以压缩。实际会不会压缩,还要看这轮读进了什么、下一轮可能有多长。上下文接近窗口上限时,DSH 仍可调用模型做一次大摘要。
28
28
 
29
+ 已执行工具的任务触及单步输出上限时,1.1.13 会在同一会话中续接,沿用原任务、已有改动和原输出上限。若首次续接仍在纯思考阶段触顶,插件会最后续接一次,提示模型从一个小的工具调用开始。自动续接会避让待处理输入、已取消的任务和含未执行工具调用的响应。
30
+
29
31
  平常用默认设置就够了。`SPINE_THUNDER` 是实验性的模型摘要模式,默认关闭。需要试用时才设为 `1`。本机或内网模型建议保持关闭。
30
32
 
31
33
  headless:
32
34
 
33
35
  ```sh
34
- dsh plugin --profile headless add dsh-live-compact@1.1.12
36
+ dsh plugin --profile headless add dsh-live-compact@1.1.14
35
37
  ```
36
38
 
37
39
  网页端:
38
40
 
39
41
  ```sh
40
- dsh plugin --profile web add dsh-live-compact@1.1.12
42
+ dsh plugin --profile web add dsh-live-compact@1.1.14
41
43
  ```
42
44
 
43
45
  想先装到本机看版本:
@@ -118,7 +120,7 @@ Issue #19 里下一轮输入回到 21 万到 24 万、前缀被打掉的那一
118
120
  - 预设不再硬等 gate。gate 加载失败时,网页预设不会卡在等待。换包前先试加载,失败就保留原版名字。
119
121
  - 换上之后带上 0.8、65536、8192。预设里已有的配置优先。
120
122
  - 预设 id 写在外层或内层都能换。standard、ptc、cordis、minimal 在 0.2.1-rc.5 上都会换。TUI 仍不碰。
121
- - 外壳先加载。引擎装不上时,这一会话不挂起。能改用原版就用原版,并记下「本会话未接管」。原版也装不上时,`/compact` 马上返回错误。
123
+ - 原版压缩已启用时,Live Compact 初始化完成后才接管。激活失败会保留原版,并记下「本会话未接管」。如果旧的 profile 用户补丁另外关闭了 `compaction-basic`,可在宿主的插件管理中重新启用它。两种引擎都装不上时,外壳会报告失败原因。
122
124
  - headless 的宿主包自己关掉了原版压缩。插件不能把那一行重新打开。网页预设不注入 gate,漏换这一轮就继续用原版。
123
125
 
124
126
  ## Windows 备份权限
@@ -127,7 +129,7 @@ Windows 会重新设置备份访问权限,失败时停止写备份并保留原
127
129
 
128
130
  双用户实测(Actions run `42367713007`,Windows 11 Enterprise ARM / Server 2022 x64)确认:`/inheritance:r /grant:r` 会留下其他主体的显式 ACE,第二个普通用户仍能读取备份。Windows 备份完整替换 DACL。慢存储、超大历史和共享目录压力仍属于后续观察范围。
129
131
 
130
- 权限写入改为固定的 `%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe`(Windows PowerShell 5.1 / .NET Framework),使用 `-NoProfile -NonInteractive -EncodedCommand`。脚本固定内嵌在已打包的 `shadow.js`,路径、SID、文件类型通过子进程环境传递,不拼进脚本。当前用户 SID 仍由固定 System32 `whoami.exe` 在各权限执行上下文获取并缓存,worker 重建后重新获取,脚本再对照自身 Windows 身份。新建受保护的 DACL,只允许当前用户、SYSTEM、Administrators 完全控制;目录 ACE 带 OI/CI,直接修正的文件 ACE 不带继承标志。只修改 DACL,不提权,不改 owner、group 或 SACL,不使用临时宽松 ACL。写后读取实际 DACL,核验保护位、完整 ACE 数量、SID、Allow、权限及继承标志,收到确认才缓存。工具失败、超时、SID 非法或读回不符都会熔断本进程后续备份,不回退到 chmod。
132
+ 权限写入改为固定的 `%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe`(Windows PowerShell 5.1 / .NET Framework),使用 `-NoProfile -NonInteractive -Command`。脚本固定内嵌在已打包的 `shadow.js`,路径、SID、文件类型通过子进程环境传递,不拼进脚本。当前用户 SID 仍由固定 System32 `whoami.exe` 在各权限执行上下文获取并缓存,worker 重建后重新获取,脚本再对照自身 Windows 身份。新建受保护的 DACL,只允许当前用户、SYSTEM、Administrators 完全控制;目录 ACE 带 OI/CI,直接修正的文件 ACE 不带继承标志。只修改 DACL,不提权,不改 owner、group 或 SACL,不使用临时宽松 ACL。写后读取实际 DACL,核验保护位、完整 ACE 数量、SID、Allow、权限及继承标志,收到确认才缓存。工具失败、超时、SID 非法或读回不符都会熔断本进程后续备份,不回退到 chmod。
131
133
 
132
134
  目录缓存核对规范路径、设备/文件编号及创建时间;替换目录或改指向的已知别名会拒绝后续备份。经确认目录内以 `wx` 新建的空文件,核对已打开句柄与路径指向同一文件后,使用继承的 allowlist,不逐文件启动子进程,写入正文前完成检查。既有文件不能只凭父目录缓存获得信任:仅在本进程已确认同一文件身份时复用缓存,否则对被请求的文件单独替换 DACL。拒绝文件符号链接、非普通文件及多硬链接文件。不扫描或批量修复历史备份。重启恢复只读校验已有 raw/meta,不逐个收紧它们的权限;cursor 读取仍执行原有单文件 ACL 校验。raw 真正用于修剪或切片前,再重新授权目标文件,并与首次确认的字节数和 SHA256 比较。重新授权不能把已变化的内容当成原始备份。未触及的旧文件(包括直接外部读取或 shadow-search 读取的旧文件)不保证已修复,也无法撤回此前泄露的数据。不要把 shadow 指向混有其他文件的目录。
133
135
 
@@ -189,8 +191,8 @@ Windows 会重新设置备份访问权限,失败时停止写备份并保留原
189
191
  从 npm 装。headless 和网页是两个 profile,要各装一次。桌面端是另一个 profile,普通 `dsh plugin --profile desktop` 会被拒绝。
190
192
 
191
193
  ```sh
192
- dsh plugin --profile headless add dsh-live-compact@1.1.12
193
- dsh plugin --profile web add dsh-live-compact@1.1.12
194
+ dsh plugin --profile headless add dsh-live-compact@1.1.14
195
+ dsh plugin --profile web add dsh-live-compact@1.1.14
194
196
  ```
195
197
 
196
198
  想先装到本机看版本:
@@ -200,7 +202,7 @@ npm install -g dsh-live-compact
200
202
  dsh-live-compact --version
201
203
  ```
202
204
 
203
- 上不了 npm 时的镜像安装命令:
205
+ 以下是 1.1.12 的历史镜像。
204
206
 
205
207
  ```sh
206
208
  dsh plugin --profile headless add https://download.merkyorlynn.com/downloads/plugins/dsh-live-compact-1.1.12.tgz
@@ -215,7 +217,11 @@ DSH-TUI 先不要装。本包已补预设压缩隔离组的接管;TUI 仍需
215
217
 
216
218
  被切掉的原文会写到 `~/.dsh/compaction-spine/shadow`。Unix 权限为目录 0700 / 文件 0600;Windows 新建/修正后的备份允许当前用户、SYSTEM、Administrators,历史文件及缓存限制见上面的 ACL 说明。上限 256MB。快满时删最老的备份。卡片里的序号是会话日志的事件号。要在当前会话的备份里找一行,用 `import { searchShadow } from "dsh-live-compact/shadow-search"`。插件自己不会去搜。
217
219
 
218
- `dsh-live-compact stats` 的 `saved` 是切完当下少掉的 token,`rewrite` 是同一次收尾实际要重写的尾巴,只记一次。同一步连切不会按刀数把尾巴乘上去。这两个数口径不同,比值不是盈亏。桌面端没有终端,`rg "spine cut"` 只在终端输出里找得到。逐刀明细在 shadow 目录的 `spine-cuts.jsonl`。
220
+ `spine-maintenance.jsonl` 在已有 shadow 目录记录轮末维护状态。同一个 `operation` 对应一次尝试,`deferred` 表示补抓未结束,`completed` 的 `cuts` 是该次提交的小切数。宿主拒绝模型压力预算时,配置原因会写入 `spine-decisions.jsonl`。
221
+
222
+ `dsh-live-compact stats` 的 `saved` 是切完当下少掉的 token,`rewrite` 是同一次收尾实际要重写的尾巴,只记一次。同一步连切不会按刀数把尾巴乘上去。这两个数口径不同,比值不是盈亏。桌面端没有终端,`rg "spine cut"` 只在终端输出里找得到。每个 shadow 根的 `spine-cuts.jsonl` 最多保留 1 MiB 最近的完整逐刀明细,累计计数记录在 `spine-stats.json`。
223
+
224
+ POSIX 备份目录所在的文件系统须实际强制 0700/0600 权限。插件会读回目录及文件的权限,并在写正文前拒绝权限不符的备份。
219
225
 
220
226
  改上限:
221
227
 
package/adapter.js CHANGED
@@ -6,6 +6,17 @@
6
6
 
7
7
  export const STOCK_ENGINE = "@deepseek-ai/dsh-compaction-basic";
8
8
 
9
+ const ROOT = Symbol.for("cordis.root");
10
+
11
+ export function contextProperty(ctx, key) {
12
+ try { return ctx?.[key]; } catch { return undefined; }
13
+ }
14
+
15
+ export function rootContext(ctx) {
16
+ const root = contextProperty(ctx, ROOT) ?? contextProperty(ctx, "root") ?? ctx;
17
+ return root && (typeof root === "object" || typeof root === "function") ? root : undefined;
18
+ }
19
+
9
20
  export const loadBase = () => import("@deepseek-ai/dsh-compaction-basic");
10
21
 
11
22
  export const loadCompaction = () => import("@deepseek-ai/dsh-compaction");
package/cordis.patch.yml CHANGED
@@ -1,9 +1,5 @@
1
- # Host stock stays disabled so this engine can register ctx.compaction.
2
- # The entry installs its preset listener before constructing the engine.
1
+ # Keep the host stock entry available until Live Compact has activated.
3
2
  # takeoverPresets controls future preset loads, not existing session engines.
4
- - id: compaction-basic
5
- name: '@deepseek-ai/dsh-compaction-basic'
6
- disabled: true
7
3
  - insert:
8
4
  - id: compaction-spine
9
5
  name: dsh-live-compact
package/gate.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from "node:module";
2
- import { STOCK_ENGINE as STOCK } from "./adapter.js";
2
+ import { contextProperty, rootContext, STOCK_ENGINE as STOCK } from "./adapter.js";
3
3
  import { configSnapshot, engineConfig } from "./settings.js";
4
4
 
5
5
  const OURS = "dsh-live-compact";
@@ -19,7 +19,7 @@ export const PRESET_ENGINE_CONFIG = Object.freeze(engineConfig());
19
19
  export function activeCompactionPeers(ctx) {
20
20
  const peers = [];
21
21
  if (process.env.SPINE_STAND_DOWN === "1") peers.push("SPINE_STAND_DOWN");
22
- const registry = ctx?.registry;
22
+ const registry = contextProperty(ctx, "registry");
23
23
  if (!registry || typeof registry.values !== "function") return peers;
24
24
  try {
25
25
  for (const runtime of registry.values()) {
@@ -40,10 +40,10 @@ export function compactionStandDown(ctx) {
40
40
  return activeCompactionPeers(ctx).length > 0;
41
41
  }
42
42
 
43
- export function warnCompactionStandDown(ctx, logger = ctx?.logger) {
43
+ export function warnCompactionStandDown(ctx, logger = contextProperty(ctx, "logger")) {
44
44
  const peers = activeCompactionPeers(ctx);
45
45
  if (!peers.length) return peers;
46
- const root = ctx?.root || ctx;
46
+ const root = rootContext(ctx);
47
47
  const key = peers.join(",");
48
48
  if (root && standDownNotices.get(root) === key) return peers;
49
49
  if (root) standDownNotices.set(root, key);
@@ -188,21 +188,20 @@ const installedGates = new WeakMap();
188
188
 
189
189
  function entryDepth(ctx) {
190
190
  let depth = 0;
191
- for (let fiber = ctx.fiber; fiber?.runtime; fiber = fiber.parent.fiber) depth++;
191
+ for (let fiber = contextProperty(ctx, "fiber"); fiber?.runtime; fiber = contextProperty(fiber.parent, "fiber")) depth++;
192
192
  return depth;
193
193
  }
194
194
 
195
- export function installPresetGate(ctx, config = {}, { legacy = false } = {}) {
195
+ export function installPresetGate(ctx, config = {}, { legacy = false, deferCommit = false } = {}) {
196
196
  const depth = entryDepth(ctx);
197
- const previous = installedGates.get(ctx.root);
197
+ const root = rootContext(ctx);
198
+ if (!root) throw new Error("spine: Cordis root context unavailable");
199
+ const previous = installedGates.get(root);
198
200
  if (previous) {
199
201
  if (legacy && !previous.legacy) return;
200
202
  if (legacy === previous.legacy && (depth > previous.depth || (depth === previous.depth && previous.active))) return;
201
- previous.active = false;
202
- previous.disposeListener?.();
203
203
  }
204
- const gate = { depth, legacy, active: true };
205
- installedGates.set(ctx.root, gate);
204
+ const gate = { depth, legacy, active: false };
206
205
  ctx.effect(() => () => { gate.active = false; });
207
206
  const enabled = () => {
208
207
  const value = config.takeoverPresets ?? true;
@@ -211,11 +210,11 @@ export function installPresetGate(ctx, config = {}, { legacy = false } = {}) {
211
210
  const seen = new Set();
212
211
  gate.disposeListener = ctx.on("internal/config", function (fiber, next) {
213
212
  const resolved = next();
213
+ if (!gate.active) return resolved;
214
214
  if (compactionStandDown(ctx)) {
215
215
  warnCompactionStandDown(ctx);
216
216
  return resolved;
217
217
  }
218
- if (!gate.active) return resolved;
219
218
  const selector = enabled();
220
219
  if (!selector || (Array.isArray(selector) && selector.length === 0)) return resolved;
221
220
  const loadable = packageLoadable();
@@ -236,6 +235,16 @@ export function installPresetGate(ctx, config = {}, { legacy = false } = {}) {
236
235
  }
237
236
  return rewritten;
238
237
  }, { global: true });
238
+ const commit = () => {
239
+ installedGates.set(root, gate);
240
+ gate.active = true;
241
+ if (previous) {
242
+ previous.active = false;
243
+ try { previous.disposeListener?.()?.catch?.(() => {}); } catch {}
244
+ }
245
+ };
246
+ if (deferCommit) return commit;
247
+ commit();
239
248
  }
240
249
 
241
250
  // Legacy entry for existing compositions; new installs only register compaction-spine.