dsh-context-compression-improved 0.8.0-beta.2 → 0.8.0-beta.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/eslint.config.js +30 -30
  3. package/package.json +163 -163
  4. package/packages/selector/dsh.plugin.json +16 -16
  5. package/packages/selector/lib/client.d.ts +20 -0
  6. package/packages/selector/lib/client.js +433 -17
  7. package/packages/selector/lib/index.js +213 -2
  8. package/packages/selector/lib/{advisor-state.js → intent-gate.js} +593 -3
  9. package/packages/selector/lib/profiles.d.ts +9 -0
  10. package/packages/selector/lib/pruner.d.ts +59 -0
  11. package/packages/selector/lib/pruner.js +494 -262
  12. package/packages/selector/lib/style.css +42 -0
  13. package/packages/selector/src/client/CompressionProfileControls.tsx +34 -0
  14. package/packages/selector/src/client/CompressionProfileSelector.module.css +199 -170
  15. package/packages/selector/src/client/CompressionProfileSelector.tsx +1 -0
  16. package/packages/selector/src/client/decode.ts +53 -49
  17. package/packages/selector/src/client/index.ts +4 -0
  18. package/packages/selector/src/client/locales/de.ts +20 -0
  19. package/packages/selector/src/client/locales/es.ts +20 -0
  20. package/packages/selector/src/client/locales/fr.ts +20 -0
  21. package/packages/selector/src/client/locales/it.ts +20 -0
  22. package/packages/selector/src/client/locales/ja.ts +20 -0
  23. package/packages/selector/src/client/locales/ko.ts +20 -0
  24. package/packages/selector/src/client/locales/ru.ts +20 -0
  25. package/packages/selector/src/client/locales.ts +236 -196
  26. package/packages/selector/src/client/savings-card.tsx +150 -0
  27. package/packages/selector/src/client/settings-section.tsx +133 -124
  28. package/packages/selector/src/index.ts +554 -411
  29. package/packages/selector/src/profiles.ts +414 -394
  30. package/packages/selector/src/pruner/state.ts +57 -50
  31. package/packages/selector/src/pruner.ts +2745 -2421
  32. package/packages/selector/src/runtime/audit.ts +303 -286
  33. package/packages/selector/src/runtime/config.ts +731 -706
  34. package/packages/selector/src/runtime/retrieve.ts +479 -457
  35. package/packages/selector/src/runtime/savings.ts +337 -0
  36. package/packages/selector/src/runtime/summary-command.ts +127 -0
  37. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +233 -188
  38. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +204 -149
  39. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +53 -0
  40. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +65 -0
  41. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +125 -0
  42. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +37 -0
  43. package/packages/selector/src/runtime/types.ts +358 -346
  44. package/packages/selector/tests/auto-compact.client.spec.tsx +214 -213
  45. package/packages/selector/tests/code-skeleton.client.spec.ts +94 -93
  46. package/packages/selector/tests/custom-contract.client.spec.ts +223 -222
  47. package/packages/selector/tests/estimator-channel.client.spec.tsx +253 -252
  48. package/packages/selector/tests/estimator-route-registration.host.spec.ts +192 -188
  49. package/packages/selector/tests/preset-options-write.client.spec.ts +188 -187
  50. package/packages/selector/tests/profiles.client.spec.tsx +436 -434
  51. package/packages/selector/tests/runtime/audit.spec.ts +275 -274
  52. package/packages/selector/tests/runtime/intent-gate.spec.ts +62 -0
  53. package/packages/selector/tests/runtime/intent-summary.spec.ts +156 -0
  54. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2734 -2731
  55. package/packages/selector/tests/runtime/savings.spec.ts +120 -0
  56. package/packages/selector/tests/runtime/summary-command.spec.ts +154 -0
  57. package/packages/selector/tests/settings-seat.client.spec.ts +1 -1
  58. package/scripts/packed-install-e2e.mjs +1 -1
  59. package/scripts/verify-release.mjs +2 -1
@@ -134,6 +134,15 @@ 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
+ }
137
146
  /**
138
147
  * Persisted sub-capability overrides for the `tokenpilot-inspired` preset.
139
148
  * Absent fields inherit the preset defaults; the section is only meaningful
@@ -173,6 +182,8 @@ interface ContextCompressionSettings {
173
182
  autoCompact: AutoCompactSettings;
174
183
  /** Code-skeleton reducer gate snapped independently of `profile`. */
175
184
  codeSkeleton: CodeSkeletonSettings;
185
+ /** Turn-tail intent-summary gate snapped independently of `profile`. */
186
+ intentSummary: IntentSummarySettings;
176
187
  /** Optional tokenpilot-inspired sub-capability overrides; absent inherits preset defaults. */
177
188
  presetOptions?: PresetOptionsSettings;
178
189
  }
@@ -397,6 +408,32 @@ interface EstimatorFailures {
397
408
  cooldownUntil: number;
398
409
  }
399
410
  //#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
400
437
  //#region src/pruner/state.d.ts
401
438
  /** Mutable per-session state bag used inside {@link ToolResultPruner}. */
402
439
  interface PrunerState {
@@ -430,6 +467,12 @@ interface PrunerState {
430
467
  readonly estimatorRemainingTurns: WeakMap<Session, number>;
431
468
  /** Per-session advisor side channel, constructed once with the advisor overrides. */
432
469
  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>;
433
476
  }
434
477
  //#endregion
435
478
  //#region src/runtime/custom-policy.d.ts
@@ -759,6 +802,22 @@ declare class ToolResultPruner extends Service {
759
802
  * reads, so the default configuration adds exactly zero behavior.
760
803
  */
761
804
  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;
762
821
  /**
763
822
  * Monotonic per-session turn clock for advisory records. Bumped by the agent
764
823
  * loop payloads (`pre-step`); passes without a turn coordinate reuse the last