dsh-context-compression-improved 0.1.1 → 0.2.0

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 (148) hide show
  1. package/.gitattributes +1 -0
  2. package/.github/workflows/ci.yml +39 -0
  3. package/CHANGELOG.ja.md +39 -0
  4. package/CHANGELOG.ko.md +39 -0
  5. package/CHANGELOG.md +135 -0
  6. package/CHANGELOG.zh.md +39 -0
  7. package/CONTRIBUTING.md +22 -0
  8. package/README.ja.md +104 -0
  9. package/README.ko.md +103 -0
  10. package/README.md +89 -12
  11. package/README.zh.md +87 -12
  12. package/SECURITY.md +18 -0
  13. package/THIRD_PARTY_NOTICES.md +7 -31
  14. package/docs/installation.ja.md +76 -0
  15. package/docs/installation.ko.md +76 -0
  16. package/docs/installation.md +76 -0
  17. package/docs/installation.zh.md +76 -0
  18. package/docs/repair-log.md +582 -0
  19. package/eslint.config.js +30 -0
  20. package/package.json +84 -81
  21. package/packages/selector/LICENSE +21 -0
  22. package/packages/selector/README.md +26 -0
  23. package/packages/selector/README.zh.md +26 -0
  24. package/packages/selector/THIRD_PARTY_NOTICES.md +38 -0
  25. package/packages/selector/docs/history-tool-call-working-set-spec.md +112 -0
  26. package/packages/selector/docs/native-tool-result-selector-spec.md +34 -0
  27. package/packages/selector/docs/subagent-cache-reuse-spec.md +46 -0
  28. package/packages/selector/lib/style.css +308 -0
  29. package/packages/selector/package.json +115 -0
  30. package/{screenshots.json → packages/selector/screenshots.json} +6 -6
  31. package/packages/selector/src/client/CompressionProfileControls.tsx +229 -0
  32. package/packages/selector/src/client/CompressionProfileSelector.module.css +170 -0
  33. package/packages/selector/src/client/CompressionProfileSelector.tsx +79 -0
  34. package/packages/selector/src/client/CustomPolicyEditor.tsx +216 -0
  35. package/packages/selector/src/client/EstimatorControls.tsx +281 -0
  36. package/packages/selector/src/client/decode.ts +49 -0
  37. package/packages/selector/src/client/index.ts +111 -0
  38. package/packages/selector/src/client/locales.ts +198 -0
  39. package/packages/selector/src/client/preset-options.ts +70 -0
  40. package/packages/selector/src/client/settings-section.tsx +126 -0
  41. package/packages/selector/src/css-modules.d.ts +6 -0
  42. package/packages/selector/src/deepseek-v4-tokenizer.ts +210 -0
  43. package/packages/selector/src/estimator-catalog.ts +104 -0
  44. package/packages/selector/src/index.ts +327 -0
  45. package/packages/selector/src/invariant.ts +113 -0
  46. package/packages/selector/src/preset-overlay.ts +567 -0
  47. package/packages/selector/src/profiles.ts +342 -0
  48. package/packages/selector/src/pruner/content.ts +188 -0
  49. package/packages/selector/src/pruner/session.ts +94 -0
  50. package/packages/selector/src/pruner/state.ts +43 -0
  51. package/packages/selector/src/pruner/tuning.ts +23 -0
  52. package/packages/selector/src/pruner/types.ts +60 -0
  53. package/packages/selector/src/pruner.ts +2144 -0
  54. package/packages/selector/src/runtime/adaptive-cost.ts +194 -0
  55. package/packages/selector/src/runtime/audit.ts +215 -0
  56. package/packages/selector/src/runtime/config.ts +613 -0
  57. package/packages/selector/src/runtime/custom-policy.ts +278 -0
  58. package/packages/selector/src/runtime/deepseek-official-pricing.ts +298 -0
  59. package/packages/selector/src/runtime/deepseek-v4-vision-tokens.ts +254 -0
  60. package/packages/selector/src/runtime/measurement.ts +403 -0
  61. package/packages/selector/src/runtime/reducers.ts +656 -0
  62. package/packages/selector/src/runtime/retrieve.ts +457 -0
  63. package/packages/selector/src/runtime/session-events.ts +17 -0
  64. package/packages/selector/src/runtime/tail-trim.ts +166 -0
  65. package/packages/selector/src/runtime/token-count.ts +72 -0
  66. package/packages/selector/src/runtime/tokenpilot/dedup.ts +81 -0
  67. package/packages/selector/src/runtime/tokenpilot/estimator.ts +183 -0
  68. package/packages/selector/src/runtime/tokenpilot/locator.ts +128 -0
  69. package/packages/selector/src/runtime/tokenpilot/read-state.ts +77 -0
  70. package/packages/selector/src/runtime/types.ts +309 -0
  71. package/packages/selector/src/runtime/value.ts +48 -0
  72. package/packages/selector/tests/auto-compact.client.spec.tsx +226 -0
  73. package/packages/selector/tests/built/client-artifact.spec.ts +51 -0
  74. package/packages/selector/tests/cache-prefix-audit.spec.ts +123 -0
  75. package/packages/selector/tests/code-skeleton.client.spec.ts +88 -0
  76. package/packages/selector/tests/custom-contract.client.spec.ts +202 -0
  77. package/packages/selector/tests/estimator-catalog.spec.ts +70 -0
  78. package/packages/selector/tests/estimator-channel.client.spec.tsx +247 -0
  79. package/packages/selector/tests/estimator-route-registration.host.spec.ts +176 -0
  80. package/packages/selector/tests/host-preset-overlay.host.spec.ts +204 -0
  81. package/packages/selector/tests/preset-options-write.client.spec.ts +181 -0
  82. package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +196 -0
  83. package/packages/selector/tests/preset-overlay.host.spec.ts +243 -0
  84. package/packages/selector/tests/profiles.client.spec.tsx +434 -0
  85. package/packages/selector/tests/public/package-contract.client.spec.ts +33 -0
  86. package/packages/selector/tests/runtime/adaptive-cost.spec.ts +167 -0
  87. package/packages/selector/tests/runtime/audit.spec.ts +129 -0
  88. package/packages/selector/tests/runtime/auto-compact-config.spec.ts +523 -0
  89. package/packages/selector/tests/runtime/code-skeleton.spec.ts +141 -0
  90. package/packages/selector/tests/runtime/deepseek-official-pricing.spec.ts +186 -0
  91. package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +122 -0
  92. package/packages/selector/tests/runtime/deepseek-v4-vision-tokens.spec.ts +122 -0
  93. package/packages/selector/tests/runtime/fixtures/profile-baseline.json +273 -0
  94. package/packages/selector/tests/runtime/fixtures/tokenizer-golden.json +106 -0
  95. package/packages/selector/tests/runtime/fixtures/vision-golden.json +459 -0
  96. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2531 -0
  97. package/packages/selector/tests/runtime/session-events.spec.ts +27 -0
  98. package/packages/selector/tests/runtime/tokenizer-golden.spec.ts +53 -0
  99. package/packages/selector/tests/runtime/tokenpilot/dedup.spec.ts +52 -0
  100. package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +56 -0
  101. package/packages/selector/tests/runtime/tokenpilot/locator.spec.ts +76 -0
  102. package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +100 -0
  103. package/packages/selector/tests/runtime/tokenpilot/read-state.spec.ts +58 -0
  104. package/packages/selector/tests/runtime/value.spec.ts +23 -0
  105. package/packages/selector/tests/standing-generation.host.spec.ts +631 -0
  106. package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +250 -0
  107. package/packages/selector/tests/support/cache-prefix-audit.ts +105 -0
  108. package/packages/selector/tests/support/mock-adapter.ts +37 -0
  109. package/packages/selector/tests/support/ui-primitives.tsx +34 -0
  110. package/packages/selector/tsconfig.json +11 -0
  111. package/packages/selector/tsdown.client.config.ts +102 -0
  112. package/packages/selector/tsdown.config.ts +20 -0
  113. package/pnpm-workspace.yaml +19 -0
  114. package/scripts/capture-profile-baseline.ts +80 -0
  115. package/scripts/generate-tokenizer-fixtures.py +81 -0
  116. package/scripts/generate-vision-fixtures.py +208 -0
  117. package/scripts/packed-components-smoke.ts +713 -0
  118. package/scripts/packed-install-e2e.ts +1072 -0
  119. package/scripts/verify-release.ts +300 -0
  120. package/tests/TEST_INVENTORY.md +42 -0
  121. package/tsconfig.base.json +18 -0
  122. package/tsconfig.json +7 -0
  123. package/tsconfig.scripts.json +13 -0
  124. package/tsconfig.tests.json +15 -0
  125. package/vitest.built.config.ts +9 -0
  126. package/vitest.config.ts +43 -0
  127. /package/{assets → packages/selector/assets}/deepseek-v4/LICENSE.DeepSeek-V4-Pro.txt +0 -0
  128. /package/{assets → packages/selector/assets}/deepseek-v4/manifest.json +0 -0
  129. /package/{assets → packages/selector/assets}/deepseek-v4/tokenizer.json +0 -0
  130. /package/{assets → packages/selector/assets}/deepseek-v4/tokenizer_config.json +0 -0
  131. /package/{assets → packages/selector/assets}/deepseek-v4-vision-exp/LICENSE.DeepSeek-V4-Flash-Vision-Exp.txt +0 -0
  132. /package/{assets → packages/selector/assets}/deepseek-v4-vision-exp/manifest.json +0 -0
  133. /package/{assets → packages/selector/assets}/deepseek-v4-vision-exp/tokenizer.json +0 -0
  134. /package/{assets → packages/selector/assets}/deepseek-v4-vision-exp/tokenizer_config.json +0 -0
  135. /package/{assets → packages/selector/assets}/screenshots/context-compression-selector-profiles.jpg +0 -0
  136. /package/{assets → packages/selector/assets}/screenshots/context-compression-selector-settings.png +0 -0
  137. /package/{cordis.patch.yml → packages/selector/cordis.patch.yml} +0 -0
  138. /package/{dsh.plugin.json → packages/selector/dsh.plugin.json} +0 -0
  139. /package/{lib → packages/selector/lib}/client.d.ts +0 -0
  140. /package/{lib → packages/selector/lib}/client.js +0 -0
  141. /package/{lib → packages/selector/lib}/config.js +0 -0
  142. /package/{lib → packages/selector/lib}/index.d.ts +0 -0
  143. /package/{lib → packages/selector/lib}/index.js +0 -0
  144. /package/{lib → packages/selector/lib}/invariant.d.ts +0 -0
  145. /package/{lib → packages/selector/lib}/invariant.js +0 -0
  146. /package/{lib → packages/selector/lib}/pruner.d.ts +0 -0
  147. /package/{lib → packages/selector/lib}/pruner.js +0 -0
  148. /package/{lib → packages/selector/lib}/tail-trim.js +0 -0
package/.gitattributes ADDED
@@ -0,0 +1 @@
1
+ packages/selector/assets/** -text
@@ -0,0 +1,39 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ verify:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
16
+ - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
17
+ with:
18
+ version: 11.7.0
19
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
20
+ with:
21
+ node-version: 22.19.0
22
+ cache: pnpm
23
+ - run: pnpm install --frozen-lockfile
24
+ - run: pnpm lint
25
+ - run: pnpm typecheck
26
+ - run: pnpm build
27
+ # scripts/ is compiled to the gitignored scripts-dist/, and nothing above this
28
+ # point builds it. Without this step verify:release and test:e2e:packed both
29
+ # die with MODULE_NOT_FOUND on a clean checkout — which is what kept this
30
+ # workflow red on every push to main while the same gates passed locally,
31
+ # where scripts-dist/ had been built by hand once.
32
+ - run: pnpm build:scripts
33
+ - run: pnpm test
34
+ - run: pnpm --filter dsh-context-compression-improved test
35
+ - run: pnpm test:built
36
+ - run: pnpm verify:release
37
+ - run: pnpm pack:dry-run
38
+ - run: pnpm test:e2e:packed
39
+ - run: pnpm audit --audit-level high
@@ -0,0 +1,39 @@
1
+ # 変更履歴(フォークの追加エントリー)
2
+
3
+ > 完全な履歴(アップストリーム 0.1.0 以前を含む)は [CHANGELOG.md](CHANGELOG.md) を参照。このファイルはフォークの追加エントリーのみを翻訳したものです。 · [English](CHANGELOG.md) · [中文](CHANGELOG.zh.md) · [한국어](CHANGELOG.ko.md)
4
+
5
+ ## 0.1.1
6
+
7
+ ### 追加
8
+
9
+ - `scripts/` の TypeScript ツールチェーン:`verify-release`、`packed-components-smoke`、`packed-install-e2e` が `.ts` ソースになり、`tsc` で `scripts-dist/` にコンパイルされます。リポジトリ内の最後の3つの非 TS ヽースファイルが排除されました。
10
+
11
+ ### 変更
12
+
13
+ - `package.json` スクリプト `test:e2e:packed` と `verify:release` が `scripts-dist/` のコンパイル成果物を実行するようになりました。
14
+ - エスティメーターカタログルート登録が硬化:`asWebServer` がサービス自体を返すように修正(D7 修正)、エステーター UI が非アクティブ時にセクション見出しを保持するように修正(U1 修正)。
15
+ - フレームワークドキュメント修正:行レベル `inject: [webServer]` は負荷担うものではない(Y22);DSH 全パッケージに `isolate()` なし。
16
+
17
+ ### 修正
18
+
19
+ - エスティメーターカタログルートは `asWebServer` が `register` をサービスから切り離したため、最初から一度も登録されなかった(D7)。
20
+ - 非 TokenPilot プロファイル時にエステーターセクションが警告なしに非表示になっていた(U1)。
21
+
22
+ ## Unreleased(未リリース)
23
+
24
+ ### 追加
25
+
26
+ - 直交するコードスケルトン圧縮ゲート(`codeSkeleton.enabled`、デフォルトはオフ):超大規模なソースコード系ツール結果の初回露出時に、インポートと宣言のスケルトンを保持できます(関数本体は省略、エラー行は保持)。失敗時は元の先頭トリミングへフォールバックします。ゲートはすべてのプロファイルから独立し、正確なトークナイザー計測を前提とします。
27
+ - セレクター設定セクションにゲートのトグルを追加(簡体字中国語・英語のコピー付き)。
28
+ - 新セクションのブラウザー/ランタイム デコード整合テスト、`saveCodeSkeleton` の confirm-on-write コントラクトテスト、およびドキュメント全体のパリティ行列拡張。
29
+
30
+ ### 変更
31
+
32
+ - ESLint フラット設定ベースライン(`pnpm lint`、CI でも強制)と `pnpm test:watch` による TDD ループを追加。デッドインポートを整理し、lint ベースラインで浮かび上がった 2 つのエラー経路を強化しました。
33
+ - 本リポジトリは `WilliamShi666/dsh-context-compression-selector` の改良フォークとして管理されます。ドキュメントは英語・簡体字中国語・日本語・韓国語で提供されます。
34
+
35
+ ### 修正
36
+
37
+ - エスティメーターカードは Harness ホストチャネルで API キーを要求しなくなりました。ホストチャネルを選ぶと、ライブのプロバイダー/モデル ドロップダウンが表示され、実際に使われるルート(明示的な上書き、なければセッション既定モデル)を明示します。キー入力欄と 2 つ目の手入力モデル欄は表示されません — エンドポイント URL、モデルのテキスト欄、書き込み専用キーはダイレクト接続チャネルだけに属します。
38
+ - `presetOptions` の書き込みが兄弟フィールドを保持するようになりました。`settingsScope.set('presetOptions', patch)` はセクション全体を置き換えるため、エスティメーターの 2 つ目のフィールド(プロバイダー、モデル、エンドポイント)に触れると `estimatorMode` と他のすべての上書きが削除され、パネルは保存成功と表示したままエスティメーターが静かにオフへ戻っていました。現在はパッチを保存済みセクションへマージし、`undefined` は指定したフィールドだけを消去し、変更なしのパッチは書き込まず、confirm-on-write はチャネル単独ではなく同じフィールド群を検証します。
39
+ - 回帰カバレッジを追加:`packages/selector/tests/preset-options-write.client.spec.ts`(マージ書き込み、兄弟フィールドの保持、明示的な消去、変更なし時の無書き込み、未コミット書き込みの報告)と `packages/selector/tests/estimator-channel.client.spec.tsx`(チャネル別フィールド、カタログのドロップダウン、手入力フォールバック)。
@@ -0,0 +1,39 @@
1
+ # 변경 로그(포크 추가 항목)
2
+
3
+ > 전체 히스토리(업스트림 0.1.0 이전 포함)는 [CHANGELOG.md](CHANGELOG.md)를 참고하세요. 이 파일은 포크의 추가 항목만 번역한 것입니다. · [English](CHANGELOG.md) · [中文](CHANGELOG.zh.md) · [日本語](CHANGELOG.ja.md)
4
+
5
+ ## 0.1.1
6
+
7
+ ### 추가
8
+
9
+ - `scripts/`의 TypeScript 도구 체인: `verify-release`, `packed-components-smoke`, `packed-install-e2e`가 `.ts` 소스가 되어 `tsc`로 `scripts-dist/`에 컴파일됩니다. 저장소의 마지막 3개 비-TS 소스 파일이 제거되었습니다.
10
+
11
+ ### 변경
12
+
13
+ - `package.json` 스크립트 `test:e2e:packed`와 `verify:release`가 `scripts-dist/`의 컴파일 결과물을 실행합니다.
14
+ - 추정기 카탈로그 라우트 등록이 강화됨: `asWebServer`가 서비스 자체를 반환하도록 수정(D7 수정), 추정기 UI가 비활성 시 섹션 제목을 유지하도록 수정(U1 수정).
15
+ - 프레임워크 문서 정정: 행 수준 `inject: [webServer]`는 부담을 지지 않음(Y22); DSH 모든 패키지에 `isolate()` 없음.
16
+
17
+ ### 수정
18
+
19
+ - 추정기 카탈로그 라우트는 `asWebServer`가 `register`를 서비스에서 분리한导致로 처음부터 한 번도 등록되지 않았음(D7).
20
+ - 비-TokenPilot 프로필에서 추정기 섹션이 경고 없이 사라졌음(U1).
21
+
22
+ ## Unreleased(미출시)
23
+
24
+ ### 추가
25
+
26
+ - 직교하는 코드 스켈레톤 압축 게이트(`codeSkeleton.enabled`, 기본값 off): 매우 큰 소스코드 도구 결과가 처음 노출될 때 임포트와 선언부의 스켈레톤을 보존할 수 있습니다(함수 본문 생략, 에러 라인 유지). 실패 시 기존의 head 트리밍으로 폴백합니다. 게이트는 모든 프로파일과 독립적이며 정확한 토크나이저 측정이 전제입니다.
27
+ - 셀렉터 설정 섹션에 게이트의 토글 추가(간체 중국어·영문 카피 포함).
28
+ - 새 섹션의 브라우저/런타임 디코드 정합성 테스트, `saveCodeSkeleton`의 confirm-on-write 컨트랙트 테스트, 전체 문서 패리티 매트릭스 확장.
29
+
30
+ ### 변경
31
+
32
+ - ESLint 플랫 설정 베이스라인(`pnpm lint`, CI에서도 강제)과 `pnpm test:watch` TDD 루프를 추가. 죽은 임포트를 정리하고, lint 베이스라인에서 드러난 두 오류 경로를 보강했습니다.
33
+ - 이 저장소는 이제 `WilliamShi666/dsh-context-compression-selector`의 개선 포크로 관리됩니다. 문서는 영어·중국어(간체)·일본어·한국어로 제공됩니다.
34
+
35
+ ### 수정
36
+
37
+ - 추정기 카드가 Harness 호스트 채널에서 더 이상 API 키를 요구하지 않습니다. 호스트 채널을 선택하면 라이브 프로바이더/모델 드롭다운이 표시되고 실제로 사용될 라우트(명시적 재정의, 없으면 세션 기본 모델)를 알려줍니다. 키 입력란과 두 번째 수동 모델 입력란은 렌더링되지 않습니다 — 엔드포인트 URL, 모델 텍스트 필드, 쓰기 전용 키는 직접 연결 채널에만 속합니다.
38
+ - `presetOptions` 쓰기가 형제 필드를 보존합니다. `settingsScope.set('presetOptions', patch)`는 섹션 전체를 교체하므로 추정기의 두 번째 필드(프로바이더, 모델, 엔드포인트)를 건드리면 `estimatorMode`와 다른 모든 재정의가 삭제되어, 패널은 저장 성공을 보고하는데도 추정기가 조용히 꺼졌습니다. 이제 패치는 저장된 섹션 위에 병합되고, `undefined`는 지목한 필드만 지우며, 변경 없는 패치는 쓰지 않고, confirm-on-write는 채널 하나가 아니라 같은 필드 집합을 검증합니다.
39
+ - 회귀 커버리지 추가: `packages/selector/tests/preset-options-write.client.spec.ts`(병합 쓰기, 형제 필드 보존, 명시적 삭제, 변경 없음 시 무쓰기, 미커밋 쓰기 보고)와 `packages/selector/tests/estimator-channel.client.spec.tsx`(채널별 필드, 카탈로그 드롭다운, 수동 폴백).
package/CHANGELOG.md ADDED
@@ -0,0 +1,135 @@
1
+ # Changelog
2
+
3
+ All notable changes use this file. The project follows semantic versioning after `0.1.0`.
4
+
5
+ ## 0.1.1
6
+
7
+ ### Added
8
+
9
+ - TypeScript toolchain for `scripts/`: `verify-release`, `packed-components-smoke`, and `packed-install-e2e` are now `.ts` sources compiled to `scripts-dist/` via `tsc`, eliminating the last three non-TS source files in the repository.
10
+
11
+ ### Changed
12
+
13
+ - `package.json` scripts `test:e2e:packed` and `verify:release` now run compiled outputs from `scripts-dist/`.
14
+ - Estimator catalog route registration hardened: `asWebServer` returns the service itself (D7 fix), and the estimator UI preserves its section heading when inactive instead of hiding behind an invisible gate (U1 fix).
15
+ - Framework documentation corrected: row-level `inject: [webServer]` is not load-bearing (Y22); `isolate()` does not exist in any DSH package.
16
+
17
+ ### Fixed
18
+
19
+ - The estimator catalog route was never registered since day one because `asWebServer` detached `register` from its service (D7).
20
+ - The estimator section silently disappeared when a non-TokenPilot profile was active, with no hint about why or how to enable it (U1).
21
+
22
+ ## Unreleased
23
+
24
+ ### Added
25
+
26
+ - New `tokenpilot-inspired` profile: a TokenPilot-paper-inspired capability matrix layered on the Balanced thresholds, selected explicitly from the settings UI; every pre-existing profile keeps a byte-identical resolved policy (enforced by a captured-baseline golden test).
27
+ - Byte-identical repeated tool-result dedup: an oversized repeat is replaced with a pointer to the first occurrence's append-only original event (`dedupe-pointer`), with a per-session SHA-256 index (2,048-entry insertion-order eviction, hash+seq metadata only).
28
+ - No-net-savings guard: replacements whose text is not smaller than the original are rejected even when the exact tokenizer reports a token saving.
29
+ - Recovery exemption: recovery-tool output is permanently exempt from every reduction pass via a unified per-session exemption set, preventing compress-restore oscillation.
30
+ - Auto Compact summary locator: after `compaction/end`, the landed summary checkpoint gains an Exact Sources block (shadowed seq range, spill files, touched files) so summarized-away details stay recoverable; skipped when it would locate nothing concrete.
31
+ - Read-state semantics: a historical read whose file was later mutated is `superseded` and takes the small whole-result placeholder; optional error/warn/info clustering of omitted lines is appended to historical placeholders.
32
+ - Optional residual-utility estimator (three channels: off / Harness host model / direct OpenAI-compatible endpoint) with per-session exponential backoff, strict timeout, advisory-only verdicts consumed by the next pressure pass, and numeric-only `estimator-outcome` audits. The estimator card appears only while the new profile is selected; the API key is write-only in settings and never enters the frozen policy, audits, or logs.
33
+ - New audit records: `summary-locator` and `estimator-outcome`; the rewrite record covers dedup via the `dedupe-pointer` reducer. Audit field allowlists are unchanged.
34
+ - Simplified Chinese and English copy for the new profile and estimator card; unit and golden coverage under `packages/runtime/tests/tokenpilot/`.
35
+
36
+ - Orthogonal code-skeleton compression gate (`codeSkeleton.enabled`, default off): the first exposure of an oversized fresh source-code tool result can keep an imports-and-declarations skeleton with bodies elided and error lines preserved, falling back to the original head pruning. The gate is independent of every profile and gated on exact tokenizer measurement.
37
+ - Settings-UI toggle for the gate in the selector settings section, with Simplified Chinese and English copy.
38
+ - Browser/runtime decode parity for the new section, confirm-on-write contract tests for `saveCodeSkeleton`, and a full-document parity matrix extension.
39
+
40
+ ### Changed
41
+
42
+ - Added an ESLint flat-config baseline (`pnpm lint`, enforced in CI) and a `pnpm test:watch` TDD loop; removed dead imports and hardened two error paths surfaced by the lint baseline.
43
+ - This repository is now maintained as an improved fork of `WilliamShi666/dsh-context-compression-selector`; documentation ships in English, Simplified Chinese, Japanese, and Korean.
44
+
45
+ ### Fixed
46
+
47
+ - The estimator card no longer demands an API key on the Harness host channel. Selecting the host channel shows the live provider/model dropdowns, names the route that would actually run (explicit override, else the session default), and renders neither a key field nor a second manual model input: the base URL, the model text field, and the write-only key belong to the direct endpoint channel alone.
48
+ - `presetOptions` writes preserve their siblings. `settingsScope.set('presetOptions', patch)` replaces the whole section, so touching any second estimator field (a provider, a model, an endpoint) deleted `estimatorMode` and every other override — silently switching the estimator back off while the panel still reported a successful save. The patch is now merged over the stored section, `undefined` clears exactly the field it names, an unchanged patch writes nothing, and the confirmation read compares the same fields instead of the channel alone.
49
+ - New coverage: `packages/selector/tests/preset-options-write.client.spec.ts` (merged writes, sibling preservation, explicit clears, no-op patches, uncommitted-write reporting) and `packages/selector/tests/estimator-channel.client.spec.tsx` (per-channel fields, catalog dropdowns, manual fallback).
50
+
51
+ ## 0.1.0 - 2026-09-03
52
+
53
+ ### Added
54
+
55
+ - Stable release of DeepSeek V4 Flash Vision tokenizer integration for `deepseek-v4-flash-vision-exp`, including exact text counting and bounded image-token estimates.
56
+ - User-configurable model-driven Auto Compact threshold in the selector settings section.
57
+ - Auto Compact threshold linkage for each standard profile's History / micro-compact watermarks and related compression parameters.
58
+
59
+ ### Changed
60
+
61
+ - The threshold editor now uses one direct numeric input; the slider and fixed quick-value buttons were removed.
62
+ - Runtime session-event access supports both the established Harness `events` accessor and the newer `snapshotEvents()` public API.
63
+
64
+ ## 0.1.0-beta.4 - 2026-09-02
65
+
66
+ ### Fixed
67
+
68
+ - Support the official DeepSeek Harness `dsh-v0.1.2-alpha.5` public API while retaining compatibility with the existing `0.1.1-rc.2` peer range. The plugin now owns the two small immutable-value helpers that the newer Harness no longer exports, and uses the same public `context-compression` namespace literal accepted by both Settings implementations. No Harness core code is modified.
69
+
70
+ ## 0.1.0-beta.3 - 2026-09-01
71
+
72
+ ### Scope
73
+
74
+ This is a staged release. Exact **text-class** token counting for `deepseek-v4-flash-vision-exp`, best-effort bounded **vision-class image** estimates, and the Auto Compact threshold/UI/audit work are delivered. Exact image measurement remains **BLOCKED upstream**: the current measurement seam exposes neither the adapter's projected request-image dimensions nor the absolute serialized position, so estimates cannot be promoted to `exact-tokenizer`.
75
+
76
+ ### Added
77
+
78
+ - DeepSeek V4 Flash Vision support for `deepseek-v4-flash-vision-exp` via a separately bundled official tokenizer pinned at `deepseek-ai/DeepSeek-V4-Flash-Vision-Exp` revision `6821d6ad3681a4b137b066b76094fa82ebd0a380`. Text, reasoning, tool-call arguments, and pure-text tool results are counted exactly; image-bearing tool-result candidates stay fail-open.
79
+ - Vision image-token arithmetic ported line-by-line from the official `inference/image_processor.py` (patch size 14, downsample 3, 384-token cap, min pixels 147456, 8:1 aspect clamp, and position-dependent alignment padding), validated against golden fixtures generated by executing the official Python implementation. Valid intrinsic dimensions now produce `tokenizer-estimate` at the midpoint of all four alignment residues with a 384-token per-image upper bound; malformed or unevaluable dimensions use a documented 256-token fallback. Mixed text/image surfaces aggregate exact text and estimated images without promoting them to exact.
80
+ - `autoCompact.thresholdPercent` setting (default 80, integer 50–90, step 1) with one shared validation contract across the settings UI, the persisted schema, and the runtime resolver. The editor lives inside the context-compression selector settings section.
81
+ - Standard-profile History linkage to the Auto Compact watermark: `A = floor(C × a)` rescales the History trigger, minimum reclaim, and recent-token tail; `D = floor(A × 0.875)` replaces the fixed 0.7 capacity-pressure ratio as the micro-compact last-chance gate; one batch must justify its cache break by pulling the complete request back below the deadline. Defaults at 80% reproduce the previous numbers exactly.
82
+ - The preset overlay writes the saved threshold into the generated `compaction-basic` composition as `thresholdRatio` (with `retainRatio` pinned at 0.16) and, from the same read, into the plugin runtime's deployment config as `autoCompactThresholdPercent`, so one standing generation never runs Auto Compact and micro compact on two different thresholds. Any generation-identity change — threshold, source, or module paths, including equal-length ones — produces a new standing composition generation. Deterministic identity-derived stamps use an 8-hex whole-second window; equal-prefix identities can collide in that first window on a coarse filesystem, so the overlay observes the staging file's real `mtimeMs+size` key and escalates to later hash windows before the atomic rename. Content, permissions, and the final unique stamp are complete before publication; already-running sessions keep their frozen policy.
83
+ - `policy-resolved` audits now record the Auto Compact coordination facts (threshold percent, `A`, `D`, parameter source — including `deployment-override`/`mixed` when deployment config replaces linked History watermarks), the routed provider/model, and the bundled tokenizer identity.
84
+ - Persisted settings reject present-but-invalid sections (`profile: null`, `custom: null`, own-property `undefined`) before any schema default can absorb them; a malformed stored document freezes the session losslessly (`profile: off`, audited as `settingsInvalidFallback: lossless-off`) instead of silently enabling the lossy Balanced default. The browser decoder applies the same rule and canonicalizes legacy Custom v1/v2 documents to the same v3 document the runtime resolver produces.
85
+ - The History planner returns a discriminated outcome, and `component-evaluation` audits distinguish the full skip taxonomy: `below-profile-trigger`, `below-micro-deadline`, `exact-tokenizer-unavailable`, `no-safe-candidates` (only recovery-tool output or already-cleared results), `protected-working-set` (everything inside the protected tail), `insufficient-reclaim` and `cannot-reach-deadline-target` (with the reached/required token numbers), `adaptive-cost-rejected`, and `recovery-tool-unavailable`.
86
+
87
+ ### Known limitations
88
+
89
+ - Images never claim exact counts. The official expansion depends on the absolute prompt position (system prompt, chat-template framing, adapter image handles) and on the adapter's final request-image projection (including per-route `imagePixelBudget`/`imageDetail` overrides and byte-cap reprojection), none of which is exposed through the current measurement seam. Intrinsic/default estimates may therefore differ materially from provider accounting. Upstream capability requests remain projected request-image dimensions and the absolute serialized position exposed to token-meter extensions.
90
+ - History skips the whole batch whenever any tool-result candidate lacks an exact count, including image-bearing candidates, even though sibling text candidates are individually exact.
91
+ - Custom remains manual token mode; its History parameters do not follow the Auto Compact watermark.
92
+ - A vision token breakdown UI is not shipped; image estimates and the intrinsic alignment diagnostic are available on the measured token view, while lossy rewrite proofs still require exact counts.
93
+
94
+ ### Deferred
95
+
96
+ - Audit `modality` field and the tokenizer artifact SHA-256 inside audit records (the audits already carry the routed provider/model and tokenizer identity).
97
+ - Publishing the (now complete) runtime skip-reason taxonomy as a user-facing documentation table.
98
+ - Custom-profile display of the A/D watermarks and an above-D warning; Custom remains fully manual.
99
+ - Vision token breakdown UI and promotion of image estimates to exact measurement.
100
+
101
+ ## 0.1.0-beta.2 - 2026-08-28
102
+
103
+ ### Fixed
104
+
105
+ - Resolve the official DeepSeek V4 Flash tokenizer route so Fresh and Aggregate can evaluate tool results for the supported V4 models.
106
+ - Run Cache Strict History at the real request boundary once its configured capacity-pressure condition is met; trigger the capacity condition at 70% routed-context utilization.
107
+ - Disable Harness-native head/middle/tail tool-result pruning whenever a selector profile is active, leaving the selector as the sole tool-result compactor.
108
+
109
+ ### Changed
110
+
111
+ - Protect the newest 10 agent tool calls and a 64,000-token tool-result tail window before History/microcompact rewrites older results.
112
+
113
+ ## 0.1.0-beta.1 - 2026-08-27
114
+
115
+ ### Added
116
+
117
+ - One-install DeepSeek Harness Product Bundle backed by a separate exact-version runtime package.
118
+ - Web profile selector with preset-stable settings and an explicit built-in Minimal exception.
119
+ - Fresh, Aggregate, routine/capacity-aware History, Native tool-result pruning, and default-off Custom TailTrim.
120
+ - Standard-event TailTrim protocol using `compaction/prune` plus recoverable `user/message` replacement.
121
+ - Plugin-owned `context_compression_retrieve` recovery tool.
122
+ - Structured, content-free policy, evaluation, rewrite, failure, and Native auto-compact audit records.
123
+ - Pinned official DeepSeek V4 tokenizer assets with runtime SHA-256 validation and upstream license.
124
+ - Public-API component E2E, preset/Minimal, and parent/fork/spawn cache-prefix regression tests.
125
+
126
+ ### Compatibility
127
+
128
+ - Verified against DeepSeek Harness `dsh-v0.1.1-rc.2` public packages.
129
+ - Exact tokenizer mapping is currently limited to `deepseek-v4-flash` and `deepseek-v4-pro`.
130
+
131
+ ### Known limitations
132
+
133
+ - Adaptive ordinary History fails closed when public request-level route/cache evidence is incomplete; capacity pressure remains a separate safety override.
134
+ - Cache-prefix tests prove native fork inheritance and identical serialized prefixes, not a provider-specific cache allocation or a guaranteed DeepSeek cache hit.
135
+ - Settings snapshots and first-exposure decisions are process-local to the mounted runtime.
@@ -0,0 +1,39 @@
1
+ # 更新日志(fork 新增条目)
2
+
3
+ > 完整历史(含上游 0.1.0 及更早版本)见 [CHANGELOG.md](CHANGELOG.md)。本文件只翻译本 fork 的新增条目。 · [English](CHANGELOG.md) · [日本語](CHANGELOG.ja.md) · [한국어](CHANGELOG.ko.md)
4
+
5
+ ## 0.1.1
6
+
7
+ ### 新增
8
+
9
+ - `scripts/` 的 TypeScript 工具链:`verify-release`、`packed-components-smoke` 和 `packed-install-e2e` 现为 `.ts` 源文件,通过 `tsc` 编译至 `scripts-dist/`,消除仓库中最后三个非 TS 源文件。
10
+
11
+ ### 变更
12
+
13
+ - `package.json` 脚本 `test:e2e:packed` 和 `verify:release` 现运行 `scripts-dist/` 中的编译产物。
14
+ - 估计器目录路由注册加固:`asWebServer` 直接返回 service 本身(D7 修复),估计器 UI 在未激活时保留区块标题而非隐藏(U1 修复)。
15
+ - 框架文档更正:行级 `inject: [webServer]` 非承载性(Y22);DSH 中无 `isolate()` 实例。
16
+
17
+ ### 修复
18
+
19
+ - 估计器目录路由自始至终从未注册,因 `asWebServer` 使 `register` 脱离 service(D7)。
20
+ - 非 TokenPilot Profile 下估计器区块静默消失,无任何启用提示(U1)。
21
+
22
+ ## Unreleased(未发布)
23
+
24
+ ### 新增
25
+
26
+ - 正交的代码骨架压缩门(`codeSkeleton.enabled`,默认关闭):超大源码类工具结果首次曝光时,可保留导入与声明的骨架——省略函数体并保留错误行——失败时回退到原头部裁剪。这道门独立于所有 Profile,且以精确 tokenizer 测量为前提。
27
+ - 选择器设置区内新增该门的开关,附简体中文与英文文案。
28
+ - 新增段的浏览器/运行时解码对齐测试、`saveCodeSkeleton` 的 confirm-on-write 契约测试,以及全文档 parity 矩阵扩展。
29
+
30
+ ### 变更
31
+
32
+ - 新增 ESLint 平铺配置基线(`pnpm lint`,CI 同步强制)与 `pnpm test:watch` TDD 环路;清理死导入,并修复 lint 基线暴露的两处错误处理路径。
33
+ - 本仓库现为 `WilliamShi666/dsh-context-compression-selector` 的改进版 fork;文档提供英、简中、日、韩四种语言。
34
+
35
+ ### 修复
36
+
37
+ - 估计器卡片在 Harness 宿主通道上不再要求 API Key。选择宿主通道后只显示实时供应商/模型下拉框,并标出当前真正生效的路由(显式覆盖优先,否则跟随会话默认模型);既不显示密钥输入框,也不再有第二个手填模型输入——端点地址、模型文本框与只写密钥均只属于直连端点通道。
38
+ - `presetOptions` 写入改为保留同级字段。`settingsScope.set('presetOptions', patch)` 会替换整个分节,导致再改动估计器的任何一个字段(供应商、模型、端点)都会删掉 `estimatorMode` 及其余全部覆盖值——估计器被静默关回关闭状态,而面板却报告保存成功。现在补丁会合并到已存分节之上,`undefined` 只清除指名的那一个字段,空改动不写盘,且 confirm-on-write 校验同一组字段而非仅校验通道。
39
+ - 新增回归覆盖:`packages/selector/tests/preset-options-write.client.spec.ts`(合并写入、保留同级字段、显式清除、空改动不写、未提交写入的报错)与 `packages/selector/tests/estimator-channel.client.spec.tsx`(各通道字段、目录下拉框、手填回退)。
@@ -0,0 +1,22 @@
1
+ # Contributing
2
+
3
+ Thank you for helping improve this community plugin.
4
+
5
+ 1. Open an issue before large behavior or compatibility changes.
6
+ 2. Keep every production change inside this repository; do not require a DeepSeek Harness core patch.
7
+ 3. Add a failing regression first for compression, surface/recovery, preset, tokenizer, or cache-prefix behavior.
8
+ 4. Run:
9
+
10
+ ```sh
11
+ pnpm install --frozen-lockfile
12
+ pnpm test
13
+ pnpm typecheck
14
+ pnpm build
15
+ pnpm verify:release
16
+ pnpm pack:dry-run
17
+ ```
18
+
19
+ 5. Never commit API keys, `.env` files, real Session logs, prompts/tool results, user paths, generated tarballs, or NPM tokens.
20
+ 6. Read [`docs/repair-log.md`](docs/repair-log.md) before starting a new branch or version. It is the cross-version ledger of install/boot defects; a class recorded there must be re-checked on every new line instead of being rediscovered. Note in particular that `lib/` is committed, so a built chunk an entry imports must be committed in the same change — `pnpm verify:release` enforces it.
21
+
22
+ Pull requests should explain the evidence for “triggered”, “enabled but skipped”, and fail-open behavior separately. A code path existing is not runtime proof. Changes to tokenizer/model compatibility require an official source, pinned revision, license, byte length, SHA-256, and negative tests.
package/README.ja.md ADDED
@@ -0,0 +1,104 @@
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.ko.md) · [変更履歴](CHANGELOG.ja.md) · [インストールガイド](docs/installation.ja.md)
6
+
7
+ > [!NOTE]
8
+ > **このフォークがアップストリーム 0.1.0 に追加したもの:**
9
+ >
10
+ > - 直交する**コードスケルトン圧縮ゲート**(`codeSkeleton.enabled`、デフォルトはオフ):超大規模なソースコード系ツール結果の初回露出時に、通常の reducer に渡る前でインポートと宣言のスケルトンを保持できます(関数本体は省略、エラー行は保持)。
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 方式の先頭/中間/末尾トリミングを明示的なプロファイルとして保持します。
26
+ - **コードスケルトン(新規、直交ゲート)**——下記参照。
27
+
28
+ すべての判断は記録されます:ステージ、reducer、トリガー理由、スキップ理由、そして取得可能な場合は正確なトークン数。
29
+
30
+ ## コードスケルトンゲート(新規)
31
+
32
+ ゲートを有効にすると、超大規模な**ソースコード系の新規ツール結果**(例:大きな `read_file`)に対して、まずスケルトン圧縮を試みます:インポートと型/関数/クラス宣言を保持し、関数本体をマーカー付きで省略し、省略された本体の中のエラー行を保持します。スケルトンを生成できない、または検証できない場合は、元の先頭トリミングへフォールバックします——このゲートがコンテキストを悪化させることはありません。
33
+
34
+ 特徴:
35
+
36
+ - **直交**:選択されたプロファイル(`balanced`、`savings`、`cache-strict`、`adaptive`、`custom`、`off`、`native`)から独立しています。すべてのプロファイルでゲートを利用できます。
37
+ - **デフォルトはオフ**:`codeSkeleton: { enabled: false }`。明示的に有効化するまで動作しません。
38
+ - **計測が前提**:正確な DeepSeek トークナイザーが必要で、利用不可の場合は fail-open します。
39
+ - **セッション凍結**:他のセレクター設定と同様、変更は新しく観測されたセッションにのみ適用されます。
40
+ - **厳格なパース**:`codeSkeleton` は正確に `{ enabled: boolean }` である必要があります。不正な値はランタイム側でスローされ、ブラウザー UI 側では読み取り不能として表示されます。
41
+
42
+ ### 出典、そしてこの数値は誰のものか
43
+
44
+ スケルトン化のアプローチは **[Headroom](https://github.com/headroomlabs-ai/headroom)**
45
+ (Apache-2.0)から借用しています。AI エージェント向けのコンテキスト圧縮レイヤーで、JSON・
46
+ ソースコード・散文をそれぞれ別の圧縮器に振り分け(JSON は `SmartCrusher`、コードは
47
+ `CodeCompressor`)、スケルトン変換は
48
+ `crates/headroom-core/src/transforms/live_zone.rs` と `smart_crusher/planning.rs` にあります。
49
+
50
+ **削減率は Headroom のものであり、本プラグインのものではありません。** Headroom が公開している
51
+ 公式な表現は次のとおりです。
52
+
53
+ > 20% fewer tokens for coding agents, **60–95% fewer tokens for JSON**, same answers.
54
+
55
+ **最大 95% 削減**という数字はこの一文によるもので、口径は JSON ペイロード、Headroom 自身の
56
+ 圧縮器が Headroom 自身のベンチマークで測定した値です。本ゲートの機構はここに同源があります。
57
+ 本リポジトリは**独自のベンチマークを一切持たない**ため、**独自の削減率を主張しません**。
58
+ 数値が必要な場合は出典で確認してください。
59
+
60
+ ## 設定 UI
61
+
62
+ 同じ設定セクションで、圧縮プロファイルの選択、Auto Compact トリガーレベルの調整、コードスケルトン圧縮のトグルが行えます。トグルは変更時に即保存され、再読み込み時には保存済みの状態が表示されます。
63
+
64
+ ![Context Compression Selector 設定 UI](packages/selector/assets/screenshots/context-compression-selector-settings.png)
65
+
66
+ ## インストール
67
+
68
+ ソースからビルドしてインストールします(本フォークはまだ npm に公開していません。内部パッケージ名は意図的にアップストリームのままです):
69
+
70
+ ```sh
71
+ git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
72
+ cd dsh-context-compression-improved
73
+ pnpm install --frozen-lockfile
74
+ pnpm build
75
+ ```
76
+
77
+ その後、セレクターパッケージを pack して Harness プロファイルに追加します——検証とアンインストールを含む完全な手順は[インストールガイド](docs/installation.ja.md)を参照してください。
78
+
79
+ ## 開発
80
+
81
+ ```sh
82
+ pnpm install --frozen-lockfile
83
+ pnpm lint # ESLint ベースライン(CI でも強制)
84
+ pnpm typecheck # runtime + selector + tests の tsc と bundle ステップ
85
+ pnpm test # vitest フルスイート
86
+ pnpm test:watch # TDD ループ:先に失敗する回帰テストを書き、それを通す
87
+ pnpm build
88
+ pnpm verify:release
89
+ ```
90
+
91
+ コントリビューションはアップストリームの規律に従います:先に失敗する回帰テストを追加し、プロダクション変更はすべてこのリポジトリ内に収め、「発火した」「有効だがスキップされた」「fail-open」の証拠をそれぞれ別に示してください。詳細は [CONTRIBUTING.md](CONTRIBUTING.md)。
92
+
93
+ ## 互換性
94
+
95
+ - 公開されているプラグインおよびプロファイル API のみを使用し、DeepSeek Harness `dsh-v0.1.1-rc.2` に対して検証済み。公式 `dsh-v0.1.2-alpha.5` リリースと互換。
96
+ - Node `^22.19.0 || >=24` と pnpm `11.7.0` が必要です。
97
+ - プラグインは Harness の公開拡張 API のみを使用し、Harness コアは改変しません。非公式のコミュニティプロジェクトであり、DeepSeek とは提携・承認関係にありません。
98
+
99
+ ## クレジットとライセンス
100
+
101
+ - アップストリームのプロジェクトと既存のすべての成果:[WilliamShi666/dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector)(作者 WilliamShi666、MIT)。
102
+ - フォークによる追加(コードスケルトンゲート、ツールチェーン、多言語ドキュメント):drscrewdriver。
103
+ - コードスケルトン機構の出典:[Headroom](https://github.com/headroomlabs-ai/headroom)(Apache-2.0)——上記「出典、そしてこの数値は誰のものか」を参照。
104
+ - MIT——[LICENSE](LICENSE)(アップストリームの著作権表示を保持)を参照。同梱トークナイザーの出所は [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。
package/README.ko.md ADDED
@@ -0,0 +1,103 @@
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
+ ### 출처, 그리고 이 수치는 누구의 것인가
43
+
44
+ 스켈레톤화 접근은 **[Headroom](https://github.com/headroomlabs-ai/headroom)**(Apache-2.0)에서
45
+ 차용했습니다. AI 에이전트용 컨텍스트 압축 계층으로, JSON·소스 코드·산문을 각각 다른 압축기로
46
+ 분기하며(JSON은 `SmartCrusher`, 코드는 `CodeCompressor`), 스켈레톤 변환은
47
+ `crates/headroom-core/src/transforms/live_zone.rs`와 `smart_crusher/planning.rs`에 있습니다.
48
+
49
+ **감축 수치는 Headroom의 것이며 이 플러그인의 것이 아닙니다.** Headroom이 공개한 공식 표현은
50
+ 다음과 같습니다.
51
+
52
+ > 20% fewer tokens for coding agents, **60–95% fewer tokens for JSON**, same answers.
53
+
54
+ **최대 95% 감축**이라는 수치는 이 문장에서 나온 것이며, 기준은 JSON 페이로드이고 Headroom 자체
55
+ 압축기가 Headroom 자체 벤치마크에서 측정한 값입니다. 이 게이트의 메커니즘은 여기에 동원(同源)을
56
+ 둡니다. 이 저장소는 **자체 벤치마크가 전혀 없으므로 자체 감축률을 주장하지 않습니다.** 수치가
57
+ 필요하면 출처에서 확인하십시오.
58
+
59
+ ## 설정 UI
60
+
61
+ 동일한 설정 섹션에서 압축 프로파일 선택, Auto Compact 트리거 레벨 조정, 코드 스켈레톤 압축 토글을 모두 처리할 수 있습니다. 토글은 변경 시 즉시 저장되며, 다시 불러올 때 저장된 상태가 표시됩니다.
62
+
63
+ ![Context Compression Selector 설정 UI](packages/selector/assets/screenshots/context-compression-selector-settings.png)
64
+
65
+ ## 설치
66
+
67
+ 소스에서 빌드하여 설치합니다(이 포크는 아직 npm에 게시되지 않았습니다. 내부 패키지 이름은 의도적으로 업스트림과 동일하게 유지됩니다):
68
+
69
+ ```sh
70
+ git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
71
+ cd dsh-context-compression-improved
72
+ pnpm install --frozen-lockfile
73
+ pnpm build
74
+ ```
75
+
76
+ 이후 셀렉터 패키지를 pack 해서 Harness 프로파일에 추가합니다——검증과 제거를 포함한 전체 절차는 [설치 가이드](docs/installation.ko.md)를 참고하세요.
77
+
78
+ ## 개발
79
+
80
+ ```sh
81
+ pnpm install --frozen-lockfile
82
+ pnpm lint # ESLint 베이스라인(CI에서도 강제)
83
+ pnpm typecheck # runtime + selector + tests tsc 및 bundle 단계
84
+ pnpm test # vitest 전체 스위트
85
+ pnpm test:watch # TDD 루프: 먼저 실패하는 회귀 테스트를 작성하고, 통과시킨다
86
+ pnpm build
87
+ pnpm verify:release
88
+ ```
89
+
90
+ 기여는 업스트림의 규율을 따릅니다: 먼저 실패하는 회귀 테스트를 추가하고, 모든 프로덕션 변경은 이 저장소 안에 유지하며, "트리거됨", "활성화되었지만 건너뜀", "fail-open"의 증거를 각각 따로 제시하세요. [CONTRIBUTING.md](CONTRIBUTING.md) 참고.
91
+
92
+ ## 호환성
93
+
94
+ - 공개된 플러그인 및 프로파일 API만 사용하여 DeepSeek Harness `dsh-v0.1.1-rc.2`에서 검증되었으며, 공식 `dsh-v0.1.2-alpha.5` 릴리스와 호환됩니다.
95
+ - Node `^22.19.0 || >=24`와 pnpm `11.7.0`이 필요합니다.
96
+ - 플러그인은 Harness의 공개 확장 API만 사용하며 Harness 코어를 수정하지 않습니다. 비공식 커뮤니티 프로젝트이며 DeepSeek과 제휴하거나 승인받지 않았습니다.
97
+
98
+ ## 크레딧과 라이선스
99
+
100
+ - 업스트림 프로젝트와 기존의 모든 작업: [WilliamShi666/dsh-context-compression-selector](https://github.com/WilliamShi666/dsh-context-compression-selector), 작성자 WilliamShi666(MIT).
101
+ - 포크에서 추가된 것(코드 스켈레톤 게이트, 툴체인, 다국어 문서): drscrewdriver.
102
+ - 코드 스켈레톤 메커니즘 출처: [Headroom](https://github.com/headroomlabs-ai/headroom) (Apache-2.0) — 위의 "출처, 그리고 이 수치는 누구의 것인가"를 참조하십시오.
103
+ - MIT——[LICENSE](LICENSE)(업스트림 저작권 표기 유지) 참고. 번들된 토크나이저의 출처는 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).