dsh-context-compression-improved 0.5.6 → 0.5.8

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 (183) hide show
  1. package/.gitattributes +2 -2
  2. package/.githooks/pre-push +37 -37
  3. package/.github/workflows/ci.yml +39 -39
  4. package/CHANGELOG.ja.md +169 -169
  5. package/CHANGELOG.ko.md +167 -167
  6. package/CHANGELOG.md +323 -304
  7. package/CHANGELOG.zh.md +152 -152
  8. package/CONTRIBUTING.md +22 -22
  9. package/LICENSE +21 -21
  10. package/README.ja.md +85 -85
  11. package/README.ko.md +85 -85
  12. package/README.md +94 -94
  13. package/README.zh.md +85 -85
  14. package/SECURITY.md +18 -18
  15. package/THIRD_PARTY_NOTICES.md +14 -14
  16. package/docs/compat-0.1.5-report.md +77 -77
  17. package/docs/installation.ja.md +78 -78
  18. package/docs/installation.ko.md +78 -78
  19. package/docs/installation.md +103 -103
  20. package/docs/installation.zh.md +100 -100
  21. package/docs/repair-log.md +657 -657
  22. package/eslint.config.js +30 -30
  23. package/package.json +163 -164
  24. package/packages/selector/LICENSE +21 -21
  25. package/packages/selector/README.md +26 -26
  26. package/packages/selector/README.zh.md +24 -24
  27. package/packages/selector/THIRD_PARTY_NOTICES.md +32 -32
  28. package/packages/selector/cordis.patch.yml +27 -27
  29. package/packages/selector/docs/history-tool-call-working-set-spec.md +112 -112
  30. package/packages/selector/docs/native-tool-result-selector-spec.md +34 -34
  31. package/packages/selector/docs/subagent-cache-reuse-spec.md +46 -46
  32. package/packages/selector/dsh.plugin.json +16 -16
  33. package/packages/selector/lib/client.d.ts +59 -0
  34. package/packages/selector/lib/client.js +1738 -10
  35. package/packages/selector/lib/{advisor-state.js → config.js} +816 -65
  36. package/packages/selector/lib/index.d.ts +13 -1
  37. package/packages/selector/lib/index.js +295 -3
  38. package/packages/selector/lib/pruner.d.ts +65 -0
  39. package/packages/selector/lib/pruner.js +497 -262
  40. package/packages/selector/lib/style.css +88 -46
  41. package/packages/selector/package.json +114 -114
  42. package/packages/selector/screenshots.json +3 -3
  43. package/packages/selector/src/client/CompressionProfileControls.tsx +293 -226
  44. package/packages/selector/src/client/CompressionProfileSelector.module.css +199 -170
  45. package/packages/selector/src/client/CompressionProfileSelector.tsx +85 -83
  46. package/packages/selector/src/client/CustomPolicyEditor.tsx +216 -216
  47. package/packages/selector/src/client/EstimatorControls.tsx +277 -277
  48. package/packages/selector/src/client/decode.ts +57 -49
  49. package/packages/selector/src/client/index.ts +240 -149
  50. package/packages/selector/src/client/locales/de.ts +141 -0
  51. package/packages/selector/src/client/locales/es.ts +141 -0
  52. package/packages/selector/src/client/locales/fr.ts +141 -0
  53. package/packages/selector/src/client/locales/it.ts +141 -0
  54. package/packages/selector/src/client/locales/ja.ts +141 -0
  55. package/packages/selector/src/client/locales/ko.ts +141 -0
  56. package/packages/selector/src/client/locales/ru.ts +141 -0
  57. package/packages/selector/src/client/locales.ts +282 -196
  58. package/packages/selector/src/client/monitor-fab.ts +336 -0
  59. package/packages/selector/src/client/preset-options.ts +88 -88
  60. package/packages/selector/src/client/savings-card.tsx +150 -0
  61. package/packages/selector/src/client/settings-section.tsx +140 -124
  62. package/packages/selector/src/css-modules.d.ts +6 -6
  63. package/packages/selector/src/deepseek-v4-tokenizer.ts +205 -205
  64. package/packages/selector/src/estimator-catalog.ts +104 -104
  65. package/packages/selector/src/index.ts +673 -463
  66. package/packages/selector/src/invariant.ts +113 -113
  67. package/packages/selector/src/preset-overlay.ts +626 -626
  68. package/packages/selector/src/profiles.ts +431 -394
  69. package/packages/selector/src/pruner/content.ts +201 -201
  70. package/packages/selector/src/pruner/session.ts +94 -94
  71. package/packages/selector/src/pruner/state.ts +57 -50
  72. package/packages/selector/src/pruner/tuning.ts +23 -23
  73. package/packages/selector/src/pruner/types.ts +78 -78
  74. package/packages/selector/src/pruner.ts +2736 -2402
  75. package/packages/selector/src/runtime/adaptive-cost.ts +205 -205
  76. package/packages/selector/src/runtime/audit.ts +303 -286
  77. package/packages/selector/src/runtime/config.ts +756 -706
  78. package/packages/selector/src/runtime/custom-policy.ts +278 -278
  79. package/packages/selector/src/runtime/deepseek-official-pricing.ts +298 -298
  80. package/packages/selector/src/runtime/deepseek-v4-vision-tokens.ts +254 -254
  81. package/packages/selector/src/runtime/measurement.ts +436 -436
  82. package/packages/selector/src/runtime/monitor.ts +235 -0
  83. package/packages/selector/src/runtime/reducers.ts +1674 -1674
  84. package/packages/selector/src/runtime/retrieve.ts +479 -457
  85. package/packages/selector/src/runtime/savings.ts +337 -0
  86. package/packages/selector/src/runtime/session-events.ts +30 -30
  87. package/packages/selector/src/runtime/summary-command.ts +127 -0
  88. package/packages/selector/src/runtime/tail-trim.ts +166 -166
  89. package/packages/selector/src/runtime/token-count.ts +72 -72
  90. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +233 -188
  91. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +204 -149
  92. package/packages/selector/src/runtime/tokenpilot/advisor.ts +419 -419
  93. package/packages/selector/src/runtime/tokenpilot/benefit.ts +200 -200
  94. package/packages/selector/src/runtime/tokenpilot/dedup.ts +81 -81
  95. package/packages/selector/src/runtime/tokenpilot/estimator.ts +151 -151
  96. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +53 -0
  97. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +65 -0
  98. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +125 -0
  99. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +37 -0
  100. package/packages/selector/src/runtime/tokenpilot/locator.ts +128 -128
  101. package/packages/selector/src/runtime/tokenpilot/read-state.ts +98 -98
  102. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +303 -303
  103. package/packages/selector/src/runtime/toolclass.ts +103 -103
  104. package/packages/selector/src/runtime/types.ts +365 -346
  105. package/packages/selector/src/runtime/value.ts +48 -48
  106. package/packages/selector/tests/advisor-report.host.spec.ts +223 -223
  107. package/packages/selector/tests/auto-compact.client.spec.tsx +214 -213
  108. package/packages/selector/tests/built/client-artifact.spec.ts +59 -59
  109. package/packages/selector/tests/cache-prefix-audit.spec.ts +123 -123
  110. package/packages/selector/tests/code-skeleton.client.spec.ts +91 -90
  111. package/packages/selector/tests/custom-contract.client.spec.ts +205 -204
  112. package/packages/selector/tests/estimator-catalog.spec.ts +70 -70
  113. package/packages/selector/tests/estimator-channel.client.spec.tsx +253 -252
  114. package/packages/selector/tests/estimator-route-registration.host.spec.ts +194 -188
  115. package/packages/selector/tests/host-preset-overlay.host.spec.ts +206 -206
  116. package/packages/selector/tests/monitor-fab.client.spec.ts +138 -0
  117. package/packages/selector/tests/preset-options-write.client.spec.ts +207 -206
  118. package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +201 -201
  119. package/packages/selector/tests/preset-overlay.host.spec.ts +246 -246
  120. package/packages/selector/tests/profiles.client.spec.tsx +436 -434
  121. package/packages/selector/tests/public/package-contract.client.spec.ts +78 -78
  122. package/packages/selector/tests/runtime/adaptive-cost.spec.ts +167 -167
  123. package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +232 -232
  124. package/packages/selector/tests/runtime/advisor-invariant.spec.ts +272 -272
  125. package/packages/selector/tests/runtime/advisor.spec.ts +226 -226
  126. package/packages/selector/tests/runtime/audit.spec.ts +275 -274
  127. package/packages/selector/tests/runtime/auto-compact-config.spec.ts +523 -523
  128. package/packages/selector/tests/runtime/char-basis.spec.ts +30 -30
  129. package/packages/selector/tests/runtime/code-skeleton.spec.ts +152 -152
  130. package/packages/selector/tests/runtime/deepseek-official-pricing.spec.ts +186 -186
  131. package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +122 -122
  132. package/packages/selector/tests/runtime/deepseek-v4-vision-tokens.spec.ts +122 -122
  133. package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +96 -96
  134. package/packages/selector/tests/runtime/fixtures/profile-baseline.json +273 -273
  135. package/packages/selector/tests/runtime/fixtures/tokenizer-golden.json +106 -106
  136. package/packages/selector/tests/runtime/fixtures/vision-golden.json +459 -459
  137. package/packages/selector/tests/runtime/frequency-longstrings.spec.ts +74 -74
  138. package/packages/selector/tests/runtime/html-reducer.spec.ts +212 -212
  139. package/packages/selector/tests/runtime/intent-gate.spec.ts +62 -0
  140. package/packages/selector/tests/runtime/intent-summary.spec.ts +156 -0
  141. package/packages/selector/tests/runtime/line-mapping.spec.ts +153 -153
  142. package/packages/selector/tests/runtime/monitor.spec.ts +301 -0
  143. package/packages/selector/tests/runtime/prose-reducers.spec.ts +133 -133
  144. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2724 -2724
  145. package/packages/selector/tests/runtime/read-input-cap.spec.ts +33 -33
  146. package/packages/selector/tests/runtime/savings.spec.ts +120 -0
  147. package/packages/selector/tests/runtime/search-reducer.spec.ts +110 -110
  148. package/packages/selector/tests/runtime/session-events.spec.ts +27 -27
  149. package/packages/selector/tests/runtime/sidechannel.spec.ts +241 -241
  150. package/packages/selector/tests/runtime/summary-command.spec.ts +154 -0
  151. package/packages/selector/tests/runtime/toc-and-bundled.spec.ts +159 -159
  152. package/packages/selector/tests/runtime/tokenizer-golden.spec.ts +53 -53
  153. package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +217 -217
  154. package/packages/selector/tests/runtime/tokenpilot/dedup.spec.ts +52 -52
  155. package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +79 -79
  156. package/packages/selector/tests/runtime/tokenpilot/locator.spec.ts +76 -76
  157. package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +116 -116
  158. package/packages/selector/tests/runtime/tokenpilot/read-state.spec.ts +82 -82
  159. package/packages/selector/tests/runtime/toolclass.spec.ts +156 -156
  160. package/packages/selector/tests/runtime/value.spec.ts +23 -23
  161. package/packages/selector/tests/settings-seat.client.spec.ts +130 -118
  162. package/packages/selector/tests/standing-generation.host.spec.ts +697 -697
  163. package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +253 -253
  164. package/packages/selector/tests/support/cache-prefix-audit.ts +105 -105
  165. package/packages/selector/tests/support/mock-adapter.ts +37 -37
  166. package/packages/selector/tests/support/ui-primitives.tsx +34 -34
  167. package/packages/selector/tsconfig.json +11 -11
  168. package/packages/selector/tsdown.client.config.ts +102 -102
  169. package/packages/selector/tsdown.config.ts +20 -20
  170. package/pnpm-workspace.yaml +66 -66
  171. package/scripts/capture-profile-baseline.mjs +42 -42
  172. package/scripts/generate-tokenizer-fixtures.py +81 -81
  173. package/scripts/generate-vision-fixtures.py +208 -208
  174. package/scripts/packed-components-smoke.mjs +732 -732
  175. package/scripts/packed-install-e2e.mjs +1273 -1273
  176. package/scripts/toolclass-corpus-replay.mjs +281 -281
  177. package/scripts/verify-release.mjs +318 -317
  178. package/tests/TEST_INVENTORY.md +41 -41
  179. package/tsconfig.base.json +18 -18
  180. package/tsconfig.json +7 -7
  181. package/tsconfig.tests.json +15 -15
  182. package/vitest.built.config.ts +9 -9
  183. package/vitest.config.ts +43 -43
package/README.ko.md CHANGED
@@ -1,85 +1,85 @@
1
- # dsh-context-compression-improved
2
-
3
- > [dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector)의 개선 포크——DeepSeek Harness용 감사 가능한 도구 결과 컨텍스트 압축 셀렉터에, 직교하는 **코드 스켈레톤 압축 게이트*를추가했습니다.
4
-
5
- [English](README.md) · [中文说明](README.zh.md) · [日本語](README.ja.md) · [변경 로그](CHANGELOG.ko.md) · [설치 가이드](docs/installation.ko.md)
6
-
7
- > [!NOTE]
8
- > **이 포크가 업스트림 0.1.0에 추가한것**
9
- >
10
- > - 직교하는 **코드 스켈레톤 압축 게이트**(`codeSkeleton.enabled`, 기본값 off): 매우 큰 소스코드 도구 결과가 처음 노출될때 일반 리듀서로 넘어가기 전에 임포트와 선언부의 스켈레톤을 보존할수있습니다(함수 본문은 생략, 에러 라인은 유지).
11
- > - 동일한 셀렉터 설정 섹션에 모든 압축 프로파일과 독립적인 이 게이트의 토글을 추가.
12
- > - CI에 통합된 ESLint 베이스라인, `test:watch` TDD 루프, 영어/중국어(간체)/일본어/한국어 문서.
13
-
14
- > [!IMPORTANT]
15
- > 이 프로젝트는 **DeepSeek 모델만** 지원합니다. 손실 없는 측정과 손실 압축은 번들된 DeepSeek 공식 토크나이저(`deepseek-v4-flash`, `deepseek-v4-pro`, `deepseek-v4-flash-vision-exp`)에 의존합니다. 그외의 경우 fail-open으로 동작하며 원본 도구 결과를 유지합니다. 전체 안전 모델은 [업스트림 README](https://github.com/WilliamShi666/dsh-context-compression-selector#model-support-and-safety)를 참고하세요.
16
-
17
- ## 이것은 무엇인가
18
-
19
- 장시간 실행되는 에이전트 작업은 대량의 도구 출력을 축적합니다. 이커뮤니티 플러그인은 DeepSeek Harness 코어를 수정하지 않고, 선택 가능하고 감사 가능한 도구 결과 컨텍스트 압축 정책을 제공합니다:
20
-
21
- - **Fresh**: 모델이 받기 전에 새로 커진 도구 결과 세그먼트를 사전 압축합니다.
22
- - **Aggregate**: Fresh 압축 후에도 예산을 초과하면 다시 압축합니다.
23
- - **History / micro-compact**: 최근 작업 컨텍스트를 보호하면서 대상이 되는 오래된 도구 결과를 교체합니다.
24
- - **TailTrim**: Custom에서만 활성화할 수 있는 선택적 테일 축소 경로입니다.
25
- - **Native**: Harness 방식의 head/중간/tail 트리밍을 하나의 명시적 프로파일로 유지합니다.
26
- - **코드 스켈레톤(신규, 직교 게이트)**——아래 참고.
27
-
28
- 모든 결정은 기록됩니다: 단계, 리듀서, 트리거 이유, 건너뜀 이유, 그리고 가능한 경우 정확한 토큰 수.
29
-
30
- ## 코드 스켈레톤 게이트(신규)
31
-
32
- 게이트를 활성화하면 매우 큰 **소스코드 도구 결과**(예: 큰`read_file`)에 대해 먼저 스켈레톤 축소를 시도합니다: 임포트와 타입/함수/클래스 선언을 유지하고, 함수 본문은 마커와 함께 생략하며, 생략된 본문 안의 에러 라인은 보존합니다. 스켈레톤을 생성하거나 검증할 수 없으면 원래의 head 트리밍으로 폴백합니다——이 게이트가 컨텍스트를 악화시킬 수는 없습니다.
33
-
34
- 특성:
35
-
36
- - **직교**: 선택된 프로파일(`balanced`, `savings`, `cache-strict`, `adaptive`, `custom`, `off`, `native`)과 독립적입니다. 모든 프로파일이이게이트를 받습니다.
37
- - **기본값 off**: `codeSkeleton: { enabled: false }`이며, 직접 켜기 전까지는 동작하지 않습니다.
38
- - **측정이 선행**: 정확한 DeepSeek 토크나이저가 필요하며, 사용할수없으면 fail-open합니다.
39
- - **세션 고정**: 다른 셀렉터 설정과 마찬가지로 변경 사항은 새로 관찰된 세션에만 적용됩니다.
40
- - **엄격한 파싱**: `codeSkeleton`은 정확히 `{ enabled: boolean }`이어야 합니다. 잘못된 값은 런타임 쪽에서 예외를 던지고, 브라우저 UI에서는 읽을 수 없음으로 표시됩니다.
41
-
42
- ## 설정 UI
43
-
44
- 동일한 설정 섹션에서 압축 프로파일 선택, Auto Compact 트리거 레벨 조정, 코드 스켈레톤 압축 토글을 모두 처리할수있습니다. 토글은 변경시즉시 저장되며, 다시 불러올때저장된 상태가 표시됩니다.
45
-
46
- ![Context Compression Selector 설정 UI](docs/assets/context-compression-selector-settings.png)
47
-
48
- ## 설치
49
-
50
- 소스에서 빌드하여 설치합니다 —— 이 포크는 npm에도 `dsh-context-compression-improved`로 게시되어 있습니다(dist-tag `dsh-0.1.5`). 내부 패키지 이름은 의도적으로 업스트림과 동일하게 유지됩니다:
51
-
52
- ```sh
53
- git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
54
- cd dsh-context-compression-improved
55
- pnpm install --frozen-lockfile
56
- pnpm build
57
- ```
58
-
59
- 이후 셀렉터 패키지를 pack 해서 Harness 프로파일에 추가합니다——검증과 제거를 포함한 전체 절차는 [설치 가이드](docs/installation.ko.md)를 참고하세요.
60
-
61
- ## 개발
62
-
63
- ```sh
64
- pnpm install --frozen-lockfile
65
- pnpm lint # ESLint 베이스라인(CI에서도 강제)
66
- pnpm typecheck # runtime + selector + tests tsc 및 bundle 단계
67
- pnpm test # vitest 전체 스위트
68
- pnpm test:watch # TDD 루프: 먼저 실패하는 회귀 테스트를 작성하고, 통과시킨다
69
- pnpm build
70
- pnpm verify:release
71
- ```
72
-
73
- 기여는 업스트림의 규율을 따릅니다: 먼저 실패하는 회귀 테스트를 추가하고, 모든 프로덕션 변경은 이 저장소 안에 유지하며, "트리거됨", "활성화되었지만 건너뜀", "fail-open"의 증거를 각각 따로 제시하세요. [CONTRIBUTING.md](CONTRIBUTING.md) 참고.
74
-
75
- ## 호환성
76
-
77
- - 공개된 플러그인 및 프로파일 API만 사용하여 DeepSeek Harness `dsh-v0.1.1-rc.2`에서 검증되었으며, 공식 `dsh-v0.1.2-alpha.5` 릴리스와 호환됩니다.
78
- - Node `^22.19.0 || >=24`와 pnpm `11.7.0`이 필요합니다.
79
- - 플러그인은 Harness의 공개 확장 API만 사용하며 Harness 코어를 수정하지 않습니다. 비공식 커뮤니티 프로젝트이며 DeepSeek과 제휴하거나 승인받지 않았습니다.
80
-
81
- ## 크레딧과 라이선스
82
-
83
- - 업스트림 프로젝트와 기존의 모든 작업: [WilliamShi666/dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector), 작성자 WilliamShi666(MIT).
84
- - 포크에서 추가된것코드 스켈레톤 게이트, 툴체인, 다국어 문서): drscrewdriver.
85
- - MIT——[LICENSE](LICENSE)(업스트림 저작권 표기 유지) 참고. 번들된 토크나이저의 출처는 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
1
+ # dsh-context-compression-improved
2
+
3
+ > [dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector)의 개선 포크——DeepSeek Harness용 감사 가능한 도구 결과 컨텍스트 압축 셀렉터에, 직교하는 **코드 스켈레톤 압축 게이트*를추가했습니다.
4
+
5
+ [English](README.md) · [中文说明](README.zh.md) · [日本語](README.ja.md) · [변경 로그](CHANGELOG.ko.md) · [설치 가이드](docs/installation.ko.md)
6
+
7
+ > [!NOTE]
8
+ > **이 포크가 업스트림 0.1.0에 추가한것**
9
+ >
10
+ > - 직교하는 **코드 스켈레톤 압축 게이트**(`codeSkeleton.enabled`, 기본값 off): 매우 큰 소스코드 도구 결과가 처음 노출될때 일반 리듀서로 넘어가기 전에 임포트와 선언부의 스켈레톤을 보존할수있습니다(함수 본문은 생략, 에러 라인은 유지).
11
+ > - 동일한 셀렉터 설정 섹션에 모든 압축 프로파일과 독립적인 이 게이트의 토글을 추가.
12
+ > - CI에 통합된 ESLint 베이스라인, `test:watch` TDD 루프, 영어/중국어(간체)/일본어/한국어 문서.
13
+
14
+ > [!IMPORTANT]
15
+ > 이 프로젝트는 **DeepSeek 모델만** 지원합니다. 손실 없는 측정과 손실 압축은 번들된 DeepSeek 공식 토크나이저(`deepseek-v4-flash`, `deepseek-v4-pro`, `deepseek-v4-flash-vision-exp`)에 의존합니다. 그외의 경우 fail-open으로 동작하며 원본 도구 결과를 유지합니다. 전체 안전 모델은 [업스트림 README](https://github.com/WilliamShi666/dsh-context-compression-selector#model-support-and-safety)를 참고하세요.
16
+
17
+ ## 이것은 무엇인가
18
+
19
+ 장시간 실행되는 에이전트 작업은 대량의 도구 출력을 축적합니다. 이커뮤니티 플러그인은 DeepSeek Harness 코어를 수정하지 않고, 선택 가능하고 감사 가능한 도구 결과 컨텍스트 압축 정책을 제공합니다:
20
+
21
+ - **Fresh**: 모델이 받기 전에 새로 커진 도구 결과 세그먼트를 사전 압축합니다.
22
+ - **Aggregate**: Fresh 압축 후에도 예산을 초과하면 다시 압축합니다.
23
+ - **History / micro-compact**: 최근 작업 컨텍스트를 보호하면서 대상이 되는 오래된 도구 결과를 교체합니다.
24
+ - **TailTrim**: Custom에서만 활성화할 수 있는 선택적 테일 축소 경로입니다.
25
+ - **Native**: Harness 방식의 head/중간/tail 트리밍을 하나의 명시적 프로파일로 유지합니다.
26
+ - **코드 스켈레톤(신규, 직교 게이트)**——아래 참고.
27
+
28
+ 모든 결정은 기록됩니다: 단계, 리듀서, 트리거 이유, 건너뜀 이유, 그리고 가능한 경우 정확한 토큰 수.
29
+
30
+ ## 코드 스켈레톤 게이트(신규)
31
+
32
+ 게이트를 활성화하면 매우 큰 **소스코드 도구 결과**(예: 큰`read_file`)에 대해 먼저 스켈레톤 축소를 시도합니다: 임포트와 타입/함수/클래스 선언을 유지하고, 함수 본문은 마커와 함께 생략하며, 생략된 본문 안의 에러 라인은 보존합니다. 스켈레톤을 생성하거나 검증할 수 없으면 원래의 head 트리밍으로 폴백합니다——이 게이트가 컨텍스트를 악화시킬 수는 없습니다.
33
+
34
+ 특성:
35
+
36
+ - **직교**: 선택된 프로파일(`balanced`, `savings`, `cache-strict`, `adaptive`, `custom`, `off`, `native`)과 독립적입니다. 모든 프로파일이이게이트를 받습니다.
37
+ - **기본값 off**: `codeSkeleton: { enabled: false }`이며, 직접 켜기 전까지는 동작하지 않습니다.
38
+ - **측정이 선행**: 정확한 DeepSeek 토크나이저가 필요하며, 사용할수없으면 fail-open합니다.
39
+ - **세션 고정**: 다른 셀렉터 설정과 마찬가지로 변경 사항은 새로 관찰된 세션에만 적용됩니다.
40
+ - **엄격한 파싱**: `codeSkeleton`은 정확히 `{ enabled: boolean }`이어야 합니다. 잘못된 값은 런타임 쪽에서 예외를 던지고, 브라우저 UI에서는 읽을 수 없음으로 표시됩니다.
41
+
42
+ ## 설정 UI
43
+
44
+ 동일한 설정 섹션에서 압축 프로파일 선택, Auto Compact 트리거 레벨 조정, 코드 스켈레톤 압축 토글을 모두 처리할수있습니다. 토글은 변경시즉시 저장되며, 다시 불러올때저장된 상태가 표시됩니다.
45
+
46
+ ![Context Compression Selector 설정 UI](docs/assets/context-compression-selector-settings.png)
47
+
48
+ ## 설치
49
+
50
+ 소스에서 빌드하여 설치합니다 —— 이 포크는 npm에도 `dsh-context-compression-improved`로 게시되어 있습니다(dist-tag `dsh-0.1.5`). 내부 패키지 이름은 의도적으로 업스트림과 동일하게 유지됩니다:
51
+
52
+ ```sh
53
+ git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
54
+ cd dsh-context-compression-improved
55
+ pnpm install --frozen-lockfile
56
+ pnpm build
57
+ ```
58
+
59
+ 이후 셀렉터 패키지를 pack 해서 Harness 프로파일에 추가합니다——검증과 제거를 포함한 전체 절차는 [설치 가이드](docs/installation.ko.md)를 참고하세요.
60
+
61
+ ## 개발
62
+
63
+ ```sh
64
+ pnpm install --frozen-lockfile
65
+ pnpm lint # ESLint 베이스라인(CI에서도 강제)
66
+ pnpm typecheck # runtime + selector + tests tsc 및 bundle 단계
67
+ pnpm test # vitest 전체 스위트
68
+ pnpm test:watch # TDD 루프: 먼저 실패하는 회귀 테스트를 작성하고, 통과시킨다
69
+ pnpm build
70
+ pnpm verify:release
71
+ ```
72
+
73
+ 기여는 업스트림의 규율을 따릅니다: 먼저 실패하는 회귀 테스트를 추가하고, 모든 프로덕션 변경은 이 저장소 안에 유지하며, "트리거됨", "활성화되었지만 건너뜀", "fail-open"의 증거를 각각 따로 제시하세요. [CONTRIBUTING.md](CONTRIBUTING.md) 참고.
74
+
75
+ ## 호환성
76
+
77
+ - 공개된 플러그인 및 프로파일 API만 사용하여 DeepSeek Harness `dsh-v0.1.1-rc.2`에서 검증되었으며, 공식 `dsh-v0.1.2-alpha.5` 릴리스와 호환됩니다.
78
+ - Node `^22.19.0 || >=24`와 pnpm `11.7.0`이 필요합니다.
79
+ - 플러그인은 Harness의 공개 확장 API만 사용하며 Harness 코어를 수정하지 않습니다. 비공식 커뮤니티 프로젝트이며 DeepSeek과 제휴하거나 승인받지 않았습니다.
80
+
81
+ ## 크레딧과 라이선스
82
+
83
+ - 업스트림 프로젝트와 기존의 모든 작업: [WilliamShi666/dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector), 작성자 WilliamShi666(MIT).
84
+ - 포크에서 추가된것코드 스켈레톤 게이트, 툴체인, 다국어 문서): drscrewdriver.
85
+ - MIT——[LICENSE](LICENSE)(업스트림 저작권 표기 유지) 참고. 번들된 토크나이저의 출처는 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
package/README.md CHANGED
@@ -1,94 +1,94 @@
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
- ## Settings UI
43
-
44
- 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.
45
-
46
- ![Context Compression Selector settings UI](docs/assets/context-compression-selector-settings.png)
47
-
48
- ## Install
49
-
50
- **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.
51
-
52
- ```sh
53
- dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.5
54
- # DSH 0.1.2 line:
55
- # dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.2
56
- dsh --profile web --dump-config
57
- ```
58
-
59
- From source (alternative — the internal package names intentionally stay upstream's):
60
-
61
- ```sh
62
- git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
63
- cd dsh-context-compression-improved
64
- pnpm install --frozen-lockfile
65
- pnpm build
66
- ```
67
-
68
- 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).
69
-
70
- ## Development
71
-
72
- ```sh
73
- pnpm install --frozen-lockfile
74
- pnpm lint # ESLint baseline (also enforced in CI)
75
- pnpm typecheck # runtime + selector + tests tsc, plus the bundle step
76
- pnpm test # full vitest suite
77
- pnpm test:watch # TDD loop: write the failing regression first, then make it pass
78
- pnpm build
79
- pnpm verify:release
80
- ```
81
-
82
- 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).
83
-
84
- ## Compatibility
85
-
86
- - 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.
87
- - Requires Node `^22.19.0 || >=24` and pnpm `11.7.0`.
88
- - 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.
89
-
90
- ## Credits and license
91
-
92
- - Upstream project and all prior work: [WilliamShi666/dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector) by WilliamShi666 (MIT).
93
- - Fork additions (code-skeleton gate, tooling, localized docs): drscrewdriver.
94
- - 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
+ ## Settings UI
43
+
44
+ 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.
45
+
46
+ ![Context Compression Selector settings UI](docs/assets/context-compression-selector-settings.png)
47
+
48
+ ## Install
49
+
50
+ **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.
51
+
52
+ ```sh
53
+ dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.5
54
+ # DSH 0.1.2 line:
55
+ # dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.2
56
+ dsh --profile web --dump-config
57
+ ```
58
+
59
+ From source (alternative — the internal package names intentionally stay upstream's):
60
+
61
+ ```sh
62
+ git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
63
+ cd dsh-context-compression-improved
64
+ pnpm install --frozen-lockfile
65
+ pnpm build
66
+ ```
67
+
68
+ 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).
69
+
70
+ ## Development
71
+
72
+ ```sh
73
+ pnpm install --frozen-lockfile
74
+ pnpm lint # ESLint baseline (also enforced in CI)
75
+ pnpm typecheck # runtime + selector + tests tsc, plus the bundle step
76
+ pnpm test # full vitest suite
77
+ pnpm test:watch # TDD loop: write the failing regression first, then make it pass
78
+ pnpm build
79
+ pnpm verify:release
80
+ ```
81
+
82
+ 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).
83
+
84
+ ## Compatibility
85
+
86
+ - 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.
87
+ - Requires Node `^22.19.0 || >=24` and pnpm `11.7.0`.
88
+ - 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.
89
+
90
+ ## Credits and license
91
+
92
+ - Upstream project and all prior work: [WilliamShi666/dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector) by WilliamShi666 (MIT).
93
+ - Fork additions (code-skeleton gate, tooling, localized docs): drscrewdriver.
94
+ - MIT — see [LICENSE](LICENSE) (upstream copyright notice retained) and [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for bundled tokenizer provenance.
package/README.zh.md CHANGED
@@ -1,85 +1,85 @@
1
- # dsh-context-compression-improved
2
-
3
- > [dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector) 的改进版 fork——面向 DeepSeek Harness 的可审计工具结果上下文压缩选择器,新增正交的**代码骨架压缩门*。
4
-
5
- [English](README.md) · [日本語](README.ja.md) · [한국어](README.ko.md) · [更新日志](CHANGELOG.zh.md) · [安装教程](docs/installation.zh.md)
6
-
7
- > [!NOTE]
8
- > **本fork 在上游 0.1.0 之上新增:*
9
- >
10
- > - 正交的**代码骨架压缩门**(`codeSkeleton.enabled`,默认关闭):超大源码类工具结果首次曝光时,可先保留导入与声明的骨架——省略函数体并保留错误行——再进入常规 reducer。
11
- > - 同一选择器设置区内新增该门的开关,独立于所有压缩 Profile。
12
- > - 接入 CI 的 ESLint 基线、`test:watch` TDD 环路,以及英/中日韩四语文档。
13
-
14
- > [!IMPORTANT]
15
- > 本项目仅支持 **DeepSeek 模型**。无损测量与有损压缩依赖内置的 DeepSeek 官方 tokenizer(`deepseek-v4-flash`、`deepseek-v4-pro`、`deepseek-v4-flash-vision-exp`)。其余模型一律 fail-open 并保留原始工具结果。完整安全模型见[上游 README](https://github.com/WilliamShi666/dsh-context-compression-selector#model-support-and-safety)。
16
-
17
- ## 它是什么
18
-
19
- 长时运行的 agent 任务会积累大量工具输出。本社区插件在不修改 DeepSeek Harness 核心的前提下,提供可选、可审计的工具结果上下文压缩策略:
20
-
21
- - **Fresh**:在模型收到之前,预压缩新近超限的工具结果段。
22
- - **Aggregate**:当 Fresh 压缩后仍超出预算时再次预压缩。
23
- - **History / micro-compact**:在保护近期工作上下文的前提下替换符合条件的旧工具结果。
24
- - **TailTrim**:仅在 Custom 下可选的尾窗收缩路径。
25
- - **Native**:把 Harness 原生头中尾裁剪保留为一个显式 Profile。
26
- - **代码骨架(新增,正交门)**——见下节。
27
-
28
- 每个决策都会留痕:阶段、reducer、触发原因、跳过原因,以及可得时的精确 token 数。
29
-
30
- ## 代码骨架门(新增)
31
-
32
- 开启后,超大**源码类新工具结果**(例如大型 `read_file`)会先尝试骨架化压缩:保留导入与类型/函数/类声明,省略函数体并加占位标记,被省略函数体内的错误行予以保留。若骨架无法生成或无法通过验证,则回退到原有的头部裁剪——这道门不会让上下文变得更差。
33
-
34
- 特性:
35
-
36
- - **正交**:独立于所选 Profile(`balanced`、`savings`、`cache-strict`、`adaptive`、`custom`、`off`、`native`),所有 Profile 都能拿到这道门。
37
- - **默认关闭**:`codeSkeleton: { enabled: false }`,需要显式开启。
38
- - **测量前置**:需要精确 DeepSeek tokenizer;不可用时 fail-open。
39
- - **会话冻结**:与所有选择器设置一致,修改只影响新观察的会话。
40
- - **严格解析**:`codeSkeleton` 必须恰好是 `{ enabled: boolean }`;畸形输入在运行时侧抛错、浏览器侧显示不可读。
41
-
42
- ## 设置界面
43
-
44
- 在同一设置区内选择压缩 Profile、调整 Auto Compact 触发水位,并开关代码骨架压缩。开关即改即存,刷新后显示已保存状态。
45
-
46
- ![Context Compression Selector 设置界面](docs/assets/context-compression-selector-settings.png)
47
-
48
- ## 安装
49
-
50
- 从源码构建并安装 —— 本 fork 亦已发布到 npm,包名为 `dsh-context-compression-improved`(dist-tag `dsh-0.1.5`);内部包名有意保持与上游一致:
51
-
52
- ```sh
53
- git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
54
- cd dsh-context-compression-improved
55
- pnpm install --frozen-lockfile
56
- pnpm build
57
- ```
58
-
59
- 随后打包 selector 包并安装到某个 Harness Profile——完整步骤(含验证与卸载)见[安装教程](docs/installation.zh.md)。
60
-
61
- ## 开发
62
-
63
- ```sh
64
- pnpm install --frozen-lockfile
65
- pnpm lint # ESLint 基线(CI 同步强制)
66
- pnpm typecheck # runtime + selector + tests tsc,含 bundle 步
67
- pnpm test # vitest 全量
68
- pnpm test:watch # TDD 环路:先写失败的回归用例,再让它通过
69
- pnpm build
70
- pnpm verify:release
71
- ```
72
-
73
- 贡献遵循上游纪律:先写失败的回归用例;所有生产改动收敛在本仓库内;对“已触发”“已启用但跳过”“fail-open”分别给出证据。见 [CONTRIBUTING.md](CONTRIBUTING.md)。
74
-
75
- ## 兼容性
76
-
77
- - 仅使用公开的插件与 Profile API,针对 DeepSeek Harness `dsh-v0.1.1-rc.2` 验证;兼容官方 `dsh-v0.1.2-alpha.5` 版本。
78
- - 需要 Node `^22.19.0 || >=24` 与 pnpm `11.7.0`。
79
- - 插件只使用 Harness 公开扩展 API,不修改 Harness 核心代码。非官方社区项目,与 DeepSeek 无隶属或背书关系。
80
-
81
- ## 致谢与许可
82
-
83
- - 上游项目与全部既有工作:[WilliamShi666/dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector),作者 WilliamShi666(MIT)。
84
- - fork 新增内容(代码骨架门、工具链、多语文档):drscrewdriver。
85
- - MIT——见 [LICENSE](LICENSE)(保留上游版权声明);内置 tokenizer 来源见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。
1
+ # dsh-context-compression-improved
2
+
3
+ > [dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector) 的改进版 fork——面向 DeepSeek Harness 的可审计工具结果上下文压缩选择器,新增正交的**代码骨架压缩门*。
4
+
5
+ [English](README.md) · [日本語](README.ja.md) · [한국어](README.ko.md) · [更新日志](CHANGELOG.zh.md) · [安装教程](docs/installation.zh.md)
6
+
7
+ > [!NOTE]
8
+ > **本fork 在上游 0.1.0 之上新增:*
9
+ >
10
+ > - 正交的**代码骨架压缩门**(`codeSkeleton.enabled`,默认关闭):超大源码类工具结果首次曝光时,可先保留导入与声明的骨架——省略函数体并保留错误行——再进入常规 reducer。
11
+ > - 同一选择器设置区内新增该门的开关,独立于所有压缩 Profile。
12
+ > - 接入 CI 的 ESLint 基线、`test:watch` TDD 环路,以及英/中日韩四语文档。
13
+
14
+ > [!IMPORTANT]
15
+ > 本项目仅支持 **DeepSeek 模型**。无损测量与有损压缩依赖内置的 DeepSeek 官方 tokenizer(`deepseek-v4-flash`、`deepseek-v4-pro`、`deepseek-v4-flash-vision-exp`)。其余模型一律 fail-open 并保留原始工具结果。完整安全模型见[上游 README](https://github.com/WilliamShi666/dsh-context-compression-selector#model-support-and-safety)。
16
+
17
+ ## 它是什么
18
+
19
+ 长时运行的 agent 任务会积累大量工具输出。本社区插件在不修改 DeepSeek Harness 核心的前提下,提供可选、可审计的工具结果上下文压缩策略:
20
+
21
+ - **Fresh**:在模型收到之前,预压缩新近超限的工具结果段。
22
+ - **Aggregate**:当 Fresh 压缩后仍超出预算时再次预压缩。
23
+ - **History / micro-compact**:在保护近期工作上下文的前提下替换符合条件的旧工具结果。
24
+ - **TailTrim**:仅在 Custom 下可选的尾窗收缩路径。
25
+ - **Native**:把 Harness 原生头中尾裁剪保留为一个显式 Profile。
26
+ - **代码骨架(新增,正交门)**——见下节。
27
+
28
+ 每个决策都会留痕:阶段、reducer、触发原因、跳过原因,以及可得时的精确 token 数。
29
+
30
+ ## 代码骨架门(新增)
31
+
32
+ 开启后,超大**源码类新工具结果**(例如大型 `read_file`)会先尝试骨架化压缩:保留导入与类型/函数/类声明,省略函数体并加占位标记,被省略函数体内的错误行予以保留。若骨架无法生成或无法通过验证,则回退到原有的头部裁剪——这道门不会让上下文变得更差。
33
+
34
+ 特性:
35
+
36
+ - **正交**:独立于所选 Profile(`balanced`、`savings`、`cache-strict`、`adaptive`、`custom`、`off`、`native`),所有 Profile 都能拿到这道门。
37
+ - **默认关闭**:`codeSkeleton: { enabled: false }`,需要显式开启。
38
+ - **测量前置**:需要精确 DeepSeek tokenizer;不可用时 fail-open。
39
+ - **会话冻结**:与所有选择器设置一致,修改只影响新观察的会话。
40
+ - **严格解析**:`codeSkeleton` 必须恰好是 `{ enabled: boolean }`;畸形输入在运行时侧抛错、浏览器侧显示不可读。
41
+
42
+ ## 设置界面
43
+
44
+ 在同一设置区内选择压缩 Profile、调整 Auto Compact 触发水位,并开关代码骨架压缩。开关即改即存,刷新后显示已保存状态。
45
+
46
+ ![Context Compression Selector 设置界面](docs/assets/context-compression-selector-settings.png)
47
+
48
+ ## 安装
49
+
50
+ 从源码构建并安装 —— 本 fork 亦已发布到 npm,包名为 `dsh-context-compression-improved`(dist-tag `dsh-0.1.5`);内部包名有意保持与上游一致:
51
+
52
+ ```sh
53
+ git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
54
+ cd dsh-context-compression-improved
55
+ pnpm install --frozen-lockfile
56
+ pnpm build
57
+ ```
58
+
59
+ 随后打包 selector 包并安装到某个 Harness Profile——完整步骤(含验证与卸载)见[安装教程](docs/installation.zh.md)。
60
+
61
+ ## 开发
62
+
63
+ ```sh
64
+ pnpm install --frozen-lockfile
65
+ pnpm lint # ESLint 基线(CI 同步强制)
66
+ pnpm typecheck # runtime + selector + tests tsc,含 bundle 步
67
+ pnpm test # vitest 全量
68
+ pnpm test:watch # TDD 环路:先写失败的回归用例,再让它通过
69
+ pnpm build
70
+ pnpm verify:release
71
+ ```
72
+
73
+ 贡献遵循上游纪律:先写失败的回归用例;所有生产改动收敛在本仓库内;对“已触发”“已启用但跳过”“fail-open”分别给出证据。见 [CONTRIBUTING.md](CONTRIBUTING.md)。
74
+
75
+ ## 兼容性
76
+
77
+ - 仅使用公开的插件与 Profile API,针对 DeepSeek Harness `dsh-v0.1.1-rc.2` 验证;兼容官方 `dsh-v0.1.2-alpha.5` 版本。
78
+ - 需要 Node `^22.19.0 || >=24` 与 pnpm `11.7.0`。
79
+ - 插件只使用 Harness 公开扩展 API,不修改 Harness 核心代码。非官方社区项目,与 DeepSeek 无隶属或背书关系。
80
+
81
+ ## 致谢与许可
82
+
83
+ - 上游项目与全部既有工作:[WilliamShi666/dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector),作者 WilliamShi666(MIT)。
84
+ - fork 新增内容(代码骨架门、工具链、多语文档):drscrewdriver。
85
+ - MIT——见 [LICENSE](LICENSE)(保留上游版权声明);内置 tokenizer 来源见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。
package/SECURITY.md CHANGED
@@ -1,18 +1,18 @@
1
- # Security policy
2
-
3
- ## Supported versions
4
-
5
- During the initial release, only the newest published Beta or stable version is supported. Compatibility is limited to the Harness versions listed in the README.
6
-
7
- ## Reporting a vulnerability
8
-
9
- Please use GitHub's private **Report a vulnerability** flow for this repository. Do not open a public issue containing secrets, exploit details, private Session data, prompts, tool results, or user paths.
10
-
11
- Include the affected plugin version, Harness version, minimal reproduction, impact, and whether the issue can alter Session surface/recovery behavior. We will acknowledge a valid report as soon as practical, investigate privately, and publish a coordinated fix and advisory when appropriate.
12
-
13
- ## Security posture
14
-
15
- - The Bundle does not require credentials of its own.
16
- - Compression and recovery are same-Session operations; audit records omit model-visible content.
17
- - Unknown models, tokenizer integrity failures, malformed policies, unsafe tool groups, and incomplete exact measurements fail open.
18
- - NPM tarballs use explicit file allowlists and do not ship source maps, user logs, Sessions, or local configuration.
1
+ # Security policy
2
+
3
+ ## Supported versions
4
+
5
+ During the initial release, only the newest published Beta or stable version is supported. Compatibility is limited to the Harness versions listed in the README.
6
+
7
+ ## Reporting a vulnerability
8
+
9
+ Please use GitHub's private **Report a vulnerability** flow for this repository. Do not open a public issue containing secrets, exploit details, private Session data, prompts, tool results, or user paths.
10
+
11
+ Include the affected plugin version, Harness version, minimal reproduction, impact, and whether the issue can alter Session surface/recovery behavior. We will acknowledge a valid report as soon as practical, investigate privately, and publish a coordinated fix and advisory when appropriate.
12
+
13
+ ## Security posture
14
+
15
+ - The Bundle does not require credentials of its own.
16
+ - Compression and recovery are same-Session operations; audit records omit model-visible content.
17
+ - Unknown models, tokenizer integrity failures, malformed policies, unsafe tool groups, and incomplete exact measurements fail open.
18
+ - NPM tarballs use explicit file allowlists and do not ship source maps, user logs, Sessions, or local configuration.
@@ -1,14 +1,14 @@
1
- # Third-party notices
2
-
3
- This community project contains code adapted from the MIT-licensed [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness), verified against tag `dsh-v0.1.1-rc.2`, commit `b150a551b8d465e31e418e1b2eaf5e79bbb7d28e`.
4
-
5
- The runtime package distributes tokenizer assets from these pinned official repositories, both under the MIT license:
6
-
7
- - [deepseek-ai/DeepSeek-V4-Pro](https://huggingface.co/deepseek-ai/DeepSeek-V4-Pro) at revision `0e1a0e5e52aea73055f50fef6f2423db370265b6`, recorded in `packages/selector/assets/deepseek-v4/manifest.json`.
8
- - [deepseek-ai/DeepSeek-V4-Flash-Vision-Exp](https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash-Vision-Exp) at revision `6821d6ad3681a4b137b066b76094fa82ebd0a380`, recorded in `packages/selector/assets/deepseek-v4-vision-exp/manifest.json`. The vision model is served by this distinct tokenizer, never as an alias of the text tokenizer.
9
-
10
- Exact file sizes and SHA-256 values are recorded in each directory's `manifest.json`; the upstream license text ships beside the assets.
11
-
12
- The install-time production dependency closure also contains `@huggingface/tokenizers` (Apache-2.0), `js-yaml` (MIT), and its `argparse` dependency (Python-2.0). Each dependency ships its own license text in its NPM package.
13
-
14
- The names DeepSeek and DeepSeek Harness identify upstream projects only. They do not imply affiliation or endorsement.
1
+ # Third-party notices
2
+
3
+ This community project contains code adapted from the MIT-licensed [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness), verified against tag `dsh-v0.1.1-rc.2`, commit `b150a551b8d465e31e418e1b2eaf5e79bbb7d28e`.
4
+
5
+ The runtime package distributes tokenizer assets from these pinned official repositories, both under the MIT license:
6
+
7
+ - [deepseek-ai/DeepSeek-V4-Pro](https://huggingface.co/deepseek-ai/DeepSeek-V4-Pro) at revision `0e1a0e5e52aea73055f50fef6f2423db370265b6`, recorded in `packages/selector/assets/deepseek-v4/manifest.json`.
8
+ - [deepseek-ai/DeepSeek-V4-Flash-Vision-Exp](https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash-Vision-Exp) at revision `6821d6ad3681a4b137b066b76094fa82ebd0a380`, recorded in `packages/selector/assets/deepseek-v4-vision-exp/manifest.json`. The vision model is served by this distinct tokenizer, never as an alias of the text tokenizer.
9
+
10
+ Exact file sizes and SHA-256 values are recorded in each directory's `manifest.json`; the upstream license text ships beside the assets.
11
+
12
+ The install-time production dependency closure also contains `@huggingface/tokenizers` (Apache-2.0), `js-yaml` (MIT), and its `argparse` dependency (Python-2.0). Each dependency ships its own license text in its NPM package.
13
+
14
+ The names DeepSeek and DeepSeek Harness identify upstream projects only. They do not imply affiliation or endorsement.