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
@@ -1,100 +1,100 @@
1
- # 安装 dsh-context-compression-improved
2
-
3
- > [English](installation.md) · [中文](installation.zh.md) · [日本語](installation.ja.md) · [한국어](installation.ko.md)
4
-
5
- 本教程从源码安装 fork。fork 亦已发布到 npm,dist-tag 为 `dsh-0.1.5`;包名有意与上游保持一致:
6
- `dsh-context-compression-improved`(单一包 —— 原先独立发布的 runtime 包已并入其中)。
7
-
8
- ## 前置条件
9
-
10
- - Node `^22.19.0 || >=24` 与 pnpm `11.7.0`(`corepack enable` 会按 `packageManager` 字段使用固定版本)。
11
- - 兼容 `0.1.1-rc.2` peer 范围的 DeepSeek Harness(已针对官方 `dsh-v0.1.2-alpha.5` 验证)。
12
- - DeepSeek 模型路由。有损压缩——包括代码骨架门——按字符基准决策,不再要求内建精确 tokenizer;存在内建 tokenizer 时其 exact 计数仅作遥测记录,其他路由 fail-open 并保留原始工具结果。
13
- - Git。
14
-
15
- ## 1. 从源码构建
16
-
17
- ```sh
18
- git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
19
- cd dsh-context-compression-improved
20
- pnpm install --frozen-lockfile
21
- pnpm build
22
- ```
23
-
24
- `pnpm build` 会打包所有包的两套产物(`tsdown`)。如需在安装前先跑全量测试,可执行 `pnpm test`。
25
-
26
- ## 2. 打包 Bundle 入口包
27
-
28
- selector 包是唯一的 Bundle 入口;runtime 作为其精确版本依赖自动随行:
29
-
30
- ```sh
31
- cd packages/selector
32
- pnpm pack
33
- # → dsh-context-compression-improved-0.1.0.tgz
34
- cd ../..
35
- ```
36
-
37
- `pnpm pack` 会通过 `prepack` 钩子执行打包,因此 tarball 始终与你的检出内容一致。
38
-
39
- ## 3. 安装到 Harness Profile
40
-
41
- selector 包声明了 Harness Bundle manifest 字段 `dsh.bundle.patch`,因此 `dsh plugin add` 是标准的树外 Bundle 安装方式:
42
-
43
- ```sh
44
- dsh plugin --profile web add packages/selector/dsh-context-compression-improved-0.1.0.tgz
45
- dsh --profile web --dump-config
46
- ```
47
-
48
- 安装后重启对应 Profile。配置导出中应显示 selector Bundle 已激活。**不要**分别安装或手动连接 selector 与 runtime 两个包——runtime 会自动安装。
49
-
50
- ## 4. 打开代码骨架门
51
-
52
- 打开 DeepSeek Harness 设置 → **上下文压缩选择器*:
53
-
54
- 1. 选择一个压缩 Profile(这道门与所有 Profile 正交)。
55
- 2. 按需调整 Auto Compact 触发水位(50–90%,默认 80%)。
56
- 3. 将**代码骨架压缩**设为**开**。开关即改即存。
57
-
58
- 与所有选择器设置一致,取值在会话首次观察时冻结——这道门只影响新观察的会话,不会改变正在运行的任务。
59
-
60
- ## 5. 可选:建议型相关度 advisor
61
-
62
- 插件可以对"会话历史还有多相关"做统计——仅建议性质,不做任何决策、也不阻断任何流程。默认关闭;本轮没有设置卡片,请直接编辑上下文压缩设置中的 `presetOptions` 段(settings JSON):
63
-
64
- ```json
65
- "presetOptions": {
66
- "advisorMode": "host",
67
- "advisorRefreshTurns": 8,
68
- "advisorScoreThreshold": 0.35,
69
- "advisorSampleLimit": 16,
70
- "advisorMinTokens": 250,
71
- "advisorTimeoutMs": 8000
72
- }
73
- ```
74
-
75
- `advisorMode: "host"` 走 harness `llm` 服务;`"direct"` 复用 estimator 的
76
- `estimatorBaseUrl` / `estimatorApiKey` / `estimatorModel` 端点。每个 turn 边界,advisor
77
- 会:(1) 从最近的 `todo/write` 事件总结当前任务语义;(2) 对历史 tool result 做"内容+注释
78
- 语义 ↔ 当前任务"的增量相关度打分;(3) 记录前缀腐化度(prefix-decay)。结果以
79
- `advisor-outcome` 审计记录呈现;部署配置打开 `advisorReportRoute: true` 后,还可经只读
80
- HTTP 路由 `GET .../advisor-report?sessionId=` 读取。advisor 报告的任何内容都不会抑制、
81
- 延迟或改写任何本应落地的 reduction。
82
-
83
- ## 6. 更新或卸载
84
-
85
- ```sh
86
- # 更新:拉取、重建、重新打包、再次添加新 tarball
87
- git pull && pnpm install --frozen-lockfile && pnpm build
88
- cd packages/selector && pnpm pack && cd ../..
89
- dsh plugin --profile web add packages/selector/dsh-context-compression-improved-0.1.0.tgz
90
-
91
- # 卸载
92
- dsh plugin --profile web remove dsh-context-compression-improved
93
- ```
94
-
95
- ## 故障排除
96
-
97
- - **配置导出中 Bundle 未激活**:重启 Profile;确认添加的是 selector 入口包(而非 runtime),且 Harness 版本在兼容的 peer 范围内。
98
- - **工具结果从未被骨架化压缩**:该门默认关闭,请检查开关。压缩只作用于新鲜、超大、源码类的工具结果(决策按字符基准执行,无精确 tokenizer 路由要求),且每次跳过都会在审计记录中留有原因。
99
- - **开关显示为不可读**:已存的 `codeSkeleton` 段未通过严格的浏览器解码(必须恰好是 `{ enabled: boolean }`)。删除畸形段即可恢复默认。
100
- - **升级步骤失败**:插件遵循 npm 包语义;如果你的 Harness 构建拒绝 tarball 到 tarball 的升级,请先移除旧版本再安装。
1
+ # 安装 dsh-context-compression-improved
2
+
3
+ > [English](installation.md) · [中文](installation.zh.md) · [日本語](installation.ja.md) · [한국어](installation.ko.md)
4
+
5
+ 本教程从源码安装 fork。fork 亦已发布到 npm,dist-tag 为 `dsh-0.1.5`;包名有意与上游保持一致:
6
+ `dsh-context-compression-improved`(单一包 —— 原先独立发布的 runtime 包已并入其中)。
7
+
8
+ ## 前置条件
9
+
10
+ - Node `^22.19.0 || >=24` 与 pnpm `11.7.0`(`corepack enable` 会按 `packageManager` 字段使用固定版本)。
11
+ - 兼容 `0.1.1-rc.2` peer 范围的 DeepSeek Harness(已针对官方 `dsh-v0.1.2-alpha.5` 验证)。
12
+ - DeepSeek 模型路由。有损压缩——包括代码骨架门——按字符基准决策,不再要求内建精确 tokenizer;存在内建 tokenizer 时其 exact 计数仅作遥测记录,其他路由 fail-open 并保留原始工具结果。
13
+ - Git。
14
+
15
+ ## 1. 从源码构建
16
+
17
+ ```sh
18
+ git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
19
+ cd dsh-context-compression-improved
20
+ pnpm install --frozen-lockfile
21
+ pnpm build
22
+ ```
23
+
24
+ `pnpm build` 会打包所有包的两套产物(`tsdown`)。如需在安装前先跑全量测试,可执行 `pnpm test`。
25
+
26
+ ## 2. 打包 Bundle 入口包
27
+
28
+ selector 包是唯一的 Bundle 入口;runtime 作为其精确版本依赖自动随行:
29
+
30
+ ```sh
31
+ cd packages/selector
32
+ pnpm pack
33
+ # → dsh-context-compression-improved-0.1.0.tgz
34
+ cd ../..
35
+ ```
36
+
37
+ `pnpm pack` 会通过 `prepack` 钩子执行打包,因此 tarball 始终与你的检出内容一致。
38
+
39
+ ## 3. 安装到 Harness Profile
40
+
41
+ selector 包声明了 Harness Bundle manifest 字段 `dsh.bundle.patch`,因此 `dsh plugin add` 是标准的树外 Bundle 安装方式:
42
+
43
+ ```sh
44
+ dsh plugin --profile web add packages/selector/dsh-context-compression-improved-0.1.0.tgz
45
+ dsh --profile web --dump-config
46
+ ```
47
+
48
+ 安装后重启对应 Profile。配置导出中应显示 selector Bundle 已激活。**不要**分别安装或手动连接 selector 与 runtime 两个包——runtime 会自动安装。
49
+
50
+ ## 4. 打开代码骨架门
51
+
52
+ 打开 DeepSeek Harness 设置 → **上下文压缩选择器*:
53
+
54
+ 1. 选择一个压缩 Profile(这道门与所有 Profile 正交)。
55
+ 2. 按需调整 Auto Compact 触发水位(50–90%,默认 80%)。
56
+ 3. 将**代码骨架压缩**设为**开**。开关即改即存。
57
+
58
+ 与所有选择器设置一致,取值在会话首次观察时冻结——这道门只影响新观察的会话,不会改变正在运行的任务。
59
+
60
+ ## 5. 可选:建议型相关度 advisor
61
+
62
+ 插件可以对"会话历史还有多相关"做统计——仅建议性质,不做任何决策、也不阻断任何流程。默认关闭;本轮没有设置卡片,请直接编辑上下文压缩设置中的 `presetOptions` 段(settings JSON):
63
+
64
+ ```json
65
+ "presetOptions": {
66
+ "advisorMode": "host",
67
+ "advisorRefreshTurns": 8,
68
+ "advisorScoreThreshold": 0.35,
69
+ "advisorSampleLimit": 16,
70
+ "advisorMinTokens": 250,
71
+ "advisorTimeoutMs": 8000
72
+ }
73
+ ```
74
+
75
+ `advisorMode: "host"` 走 harness `llm` 服务;`"direct"` 复用 estimator 的
76
+ `estimatorBaseUrl` / `estimatorApiKey` / `estimatorModel` 端点。每个 turn 边界,advisor
77
+ 会:(1) 从最近的 `todo/write` 事件总结当前任务语义;(2) 对历史 tool result 做"内容+注释
78
+ 语义 ↔ 当前任务"的增量相关度打分;(3) 记录前缀腐化度(prefix-decay)。结果以
79
+ `advisor-outcome` 审计记录呈现;部署配置打开 `advisorReportRoute: true` 后,还可经只读
80
+ HTTP 路由 `GET .../advisor-report?sessionId=` 读取。advisor 报告的任何内容都不会抑制、
81
+ 延迟或改写任何本应落地的 reduction。
82
+
83
+ ## 6. 更新或卸载
84
+
85
+ ```sh
86
+ # 更新:拉取、重建、重新打包、再次添加新 tarball
87
+ git pull && pnpm install --frozen-lockfile && pnpm build
88
+ cd packages/selector && pnpm pack && cd ../..
89
+ dsh plugin --profile web add packages/selector/dsh-context-compression-improved-0.1.0.tgz
90
+
91
+ # 卸载
92
+ dsh plugin --profile web remove dsh-context-compression-improved
93
+ ```
94
+
95
+ ## 故障排除
96
+
97
+ - **配置导出中 Bundle 未激活**:重启 Profile;确认添加的是 selector 入口包(而非 runtime),且 Harness 版本在兼容的 peer 范围内。
98
+ - **工具结果从未被骨架化压缩**:该门默认关闭,请检查开关。压缩只作用于新鲜、超大、源码类的工具结果(决策按字符基准执行,无精确 tokenizer 路由要求),且每次跳过都会在审计记录中留有原因。
99
+ - **开关显示为不可读**:已存的 `codeSkeleton` 段未通过严格的浏览器解码(必须恰好是 `{ enabled: boolean }`)。删除畸形段即可恢复默认。
100
+ - **升级步骤失败**:插件遵循 npm 包语义;如果你的 Harness 构建拒绝 tarball 到 tarball 的升级,请先移除旧版本再安装。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-context-compression-improved",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org",
6
6
  "access": "public",
@@ -14,15 +14,14 @@
14
14
  # announcing a pending route on a webServer-less profile. The two-channel
15
15
  # registration inside the plugin covers both arrival orders on its own.
16
16
  #
17
- # `reviewQueueRoute` belongs here and not on the bundle row: it gates the
18
- # R4 human-review endpoints (`/review-queue`, `/review-decide`) and was
19
- # never turned on, so the review overlay polled two 404s and the panel
20
- # could not open. Both flags are set on exactly one row, so each route is
21
- # registered exactly once.
17
+ # `estimatorCatalogRoute` is the only flag this row sets. The retired
18
+ # review gate's `reviewQueueRoute` used to live here; that key no longer
19
+ # exists in the plugin's Config schema (a reduction must never block
20
+ # automatic processing), so setting it would advertise a route that can
21
+ # never register.
22
22
  - id: context-compression-improved-estimator-catalog
23
23
  name: 'dsh-context-compression-improved'
24
24
  inject:
25
25
  - webServer
26
26
  config:
27
27
  estimatorCatalogRoute: true
28
- reviewQueueRoute: true