dsh-context-compression-improved 0.10.3 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -110
- package/README.zh.md +14 -104
- package/THIRD_PARTY_NOTICES.md +25 -7
- package/{packages/selector/dsh.plugin.json → dsh.plugin.json} +2 -2
- package/{packages/selector/lib → lib}/client.d.ts +4 -0
- package/{packages/selector/lib → lib}/client.js +70 -5
- package/{packages/selector/lib → lib}/invariant.js +1 -1
- package/{packages/selector/lib → lib}/profiles.d.ts +3 -1
- package/{packages/selector/lib → lib}/pruner.d.ts +4 -2
- package/{packages/selector/lib → lib}/pruner.js +40 -37
- package/{packages/selector/lib → lib}/savings-integral.js +83 -24
- package/{packages/selector/lib → lib}/tail-trim.js +2 -2
- package/{packages/selector/lib → lib}/tool-result.js +22 -1
- package/package.json +129 -116
- package/screenshots.json +3 -6
- package/.agents/plans/improve/checklist.md +0 -32
- package/.agents/plans/improve/findings.md +0 -102
- package/.agents/plans/improve/spec.md +0 -53
- package/.agents/plans/improve/tasks.md +0 -70
- package/.gitattributes +0 -2
- package/.githooks/pre-push +0 -37
- package/.github/workflows/ci.yml +0 -39
- package/CHANGELOG.de.md +0 -580
- package/CHANGELOG.es.md +0 -588
- package/CHANGELOG.fr.md +0 -576
- package/CHANGELOG.it.md +0 -577
- package/CHANGELOG.ja.md +0 -261
- package/CHANGELOG.ko.md +0 -254
- package/CHANGELOG.md +0 -549
- package/CHANGELOG.ru.md +0 -554
- package/CHANGELOG.zh.md +0 -238
- package/CONTRIBUTING.md +0 -22
- package/README.de.md +0 -96
- package/README.es.md +0 -96
- package/README.fr.md +0 -96
- package/README.it.md +0 -96
- package/README.ja.md +0 -102
- package/README.ko.md +0 -102
- package/README.ru.md +0 -96
- package/SECURITY.md +0 -18
- package/assets/board.png +0 -0
- package/assets/context.png +0 -0
- package/docs/assets/context-compression-selector-profiles.jpg +0 -0
- package/docs/assets/context-compression-selector-settings.png +0 -0
- package/docs/compat-0.1.5-report.md +0 -77
- package/docs/installation.de.md +0 -104
- package/docs/installation.es.md +0 -104
- package/docs/installation.fr.md +0 -104
- package/docs/installation.it.md +0 -104
- package/docs/installation.ja.md +0 -78
- package/docs/installation.ko.md +0 -78
- package/docs/installation.md +0 -103
- package/docs/installation.ru.md +0 -104
- package/docs/installation.zh.md +0 -100
- package/docs/repair-log.md +0 -657
- package/eslint.config.js +0 -30
- package/packages/selector/LICENSE +0 -21
- package/packages/selector/README.md +0 -26
- package/packages/selector/README.zh.md +0 -24
- package/packages/selector/THIRD_PARTY_NOTICES.md +0 -32
- package/packages/selector/docs/history-tool-call-working-set-spec.md +0 -112
- package/packages/selector/docs/native-tool-result-selector-spec.md +0 -34
- package/packages/selector/docs/subagent-cache-reuse-spec.md +0 -46
- package/packages/selector/lib/style.css +0 -350
- package/packages/selector/package.json +0 -178
- package/packages/selector/screenshots.json +0 -3
- package/packages/selector/src/client/CompressionProfileControls.tsx +0 -293
- package/packages/selector/src/client/CompressionProfileSelector.module.css +0 -199
- package/packages/selector/src/client/CompressionProfileSelector.tsx +0 -85
- package/packages/selector/src/client/CustomPolicyEditor.tsx +0 -216
- package/packages/selector/src/client/EstimatorControls.tsx +0 -277
- package/packages/selector/src/client/bridge-scope.ts +0 -125
- package/packages/selector/src/client/decode.ts +0 -57
- package/packages/selector/src/client/fab-pos.ts +0 -71
- package/packages/selector/src/client/index.ts +0 -424
- package/packages/selector/src/client/locales/de.ts +0 -158
- package/packages/selector/src/client/locales/es.ts +0 -158
- package/packages/selector/src/client/locales/fr.ts +0 -158
- package/packages/selector/src/client/locales/it.ts +0 -158
- package/packages/selector/src/client/locales/ja.ts +0 -158
- package/packages/selector/src/client/locales/ko.ts +0 -158
- package/packages/selector/src/client/locales/ru.ts +0 -158
- package/packages/selector/src/client/locales.ts +0 -316
- package/packages/selector/src/client/monitor-fab.ts +0 -431
- package/packages/selector/src/client/preset-options.ts +0 -88
- package/packages/selector/src/client/savings-card.tsx +0 -269
- package/packages/selector/src/client/scope-face.ts +0 -24
- package/packages/selector/src/client/settings-section.tsx +0 -140
- package/packages/selector/src/compat/host-generation.ts +0 -96
- package/packages/selector/src/compat/llm-messages.ts +0 -50
- package/packages/selector/src/compat/settings-lease.ts +0 -108
- package/packages/selector/src/compat/tool-result.ts +0 -91
- package/packages/selector/src/css-modules.d.ts +0 -6
- package/packages/selector/src/deepseek-v4-tokenizer.ts +0 -205
- package/packages/selector/src/estimator-catalog.ts +0 -104
- package/packages/selector/src/index.ts +0 -890
- package/packages/selector/src/invariant.ts +0 -113
- package/packages/selector/src/preset-overlay.ts +0 -749
- package/packages/selector/src/profiles.ts +0 -431
- package/packages/selector/src/pruner/content.ts +0 -198
- package/packages/selector/src/pruner/session.ts +0 -97
- package/packages/selector/src/pruner/state.ts +0 -61
- package/packages/selector/src/pruner/tuning.ts +0 -23
- package/packages/selector/src/pruner/types.ts +0 -78
- package/packages/selector/src/pruner.ts +0 -2914
- package/packages/selector/src/runtime/adaptive-cost.ts +0 -205
- package/packages/selector/src/runtime/audit.ts +0 -320
- package/packages/selector/src/runtime/config.ts +0 -756
- package/packages/selector/src/runtime/custom-policy.ts +0 -278
- package/packages/selector/src/runtime/deepseek-official-pricing.ts +0 -298
- package/packages/selector/src/runtime/deepseek-v4-vision-tokens.ts +0 -254
- package/packages/selector/src/runtime/display-prefs.ts +0 -98
- package/packages/selector/src/runtime/measurement.ts +0 -444
- package/packages/selector/src/runtime/monitor.ts +0 -310
- package/packages/selector/src/runtime/panel-command.ts +0 -213
- package/packages/selector/src/runtime/reducers.ts +0 -1754
- package/packages/selector/src/runtime/retrieve.ts +0 -503
- package/packages/selector/src/runtime/savings-integral.ts +0 -117
- package/packages/selector/src/runtime/savings-projection.ts +0 -229
- package/packages/selector/src/runtime/savings-verify.ts +0 -446
- package/packages/selector/src/runtime/savings.ts +0 -526
- package/packages/selector/src/runtime/session-events.ts +0 -30
- package/packages/selector/src/runtime/session-file-decode.ts +0 -523
- package/packages/selector/src/runtime/stats-backfill.ts +0 -541
- package/packages/selector/src/runtime/stats-db.ts +0 -492
- package/packages/selector/src/runtime/stats-schema.ts +0 -123
- package/packages/selector/src/runtime/stats-sync.ts +0 -307
- package/packages/selector/src/runtime/summary-command.ts +0 -127
- package/packages/selector/src/runtime/tail-trim.ts +0 -176
- package/packages/selector/src/runtime/token-count.ts +0 -72
- package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +0 -233
- package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +0 -204
- package/packages/selector/src/runtime/tokenpilot/advisor.ts +0 -419
- package/packages/selector/src/runtime/tokenpilot/benefit.ts +0 -200
- package/packages/selector/src/runtime/tokenpilot/dedup.ts +0 -81
- package/packages/selector/src/runtime/tokenpilot/estimator.ts +0 -151
- package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +0 -53
- package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +0 -65
- package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +0 -125
- package/packages/selector/src/runtime/tokenpilot/intent-range.ts +0 -37
- package/packages/selector/src/runtime/tokenpilot/locator.ts +0 -128
- package/packages/selector/src/runtime/tokenpilot/read-state.ts +0 -98
- package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +0 -303
- package/packages/selector/src/runtime/toolclass.ts +0 -103
- package/packages/selector/src/runtime/types.ts +0 -365
- package/packages/selector/src/runtime/value.ts +0 -48
- package/packages/selector/src/settings-bridge.ts +0 -175
- package/packages/selector/tests/advisor-report.host.spec.ts +0 -223
- package/packages/selector/tests/auto-compact.client.spec.tsx +0 -214
- package/packages/selector/tests/built/client-artifact.spec.ts +0 -56
- package/packages/selector/tests/cache-prefix-audit.spec.ts +0 -123
- package/packages/selector/tests/code-skeleton.client.spec.ts +0 -98
- package/packages/selector/tests/compat/compat-narrow-waist.spec.ts +0 -150
- package/packages/selector/tests/custom-contract.client.spec.ts +0 -226
- package/packages/selector/tests/estimator-catalog.spec.ts +0 -70
- package/packages/selector/tests/estimator-channel.client.spec.tsx +0 -253
- package/packages/selector/tests/estimator-route-registration.host.spec.ts +0 -202
- package/packages/selector/tests/fab-pos.client.spec.ts +0 -47
- package/packages/selector/tests/helpers/legacy-namespace.ts +0 -35
- package/packages/selector/tests/helpers/legacy-settings/index.ts +0 -15
- package/packages/selector/tests/helpers/legacy-settings/legacy/provider.d.ts +0 -41
- package/packages/selector/tests/helpers/legacy-settings/legacy/provider.js +0 -647
- package/packages/selector/tests/helpers/legacy-settings/legacy/redact.js +0 -78
- package/packages/selector/tests/helpers/legacy-settings/legacy/util-values.js +0 -234
- package/packages/selector/tests/host-preset-overlay.host.spec.ts +0 -204
- package/packages/selector/tests/monitor-fab.client.spec.ts +0 -240
- package/packages/selector/tests/preset-options-write.client.spec.ts +0 -192
- package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +0 -200
- package/packages/selector/tests/preset-overlay.host.spec.ts +0 -246
- package/packages/selector/tests/profiles.client.spec.tsx +0 -436
- package/packages/selector/tests/public/package-contract.client.spec.ts +0 -86
- package/packages/selector/tests/runtime/adaptive-cost.spec.ts +0 -167
- package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +0 -230
- package/packages/selector/tests/runtime/advisor-invariant.spec.ts +0 -272
- package/packages/selector/tests/runtime/advisor.spec.ts +0 -226
- package/packages/selector/tests/runtime/audit.spec.ts +0 -275
- package/packages/selector/tests/runtime/auto-compact-config.spec.ts +0 -523
- package/packages/selector/tests/runtime/char-basis.spec.ts +0 -30
- package/packages/selector/tests/runtime/code-skeleton.spec.ts +0 -152
- package/packages/selector/tests/runtime/deepseek-official-pricing.spec.ts +0 -186
- package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +0 -122
- package/packages/selector/tests/runtime/deepseek-v4-vision-tokens.spec.ts +0 -122
- package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +0 -96
- package/packages/selector/tests/runtime/fixtures/profile-baseline.json +0 -273
- package/packages/selector/tests/runtime/fixtures/session-v4-dump.jsonl +0 -46
- package/packages/selector/tests/runtime/fixtures/tokenizer-golden.json +0 -106
- package/packages/selector/tests/runtime/fixtures/vision-golden.json +0 -459
- package/packages/selector/tests/runtime/frequency-longstrings.spec.ts +0 -74
- package/packages/selector/tests/runtime/fresh-gate.spec.ts +0 -43
- package/packages/selector/tests/runtime/html-reducer.spec.ts +0 -212
- package/packages/selector/tests/runtime/intent-gate.spec.ts +0 -62
- package/packages/selector/tests/runtime/intent-summary.spec.ts +0 -156
- package/packages/selector/tests/runtime/jsonl-reducer.spec.ts +0 -79
- package/packages/selector/tests/runtime/line-mapping.spec.ts +0 -153
- package/packages/selector/tests/runtime/monitor.spec.ts +0 -354
- package/packages/selector/tests/runtime/panel-command.spec.ts +0 -101
- package/packages/selector/tests/runtime/prose-reducers.spec.ts +0 -133
- package/packages/selector/tests/runtime/public/public-runtime.spec.ts +0 -2781
- package/packages/selector/tests/runtime/read-input-cap.spec.ts +0 -33
- package/packages/selector/tests/runtime/savings-accounting.spec.ts +0 -291
- package/packages/selector/tests/runtime/savings-integral.spec.ts +0 -169
- package/packages/selector/tests/runtime/savings-projection.spec.ts +0 -89
- package/packages/selector/tests/runtime/savings-verify.spec.ts +0 -226
- package/packages/selector/tests/runtime/savings.spec.ts +0 -139
- package/packages/selector/tests/runtime/search-reducer.spec.ts +0 -110
- package/packages/selector/tests/runtime/session-events.spec.ts +0 -27
- package/packages/selector/tests/runtime/session-file-decode.spec.ts +0 -281
- package/packages/selector/tests/runtime/settings-unwrap.spec.ts +0 -58
- package/packages/selector/tests/runtime/sidechannel.spec.ts +0 -241
- package/packages/selector/tests/runtime/stats-backfill-scheduler.spec.ts +0 -167
- package/packages/selector/tests/runtime/stats-backfill.spec.ts +0 -348
- package/packages/selector/tests/runtime/stats-db.spec.ts +0 -361
- package/packages/selector/tests/runtime/stats-privacy.spec.ts +0 -55
- package/packages/selector/tests/runtime/stats-sync.spec.ts +0 -278
- package/packages/selector/tests/runtime/summary-command.spec.ts +0 -154
- package/packages/selector/tests/runtime/toc-and-bundled.spec.ts +0 -159
- package/packages/selector/tests/runtime/tokenizer-golden.spec.ts +0 -53
- package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +0 -217
- package/packages/selector/tests/runtime/tokenpilot/dedup.spec.ts +0 -52
- package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +0 -79
- package/packages/selector/tests/runtime/tokenpilot/locator.spec.ts +0 -76
- package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +0 -119
- package/packages/selector/tests/runtime/tokenpilot/read-state.spec.ts +0 -82
- package/packages/selector/tests/runtime/toolclass.spec.ts +0 -156
- package/packages/selector/tests/runtime/value.spec.ts +0 -23
- package/packages/selector/tests/savings-sessions.client.spec.tsx +0 -140
- package/packages/selector/tests/settings-seat.client.spec.ts +0 -215
- package/packages/selector/tests/standing-generation.host.spec.ts +0 -724
- package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +0 -269
- package/packages/selector/tests/support/cache-prefix-audit.ts +0 -105
- package/packages/selector/tests/support/mock-adapter.ts +0 -37
- package/packages/selector/tests/support/ui-primitives.tsx +0 -34
- package/packages/selector/tsconfig.json +0 -11
- package/packages/selector/tsdown.client.config.ts +0 -102
- package/packages/selector/tsdown.config.ts +0 -20
- package/pnpm-workspace.yaml +0 -76
- package/scripts/capture-profile-baseline.mjs +0 -42
- package/scripts/cell-browser-e2e.mjs +0 -354
- package/scripts/generate-tokenizer-fixtures.py +0 -81
- package/scripts/generate-vision-fixtures.py +0 -208
- package/scripts/hosts.mjs +0 -78
- package/scripts/packed-components-smoke.mjs +0 -763
- package/scripts/packed-install-e2e.mjs +0 -1346
- package/scripts/sync-hosts.mjs +0 -174
- package/scripts/toolclass-corpus-replay.mjs +0 -281
- package/scripts/verify-release.mjs +0 -338
- package/tests/TEST_INVENTORY.md +0 -41
- package/tsconfig.base.json +0 -18
- package/tsconfig.json +0 -7
- package/tsconfig.tests.json +0 -15
- package/vitest.built.config.ts +0 -9
- package/vitest.config.ts +0 -54
- /package/{packages/selector/assets → assets}/deepseek-v4/LICENSE.DeepSeek-V4-Pro.txt +0 -0
- /package/{packages/selector/assets → assets}/deepseek-v4/manifest.json +0 -0
- /package/{packages/selector/assets → assets}/deepseek-v4/tokenizer.json +0 -0
- /package/{packages/selector/assets → assets}/deepseek-v4/tokenizer_config.json +0 -0
- /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/LICENSE.DeepSeek-V4-Flash-Vision-Exp.txt +0 -0
- /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/manifest.json +0 -0
- /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/tokenizer.json +0 -0
- /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/tokenizer_config.json +0 -0
- /package/{packages/selector/cordis.patch.yml → cordis.patch.yml} +0 -0
- /package/{packages/selector/lib → lib}/index.d.ts +0 -0
- /package/{packages/selector/lib → lib}/index.js +0 -0
- /package/{packages/selector/lib → lib}/invariant.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,121 +1,26 @@
|
|
|
1
1
|
# dsh-context-compression-improved
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The installable Product Bundle for the unofficial community DeepSeek Harness context-compression selector.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
> [!TIP]
|
|
18
|
-
> **Recommended: connect DeepSeek with your own API key via a custom Responses API endpoint.** Prefer a custom OpenAI-compatible endpoint (`/v1/responses`) over the official-account Messages API route: it does not go through the Anthropic-style message serialization, so requests never trip message-format issues or `tool_use`/`tool_result` pairing validation (the official route's resume-replay 400s cannot be repaired from the plugin side), and you can switch endpoint nodes over time and keep existing sessions running.
|
|
19
|
-
|
|
20
|
-
<!-- host-compat:begin — generated by scripts/sync-hosts.mjs from scripts/hosts.mjs; DO NOT EDIT -->
|
|
21
|
-
- **Supported DSH hosts:** `0.1.0-rc.2` `0.1.0-rc.3` `0.1.0-rc.6` `0.1.0-rc.7` `0.1.0-rc.8` `0.1.1-rc.1` `0.1.1-rc.2` `0.1.2-rc.1` `0.1.5-rc.1` `0.1.5-rc.2` `0.1.5-rc.3` `0.1.7-rc.1` `0.1.7-rc.2` `0.2.0-rc.1` `0.2.0-rc.2` `0.2.1-rc.1` `0.2.1-rc.2` `0.2.1-rc.3` `0.2.1-rc.4` `0.2.1-rc.5` (20 rc releases across lines 0.1.0 / 0.1.1 / 0.1.2 / 0.1.5 / 0.1.7 / 0.2.0 / 0.2.1)
|
|
22
|
-
<!-- host-compat:end -->
|
|
23
|
-
|
|
24
|
-
## What it is
|
|
25
|
-
|
|
26
|
-
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:
|
|
27
|
-
|
|
28
|
-
- **Fresh** pre-compresses a newly oversized tool-result segment before the model receives it.
|
|
29
|
-
- **Aggregate** pre-compresses fresh material again when it still grows beyond its budget.
|
|
30
|
-
- **History / micro-compact** replaces eligible old tool results while preserving recent working context.
|
|
31
|
-
- **TailTrim** is an optional Custom-only tail reduction path.
|
|
32
|
-
- **Native** preserves the Harness-style head/middle/tail trimming as one explicit profile.
|
|
33
|
-
- **Code skeleton (new, orthogonal gate)** — see below.
|
|
34
|
-
|
|
35
|
-
Every decision is recorded: stage, reducer, trigger, skip reason, and exact token counts where available.
|
|
36
|
-
|
|
37
|
-
## Code skeleton gate (new)
|
|
38
|
-
|
|
39
|
-
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.
|
|
40
|
-
|
|
41
|
-
Properties:
|
|
42
|
-
|
|
43
|
-
- **Orthogonal**: independent of the selected profile (`balanced`, `savings`, `cache-strict`, `adaptive`, `custom`, `off`, `native`). All profiles get the gate.
|
|
44
|
-
- **Off by default**: `codeSkeleton: { enabled: false }` until you turn it on.
|
|
45
|
-
- **Measurement-gated**: requires the exact DeepSeek tokenizer; without it the plugin fails open.
|
|
46
|
-
- **Session-frozen**: like all selector settings, changes affect newly observed sessions only.
|
|
47
|
-
- **Strictly parsed**: `codeSkeleton` must be exactly `{ enabled: boolean }`; malformed values throw on the runtime side and show as unreadable in the browser UI.
|
|
48
|
-
|
|
49
|
-
## Settings UI
|
|
50
|
-
|
|
51
|
-
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.
|
|
52
|
-
|
|
53
|
-

|
|
54
|
-
|
|
55
|
-
## Monitoring UI
|
|
56
|
-
|
|
57
|
-
While compression runs, the plugin gives you a live view of what it saves: a **compression monitor** panel — net/gross savings, offsets, context usage, cache-hit rate, cost estimate, and the turn-tail intent-summary state, with a per-session resume/disable override right in the panel — next to the session's context trend chart.
|
|
58
|
-
|
|
59
|
-

|
|
60
|
-
|
|
61
|
-
Context trend for a session under compression: per-step / per-turn token composition with a timing overlay; the scissors mark where reductions landed.
|
|
62
|
-
|
|
63
|
-

|
|
64
|
-
|
|
65
|
-
## Stats semantics and persistence
|
|
66
|
-
|
|
67
|
-
Savings are reported in three distinct semantics — never merged:
|
|
68
|
-
|
|
69
|
-
- **Stock (currently active)** — net savings still in effect on the live surface; it rises and falls as compressed content moves in and out.
|
|
70
|
-
- **Cumulative (across N calls)** — the stock sampled at every request boundary and summed; answers "how much was saved historically" and survives host restarts.
|
|
71
|
-
- **Money saved** — cumulative weighted by cache hit/miss at official list prices (deepseek-official official routes only; other routes show the token figure).
|
|
72
|
-
|
|
73
|
-
Stats persist in SQLite (`~/.dsh/storages/dsh-context-compression/stats.sqlite`) across host restarts; a missing driver or write failure degrades visibly (panel badge, in-memory fallback). Historical sessions are backfilled from on-disk behavior records (host `sessionQuery` service preferred, read-only session-log parsing as fallback — session files are never written). Records contain counts, sequence numbers, session identifiers, and enum component names only; original text and free-form text never enter the database. Delete the file to reset stats completely.
|
|
74
|
-
|
|
75
|
-
The `/ccip` command drives the panel in real time: `rows stock|total|money on|off`, `mode compact|full`, `session <id|latest|off>`, `flush`, `backfill pause|resume|status`.
|
|
76
|
-
|
|
77
|
-
## Install
|
|
78
|
-
|
|
79
|
-
**Recommended: install from npm.** One version covers every supported Harness line — `latest` carries the full 17-rc enum (0.1.0-rc.2 → 0.2.1-rc.2); the runtime picks per-line code paths on its own.
|
|
5
|
+
**0.1.0 highlights:** DeepSeek V4 Flash Vision's official tokenizer is included; users can choose the model-driven Auto Compact threshold; standard profile watermarks and compression parameters follow that choice.
|
|
80
6
|
|
|
81
7
|
```sh
|
|
82
|
-
dsh plugin --profile web add dsh-context-compression-improved@latest
|
|
83
|
-
dsh --profile web --dump-config
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
From source (alternative — the internal package names intentionally stay upstream's):
|
|
87
|
-
|
|
88
8
|
```sh
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
9
|
+
dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.5
|
|
10
|
+
# DSH 0.1.2 line:
|
|
11
|
+
# dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.2
|
|
12
|
+
dsh --profile web --dump-config
|
|
93
13
|
```
|
|
94
|
-
|
|
95
|
-
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).
|
|
96
|
-
|
|
97
|
-
## Development
|
|
98
|
-
|
|
99
|
-
```sh
|
|
100
|
-
pnpm install --frozen-lockfile
|
|
101
|
-
pnpm lint # ESLint baseline (also enforced in CI)
|
|
102
|
-
pnpm typecheck # runtime + selector + tests tsc, plus the bundle step
|
|
103
|
-
pnpm test # full vitest suite
|
|
104
|
-
pnpm test:watch # TDD loop: write the failing regression first, then make it pass
|
|
105
|
-
pnpm build
|
|
106
|
-
pnpm verify:release
|
|
14
|
+
dsh --profile web --dump-config
|
|
107
15
|
```
|
|
108
16
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
- 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.
|
|
17
|
+
This one command installs the single `dsh-context-compression-improved` package: the compression
|
|
18
|
+
runtime, the Host settings, the Web UI and the reversible preset overlay all ship in it.
|
|
19
|
+
The Bundle contributes Host settings, the Web UI, and a reversible preset overlay. All presets
|
|
20
|
+
except the exact built-in `minimal` id receive the compression stack; switching non-Minimal
|
|
21
|
+
presets preserves the saved selector settings. Minimal pauses plugin compression without
|
|
22
|
+
deleting the setting.
|
|
116
23
|
|
|
117
|
-
|
|
24
|
+
Verified compatibility: DeepSeek Harness `dsh-v0.1.1-rc.2` and `dsh-v0.1.2-alpha.5`, Node `^22.19.0 || >=24`. No Harness core patch is required.
|
|
118
25
|
|
|
119
|
-
|
|
120
|
-
- Fork additions (code-skeleton gate, tooling, localized docs): drscrewdriver.
|
|
121
|
-
- MIT — see [LICENSE](LICENSE) (upstream copyright notice retained) and [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for bundled tokenizer provenance.
|
|
26
|
+
See the [full README](https://github.com/WilliamShi666/dsh-context-compression-improved#readme) for profiles, defaults, audit evidence, Adaptive/cache limitations, upgrade/removal, and security guidance. This package is not affiliated with or endorsed by DeepSeek.
|
package/README.zh.md
CHANGED
|
@@ -1,114 +1,24 @@
|
|
|
1
1
|
# dsh-context-compression-improved
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
这是可直接安装的非官方社区 DeepSeek Harness 上下文压缩选择器 Product Bundle。
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
> [!TIP]
|
|
18
|
-
> **推荐接入方式:用 API key 以自定义 Responses API 连接 DeepSeek。** 建议走自定义 OpenAI 兼容端点(`/v1/responses`)而不是官方账号的 Messages API 路由:前者不经过 Anthropic 风格的消息序列化,不会因为 message 格式而出现问题,可避开 `tool_use`/`tool_result` 配对校验限制(官方路由 resume-replay 时的 400 插件侧无法修复);也便于按时间切换节点后接续会话。
|
|
19
|
-
|
|
20
|
-
<!-- host-compat:begin — generated by scripts/sync-hosts.mjs from scripts/hosts.mjs; DO NOT EDIT -->
|
|
21
|
-
- **支持的 DSH 宿主:** `0.1.0-rc.2` `0.1.0-rc.3` `0.1.0-rc.6` `0.1.0-rc.7` `0.1.0-rc.8` `0.1.1-rc.1` `0.1.1-rc.2` `0.1.2-rc.1` `0.1.5-rc.1` `0.1.5-rc.2` `0.1.5-rc.3` `0.1.7-rc.1` `0.1.7-rc.2` `0.2.0-rc.1` `0.2.0-rc.2` `0.2.1-rc.1` `0.2.1-rc.2` `0.2.1-rc.3` `0.2.1-rc.4` `0.2.1-rc.5`(覆盖 0.1.0 / 0.1.1 / 0.1.2 / 0.1.5 / 0.1.7 / 0.2.0 / 0.2.1 七条线共 20 个 rc)
|
|
22
|
-
<!-- host-compat:end -->
|
|
23
|
-
|
|
24
|
-
## 它是什么
|
|
25
|
-
|
|
26
|
-
长时运行的 agent 任务会积累大量工具输出。本社区插件在不修改 DeepSeek Harness 核心的前提下,提供可选、可审计的工具结果上下文压缩策略:
|
|
27
|
-
|
|
28
|
-
- **Fresh**:在模型收到之前,预压缩新近超限的工具结果段。
|
|
29
|
-
- **Aggregate**:当 Fresh 压缩后仍超出预算时再次预压缩。
|
|
30
|
-
- **History / micro-compact**:在保护近期工作上下文的前提下替换符合条件的旧工具结果。
|
|
31
|
-
- **TailTrim**:仅在 Custom 下可选的尾窗收缩路径。
|
|
32
|
-
- **Native**:把 Harness 原生头中尾裁剪保留为一个显式 Profile。
|
|
33
|
-
- **代码骨架(新增,正交门)**——见下节。
|
|
34
|
-
|
|
35
|
-
每个决策都会留痕:阶段、reducer、触发原因、跳过原因,以及可得时的精确 token 数。
|
|
36
|
-
|
|
37
|
-
## 代码骨架门(新增)
|
|
38
|
-
|
|
39
|
-
开启后,超大**源码类新工具结果**(例如大型 `read_file`)会先尝试骨架化压缩:保留导入与类型/函数/类声明,省略函数体并加占位标记,被省略函数体内的错误行予以保留。若骨架无法生成或无法通过验证,则回退到原有的头部裁剪——这道门不会让上下文变得更差。
|
|
40
|
-
|
|
41
|
-
特性:
|
|
42
|
-
|
|
43
|
-
- **正交**:独立于所选 Profile(`balanced`、`savings`、`cache-strict`、`adaptive`、`custom`、`off`、`native`),所有 Profile 都能拿到这道门。
|
|
44
|
-
- **默认关闭**:`codeSkeleton: { enabled: false }`,需要显式开启。
|
|
45
|
-
- **测量前置**:需要精确 DeepSeek tokenizer;不可用时 fail-open。
|
|
46
|
-
- **会话冻结**:与所有选择器设置一致,修改只影响新观察的会话。
|
|
47
|
-
- **严格解析**:`codeSkeleton` 必须恰好是 `{ enabled: boolean }`;畸形输入在运行时侧抛错、浏览器侧显示不可读。
|
|
48
|
-
|
|
49
|
-
## 设置界面
|
|
50
|
-
|
|
51
|
-
在同一设置区内选择压缩 Profile、调整 Auto Compact 触发水位,并开关代码骨架压缩。开关即改即存,刷新后显示已保存状态。
|
|
52
|
-
|
|
53
|
-

|
|
54
|
-
|
|
55
|
-
## 监控界面
|
|
56
|
-
|
|
57
|
-
压缩运行时,插件提供节省量的实时视图:**压缩监控**悬浮面板——净节省/毛节省/抵消/上下文占用/缓存命中率/成本估算/回合末意图摘要状态,面板内可直接对当前会话恢复或停用——以及会话的上下文趋势图。
|
|
58
|
-
|
|
59
|
-

|
|
60
|
-
|
|
61
|
-
压缩会话的上下文趋势:逐步骤/轮次的 token 组成与耗时叠加,剪刀标记指示裁剪/折叠落点。
|
|
62
|
-
|
|
63
|
-

|
|
64
|
-
|
|
65
|
-
## 统计口径与持久化
|
|
66
|
-
|
|
67
|
-
节省统计分三个口径,语义不同、互不替代:
|
|
68
|
-
|
|
69
|
-
- **存量(当前生效)**——当前上下文面上仍在生效的净节省,随压缩内容进出面而涨落;
|
|
70
|
-
- **累计(按 N 次 call)**——每个请求边界对存量的采样求和,回答"历史上总共省了多少",跨宿主重启保留;
|
|
71
|
-
- **省钱估计**——累计按缓存命中/未命中分权折算官方牌价(仅 deepseek-official 官方路由可解,其余只显示 token 口径)。
|
|
72
|
-
|
|
73
|
-
统计经 SQLite 持久化(`~/.dsh/storages/dsh-context-compression/stats.sqlite`),跨宿主重启保留;驱动缺席或写失败时可见降级(面板标注,统计退回内存口径)。历史会话可从磁盘行为记录回填统计(宿主 sessionQuery 服务优先,缺席时只读解析会话日志,绝不写会话文件)。记录只含计数/序号/会话标识与组件枚举名,原文与自由文本绝不入库;删除该文件即可完全重置统计。
|
|
74
|
-
|
|
75
|
-
`/ccip` 命令提供面板实时控制:`rows stock|total|money on|off`(行开关)、`mode compact|full`、`session <id|latest|off>`(聚焦会话)、`flush`(强制落库)、`backfill pause|resume|status`(回填开关)。
|
|
76
|
-
|
|
77
|
-
## 安装
|
|
78
|
-
|
|
79
|
-
从源码构建并安装 —— 本 fork 亦已发布到 npm,包名为 `dsh-context-compression-improved`(单版本覆盖全部支持线:`latest` 携带 17 个 rc 的完整枚举 0.1.0-rc.2 → 0.2.1-rc.2,分线代码路径由运行时自行选择);内部包名有意保持与上游一致:
|
|
5
|
+
**0.1.0 更新:**已加入 DeepSeek V4 Flash 视觉模型的官方 tokenizer;用户可选择模型驱动 Auto Compact 的触发阈值;标准 Profile 的水位与压缩参数会随该选择联动。
|
|
80
6
|
|
|
81
7
|
```sh
|
|
82
|
-
git clone https://github.com/drscrewdriver/dsh-context-compression-improved.git
|
|
83
|
-
cd dsh-context-compression-improved
|
|
84
|
-
pnpm install --frozen-lockfile
|
|
85
|
-
pnpm build
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
随后打包 selector 包并安装到某个 Harness Profile——完整步骤(含验证与卸载)见[安装教程](docs/installation.zh.md)。
|
|
89
|
-
|
|
90
|
-
## 开发
|
|
91
|
-
|
|
92
8
|
```sh
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
pnpm verify:release
|
|
9
|
+
dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.5
|
|
10
|
+
# DSH 0.1.2 line:
|
|
11
|
+
# dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.2
|
|
12
|
+
dsh --profile web --dump-config
|
|
13
|
+
```
|
|
14
|
+
dsh --profile web --dump-config
|
|
100
15
|
```
|
|
101
16
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
- 基于官方 DeepSeek Harness 发布版构建并测试;peers 声明完整支持清单枚举(`0.1.0-rc.2` → `0.2.1-rc.2` 七条线),仅使用公开的插件与 Profile API。支持清单由 `scripts/sync-hosts.mjs` 从 `scripts/hosts.mjs` 生成到上方管理块。
|
|
107
|
-
- 需要 Node `^22.19.0 || >=24` 与 pnpm `11.7.0`。
|
|
108
|
-
- 插件只使用 Harness 公开扩展 API,不修改 Harness 核心代码。非官方社区项目,与 DeepSeek 无隶属或背书关系。
|
|
17
|
+
这一条命令安装单一的 `dsh-context-compression-improved` 包:压缩运行时、Host 设置、Web UI
|
|
18
|
+
与可逆 preset overlay 全部包含在其中。除 id 精确等于内置 `minimal` 的 preset 外,
|
|
19
|
+
其他 preset 都会获得压缩能力;非 Minimal preset 之间切换时已保存设置保持不变。
|
|
20
|
+
Minimal 只暂停插件压缩,不删除设置。
|
|
109
21
|
|
|
110
|
-
|
|
22
|
+
已验证兼容 DeepSeek Harness `dsh-v0.1.1-rc.2` 与 `dsh-v0.1.2-alpha.5`,Node `^22.19.0 || >=24`。不需要修改 Harness 核心。
|
|
111
23
|
|
|
112
|
-
|
|
113
|
-
- fork 新增内容(代码骨架门、工具链、多语文档):drscrewdriver。
|
|
114
|
-
- MIT——见 [LICENSE](LICENSE)(保留上游版权声明);内置 tokenizer 来源见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。
|
|
24
|
+
Profile、默认值、审计证据、Adaptive/cache 限制、升级/卸载与安全说明见[完整 README](https://github.com/WilliamShi666/dsh-context-compression-improved#readme)。本包与 DeepSeek 无隶属或背书关系。
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
# Third-party notices
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Portions of this package are adapted from the MIT-licensed DeepSeek Harness, verified against `dsh-v0.1.1-rc.2` (`b150a551b8d465e31e418e1b2eaf5e79bbb7d28e`).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## DeepSeek Harness MIT notice
|
|
6
6
|
|
|
7
|
-
|
|
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.
|
|
7
|
+
Copyright (c) 2026 DeepSeek
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
11
15
|
|
|
12
|
-
The
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
This package carries the official DeepSeek tokenizer assets, with their exact license and
|
|
28
|
+
provenance manifests, under `assets/`.
|
|
29
|
+
|
|
30
|
+
This package depends on `js-yaml` under MIT; its production dependency `argparse` is licensed under Python-2.0. Their NPM packages carry the dependency license texts.
|
|
31
|
+
|
|
32
|
+
This is an unofficial community package and is not endorsed by DeepSeek.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "dsh-external/dsh-context-compression-improved",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"description": "Auditable tool-result context-compression selector with code-skeleton gate for DeepSeek Harness",
|
|
6
6
|
"engines": {
|
|
7
|
-
"dsh": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5"
|
|
7
|
+
"dsh": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1"
|
|
8
8
|
},
|
|
9
9
|
"contributes": {
|
|
10
10
|
"tools": [],
|
|
@@ -24,6 +24,8 @@ declare const zh: {
|
|
|
24
24
|
'profile.savings': string;
|
|
25
25
|
'profile.adaptive': string;
|
|
26
26
|
'profile.tokenpilot-inspired': string;
|
|
27
|
+
'profile.ptc': string;
|
|
28
|
+
'detail.ptc': string;
|
|
27
29
|
'estimator.title': string;
|
|
28
30
|
'estimator.description': string;
|
|
29
31
|
'estimator.mode': string;
|
|
@@ -202,6 +204,8 @@ interface CompressionSelectorInjected {
|
|
|
202
204
|
select: (profile: CompressionProfile) => Promise<void>;
|
|
203
205
|
saveCustom: (custom: CustomCompressionPolicy) => Promise<void>;
|
|
204
206
|
resetCustom: () => Promise<void>;
|
|
207
|
+
savePtcCustom: (custom: CustomCompressionPolicy) => Promise<void>;
|
|
208
|
+
resetPtcCustom: () => Promise<void>;
|
|
205
209
|
saveAutoCompact: (thresholdPercent: number) => Promise<void>;
|
|
206
210
|
saveCodeSkeleton: (enabled: boolean) => Promise<void>;
|
|
207
211
|
saveIntentSummary: (enabled: boolean) => Promise<void>;
|
|
@@ -17,6 +17,7 @@ window.__ModuleLoader__.load({
|
|
|
17
17
|
"savings",
|
|
18
18
|
"adaptive",
|
|
19
19
|
"tokenpilot-inspired",
|
|
20
|
+
"ptc",
|
|
20
21
|
"custom"
|
|
21
22
|
];
|
|
22
23
|
/** Browser-safe mirror of the Host's Balanced-equivalent Custom default. */
|
|
@@ -46,6 +47,33 @@ window.__ModuleLoader__.load({
|
|
|
46
47
|
trigger: 7e5
|
|
47
48
|
}
|
|
48
49
|
};
|
|
50
|
+
/** Browser-safe mirror of the runtime PTC default policy (absolute, window-independent). */
|
|
51
|
+
const DEFAULT_PTC_COMPRESSION_POLICY = {
|
|
52
|
+
version: 3,
|
|
53
|
+
unit: "tokens",
|
|
54
|
+
fresh: {
|
|
55
|
+
enabled: true,
|
|
56
|
+
trigger: 4096,
|
|
57
|
+
target: 1536
|
|
58
|
+
},
|
|
59
|
+
aggregate: {
|
|
60
|
+
enabled: true,
|
|
61
|
+
trigger: 16384,
|
|
62
|
+
target: 4096
|
|
63
|
+
},
|
|
64
|
+
history: {
|
|
65
|
+
enabled: true,
|
|
66
|
+
trigger: 2e4,
|
|
67
|
+
keepRecentToolCalls: 8,
|
|
68
|
+
keepRecentTokens: 8e3,
|
|
69
|
+
minReclaim: 6e3
|
|
70
|
+
},
|
|
71
|
+
prefixPolicy: "pressure-break",
|
|
72
|
+
tailTrim: {
|
|
73
|
+
enabled: false,
|
|
74
|
+
trigger: 7e5
|
|
75
|
+
}
|
|
76
|
+
};
|
|
49
77
|
/**
|
|
50
78
|
* Decode the persisted codeSkeleton section with exactly the runtime schema's
|
|
51
79
|
* strictness: absent means the lossless off default; present values must be a
|
|
@@ -1420,16 +1448,21 @@ window.__ModuleLoader__.load({
|
|
|
1420
1448
|
function ContextCompressionSettingsSection(props) {
|
|
1421
1449
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingsCompressionProfileControls, { ...props });
|
|
1422
1450
|
}
|
|
1423
|
-
function SettingsCompressionProfileControls({ useCompression, select, saveCustom, resetCustom, saveAutoCompact, saveCodeSkeleton, saveIntentSummary, saveMonitorPanel, savePresetOptions, t }) {
|
|
1451
|
+
function SettingsCompressionProfileControls({ useCompression, select, saveCustom, resetCustom, savePtcCustom, resetPtcCustom, saveAutoCompact, saveCodeSkeleton, saveIntentSummary, saveMonitorPanel, savePresetOptions, t }) {
|
|
1424
1452
|
const state = useCompression((snapshot) => snapshot);
|
|
1425
1453
|
const [saving, setSaving] = (0, react.useState)(false);
|
|
1426
1454
|
const [saveError, setSaveError] = (0, react.useState)(null);
|
|
1427
1455
|
const [draft, setDraft] = (0, react.useState)(null);
|
|
1456
|
+
const [ptcDraft, setPtcDraft] = (0, react.useState)(null);
|
|
1428
1457
|
const current = state.value?.profile ?? "balanced";
|
|
1429
1458
|
(0, react.useEffect)(() => {
|
|
1430
1459
|
const custom = state.value?.custom;
|
|
1431
|
-
setDraft(current === "custom" && custom !== void 0 ? editableCustom(custom) : null);
|
|
1460
|
+
setDraft((current === "custom" || current === "tokenpilot-inspired") && custom !== void 0 ? editableCustom(custom) : null);
|
|
1432
1461
|
}, [current, state.value?.custom]);
|
|
1462
|
+
(0, react.useEffect)(() => {
|
|
1463
|
+
const ptcCustom = state.value?.ptcCustom;
|
|
1464
|
+
setPtcDraft(current === "ptc" && ptcCustom !== void 0 ? editableCustom(ptcCustom) : null);
|
|
1465
|
+
}, [current, state.value?.ptcCustom]);
|
|
1433
1466
|
if (state.status === "unavailable") return null;
|
|
1434
1467
|
const busy = state.status === "loading" || saving;
|
|
1435
1468
|
const selectProfile = (profile) => {
|
|
@@ -1536,7 +1569,7 @@ window.__ModuleLoader__.load({
|
|
|
1536
1569
|
className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.pricing,
|
|
1537
1570
|
children: t("pricing.disclosure")
|
|
1538
1571
|
}),
|
|
1539
|
-
current !== "custom" || draft === null || false ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomPolicyEditor, {
|
|
1572
|
+
current !== "custom" && current !== "tokenpilot-inspired" || draft === null || false ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomPolicyEditor, {
|
|
1540
1573
|
value: draft,
|
|
1541
1574
|
disabled: busy || !state.writable,
|
|
1542
1575
|
setValue: setDraft,
|
|
@@ -1545,6 +1578,15 @@ window.__ModuleLoader__.load({
|
|
|
1545
1578
|
settle,
|
|
1546
1579
|
t
|
|
1547
1580
|
}),
|
|
1581
|
+
current !== "ptc" || ptcDraft === null || false ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomPolicyEditor, {
|
|
1582
|
+
value: ptcDraft,
|
|
1583
|
+
disabled: busy || !state.writable,
|
|
1584
|
+
setValue: setPtcDraft,
|
|
1585
|
+
save: () => savePtcCustom(structuredClone(ptcDraft)),
|
|
1586
|
+
reset: resetPtcCustom,
|
|
1587
|
+
settle,
|
|
1588
|
+
t
|
|
1589
|
+
}),
|
|
1548
1590
|
saveError === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1549
1591
|
className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.error,
|
|
1550
1592
|
role: "alert",
|
|
@@ -1568,17 +1610,20 @@ window.__ModuleLoader__.load({
|
|
|
1568
1610
|
*/
|
|
1569
1611
|
function decodeSettings(value) {
|
|
1570
1612
|
if (!isPlainRecord(value)) return void 0;
|
|
1571
|
-
if (Object.keys(value).some((key) => key !== "profile" && key !== "custom" && key !== "autoCompact" && key !== "codeSkeleton" && key !== "intentSummary" && key !== "monitorPanel" && key !== "presetOptions")) return;
|
|
1613
|
+
if (Object.keys(value).some((key) => key !== "profile" && key !== "custom" && key !== "ptcCustom" && key !== "autoCompact" && key !== "codeSkeleton" && key !== "intentSummary" && key !== "monitorPanel" && key !== "presetOptions")) return;
|
|
1572
1614
|
const profile = value.profile;
|
|
1573
1615
|
const custom = value.custom;
|
|
1616
|
+
const ptcCustomRaw = value.ptcCustom;
|
|
1617
|
+
const ptcCustom = ptcCustomRaw === void 0 ? DEFAULT_PTC_COMPRESSION_POLICY : isCustomCompressionPolicy(ptcCustomRaw) ? canonicalizeCustomPolicy(ptcCustomRaw) : void 0;
|
|
1574
1618
|
const autoCompact = decodeAutoCompactSettings(value.autoCompact);
|
|
1575
1619
|
const codeSkeleton = decodeCodeSkeletonSettings(value.codeSkeleton);
|
|
1576
1620
|
const intentSummary = decodeIntentSummarySettings(value.intentSummary);
|
|
1577
1621
|
const monitorPanel = decodeMonitorPanelSettings(value.monitorPanel);
|
|
1578
1622
|
const presetOptions = decodePresetOptionsSettings(value.presetOptions);
|
|
1579
|
-
return typeof profile === "string" && COMPRESSION_PROFILES.includes(profile) && isCustomCompressionPolicy(custom) && autoCompact !== void 0 && codeSkeleton !== void 0 && intentSummary !== void 0 && monitorPanel !== void 0 ? {
|
|
1623
|
+
return typeof profile === "string" && COMPRESSION_PROFILES.includes(profile) && isCustomCompressionPolicy(custom) && ptcCustom !== void 0 && autoCompact !== void 0 && codeSkeleton !== void 0 && intentSummary !== void 0 && monitorPanel !== void 0 ? {
|
|
1580
1624
|
profile,
|
|
1581
1625
|
custom: canonicalizeCustomPolicy(custom),
|
|
1626
|
+
ptcCustom,
|
|
1582
1627
|
autoCompact,
|
|
1583
1628
|
codeSkeleton,
|
|
1584
1629
|
intentSummary,
|
|
@@ -1996,6 +2041,8 @@ window.__ModuleLoader__.load({
|
|
|
1996
2041
|
"profile.savings": "节省模式",
|
|
1997
2042
|
"profile.adaptive": "Adaptive(保守成本)",
|
|
1998
2043
|
"profile.tokenpilot-inspired": "TokenPilot 启发模式",
|
|
2044
|
+
"profile.ptc": "PTC 模式(绝对水位)",
|
|
2045
|
+
"detail.ptc": "为代码模式与大量小结果会话提供与窗口无关的绝对水位;存量越过阈值即触发历史老化,阈值可在设置中独立编辑",
|
|
1999
2046
|
"estimator.title": "估计器(可选)",
|
|
2000
2047
|
"estimator.description": "辅助小模型零样本判断旧文件读取是否仍有引用价值,仅建议性加速历史清理;未配置或失败时自动退回纯规则通道,不影响主流程。",
|
|
2001
2048
|
"estimator.mode": "通道",
|
|
@@ -2151,6 +2198,8 @@ window.__ModuleLoader__.load({
|
|
|
2151
2198
|
"profile.savings": "Savings",
|
|
2152
2199
|
"profile.adaptive": "Adaptive (conservative cost)",
|
|
2153
2200
|
"profile.tokenpilot-inspired": "TokenPilot-inspired",
|
|
2201
|
+
"profile.ptc": "PTC / Code-mode (absolute)",
|
|
2202
|
+
"detail.ptc": "Window-independent absolute watermarks for code-mode and many-small-result sessions; history aging starts once live results cross the threshold, and the thresholds stay independently editable",
|
|
2154
2203
|
"estimator.title": "Estimator (optional)",
|
|
2155
2204
|
"estimator.description": "A small auxiliary model zero-shots whether old file reads are still likely referenced, advisory-only for history aging; unconfigured or failing endpoints fall back to rule-only behavior.",
|
|
2156
2205
|
"estimator.mode": "Channel",
|
|
@@ -2308,6 +2357,8 @@ window.__ModuleLoader__.load({
|
|
|
2308
2357
|
"profile.savings": "Sparen",
|
|
2309
2358
|
"profile.adaptive": "Adaptiv (kostenbewusst)",
|
|
2310
2359
|
"profile.tokenpilot-inspired": "TokenPilot-inspiriert",
|
|
2360
|
+
"profile.ptc": "PTC / Codemodus (absolut)",
|
|
2361
|
+
"detail.ptc": "Fensterunabhängige absolute Wasserstände für den Codemodus und Sitzungen mit vielen kleinen Ergebnissen; die Historienalterung startet, sobald der Umfang die Schwelle überschreitet, Schwellen separat editierbar",
|
|
2311
2362
|
"estimator.title": "Schätzer (optional)",
|
|
2312
2363
|
"estimator.description": "Ein kleines Hilfsmodell schätzt ohne Beispiele, ob alte Datei-Lesevorgänge wahrscheinlich noch referenziert werden; nur beratend für das Altern des Verlaufs. Ohne Konfiguration oder bei Fehlern greift reines Regelverhalten.",
|
|
2313
2364
|
"estimator.mode": "Kanal",
|
|
@@ -2465,6 +2516,8 @@ window.__ModuleLoader__.load({
|
|
|
2465
2516
|
"profile.savings": "Ahorro",
|
|
2466
2517
|
"profile.adaptive": "Adaptativo (costo conservador)",
|
|
2467
2518
|
"profile.tokenpilot-inspired": "Inspirado en TokenPilot",
|
|
2519
|
+
"profile.ptc": "PTC / modo código (absoluto)",
|
|
2520
|
+
"detail.ptc": "Marcas de agua absolutas independientes de la ventana para el modo código y sesiones con muchos resultados pequeños; el envejecimiento del historial se activa al superar el umbral, umbrales editables por separado",
|
|
2468
2521
|
"estimator.title": "Estimador (opcional)",
|
|
2469
2522
|
"estimator.description": "Un pequeño modelo auxiliar estima sin ejemplos si las lecturas antiguas de archivos probablemente aún se referencian; solo consultivo para el envejecimiento del historial. Sin configuración o ante fallos, se vuelve al comportamiento basado solo en reglas.",
|
|
2470
2523
|
"estimator.mode": "Canal",
|
|
@@ -2622,6 +2675,8 @@ window.__ModuleLoader__.load({
|
|
|
2622
2675
|
"profile.savings": "Économies",
|
|
2623
2676
|
"profile.adaptive": "Adaptatif (coût prudent)",
|
|
2624
2677
|
"profile.tokenpilot-inspired": "Inspiré de TokenPilot",
|
|
2678
|
+
"profile.ptc": "PTC / mode code (absolu)",
|
|
2679
|
+
"detail.ptc": "Repères absolus indépendants de la fenêtre pour le mode code et les sessions à nombreux petits résultats ; l’ancienneté de l’historique démarre dès que le volume dépasse le seuil, seuils modifiables séparément",
|
|
2625
2680
|
"estimator.title": "Estimateur (optionnel)",
|
|
2626
2681
|
"estimator.description": "Un petit modèle auxiliaire estime sans exemples si les anciennes lectures de fichiers ont encore des chances d’être référencées ; indicatif seulement, pour le vieillissement de l’historique. Sans configuration ou en cas d’échec, retour aux règles seules.",
|
|
2627
2682
|
"estimator.mode": "Canal",
|
|
@@ -2779,6 +2834,8 @@ window.__ModuleLoader__.load({
|
|
|
2779
2834
|
"profile.savings": "Risparmio",
|
|
2780
2835
|
"profile.adaptive": "Adattivo (costo prudente)",
|
|
2781
2836
|
"profile.tokenpilot-inspired": "Ispirato a TokenPilot",
|
|
2837
|
+
"profile.ptc": "PTC / modalità codice (assoluto)",
|
|
2838
|
+
"detail.ptc": "Soglie assolute indipendenti dalla finestra per la modalità codice e sessioni con molti risultati piccoli; l’invecchiamento della cronologia parte al superamento della soglia, soglie modificabili separatamente",
|
|
2782
2839
|
"estimator.title": "Stimatore (opzionale)",
|
|
2783
2840
|
"estimator.description": "Un piccolo modello ausiliario stima senza esempi se le vecchie letture di file sono probabilmente ancora referenziate; solo consultivo per l’invecchiamento della cronologia. Senza configurazione o in caso di errore si ripiega sul solo comportamento a regole.",
|
|
2784
2841
|
"estimator.mode": "Canale",
|
|
@@ -2936,6 +2993,8 @@ window.__ModuleLoader__.load({
|
|
|
2936
2993
|
"profile.savings": "節約",
|
|
2937
2994
|
"profile.adaptive": "Adaptive(コスト重視)",
|
|
2938
2995
|
"profile.tokenpilot-inspired": "TokenPilot モード",
|
|
2996
|
+
"profile.ptc": "PTC / コードモード(絶対)",
|
|
2997
|
+
"detail.ptc": "コードモードや小さな結果が多いセッション向けの、ウィンドウ非依存の絶対水位。履歴の圧縮は存量がしきい値を超えると開始し、しきい値は個別に編集可能",
|
|
2939
2998
|
"estimator.title": "エスティメーター(任意)",
|
|
2940
2999
|
"estimator.description": "小規模な補助モデルが、古いファイル読み取りにまだ参照価値があるかをゼロショットで判定します。履歴エージングの補助 only で、未設定や障害時は自動的にルールのみの経路へ戻り、本流には影響しません。",
|
|
2941
3000
|
"estimator.mode": "チャネル",
|
|
@@ -3093,6 +3152,8 @@ window.__ModuleLoader__.load({
|
|
|
3093
3152
|
"profile.savings": "절약",
|
|
3094
3153
|
"profile.adaptive": "Adaptive(보수적 비용)",
|
|
3095
3154
|
"profile.tokenpilot-inspired": "TokenPilot 모드",
|
|
3155
|
+
"profile.ptc": "PTC / 코드 모드(절대)",
|
|
3156
|
+
"detail.ptc": "코드 모드와 작은 결과가 많은 세션을 위한 창 독립적 절대 워터마크. 실시간 결과가 임계값을 넘으면 기록 정리가 시작되며, 임계값은 개별 편집 가능",
|
|
3096
3157
|
"estimator.title": "추정기(선택 사항)",
|
|
3097
3158
|
"estimator.description": "소형 보조 모델이 오래된 파일 읽기에 아직 참조 가치가 있는지 제로샷으로 판단합니다. 이력 에이징을 돕는 자문 전용 채널이며, 미설정 또는 실패 시 자동으로 규칙 전용 경로로 되돌아가므로 본 흐름에 영향을 주지 않습니다.",
|
|
3098
3159
|
"estimator.mode": "채널",
|
|
@@ -3250,6 +3311,8 @@ window.__ModuleLoader__.load({
|
|
|
3250
3311
|
"profile.savings": "Экономия",
|
|
3251
3312
|
"profile.adaptive": "Адаптивный (консервативная цена)",
|
|
3252
3313
|
"profile.tokenpilot-inspired": "По мотивам TokenPilot",
|
|
3314
|
+
"profile.ptc": "PTC / режим кода (абсолютный)",
|
|
3315
|
+
"detail.ptc": "Абсолютные независящие от окна пороги для режима кода и сессий с множеством мелких результатов; старение истории начинается при превышении порога, пороги можно менять отдельно",
|
|
3253
3316
|
"estimator.title": "Оценщик (опционально)",
|
|
3254
3317
|
"estimator.description": "Небольшая вспомогательная модель без примеров оценивает, вероятно ли старое чтение файла всё ещё востребовано; только рекомендация для старения истории. Без настройки или при сбое — режим только правил.",
|
|
3255
3318
|
"estimator.mode": "Канал",
|
|
@@ -3778,6 +3841,8 @@ window.__ModuleLoader__.load({
|
|
|
3778
3841
|
select: (profile) => writeAndConfirm(() => scope.set("profile", profile), (settings) => settings.profile === profile),
|
|
3779
3842
|
saveCustom: (custom) => writeAndConfirm(() => scope.set("custom", custom), (settings) => isCustomCompressionPolicy(settings.custom) && sameCustomPolicy(settings.custom, custom)),
|
|
3780
3843
|
resetCustom: () => writeAndConfirm(() => scope.set("custom", structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY)), (settings) => isCustomCompressionPolicy(settings.custom) && sameCustomPolicy(settings.custom, DEFAULT_CUSTOM_COMPRESSION_POLICY)),
|
|
3844
|
+
savePtcCustom: (custom) => writeAndConfirm(() => scope.set("ptcCustom", custom), (settings) => isCustomCompressionPolicy(settings.ptcCustom) && sameCustomPolicy(settings.ptcCustom, custom)),
|
|
3845
|
+
resetPtcCustom: () => writeAndConfirm(() => scope.set("ptcCustom", structuredClone(DEFAULT_PTC_COMPRESSION_POLICY)), (settings) => isCustomCompressionPolicy(settings.ptcCustom) && sameCustomPolicy(settings.ptcCustom, DEFAULT_PTC_COMPRESSION_POLICY)),
|
|
3781
3846
|
saveAutoCompact: (thresholdPercent) => writeAndConfirm(() => scope.set("autoCompact", { thresholdPercent }), (settings) => settings.autoCompact.thresholdPercent === thresholdPercent),
|
|
3782
3847
|
saveCodeSkeleton: (enabled) => writeAndConfirm(() => scope.set("codeSkeleton", { enabled }), (settings) => settings.codeSkeleton.enabled === enabled),
|
|
3783
3848
|
saveIntentSummary: (enabled) => writeAndConfirm(() => scope.set("intentSummary", { enabled }), (settings) => settings.intentSummary.enabled === enabled),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as sessionEvents } from "./tool-result.js";
|
|
2
2
|
import { a as validatePublishedTailTrim } from "./tail-trim.js";
|
|
3
3
|
//#region src/invariant.ts
|
|
4
4
|
const PACKAGE_NAME = "dsh-context-compression-improved-runtime";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/profiles.d.ts
|
|
2
2
|
/** Public context-compression choices shared by the Host schema and browser selector. */
|
|
3
|
-
declare const COMPRESSION_PROFILES: readonly ["off", "native", "balanced", "cache-strict", "savings", "adaptive", "tokenpilot-inspired", "custom"];
|
|
3
|
+
declare const COMPRESSION_PROFILES: readonly ["off", "native", "balanced", "cache-strict", "savings", "adaptive", "tokenpilot-inspired", "ptc", "custom"];
|
|
4
4
|
/** One supported context-compression profile. */
|
|
5
5
|
type CompressionProfile = typeof COMPRESSION_PROFILES[number];
|
|
6
6
|
/** Single canonical unit stored by a version-1 browser Custom document. */
|
|
@@ -105,6 +105,8 @@ interface ContextCompressionSettings {
|
|
|
105
105
|
profile: CompressionProfile;
|
|
106
106
|
/** Complete canonical policy captured with `profile` when the runtime first observes a Session. */
|
|
107
107
|
custom: CustomCompressionPolicy;
|
|
108
|
+
/** PTC profile's own editable policy, seeded from the ptc defaults; independent of `custom`. Optional like `monitorPanel`/`presetOptions`: schema-defaulted, always present after parse. */
|
|
109
|
+
ptcCustom?: CustomCompressionPolicy;
|
|
108
110
|
/** Auto Compact trigger captured with `profile` when the runtime first observes a Session. */
|
|
109
111
|
autoCompact: AutoCompactSettings;
|
|
110
112
|
/** Code-skeleton reducer gate captured independently of `profile`. */
|
|
@@ -28,7 +28,7 @@ declare class DedupeTable {
|
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/runtime/types.d.ts
|
|
30
30
|
/** User-facing mixed strategy profile. */
|
|
31
|
-
declare const COMPRESSION_PROFILES: readonly ["off", "native", "balanced", "cache-strict", "savings", "adaptive", "tokenpilot-inspired", "custom"];
|
|
31
|
+
declare const COMPRESSION_PROFILES: readonly ["off", "native", "balanced", "cache-strict", "savings", "adaptive", "tokenpilot-inspired", "ptc", "custom"];
|
|
32
32
|
/** Public compression strategy selected for one Session. */
|
|
33
33
|
type CompressionProfile = typeof COMPRESSION_PROFILES[number];
|
|
34
34
|
/** When historical tool results may be aged for one Session policy. */
|
|
@@ -182,6 +182,8 @@ interface ContextCompressionSettings {
|
|
|
182
182
|
profile: CompressionProfile;
|
|
183
183
|
/** Versioned Custom policy snapped with `profile` for a newly observed Session. */
|
|
184
184
|
custom: CustomCompressionPolicy;
|
|
185
|
+
/** PTC profile's own editable policy, seeded from the ptc defaults and independent of `custom`. Optional like `monitorPanel`/`presetOptions`: schema-defaulted, always present after parse. */
|
|
186
|
+
ptcCustom?: CustomCompressionPolicy;
|
|
185
187
|
/** Auto Compact trigger preference snapped with `profile` for a newly observed Session. */
|
|
186
188
|
autoCompact: AutoCompactSettings;
|
|
187
189
|
/** Code-skeleton reducer gate snapped independently of `profile`. */
|
|
@@ -691,7 +693,7 @@ declare function resolveConfig(config?: ToolResultPruneConfig): ResolvedConfig;
|
|
|
691
693
|
* to resolve context-percent Custom values and standard-profile linkage.
|
|
692
694
|
* @returns the effective deterministic compression policy.
|
|
693
695
|
*/
|
|
694
|
-
declare function resolvePolicy(config: ResolvedConfig, profile: CompressionProfile, custom?: CustomCompressionPolicy, options?: CustomPolicyResolutionOptions): CompressionPolicy;
|
|
696
|
+
declare function resolvePolicy(config: ResolvedConfig, profile: CompressionProfile, custom?: CustomCompressionPolicy, options?: CustomPolicyResolutionOptions, ptcCustom?: CustomCompressionPolicy): CompressionPolicy;
|
|
695
697
|
//#endregion
|
|
696
698
|
//#region src/runtime/reducers.d.ts
|
|
697
699
|
/** Deterministic, evidence-backed reducers for fresh tool results. */
|