dsh-context-compression-improved 0.7.0-beta.1 → 0.8.0-beta.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.de.md +539 -0
- package/CHANGELOG.es.md +547 -0
- package/CHANGELOG.fr.md +534 -0
- package/CHANGELOG.it.md +536 -0
- package/CHANGELOG.ja.md +226 -220
- package/CHANGELOG.ko.md +220 -214
- package/CHANGELOG.md +372 -376
- package/CHANGELOG.ru.md +517 -0
- package/CHANGELOG.zh.md +204 -199
- package/README.de.md +98 -0
- package/README.es.md +98 -0
- package/README.fr.md +98 -0
- package/README.it.md +98 -0
- package/README.ja.md +85 -85
- package/README.ko.md +85 -85
- package/README.md +98 -97
- package/README.ru.md +98 -0
- package/README.zh.md +85 -86
- package/docs/installation.de.md +104 -0
- package/docs/installation.es.md +104 -0
- package/docs/installation.fr.md +104 -0
- package/docs/installation.it.md +104 -0
- package/docs/installation.ja.md +78 -78
- package/docs/installation.ko.md +78 -78
- package/docs/installation.md +103 -103
- package/docs/installation.ru.md +104 -0
- package/docs/installation.zh.md +100 -100
- package/eslint.config.js +30 -76
- package/package.json +69 -70
- package/packages/selector/dsh.plugin.json +2 -2
- package/packages/selector/lib/{intent-gate.js → advisor-state.js} +3 -91
- package/packages/selector/lib/client.js +736 -14
- package/packages/selector/lib/index.js +1 -92
- package/packages/selector/lib/profiles.d.ts +0 -9
- package/packages/selector/lib/pruner.d.ts +0 -59
- package/packages/selector/lib/pruner.js +7 -410
- package/packages/selector/lib/style.css +46 -46
- package/packages/selector/package.json +114 -114
- package/packages/selector/src/client/decode.ts +2 -6
- package/packages/selector/src/client/index.ts +244 -213
- package/packages/selector/src/client/locales/de.ts +98 -0
- package/packages/selector/src/client/locales/es.ts +98 -0
- package/packages/selector/src/client/locales/fr.ts +98 -0
- package/packages/selector/src/client/locales/it.ts +98 -0
- package/packages/selector/src/client/locales/ja.ts +98 -0
- package/packages/selector/src/client/locales/ko.ts +98 -0
- package/packages/selector/src/client/locales/ru.ts +98 -0
- package/packages/selector/src/deepseek-v4-tokenizer.ts +1 -1
- package/packages/selector/src/index.ts +411 -418
- package/packages/selector/src/preset-overlay.ts +0 -3
- package/packages/selector/src/profiles.ts +10 -30
- package/packages/selector/src/pruner/content.ts +1 -1
- package/packages/selector/src/pruner/state.ts +0 -7
- package/packages/selector/src/pruner.ts +9 -253
- package/packages/selector/src/runtime/audit.ts +0 -17
- package/packages/selector/src/runtime/config.ts +11 -36
- package/packages/selector/src/runtime/reducers.ts +1 -1
- package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +1 -46
- package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +0 -55
- package/packages/selector/src/runtime/tokenpilot/locator.ts +2 -2
- package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +1 -4
- package/packages/selector/src/runtime/types.ts +0 -12
- package/packages/selector/tests/auto-compact.client.spec.tsx +213 -214
- package/packages/selector/tests/built/client-artifact.spec.ts +59 -61
- package/packages/selector/tests/code-skeleton.client.spec.ts +93 -94
- package/packages/selector/tests/custom-contract.client.spec.ts +222 -223
- package/packages/selector/tests/estimator-channel.client.spec.tsx +252 -252
- package/packages/selector/tests/host-preset-overlay.host.spec.ts +204 -204
- package/packages/selector/tests/preset-options-write.client.spec.ts +187 -188
- package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +200 -200
- package/packages/selector/tests/profiles.client.spec.tsx +434 -436
- package/packages/selector/tests/public/package-contract.client.spec.ts +78 -78
- package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +230 -230
- package/packages/selector/tests/runtime/audit.spec.ts +274 -275
- package/packages/selector/tests/runtime/auto-compact-config.spec.ts +3 -3
- package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +4 -4
- package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2731 -2736
- package/packages/selector/tests/standing-generation.host.spec.ts +724 -704
- package/pnpm-workspace.yaml +66 -66
- package/scripts/packed-components-smoke.mjs +0 -2
- package/scripts/packed-install-e2e.mjs +5 -7
- package/scripts/verify-release.mjs +2 -3
- package/tests/TEST_INVENTORY.md +41 -41
- package/tsconfig.tests.json +1 -3
- package/vitest.config.ts +0 -14
- package/packages/selector/src/runtime/summary-command.ts +0 -133
- package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +0 -53
- package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +0 -65
- package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +0 -125
- package/packages/selector/src/runtime/tokenpilot/intent-range.ts +0 -37
- package/packages/selector/tests/runtime/intent-gate.spec.ts +0 -62
- package/packages/selector/tests/runtime/intent-summary.spec.ts +0 -156
- package/packages/selector/tests/runtime/summary-command.spec.ts +0 -154
package/docs/installation.zh.md
CHANGED
|
@@ -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) · [Français](installation.fr.md) · [Deutsch](installation.de.md) · [Italiano](installation.it.md) · [Русский](installation.ru.md) · [Español](installation.es.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/eslint.config.js
CHANGED
|
@@ -1,76 +1,30 @@
|
|
|
1
|
-
import js from '@eslint/js'
|
|
2
|
-
import globals from 'globals'
|
|
3
|
-
import tseslint from 'typescript-eslint'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// project, so type-checked rules cannot run on it.
|
|
32
|
-
'packages/selector/tests/helpers/legacy-settings/**',
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
js.configs.recommended,
|
|
36
|
-
...tseslint.configs.recommendedTypeChecked,
|
|
37
|
-
{
|
|
38
|
-
// First-party TypeScript: full type-checked strength. Everything linted
|
|
39
|
-
// here is included in tsconfig.tests.json (the only root-level project).
|
|
40
|
-
files: ['packages/**/*.ts', 'packages/**/*.tsx', 'vitest.config.ts', 'vitest.built.config.ts'],
|
|
41
|
-
languageOptions: {
|
|
42
|
-
globals: { ...globals.browser, ...globals.node },
|
|
43
|
-
parserOptions: {
|
|
44
|
-
project: ['tsconfig.tests.json'],
|
|
45
|
-
tsconfigRootDir: import.meta.dirname,
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
rules: { '@typescript-eslint/no-unused-vars': noUnusedVars },
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
// Spec files implement mock async methods purely to satisfy typed host
|
|
52
|
-
// interfaces; requiring an await inside every one of them is noise.
|
|
53
|
-
files: ['packages/selector/tests/**'],
|
|
54
|
-
rules: { '@typescript-eslint/require-await': 'off', ...noUnsafeFamily },
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
// Standalone .mjs gate scripts live outside every tsconfig; the default
|
|
58
|
-
// project gives type-checked rules a loose type surface to work with.
|
|
59
|
-
files: ['scripts/**/*.{js,mjs}', 'eslint.config.js'],
|
|
60
|
-
languageOptions: {
|
|
61
|
-
globals: { ...globals.browser, ...globals.node },
|
|
62
|
-
parserOptions: {
|
|
63
|
-
projectService: {
|
|
64
|
-
allowDefaultProject: ['eslint.config.js', 'scripts/*.mjs'],
|
|
65
|
-
},
|
|
66
|
-
tsconfigRootDir: import.meta.dirname,
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
rules: { '@typescript-eslint/no-unused-vars': noUnusedVars, ...noUnsafeFamily },
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
// Terminal normalization intentionally matches ANSI/BEL control characters.
|
|
73
|
-
files: ['packages/selector/src/runtime/reducers.ts'],
|
|
74
|
-
rules: { 'no-control-regex': 'off' },
|
|
75
|
-
},
|
|
76
|
-
)
|
|
1
|
+
import js from '@eslint/js'
|
|
2
|
+
import globals from 'globals'
|
|
3
|
+
import tseslint from 'typescript-eslint'
|
|
4
|
+
|
|
5
|
+
export default tseslint.config(
|
|
6
|
+
{
|
|
7
|
+
ignores: ['**/node_modules/**', '**/lib/**', '**/dist/**', '**/coverage/**', 'docs/**'],
|
|
8
|
+
},
|
|
9
|
+
js.configs.recommended,
|
|
10
|
+
...tseslint.configs.recommended,
|
|
11
|
+
{
|
|
12
|
+
files: ['packages/**/*.{ts,tsx}', 'scripts/**/*.{js,mjs}', 'eslint.config.js'],
|
|
13
|
+
languageOptions: {
|
|
14
|
+
globals: { ...globals.browser, ...globals.node },
|
|
15
|
+
},
|
|
16
|
+
rules: {
|
|
17
|
+
'@typescript-eslint/no-unused-vars': ['error', {
|
|
18
|
+
argsIgnorePattern: '^_',
|
|
19
|
+
varsIgnorePattern: '^_',
|
|
20
|
+
caughtErrorsIgnorePattern: '^_',
|
|
21
|
+
destructuredArrayIgnorePattern: '^_',
|
|
22
|
+
}],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
// Terminal normalization intentionally matches ANSI/BEL control characters.
|
|
27
|
+
files: ['packages/selector/src/runtime/reducers.ts'],
|
|
28
|
+
rules: { 'no-control-regex': 'off' },
|
|
29
|
+
},
|
|
30
|
+
)
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-context-compression-improved",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-beta.2",
|
|
4
4
|
"publishConfig": {
|
|
5
|
-
"tag": "dsh-0.
|
|
5
|
+
"tag": "dsh-0.2.0"
|
|
6
6
|
},
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "packages/selector/lib/index.js",
|
|
@@ -50,15 +50,30 @@
|
|
|
50
50
|
"type": "git",
|
|
51
51
|
"url": "git+https://github.com/drscrewdriver/dsh-context-compression-improved.git"
|
|
52
52
|
},
|
|
53
|
+
"packageManager": "pnpm@11.7.0",
|
|
53
54
|
"engines": {
|
|
54
55
|
"node": "^22.19.0 || >=24.0.0",
|
|
55
|
-
"dsh": ">=0.
|
|
56
|
+
"dsh": ">=0.2.0-rc.1 <0.2.1-0"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "pnpm -r --if-present run bundle",
|
|
60
|
+
"typecheck": "pnpm --filter dsh-context-compression-improved run bundle && pnpm --filter dsh-context-compression-improved run typecheck && pnpm run typecheck:tests",
|
|
61
|
+
"typecheck:tests": "tsc --noEmit -p tsconfig.tests.json",
|
|
62
|
+
"lint": "eslint packages scripts eslint.config.js",
|
|
63
|
+
"lint:fix": "eslint packages scripts eslint.config.js --fix",
|
|
64
|
+
"test": "vitest run",
|
|
65
|
+
"test:watch": "vitest",
|
|
66
|
+
"test:built": "vitest run --config vitest.built.config.ts",
|
|
67
|
+
"test:e2e:packed": "node scripts/packed-install-e2e.mjs",
|
|
68
|
+
"test:unit": "vitest run",
|
|
69
|
+
"verify:release": "node scripts/verify-release.mjs",
|
|
70
|
+
"pack:dry-run": "pnpm -r --if-present run pack:dry-run"
|
|
56
71
|
},
|
|
57
72
|
"peerDependencies": {
|
|
58
|
-
"@deepseek-ai/dsh-client-locale": ">=0.
|
|
59
|
-
"@deepseek-ai/dsh-client-ui-primitives": ">=0.
|
|
60
|
-
"@deepseek-ai/dsh-client-ui-settings": ">=0.
|
|
61
|
-
"@deepseek-ai/dsh-client-ui-slots": ">=0.
|
|
73
|
+
"@deepseek-ai/dsh-client-locale": ">=0.2.0-rc.1 <0.2.1-0",
|
|
74
|
+
"@deepseek-ai/dsh-client-ui-primitives": ">=0.2.0-rc.1 <0.2.1-0",
|
|
75
|
+
"@deepseek-ai/dsh-client-ui-settings": ">=0.2.0-rc.1 <0.2.1-0",
|
|
76
|
+
"@deepseek-ai/dsh-client-ui-slots": ">=0.2.0-rc.1 <0.2.1-0"
|
|
62
77
|
},
|
|
63
78
|
"peerDependenciesMeta": {
|
|
64
79
|
"@deepseek-ai/dsh-client-locale": {
|
|
@@ -79,54 +94,54 @@
|
|
|
79
94
|
"@deepseek-ai/cordis-plugin-group": "1.0.1",
|
|
80
95
|
"@deepseek-ai/cordis-plugin-include": "1.0.6",
|
|
81
96
|
"@deepseek-ai/cordis-plugin-loader": "1.0.2",
|
|
82
|
-
"@deepseek-ai/dsh-agent": "0.
|
|
83
|
-
"@deepseek-ai/dsh-agent-loop": "0.
|
|
84
|
-
"@deepseek-ai/dsh-agent-loop-testkit": "0.
|
|
97
|
+
"@deepseek-ai/dsh-agent": "0.2.0-rc.1",
|
|
98
|
+
"@deepseek-ai/dsh-agent-loop": "0.2.0-rc.1",
|
|
99
|
+
"@deepseek-ai/dsh-agent-loop-testkit": "0.2.0-rc.1",
|
|
85
100
|
"@deepseek-ai/dsh-agent-presets": "0.1.6-alpha.2",
|
|
86
|
-
"@deepseek-ai/dsh-anonymous-user-id": "0.
|
|
87
|
-
"@deepseek-ai/dsh-api-remotes": "0.
|
|
88
|
-
"@deepseek-ai/dsh-api-session-controller": "0.
|
|
89
|
-
"@deepseek-ai/dsh-atomic-write": "0.
|
|
90
|
-
"@deepseek-ai/dsh-attachment": "0.
|
|
91
|
-
"@deepseek-ai/dsh-client-locale": "0.
|
|
92
|
-
"@deepseek-ai/dsh-client-store": "0.
|
|
93
|
-
"@deepseek-ai/dsh-client-ui-primitives": "0.
|
|
94
|
-
"@deepseek-ai/dsh-client-ui-session": "0.
|
|
95
|
-
"@deepseek-ai/dsh-client-ui-settings": "0.
|
|
96
|
-
"@deepseek-ai/dsh-client-ui-slots": "0.
|
|
97
|
-
"@deepseek-ai/dsh-client-ui-workspace": "0.
|
|
101
|
+
"@deepseek-ai/dsh-anonymous-user-id": "0.2.0-rc.1",
|
|
102
|
+
"@deepseek-ai/dsh-api-remotes": "0.2.0-rc.1",
|
|
103
|
+
"@deepseek-ai/dsh-api-session-controller": "0.2.0-rc.1",
|
|
104
|
+
"@deepseek-ai/dsh-atomic-write": "0.2.0-rc.1",
|
|
105
|
+
"@deepseek-ai/dsh-attachment": "0.2.0-rc.1",
|
|
106
|
+
"@deepseek-ai/dsh-client-locale": "0.2.0-rc.1",
|
|
107
|
+
"@deepseek-ai/dsh-client-store": "0.2.0-rc.1",
|
|
108
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.0-rc.1",
|
|
109
|
+
"@deepseek-ai/dsh-client-ui-session": "0.2.0-rc.1",
|
|
110
|
+
"@deepseek-ai/dsh-client-ui-settings": "0.2.0-rc.1",
|
|
111
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.1",
|
|
112
|
+
"@deepseek-ai/dsh-client-ui-workspace": "0.2.0-rc.1",
|
|
98
113
|
"@deepseek-ai/dsh-code-runtime": "0.1.5-rc.3",
|
|
99
|
-
"@deepseek-ai/dsh-command-compact": "0.
|
|
100
|
-
"@deepseek-ai/dsh-commands": "0.
|
|
101
|
-
"@deepseek-ai/dsh-compaction": "0.
|
|
102
|
-
"@deepseek-ai/dsh-compaction-basic": "0.
|
|
103
|
-
"@deepseek-ai/dsh-cordis-host-runner": "0.
|
|
104
|
-
"@deepseek-ai/dsh-credentials": "0.
|
|
105
|
-
"@deepseek-ai/dsh-goal": "0.
|
|
106
|
-
"@deepseek-ai/dsh-home-paths": "0.
|
|
107
|
-
"@deepseek-ai/dsh-host-plugin-inventory": "0.
|
|
108
|
-
"@deepseek-ai/dsh-invariants": "0.
|
|
109
|
-
"@deepseek-ai/dsh-jobs": "0.
|
|
110
|
-
"@deepseek-ai/dsh-launch-environment": "0.
|
|
111
|
-
"@deepseek-ai/dsh-llm": "0.
|
|
112
|
-
"@deepseek-ai/dsh-llm-deepseek": "0.
|
|
113
|
-
"@deepseek-ai/dsh-llm-retry": "0.
|
|
114
|
-
"@deepseek-ai/dsh-message-feedback": "0.
|
|
115
|
-
"@deepseek-ai/dsh-sandbox": "0.
|
|
116
|
-
"@deepseek-ai/dsh-scope": "0.
|
|
117
|
-
"@deepseek-ai/dsh-session": "0.
|
|
118
|
-
"@deepseek-ai/dsh-session-persistence": "0.
|
|
119
|
-
"@deepseek-ai/dsh-session-projection": "0.
|
|
120
|
-
"@deepseek-ai/dsh-settings": "0.
|
|
121
|
-
"@deepseek-ai/dsh-subagent": "0.
|
|
122
|
-
"@deepseek-ai/dsh-subagent-fork-in-process": "0.
|
|
123
|
-
"@deepseek-ai/dsh-subagent-in-process-driver": "0.
|
|
124
|
-
"@deepseek-ai/dsh-subagent-spawn-in-process": "0.
|
|
125
|
-
"@deepseek-ai/dsh-system-prompt": "0.
|
|
126
|
-
"@deepseek-ai/dsh-token-meter": "0.
|
|
127
|
-
"@deepseek-ai/dsh-tools": "0.
|
|
128
|
-
"@deepseek-ai/dsh-user-approval": "0.
|
|
129
|
-
"@deepseek-ai/dsh-user-questions": "0.
|
|
114
|
+
"@deepseek-ai/dsh-command-compact": "0.2.0-rc.1",
|
|
115
|
+
"@deepseek-ai/dsh-commands": "0.2.0-rc.1",
|
|
116
|
+
"@deepseek-ai/dsh-compaction": "0.2.0-rc.1",
|
|
117
|
+
"@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.1",
|
|
118
|
+
"@deepseek-ai/dsh-cordis-host-runner": "0.2.0-rc.1",
|
|
119
|
+
"@deepseek-ai/dsh-credentials": "0.2.0-rc.1",
|
|
120
|
+
"@deepseek-ai/dsh-goal": "0.2.0-rc.1",
|
|
121
|
+
"@deepseek-ai/dsh-home-paths": "0.2.0-rc.1",
|
|
122
|
+
"@deepseek-ai/dsh-host-plugin-inventory": "0.2.0-rc.1",
|
|
123
|
+
"@deepseek-ai/dsh-invariants": "0.2.0-rc.1",
|
|
124
|
+
"@deepseek-ai/dsh-jobs": "0.2.0-rc.1",
|
|
125
|
+
"@deepseek-ai/dsh-launch-environment": "0.2.0-rc.1",
|
|
126
|
+
"@deepseek-ai/dsh-llm": "0.2.0-rc.1",
|
|
127
|
+
"@deepseek-ai/dsh-llm-deepseek": "0.2.0-rc.1",
|
|
128
|
+
"@deepseek-ai/dsh-llm-retry": "0.2.0-rc.1",
|
|
129
|
+
"@deepseek-ai/dsh-message-feedback": "0.2.0-rc.1",
|
|
130
|
+
"@deepseek-ai/dsh-sandbox": "0.2.0-rc.1",
|
|
131
|
+
"@deepseek-ai/dsh-scope": "0.2.0-rc.1",
|
|
132
|
+
"@deepseek-ai/dsh-session": "0.2.0-rc.1",
|
|
133
|
+
"@deepseek-ai/dsh-session-persistence": "0.2.0-rc.1",
|
|
134
|
+
"@deepseek-ai/dsh-session-projection": "0.2.0-rc.1",
|
|
135
|
+
"@deepseek-ai/dsh-settings": "0.2.0-rc.1",
|
|
136
|
+
"@deepseek-ai/dsh-subagent": "0.2.0-rc.1",
|
|
137
|
+
"@deepseek-ai/dsh-subagent-fork-in-process": "0.2.0-rc.1",
|
|
138
|
+
"@deepseek-ai/dsh-subagent-in-process-driver": "0.2.0-rc.1",
|
|
139
|
+
"@deepseek-ai/dsh-subagent-spawn-in-process": "0.2.0-rc.1",
|
|
140
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.0-rc.1",
|
|
141
|
+
"@deepseek-ai/dsh-token-meter": "0.2.0-rc.1",
|
|
142
|
+
"@deepseek-ai/dsh-tools": "0.2.0-rc.1",
|
|
143
|
+
"@deepseek-ai/dsh-user-approval": "0.2.0-rc.1",
|
|
144
|
+
"@deepseek-ai/dsh-user-questions": "0.2.0-rc.1",
|
|
130
145
|
"@deepseek-ai/schemastery": "3.18.4",
|
|
131
146
|
"@eslint/js": "^10.0.1",
|
|
132
147
|
"@testing-library/react": "^16.3.2",
|
|
@@ -134,7 +149,6 @@
|
|
|
134
149
|
"@types/js-yaml": "^4.0.9",
|
|
135
150
|
"@types/node": "^22.20.0",
|
|
136
151
|
"@types/react": "~18.3.1",
|
|
137
|
-
"@vitest/coverage-v8": "^4.1.11",
|
|
138
152
|
"eslint": "^10.10.0",
|
|
139
153
|
"globals": "^17.12.0",
|
|
140
154
|
"jsdom": "29.1.1",
|
|
@@ -145,20 +159,5 @@
|
|
|
145
159
|
"typescript": "^6.0.3",
|
|
146
160
|
"typescript-eslint": "^8.69.0",
|
|
147
161
|
"vitest": "^4.1.8"
|
|
148
|
-
},
|
|
149
|
-
"scripts": {
|
|
150
|
-
"build": "pnpm -r --if-present run bundle",
|
|
151
|
-
"typecheck": "pnpm --filter dsh-context-compression-improved run bundle && pnpm --filter dsh-context-compression-improved run typecheck && pnpm run typecheck:tests",
|
|
152
|
-
"typecheck:tests": "tsc --noEmit -p tsconfig.tests.json",
|
|
153
|
-
"lint": "eslint packages scripts eslint.config.js",
|
|
154
|
-
"lint:fix": "eslint packages scripts eslint.config.js --fix",
|
|
155
|
-
"test": "vitest run",
|
|
156
|
-
"test:coverage": "vitest run --coverage",
|
|
157
|
-
"test:watch": "vitest",
|
|
158
|
-
"test:built": "vitest run --config vitest.built.config.ts",
|
|
159
|
-
"test:e2e:packed": "node scripts/packed-install-e2e.mjs",
|
|
160
|
-
"test:unit": "vitest run",
|
|
161
|
-
"verify:release": "node scripts/verify-release.mjs",
|
|
162
|
-
"pack:dry-run": "pnpm -r --if-present run pack:dry-run"
|
|
163
162
|
}
|
|
164
|
-
}
|
|
163
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "dsh-external/dsh-context-compression-improved",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-beta.2",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"description": "Auditable tool-result context-compression selector with code-skeleton gate for DeepSeek Harness",
|
|
6
6
|
"engines": {
|
|
7
|
-
"dsh": ">=0.
|
|
7
|
+
"dsh": ">=0.2.0-rc.1 <0.2.1-0"
|
|
8
8
|
},
|
|
9
9
|
"contributes": {
|
|
10
10
|
"tools": [],
|
|
@@ -373,20 +373,6 @@ function parseCodeSkeletonSettings(value) {
|
|
|
373
373
|
return { enabled };
|
|
374
374
|
}
|
|
375
375
|
/**
|
|
376
|
-
* Strictly parse the persisted intentSummary section. Mirrors the codeSkeleton
|
|
377
|
-
* section semantics: absent inherits the lossless `false` default, while a
|
|
378
|
-
* present-but-invalid section is an explicitly invalid document.
|
|
379
|
-
*/
|
|
380
|
-
function parseIntentSummarySettings(value) {
|
|
381
|
-
if (value === void 0) return { enabled: false };
|
|
382
|
-
if (!isPlainRecord(value)) throw new TypeError("Context-compression intentSummary must be a plain object");
|
|
383
|
-
const keys = Object.keys(value);
|
|
384
|
-
if (keys.length !== 1 || keys[0] !== "enabled") throw new TypeError(`Context-compression intentSummary: expected exactly "enabled", got "${keys.join("\", \"")}"`);
|
|
385
|
-
const enabled = value.enabled;
|
|
386
|
-
if (typeof enabled !== "boolean") throw new TypeError("Context-compression intentSummary.enabled must be a boolean");
|
|
387
|
-
return { enabled };
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
376
|
* Parse the optional tokenpilot-inspired preset sub-capability section. Absent
|
|
391
377
|
* inherits the preset defaults; present-but-invalid is rejected, mirroring the
|
|
392
378
|
* codeSkeleton section semantics.
|
|
@@ -493,8 +479,7 @@ const DEFAULT_CONTEXT_COMPRESSION_SETTINGS = {
|
|
|
493
479
|
profile: "balanced",
|
|
494
480
|
custom: structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY),
|
|
495
481
|
autoCompact: { thresholdPercent: AUTO_COMPACT_THRESHOLD_LIMITS.default },
|
|
496
|
-
codeSkeleton: { enabled: false }
|
|
497
|
-
intentSummary: { enabled: false }
|
|
482
|
+
codeSkeleton: { enabled: false }
|
|
498
483
|
};
|
|
499
484
|
/**
|
|
500
485
|
* Parse one settings document with the persisted-section semantics: `undefined`
|
|
@@ -512,19 +497,17 @@ const ContextCompressionSettingsSchema = z.transform(z.any().required(), (value)
|
|
|
512
497
|
if (!isPlainRecord(value)) throw new TypeError("Context-compression settings must be a plain object");
|
|
513
498
|
assertPlainDataTree(value);
|
|
514
499
|
const candidate = structuredClone(value);
|
|
515
|
-
const unknown = Object.keys(candidate).find((key) => key !== "profile" && key !== "custom" && key !== "autoCompact" && key !== "codeSkeleton" && key !== "
|
|
500
|
+
const unknown = Object.keys(candidate).find((key) => key !== "profile" && key !== "custom" && key !== "autoCompact" && key !== "codeSkeleton" && key !== "presetOptions");
|
|
516
501
|
if (unknown !== void 0) throw new TypeError(`Context-compression settings: unknown key "${unknown}"`);
|
|
517
502
|
assertPresentSection(candidate, "profile", isSupportedProfile);
|
|
518
503
|
assertPresentSection(candidate, "custom", isUsableCustomDocument);
|
|
519
504
|
const autoCompact = parseAutoCompactSettings(candidate.autoCompact);
|
|
520
505
|
const codeSkeleton = parseCodeSkeletonSettings(candidate.codeSkeleton);
|
|
521
|
-
const intentSummary = parseIntentSummarySettings(candidate.intentSummary);
|
|
522
506
|
const presetOptions = parsePresetOptionsSettings(candidate.presetOptions);
|
|
523
507
|
return {
|
|
524
508
|
...contextCompressionSettingsInputSchema(candidate),
|
|
525
509
|
autoCompact,
|
|
526
510
|
codeSkeleton,
|
|
527
|
-
intentSummary,
|
|
528
511
|
...presetOptions === void 0 ? {} : { presetOptions }
|
|
529
512
|
};
|
|
530
513
|
}).default(DEFAULT_CONTEXT_COMPRESSION_SETTINGS);
|
|
@@ -975,76 +958,5 @@ function invalidateOnTaskChange(state, todoVersion) {
|
|
|
975
958
|
state.lastSummaryTurn = -1;
|
|
976
959
|
return true;
|
|
977
960
|
}
|
|
978
|
-
/**
|
|
979
|
-
* `/ctx-summary off|on` overrides, keyed by session id (string). The command
|
|
980
|
-
* handler only sees `invocation.agent.session.id`, not the pruner's Session
|
|
981
|
-
* object, so these are id-keyed rather than WeakMap'd. Entries are two-char
|
|
982
|
-
* strings per session and cleared whenever the override is lifted.
|
|
983
|
-
*/
|
|
984
|
-
const summaryOverrides = /* @__PURE__ */ new Map();
|
|
985
|
-
/** Read the session's `/ctx-summary` override; `undefined` = default (settings-driven). */
|
|
986
|
-
function getSummaryOverride(sessionId) {
|
|
987
|
-
return summaryOverrides.get(sessionId);
|
|
988
|
-
}
|
|
989
|
-
/** Set or clear (`undefined`) the session's `/ctx-summary` override. */
|
|
990
|
-
function setSummaryOverride(sessionId, value) {
|
|
991
|
-
if (value === void 0) summaryOverrides.delete(sessionId);
|
|
992
|
-
else summaryOverrides.set(sessionId, value);
|
|
993
|
-
}
|
|
994
|
-
/** Last observed `intentSummary.enabled` for a session, for `/ctx-summary status`. */
|
|
995
|
-
const lastObservedIntentEnabled = /* @__PURE__ */ new Map();
|
|
996
|
-
/** Record the gate input the pass last evaluated for this session. */
|
|
997
|
-
function observeIntentEnabled(sessionId, enabled) {
|
|
998
|
-
lastObservedIntentEnabled.set(sessionId, enabled);
|
|
999
|
-
}
|
|
1000
|
-
/** The settings-side enabled flag last observed for the session, if any. */
|
|
1001
|
-
function getObservedIntentEnabled(sessionId) {
|
|
1002
|
-
return lastObservedIntentEnabled.get(sessionId);
|
|
1003
|
-
}
|
|
1004
|
-
const lastIntentFolds = /* @__PURE__ */ new Map();
|
|
1005
|
-
/** Record a landed intent fold for the session (newest wins). */
|
|
1006
|
-
function recordIntentFold(sessionId, record) {
|
|
1007
|
-
lastIntentFolds.set(sessionId, record);
|
|
1008
|
-
}
|
|
1009
|
-
/** The most recent landed intent fold for the session, if any. */
|
|
1010
|
-
function getLastIntentFold(sessionId) {
|
|
1011
|
-
return lastIntentFolds.get(sessionId);
|
|
1012
|
-
}
|
|
1013
|
-
//#endregion
|
|
1014
|
-
//#region src/runtime/tokenpilot/intent-gate.ts
|
|
1015
|
-
/**
|
|
1016
|
-
* Turn-tail intent-summary growth gate (TokenPilot-inspired E2).
|
|
1017
|
-
*
|
|
1018
|
-
* Pure decision helper evaluated at the turn-boundary postflight: it decides
|
|
1019
|
-
* whether this turn may spend a summary-writer LLM call and stage a fold for
|
|
1020
|
-
* the next pressure round. The gate is deliberately conservative — every
|
|
1021
|
-
* unresolved input (unknown context window, non-finite counters) fails closed
|
|
1022
|
-
* toward "do not run", because a skipped fold is free while a wasted summary
|
|
1023
|
-
* call is not. Content safety is unaffected either way: fail-open semantics
|
|
1024
|
-
* live in the fold landing path, not here.
|
|
1025
|
-
*/
|
|
1026
|
-
/** Floor: the live surface must exceed this fraction of the context window. */
|
|
1027
|
-
const INTENT_GATE_FLOOR_FRACTION = .45;
|
|
1028
|
-
/** Growth: the live surface must have grown by more than this since the last landed fold. */
|
|
1029
|
-
const INTENT_GATE_GROWTH_TOKENS = 5e4;
|
|
1030
|
-
function isUsableNumber(value) {
|
|
1031
|
-
return Number.isFinite(value) && value >= 0;
|
|
1032
|
-
}
|
|
1033
|
-
/** Same evaluation with the reason attached, for audits and `/ctx-summary status`. */
|
|
1034
|
-
function evaluateIntentGate(input) {
|
|
1035
|
-
const snapshot = (decision, reason) => ({
|
|
1036
|
-
...input,
|
|
1037
|
-
decision,
|
|
1038
|
-
reason
|
|
1039
|
-
});
|
|
1040
|
-
if (!input.enabled) return snapshot(false, "disabled");
|
|
1041
|
-
if (input.override === "off") return snapshot(false, "override-off");
|
|
1042
|
-
if (!isUsableNumber(input.liveTokens)) return snapshot(false, "below-floor");
|
|
1043
|
-
if (input.contextWindow === void 0 || !isUsableNumber(input.contextWindow)) return snapshot(false, "no-window");
|
|
1044
|
-
if (!(input.liveTokens > input.contextWindow * .45)) return snapshot(false, "below-floor");
|
|
1045
|
-
if (!isUsableNumber(input.baselineTokens)) return snapshot(false, "below-growth");
|
|
1046
|
-
if (!(input.liveTokens - input.baselineTokens > 5e4)) return snapshot(false, "below-growth");
|
|
1047
|
-
return snapshot(true, "passed");
|
|
1048
|
-
}
|
|
1049
961
|
//#endregion
|
|
1050
|
-
export {
|
|
962
|
+
export { deepFreeze as C, assertNever as S, resolveConfig as _, AUTO_COMPACT_THRESHOLD_LIMITS as a, DEFAULT_CUSTOM_COMPRESSION_POLICY as b, DEFAULTS as c, charsForTokens as d, charsToTokens as f, parseContextCompressionSettings as g, isValidAutoCompactThresholdPercent as h, recordScore as i, DEFAULT_CONTEXT_COMPRESSION_SETTINGS as l, isCompressionProfile as m, invalidateOnTaskChange as n, CONTEXT_COMPRESSION_SETTINGS_NAMESPACE as o, codePointLength as p, recordRecertified as r, ContextCompressionSettingsSchema as s, getAdvisorState as t, PRUNE_MARKER as u, resolvePolicy as v, COMPRESSION_PROFILES as w, resolveCustomPolicy as x, CustomCompressionPolicySchema as y };
|