dsh-context-compression-improved 0.5.2 → 0.5.3

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.
Files changed (28) hide show
  1. package/.gitattributes +1 -0
  2. package/CHANGELOG.ja.md +144 -119
  3. package/CHANGELOG.ko.md +143 -118
  4. package/CHANGELOG.md +278 -250
  5. package/CHANGELOG.zh.md +131 -109
  6. package/docs/installation.md +103 -103
  7. package/docs/installation.zh.md +100 -100
  8. package/package.json +1 -1
  9. package/packages/selector/cordis.patch.yml +5 -6
  10. package/packages/selector/src/client/EstimatorControls.tsx +277 -277
  11. package/packages/selector/src/client/locales.ts +196 -196
  12. package/packages/selector/src/index.ts +463 -463
  13. package/packages/selector/src/pruner/state.ts +50 -50
  14. package/packages/selector/src/pruner.ts +2402 -2402
  15. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +188 -188
  16. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +149 -149
  17. package/packages/selector/src/runtime/tokenpilot/advisor.ts +419 -419
  18. package/packages/selector/src/runtime/tokenpilot/benefit.ts +200 -200
  19. package/packages/selector/tests/advisor-report.host.spec.ts +223 -223
  20. package/packages/selector/tests/public/package-contract.client.spec.ts +20 -0
  21. package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +232 -232
  22. package/packages/selector/tests/runtime/advisor-invariant.spec.ts +272 -272
  23. package/packages/selector/tests/runtime/advisor.spec.ts +226 -226
  24. package/packages/selector/tests/runtime/char-basis.spec.ts +30 -30
  25. package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +96 -96
  26. package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +217 -217
  27. package/packages/selector/tests/settings-seat.client.spec.ts +29 -4
  28. package/scripts/toolclass-corpus-replay.mjs +281 -281
package/CHANGELOG.zh.md CHANGED
@@ -1,109 +1,131 @@
1
- # 更新日志(fork 新增条目)
2
-
3
- > 完整历史(含上游 0.1.0 及更早版本)见 [CHANGELOG.md](CHANGELOG.md)。本文件只翻译本 fork 的新增条目。 · [English](CHANGELOG.md) · [日本語](CHANGELOG.ja.md) · [한국어](CHANGELOG.ko.md)
4
-
5
- ## 0.5.2 - 2026-09-20
6
-
7
- ### Changed
8
-
9
- - **退役**人工审查管线(review gate,beta)。其语义由"建议"取代:收益模型仍按"整批一次
10
- mutation"定价,但它算出的分带(`profitable` / `high-impact` / `slow-payback` /
11
- `unpriceable` / `not-worth-it`)现在只作为 `reduction-advice` 审计记录发布,并在 advisor
12
- 报告路由上留一份快照——绝不扣留、延迟或改写任何 reduction。该 gate 与本功能自身的要求
13
- (缩减不阻断自动处理)相矛盾,且在出厂默认下(`reviewMode` + 4000 token 高影响阈值
14
- 8192 token 的 fresh 门槛)会把整批 fresh 100% 改道进人审,等于让选择开启它的用户失去
15
- 自动路径。建议阈值改为模块常量(α `0.1`、高影响 `4000` token):没有任何路径依据它们
16
- 行动,因此不再作为配置项。
17
- - 随 gate 一并移除:审查队列及其 `storageDomain` 适配器、进程级注册表、
18
- `review-queue` / `review-decide` 两条 HTTP 路由与 `reviewQueueRoute` 部署开关、
19
- `shell.overlay` 客户端浮窗、`reviewMode` / `reviewTimeoutTurns` /
20
- `cacheHitDiscountAlpha` / `reviewHighImpactTokens` 四个 settings 键,以及
21
- `review-outcome` 审计类型。这四个键在**两个解码器**中仍被接受但被忽略——既有配置文档
22
- (线上即带 `reviewMode: false`)照常加载、设置卡照常渲染——且永不进入已解析的 policy。
23
- 只读路由 `GET .../advisor-report` 额外提供 `lastAdvice`。
24
-
25
- ### Added
26
-
27
- - 退役的回归钉桩:一条宿主集成测试用**当年会全量改道的那套配置**(`reviewMode: true`、
28
- `reviewHighImpactTokens: 1`)断言 fresh 批次**照常落地**并附带 `high-impact` 建议记录;
29
- 另一条弃用契约测试在运行时解析器与浏览器解码器两侧钉死"接受但忽略"。
30
-
31
- ### Rollback
32
-
33
- - 回退到仍带 gate 的最后一个版本:`npm dist-tag add
34
- dsh-context-compression-improved@0.5.1 dsh-0.1.5 --registry https://registry.npmjs.org/`,
35
- 然后 `dsh plugin --profile web add dsh-context-compression-improved@0.5.1`。
36
-
37
- ## 0.5.1 - 2026-09-20
38
-
39
- ### Fixed
40
-
41
- - 同一 identity 的并发 preset-overlay 组装在 Windows 上不再失败:发布改为按目标路径串行,
42
- 且当原子 rename 仍然竞争失败时,会先确认目标文件已带有本 staging 文件的
43
- `{mtimeMs, size}` standing key 才判定发布成功。Windows 的 `MoveFileEx` 会把这种竞争
44
- 失败报成 `EPERM`/`EBUSY`,而 POSIX `rename` 只是覆盖目标——这曾导致并发启动会话时
45
- `standingKeyFor()` 抛错。目标不匹配时仍会明确失败,静默复用世代依旧被禁止。
46
- - 一并修复了长期掩盖该问题及其它预存红灯的发布门禁与测试:packed smoke 中陈旧的标识符与
47
- 已退役的审计 reason、过期的客户端 inject 断言,以及仅 Windows 触发的 spawn 陷阱
48
- (`git` 与多行 `node -e` 脚本经 `cmd.exe` 转发会被改写参数)。
49
-
50
- ## 0.5.0 - 2026-09-20
51
-
52
- ### Added
53
-
54
- - 建议型相关度 advisor(仅统计与建议,默认关闭):每个 turn 边界以 fire-and-forget 方式
55
- 运行一次 pass——从最近的 `todo/write` 事件总结尾部任务语义(无 todolist 时回退到最近
56
- 用户文本)、对历史 tool-result 候选做"内容+注释语义 ↔ 当前任务"的增量相关度打分、并
57
- 计算前缀腐化度(prefix-decay,按 characterPressure 加权的相关度均值取反)。低相关的
58
- 旧段标记为 `recertified`,仅作为后续 history 激进化的建议输入——本轮没有任何决策路径
59
- 消费它,且 advisor 输出绝不抑制、延迟或改写任何本应落地的 reduction(有专项不变量测试
60
- 钉死)。经 `presetOptions.advisor*` settings 键配置(`advisorMode` `''|'host'|'direct'`,
61
- 默认 `''`;direct 通道复用 estimator 端点;`SideChannel` 新增可选 overrides 参数,
62
- 共享传输层而不共享配置)。可观测性:新增 `advisor-outcome` 审计记录(content-free,
63
- 每阶段一条:summary / scoring / decay)与只读 HTTP 路由
64
- `GET .../advisor-report?sessionId=`(部署级 opt-in 开关 `advisorReportRoute`,与 review
65
- 路由同骨架)。本轮刻意不提供客户端 UI。
66
-
67
- ## 0.4.0 - 2026-09-20
68
-
69
- ### Fixed
70
-
71
- - 插件不再依赖路由 model id:全部规划闸门改按字符基准决策(Unicode code points,
72
- `characterPressure` / `pressureCost`),不再以 exact tokenizer 计数为前提,
73
- 因此未内建 tokenizer 的路由(线上 `deepseek-flash`)重新能落地改写而不是静默跳过。
74
- token 阈值键名与数值全部保留(按既有 4.0 字符/token 约定换算,冻结 profile 基线零改动);
75
- token 数值降级为遥测,由 rewrite 审计记录新增的 `measurementBasis` 字段如实区分
76
- (`exact-tokenizer` `characters`,派生时写 `tokenizerId: 'characters'` /
77
- `tokenizerRevision: 'chars-per-token-4.0'`)。回滚:确认无后续改动依赖本提交后再执行
78
- `git revert 7a1972a` 整体恢复旧闸门。
79
-
80
- ### Changed
81
-
82
- - runtime 包并入 selector 包:一次安装即可获得完整栈,仓库根目录即为安装面
83
- (`name`、`main`、`types`、`exports`(含 `./pruner`、`./invariant`)、`dependencies`、`dsh`),
84
- 工具链、脚本与 CI 一并收敛为单包。已真机验证的 estimator-catalog 路由注册(双前缀、受保护的
85
- 双通道激活、按请求解析服务、可检索的生命周期日志)重放到本线,并新增宿主侧守门;`ab2175a`
86
- 降级为 `z.any()` settings schema 已还原,每日 Custom 默认值重新下发。
87
- - 在本分支适配官方 DeepSeek Harness `v0.1.5-rc.2`。全部 `@deepseek-ai/dsh-*` 开发依赖与 e2e 官方宿主清单从 `0.1.1-rc.2` 升至 `0.1.5-rc.2`(cordis `4.0.2`、schemastery `3.18.2`),含新的拆分包(`dsh-session-projection`、`dsh-session-persistence`、`dsh-atomic-write`、`dsh-home-paths`、`dsh-sandbox` 等)与 `dsh-client-store` 客户端栈。
88
- - Surface 替换操作改用 v3 的 `startSeq`/`endSeq` 形状与品牌化 `SessionSeq`;`compaction/prune` 清单保留持久化的 `start`/`end` 字段。surface node 事件改为按 seq 查找而非数组下标。
89
- - 客户端 bundle 不再引用已移除的 `@deepseek-ai/dsh-client-runtime`:settings 类型改自 `@deepseek-ai/dsh-client-ui-settings`,会话 hooks 合并自 `@deepseek-ai/dsh-client-ui-session`。两份 package manifest 与 `dsh.plugin.json` 声明 `engines.dsh >=0.1.5-alpha.1 <0.2.0-0`。
90
- - Harness 0.1.5 不再向浏览器暴露会话 `agentPreset`,客户端无法再识别 Minimal 会话;选择器保持可选,旧的不可用横幅不再出现。
91
- - 测试套件按 0.1.5 语义更新:cordis 插件启动需要 `.await()`,Token Meter 需要预先挂载 `SessionProjectionRegistry`,assistant 事件携带 `stream: []`,settings 命名空间为普通字符串。
92
-
93
- ### 修复
94
-
95
- - 估计器卡片在 Harness 宿主通道上不再要求 API Key。选择宿主通道后只显示实时供应商/模型下拉框,并标出当前真正生效的路由(显式覆盖优先,否则跟随会话默认模型);既不显示密钥输入框,也不再有第二个手填模型输入——端点地址、模型文本框与只写密钥均只属于直连端点通道。
96
- - `presetOptions` 改为按路径写入。此前整段写入会替换整个分节,导致再改动估计器的任何一个字段(供应商、模型、端点)都会删掉 `estimatorMode` 及其余全部覆盖值——估计器被静默关回关闭状态,而面板却报告保存成功。现在每个字段只写自己,`undefined` 只清除指名的那一个字段,且 confirm-on-write 校验的是同一组字段而非仅校验通道。
97
- - 新增回归覆盖:`packages/selector/tests/preset-options-write.client.spec.ts`(按路径写入、保留同级字段、显式清除、空改动不写、未提交写入的报错)与 `packages/selector/tests/estimator-channel.client.spec.tsx`(各通道字段、目录下拉框、手填回退)。
98
-
99
-
100
- ### 新增
101
-
102
- - 正交的代码骨架压缩门(`codeSkeleton.enabled`,默认关闭):超大源码类工具结果首次曝光时,可保留导入与声明的骨架——省略函数体并保留错误行——失败时回退到原头部裁剪。这道门独立于所有 Profile,且以精确 tokenizer 测量为前提。
103
- - 选择器设置区内新增该门的开关,附简体中文与英文文案。
104
- - 新增段的浏览器/运行时解码对齐测试、`saveCodeSkeleton` confirm-on-write 契约测试,以及全文档 parity 矩阵扩展。
105
-
106
- ### 变更
107
-
108
- - 新增 ESLint 平铺配置基线(`pnpm lint`,CI 同步强制)与 `pnpm test:watch` TDD 环路;清理死导入,并修复 lint 基线暴露的两处错误处理路径。
109
- - 本仓库现为 `WilliamShi666/dsh-context-compression-selector` 的改进版 fork;文档提供英、简中、日、韩四种语言。
1
+ # 更新日志(fork 新增条目)
2
+
3
+ > 完整历史(含上游 0.1.0 及更早版本)见 [CHANGELOG.md](CHANGELOG.md)。本文件只翻译本 fork 的新增条目。 · [English](CHANGELOG.md) · [日本語](CHANGELOG.ja.md) · [한국어](CHANGELOG.ko.md)
4
+
5
+ ## 0.5.3 - 2026-09-20
6
+
7
+ ### Fixed
8
+
9
+ - Bundle patch 不再设置已退役的 review 路由开关。`reviewQueueRoute` 在 review gate 退役时已从插件的
10
+ Config schema 删除,却仍留在 `packages/selector/cordis.patch.yml` 中,等于宣告了一条永远注册不了的
11
+ 路由。宿主对未知配置键宽容(插件加载与服务均正常,已在真机验证),故属**陈旧配置**而非故障;但任何
12
+ 严格校验插件配置的宿主都会失败。
13
+ - 生成产物钉死为 LF(`packages/selector/lib/** text eol=lf`)。此前在 `core.autocrlf=true` 下,每次
14
+ 检出都会把已提交的 `lib/**` 改写成 CRLF,于是任何分支切换或合并都会让整个产物目录以"仅行尾差异"
15
+ 显示为已修改。该状态从未被提交过,但它让每棵树看起来都是脏的,并且会掩盖真实的产物变更。
16
+
17
+ ### Added
18
+
19
+ - Bundle patch 的**阴性对照**契约钉桩:patch 中一旦设置退役配置键即失败(按"键赋值行"判定,注释里
20
+ 仍可点名该键),并要求在线的 `estimatorCatalogRoute` 开关保持接线。
21
+
22
+ ### Tests
23
+
24
+ - 客户端座位契约补充了老宿主降级钉桩:未声明该 seat 的宿主会在槽边界拒绝注册,`apply()` 必须吞掉该
25
+ 拒绝并告警,而不是把全部设置入口一起弄丢。
26
+
27
+ ## 0.5.2 - 2026-09-20
28
+
29
+ ### Changed
30
+
31
+ - **退役**人工审查管线(review gate,beta)。其语义由"建议"取代:收益模型仍按"整批一次
32
+ mutation"定价,但它算出的分带(`profitable` / `high-impact` / `slow-payback` /
33
+ `unpriceable` / `not-worth-it`)现在只作为 `reduction-advice` 审计记录发布,并在 advisor
34
+ 报告路由上留一份快照——绝不扣留、延迟或改写任何 reduction。该 gate 与本功能自身的要求
35
+ (缩减不阻断自动处理)相矛盾,且在出厂默认下(`reviewMode` + 4000 token 高影响阈值
36
+ 对 8192 token 的 fresh 门槛)会把整批 fresh 100% 改道进人审,等于让选择开启它的用户失去
37
+ 自动路径。建议阈值改为模块常量(α `0.1`、高影响 `4000` token):没有任何路径依据它们
38
+ 行动,因此不再作为配置项。
39
+ - 随 gate 一并移除:审查队列及其 `storageDomain` 适配器、进程级注册表、
40
+ `review-queue` / `review-decide` 两条 HTTP 路由与 `reviewQueueRoute` 部署开关、
41
+ `shell.overlay` 客户端浮窗、`reviewMode` / `reviewTimeoutTurns` /
42
+ `cacheHitDiscountAlpha` / `reviewHighImpactTokens` 四个 settings 键,以及
43
+ `review-outcome` 审计类型。这四个键在**两个解码器**中仍被接受但被忽略——既有配置文档
44
+ (线上即带 `reviewMode: false`)照常加载、设置卡照常渲染——且永不进入已解析的 policy。
45
+ 只读路由 `GET .../advisor-report` 额外提供 `lastAdvice`。
46
+
47
+ ### Added
48
+
49
+ - 退役的回归钉桩:一条宿主集成测试用**当年会全量改道的那套配置**(`reviewMode: true`、
50
+ `reviewHighImpactTokens: 1`)断言 fresh 批次**照常落地**并附带 `high-impact` 建议记录;
51
+ 另一条弃用契约测试在运行时解析器与浏览器解码器两侧钉死"接受但忽略"。
52
+
53
+ ### Rollback
54
+
55
+ - 回退到仍带 gate 的最后一个版本:`npm dist-tag add
56
+ dsh-context-compression-improved@0.5.1 dsh-0.1.5 --registry https://registry.npmjs.org/`,
57
+ 然后 `dsh plugin --profile web add dsh-context-compression-improved@0.5.1`。
58
+
59
+ ## 0.5.1 - 2026-09-20
60
+
61
+ ### Fixed
62
+
63
+ - 同一 identity 的并发 preset-overlay 组装在 Windows 上不再失败:发布改为按目标路径串行,
64
+ 且当原子 rename 仍然竞争失败时,会先确认目标文件已带有本 staging 文件的
65
+ `{mtimeMs, size}` standing key 才判定发布成功。Windows 的 `MoveFileEx` 会把这种竞争
66
+ 失败报成 `EPERM`/`EBUSY`,而 POSIX `rename` 只是覆盖目标——这曾导致并发启动会话时
67
+ `standingKeyFor()` 抛错。目标不匹配时仍会明确失败,静默复用世代依旧被禁止。
68
+ - 一并修复了长期掩盖该问题及其它预存红灯的发布门禁与测试:packed smoke 中陈旧的标识符与
69
+ 已退役的审计 reason、过期的客户端 inject 断言,以及仅 Windows 触发的 spawn 陷阱
70
+ (`git` 与多行 `node -e` 脚本经 `cmd.exe` 转发会被改写参数)。
71
+
72
+ ## 0.5.0 - 2026-09-20
73
+
74
+ ### Added
75
+
76
+ - 建议型相关度 advisor(仅统计与建议,默认关闭):每个 turn 边界以 fire-and-forget 方式
77
+ 运行一次 pass——从最近的 `todo/write` 事件总结尾部任务语义(无 todolist 时回退到最近
78
+ 用户文本)、对历史 tool-result 候选做"内容+注释语义 ↔ 当前任务"的增量相关度打分、并
79
+ 计算前缀腐化度(prefix-decay,按 characterPressure 加权的相关度均值取反)。低相关的
80
+ 旧段标记为 `recertified`,仅作为后续 history 激进化的建议输入——本轮没有任何决策路径
81
+ 消费它,且 advisor 输出绝不抑制、延迟或改写任何本应落地的 reduction(有专项不变量测试
82
+ 钉死)。经 `presetOptions.advisor*` settings 键配置(`advisorMode` `''|'host'|'direct'`,
83
+ 默认 `''`;direct 通道复用 estimator 端点;`SideChannel` 新增可选 overrides 参数,
84
+ 共享传输层而不共享配置)。可观测性:新增 `advisor-outcome` 审计记录(content-free,
85
+ 每阶段一条:summary / scoring / decay)与只读 HTTP 路由
86
+ `GET .../advisor-report?sessionId=`(部署级 opt-in 开关 `advisorReportRoute`,与 review
87
+ 路由同骨架)。本轮刻意不提供客户端 UI。
88
+
89
+ ## 0.4.0 - 2026-09-20
90
+
91
+ ### Fixed
92
+
93
+ - 插件不再依赖路由 model id:全部规划闸门改按字符基准决策(Unicode code points,
94
+ 经 `characterPressure` / `pressureCost`),不再以 exact tokenizer 计数为前提,
95
+ 因此未内建 tokenizer 的路由(线上 `deepseek-flash`)重新能落地改写而不是静默跳过。
96
+ token 阈值键名与数值全部保留(按既有 4.0 字符/token 约定换算,冻结 profile 基线零改动);
97
+ token 数值降级为遥测,由 rewrite 审计记录新增的 `measurementBasis` 字段如实区分
98
+ (`exact-tokenizer` 与 `characters`,派生时写 `tokenizerId: 'characters'` /
99
+ `tokenizerRevision: 'chars-per-token-4.0'`)。回滚:确认无后续改动依赖本提交后再执行
100
+ `git revert 7a1972a` 整体恢复旧闸门。
101
+
102
+ ### Changed
103
+
104
+ - runtime 包并入 selector 包:一次安装即可获得完整栈,仓库根目录即为安装面
105
+ (`name`、`main`、`types`、`exports`(含 `./pruner`、`./invariant`)、`dependencies`、`dsh`),
106
+ 工具链、脚本与 CI 一并收敛为单包。已真机验证的 estimator-catalog 路由注册(双前缀、受保护的
107
+ 双通道激活、按请求解析服务、可检索的生命周期日志)重放到本线,并新增宿主侧守门;`ab2175a`
108
+ 降级为 `z.any()` settings schema 已还原,每日 Custom 默认值重新下发。
109
+ - 在本分支适配官方 DeepSeek Harness `v0.1.5-rc.2`。全部 `@deepseek-ai/dsh-*` 开发依赖与 e2e 官方宿主清单从 `0.1.1-rc.2` 升至 `0.1.5-rc.2`(cordis `4.0.2`、schemastery `3.18.2`),含新的拆分包(`dsh-session-projection`、`dsh-session-persistence`、`dsh-atomic-write`、`dsh-home-paths`、`dsh-sandbox` 等)与 `dsh-client-store` 客户端栈。
110
+ - Surface 替换操作改用 v3 的 `startSeq`/`endSeq` 形状与品牌化 `SessionSeq`;`compaction/prune` 清单保留持久化的 `start`/`end` 字段。surface node 事件改为按 seq 查找而非数组下标。
111
+ - 客户端 bundle 不再引用已移除的 `@deepseek-ai/dsh-client-runtime`:settings 类型改自 `@deepseek-ai/dsh-client-ui-settings`,会话 hooks 合并自 `@deepseek-ai/dsh-client-ui-session`。两份 package manifest 与 `dsh.plugin.json` 声明 `engines.dsh >=0.1.5-alpha.1 <0.2.0-0`。
112
+ - Harness 0.1.5 不再向浏览器暴露会话 `agentPreset`,客户端无法再识别 Minimal 会话;选择器保持可选,旧的不可用横幅不再出现。
113
+ - 测试套件按 0.1.5 语义更新:cordis 插件启动需要 `.await()`,Token Meter 需要预先挂载 `SessionProjectionRegistry`,assistant 事件携带 `stream: []`,settings 命名空间为普通字符串。
114
+
115
+ ### 修复
116
+
117
+ - 估计器卡片在 Harness 宿主通道上不再要求 API Key。选择宿主通道后只显示实时供应商/模型下拉框,并标出当前真正生效的路由(显式覆盖优先,否则跟随会话默认模型);既不显示密钥输入框,也不再有第二个手填模型输入——端点地址、模型文本框与只写密钥均只属于直连端点通道。
118
+ - `presetOptions` 改为按路径写入。此前整段写入会替换整个分节,导致再改动估计器的任何一个字段(供应商、模型、端点)都会删掉 `estimatorMode` 及其余全部覆盖值——估计器被静默关回关闭状态,而面板却报告保存成功。现在每个字段只写自己,`undefined` 只清除指名的那一个字段,且 confirm-on-write 校验的是同一组字段而非仅校验通道。
119
+ - 新增回归覆盖:`packages/selector/tests/preset-options-write.client.spec.ts`(按路径写入、保留同级字段、显式清除、空改动不写、未提交写入的报错)与 `packages/selector/tests/estimator-channel.client.spec.tsx`(各通道字段、目录下拉框、手填回退)。
120
+
121
+
122
+ ### 新增
123
+
124
+ - 正交的代码骨架压缩门(`codeSkeleton.enabled`,默认关闭):超大源码类工具结果首次曝光时,可保留导入与声明的骨架——省略函数体并保留错误行——失败时回退到原头部裁剪。这道门独立于所有 Profile,且以精确 tokenizer 测量为前提。
125
+ - 选择器设置区内新增该门的开关,附简体中文与英文文案。
126
+ - 新增段的浏览器/运行时解码对齐测试、`saveCodeSkeleton` 的 confirm-on-write 契约测试,以及全文档 parity 矩阵扩展。
127
+
128
+ ### 变更
129
+
130
+ - 新增 ESLint 平铺配置基线(`pnpm lint`,CI 同步强制)与 `pnpm test:watch` TDD 环路;清理死导入,并修复 lint 基线暴露的两处错误处理路径。
131
+ - 本仓库现为 `WilliamShi666/dsh-context-compression-selector` 的改进版 fork;文档提供英、简中、日、韩四种语言。
@@ -1,103 +1,103 @@
1
- # Installing dsh-context-compression-improved
2
-
3
- > [English](installation.md) · [中文](installation.zh.md) · [日本語](installation.ja.md) · [한국어](installation.ko.md)
4
-
5
- This guide installs the fork from source. The fork is published to npm as
6
- `dsh-context-compression-improved` under the `dsh-0.1.5` dist-tag; the package name
7
- intentionally stays upstream's. The runtime that used to be a second package is now part of
8
- it, so one install brings the whole stack.
9
-
10
- ## Prerequisites
11
-
12
- - Node `^22.19.0 || >=24` and pnpm `11.7.0` (`corepack enable` picks the pinned version from `packageManager`).
13
- - A DeepSeek Harness installation compatible with the `0.1.1-rc.2` peer range (verified against the official `dsh-v0.1.2-alpha.5` release).
14
- - A DeepSeek model route. Lossy compression — including the code-skeleton gate — decides on the character basis, so no bundled-tokenizer route requirement remains; when a bundled tokenizer exists its exact counts are recorded as telemetry, and other routes fail open and keep original tool results.
15
- - Git.
16
-
17
- ## 1. Build from source
18
-
19
- ```sh
20
- git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
21
- cd dsh-context-compression-improved
22
- pnpm install --frozen-lockfile
23
- pnpm build
24
- ```
25
-
26
- `pnpm build` bundles both library faces of every package (`tsdown`). Run `pnpm test` first if you want the full suite on your machine before installing.
27
-
28
- ## 2. Pack the Bundle entry package
29
-
30
- The selector package is the single Bundle entry; the runtime comes along as its exact-version dependency:
31
-
32
- ```sh
33
- cd packages/selector
34
- pnpm pack
35
- # → dsh-context-compression-improved-0.1.0.tgz
36
- cd ../..
37
- ```
38
-
39
- `pnpm pack` runs the bundle through the `prepack` hook, so the tarball always matches your checkout.
40
-
41
- ## 3. Add it to a Harness profile
42
-
43
- The selector package declares the Harness Bundle manifest field `dsh.bundle.patch`, so `dsh plugin add` is the standard out-of-tree Bundle installation path:
44
-
45
- ```sh
46
- dsh plugin --profile web add packages/selector/dsh-context-compression-improved-0.1.0.tgz
47
- dsh --profile web --dump-config
48
- ```
49
-
50
- Restart the selected profile after installation. The config dump should list the selector Bundle as active. Do **not** install or wire the selector and runtime packages separately — the runtime is installed automatically.
51
-
52
- ## 4. Turn on the code-skeleton gate
53
-
54
- Open DeepSeek Harness settings → **Context compression selector**:
55
-
56
- 1. Pick a compression profile (the gate is orthogonal to all of them).
57
- 2. Optionally adjust the Auto Compact trigger level (50–90%, default 80%).
58
- 3. Set **Code skeleton compression** to **On**. The toggle saves on change.
59
-
60
- Like all selector settings, the value is frozen when a session first observes it — the gate affects newly observed sessions, never a task that is already running.
61
-
62
- ## 5. Optional: the advisory relevance advisor
63
-
64
- The plugin can keep statistics about how relevant the session's history still is — advisory only, it never decides or blocks anything. It is off by default; turn it on by editing the `presetOptions` section of the context-compression settings (settings JSON, no UI card this round):
65
-
66
- ```json
67
- "presetOptions": {
68
- "advisorMode": "host",
69
- "advisorRefreshTurns": 8,
70
- "advisorScoreThreshold": 0.35,
71
- "advisorSampleLimit": 16,
72
- "advisorMinTokens": 250,
73
- "advisorTimeoutMs": 8000
74
- }
75
- ```
76
-
77
- `advisorMode: "host"` calls the harness `llm` service; `"direct"` reuses the estimator's
78
- `estimatorBaseUrl` / `estimatorApiKey` / `estimatorModel` endpoint. At every turn boundary
79
- the advisor (1) summarizes the current task from the most recent `todo/write` event,
80
- (2) incrementally scores historical tool results for content-and-comment relevance, and
81
- (3) records a prefix-decay figure. Results surface as `advisor-outcome` audit records and,
82
- with the deployment flag `advisorReportRoute: true`, a read-only
83
- `GET .../advisor-report?sessionId=` HTTP route. What the advisor reports can never
84
- suppress, delay, or rewrite any reduction that would land.
85
-
86
- ## 6. Update or remove
87
-
88
- ```sh
89
- # update: pull, rebuild, repack, and add the new tarball again
90
- git pull && pnpm install --frozen-lockfile && pnpm build
91
- cd packages/selector && pnpm pack && cd ../..
92
- dsh plugin --profile web add packages/selector/dsh-context-compression-improved-0.1.0.tgz
93
-
94
- # remove
95
- dsh plugin --profile web remove dsh-context-compression-improved
96
- ```
97
-
98
- ## Troubleshooting
99
-
100
- - **Bundle not active in the dump**: restart the profile; confirm you added the selector entry package (not the runtime) and that the Harness version is in the compatible peer range.
101
- - **Tool results are never skeleton-compressed**: the gate is off by default; check the toggle. Compression only applies to fresh, oversized source-code tool results (decisions run on the character basis; no exact-tokenizer route requirement), and every skip is recorded with a reason in the audit trail.
102
- - **The toggle shows as unreadable**: the stored `codeSkeleton` section failed the strict browser decode (it must be exactly `{ enabled: boolean }`). Removing the malformed section restores defaults.
103
- - **Updating fails on the upgrade step**: the plugin follows npm package semantics; remove the old version first if a tarball-to-tarball upgrade is refused by your Harness build.
1
+ # Installing dsh-context-compression-improved
2
+
3
+ > [English](installation.md) · [中文](installation.zh.md) · [日本語](installation.ja.md) · [한국어](installation.ko.md)
4
+
5
+ This guide installs the fork from source. The fork is published to npm as
6
+ `dsh-context-compression-improved` under the `dsh-0.1.5` dist-tag; the package name
7
+ intentionally stays upstream's. The runtime that used to be a second package is now part of
8
+ it, so one install brings the whole stack.
9
+
10
+ ## Prerequisites
11
+
12
+ - Node `^22.19.0 || >=24` and pnpm `11.7.0` (`corepack enable` picks the pinned version from `packageManager`).
13
+ - A DeepSeek Harness installation compatible with the `0.1.1-rc.2` peer range (verified against the official `dsh-v0.1.2-alpha.5` release).
14
+ - A DeepSeek model route. Lossy compression — including the code-skeleton gate — decides on the character basis, so no bundled-tokenizer route requirement remains; when a bundled tokenizer exists its exact counts are recorded as telemetry, and other routes fail open and keep original tool results.
15
+ - Git.
16
+
17
+ ## 1. Build from source
18
+
19
+ ```sh
20
+ git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
21
+ cd dsh-context-compression-improved
22
+ pnpm install --frozen-lockfile
23
+ pnpm build
24
+ ```
25
+
26
+ `pnpm build` bundles both library faces of every package (`tsdown`). Run `pnpm test` first if you want the full suite on your machine before installing.
27
+
28
+ ## 2. Pack the Bundle entry package
29
+
30
+ The selector package is the single Bundle entry; the runtime comes along as its exact-version dependency:
31
+
32
+ ```sh
33
+ cd packages/selector
34
+ pnpm pack
35
+ # → dsh-context-compression-improved-0.1.0.tgz
36
+ cd ../..
37
+ ```
38
+
39
+ `pnpm pack` runs the bundle through the `prepack` hook, so the tarball always matches your checkout.
40
+
41
+ ## 3. Add it to a Harness profile
42
+
43
+ The selector package declares the Harness Bundle manifest field `dsh.bundle.patch`, so `dsh plugin add` is the standard out-of-tree Bundle installation path:
44
+
45
+ ```sh
46
+ dsh plugin --profile web add packages/selector/dsh-context-compression-improved-0.1.0.tgz
47
+ dsh --profile web --dump-config
48
+ ```
49
+
50
+ Restart the selected profile after installation. The config dump should list the selector Bundle as active. Do **not** install or wire the selector and runtime packages separately — the runtime is installed automatically.
51
+
52
+ ## 4. Turn on the code-skeleton gate
53
+
54
+ Open DeepSeek Harness settings → **Context compression selector**:
55
+
56
+ 1. Pick a compression profile (the gate is orthogonal to all of them).
57
+ 2. Optionally adjust the Auto Compact trigger level (50–90%, default 80%).
58
+ 3. Set **Code skeleton compression** to **On**. The toggle saves on change.
59
+
60
+ Like all selector settings, the value is frozen when a session first observes it — the gate affects newly observed sessions, never a task that is already running.
61
+
62
+ ## 5. Optional: the advisory relevance advisor
63
+
64
+ The plugin can keep statistics about how relevant the session's history still is — advisory only, it never decides or blocks anything. It is off by default; turn it on by editing the `presetOptions` section of the context-compression settings (settings JSON, no UI card this round):
65
+
66
+ ```json
67
+ "presetOptions": {
68
+ "advisorMode": "host",
69
+ "advisorRefreshTurns": 8,
70
+ "advisorScoreThreshold": 0.35,
71
+ "advisorSampleLimit": 16,
72
+ "advisorMinTokens": 250,
73
+ "advisorTimeoutMs": 8000
74
+ }
75
+ ```
76
+
77
+ `advisorMode: "host"` calls the harness `llm` service; `"direct"` reuses the estimator's
78
+ `estimatorBaseUrl` / `estimatorApiKey` / `estimatorModel` endpoint. At every turn boundary
79
+ the advisor (1) summarizes the current task from the most recent `todo/write` event,
80
+ (2) incrementally scores historical tool results for content-and-comment relevance, and
81
+ (3) records a prefix-decay figure. Results surface as `advisor-outcome` audit records and,
82
+ with the deployment flag `advisorReportRoute: true`, a read-only
83
+ `GET .../advisor-report?sessionId=` HTTP route. What the advisor reports can never
84
+ suppress, delay, or rewrite any reduction that would land.
85
+
86
+ ## 6. Update or remove
87
+
88
+ ```sh
89
+ # update: pull, rebuild, repack, and add the new tarball again
90
+ git pull && pnpm install --frozen-lockfile && pnpm build
91
+ cd packages/selector && pnpm pack && cd ../..
92
+ dsh plugin --profile web add packages/selector/dsh-context-compression-improved-0.1.0.tgz
93
+
94
+ # remove
95
+ dsh plugin --profile web remove dsh-context-compression-improved
96
+ ```
97
+
98
+ ## Troubleshooting
99
+
100
+ - **Bundle not active in the dump**: restart the profile; confirm you added the selector entry package (not the runtime) and that the Harness version is in the compatible peer range.
101
+ - **Tool results are never skeleton-compressed**: the gate is off by default; check the toggle. Compression only applies to fresh, oversized source-code tool results (decisions run on the character basis; no exact-tokenizer route requirement), and every skip is recorded with a reason in the audit trail.
102
+ - **The toggle shows as unreadable**: the stored `codeSkeleton` section failed the strict browser decode (it must be exactly `{ enabled: boolean }`). Removing the malformed section restores defaults.
103
+ - **Updating fails on the upgrade step**: the plugin follows npm package semantics; remove the old version first if a tarball-to-tarball upgrade is refused by your Harness build.