dsh-context-compression-improved 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +2 -1
- package/.githooks/pre-push +37 -0
- package/.github/workflows/ci.yml +8 -8
- package/CHANGELOG.ja.md +169 -39
- package/CHANGELOG.ko.md +167 -39
- package/CHANGELOG.md +212 -16
- package/CHANGELOG.zh.md +152 -39
- package/CONTRIBUTING.md +22 -22
- package/README.ja.md +85 -104
- package/README.ko.md +85 -103
- package/README.md +1 -19
- package/README.zh.md +85 -101
- package/THIRD_PARTY_NOTICES.md +14 -14
- package/docs/compat-0.1.5-report.md +77 -0
- package/docs/installation.ja.md +78 -76
- package/docs/installation.ko.md +78 -76
- package/docs/installation.md +103 -76
- package/docs/installation.zh.md +100 -76
- package/docs/repair-log.md +657 -582
- package/eslint.config.js +30 -30
- package/package.json +75 -54
- package/packages/selector/README.md +7 -12
- package/packages/selector/README.zh.md +6 -13
- package/packages/selector/THIRD_PARTY_NOTICES.md +32 -38
- package/packages/selector/cordis.patch.yml +27 -19
- package/packages/selector/dsh.plugin.json +16 -16
- package/packages/selector/lib/client.d.ts +97 -5
- package/packages/selector/lib/client.js +1884 -92
- package/packages/selector/lib/config.js +863 -6
- package/packages/selector/lib/index.d.ts +29 -21
- package/packages/selector/lib/index.js +424 -18
- package/packages/selector/lib/invariant.js +4 -4
- package/packages/selector/lib/pruner.d.ts +179 -4
- package/packages/selector/lib/pruner.js +1406 -371
- package/packages/selector/lib/style.css +42 -0
- package/packages/selector/lib/tail-trim.js +13 -4
- package/packages/selector/package.json +18 -27
- package/packages/selector/screenshots.json +3 -6
- package/packages/selector/src/client/CompressionProfileControls.tsx +293 -229
- package/packages/selector/src/client/CompressionProfileSelector.module.css +199 -170
- package/packages/selector/src/client/CompressionProfileSelector.tsx +85 -79
- package/packages/selector/src/client/EstimatorControls.tsx +277 -281
- package/packages/selector/src/client/decode.ts +57 -49
- package/packages/selector/src/client/index.ts +200 -62
- package/packages/selector/src/client/locales/de.ts +141 -0
- package/packages/selector/src/client/locales/es.ts +141 -0
- package/packages/selector/src/client/locales/fr.ts +141 -0
- package/packages/selector/src/client/locales/it.ts +141 -0
- package/packages/selector/src/client/locales/ja.ts +141 -0
- package/packages/selector/src/client/locales/ko.ts +141 -0
- package/packages/selector/src/client/locales/ru.ts +141 -0
- package/packages/selector/src/client/locales.ts +282 -198
- package/packages/selector/src/client/monitor-fab.ts +336 -0
- package/packages/selector/src/client/preset-options.ts +88 -70
- package/packages/selector/src/client/savings-card.tsx +150 -0
- package/packages/selector/src/client/settings-section.tsx +140 -126
- package/packages/selector/src/deepseek-v4-tokenizer.ts +205 -210
- package/packages/selector/src/index.ts +671 -327
- package/packages/selector/src/invariant.ts +113 -113
- package/packages/selector/src/profiles.ts +431 -342
- package/packages/selector/src/pruner/state.ts +57 -43
- package/packages/selector/src/pruner.ts +2736 -2154
- package/packages/selector/src/runtime/audit.ts +303 -231
- package/packages/selector/src/runtime/config.ts +756 -642
- package/packages/selector/src/runtime/measurement.ts +436 -432
- package/packages/selector/src/runtime/monitor.ts +235 -0
- package/packages/selector/src/runtime/retrieve.ts +479 -457
- package/packages/selector/src/runtime/savings.ts +337 -0
- package/packages/selector/src/runtime/session-events.ts +30 -17
- package/packages/selector/src/runtime/summary-command.ts +127 -0
- package/packages/selector/src/runtime/tail-trim.ts +166 -166
- package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +233 -0
- package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +204 -0
- package/packages/selector/src/runtime/tokenpilot/advisor.ts +419 -0
- package/packages/selector/src/runtime/tokenpilot/benefit.ts +200 -0
- package/packages/selector/src/runtime/tokenpilot/estimator.ts +151 -183
- package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +53 -0
- package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +65 -0
- package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +125 -0
- package/packages/selector/src/runtime/tokenpilot/intent-range.ts +37 -0
- package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +303 -275
- package/packages/selector/src/runtime/types.ts +365 -325
- package/packages/selector/tests/advisor-report.host.spec.ts +223 -0
- package/packages/selector/tests/auto-compact.client.spec.tsx +214 -226
- package/packages/selector/tests/built/client-artifact.spec.ts +59 -51
- package/packages/selector/tests/code-skeleton.client.spec.ts +91 -88
- package/packages/selector/tests/custom-contract.client.spec.ts +205 -202
- package/packages/selector/tests/estimator-channel.client.spec.tsx +253 -247
- package/packages/selector/tests/estimator-route-registration.host.spec.ts +194 -176
- package/packages/selector/tests/host-preset-overlay.host.spec.ts +206 -204
- package/packages/selector/tests/monitor-fab.client.spec.ts +138 -0
- package/packages/selector/tests/preset-options-write.client.spec.ts +207 -181
- package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +201 -196
- package/packages/selector/tests/preset-overlay.host.spec.ts +8 -18
- package/packages/selector/tests/profiles.client.spec.tsx +436 -434
- package/packages/selector/tests/public/package-contract.client.spec.ts +78 -33
- package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +232 -0
- package/packages/selector/tests/runtime/advisor-invariant.spec.ts +272 -0
- package/packages/selector/tests/runtime/advisor.spec.ts +226 -0
- package/packages/selector/tests/runtime/audit.spec.ts +275 -172
- package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +96 -0
- package/packages/selector/tests/runtime/intent-gate.spec.ts +62 -0
- package/packages/selector/tests/runtime/intent-summary.spec.ts +156 -0
- package/packages/selector/tests/runtime/monitor.spec.ts +301 -0
- package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2724 -2702
- package/packages/selector/tests/runtime/savings.spec.ts +120 -0
- package/packages/selector/tests/runtime/session-events.spec.ts +27 -27
- package/packages/selector/tests/runtime/summary-command.spec.ts +154 -0
- package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +217 -0
- package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +79 -56
- package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +116 -100
- package/packages/selector/tests/settings-seat.client.spec.ts +130 -0
- package/packages/selector/tests/standing-generation.host.spec.ts +142 -87
- package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +253 -250
- package/pnpm-workspace.yaml +66 -19
- package/scripts/capture-profile-baseline.mjs +42 -0
- package/scripts/generate-tokenizer-fixtures.py +81 -81
- package/scripts/generate-vision-fixtures.py +208 -208
- package/scripts/{packed-components-smoke.ts → packed-components-smoke.mjs} +732 -713
- package/scripts/{packed-install-e2e.ts → packed-install-e2e.mjs} +1273 -1072
- package/scripts/toolclass-corpus-replay.mjs +281 -273
- package/scripts/{verify-release.ts → verify-release.mjs} +318 -300
- package/tests/TEST_INVENTORY.md +41 -42
- package/scripts/capture-profile-baseline.ts +0 -80
- package/tsconfig.scripts.json +0 -13
- /package/{packages/selector/assets/screenshots → docs/assets}/context-compression-selector-profiles.jpg +0 -0
- /package/{packages/selector/assets/screenshots → docs/assets}/context-compression-selector-settings.png +0 -0
|
@@ -1,49 +1,57 @@
|
|
|
1
|
-
/** Browser-safe settings decoding shared by the client entry and node tests. */
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
canonicalizeCustomPolicy,
|
|
5
|
-
COMPRESSION_PROFILES,
|
|
6
|
-
decodeAutoCompactSettings,
|
|
7
|
-
decodeCodeSkeletonSettings,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
/** Browser-safe settings decoding shared by the client entry and node tests. */
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
canonicalizeCustomPolicy,
|
|
5
|
+
COMPRESSION_PROFILES,
|
|
6
|
+
decodeAutoCompactSettings,
|
|
7
|
+
decodeCodeSkeletonSettings,
|
|
8
|
+
decodeIntentSummarySettings,
|
|
9
|
+
decodeMonitorPanelSettings,
|
|
10
|
+
decodePresetOptionsSettings,
|
|
11
|
+
isCustomCompressionPolicy,
|
|
12
|
+
isPlainRecord,
|
|
13
|
+
type CompressionProfile,
|
|
14
|
+
type ContextCompressionSettings,
|
|
15
|
+
} from '../profiles.ts'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Decode one stored context-compression settings document with exactly the
|
|
19
|
+
* runtime schema's strictness: a plain object with only `profile`, `custom`,
|
|
20
|
+
* `autoCompact`, `codeSkeleton`, and `intentSummary` keys, a supported profile, a valid Custom
|
|
21
|
+
* document canonicalized to v3 exactly as the runtime resolver would, a
|
|
22
|
+
* strictly-shaped autoCompact section (absent inherits the 80% default), and
|
|
23
|
+
* a strictly-shaped codeSkeleton gate (absent inherits off). Anything else
|
|
24
|
+
* decodes to `undefined` so the UI reports the document as unreadable instead
|
|
25
|
+
* of silently disagreeing with the runtime.
|
|
26
|
+
*/
|
|
27
|
+
export function decodeSettings(value: unknown): ContextCompressionSettings | undefined {
|
|
28
|
+
if (!isPlainRecord(value)) return undefined
|
|
29
|
+
const keys = Object.keys(value)
|
|
30
|
+
if (keys.some(key => key !== 'profile' && key !== 'custom' && key !== 'autoCompact' && key !== 'codeSkeleton' && key !== 'intentSummary' && key !== 'monitorPanel' && key !== 'presetOptions')) {
|
|
31
|
+
return undefined
|
|
32
|
+
}
|
|
33
|
+
const profile = (value as { profile?: unknown }).profile
|
|
34
|
+
const custom = (value as { custom?: unknown }).custom
|
|
35
|
+
const autoCompact = decodeAutoCompactSettings((value as { autoCompact?: unknown }).autoCompact)
|
|
36
|
+
const codeSkeleton = decodeCodeSkeletonSettings((value as { codeSkeleton?: unknown }).codeSkeleton)
|
|
37
|
+
const intentSummary = decodeIntentSummarySettings((value as { intentSummary?: unknown }).intentSummary)
|
|
38
|
+
const monitorPanel = decodeMonitorPanelSettings((value as { monitorPanel?: unknown }).monitorPanel)
|
|
39
|
+
const presetOptions = decodePresetOptionsSettings((value as { presetOptions?: unknown }).presetOptions)
|
|
40
|
+
return typeof profile === 'string'
|
|
41
|
+
&& (COMPRESSION_PROFILES as readonly string[]).includes(profile)
|
|
42
|
+
&& isCustomCompressionPolicy(custom)
|
|
43
|
+
&& autoCompact !== undefined
|
|
44
|
+
&& codeSkeleton !== undefined
|
|
45
|
+
&& intentSummary !== undefined
|
|
46
|
+
&& monitorPanel !== undefined
|
|
47
|
+
? {
|
|
48
|
+
profile: profile as CompressionProfile,
|
|
49
|
+
custom: canonicalizeCustomPolicy(custom),
|
|
50
|
+
autoCompact,
|
|
51
|
+
codeSkeleton,
|
|
52
|
+
intentSummary,
|
|
53
|
+
...monitorPanel === undefined ? {} : { monitorPanel },
|
|
54
|
+
...presetOptions === undefined ? {} : { presetOptions },
|
|
55
|
+
}
|
|
56
|
+
: undefined
|
|
57
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type {} from '@deepseek-ai/dsh-client-locale/client'
|
|
2
|
-
import type { ClientContext } from '@deepseek-ai/
|
|
2
|
+
import type { Context as ClientContext } from '@deepseek-ai/cordis'
|
|
3
|
+
import type {} from '@deepseek-ai/dsh-client-ui-session/client'
|
|
3
4
|
import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
4
5
|
import type {} from '@deepseek-ai/dsh-client-ui-workspace/client'
|
|
5
6
|
import {
|
|
@@ -9,9 +10,42 @@ import {
|
|
|
9
10
|
} from './CompressionProfileSelector.tsx'
|
|
10
11
|
import { DEFAULT_CUSTOM_COMPRESSION_POLICY } from '../profiles.ts'
|
|
11
12
|
import { decodeSettings } from './decode.ts'
|
|
13
|
+
import { initMonitorFab } from './monitor-fab.ts'
|
|
12
14
|
import { en, zh } from './locales.ts'
|
|
13
|
-
import {
|
|
15
|
+
import { de } from './locales/de.ts'
|
|
16
|
+
import { es } from './locales/es.ts'
|
|
17
|
+
import { fr } from './locales/fr.ts'
|
|
18
|
+
import { it } from './locales/it.ts'
|
|
19
|
+
import { ja } from './locales/ja.ts'
|
|
20
|
+
import { ko } from './locales/ko.ts'
|
|
21
|
+
import { ru } from './locales/ru.ts'
|
|
22
|
+
import { planPresetOptionsOps, presetOptionsOpsAccepted } from './preset-options.ts'
|
|
14
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Harness 0.1.5 mounts the web core's `slots` service on the client context
|
|
26
|
+
* but no longer ships a public type for it; declare the face this plugin
|
|
27
|
+
* consumes (same shape dsh-thinking-levels and dsh-prime-memory rely on).
|
|
28
|
+
* `inject` factories may be sync (return a disposer) or generator (yield the
|
|
29
|
+
* registration); slot options are validated at runtime per slot kind, which
|
|
30
|
+
* lets one entry supply both `id` (Desktop, list) and `key` (CLI, keyed).
|
|
31
|
+
*/
|
|
32
|
+
interface SlotsService {
|
|
33
|
+
inject(slot: string, register: () => (() => void) | Generator<() => void>): () => void
|
|
34
|
+
register(options: Record<string, unknown>, component: unknown): () => void
|
|
35
|
+
}
|
|
36
|
+
declare module '@deepseek-ai/cordis' {
|
|
37
|
+
interface Context {
|
|
38
|
+
slots: SlotsService
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Declare all consumed services (the official client-plugin pattern, and the
|
|
43
|
+
// shape dsh-thinking-levels proves on this same 0.1.5 host line): cordis holds
|
|
44
|
+
// apply until `locale` / `settingsScope` are provided, so registration can use
|
|
45
|
+
// them directly. Resolving them lazily via ctx.get() instead races the settings
|
|
46
|
+
// client's activation — on a loss the apply early-returned and EVERY settings
|
|
47
|
+
// entry (the standalone section, the plugins-tab card, the item card) silently
|
|
48
|
+
// vanished.
|
|
15
49
|
export const inject = ['slots', 'locale', 'settingsScope']
|
|
16
50
|
const NS = 'context-compression'
|
|
17
51
|
|
|
@@ -40,69 +74,173 @@ function sameCustomPolicy(
|
|
|
40
74
|
}
|
|
41
75
|
|
|
42
76
|
export function apply(ctx: ClientContext): void {
|
|
43
|
-
ctx.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
77
|
+
ctx.locale.register(NS, { zh, en })
|
|
78
|
+
// de/es/fr/it/ja/ko/ru are not host built-ins (`BuiltInLocaleId` is zh|en), so
|
|
79
|
+
// their dictionaries ride the single-locale untyped register overload, and each
|
|
80
|
+
// needs an `addLanguage` definition to become selectable. Labels are
|
|
81
|
+
// self-described in their own language; the fallback chain ends at English.
|
|
82
|
+
// One occupied locale must not sink activation, hence the per-language guard.
|
|
83
|
+
const languages = [
|
|
84
|
+
{ id: 'de', label: 'Deutsch', dict: de },
|
|
85
|
+
{ id: 'es', label: 'Español', dict: es },
|
|
86
|
+
{ id: 'fr', label: 'Français', dict: fr },
|
|
87
|
+
{ id: 'it', label: 'Italiano', dict: it },
|
|
88
|
+
{ id: 'ja', label: '日本語', dict: ja },
|
|
89
|
+
{ id: 'ko', label: '한국어', dict: ko },
|
|
90
|
+
{ id: 'ru', label: 'Русский', dict: ru },
|
|
91
|
+
] as const
|
|
92
|
+
for (const language of languages) {
|
|
93
|
+
try {
|
|
94
|
+
ctx.locale.register(NS, language.id, language.dict)
|
|
95
|
+
ctx.locale.addLanguage({ id: language.id, label: language.label, fallback: 'en' })
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.warn(`[dsh-context-compression-improved] locale "${language.id}" registration failed:`, error)
|
|
59
98
|
}
|
|
60
99
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
92
|
-
return
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
)
|
|
100
|
+
// Section label translator, captured EAGERLY: the settings shell evaluates
|
|
101
|
+
// `label()` during its own render; a lazy ctx.locale accessor inside the
|
|
102
|
+
// thunk would throw there if `locale` ever left this module's inject list
|
|
103
|
+
// (the search-index 0.5.3 family-tab incident). bind() returns a live
|
|
104
|
+
// binder, so locale switches are still followed.
|
|
105
|
+
const localeSvc = ctx.locale as { bind?: (n: string) => (key: string) => string } | undefined
|
|
106
|
+
const tNav = localeSvc?.bind?.(NS) ?? ((key: string) => key)
|
|
107
|
+
|
|
108
|
+
// 浮动监控面板(FAB): body 级幂等单例。enabled 读取走设置文档——0.1.2 宿主没有
|
|
109
|
+
// configForms 的 volatile settings,沿用 settingsScope.bind 的共享镜像快照;
|
|
110
|
+
// bind 一次挂在 apply 的插件纤维上,FAB 轮询只读快照、不重复绑定。
|
|
111
|
+
const fabScope = ctx.settingsScope.bind<ContextCompressionSettings>({ namespace: NS, decode: decodeSettings })
|
|
112
|
+
const readMonitorPanelEnabled = (): boolean => {
|
|
113
|
+
try {
|
|
114
|
+
const snap = fabScope.getSnapshot()
|
|
115
|
+
return snap.status === 'ready' ? (snap.value?.monitorPanel?.enabled ?? false) : false
|
|
116
|
+
} catch {
|
|
117
|
+
return false
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// 浮动面板会话绑定:跟随输入栏座位的 inject 回调(裸 sessionId,pm longtask 同款)。
|
|
121
|
+
let latestSessionId: string | undefined
|
|
122
|
+
try {
|
|
123
|
+
initMonitorFab({
|
|
124
|
+
t: tNav,
|
|
125
|
+
sessionIdOf: () => latestSessionId,
|
|
126
|
+
enabledOf: () => readMonitorPanelEnabled(),
|
|
127
|
+
fetchSnapshot: async (sessionId) => {
|
|
128
|
+
const query = sessionId === undefined ? '' : `?sessionId=${encodeURIComponent(sessionId)}`
|
|
129
|
+
const response = await fetch(`/api/dsh-context-compression-improved/monitor${query}`, { headers: { 'cache-control': 'no-cache' } })
|
|
130
|
+
if (!response.ok) throw new Error(`monitor snapshot ${response.status}`)
|
|
131
|
+
return await response.json() as Parameters<typeof initMonitorFab>[0]['fetchSnapshot'] extends (...args: never[]) => Promise<infer T> ? T : never
|
|
132
|
+
},
|
|
133
|
+
applyOverride: async (sessionId, action) => {
|
|
134
|
+
const query = sessionId === undefined ? '' : `?sessionId=${encodeURIComponent(sessionId)}`
|
|
135
|
+
await fetch(`/api/dsh-context-compression-improved/monitor${query}`, {
|
|
136
|
+
method: 'POST',
|
|
137
|
+
headers: { 'content-type': 'application/json' },
|
|
138
|
+
body: JSON.stringify({ action }),
|
|
139
|
+
})
|
|
96
140
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
141
|
+
})
|
|
142
|
+
} catch (error) {
|
|
143
|
+
console.warn('[dsh-context-compression-improved] 监控浮动球挂载失败(不影响设置分节):', error)
|
|
144
|
+
}
|
|
145
|
+
const injected = (): CompressionSelectorInjected => {
|
|
146
|
+
// Bind per factory call on the caller's fiber (0.1.5: activation must
|
|
147
|
+
// never block on the settings transport; the scope disposer belongs to
|
|
148
|
+
// the calling registration's lifecycle).
|
|
149
|
+
const scope = ctx.settingsScope.bind<ContextCompressionSettings>({ namespace: NS, decode: decodeSettings })
|
|
150
|
+
const writeAndConfirm = async (
|
|
151
|
+
write: () => Promise<void>,
|
|
152
|
+
accepts: (settings: ContextCompressionSettings) => boolean,
|
|
153
|
+
): Promise<void> => {
|
|
154
|
+
const beforeRevision = scope.getSnapshot().revision
|
|
155
|
+
await write()
|
|
156
|
+
const after = scope.getSnapshot()
|
|
157
|
+
if (
|
|
158
|
+
after.status !== 'ready'
|
|
159
|
+
|| after.value === undefined
|
|
160
|
+
|| after.revision === beforeRevision
|
|
161
|
+
|| !accepts(after.value)
|
|
162
|
+
) {
|
|
163
|
+
throw new Error('Context compression settings were not saved.')
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
hooks: { compression: scope },
|
|
168
|
+
select: profile => writeAndConfirm(
|
|
169
|
+
() => scope.set('profile', profile),
|
|
170
|
+
settings => settings.profile === profile,
|
|
171
|
+
),
|
|
172
|
+
saveCustom: custom => writeAndConfirm(
|
|
173
|
+
() => scope.set('custom', custom),
|
|
174
|
+
settings => isCustomCompressionPolicy(settings.custom)
|
|
175
|
+
&& sameCustomPolicy(settings.custom, custom),
|
|
176
|
+
),
|
|
177
|
+
resetCustom: () => writeAndConfirm(
|
|
178
|
+
() => scope.set('custom', structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY)),
|
|
179
|
+
settings => isCustomCompressionPolicy(settings.custom)
|
|
180
|
+
&& sameCustomPolicy(settings.custom, DEFAULT_CUSTOM_COMPRESSION_POLICY),
|
|
181
|
+
),
|
|
182
|
+
saveAutoCompact: thresholdPercent => writeAndConfirm(
|
|
183
|
+
() => scope.set('autoCompact', { thresholdPercent }),
|
|
184
|
+
settings => settings.autoCompact.thresholdPercent === thresholdPercent,
|
|
185
|
+
),
|
|
186
|
+
saveCodeSkeleton: enabled => writeAndConfirm(
|
|
187
|
+
() => scope.set('codeSkeleton', { enabled }),
|
|
188
|
+
settings => settings.codeSkeleton.enabled === enabled,
|
|
189
|
+
),
|
|
190
|
+
saveIntentSummary: enabled => writeAndConfirm(
|
|
191
|
+
() => scope.set('intentSummary', { enabled }),
|
|
192
|
+
settings => settings.intentSummary.enabled === enabled,
|
|
193
|
+
),
|
|
194
|
+
saveMonitorPanel: enabled => writeAndConfirm(
|
|
195
|
+
() => scope.set('monitorPanel', { enabled }),
|
|
196
|
+
settings => settings.monitorPanel?.enabled === enabled,
|
|
197
|
+
),
|
|
198
|
+
savePresetOptions: options => {
|
|
199
|
+
// Path-addressed so one field write cannot delete its siblings: the
|
|
200
|
+
// previous whole-section set erased estimatorMode (and every other
|
|
201
|
+
// override) whenever the user touched a second field.
|
|
202
|
+
const ops = planPresetOptionsOps(scope.getSnapshot().value?.presetOptions, options)
|
|
203
|
+
if (ops.length === 0) return Promise.resolve()
|
|
204
|
+
return writeAndConfirm(
|
|
205
|
+
() => scope.mutate(ops),
|
|
206
|
+
settings => presetOptionsOpsAccepted(settings.presetOptions, ops),
|
|
207
|
+
)
|
|
208
|
+
},
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// 设置 → 上下文压缩 直挂分节(0.1.1 契约;0.1.5 官方分节也注册在此,未声明槽
|
|
212
|
+
// 的注册会在激活期抛错,故 try/catch 守卫 —— 同 dsh-prime-memory 的双槽冗余)。
|
|
213
|
+
// 只挂这一处:再注册 `settings.plugins.tab` / `settings.plugin.item` 会在
|
|
214
|
+
// 设置里同时出现独立分节和插件卡片,重复展示同一张面板。
|
|
215
|
+
try {
|
|
216
|
+
ctx.slots.inject('settings.section', () => ctx.slots.register({
|
|
217
|
+
name: 'settings.section',
|
|
218
|
+
id: 'context-compression',
|
|
219
|
+
order: 17,
|
|
220
|
+
label: () => ctx.locale.bind(NS)('nav'),
|
|
221
|
+
locale: NS,
|
|
222
|
+
inject: injected,
|
|
223
|
+
}, ContextCompressionSettingsSection))
|
|
224
|
+
} catch (error) {
|
|
225
|
+
console.warn('[dsh-context-compression-improved] settings.section 注册失败(新宿主已收编):', error)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// 输入栏左座(0.1.5+ 宿主):组件刻意空渲染——注册此座位只为接收宿主的
|
|
229
|
+
// sessionId 注入回调,供浮动监控面板绑定会话(pm longtask 同款)。旧宿主
|
|
230
|
+
// 未声明该槽时激活期会抛错,try/catch 守卫(同上双槽冗余先例)。
|
|
231
|
+
try {
|
|
232
|
+
ctx.slots.inject('conversation.input.left', () => ctx.slots.register({
|
|
233
|
+
name: 'conversation.input.left',
|
|
234
|
+
id: 'context-compression-session-bind',
|
|
235
|
+
order: 170,
|
|
236
|
+
inject: (sessionId: string) => {
|
|
237
|
+
latestSessionId = sessionId
|
|
238
|
+
return {}
|
|
239
|
+
},
|
|
240
|
+
}, () => null))
|
|
241
|
+
} catch (error) {
|
|
242
|
+
console.warn('[dsh-context-compression-improved] conversation.input.left 注册失败(旧宿主无该槽,浮动面板保持聚合口径):', error)
|
|
243
|
+
}
|
|
106
244
|
}
|
|
107
245
|
|
|
108
246
|
export type {
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { ContextCompressionLocaleKey } from '../locales.ts'
|
|
2
|
+
|
|
3
|
+
/** German copy matching every simplified Chinese selector key. */
|
|
4
|
+
export const de = {
|
|
5
|
+
'nav': 'Kontextkomprimierung wählen',
|
|
6
|
+
'settings.title': 'Kontextkomprimierung wählen',
|
|
7
|
+
'settings.description': 'Wählen Sie ein Komprimierungsprofil für die aktuelle Sitzung und konfigurieren Sie dessen Parameter.',
|
|
8
|
+
'label': 'Kontextkomprimierung',
|
|
9
|
+
'status.loading': 'Wird geladen',
|
|
10
|
+
'status.unavailable': 'Nicht verfügbar',
|
|
11
|
+
'status.presetUnavailable': 'Das Preset dieser Sitzung bietet keine Kontextkomprimierung, oder die Verfügbarkeit ist noch nicht bestätigt.',
|
|
12
|
+
'status.minimalUnavailable': 'Der Minimalmodus lädt für diese Sitzung keine Kontextkomprimierung. Die Auswahl ist aus und das native Harness-Verhalten gilt. Wechseln Sie zu Standard, PTC / Coding, Kreativ oder zu einem kompatiblen eigenen Preset, um sie zu konfigurieren.',
|
|
13
|
+
'status.saveFailed': 'Speichern fehlgeschlagen. Bitte erneut versuchen.',
|
|
14
|
+
'pricing.disclosure': 'Offizielle DeepSeek-Preise, geprüft am 2026-08-25. Spitzenzeiten Mo–Fr 09:00–12:00 und 14:00–18:00 (Asia/Shanghai), sonst Nebenzeiten. Anfragen über eine Grenze hinweg verwenden eine Kostenspanne.',
|
|
15
|
+
'profile.balanced': 'Ausbalanciert',
|
|
16
|
+
'profile.cache-strict': 'Cache Strict (Präfixschutz)',
|
|
17
|
+
'profile.savings': 'Sparen',
|
|
18
|
+
'profile.adaptive': 'Adaptiv (kostenbewusst)',
|
|
19
|
+
'profile.tokenpilot-inspired': 'TokenPilot-inspiriert',
|
|
20
|
+
'estimator.title': 'Schätzer (optional)',
|
|
21
|
+
'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.',
|
|
22
|
+
'estimator.mode': 'Kanal',
|
|
23
|
+
'estimator.mode.off': 'Aus (nur Regeln)',
|
|
24
|
+
'estimator.mode.host': 'Host-Modell (nutzt konfigurierte Anbieter)',
|
|
25
|
+
'estimator.mode.direct': 'Direkter OpenAI-kompatibler Endpunkt',
|
|
26
|
+
'estimator.inactive': 'Der Schätzer gehört nur zum Profil „TokenPilot-inspiriert“: dessen Preset-Optionen (Deduplizierungszeiger, Zusammenfassungsanker, Lesestatus-Semantik und der Schätzer-Kanal) werden nie in ein anderes Profil übernommen, daher hat das aktuelle Profil „{profile}“ keinen Schätzer-Kanal. Wählen Sie „TokenPilot-inspiriert“, dann erhält dieser Bereich eine Kanalwahl — konfigurierte Anbieter nutzen (Host-Modell) oder ein direkter OpenAI-kompatibler Endpunkt.',
|
|
27
|
+
'estimator.provider': 'Anbieter',
|
|
28
|
+
'estimator.provider.placeholder': 'Leer folgt dem Standardmodell der Sitzung; aus der Liste wählen oder eigene ID eingeben',
|
|
29
|
+
'estimator.model.placeholder': 'Leer folgt dem Standardmodell der Sitzung; aus der Liste wählen oder eigene ID eingeben',
|
|
30
|
+
'estimator.hostReuse': 'Der Host-Kanal nutzt die in DSH bereits konfigurierten Anbieter und Zugangsdaten — kein API-Schlüssel nötig, und hier wird keiner akzeptiert.',
|
|
31
|
+
'estimator.hostRoute': 'Aktuelle Route: {route}.',
|
|
32
|
+
'estimator.hostUnresolved': 'noch unbestimmt (wählen Sie ein Standardmodell in den DSH-Einstellungen oder geben Sie hier Anbieter und Modell an)',
|
|
33
|
+
'estimator.baseUrl': 'Basis-URL des Endpunkts (/v1)',
|
|
34
|
+
'estimator.model': 'Modell',
|
|
35
|
+
'estimator.apiKey': 'API-Schlüssel (nur schreiben, nie angezeigt)',
|
|
36
|
+
'estimator.apiKey.placeholder': 'Endpunkt-Schlüssel eingeben; Speichern beim Verlassen des Felds',
|
|
37
|
+
'estimator.apiKey.set': 'Gesetzt · neuen Wert eingeben, um ihn zu überschreiben',
|
|
38
|
+
'estimator.apiKey.clear': 'Löschen',
|
|
39
|
+
'estimator.apiKey.overwrite': 'Ein Geheimnis ist gespeichert; neuen Wert eingeben und das Feld verlassen, um ihn zu überschreiben.',
|
|
40
|
+
'detail.tokenpilot-inspired': 'Auf Ausbalanciert aufsetzend: Deduplizierungszeiger, Wiederherstellungs-Freistellung, Zusammenfassungsanker, Präfixstabilisierung und Lesestatus-Semantik; der Schätzer braucht einen separat konfigurierten Endpunkt',
|
|
41
|
+
'profile.custom': 'Eigene / Experimentell',
|
|
42
|
+
'profile.native': 'Native Referenz',
|
|
43
|
+
'profile.off': 'Plugin aus',
|
|
44
|
+
'profile.current': 'Aktuelles Profil',
|
|
45
|
+
'detail.balanced': 'Reduziert frische Tool-Ergebnisse deterministisch; altert alte Ergebnisse bei hohem Füllstand',
|
|
46
|
+
'detail.cache-strict': 'Altert den gesendeten Verlauf nur bei bestätigter Kapazitätslast; Anbieter-Cache-Treffer bleiben Best-Effort',
|
|
47
|
+
'detail.savings': 'Nutzt kleinere Ziele und altert alte Tool-Ergebnisse früher; günstigere Anfragen sind nicht garantiert',
|
|
48
|
+
'detail.adaptive': 'Nutzt Fresh/Aggregate von Ausbalanciert; altert den Verlauf nur, wenn benachbarte offizielle Nutzung und aktuelle offizielle Preise eine klare Ersparnis belegen',
|
|
49
|
+
'detail.custom': 'Wählen Sie umgesetzte Stufen und gemessene Schwellenwerte für neue Sitzungen',
|
|
50
|
+
'detail.native': 'Nutzt nur die native Kopf-/Schwanz-Kürzung von Harness',
|
|
51
|
+
'detail.off': 'Deaktiviert die deterministische Auswahl; natives Auto-Compact bleibt separat konfiguriert',
|
|
52
|
+
'autoCompact.title': 'Auto-Compact-Auslöseschwelle',
|
|
53
|
+
'autoCompact.description': 'Das modellgetriebene Auto Compact löst aus, sobald die Anfrage-Auslastung diese Schwelle überschreitet. History-Auslöser des Standardprofils, Mindest-Freigabe und das neue Ende folgen der Schwelle; Änderungen wirken nur auf neue Sitzungen.',
|
|
54
|
+
'autoCompact.inputLabel': 'Auto-Compact-Schwelle (%)',
|
|
55
|
+
'autoCompact.sliderLabel': 'Schieberegler für die Auto-Compact-Schwelle',
|
|
56
|
+
'autoCompact.quick': 'Schnellwerte',
|
|
57
|
+
'autoCompact.riskLow': 'Unter dem empfohlenen Bereich: früheres Auslösen erhöht Zusammenfassungsaufrufe und Präfix-Neuaufbauten.',
|
|
58
|
+
'autoCompact.riskHigh': 'Über dem empfohlenen Bereich: die Kontextkapazität teilen sich Anfragen und Ausgabe, späteres Auslösen verkleinert den Spielraum für einzelne große Ausgaben, Reasoning und Tool-Schemata.',
|
|
59
|
+
'autoCompact.invalid': 'Die Auto-Compact-Schwelle muss eine ganze Zahl zwischen 50 und 90 sein.',
|
|
60
|
+
'autoCompact.save': 'Auto-Compact-Schwelle speichern',
|
|
61
|
+
'autoCompact.summaryHint': 'Auto-Compact-Schwelle: {percent} %. In den Einstellungen änderbar.',
|
|
62
|
+
'codeSkeleton.title': 'Code-Skelettkomprimierung (opt-in)',
|
|
63
|
+
'codeSkeleton.description': 'Unabhängiger Schalter, losgelöst von den Profilen oben. Aktiviert versucht ein überdimensioniertes frisches Quellcode-Tool-Ergebnis zuerst ein Skelett, das Imports und Deklarationen hält (Rümpfe ausgelassen, Fehlerzeilen behalten), und fällt bei Scheitern auf die ursprüngliche Kopf-Kürzung zurück. Erfordert den exakten Tokenizer; wirkt nur auf neue Sitzungen.',
|
|
64
|
+
'codeSkeleton.enabled': 'Code-Skelettkomprimierung',
|
|
65
|
+
'codeSkeleton.enabled.on': 'Ein',
|
|
66
|
+
'codeSkeleton.enabled.off': 'Aus (Standard)',
|
|
67
|
+
'intentSummary.title': 'Abschluss-Zusammenfassung (Turn-Tail)',
|
|
68
|
+
'intentSummary.description': 'Aktiviert faltet der Turn-Abschluss den verbrauchten Zuwachs nach semantischen Rollen zu Intent-Zusammenfassungsblöcken: Lese-Tool-Ergebnisse werden zu Einzeilern mit Ziel/Umfang, die Schreibklasse behält Skelettköpfe plus wörtliche Fehlerzeilen; die Landung erfolgt in der nächsten Druckrunde über die gewöhnliche Falt-Pipeline. Zündet nur, wenn die Wachstumsschwelle passiert ist (live Oberfläche >45 % und >50K Token seit der letzten Faltung). Gilt für neue Sitzungen; die aktuelle lässt sich mit /ctx-summary off|on|status übersteuern.',
|
|
69
|
+
'intentSummary.enabled': 'Abschluss-Zusammenfassung',
|
|
70
|
+
'intentSummary.enabled.on': 'Ein',
|
|
71
|
+
'intentSummary.enabled.off': 'Aus (Standard)',
|
|
72
|
+
'monitor.fab.title': 'Komprimierungs-Monitor',
|
|
73
|
+
'monitor.panel.title': 'Komprimierungs-Monitor',
|
|
74
|
+
'monitor.panel.net': 'Nettoeinsparung',
|
|
75
|
+
'monitor.panel.gross': 'Bruttoeinsparung',
|
|
76
|
+
'monitor.panel.offsets': 'Ausgleiche',
|
|
77
|
+
'monitor.panel.context': 'Kontextbelegung',
|
|
78
|
+
'monitor.panel.suggest': 'Kontextbelegung bei {pct}% — nahe der katastrophalen Vergessenszone; Komprimieren oder Kürzen des Verlaufs empfohlen',
|
|
79
|
+
'monitor.panel.cacheHit': 'Cache-Trefferquote',
|
|
80
|
+
'monitor.panel.cost': 'Kosten (ist / gespart gesch.)',
|
|
81
|
+
'monitor.panel.intent': 'Intent-Zusammenfassung',
|
|
82
|
+
'monitor.panel.overrideHint': 'Sitzungs-Übersteuerung',
|
|
83
|
+
'monitor.panel.resume': 'Fortsetzen',
|
|
84
|
+
'monitor.panel.disable': 'Deaktivieren',
|
|
85
|
+
'monitor.panel.stateOn': 'ein',
|
|
86
|
+
'monitor.panel.stateOff': 'aus',
|
|
87
|
+
'monitor.panel.gateUnknown': 'noch nicht bewertet',
|
|
88
|
+
'monitor.panel.lastFold': 'Letzte Faltung',
|
|
89
|
+
'monitor.panel.stale': 'Snapshot nicht erreichbar — letzte Daten',
|
|
90
|
+
'monitorPanel.title': 'Komprimierungs-Monitorpanel',
|
|
91
|
+
'monitorPanel.description': 'Aktiviert erscheint neben dem Eingabebereich eine ziehbare Schwebekugel — öffne sie, um den Live-Komprimierungszustand zu beobachten: Nettoeinsparung (exakte Basis), Cache-Trefferquote, Kostenschätzung, das Turn-Tail-Gate und letzte Ausgleiche. Das Panel kann den Intent-Zusammenfassungsschalter der aktuellen Sitzung temporär übersteuern. Das Konto ist prozesslokal (Reset bei Host-Neustart).',
|
|
92
|
+
'monitorPanel.enabled': 'Monitorpanel',
|
|
93
|
+
'monitorPanel.enabled.on': 'Ein',
|
|
94
|
+
'monitorPanel.enabled.off': 'Aus (Standard)',
|
|
95
|
+
'custom.title': 'Eigene Strategie',
|
|
96
|
+
'custom.settingsHint': 'Detaillierte Parameter unter Einstellungen > Kontextkomprimierung wählen bearbeiten.',
|
|
97
|
+
'custom.sessionScope': 'Gespeicherte Änderungen greifen, wenn die aktuelle Compression-Runtime eine Sitzung zum ersten Mal beobachtet. Eine von dieser Runtime bereits beobachtete Sitzung behält ihre eingefrorene Strategie.',
|
|
98
|
+
'custom.measurement': 'Zuerst der exakte DeepSeek-Tokenizer; sonst Tokenizer-Schätzung mit Kalibrierung als Rückfallebene. Nie chars/4. Die Cache-Zuordnung bleibt unbekannt.',
|
|
99
|
+
'custom.unit': 'Kanonische Einheit',
|
|
100
|
+
'custom.unit.tokens': 'Token',
|
|
101
|
+
'custom.unit.contextPercent': 'Kontextprozent',
|
|
102
|
+
'custom.enabled': 'Aktiviert',
|
|
103
|
+
'custom.enabled.on': 'Ein',
|
|
104
|
+
'custom.enabled.off': 'Aus',
|
|
105
|
+
'custom.fresh.enabled': 'Fresh aktivieren',
|
|
106
|
+
'custom.fresh.trigger': 'Fresh-Auslöser',
|
|
107
|
+
'custom.fresh.target': 'Fresh-Ziel',
|
|
108
|
+
'custom.aggregate.enabled': 'Aggregate aktivieren',
|
|
109
|
+
'custom.aggregate.trigger': 'Aggregate-Auslöser',
|
|
110
|
+
'custom.aggregate.target': 'Aggregate-Ziel',
|
|
111
|
+
'custom.history.enabled': 'History aktivieren',
|
|
112
|
+
'custom.history.trigger': 'History-Auslöser',
|
|
113
|
+
'custom.history.keepRecentToolCalls': 'Geschützte letzte Tool-Aufrufe',
|
|
114
|
+
'custom.history.keepRecentTokens': 'Geschütztes neues Ende der Tool-Ergebnisse',
|
|
115
|
+
'custom.history.minReclaim': 'Mindest-Freigabe',
|
|
116
|
+
'custom.prefixPolicy': 'Richtlinie für gesendete Präfixe',
|
|
117
|
+
'custom.prefixPolicy.preserve': 'Bewahren bis Kapazitätsdruck',
|
|
118
|
+
'custom.prefixPolicy.pressureBreak': 'Reguläres Verlaufsaltern erlauben',
|
|
119
|
+
'custom.experimental': 'Experimentell: diese Regler gehören nur zum eigenen Profil und kommen nie in Standardprofile.',
|
|
120
|
+
'custom.tailTrim.enabled': 'TailTrim aktivieren (experimentell)',
|
|
121
|
+
'custom.tailTrim.trigger': 'TailTrim-Auslöser',
|
|
122
|
+
'custom.tailTrim.warning': 'TailTrim erfordert den exakten Tokenizer und ersetzt höchstens eine vollständige, abgeschlossene, fehlerfreie Gruppe nur aus Tools durch eine wiederherstellbare Referenz. Es teilt sich mit History die geschützten letzten Tool-Aufrufe, das geschützte neue Ende der Tool-Ergebnisse und die Mindest-Freigabe. Es schreibt ein gesendetes Präfix um und kann Cache-Treffer verringern.',
|
|
123
|
+
'custom.save': 'Eigene Strategie speichern',
|
|
124
|
+
'custom.reset': 'Eigene Strategie zurücksetzen',
|
|
125
|
+
'custom.invalid': 'Werte der eigenen Strategie sind ungültig.',
|
|
126
|
+
'savings.title': 'Einsparungen (dieser Prozess)',
|
|
127
|
+
'savings.netExact': 'Netto gespeichert (exakte Basis)',
|
|
128
|
+
'savings.netEstimated': 'Netto gespeichert (geschätzte Basis)',
|
|
129
|
+
'savings.gross': 'Brutto gespeichert (bei Veröffentlichung)',
|
|
130
|
+
'savings.offsets': 'Abschläge (komprimiert, später vollständig gelesen)',
|
|
131
|
+
'savings.empty': 'Noch keine Komprimierung — Nettoeinsparungen erscheinen nach der ersten Reduktion.',
|
|
132
|
+
'savings.basisExact': 'exakt',
|
|
133
|
+
'savings.basisEstimated': 'geschätzt',
|
|
134
|
+
'savings.basisNote': 'Basen werden getrennt ausgewiesen, nie gemischt: exakt = DeepSeek-Tokenizer; geschätzt = chars/4. Erst Skelett, dann Volltext zählt als negative Einsparung (Netto kann unter null fallen).',
|
|
135
|
+
'savings.requests': 'Requests',
|
|
136
|
+
'savings.cacheHit': 'Cache hit rate',
|
|
137
|
+
'savings.actualCost': 'Actual cost (official prices)',
|
|
138
|
+
'savings.savedMoney': 'Estimated saved cost (input price)',
|
|
139
|
+
'savings.perSession': 'Session',
|
|
140
|
+
|
|
141
|
+
} satisfies Record<ContextCompressionLocaleKey, string>
|