dsh-context-compression-improved 0.2.4 → 0.2.5

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 (127) hide show
  1. package/.gitattributes +2 -1
  2. package/.githooks/pre-push +37 -0
  3. package/.github/workflows/ci.yml +8 -8
  4. package/CHANGELOG.ja.md +169 -39
  5. package/CHANGELOG.ko.md +167 -39
  6. package/CHANGELOG.md +212 -16
  7. package/CHANGELOG.zh.md +152 -39
  8. package/CONTRIBUTING.md +22 -22
  9. package/README.ja.md +85 -104
  10. package/README.ko.md +85 -103
  11. package/README.md +1 -19
  12. package/README.zh.md +85 -101
  13. package/THIRD_PARTY_NOTICES.md +14 -14
  14. package/docs/compat-0.1.5-report.md +77 -0
  15. package/docs/installation.ja.md +78 -76
  16. package/docs/installation.ko.md +78 -76
  17. package/docs/installation.md +103 -76
  18. package/docs/installation.zh.md +100 -76
  19. package/docs/repair-log.md +657 -582
  20. package/eslint.config.js +30 -30
  21. package/package.json +75 -54
  22. package/packages/selector/README.md +7 -12
  23. package/packages/selector/README.zh.md +6 -13
  24. package/packages/selector/THIRD_PARTY_NOTICES.md +32 -38
  25. package/packages/selector/cordis.patch.yml +27 -19
  26. package/packages/selector/dsh.plugin.json +16 -16
  27. package/packages/selector/lib/client.d.ts +97 -5
  28. package/packages/selector/lib/client.js +1884 -92
  29. package/packages/selector/lib/config.js +863 -6
  30. package/packages/selector/lib/index.d.ts +29 -21
  31. package/packages/selector/lib/index.js +424 -18
  32. package/packages/selector/lib/invariant.js +4 -4
  33. package/packages/selector/lib/pruner.d.ts +179 -4
  34. package/packages/selector/lib/pruner.js +1406 -371
  35. package/packages/selector/lib/style.css +42 -0
  36. package/packages/selector/lib/tail-trim.js +13 -4
  37. package/packages/selector/package.json +18 -27
  38. package/packages/selector/screenshots.json +3 -6
  39. package/packages/selector/src/client/CompressionProfileControls.tsx +293 -229
  40. package/packages/selector/src/client/CompressionProfileSelector.module.css +199 -170
  41. package/packages/selector/src/client/CompressionProfileSelector.tsx +85 -79
  42. package/packages/selector/src/client/EstimatorControls.tsx +277 -281
  43. package/packages/selector/src/client/decode.ts +57 -49
  44. package/packages/selector/src/client/index.ts +200 -62
  45. package/packages/selector/src/client/locales/de.ts +141 -0
  46. package/packages/selector/src/client/locales/es.ts +141 -0
  47. package/packages/selector/src/client/locales/fr.ts +141 -0
  48. package/packages/selector/src/client/locales/it.ts +141 -0
  49. package/packages/selector/src/client/locales/ja.ts +141 -0
  50. package/packages/selector/src/client/locales/ko.ts +141 -0
  51. package/packages/selector/src/client/locales/ru.ts +141 -0
  52. package/packages/selector/src/client/locales.ts +282 -198
  53. package/packages/selector/src/client/monitor-fab.ts +336 -0
  54. package/packages/selector/src/client/preset-options.ts +88 -70
  55. package/packages/selector/src/client/savings-card.tsx +150 -0
  56. package/packages/selector/src/client/settings-section.tsx +140 -126
  57. package/packages/selector/src/deepseek-v4-tokenizer.ts +205 -210
  58. package/packages/selector/src/index.ts +671 -327
  59. package/packages/selector/src/invariant.ts +113 -113
  60. package/packages/selector/src/profiles.ts +431 -342
  61. package/packages/selector/src/pruner/state.ts +57 -43
  62. package/packages/selector/src/pruner.ts +2736 -2154
  63. package/packages/selector/src/runtime/audit.ts +303 -231
  64. package/packages/selector/src/runtime/config.ts +756 -642
  65. package/packages/selector/src/runtime/measurement.ts +436 -432
  66. package/packages/selector/src/runtime/monitor.ts +235 -0
  67. package/packages/selector/src/runtime/retrieve.ts +479 -457
  68. package/packages/selector/src/runtime/savings.ts +337 -0
  69. package/packages/selector/src/runtime/session-events.ts +30 -17
  70. package/packages/selector/src/runtime/summary-command.ts +127 -0
  71. package/packages/selector/src/runtime/tail-trim.ts +166 -166
  72. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +233 -0
  73. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +204 -0
  74. package/packages/selector/src/runtime/tokenpilot/advisor.ts +419 -0
  75. package/packages/selector/src/runtime/tokenpilot/benefit.ts +200 -0
  76. package/packages/selector/src/runtime/tokenpilot/estimator.ts +151 -183
  77. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +53 -0
  78. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +65 -0
  79. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +125 -0
  80. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +37 -0
  81. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +303 -275
  82. package/packages/selector/src/runtime/types.ts +365 -325
  83. package/packages/selector/tests/advisor-report.host.spec.ts +223 -0
  84. package/packages/selector/tests/auto-compact.client.spec.tsx +214 -226
  85. package/packages/selector/tests/built/client-artifact.spec.ts +59 -51
  86. package/packages/selector/tests/code-skeleton.client.spec.ts +91 -88
  87. package/packages/selector/tests/custom-contract.client.spec.ts +205 -202
  88. package/packages/selector/tests/estimator-channel.client.spec.tsx +253 -247
  89. package/packages/selector/tests/estimator-route-registration.host.spec.ts +194 -176
  90. package/packages/selector/tests/host-preset-overlay.host.spec.ts +206 -204
  91. package/packages/selector/tests/monitor-fab.client.spec.ts +138 -0
  92. package/packages/selector/tests/preset-options-write.client.spec.ts +207 -181
  93. package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +201 -196
  94. package/packages/selector/tests/preset-overlay.host.spec.ts +8 -18
  95. package/packages/selector/tests/profiles.client.spec.tsx +436 -434
  96. package/packages/selector/tests/public/package-contract.client.spec.ts +78 -33
  97. package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +232 -0
  98. package/packages/selector/tests/runtime/advisor-invariant.spec.ts +272 -0
  99. package/packages/selector/tests/runtime/advisor.spec.ts +226 -0
  100. package/packages/selector/tests/runtime/audit.spec.ts +275 -172
  101. package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +96 -0
  102. package/packages/selector/tests/runtime/intent-gate.spec.ts +62 -0
  103. package/packages/selector/tests/runtime/intent-summary.spec.ts +156 -0
  104. package/packages/selector/tests/runtime/monitor.spec.ts +301 -0
  105. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2724 -2702
  106. package/packages/selector/tests/runtime/savings.spec.ts +120 -0
  107. package/packages/selector/tests/runtime/session-events.spec.ts +27 -27
  108. package/packages/selector/tests/runtime/summary-command.spec.ts +154 -0
  109. package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +217 -0
  110. package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +79 -56
  111. package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +116 -100
  112. package/packages/selector/tests/settings-seat.client.spec.ts +130 -0
  113. package/packages/selector/tests/standing-generation.host.spec.ts +142 -87
  114. package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +253 -250
  115. package/pnpm-workspace.yaml +66 -19
  116. package/scripts/capture-profile-baseline.mjs +42 -0
  117. package/scripts/generate-tokenizer-fixtures.py +81 -81
  118. package/scripts/generate-vision-fixtures.py +208 -208
  119. package/scripts/{packed-components-smoke.ts → packed-components-smoke.mjs} +732 -713
  120. package/scripts/{packed-install-e2e.ts → packed-install-e2e.mjs} +1273 -1072
  121. package/scripts/toolclass-corpus-replay.mjs +281 -273
  122. package/scripts/{verify-release.ts → verify-release.mjs} +318 -300
  123. package/tests/TEST_INVENTORY.md +41 -42
  124. package/scripts/capture-profile-baseline.ts +0 -80
  125. package/tsconfig.scripts.json +0 -13
  126. /package/{packages/selector/assets/screenshots → docs/assets}/context-compression-selector-profiles.jpg +0 -0
  127. /package/{packages/selector/assets/screenshots → docs/assets}/context-compression-selector-settings.png +0 -0
@@ -1,76 +1,78 @@
1
- # dsh-context-compression-improved 설치하기
2
-
3
- > [English](installation.md) · [中文](installation.zh.md) · [日本語](installation.ja.md) · [한국어](installation.ko.md)
4
-
5
- 이 가이드는 포크를 소스에서 설치하는 방법을 다룹니다. 이 포크는 업스트림에 대해 이름이 변경되었으며(`dsh-context-compression-selector` → `dsh-context-compression-improved`), 아직 npm에 게시되지 않았습니다. 소스와 세션 로그에 나타나는 `dsh-context-compression-improved-runtime`은 동결된 프로버넌스 라벨이며 패키지 의존성이 아닙니다. 런타임 의존성은 `@huggingface/tokenizers`와 `js-yaml`뿐입니다.
6
-
7
- ## 사전 요구 사항
8
-
9
- - Node `^22.19.0 || >=24` 및 pnpm `11.7.0`(`corepack enable`은 `packageManager`의 고정 버전을 사용합니다).
10
- - `0.1.1-rc.2` peer 범위와 호환되는 DeepSeek Harness(공식 `dsh-v0.1.2-alpha.5` 릴리스에서 검증).
11
- - DeepSeek V4 모델 경로(`deepseek-v4-flash`, `deepseek-v4-pro`, `deepseek-v4-flash-vision-exp`). 코드 스켈레톤 게이트를 포함한 손실 압축은 번들된 정확한 토크나이저가 필요하며, 그 외의 경로는 fail-open으로 원본 도구 결과를 유지합니다.
12
- - Git.
13
-
14
- ## 1. 소스에서 빌드
15
-
16
- ```sh
17
- git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
18
- cd dsh-context-compression-improved
19
- pnpm install --frozen-lockfile
20
- pnpm build
21
- ```
22
-
23
- `pnpm build`는 모든 패키지의 두 라이브러리 산출물을 번들합니다(`tsdown`). 설치 전에 전체 테스트 스위트를 실행하려면 `pnpm test`를 먼저 실행하세요.
24
-
25
- ## 2. Bundle 엔트리 패키지를 pack
26
-
27
- 셀렉터 패키지가 유일한 Bundle 엔트리이며, 런타임은 정확한 버전 의존성으로 함께 따라옵니다:
28
-
29
- ```sh
30
- cd packages/selector
31
- pnpm pack
32
- # → dsh-context-compression-improved-0.1.0.tgz
33
- cd ../..
34
- ```
35
-
36
- `pnpm pack`은 `prepack` 훅을 통해 번들을 실행하므로, tarball은 항상 체크아웃 내용과 일치합니다.
37
-
38
- ## 3. Harness 프로파일에 추가
39
-
40
- 셀렉터 패키지는 Harness Bundle 매니페스트 필드 `dsh.bundle.patch`를 선언하므로, `dsh plugin add`가 표준적인 out-of-tree Bundle 설치 경로입니다:
41
-
42
- ```sh
43
- dsh plugin --profile web add packages/selector/dsh-context-compression-improved-0.1.0.tgz
44
- dsh --profile web --dump-config
45
- ```
46
-
47
- 설치 후 해당 프로파일을 재시작하세요. 설정 덤프에 셀렉터 Bundle이 활성 상태로 표시되어야 합니다. 셀렉터와 런타임 패키지를 따로 설치하거나 연결하지 **마세요** — 런타임은 자동으로 설치됩니다.
48
-
49
- ## 4. 코드 스켈레톤 게이트 켜기
50
-
51
- DeepSeek Harness 설정 → **Context compression selector**를 엽니다:
52
-
53
- 1. 압축 프로파일을 선택합니다(게이트는 모든 프로파일에 대해 직교합니다).
54
- 2. 필요하면 Auto Compact 트리거 레벨을 조정합니다(50–90%, 기본값 80%).
55
- 3. **Code skeleton compression**을 **On**으로 설정합니다. 토글은 변경 시 저장됩니다.
56
-
57
- 다른 셀렉터 설정과 마찬가지로 값은 세션이 처음 관찰하는 시점에 고정됩니다 — 게이트는 새로 관찰된 세션에만 적용되며, 실행 중인 작업에는 적용되지 않습니다.
58
-
59
- ## 5. 업데이트 및 제거
60
-
61
- ```sh
62
- # 업데이트: pull, 재빌드, 재 pack, 새 tarball을 다시 추가
63
- git pull && pnpm install --frozen-lockfile && pnpm build
64
- cd packages/selector && pnpm pack && cd ../..
65
- dsh plugin --profile web add packages/selector/dsh-context-compression-improved-0.1.0.tgz
66
-
67
- # 제거
68
- dsh plugin --profile web remove dsh-context-compression-improved
69
- ```
70
-
71
- ## 문제 해결
72
-
73
- - **덤프에 Bundle이 활성으로 표시되지 않음**: 프로파일을 재시작하고, 셀렉터 엔트리 패키지(런타임이 아닌)를 추가했는지, Harness 버전이 호환 peer 범위 내인지 확인하세요.
74
- - **도구 결과가 한 번도 스켈레톤 압축되지 않음**: 게이트는 기본값이 off입니다. 토글을 확인하세요. 압축은 정확한 토크나이저 모델 경로에서 새로 들어온 초대형 소스코드 도구 결과에만 적용되며, 모든 건너뜀은 사유와 함께 감사 기록에 남습니다.
75
- - **토글이 읽을 수 없음으로 표시됨**: 저장된 `codeSkeleton` 섹션이 엄격한 브라우저 디코드에 실패했습니다(정확히 `{ enabled: boolean }`이어야 함). 잘못된 섹션을 제거하면 기본값으로 돌아갑니다.
76
- - **업데이트 단계 실패**: 플러그인은 npm 패키지 의미론을 따릅니다. 사용 중인 Harness 빌드가 tarball 간 업그레이드를 거부하면 먼저 이전 버전을 제거하세요.
1
+ # dsh-context-compression-improved 설치하기
2
+
3
+ > [English](installation.md) · [中文](installation.zh.md) · [日本語](installation.ja.md) · [한국어](installation.ko.md)
4
+
5
+ 이 가이드는 소스에서 포크를 설치합니다. 포크는 npm에도 게시되어 있습니다(dist-tag
6
+ `dsh-0.1.5`). 패키지 이름은 의도적으로 업스트림과 동일합니다(`dsh-context-compression-improved` 단일 패키지이며,
7
+ 예전에 별도 패키지였던 runtime이 함께 포함됩니다).
8
+
9
+ ## 사전 요구 사항
10
+
11
+ - Node `^22.19.0 || >=24` 및 pnpm `11.7.0`(`corepack enable`은 `packageManager`의 고정 버전을 사용합니다).
12
+ - `0.1.1-rc.2` peer 범위와 호환되는 DeepSeek Harness(공식 `dsh-v0.1.2-alpha.5` 릴리스에서 검증).
13
+ - DeepSeek V4 모델 경로(`deepseek-v4-flash`, `deepseek-v4-pro`, `deepseek-v4-flash-vision-exp`). 코드 스켈레톤 게이트를 포함한 손실 압축은 번들된 정확한 토크나이저가 필요하며, 그 외의 경로는 fail-open으로 원본 도구 결과를 유지합니다.
14
+ - Git.
15
+
16
+ ## 1. 소스에서 빌드
17
+
18
+ ```sh
19
+ git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
20
+ cd dsh-context-compression-improved
21
+ pnpm install --frozen-lockfile
22
+ pnpm build
23
+ ```
24
+
25
+ `pnpm build`는 모든 패키지의두라이브러리 산출물을 번들합니다(`tsdown`). 설치 전에 전체 테스트 스위트를 실행하려면 `pnpm test`를 먼저 실행하세요.
26
+
27
+ ## 2. Bundle 엔트리 패키지를 pack
28
+
29
+ 셀렉터 패키지가 유일한 Bundle 엔트리이며, 런타임은 정확한 버전 의존성으로 함께 따라옵니다:
30
+
31
+ ```sh
32
+ cd packages/selector
33
+ pnpm pack
34
+ # → dsh-context-compression-improved-0.1.0.tgz
35
+ cd ../..
36
+ ```
37
+
38
+ `pnpm pack`은 `prepack` 훅을 통해 번들을 실행하므로, tarball은 항상 체크아웃 내용과 일치합니다.
39
+
40
+ ## 3. Harness 프로파일에 추가
41
+
42
+ 셀렉터 패키지는 Harness Bundle 매니페스트 필드 `dsh.bundle.patch`를 선언하므로, `dsh plugin add`가 표준적인 out-of-tree Bundle 설치 경로입니다:
43
+
44
+ ```sh
45
+ dsh plugin --profile web add packages/selector/dsh-context-compression-improved-0.1.0.tgz
46
+ dsh --profile web --dump-config
47
+ ```
48
+
49
+ 설치 후 해당 프로파일을 재시작하세요. 설정 덤프에 셀렉터 Bundle이 활성 상태로 표시되어야 합니다. 셀렉터와 런타임 패키지를 따로 설치하거나 연결하지 **마세요** — 런타임은 자동으로 설치됩니다.
50
+
51
+ ## 4. 코드 스켈레톤 게이트 켜기
52
+
53
+ DeepSeek Harness 설정 → **Context compression selector**를 엽니다:
54
+
55
+ 1. 압축 프로파일을 선택합니다(게이트는 모든 프로파일에 대해 직교합니다).
56
+ 2. 필요하면 Auto Compact 트리거 레벨을 조정합니다(50–90%, 기본값 80%).
57
+ 3. **Code skeleton compression**을 **On**으로 설정합니다. 토글은 변경시저장됩니다.
58
+
59
+ 다른 셀렉터 설정과 마찬가지로 값은 세션이 처음 관찰하는 시점에 고정됩니다—게이트는 새로 관찰된 세션에만 적용되며, 실행 중인 작업에는 적용되지 않습니다.
60
+
61
+ ## 5. 업데이트 및 제거
62
+
63
+ ```sh
64
+ # 업데이트: pull, 재빌드, 재pack, 새 tarball을 다시 추가
65
+ git pull && pnpm install --frozen-lockfile && pnpm build
66
+ cd packages/selector && pnpm pack && cd ../..
67
+ dsh plugin --profile web add packages/selector/dsh-context-compression-improved-0.1.0.tgz
68
+
69
+ # 제거
70
+ dsh plugin --profile web remove dsh-context-compression-improved
71
+ ```
72
+
73
+ ## 문제 해결
74
+
75
+ - **덤프에 Bundle이 활성으로 표시되지 않음**: 프로파일을 재시작하고, 셀렉터 엔트리 패키지(런타임이 아닌)를 추가했는지, Harness 버전이 호환 peer 범위 내인지 확인하세요.
76
+ - **도구 결과가 한 번도 스켈레톤 압축되지 않음**: 게이트는 기본값이 off입니다. 토글을 확인하세요 압축은 정확한 토크나이저 모델 경로에서 새로 들어온 초대형 소스코드 도구 결과에만 적용되며, 모든 건너뜀은 사유와 함께 감사 기록에 남습니다.
77
+ - **토글이 읽을 수 없음으로 표시됨**: 저장된 `codeSkeleton` 섹션이 엄격한 브라우저 디코드에 실패했습니다(정확히 `{ enabled: boolean }`이어야함. 잘못된 섹션을제거하면 기본값으로 돌아갑니다.
78
+ - **업데이트 단계 실패**: 플러그인은 npm 패키지 의미론을 따릅니다. 사용 중인 Harness 빌드가 tarball 간 업그레이드를 거부하면 먼저 이전 버전을 제거하세요.
@@ -1,76 +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 renamed relative to upstream (`dsh-context-compression-selector` → `dsh-context-compression-improved`) and is not yet published to npm. The literal `dsh-context-compression-improved-runtime` that appears in the source and in durable session logs is a frozen provenance label, not a package dependency — the runtime dependencies are `@huggingface/tokenizers` and `js-yaml`.
6
-
7
- ## Prerequisites
8
-
9
- - Node `^22.19.0 || >=24` and pnpm `11.7.0` (`corepack enable` picks the pinned version from `packageManager`).
10
- - 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).
11
- - A DeepSeek V4 model route (`deepseek-v4-flash`, `deepseek-v4-pro`, or `deepseek-v4-flash-vision-exp`). Lossy compression — including the code-skeleton gate — requires the exact bundled tokenizer; other routes fail open and keep original tool results.
12
- - Git.
13
-
14
- ## 1. Build from source
15
-
16
- ```sh
17
- git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
18
- cd dsh-context-compression-improved
19
- pnpm install --frozen-lockfile
20
- pnpm build
21
- ```
22
-
23
- `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.
24
-
25
- ## 2. Pack the Bundle entry package
26
-
27
- The selector package is the single Bundle entry; the runtime comes along as its exact-version dependency:
28
-
29
- ```sh
30
- cd packages/selector
31
- pnpm pack
32
- # → dsh-context-compression-improved-0.1.0.tgz
33
- cd ../..
34
- ```
35
-
36
- `pnpm pack` runs the bundle through the `prepack` hook, so the tarball always matches your checkout.
37
-
38
- ## 3. Add it to a Harness profile
39
-
40
- 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:
41
-
42
- ```sh
43
- dsh plugin --profile web add packages/selector/dsh-context-compression-improved-0.1.0.tgz
44
- dsh --profile web --dump-config
45
- ```
46
-
47
- 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.
48
-
49
- ## 4. Turn on the code-skeleton gate
50
-
51
- Open DeepSeek Harness settings → **Context compression selector**:
52
-
53
- 1. Pick a compression profile (the gate is orthogonal to all of them).
54
- 2. Optionally adjust the Auto Compact trigger level (50–90%, default 80%).
55
- 3. Set **Code skeleton compression** to **On**. The toggle saves on change.
56
-
57
- 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.
58
-
59
- ## 5. Update or remove
60
-
61
- ```sh
62
- # update: pull, rebuild, repack, and add the new tarball again
63
- git pull && pnpm install --frozen-lockfile && pnpm build
64
- cd packages/selector && pnpm pack && cd ../..
65
- dsh plugin --profile web add packages/selector/dsh-context-compression-improved-0.1.0.tgz
66
-
67
- # remove
68
- dsh plugin --profile web remove dsh-context-compression-improved
69
- ```
70
-
71
- ## Troubleshooting
72
-
73
- - **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.
74
- - **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 on exact-tokenizer model routes, and every skip is recorded with a reason in the audit trail.
75
- - **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.
76
- - **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.
@@ -1,76 +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 相对上游已重命名(`dsh-context-compression-selector` → `dsh-context-compression-improved`),且尚未发布 npm 包。源码与会话日志中出现的 `dsh-context-compression-improved-runtime` 是冻结的溯源标识,并非包依赖——运行时依赖只有 `@huggingface/tokenizers` 和 `js-yaml`。
6
-
7
- ## 前置条件
8
-
9
- - Node `^22.19.0 || >=24` 与 pnpm `11.7.0`(`corepack enable` 会按 `packageManager` 字段使用固定版本)。
10
- - 兼容 `0.1.1-rc.2` peer 范围的 DeepSeek Harness(已针对官方 `dsh-v0.1.2-alpha.5` 验证)。
11
- - DeepSeek V4 模型路由(`deepseek-v4-flash`、`deepseek-v4-pro` 或 `deepseek-v4-flash-vision-exp`)。有损压缩——包括代码骨架门——依赖内置的精确 tokenizer;其他路由 fail-open 并保留原始工具结果。
12
- - Git。
13
-
14
- ## 1. 从源码构建
15
-
16
- ```sh
17
- git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
18
- cd dsh-context-compression-improved
19
- pnpm install --frozen-lockfile
20
- pnpm build
21
- ```
22
-
23
- `pnpm build` 会打包所有包的两套产物(`tsdown`)。如需在安装前先跑全量测试,可执行 `pnpm test`。
24
-
25
- ## 2. 打包 Bundle 入口包
26
-
27
- selector 包是唯一的 Bundle 入口;runtime 作为其精确版本依赖自动随行:
28
-
29
- ```sh
30
- cd packages/selector
31
- pnpm pack
32
- # → dsh-context-compression-improved-0.1.0.tgz
33
- cd ../..
34
- ```
35
-
36
- `pnpm pack` 会通过 `prepack` 钩子执行打包,因此 tarball 始终与你的检出内容一致。
37
-
38
- ## 3. 安装到 Harness Profile
39
-
40
- selector 包声明了 Harness Bundle manifest 字段 `dsh.bundle.patch`,因此 `dsh plugin add` 是标准的树外 Bundle 安装方式:
41
-
42
- ```sh
43
- dsh plugin --profile web add packages/selector/dsh-context-compression-improved-0.1.0.tgz
44
- dsh --profile web --dump-config
45
- ```
46
-
47
- 安装后重启对应 Profile。配置导出中应显示 selector Bundle 已激活。**不要**分别安装或手动连接 selector 与 runtime 两个包——runtime 会自动安装。
48
-
49
- ## 4. 打开代码骨架门
50
-
51
- 打开 DeepSeek Harness 设置 → **上下文压缩选择器**:
52
-
53
- 1. 选择一个压缩 Profile(这道门与所有 Profile 正交)。
54
- 2. 按需调整 Auto Compact 触发水位(50–90%,默认 80%)。
55
- 3. 将**代码骨架压缩**设为**开**。开关即改即存。
56
-
57
- 与所有选择器设置一致,取值在会话首次观察时冻结——这道门只影响新观察的会话,不会改变正在运行的任务。
58
-
59
- ## 5. 更新或卸载
60
-
61
- ```sh
62
- # 更新:拉取、重建、重新打包、再次添加新 tarball
63
- git pull && pnpm install --frozen-lockfile && pnpm build
64
- cd packages/selector && pnpm pack && cd ../..
65
- dsh plugin --profile web add packages/selector/dsh-context-compression-improved-0.1.0.tgz
66
-
67
- # 卸载
68
- dsh plugin --profile web remove dsh-context-compression-improved
69
- ```
70
-
71
- ## 故障排除
72
-
73
- - **配置导出中 Bundle 未激活**:重启 Profile;确认添加的是 selector 入口包(而非 runtime),且 Harness 版本在兼容的 peer 范围内。
74
- - **工具结果从未被骨架化压缩**:该门默认关闭,请检查开关。压缩只作用于精确 tokenizer 路由上新鲜、超大、源码类的工具结果,且每次跳过都会在审计记录中留有原因。
75
- - **开关显示为不可读**:已存的 `codeSkeleton` 段未通过严格的浏览器解码(必须恰好是 `{ enabled: boolean }`)。删除畸形段即可恢复默认。
76
- - **升级步骤失败**:插件遵循 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 的升级,请先移除旧版本再安装。