dsh-context-compression-improved 0.7.0-beta.1 → 0.7.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/.github/workflows/ci.yml +39 -39
  2. package/CHANGELOG.ja.md +217 -220
  3. package/CHANGELOG.ko.md +211 -214
  4. package/CHANGELOG.md +392 -376
  5. package/CHANGELOG.zh.md +196 -199
  6. package/README.md +97 -97
  7. package/README.zh.md +86 -86
  8. package/package.json +18 -17
  9. package/packages/selector/dsh.plugin.json +1 -1
  10. package/packages/selector/lib/client.js +733 -0
  11. package/packages/selector/lib/style.css +46 -46
  12. package/packages/selector/src/client/decode.ts +53 -53
  13. package/packages/selector/src/client/index.ts +30 -0
  14. package/packages/selector/src/client/locales/de.ts +98 -0
  15. package/packages/selector/src/client/locales/es.ts +98 -0
  16. package/packages/selector/src/client/locales/fr.ts +98 -0
  17. package/packages/selector/src/client/locales/it.ts +98 -0
  18. package/packages/selector/src/client/locales/ja.ts +98 -0
  19. package/packages/selector/src/client/locales/ko.ts +98 -0
  20. package/packages/selector/src/client/locales/ru.ts +98 -0
  21. package/packages/selector/src/deepseek-v4-tokenizer.ts +205 -205
  22. package/packages/selector/src/preset-overlay.ts +629 -629
  23. package/packages/selector/src/profiles.ts +414 -414
  24. package/packages/selector/src/pruner/content.ts +198 -198
  25. package/packages/selector/src/pruner/state.ts +57 -57
  26. package/packages/selector/src/pruner.ts +2665 -2665
  27. package/packages/selector/src/runtime/audit.ts +303 -303
  28. package/packages/selector/src/runtime/config.ts +731 -731
  29. package/packages/selector/src/runtime/reducers.ts +1674 -1674
  30. package/packages/selector/src/runtime/summary-command.ts +133 -133
  31. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +233 -233
  32. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +204 -204
  33. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +53 -53
  34. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +65 -65
  35. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +125 -125
  36. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +37 -37
  37. package/packages/selector/src/runtime/tokenpilot/locator.ts +128 -128
  38. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +306 -306
  39. package/packages/selector/src/runtime/types.ts +358 -358
  40. package/packages/selector/tests/built/client-artifact.spec.ts +61 -61
  41. package/packages/selector/tests/helpers/legacy-settings/index.ts +15 -15
  42. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.d.ts +41 -41
  43. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.js +647 -647
  44. package/packages/selector/tests/helpers/legacy-settings/legacy/redact.js +78 -78
  45. package/packages/selector/tests/helpers/legacy-settings/legacy/util-values.js +234 -234
  46. package/packages/selector/tests/host-preset-overlay.host.spec.ts +203 -203
  47. package/packages/selector/tests/runtime/auto-compact-config.spec.ts +523 -523
  48. package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +122 -122
  49. package/packages/selector/tests/runtime/intent-gate.spec.ts +62 -62
  50. package/packages/selector/tests/runtime/intent-summary.spec.ts +156 -156
  51. package/packages/selector/tests/runtime/summary-command.spec.ts +154 -154
  52. package/scripts/packed-components-smoke.mjs +734 -734
  53. package/tests/TEST_INVENTORY.md +41 -41
  54. package/tsconfig.tests.json +17 -17
  55. package/vitest.config.ts +57 -57
@@ -1,61 +1,61 @@
1
- import { readFileSync } from 'node:fs'
2
- import { resolve } from 'node:path'
3
- import * as React from 'react'
4
- import * as jsxRuntime from 'react/jsx-runtime'
5
- import { describe, expect, it } from 'vitest'
6
-
7
- const artifact = resolve(import.meta.dirname, '../../lib/client.js')
8
-
9
- describe('built Harness client artifact', () => {
10
- it('registers a self-contained lazy-CJS factory and injects its CSS', () => {
11
- const code = readFileSync(artifact, 'utf8')
12
- let registration: { id: string, factory: (require: (id: string) => unknown) => unknown } | undefined
13
- const moduleLoader = {
14
- load(value: typeof registration) {
15
- registration = value
16
- },
17
- }
18
- Object.defineProperty(window, '__ModuleLoader__', { configurable: true, value: moduleLoader })
19
-
20
- // The smoke evaluates the built IIFE bundle the same way a browser page would.
21
- // eslint-disable-next-line @typescript-eslint/no-implied-eval
22
- expect(() => Function(code)()).not.toThrow()
23
- expect(registration?.id).toBe('dsh-context-compression-improved')
24
-
25
- const modules = new Map<string, unknown>([
26
- ['react', React],
27
- ['react/jsx-runtime', jsxRuntime],
28
- // The current selector only keeps this official package as a side-effect
29
- // external. A minimal public-module stub proves the artifact asks the
30
- // Harness loader for it without importing the package's raw CSS in Node.
31
- ['@deepseek-ai/dsh-client-ui-primitives', {}],
32
- ])
33
- const exported = registration?.factory((id) => {
34
- if (!modules.has(id)) throw new Error(`unexpected client dependency: ${id}`)
35
- return modules.get(id)
36
- }) as { apply?: unknown, inject?: unknown }
37
-
38
- expect(exported.apply).toBeTypeOf('function')
39
- // Declare every consumed service: cordis holds apply until each one is
40
- // provided, which is the official client-plugin pattern on this 0.1.5 host
41
- // line (dsh-thinking-levels does the same). The earlier lazy alternative —
42
- // resolving `locale` / `settingsScope` through ctx.get() inside apply —
43
- // raced the settings client's activation; on a loss the apply
44
- // early-returned and EVERY settings entry (the standalone section, the
45
- // plugins-tab card, the item card) silently vanished. See the rationale
46
- // recorded in src/client/index.ts.
47
- expect(exported.inject).toEqual(['slots', 'locale', 'settingsScope'])
48
- const style = document.querySelector<HTMLStyleElement>(
49
- 'style[data-plugin-css="dsh-context-compression-improved/CompressionProfileSelector.module.css"]',
50
- )
51
- expect(style?.dataset.plugin).toBe('dsh-context-compression-improved')
52
- expect(style?.textContent).toContain('profileGrid')
53
- expect(document.querySelectorAll('style[data-plugin-css]').length).toBe(1)
54
-
55
- registration?.factory((id) => modules.get(id))
56
- expect(document.querySelectorAll('style[data-plugin-css]').length).toBe(1)
57
- expect(code).not.toMatch(/^\s*(?:import|export)\s/mu)
58
- expect(code).not.toMatch(/(?:\/home\/|[A-Za-z]:\\Users\\)/u)
59
- expect(code).not.toContain('sourceMappingURL')
60
- })
61
- })
1
+ import { readFileSync } from 'node:fs'
2
+ import { resolve } from 'node:path'
3
+ import * as React from 'react'
4
+ import * as jsxRuntime from 'react/jsx-runtime'
5
+ import { describe, expect, it } from 'vitest'
6
+
7
+ const artifact = resolve(import.meta.dirname, '../../lib/client.js')
8
+
9
+ describe('built Harness client artifact', () => {
10
+ it('registers a self-contained lazy-CJS factory and injects its CSS', () => {
11
+ const code = readFileSync(artifact, 'utf8')
12
+ let registration: { id: string, factory: (require: (id: string) => unknown) => unknown } | undefined
13
+ const moduleLoader = {
14
+ load(value: typeof registration) {
15
+ registration = value
16
+ },
17
+ }
18
+ Object.defineProperty(window, '__ModuleLoader__', { configurable: true, value: moduleLoader })
19
+
20
+ // The smoke evaluates the built IIFE bundle the same way a browser page would.
21
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval
22
+ expect(() => Function(code)()).not.toThrow()
23
+ expect(registration?.id).toBe('dsh-context-compression-improved')
24
+
25
+ const modules = new Map<string, unknown>([
26
+ ['react', React],
27
+ ['react/jsx-runtime', jsxRuntime],
28
+ // The current selector only keeps this official package as a side-effect
29
+ // external. A minimal public-module stub proves the artifact asks the
30
+ // Harness loader for it without importing the package's raw CSS in Node.
31
+ ['@deepseek-ai/dsh-client-ui-primitives', {}],
32
+ ])
33
+ const exported = registration?.factory((id) => {
34
+ if (!modules.has(id)) throw new Error(`unexpected client dependency: ${id}`)
35
+ return modules.get(id)
36
+ }) as { apply?: unknown, inject?: unknown }
37
+
38
+ expect(exported.apply).toBeTypeOf('function')
39
+ // Declare every consumed service: cordis holds apply until each one is
40
+ // provided, which is the official client-plugin pattern on this 0.1.5 host
41
+ // line (dsh-thinking-levels does the same). The earlier lazy alternative —
42
+ // resolving `locale` / `settingsScope` through ctx.get() inside apply —
43
+ // raced the settings client's activation; on a loss the apply
44
+ // early-returned and EVERY settings entry (the standalone section, the
45
+ // plugins-tab card, the item card) silently vanished. See the rationale
46
+ // recorded in src/client/index.ts.
47
+ expect(exported.inject).toEqual(['slots', 'locale', 'settingsScope'])
48
+ const style = document.querySelector<HTMLStyleElement>(
49
+ 'style[data-plugin-css="dsh-context-compression-improved/CompressionProfileSelector.module.css"]',
50
+ )
51
+ expect(style?.dataset.plugin).toBe('dsh-context-compression-improved')
52
+ expect(style?.textContent).toContain('profileGrid')
53
+ expect(document.querySelectorAll('style[data-plugin-css]').length).toBe(1)
54
+
55
+ registration?.factory((id) => modules.get(id))
56
+ expect(document.querySelectorAll('style[data-plugin-css]').length).toBe(1)
57
+ expect(code).not.toMatch(/^\s*(?:import|export)\s/mu)
58
+ expect(code).not.toMatch(/(?:\/home\/|[A-Za-z]:\\Users\\)/u)
59
+ expect(code).not.toContain('sourceMappingURL')
60
+ })
61
+ })
@@ -1,15 +1,15 @@
1
- /**
2
- * Legacy test-host settings seam.
3
- *
4
- * Vendored verbatim from `@deepseek-ai/dsh-settings@0.1.5-rc.2`
5
- * (`lib/types/index.js` + `lib/types/redact.js`, with the
6
- * `@deepseek-ai/dsh-util-values@0.1.5-rc.2` helpers inlined as
7
- * `./legacy/util-values.js`): the 0.1.7 host replaced the
8
- * namespace-registry provider with declarative `SettingsForms`, while the
9
- * plugin keeps the legacy `ctx.settings.get(ns)` read as a host-shape
10
- * fallback (see src/index.ts). The host specs mount a provider subclassing
11
- * this base to exercise exactly that fallback against the real 0.1.7
12
- * baseline. Type declarations: `./legacy/provider.d.ts`.
13
- */
14
- export { SettingsProvider as LegacySettingsProvider } from './legacy/provider.js'
15
-
1
+ /**
2
+ * Legacy test-host settings seam.
3
+ *
4
+ * Vendored verbatim from `@deepseek-ai/dsh-settings@0.1.5-rc.2`
5
+ * (`lib/types/index.js` + `lib/types/redact.js`, with the
6
+ * `@deepseek-ai/dsh-util-values@0.1.5-rc.2` helpers inlined as
7
+ * `./legacy/util-values.js`): the 0.1.7 host replaced the
8
+ * namespace-registry provider with declarative `SettingsForms`, while the
9
+ * plugin keeps the legacy `ctx.settings.get(ns)` read as a host-shape
10
+ * fallback (see src/index.ts). The host specs mount a provider subclassing
11
+ * this base to exercise exactly that fallback against the real 0.1.7
12
+ * baseline. Type declarations: `./legacy/provider.d.ts`.
13
+ */
14
+ export { SettingsProvider as LegacySettingsProvider } from './legacy/provider.js'
15
+
@@ -1,41 +1,41 @@
1
- /**
2
- * Narrow type surface for the vendored 0.1.5 `SettingsProvider` (legacy test-host seam).
3
- *
4
- * The 0.1.7 `@deepseek-ai/dsh-settings` host replaced the namespace-registry
5
- * provider with the declarative `SettingsForms` projector, but the plugin
6
- * deliberately keeps the legacy `ctx.settings.get(ns)` read as a fallback
7
- * "so a host that still serves the old service shape keeps working (test
8
- * hosts do exactly that)" (src/index.ts). The host specs drive that fallback
9
- * through this vendored base class — the verbatim 0.1.5-rc.2 implementation,
10
- * not a behavioral re-implementation.
11
- *
12
- * Only the members the specs and the production fallback actually touch are
13
- * declared; the full 0.1.5 surface exists at runtime in provider.js.
14
- */
15
- import { Service } from '@deepseek-ai/cordis'
16
-
17
- export declare abstract class SettingsProvider extends Service {
18
- /** Register as the `settings` service of `ctx` (implementation: `super(ctx, 'settings')`). */
19
- constructor(ctx: Context)
20
- /** Whether {@linkcode LegacySettingsProvider.update} may persist through this provider. */
21
- abstract readonly writable: boolean
22
- /** Load the provider's raw document (namespace → raw section) once at init. */
23
- protected abstract load(): Promise<Record<string, unknown>>
24
- /** Durably store one namespace's merged user section. */
25
- protected abstract persist(ns: string, section: Record<string, unknown>): Promise<void>
26
- /** Register a namespace schema; duplicate registration fails loud. */
27
- register(ns: string, schema: unknown, options?: unknown): unknown
28
- /** Read one registered namespace's resolved value (undefined while unregistered). */
29
- get(ns: string): unknown
30
- /** Merge a patch into one registered namespace's user layer, validate, persist. */
31
- update(ns: string, patch: object, expectedRevision?: number): Promise<void>
32
- /** Replace one registered namespace's user section wholesale, validate, persist. */
33
- replace(ns: string, section: object, expectedRevision?: number): Promise<void>
34
- /** Apply path-addressed edits to one registered namespace's user section. */
35
- mutate(ns: string, ops: readonly unknown[], expectedRevision?: number): Promise<void>
36
- /** Describe every registered namespace for configuration surfaces. */
37
- describe(options?: { redactSecrets?: boolean }): unknown[]
38
- /** Non-file providers expose no open-document affordance. */
39
- get documentPath(): string | undefined
40
- prepareDocument(): Promise<string | undefined>
41
- }
1
+ /**
2
+ * Narrow type surface for the vendored 0.1.5 `SettingsProvider` (legacy test-host seam).
3
+ *
4
+ * The 0.1.7 `@deepseek-ai/dsh-settings` host replaced the namespace-registry
5
+ * provider with the declarative `SettingsForms` projector, but the plugin
6
+ * deliberately keeps the legacy `ctx.settings.get(ns)` read as a fallback
7
+ * "so a host that still serves the old service shape keeps working (test
8
+ * hosts do exactly that)" (src/index.ts). The host specs drive that fallback
9
+ * through this vendored base class — the verbatim 0.1.5-rc.2 implementation,
10
+ * not a behavioral re-implementation.
11
+ *
12
+ * Only the members the specs and the production fallback actually touch are
13
+ * declared; the full 0.1.5 surface exists at runtime in provider.js.
14
+ */
15
+ import { Service } from '@deepseek-ai/cordis'
16
+
17
+ export declare abstract class SettingsProvider extends Service {
18
+ /** Register as the `settings` service of `ctx` (implementation: `super(ctx, 'settings')`). */
19
+ constructor(ctx: Context)
20
+ /** Whether {@linkcode LegacySettingsProvider.update} may persist through this provider. */
21
+ abstract readonly writable: boolean
22
+ /** Load the provider's raw document (namespace → raw section) once at init. */
23
+ protected abstract load(): Promise<Record<string, unknown>>
24
+ /** Durably store one namespace's merged user section. */
25
+ protected abstract persist(ns: string, section: Record<string, unknown>): Promise<void>
26
+ /** Register a namespace schema; duplicate registration fails loud. */
27
+ register(ns: string, schema: unknown, options?: unknown): unknown
28
+ /** Read one registered namespace's resolved value (undefined while unregistered). */
29
+ get(ns: string): unknown
30
+ /** Merge a patch into one registered namespace's user layer, validate, persist. */
31
+ update(ns: string, patch: object, expectedRevision?: number): Promise<void>
32
+ /** Replace one registered namespace's user section wholesale, validate, persist. */
33
+ replace(ns: string, section: object, expectedRevision?: number): Promise<void>
34
+ /** Apply path-addressed edits to one registered namespace's user section. */
35
+ mutate(ns: string, ops: readonly unknown[], expectedRevision?: number): Promise<void>
36
+ /** Describe every registered namespace for configuration surfaces. */
37
+ describe(options?: { redactSecrets?: boolean }): unknown[]
38
+ /** Non-file providers expose no open-document affordance. */
39
+ get documentPath(): string | undefined
40
+ prepareDocument(): Promise<string | undefined>
41
+ }