dsh-context-compression-improved 0.7.0-beta.1 → 0.8.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 (93) hide show
  1. package/CHANGELOG.de.md +539 -0
  2. package/CHANGELOG.es.md +547 -0
  3. package/CHANGELOG.fr.md +534 -0
  4. package/CHANGELOG.it.md +536 -0
  5. package/CHANGELOG.ja.md +226 -220
  6. package/CHANGELOG.ko.md +220 -214
  7. package/CHANGELOG.md +372 -376
  8. package/CHANGELOG.ru.md +517 -0
  9. package/CHANGELOG.zh.md +204 -199
  10. package/README.de.md +98 -0
  11. package/README.es.md +98 -0
  12. package/README.fr.md +98 -0
  13. package/README.it.md +98 -0
  14. package/README.ja.md +85 -85
  15. package/README.ko.md +85 -85
  16. package/README.md +98 -97
  17. package/README.ru.md +98 -0
  18. package/README.zh.md +85 -86
  19. package/docs/installation.de.md +104 -0
  20. package/docs/installation.es.md +104 -0
  21. package/docs/installation.fr.md +104 -0
  22. package/docs/installation.it.md +104 -0
  23. package/docs/installation.ja.md +78 -78
  24. package/docs/installation.ko.md +78 -78
  25. package/docs/installation.md +103 -103
  26. package/docs/installation.ru.md +104 -0
  27. package/docs/installation.zh.md +100 -100
  28. package/eslint.config.js +30 -76
  29. package/package.json +69 -70
  30. package/packages/selector/dsh.plugin.json +2 -2
  31. package/packages/selector/lib/{intent-gate.js → advisor-state.js} +3 -91
  32. package/packages/selector/lib/client.js +736 -14
  33. package/packages/selector/lib/index.js +1 -92
  34. package/packages/selector/lib/profiles.d.ts +0 -9
  35. package/packages/selector/lib/pruner.d.ts +0 -59
  36. package/packages/selector/lib/pruner.js +7 -410
  37. package/packages/selector/lib/style.css +46 -46
  38. package/packages/selector/package.json +114 -114
  39. package/packages/selector/src/client/decode.ts +2 -6
  40. package/packages/selector/src/client/index.ts +244 -213
  41. package/packages/selector/src/client/locales/de.ts +98 -0
  42. package/packages/selector/src/client/locales/es.ts +98 -0
  43. package/packages/selector/src/client/locales/fr.ts +98 -0
  44. package/packages/selector/src/client/locales/it.ts +98 -0
  45. package/packages/selector/src/client/locales/ja.ts +98 -0
  46. package/packages/selector/src/client/locales/ko.ts +98 -0
  47. package/packages/selector/src/client/locales/ru.ts +98 -0
  48. package/packages/selector/src/deepseek-v4-tokenizer.ts +1 -1
  49. package/packages/selector/src/index.ts +411 -418
  50. package/packages/selector/src/preset-overlay.ts +0 -3
  51. package/packages/selector/src/profiles.ts +10 -30
  52. package/packages/selector/src/pruner/content.ts +1 -1
  53. package/packages/selector/src/pruner/state.ts +0 -7
  54. package/packages/selector/src/pruner.ts +9 -253
  55. package/packages/selector/src/runtime/audit.ts +0 -17
  56. package/packages/selector/src/runtime/config.ts +11 -36
  57. package/packages/selector/src/runtime/reducers.ts +1 -1
  58. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +1 -46
  59. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +0 -55
  60. package/packages/selector/src/runtime/tokenpilot/locator.ts +2 -2
  61. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +1 -4
  62. package/packages/selector/src/runtime/types.ts +0 -12
  63. package/packages/selector/tests/auto-compact.client.spec.tsx +213 -214
  64. package/packages/selector/tests/built/client-artifact.spec.ts +59 -61
  65. package/packages/selector/tests/code-skeleton.client.spec.ts +93 -94
  66. package/packages/selector/tests/custom-contract.client.spec.ts +222 -223
  67. package/packages/selector/tests/estimator-channel.client.spec.tsx +252 -252
  68. package/packages/selector/tests/host-preset-overlay.host.spec.ts +204 -204
  69. package/packages/selector/tests/preset-options-write.client.spec.ts +187 -188
  70. package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +200 -200
  71. package/packages/selector/tests/profiles.client.spec.tsx +434 -436
  72. package/packages/selector/tests/public/package-contract.client.spec.ts +78 -78
  73. package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +230 -230
  74. package/packages/selector/tests/runtime/audit.spec.ts +274 -275
  75. package/packages/selector/tests/runtime/auto-compact-config.spec.ts +3 -3
  76. package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +4 -4
  77. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2731 -2736
  78. package/packages/selector/tests/standing-generation.host.spec.ts +724 -704
  79. package/pnpm-workspace.yaml +66 -66
  80. package/scripts/packed-components-smoke.mjs +0 -2
  81. package/scripts/packed-install-e2e.mjs +5 -7
  82. package/scripts/verify-release.mjs +2 -3
  83. package/tests/TEST_INVENTORY.md +41 -41
  84. package/tsconfig.tests.json +1 -3
  85. package/vitest.config.ts +0 -14
  86. package/packages/selector/src/runtime/summary-command.ts +0 -133
  87. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +0 -53
  88. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +0 -65
  89. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +0 -125
  90. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +0 -37
  91. package/packages/selector/tests/runtime/intent-gate.spec.ts +0 -62
  92. package/packages/selector/tests/runtime/intent-summary.spec.ts +0 -156
  93. package/packages/selector/tests/runtime/summary-command.spec.ts +0 -154
@@ -1,4 +1,4 @@
1
- import { a as getLastIntentFold, i as getAdvisorState, n as INTENT_GATE_GROWTH_TOKENS, o as getObservedIntentEnabled, p as setSummaryOverride, s as getSummaryOverride, t as INTENT_GATE_FLOOR_FRACTION, v as DEFAULT_CONTEXT_COMPRESSION_SETTINGS } from "./intent-gate.js";
1
+ import { l as DEFAULT_CONTEXT_COMPRESSION_SETTINGS, t as getAdvisorState } from "./advisor-state.js";
2
2
  import z from "@deepseek-ai/schemastery";
3
3
  import { AsyncLocalStorage } from "node:async_hooks";
4
4
  import { createHash } from "node:crypto";
@@ -75,96 +75,6 @@ async function buildEstimatorCatalog(deps) {
75
75
  };
76
76
  }
77
77
  //#endregion
78
- //#region src/runtime/summary-command.ts
79
- const SUMMARY_COMMAND_NAME = "ctx-summary";
80
- const USAGE = "Usage: /ctx-summary off|on|status";
81
- /** Parse the raw argument string; `undefined` = unrecognized (usage error). */
82
- function parseSummaryCommandArgs(rawInput) {
83
- const token = rawInput.trim().toLowerCase();
84
- if (token === "off" || token === "on" || token === "status") return token;
85
- }
86
- function describeFold(sessionId) {
87
- const fold = getLastIntentFold(sessionId);
88
- if (fold === void 0) return "none";
89
- return `turn ${fold.turn}, seq ${fold.startSeq}..${fold.endSeq}`;
90
- }
91
- /** Human-facing status line; observability only, never a decision input. */
92
- function formatSummaryStatus(sessionId) {
93
- const override = getSummaryOverride(sessionId);
94
- const enabled = getObservedIntentEnabled(sessionId);
95
- const enabledText = enabled === void 0 ? "unknown (gate not evaluated yet)" : enabled ? "yes" : "no";
96
- return [
97
- `ctx-summary status:`,
98
- ` override: ${override ?? "default (settings-driven)"}`,
99
- ` intentSummary enabled (settings): ${enabledText}`,
100
- ` gate: floor >${Math.round(INTENT_GATE_FLOOR_FRACTION * 100)}% of window AND growth >${INTENT_GATE_GROWTH_TOKENS} tokens since last fold`,
101
- ` last fold: ${describeFold(sessionId)}`
102
- ].join("\n");
103
- }
104
- /** Resolve the invoking agent's session id (`''` when the host exposes none). */
105
- function sessionIdOf(agent) {
106
- const session = agent?.session;
107
- if (session === void 0 || session.id === void 0 || session.id === null) return "";
108
- return String(session.id);
109
- }
110
- /** Best-effort `CommandDefinitionId` brand; `undefined` on stripped hosts (registered without it). */
111
- async function loadCommandDefinitionId() {
112
- try {
113
- return (await import("@deepseek-ai/dsh-commands")).CommandDefinitionId;
114
- } catch {
115
- return;
116
- }
117
- }
118
- /**
119
- * Mount `/ctx-summary` for every composed human-command adapter. Never
120
- * throws: the command is a convenience surface, and a host without the
121
- * commands service (or with an incompatible registry shape) simply runs
122
- * without it.
123
- */
124
- function registerSummaryCommand(ctx) {
125
- ctx.inject(["commands"], (injected) => {
126
- const commands = injected.commands;
127
- if (commands === void 0 || typeof commands.register !== "function") return;
128
- (async () => {
129
- try {
130
- const definitionId = await loadCommandDefinitionId();
131
- await commands.register({
132
- name: SUMMARY_COMMAND_NAME,
133
- description: "Turn-tail intent summary: temporarily disable/resume or inspect status",
134
- ...definitionId === void 0 ? {} : { definitionId: definitionId("dsh-context-compression-improved/ctx-summary") },
135
- handler: async (invocation) => {
136
- const args = parseSummaryCommandArgs(typeof invocation.rawInput === "string" ? invocation.rawInput : "");
137
- if (args === void 0) return {
138
- kind: "error",
139
- text: USAGE
140
- };
141
- const sessionId = sessionIdOf(invocation.agent);
142
- if (args === "status") {
143
- if (sessionId === "") return {
144
- kind: "error",
145
- text: "ctx-summary: no session is attached to this invocation"
146
- };
147
- return {
148
- kind: "success",
149
- text: formatSummaryStatus(sessionId)
150
- };
151
- }
152
- if (sessionId === "") return {
153
- kind: "error",
154
- text: "ctx-summary: no session is attached to this invocation"
155
- };
156
- setSummaryOverride(sessionId, args);
157
- return {
158
- kind: "success",
159
- text: args === "off" ? "ctx-summary: turn-tail intent summary paused for this session (until process restart or `/ctx-summary on`)" : "ctx-summary: turn-tail intent summary resumed for this session (numeric gates still apply)"
160
- };
161
- }
162
- });
163
- } catch {}
164
- })();
165
- });
166
- }
167
- //#endregion
168
78
  //#region src/preset-overlay.ts
169
79
  /** Plugin-owned, reversible compression overlays for native agent presets. */
170
80
  /**
@@ -832,7 +742,6 @@ function apply(ctx, config = {}) {
832
742
  try {
833
743
  if (config.estimatorCatalogRoute === true) registerEstimatorCatalogRoute(ctx);
834
744
  if (config.advisorReportRoute === true) registerAdvisorReportRoute(ctx);
835
- registerSummaryCommand(ctx);
836
745
  if (config.presetOverlay !== true) return;
837
746
  ctx.inject(["agentPresets"], (presetsCtx) => {
838
747
  const installation = decorateAgentPresets(presetsCtx.agentPresets, {
@@ -68,13 +68,6 @@ interface AutoCompactSettings {
68
68
  interface CodeSkeletonSettings {
69
69
  enabled: boolean;
70
70
  }
71
- /**
72
- * Orthogonal turn-tail intent-summary gate, mirrored browser-safe from the
73
- * runtime: independent of every profile, default off.
74
- */
75
- interface IntentSummarySettings {
76
- enabled: boolean;
77
- }
78
71
  /** Browser-safe mirror of the runtime presetOptions section. */
79
72
  interface PresetOptionsSettings {
80
73
  readonly dedupeToolResults?: boolean;
@@ -105,8 +98,6 @@ interface ContextCompressionSettings {
105
98
  autoCompact: AutoCompactSettings;
106
99
  /** Code-skeleton reducer gate captured independently of `profile`. */
107
100
  codeSkeleton: CodeSkeletonSettings;
108
- /** Turn-tail intent-summary gate captured independently of `profile`. */
109
- intentSummary: IntentSummarySettings;
110
101
  /** Optional tokenpilot-inspired sub-capability overrides (presence-validated only). */
111
102
  presetOptions?: PresetOptionsSettings;
112
103
  }
@@ -134,15 +134,6 @@ interface AutoCompactSettings {
134
134
  interface CodeSkeletonSettings {
135
135
  enabled: boolean;
136
136
  }
137
- /**
138
- * Orthogonal turn-tail intent-summary gate. Independent of every profile:
139
- * when enabled, the turn-boundary growth gate may fold consumed-increment
140
- * tool results into an LLM-written intent block (skeleton + verbatim error
141
- * lines are kept; the model only ever writes the summary segment).
142
- */
143
- interface IntentSummarySettings {
144
- enabled: boolean;
145
- }
146
137
  /**
147
138
  * Persisted sub-capability overrides for the `tokenpilot-inspired` preset.
148
139
  * Absent fields inherit the preset defaults; the section is only meaningful
@@ -182,8 +173,6 @@ interface ContextCompressionSettings {
182
173
  autoCompact: AutoCompactSettings;
183
174
  /** Code-skeleton reducer gate snapped independently of `profile`. */
184
175
  codeSkeleton: CodeSkeletonSettings;
185
- /** Turn-tail intent-summary gate snapped independently of `profile`. */
186
- intentSummary: IntentSummarySettings;
187
176
  /** Optional tokenpilot-inspired sub-capability overrides; absent inherits preset defaults. */
188
177
  presetOptions?: PresetOptionsSettings;
189
178
  }
@@ -408,32 +397,6 @@ interface EstimatorFailures {
408
397
  cooldownUntil: number;
409
398
  }
410
399
  //#endregion
411
- //#region src/runtime/tokenpilot/intent-input-mask.d.ts
412
- type IntentRole = 'read-mask' | 'write-keep' | 'conservative';
413
- //#endregion
414
- //#region src/runtime/tokenpilot/intent-fold.d.ts
415
- /** One staged fold awaiting the next pressure round. */
416
- interface PendingIntentFold {
417
- readonly createdAt: number;
418
- readonly turn: number;
419
- /** Inclusive seq span of the folded candidates. */
420
- readonly startSeq: number;
421
- readonly endSeq: number;
422
- /** LLM-written summary segment (fail-open parsed, char-capped). */
423
- readonly summary: string;
424
- /** Verbatim error lines collected across the batch (never LLM-revoiced). */
425
- readonly errorLines: readonly string[];
426
- /** Per-candidate faces: read-mask single lines ride the block, keep-class lines prompt-only. */
427
- readonly records: ReadonlyArray<{
428
- readonly seq: number;
429
- readonly role: IntentRole;
430
- readonly toolName: string;
431
- readonly line: string;
432
- }>;
433
- /** Characters consumed by the summary-writer call (credit accounting). */
434
- readonly summaryCallChars: number;
435
- }
436
- //#endregion
437
400
  //#region src/pruner/state.d.ts
438
401
  /** Mutable per-session state bag used inside {@link ToolResultPruner}. */
439
402
  interface PrunerState {
@@ -467,12 +430,6 @@ interface PrunerState {
467
430
  readonly estimatorRemainingTurns: WeakMap<Session, number>;
468
431
  /** Per-session advisor side channel, constructed once with the advisor overrides. */
469
432
  readonly advisorChannels: WeakMap<Session, SideChannel>;
470
- /** Staged intent fold awaiting the next pressure round (at most one per session). */
471
- readonly pendingIntentFolds: WeakMap<Session, PendingIntentFold>;
472
- /** Landed intent-fold seqs: fold-once, never reconsidered by any later stage. */
473
- readonly intentFoldedSeqs: WeakMap<Session, Set<number>>;
474
- /** Live-surface tokens when the last intent fold landed (growth-gate baseline). */
475
- readonly intentBaselines: WeakMap<Session, number>;
476
433
  }
477
434
  //#endregion
478
435
  //#region src/runtime/custom-policy.d.ts
@@ -802,22 +759,6 @@ declare class ToolResultPruner extends Service {
802
759
  * reads, so the default configuration adds exactly zero behavior.
803
760
  */
804
761
  private postflightAdvisorPass;
805
- /**
806
- * Fire-and-forget postflight: evaluate the growth gate, and only when it
807
- * passes, select the consumed increment OUTSIDE the protected working set,
808
- * mask it to semantic-role records, and spend ONE summary-writer call. The
809
- * verdict stages as a pending fold that the NEXT pressure round lands via
810
- * the ordinary plan/apply machinery — the synchronous decision path never
811
- * waits on an LLM.
812
- */
813
- private postflightIntentFoldPass;
814
- /**
815
- * Convert a staged pending fold into per-candidate planned replacements
816
- * (reducer `intent-summary`). Fail-open: a candidate that would grow, is
817
- * rich-content, or no longer exists keeps its original text. Returns
818
- * `undefined` when there is nothing (or no longer anything) to fold.
819
- */
820
- private applyPendingIntentFold;
821
762
  /**
822
763
  * Monotonic per-session turn clock for advisory records. Bumped by the agent
823
764
  * loop payloads (`pre-step`); passes without a turn coordinate reuse the last