dsh-context-compression-improved 0.2.3 → 0.2.4

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 (52) hide show
  1. package/.github/workflows/ci.yml +39 -39
  2. package/CHANGELOG.md +137 -135
  3. package/README.md +112 -112
  4. package/package.json +142 -142
  5. package/packages/selector/README.md +31 -31
  6. package/packages/selector/README.zh.md +31 -31
  7. package/packages/selector/dsh.plugin.json +16 -16
  8. package/packages/selector/lib/client.d.ts +228 -228
  9. package/packages/selector/lib/client.js +1462 -1462
  10. package/packages/selector/lib/config.js +856 -842
  11. package/packages/selector/lib/index.d.ts +37 -37
  12. package/packages/selector/lib/index.js +693 -645
  13. package/packages/selector/lib/invariant.js +70 -70
  14. package/packages/selector/lib/pruner.d.ts +728 -683
  15. package/packages/selector/lib/pruner.js +4765 -3807
  16. package/packages/selector/lib/style.css +46 -46
  17. package/packages/selector/lib/tail-trim.js +136 -136
  18. package/packages/selector/package.json +9 -1
  19. package/packages/selector/src/client/index.ts +111 -111
  20. package/packages/selector/src/preset-overlay.ts +60 -1
  21. package/packages/selector/src/pruner/content.ts +18 -5
  22. package/packages/selector/src/pruner/types.ts +23 -5
  23. package/packages/selector/src/pruner.ts +164 -154
  24. package/packages/selector/src/runtime/adaptive-cost.ts +23 -12
  25. package/packages/selector/src/runtime/audit.ts +18 -2
  26. package/packages/selector/src/runtime/config.ts +30 -1
  27. package/packages/selector/src/runtime/measurement.ts +31 -2
  28. package/packages/selector/src/runtime/reducers.ts +1115 -97
  29. package/packages/selector/src/runtime/tokenpilot/dedup.ts +1 -1
  30. package/packages/selector/src/runtime/tokenpilot/locator.ts +1 -1
  31. package/packages/selector/src/runtime/tokenpilot/read-state.ts +23 -2
  32. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +275 -0
  33. package/packages/selector/src/runtime/toolclass.ts +103 -0
  34. package/packages/selector/src/runtime/types.ts +16 -0
  35. package/packages/selector/tests/preset-overlay.host.spec.ts +256 -243
  36. package/packages/selector/tests/runtime/adaptive-cost.spec.ts +7 -7
  37. package/packages/selector/tests/runtime/audit.spec.ts +44 -1
  38. package/packages/selector/tests/runtime/char-basis.spec.ts +30 -0
  39. package/packages/selector/tests/runtime/code-skeleton.spec.ts +14 -3
  40. package/packages/selector/tests/runtime/frequency-longstrings.spec.ts +74 -0
  41. package/packages/selector/tests/runtime/html-reducer.spec.ts +212 -0
  42. package/packages/selector/tests/runtime/line-mapping.spec.ts +153 -0
  43. package/packages/selector/tests/runtime/prose-reducers.spec.ts +133 -0
  44. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +198 -27
  45. package/packages/selector/tests/runtime/read-input-cap.spec.ts +33 -0
  46. package/packages/selector/tests/runtime/search-reducer.spec.ts +110 -0
  47. package/packages/selector/tests/runtime/sidechannel.spec.ts +241 -0
  48. package/packages/selector/tests/runtime/toc-and-bundled.spec.ts +159 -0
  49. package/packages/selector/tests/runtime/tokenpilot/read-state.spec.ts +24 -0
  50. package/packages/selector/tests/runtime/toolclass.spec.ts +156 -0
  51. package/packages/selector/tests/standing-generation.host.spec.ts +642 -631
  52. package/scripts/toolclass-corpus-replay.mjs +273 -0
package/README.md CHANGED
@@ -1,112 +1,112 @@
1
- # dsh-context-compression-improved
2
-
3
- > An improved fork of [dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector) — an auditable tool-result context-compression selector for DeepSeek Harness — adding an orthogonal **code-skeleton compression gate**.
4
-
5
- [中文说明](README.zh.md) · [日本語](README.ja.md) · [한국어](README.ko.md) · [Changelog](CHANGELOG.md) · [Installation guide](docs/installation.md)
6
-
7
- > [!NOTE]
8
- > **What this fork adds on top of upstream 0.1.0:**
9
- >
10
- > - An orthogonal **code-skeleton compression gate** (`codeSkeleton.enabled`, default off): the first exposure of an oversized fresh source-code tool result can keep a skeleton of imports and declarations — bodies elided, error lines kept — before the regular reducers run.
11
- > - A settings toggle for that gate in the same selector settings section, independent of every compression profile.
12
- > - An ESLint baseline wired into CI, a `test:watch` TDD loop, and documentation in English, Simplified Chinese, Japanese, and Korean.
13
-
14
- > [!IMPORTANT]
15
- > This project supports **DeepSeek models only**. Lossless measurement and lossy compression depend on the bundled official DeepSeek tokenizers (`deepseek-v4-flash`, `deepseek-v4-pro`, `deepseek-v4-flash-vision-exp`). Everything else fails open and keeps original tool results. See the [upstream README](https://github.com/WilliamShi666/dsh-context-compression-selector#model-support-and-safety) for the full safety model.
16
-
17
- ## What it is
18
-
19
- Long-running agent tasks accumulate a large amount of tool output. This community plugin adds selectable, auditable policies for reducing that tool-result context without modifying DeepSeek Harness core:
20
-
21
- - **Fresh** pre-compresses a newly oversized tool-result segment before the model receives it.
22
- - **Aggregate** pre-compresses fresh material again when it still grows beyond its budget.
23
- - **History / micro-compact** replaces eligible old tool results while preserving recent working context.
24
- - **TailTrim** is an optional Custom-only tail reduction path.
25
- - **Native** preserves the Harness-style head/middle/tail trimming as one explicit profile.
26
- - **Code skeleton (new, orthogonal gate)** — see below.
27
-
28
- Every decision is recorded: stage, reducer, trigger, skip reason, and exact token counts where available.
29
-
30
- ## Code skeleton gate (new)
31
-
32
- When the gate is enabled, an oversized **fresh source-code tool result** (for example a large `read_file`) first tries a skeleton reduction: imports and type/function/class declarations are kept, function bodies are elided with a marker, and error lines inside elided bodies are preserved. If the skeleton cannot be produced or verified, the result falls back to the original head pruning — the gate can never make context worse.
33
-
34
- Properties:
35
-
36
- - **Orthogonal**: independent of the selected profile (`balanced`, `savings`, `cache-strict`, `adaptive`, `custom`, `off`, `native`). All profiles get the gate.
37
- - **Off by default**: `codeSkeleton: { enabled: false }` until you turn it on.
38
- - **Measurement-gated**: requires the exact DeepSeek tokenizer; without it the plugin fails open.
39
- - **Session-frozen**: like all selector settings, changes affect newly observed sessions only.
40
- - **Strictly parsed**: `codeSkeleton` must be exactly `{ enabled: boolean }`; malformed values throw on the runtime side and show as unreadable in the browser UI.
41
-
42
- ### Provenance, and whose numbers these are
43
-
44
- The skeletonization approach is borrowed from **[Headroom](https://github.com/headroomlabs-ai/headroom)**
45
- (Apache-2.0) — a context-compression layer for AI agents that routes JSON, source code and prose
46
- through separate compressors (`SmartCrusher` for JSON, `CodeCompressor` for code), with its
47
- skeleton transform living in `crates/headroom-core/src/transforms/live_zone.rs` and
48
- `smart_crusher/planning.rs`.
49
-
50
- **The reduction figures are Headroom's, not this plugin's.** Headroom's published claim, verbatim:
51
-
52
- > 20% fewer tokens for coding agents, **60–95% fewer tokens for JSON**, same answers.
53
-
54
- The headline — **up to 95% fewer tokens** — comes from that sentence: JSON payloads, measured by
55
- Headroom's own compressors on Headroom's own benchmarks. That is the same source this gate draws
56
- its mechanism from. This repository ships **no benchmark of its own**, so it claims **no reduction
57
- percentage of its own**; read the measurements at the source.
58
-
59
- ## Settings UI
60
-
61
- Choose a compression profile, set the Auto Compact trigger level, and toggle code-skeleton compression in the same settings section. The toggle saves on change and shows the saved state on reload.
62
-
63
- ![Context Compression Selector settings UI](packages/selector/assets/screenshots/context-compression-selector-settings.png)
64
-
65
- ## Install
66
-
67
- **Recommended: install from npm.** One dist-tag per Harness line — `dsh-0.1.5` for the 0.1.5 line (this branch), `dsh-0.1.2` for the 0.1.2 line.
68
-
69
- ```sh
70
- dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.5
71
- # DSH 0.1.2 line:
72
- # dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.2
73
- dsh --profile web --dump-config
74
- ```
75
-
76
- From source (alternative — the internal package names intentionally stay upstream's):
77
-
78
- ```sh
79
- git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
80
- cd dsh-context-compression-improved
81
- pnpm install --frozen-lockfile
82
- pnpm build
83
- ```
84
-
85
- Then pack the selector package and add it to a Harness profile — the full walkthrough, including verification and uninstall steps, is in the [installation guide](docs/installation.md).
86
-
87
- ## Development
88
-
89
- ```sh
90
- pnpm install --frozen-lockfile
91
- pnpm lint # ESLint baseline (also enforced in CI)
92
- pnpm typecheck # runtime + selector + tests tsc, plus the bundle step
93
- pnpm test # full vitest suite
94
- pnpm test:watch # TDD loop: write the failing regression first, then make it pass
95
- pnpm build
96
- pnpm verify:release
97
- ```
98
-
99
- Contributions follow the upstream discipline: add the failing regression first, keep every production change inside this repository, and explain “triggered”, “enabled but skipped”, and fail-open evidence separately. See [CONTRIBUTING.md](CONTRIBUTING.md).
100
-
101
- ## Compatibility
102
-
103
- - Verified against DeepSeek Harness `dsh-v0.1.1-rc.2` using public plugin and profile APIs only; compatible with the official `dsh-v0.1.2-alpha.5` release.
104
- - Requires Node `^22.19.0 || >=24` and pnpm `11.7.0`.
105
- - The plugin uses only public Harness extension APIs and does not modify Harness core code. Unofficial community project, not affiliated with or endorsed by DeepSeek.
106
-
107
- ## Credits and license
108
-
109
- - Upstream project and all prior work: [WilliamShi666/dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector) by WilliamShi666 (MIT).
110
- - Fork additions (code-skeleton gate, tooling, localized docs): drscrewdriver.
111
- - Code-skeleton mechanism: [Headroom](https://github.com/headroomlabs-ai/headroom) (Apache-2.0) — see "Provenance, and whose numbers these are" above.
112
- - MIT — see [LICENSE](LICENSE) (upstream copyright notice retained) and [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for bundled tokenizer provenance.
1
+ # dsh-context-compression-improved
2
+
3
+ > An improved fork of [dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector) — an auditable tool-result context-compression selector for DeepSeek Harness — adding an orthogonal **code-skeleton compression gate**.
4
+
5
+ [中文说明](README.zh.md) · [日本語](README.ja.md) · [한국어](README.ko.md) · [Changelog](CHANGELOG.md) · [Installation guide](docs/installation.md)
6
+
7
+ > [!NOTE]
8
+ > **What this fork adds on top of upstream 0.1.0:**
9
+ >
10
+ > - An orthogonal **code-skeleton compression gate** (`codeSkeleton.enabled`, default off): the first exposure of an oversized fresh source-code tool result can keep a skeleton of imports and declarations — bodies elided, error lines kept — before the regular reducers run.
11
+ > - A settings toggle for that gate in the same selector settings section, independent of every compression profile.
12
+ > - An ESLint baseline wired into CI, a `test:watch` TDD loop, and documentation in English, Simplified Chinese, Japanese, and Korean.
13
+
14
+ > [!IMPORTANT]
15
+ > This project supports **DeepSeek models only**. Lossless measurement and lossy compression depend on the bundled official DeepSeek tokenizers (`deepseek-v4-flash`, `deepseek-v4-pro`, `deepseek-v4-flash-vision-exp`). Everything else fails open and keeps original tool results. See the [upstream README](https://github.com/WilliamShi666/dsh-context-compression-selector#model-support-and-safety) for the full safety model.
16
+
17
+ ## What it is
18
+
19
+ Long-running agent tasks accumulate a large amount of tool output. This community plugin adds selectable, auditable policies for reducing that tool-result context without modifying DeepSeek Harness core:
20
+
21
+ - **Fresh** pre-compresses a newly oversized tool-result segment before the model receives it.
22
+ - **Aggregate** pre-compresses fresh material again when it still grows beyond its budget.
23
+ - **History / micro-compact** replaces eligible old tool results while preserving recent working context.
24
+ - **TailTrim** is an optional Custom-only tail reduction path.
25
+ - **Native** preserves the Harness-style head/middle/tail trimming as one explicit profile.
26
+ - **Code skeleton (new, orthogonal gate)** — see below.
27
+
28
+ Every decision is recorded: stage, reducer, trigger, skip reason, and exact token counts where available.
29
+
30
+ ## Code skeleton gate (new)
31
+
32
+ When the gate is enabled, an oversized **fresh source-code tool result** (for example a large `read_file`) first tries a skeleton reduction: imports and type/function/class declarations are kept, function bodies are elided with a marker, and error lines inside elided bodies are preserved. If the skeleton cannot be produced or verified, the result falls back to the original head pruning — the gate can never make context worse.
33
+
34
+ Properties:
35
+
36
+ - **Orthogonal**: independent of the selected profile (`balanced`, `savings`, `cache-strict`, `adaptive`, `custom`, `off`, `native`). All profiles get the gate.
37
+ - **Off by default**: `codeSkeleton: { enabled: false }` until you turn it on.
38
+ - **Measurement-gated**: requires the exact DeepSeek tokenizer; without it the plugin fails open.
39
+ - **Session-frozen**: like all selector settings, changes affect newly observed sessions only.
40
+ - **Strictly parsed**: `codeSkeleton` must be exactly `{ enabled: boolean }`; malformed values throw on the runtime side and show as unreadable in the browser UI.
41
+
42
+ ### Provenance, and whose numbers these are
43
+
44
+ The skeletonization approach is borrowed from **[Headroom](https://github.com/headroomlabs-ai/headroom)**
45
+ (Apache-2.0) — a context-compression layer for AI agents that routes JSON, source code and prose
46
+ through separate compressors (`SmartCrusher` for JSON, `CodeCompressor` for code), with its
47
+ skeleton transform living in `crates/headroom-core/src/transforms/live_zone.rs` and
48
+ `smart_crusher/planning.rs`.
49
+
50
+ **The reduction figures are Headroom's, not this plugin's.** Headroom's published claim, verbatim:
51
+
52
+ > 20% fewer tokens for coding agents, **60–95% fewer tokens for JSON**, same answers.
53
+
54
+ The headline — **up to 95% fewer tokens** — comes from that sentence: JSON payloads, measured by
55
+ Headroom's own compressors on Headroom's own benchmarks. That is the same source this gate draws
56
+ its mechanism from. This repository ships **no benchmark of its own**, so it claims **no reduction
57
+ percentage of its own**; read the measurements at the source.
58
+
59
+ ## Settings UI
60
+
61
+ Choose a compression profile, set the Auto Compact trigger level, and toggle code-skeleton compression in the same settings section. The toggle saves on change and shows the saved state on reload.
62
+
63
+ ![Context Compression Selector settings UI](packages/selector/assets/screenshots/context-compression-selector-settings.png)
64
+
65
+ ## Install
66
+
67
+ **Recommended: install from npm.** One dist-tag per Harness line — `dsh-0.1.5` for the 0.1.5 line (this branch), `dsh-0.1.2` for the 0.1.2 line.
68
+
69
+ ```sh
70
+ dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.5
71
+ # DSH 0.1.2 line:
72
+ # dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.2
73
+ dsh --profile web --dump-config
74
+ ```
75
+
76
+ From source (alternative — the internal package names intentionally stay upstream's):
77
+
78
+ ```sh
79
+ git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
80
+ cd dsh-context-compression-improved
81
+ pnpm install --frozen-lockfile
82
+ pnpm build
83
+ ```
84
+
85
+ Then pack the selector package and add it to a Harness profile — the full walkthrough, including verification and uninstall steps, is in the [installation guide](docs/installation.md).
86
+
87
+ ## Development
88
+
89
+ ```sh
90
+ pnpm install --frozen-lockfile
91
+ pnpm lint # ESLint baseline (also enforced in CI)
92
+ pnpm typecheck # runtime + selector + tests tsc, plus the bundle step
93
+ pnpm test # full vitest suite
94
+ pnpm test:watch # TDD loop: write the failing regression first, then make it pass
95
+ pnpm build
96
+ pnpm verify:release
97
+ ```
98
+
99
+ Contributions follow the upstream discipline: add the failing regression first, keep every production change inside this repository, and explain “triggered”, “enabled but skipped”, and fail-open evidence separately. See [CONTRIBUTING.md](CONTRIBUTING.md).
100
+
101
+ ## Compatibility
102
+
103
+ - Verified against DeepSeek Harness `dsh-v0.1.1-rc.2` using public plugin and profile APIs only; compatible with the official `dsh-v0.1.2-alpha.5` release.
104
+ - Requires Node `^22.19.0 || >=24` and pnpm `11.7.0`.
105
+ - The plugin uses only public Harness extension APIs and does not modify Harness core code. Unofficial community project, not affiliated with or endorsed by DeepSeek.
106
+
107
+ ## Credits and license
108
+
109
+ - Upstream project and all prior work: [WilliamShi666/dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector) by WilliamShi666 (MIT).
110
+ - Fork additions (code-skeleton gate, tooling, localized docs): drscrewdriver.
111
+ - Code-skeleton mechanism: [Headroom](https://github.com/headroomlabs-ai/headroom) (Apache-2.0) — see "Provenance, and whose numbers these are" above.
112
+ - MIT — see [LICENSE](LICENSE) (upstream copyright notice retained) and [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for bundled tokenizer provenance.
package/package.json CHANGED
@@ -1,142 +1,142 @@
1
- {
2
- "name": "dsh-context-compression-improved",
3
- "version": "0.2.3",
4
- "publishConfig": {
5
- "registry": "https://registry.npmjs.org",
6
- "access": "public",
7
- "tag": "dsh-0.1.2"
8
- },
9
- "type": "module",
10
- "main": "packages/selector/lib/index.js",
11
- "types": "packages/selector/lib/index.d.ts",
12
- "exports": {
13
- ".": {
14
- "types": "./packages/selector/lib/index.d.ts",
15
- "default": "./packages/selector/lib/index.js"
16
- },
17
- "./invariant": {
18
- "types": "./packages/selector/lib/invariant.d.ts",
19
- "default": "./packages/selector/lib/invariant.js"
20
- },
21
- "./pruner": {
22
- "types": "./packages/selector/lib/pruner.d.ts",
23
- "default": "./packages/selector/lib/pruner.js"
24
- },
25
- "./client": {
26
- "types": "./packages/selector/lib/client.d.ts",
27
- "default": "./packages/selector/lib/client.js"
28
- },
29
- "./package.json": "./package.json"
30
- },
31
- "dependencies": {
32
- "@huggingface/tokenizers": "0.1.3",
33
- "js-yaml": "^4.3.2"
34
- },
35
- "dsh": {
36
- "client": {
37
- "inject": [
38
- "@deepseek-ai/dsh-client-locale",
39
- "@deepseek-ai/dsh-client-runtime",
40
- "@deepseek-ai/dsh-client-ui-settings",
41
- "@deepseek-ai/dsh-client-ui-workspace"
42
- ],
43
- "platform": "web"
44
- },
45
- "bundle": {
46
- "patch": "./packages/selector/cordis.patch.yml"
47
- }
48
- },
49
- "license": "MIT",
50
- "repository": {
51
- "type": "git",
52
- "url": "git+https://github.com/drscrewdriver/dsh-context-compression-improved.git"
53
- },
54
- "packageManager": "pnpm@11.7.0",
55
- "engines": {
56
- "node": "^22.19.0 || >=24.0.0",
57
- "dsh": ">=0.1.2-rc.1 <0.1.3-0"
58
- },
59
- "scripts": {
60
- "build": "pnpm -r --if-present run bundle",
61
- "build:scripts": "tsc -p tsconfig.scripts.json",
62
- "typecheck": "pnpm --filter dsh-context-compression-improved run bundle && pnpm --filter dsh-context-compression-improved run typecheck && pnpm run typecheck:tests",
63
- "typecheck:tests": "tsc --noEmit -p tsconfig.tests.json",
64
- "lint": "eslint packages scripts eslint.config.js",
65
- "lint:fix": "eslint packages scripts eslint.config.js --fix",
66
- "test": "vitest run",
67
- "test:watch": "vitest",
68
- "test:built": "vitest run --config vitest.built.config.ts",
69
- "test:e2e:packed": "node scripts-dist/packed-install-e2e.js",
70
- "test:unit": "vitest run",
71
- "verify:release": "node scripts-dist/verify-release.js",
72
- "pack:dry-run": "pnpm -r --if-present run pack:dry-run"
73
- },
74
- "peerDependencies": {
75
- "@deepseek-ai/dsh-client-locale": ">=0.1.2-rc.1 <0.1.3-0",
76
- "@deepseek-ai/dsh-client-runtime": ">=0.1.2-rc.1 <0.1.3-0",
77
- "@deepseek-ai/dsh-client-ui-settings": ">=0.1.2-rc.1 <0.1.3-0",
78
- "@deepseek-ai/dsh-client-ui-workspace": ">=0.1.2-rc.1 <0.1.3-0"
79
- },
80
- "peerDependenciesMeta": {
81
- "@deepseek-ai/dsh-client-locale": {
82
- "optional": true
83
- },
84
- "@deepseek-ai/dsh-client-runtime": {
85
- "optional": true
86
- },
87
- "@deepseek-ai/dsh-client-ui-settings": {
88
- "optional": true
89
- },
90
- "@deepseek-ai/dsh-client-ui-workspace": {
91
- "optional": true
92
- }
93
- },
94
- "devDependencies": {
95
- "@deepseek-ai/cordis": "4.0.1",
96
- "@deepseek-ai/cordis-plugin-group": "1.0.1",
97
- "@deepseek-ai/cordis-plugin-include": "1.0.6",
98
- "@deepseek-ai/cordis-plugin-loader": "1.0.2",
99
- "@deepseek-ai/dsh-agent": "0.1.1-rc.2",
100
- "@deepseek-ai/dsh-agent-loop": "0.1.1-rc.2",
101
- "@deepseek-ai/dsh-agent-loop-testkit": "0.1.1-rc.2",
102
- "@deepseek-ai/dsh-agent-presets": "0.1.1-rc.2",
103
- "@deepseek-ai/dsh-client-locale": "0.1.1-rc.2",
104
- "@deepseek-ai/dsh-client-runtime": "0.1.1-rc.2",
105
- "@deepseek-ai/dsh-client-ui-primitives": "0.1.1-rc.2",
106
- "@deepseek-ai/dsh-client-ui-settings": "0.1.1-rc.2",
107
- "@deepseek-ai/dsh-client-ui-slots": "0.1.1-rc.2",
108
- "@deepseek-ai/dsh-client-ui-workspace": "0.1.1-rc.2",
109
- "@deepseek-ai/dsh-command-compact": "0.1.1-rc.2",
110
- "@deepseek-ai/dsh-commands": "0.1.1-rc.2",
111
- "@deepseek-ai/dsh-compaction": "0.1.1-rc.2",
112
- "@deepseek-ai/dsh-compaction-basic": "0.1.1-rc.2",
113
- "@deepseek-ai/dsh-invariants": "0.1.1-rc.2",
114
- "@deepseek-ai/dsh-llm": "0.1.1-rc.2",
115
- "@deepseek-ai/dsh-llm-deepseek": "0.1.1-rc.2",
116
- "@deepseek-ai/dsh-scope": "0.1.1-rc.2",
117
- "@deepseek-ai/dsh-session": "0.1.1-rc.2",
118
- "@deepseek-ai/dsh-settings": "0.1.1-rc.2",
119
- "@deepseek-ai/dsh-subagent": "0.1.1-rc.2",
120
- "@deepseek-ai/dsh-subagent-fork-in-process": "0.1.1-rc.2",
121
- "@deepseek-ai/dsh-subagent-spawn-in-process": "0.1.1-rc.2",
122
- "@deepseek-ai/dsh-system-prompt": "0.1.1-rc.2",
123
- "@deepseek-ai/dsh-token-meter": "0.1.1-rc.2",
124
- "@deepseek-ai/dsh-tools": "0.1.1-rc.2",
125
- "@deepseek-ai/schemastery": "3.18.1",
126
- "@eslint/js": "^10.0.1",
127
- "@testing-library/react": "^16.3.2",
128
- "@tsdown/css": "^0.22.14",
129
- "@types/js-yaml": "^4.0.9",
130
- "@types/node": "^22.20.0",
131
- "@types/react": "~18.3.1",
132
- "eslint": "^10.10.0",
133
- "globals": "^17.12.0",
134
- "jsdom": "29.1.1",
135
- "lightningcss": "^1.33.0",
136
- "react": "^18.2.0",
137
- "tsdown": "^0.22.2",
138
- "typescript": "^6.0.3",
139
- "typescript-eslint": "^8.69.0",
140
- "vitest": "^4.1.8"
141
- }
142
- }
1
+ {
2
+ "name": "dsh-context-compression-improved",
3
+ "version": "0.2.4",
4
+ "publishConfig": {
5
+ "registry": "https://registry.npmjs.org",
6
+ "access": "public",
7
+ "tag": "dsh-0.1.2"
8
+ },
9
+ "type": "module",
10
+ "main": "packages/selector/lib/index.js",
11
+ "types": "packages/selector/lib/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./packages/selector/lib/index.d.ts",
15
+ "default": "./packages/selector/lib/index.js"
16
+ },
17
+ "./invariant": {
18
+ "types": "./packages/selector/lib/invariant.d.ts",
19
+ "default": "./packages/selector/lib/invariant.js"
20
+ },
21
+ "./pruner": {
22
+ "types": "./packages/selector/lib/pruner.d.ts",
23
+ "default": "./packages/selector/lib/pruner.js"
24
+ },
25
+ "./client": {
26
+ "types": "./packages/selector/lib/client.d.ts",
27
+ "default": "./packages/selector/lib/client.js"
28
+ },
29
+ "./package.json": "./package.json"
30
+ },
31
+ "dependencies": {
32
+ "@huggingface/tokenizers": "0.1.3",
33
+ "js-yaml": "^4.3.2"
34
+ },
35
+ "dsh": {
36
+ "client": {
37
+ "inject": [
38
+ "@deepseek-ai/dsh-client-locale",
39
+ "@deepseek-ai/dsh-client-runtime",
40
+ "@deepseek-ai/dsh-client-ui-settings",
41
+ "@deepseek-ai/dsh-client-ui-workspace"
42
+ ],
43
+ "platform": "web"
44
+ },
45
+ "bundle": {
46
+ "patch": "./packages/selector/cordis.patch.yml"
47
+ }
48
+ },
49
+ "license": "MIT",
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/drscrewdriver/dsh-context-compression-improved.git"
53
+ },
54
+ "packageManager": "pnpm@11.7.0",
55
+ "engines": {
56
+ "node": "^22.19.0 || >=24.0.0",
57
+ "dsh": ">=0.1.2-rc.1 <0.1.3-0"
58
+ },
59
+ "scripts": {
60
+ "build": "pnpm -r --if-present run bundle",
61
+ "build:scripts": "tsc -p tsconfig.scripts.json",
62
+ "typecheck": "pnpm --filter dsh-context-compression-improved run bundle && pnpm --filter dsh-context-compression-improved run typecheck && pnpm run typecheck:tests",
63
+ "typecheck:tests": "tsc --noEmit -p tsconfig.tests.json",
64
+ "lint": "eslint packages scripts eslint.config.js",
65
+ "lint:fix": "eslint packages scripts eslint.config.js --fix",
66
+ "test": "vitest run",
67
+ "test:watch": "vitest",
68
+ "test:built": "vitest run --config vitest.built.config.ts",
69
+ "test:e2e:packed": "node scripts-dist/packed-install-e2e.js",
70
+ "test:unit": "vitest run",
71
+ "verify:release": "node scripts-dist/verify-release.js",
72
+ "pack:dry-run": "pnpm -r --if-present run pack:dry-run"
73
+ },
74
+ "peerDependencies": {
75
+ "@deepseek-ai/dsh-client-locale": ">=0.1.2-rc.1 <0.1.3-0",
76
+ "@deepseek-ai/dsh-client-runtime": ">=0.1.2-rc.1 <0.1.3-0",
77
+ "@deepseek-ai/dsh-client-ui-settings": ">=0.1.2-rc.1 <0.1.3-0",
78
+ "@deepseek-ai/dsh-client-ui-workspace": ">=0.1.2-rc.1 <0.1.3-0"
79
+ },
80
+ "peerDependenciesMeta": {
81
+ "@deepseek-ai/dsh-client-locale": {
82
+ "optional": true
83
+ },
84
+ "@deepseek-ai/dsh-client-runtime": {
85
+ "optional": true
86
+ },
87
+ "@deepseek-ai/dsh-client-ui-settings": {
88
+ "optional": true
89
+ },
90
+ "@deepseek-ai/dsh-client-ui-workspace": {
91
+ "optional": true
92
+ }
93
+ },
94
+ "devDependencies": {
95
+ "@deepseek-ai/cordis": "4.0.1",
96
+ "@deepseek-ai/cordis-plugin-group": "1.0.1",
97
+ "@deepseek-ai/cordis-plugin-include": "1.0.6",
98
+ "@deepseek-ai/cordis-plugin-loader": "1.0.2",
99
+ "@deepseek-ai/dsh-agent": "0.1.1-rc.2",
100
+ "@deepseek-ai/dsh-agent-loop": "0.1.1-rc.2",
101
+ "@deepseek-ai/dsh-agent-loop-testkit": "0.1.1-rc.2",
102
+ "@deepseek-ai/dsh-agent-presets": "0.1.1-rc.2",
103
+ "@deepseek-ai/dsh-client-locale": "0.1.1-rc.2",
104
+ "@deepseek-ai/dsh-client-runtime": "0.1.1-rc.2",
105
+ "@deepseek-ai/dsh-client-ui-primitives": "0.1.1-rc.2",
106
+ "@deepseek-ai/dsh-client-ui-settings": "0.1.1-rc.2",
107
+ "@deepseek-ai/dsh-client-ui-slots": "0.1.1-rc.2",
108
+ "@deepseek-ai/dsh-client-ui-workspace": "0.1.1-rc.2",
109
+ "@deepseek-ai/dsh-command-compact": "0.1.1-rc.2",
110
+ "@deepseek-ai/dsh-commands": "0.1.1-rc.2",
111
+ "@deepseek-ai/dsh-compaction": "0.1.1-rc.2",
112
+ "@deepseek-ai/dsh-compaction-basic": "0.1.1-rc.2",
113
+ "@deepseek-ai/dsh-invariants": "0.1.1-rc.2",
114
+ "@deepseek-ai/dsh-llm": "0.1.1-rc.2",
115
+ "@deepseek-ai/dsh-llm-deepseek": "0.1.1-rc.2",
116
+ "@deepseek-ai/dsh-scope": "0.1.1-rc.2",
117
+ "@deepseek-ai/dsh-session": "0.1.1-rc.2",
118
+ "@deepseek-ai/dsh-settings": "0.1.1-rc.2",
119
+ "@deepseek-ai/dsh-subagent": "0.1.1-rc.2",
120
+ "@deepseek-ai/dsh-subagent-fork-in-process": "0.1.1-rc.2",
121
+ "@deepseek-ai/dsh-subagent-spawn-in-process": "0.1.1-rc.2",
122
+ "@deepseek-ai/dsh-system-prompt": "0.1.1-rc.2",
123
+ "@deepseek-ai/dsh-token-meter": "0.1.1-rc.2",
124
+ "@deepseek-ai/dsh-tools": "0.1.1-rc.2",
125
+ "@deepseek-ai/schemastery": "3.18.1",
126
+ "@eslint/js": "^10.0.1",
127
+ "@testing-library/react": "^16.3.2",
128
+ "@tsdown/css": "^0.22.14",
129
+ "@types/js-yaml": "^4.0.9",
130
+ "@types/node": "^22.20.0",
131
+ "@types/react": "~18.3.1",
132
+ "eslint": "^10.10.0",
133
+ "globals": "^17.12.0",
134
+ "jsdom": "29.1.1",
135
+ "lightningcss": "^1.33.0",
136
+ "react": "^18.2.0",
137
+ "tsdown": "^0.22.2",
138
+ "typescript": "^6.0.3",
139
+ "typescript-eslint": "^8.69.0",
140
+ "vitest": "^4.1.8"
141
+ }
142
+ }
@@ -1,31 +1,31 @@
1
- # dsh-context-compression-improved
2
-
3
- The installable Product Bundle for the unofficial community DeepSeek Harness context-compression selector.
4
-
5
- **0.1.0 highlights:** DeepSeek V4 Flash Vision's official tokenizer is included; users can choose the model-driven Auto Compact threshold; standard profile watermarks and compression parameters follow that choice.
6
-
7
- ```sh
8
- ```sh
9
- dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.5
10
- # DSH 0.1.2 line:
11
- # dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.2
12
- dsh --profile web --dump-config
13
- ```
14
- dsh --profile web --dump-config
15
- ```
16
-
17
- This one command installs the Bundle and its pinned `@huggingface/tokenizers` dependency; there is no separate runtime package. The Bundle contributes Host settings, the Web UI, and a reversible preset overlay. All presets except the exact built-in `minimal` id receive the compression stack; switching non-Minimal presets preserves the saved selector settings. Minimal pauses plugin compression without deleting the setting.
18
-
19
- ## What it provides
20
-
21
- It provides deterministic Fresh, Aggregate, History, Native tool-result, and Custom TailTrim compression; a plugin-owned `context_compression_retrieve` recovery tool; structured audit records; and a pinned offline DeepSeek V4 tokenizer. It uses only public DeepSeek Harness APIs and supports both `0.1.1-rc.2` and `0.1.2-alpha.5`; it does not patch Harness core.
22
-
23
- Lossy rewrites require exact same-revision counts before and after replacement. Verified model ids are `deepseek-v4-flash`, `deepseek-v4-pro`, and `deepseek-v4-flash-vision-exp`. Vision text counting uses the separately pinned `deepseek-ai/DeepSeek-V4-Flash-Vision-Exp` tokenizer. Vision images use the official image-processor arithmetic validated against official golden fixtures and are reported as `tokenizer-estimate`: the four alignment residues over valid intrinsic dimensions are collapsed to their midpoint, with 384 tokens retained as the per-image upper bound; malformed or unevaluable dimensions use a fixed 256-token fallback. The estimate is not exact because the absolute prompt position and the adapter's final image projection are not publicly observable. Image-bearing tool-result candidates remain exact-ineligible and intact; unknown models, unavailable tokenizer assets, unsafe tool groups, and incomplete text measurements still fail open.
24
-
25
- Audit log records use the prefix `context-compression audit ` and distinguish policy snapshots, skipped/disabled components, committed rewrites, fail-open errors, and observed core `compaction/summary` events. No audit record contains prompt or tool-result content.
26
-
27
- The first `policy-frozen` record carries the complete settings/deployment snapshot. It is emitted through the Harness logger, so its retention follows the configured log sink; standard prune/replacement Session events remain the durable proof of committed rewrites. This package does not hard-code a private path below `~/.dsh`.
28
-
29
- Verified compatibility: DeepSeek Harness `dsh-v0.1.1-rc.2` and `dsh-v0.1.2-alpha.5`, Node `^22.19.0 || >=24`. No Harness core patch is required.
30
-
31
- See the [full README](https://github.com/WilliamShi666/dsh-context-compression-improved#readme) for profiles, defaults, audit evidence, Adaptive/cache limitations, upgrade/removal, and security guidance. Tokenizer provenance and checksums are in `assets/deepseek-v4/manifest.json` and `assets/deepseek-v4-vision-exp/manifest.json`, summarized in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). This package is not affiliated with or endorsed by DeepSeek.
1
+ # dsh-context-compression-improved
2
+
3
+ The installable Product Bundle for the unofficial community DeepSeek Harness context-compression selector.
4
+
5
+ **0.1.0 highlights:** DeepSeek V4 Flash Vision's official tokenizer is included; users can choose the model-driven Auto Compact threshold; standard profile watermarks and compression parameters follow that choice.
6
+
7
+ ```sh
8
+ ```sh
9
+ dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.5
10
+ # DSH 0.1.2 line:
11
+ # dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.2
12
+ dsh --profile web --dump-config
13
+ ```
14
+ dsh --profile web --dump-config
15
+ ```
16
+
17
+ This one command installs the Bundle and its pinned `@huggingface/tokenizers` dependency; there is no separate runtime package. The Bundle contributes Host settings, the Web UI, and a reversible preset overlay. All presets except the exact built-in `minimal` id receive the compression stack; switching non-Minimal presets preserves the saved selector settings. Minimal pauses plugin compression without deleting the setting.
18
+
19
+ ## What it provides
20
+
21
+ It provides deterministic Fresh, Aggregate, History, Native tool-result, and Custom TailTrim compression; a plugin-owned `context_compression_retrieve` recovery tool; structured audit records; and a pinned offline DeepSeek V4 tokenizer. It uses only public DeepSeek Harness APIs and supports both `0.1.1-rc.2` and `0.1.2-alpha.5`; it does not patch Harness core.
22
+
23
+ Lossy rewrites require exact same-revision counts before and after replacement. Verified model ids are `deepseek-v4-flash`, `deepseek-v4-pro`, and `deepseek-v4-flash-vision-exp`. Vision text counting uses the separately pinned `deepseek-ai/DeepSeek-V4-Flash-Vision-Exp` tokenizer. Vision images use the official image-processor arithmetic validated against official golden fixtures and are reported as `tokenizer-estimate`: the four alignment residues over valid intrinsic dimensions are collapsed to their midpoint, with 384 tokens retained as the per-image upper bound; malformed or unevaluable dimensions use a fixed 256-token fallback. The estimate is not exact because the absolute prompt position and the adapter's final image projection are not publicly observable. Image-bearing tool-result candidates remain exact-ineligible and intact; unknown models, unavailable tokenizer assets, unsafe tool groups, and incomplete text measurements still fail open.
24
+
25
+ Audit log records use the prefix `context-compression audit ` and distinguish policy snapshots, skipped/disabled components, committed rewrites, fail-open errors, and observed core `compaction/summary` events. No audit record contains prompt or tool-result content.
26
+
27
+ The first `policy-frozen` record carries the complete settings/deployment snapshot. It is emitted through the Harness logger, so its retention follows the configured log sink; standard prune/replacement Session events remain the durable proof of committed rewrites. This package does not hard-code a private path below `~/.dsh`.
28
+
29
+ Verified compatibility: DeepSeek Harness `dsh-v0.1.1-rc.2` and `dsh-v0.1.2-alpha.5`, Node `^22.19.0 || >=24`. No Harness core patch is required.
30
+
31
+ See the [full README](https://github.com/WilliamShi666/dsh-context-compression-improved#readme) for profiles, defaults, audit evidence, Adaptive/cache limitations, upgrade/removal, and security guidance. Tokenizer provenance and checksums are in `assets/deepseek-v4/manifest.json` and `assets/deepseek-v4-vision-exp/manifest.json`, summarized in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). This package is not affiliated with or endorsed by DeepSeek.