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
@@ -60,6 +60,15 @@ window.__ModuleLoader__.load({
60
60
  const enabled = value.enabled;
61
61
  return typeof enabled === "boolean" ? { enabled } : void 0;
62
62
  }
63
+ /** Browser-safe mirror of the runtime intentSummary section (absent inherits off). */
64
+ function decodeIntentSummarySettings(value) {
65
+ if (value === void 0) return { enabled: false };
66
+ if (!isPlainRecord(value)) return void 0;
67
+ const keys = Object.keys(value);
68
+ if (keys.length !== 1 || keys[0] !== "enabled") return void 0;
69
+ const enabled = value.enabled;
70
+ return typeof enabled === "boolean" ? { enabled } : void 0;
71
+ }
63
72
  /**
64
73
  * Browser mirror of the runtime presetOptions section: absent inherits the
65
74
  * preset defaults (decodes to `undefined`); present values must be a plain
@@ -285,7 +294,7 @@ window.__ModuleLoader__.load({
285
294
  }
286
295
  //#endregion
287
296
  //#region \0dsh-context-compression-css:466eb745356d-CompressionProfileSelector.module.css.mjs
288
- const css = ".rLocJG_settingsSection{max-width:720px;color:var(--dsw-alias-label-primary);flex-direction:column;gap:12px;display:flex}.rLocJG_settingsTitle{color:var(--dsw-alias-label-primary);margin:0;font-size:16px;font-weight:500;line-height:24px}.rLocJG_settingsDescription{color:var(--dsw-alias-label-tertiary);margin:0;font-size:14px;line-height:22px}.rLocJG_root{width:100%}.rLocJG_profileGrid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;display:grid}.rLocJG_profileCard{border:1px solid var(--dsw-alias-border-l2);min-height:112px;color:var(--dsw-alias-label-primary);cursor:pointer;text-align:left;background:0 0;border-radius:10px;flex-direction:column;gap:8px;padding:14px;display:flex}.rLocJG_profileCard:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.rLocJG_profileCard[aria-pressed=true]{border-color:var(--dsw-alias-label-primary)}.rLocJG_profileCard:active:not(:disabled){transform:scale(.99)}.rLocJG_profileCard:disabled{cursor:default;opacity:.6}.rLocJG_profileCard:focus-visible{outline-offset:2px;outline:2px solid}.rLocJG_profileCardTop{align-items:center;gap:8px;display:flex}.rLocJG_profileCardTitle{font-size:14px;font-weight:500;line-height:20px}.rLocJG_profileCurrent{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-base);border-radius:999px;padding:1px 6px;font-size:10px;line-height:14px}.rLocJG_profileCardDetail{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px}.rLocJG_button{border:1px solid var(--dsw-alias-border-l2);width:100%;min-height:34px;color:var(--dsw-alias-label-primary);cursor:pointer;text-align:left;background:0 0;border-radius:10px;align-items:center;gap:8px;padding:6px 8px;display:flex}.rLocJG_button:hover{background:var(--dsw-alias-interactive-bg-hover)}.rLocJG_button:disabled{cursor:default;opacity:.6}.rLocJG_copy{flex:1;min-width:0}.rLocJG_label{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:14px}.rLocJG_value{text-overflow:ellipsis;white-space:nowrap;font-size:13px;line-height:17px;overflow:hidden}.rLocJG_chevron{color:var(--dsw-alias-label-secondary);flex:none}.rLocJG_menuCopy{flex-direction:column;gap:2px;min-width:220px;display:flex}.rLocJG_menuTitle{font-size:13px;line-height:17px}.rLocJG_menuDetail{white-space:normal;max-width:290px;color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:15px}.rLocJG_error{color:var(--dsw-alias-state-error-primary);padding:4px 8px 0;font-size:11px;line-height:15px}.rLocJG_unavailable{color:var(--dsw-alias-label-tertiary);padding:4px 8px 0;font-size:11px;line-height:15px}.rLocJG_settingsHint{color:var(--dsw-alias-label-secondary);padding:4px 8px 0;font-size:11px;line-height:15px}.rLocJG_pricing{color:var(--dsw-alias-label-tertiary);padding:4px 8px 0;font-size:11px;line-height:15px}.rLocJG_custom{border-top:1px solid var(--dsw-alias-border-l2);margin-top:16px;padding:16px 0 0}.rLocJG_customTitle{margin:0 0 6px;font-size:13px;line-height:17px}.rLocJG_customNote{color:var(--dsw-alias-label-tertiary);margin:4px 0;font-size:11px;line-height:15px}.rLocJG_stage{border:0;border-top:1px solid var(--dsw-alias-border-l2);margin:12px 0 0;padding:12px 0 0}.rLocJG_stageToggle{align-items:center;gap:6px;font-size:12px;line-height:16px;display:inline-flex}.rLocJG_fieldGrid{grid-template-columns:1fr;gap:8px;display:grid}.rLocJG_field{min-width:0;color:var(--dsw-alias-label-secondary);flex-direction:column;gap:4px;margin-top:8px;font-size:11px;line-height:15px;display:flex}.rLocJG_field input,.rLocJG_field select{box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-base);width:100%;min-width:0;min-height:30px;color:var(--dsw-alias-label-primary);border-radius:7px;padding:4px 6px}.rLocJG_field input:focus-visible,.rLocJG_field select:focus-visible,.rLocJG_actions button:focus-visible{outline-offset:2px;outline:2px solid}.rLocJG_actions{flex-wrap:wrap;gap:8px;margin-top:10px;display:flex}.rLocJG_actions button{border:1px solid var(--dsw-alias-border-l2);min-height:30px;color:var(--dsw-alias-label-primary);background:0 0;border-radius:7px;padding:4px 8px}.rLocJG_actions button:active:not(:disabled){transform:scale(.98)}.rLocJG_actions button:disabled{opacity:.6}@media (width<=560px){.rLocJG_profileGrid{grid-template-columns:1fr}}.rLocJG_autoCompact{border:1px solid #80808059;border-radius:8px;margin-top:24px;padding:16px}.rLocJG_autoCompactTitle{margin:0 0 8px;font-size:15px;font-weight:600}.rLocJG_autoCompactRisk{opacity:.9;margin:8px 0 0;font-size:12px}";
297
+ const css = ".rLocJG_settingsSection{max-width:720px;color:var(--dsw-alias-label-primary);flex-direction:column;gap:12px;display:flex}.rLocJG_settingsTitle{color:var(--dsw-alias-label-primary);margin:0;font-size:16px;font-weight:500;line-height:24px}.rLocJG_settingsDescription{color:var(--dsw-alias-label-tertiary);margin:0;font-size:14px;line-height:22px}.rLocJG_root{width:100%}.rLocJG_profileGrid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;display:grid}.rLocJG_profileCard{border:1px solid var(--dsw-alias-border-l2);min-height:112px;color:var(--dsw-alias-label-primary);cursor:pointer;text-align:left;background:0 0;border-radius:10px;flex-direction:column;gap:8px;padding:14px;display:flex}.rLocJG_profileCard:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.rLocJG_profileCard[aria-pressed=true]{border-color:var(--dsw-alias-label-primary)}.rLocJG_profileCard:active:not(:disabled){transform:scale(.99)}.rLocJG_profileCard:disabled{cursor:default;opacity:.6}.rLocJG_profileCard:focus-visible{outline-offset:2px;outline:2px solid}.rLocJG_profileCardTop{align-items:center;gap:8px;display:flex}.rLocJG_profileCardTitle{font-size:14px;font-weight:500;line-height:20px}.rLocJG_profileCurrent{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-base);border-radius:999px;padding:1px 6px;font-size:10px;line-height:14px}.rLocJG_profileCardDetail{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px}.rLocJG_button{border:1px solid var(--dsw-alias-border-l2);width:100%;min-height:34px;color:var(--dsw-alias-label-primary);cursor:pointer;text-align:left;background:0 0;border-radius:10px;align-items:center;gap:8px;padding:6px 8px;display:flex}.rLocJG_button:hover{background:var(--dsw-alias-interactive-bg-hover)}.rLocJG_button:disabled{cursor:default;opacity:.6}.rLocJG_copy{flex:1;min-width:0}.rLocJG_label{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:14px}.rLocJG_value{text-overflow:ellipsis;white-space:nowrap;font-size:13px;line-height:17px;overflow:hidden}.rLocJG_chevron{color:var(--dsw-alias-label-secondary);flex:none}.rLocJG_menuCopy{flex-direction:column;gap:2px;min-width:220px;display:flex}.rLocJG_menuTitle{font-size:13px;line-height:17px}.rLocJG_menuDetail{white-space:normal;max-width:290px;color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:15px}.rLocJG_error{color:var(--dsw-alias-state-error-primary);padding:4px 8px 0;font-size:11px;line-height:15px}.rLocJG_unavailable{color:var(--dsw-alias-label-tertiary);padding:4px 8px 0;font-size:11px;line-height:15px}.rLocJG_settingsHint{color:var(--dsw-alias-label-secondary);padding:4px 8px 0;font-size:11px;line-height:15px}.rLocJG_pricing{color:var(--dsw-alias-label-tertiary);padding:4px 8px 0;font-size:11px;line-height:15px}.rLocJG_custom{border-top:1px solid var(--dsw-alias-border-l2);margin-top:16px;padding:16px 0 0}.rLocJG_customTitle{margin:0 0 6px;font-size:13px;line-height:17px}.rLocJG_customNote{color:var(--dsw-alias-label-tertiary);margin:4px 0;font-size:11px;line-height:15px}.rLocJG_stage{border:0;border-top:1px solid var(--dsw-alias-border-l2);margin:12px 0 0;padding:12px 0 0}.rLocJG_stageToggle{align-items:center;gap:6px;font-size:12px;line-height:16px;display:inline-flex}.rLocJG_fieldGrid{grid-template-columns:1fr;gap:8px;display:grid}.rLocJG_field{min-width:0;color:var(--dsw-alias-label-secondary);flex-direction:column;gap:4px;margin-top:8px;font-size:11px;line-height:15px;display:flex}.rLocJG_field input,.rLocJG_field select{box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-base);width:100%;min-width:0;min-height:30px;color:var(--dsw-alias-label-primary);border-radius:7px;padding:4px 6px}.rLocJG_field input:focus-visible,.rLocJG_field select:focus-visible,.rLocJG_actions button:focus-visible{outline-offset:2px;outline:2px solid}.rLocJG_actions{flex-wrap:wrap;gap:8px;margin-top:10px;display:flex}.rLocJG_actions button{border:1px solid var(--dsw-alias-border-l2);min-height:30px;color:var(--dsw-alias-label-primary);background:0 0;border-radius:7px;padding:4px 8px}.rLocJG_actions button:active:not(:disabled){transform:scale(.98)}.rLocJG_actions button:disabled{opacity:.6}@media (width<=560px){.rLocJG_profileGrid{grid-template-columns:1fr}}.rLocJG_autoCompact{border:1px solid #80808059;border-radius:8px;margin-top:24px;padding:16px}.rLocJG_autoCompactTitle{margin:0 0 8px;font-size:15px;font-weight:600}.rLocJG_autoCompactRisk{opacity:.9;margin:8px 0 0;font-size:12px}.rLocJG_savingsCard{border:1px solid #ffffff1a;border-radius:8px;flex-direction:column;gap:4px;margin-top:14px;padding:10px 12px;display:flex}.rLocJG_savingsRow{justify-content:space-between;align-items:baseline;gap:12px;display:flex}.rLocJG_savingsNetPositive strong{color:#30d158}.rLocJG_savingsNetNegative strong{color:#ff9f0a}.rLocJG_savingsMuted{opacity:.66;font-size:.92em}.rLocJG_savingsBreakdown{border-top:1px solid #ffffff14;margin-top:4px;padding-top:4px}.rLocJG_savingsNote{opacity:.5;margin-top:4px;font-size:.85em}";
289
298
  const tagId = "dsh-context-compression-improved/CompressionProfileSelector.module.css";
290
299
  if (typeof document !== "undefined" && document.querySelector(`style[data-plugin-css="${tagId}"]`) === null) {
291
300
  const tag = document.createElement("style");
@@ -320,6 +329,13 @@ window.__ModuleLoader__.load({
320
329
  "profileCurrent": "rLocJG_profileCurrent",
321
330
  "profileGrid": "rLocJG_profileGrid",
322
331
  "root": "rLocJG_root",
332
+ "savingsBreakdown": "rLocJG_savingsBreakdown",
333
+ "savingsCard": "rLocJG_savingsCard",
334
+ "savingsMuted": "rLocJG_savingsMuted",
335
+ "savingsNetNegative": "rLocJG_savingsNetNegative",
336
+ "savingsNetPositive": "rLocJG_savingsNetPositive",
337
+ "savingsNote": "rLocJG_savingsNote",
338
+ "savingsRow": "rLocJG_savingsRow",
323
339
  "settingsDescription": "rLocJG_settingsDescription",
324
340
  "settingsHint": "rLocJG_settingsHint",
325
341
  "settingsSection": "rLocJG_settingsSection",
@@ -708,10 +724,45 @@ window.__ModuleLoader__.load({
708
724
  });
709
725
  }
710
726
  /**
711
- * The authoritative code-skeleton reducer gate for the context-compression
712
- * section. Deliberately minimal — an on/off select plus its own save path —
713
- * because the gate is orthogonal to every profile and carries no parameters.
727
+ * The turn-tail intent summary fold gate. Same deliberately minimal shape as
728
+ * the code-skeleton gate: an on/off select with its own save path; the fold
729
+ * itself is gated by the growth constants and the per-session /ctx-summary
730
+ * override, none of which belong in this card.
714
731
  */
732
+ function IntentSummaryControls({ value, disabled, save, settle, t }) {
733
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
734
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.autoCompact,
735
+ "aria-labelledby": "context-compression-intentsummary-title",
736
+ children: [
737
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
738
+ id: "context-compression-intentsummary-title",
739
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.autoCompactTitle,
740
+ children: t("intentSummary.title")
741
+ }),
742
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
743
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.customNote,
744
+ children: t("intentSummary.description")
745
+ }),
746
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
747
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.field,
748
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("intentSummary.enabled") }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
749
+ value: value ? "on" : "off",
750
+ disabled,
751
+ onChange: (event) => {
752
+ settle(() => save(event.currentTarget.value === "on"));
753
+ },
754
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
755
+ value: "on",
756
+ children: t("intentSummary.enabled.on")
757
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
758
+ value: "off",
759
+ children: t("intentSummary.enabled.off")
760
+ })]
761
+ })]
762
+ })
763
+ ]
764
+ });
765
+ }
715
766
  function CodeSkeletonControls({ value, disabled, save, settle, t }) {
716
767
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
717
768
  className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.autoCompact,
@@ -1024,6 +1075,189 @@ window.__ModuleLoader__.load({
1024
1075
  });
1025
1076
  }
1026
1077
  //#endregion
1078
+ //#region src/client/savings-card.tsx
1079
+ /**
1080
+ * 节省统计卡片(设置分节内,只读):净/毛/抵消 + 分项条。
1081
+ * 数据源 = `/api/.../savings` 只读快照路由(忙 2s / 闲 5s 自调度轮询,
1082
+ * 失败静默——统计卡片永不打扰设置页主功能)。
1083
+ *
1084
+ * @module dsh-context-compression-improved/client/savings-card
1085
+ */
1086
+ const SAVINGS_ROUTE = "/api/dsh-context-compression-improved/savings";
1087
+ function fmt(n) {
1088
+ return n.toLocaleString("en-US");
1089
+ }
1090
+ /** 节省统计卡片:口径分列(精确 tokenizer vs chars/4 估算),永不混算。 */
1091
+ function SavingsCard({ t }) {
1092
+ const [snap, setSnap] = (0, react.useState)(null);
1093
+ const stopped = (0, react.useRef)(false);
1094
+ (0, react.useEffect)(() => {
1095
+ stopped.current = false;
1096
+ const tick = async () => {
1097
+ try {
1098
+ const response = await fetch(SAVINGS_ROUTE, { headers: { "cache-control": "no-cache" } });
1099
+ if (response.ok) {
1100
+ const data = await response.json();
1101
+ if (data?.startedAt !== void 0 && !stopped.current) setSnap(data);
1102
+ }
1103
+ } catch {}
1104
+ if (!stopped.current) setTimeout(tick, 5e3);
1105
+ };
1106
+ tick();
1107
+ return () => {
1108
+ stopped.current = true;
1109
+ };
1110
+ }, []);
1111
+ if (snap === null || snap.gross.exact + snap.gross.estimated === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1112
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.pricing,
1113
+ children: t("savings.empty")
1114
+ });
1115
+ const hasExact = snap.gross.exact > 0 || snap.offsets.exact > 0;
1116
+ const hasEstimated = snap.gross.estimated > 0 || snap.offsets.estimated > 0;
1117
+ const netTone = snap.net.exact + snap.net.estimated >= 0 ? _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsNetPositive : _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsNetNegative;
1118
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1119
+ className: `${_dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsCard}`,
1120
+ "data-testid": "savings-card",
1121
+ children: [
1122
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1123
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsRow,
1124
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("savings.title") })
1125
+ }),
1126
+ hasExact ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1127
+ className: `${_dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsRow} ${netTone}`,
1128
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("savings.netExact") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: fmt(snap.net.exact) })]
1129
+ }) : null,
1130
+ hasEstimated ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1131
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsRow,
1132
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("savings.netEstimated") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: fmt(snap.net.estimated) })]
1133
+ }) : null,
1134
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1135
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsRow,
1136
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1137
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsMuted,
1138
+ children: t("savings.gross")
1139
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1140
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsMuted,
1141
+ children: [
1142
+ hasExact ? `✓ ${fmt(snap.gross.exact)}` : "",
1143
+ hasExact && hasEstimated ? " · " : "",
1144
+ hasEstimated ? `≈ ${fmt(snap.gross.estimated)}` : ""
1145
+ ]
1146
+ })]
1147
+ }),
1148
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1149
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsRow,
1150
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1151
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsMuted,
1152
+ children: t("savings.offsets")
1153
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1154
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsMuted,
1155
+ children: [
1156
+ hasExact ? `−${fmt(snap.offsets.exact)}` : "",
1157
+ hasExact && hasEstimated ? " · " : "",
1158
+ hasEstimated ? `−${fmt(snap.offsets.estimated)}` : ""
1159
+ ]
1160
+ })]
1161
+ }),
1162
+ snap.usage !== void 0 && snap.usage.requests > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1163
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1164
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsRow,
1165
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1166
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsMuted,
1167
+ children: t("savings.requests")
1168
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1169
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsMuted,
1170
+ children: fmt(snap.usage.requests)
1171
+ })]
1172
+ }),
1173
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1174
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsRow,
1175
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1176
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsMuted,
1177
+ children: t("savings.cacheHit")
1178
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1179
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsMuted,
1180
+ children: snap.usage.cacheHitRate === null ? "–" : `${Math.round(snap.usage.cacheHitRate * 100)}%`
1181
+ })]
1182
+ }),
1183
+ snap.pricing?.actualCost !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1184
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsRow,
1185
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1186
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsMuted,
1187
+ children: t("savings.actualCost")
1188
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1189
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsMuted,
1190
+ children: [
1191
+ snap.pricing.currency,
1192
+ " ",
1193
+ snap.pricing.actualCost
1194
+ ]
1195
+ })]
1196
+ }) : null,
1197
+ snap.pricing?.estimatedSavedCost !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1198
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsRow,
1199
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1200
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsMuted,
1201
+ children: t("savings.savedMoney")
1202
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1203
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsMuted,
1204
+ children: [
1205
+ snap.pricing.currency,
1206
+ " ",
1207
+ snap.pricing.estimatedSavedCost
1208
+ ]
1209
+ })]
1210
+ }) : null
1211
+ ] }) : null,
1212
+ snap.perSession !== void 0 && snap.perSession.length > 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1213
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsBreakdown,
1214
+ children: snap.perSession.slice(0, 5).map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1215
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsRow,
1216
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1217
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsMuted,
1218
+ children: [
1219
+ t("savings.perSession"),
1220
+ " · ",
1221
+ row.sessionId.slice(0, 8),
1222
+ "…",
1223
+ row.requests > 0 ? ` · ${t("savings.cacheHit")} ${row.cacheHitRate === null ? "–" : `${Math.round(row.cacheHitRate * 100)}%`}` : ""
1224
+ ]
1225
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1226
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsMuted,
1227
+ children: fmt(row.net.exact)
1228
+ })]
1229
+ }, row.sessionId))
1230
+ }) : null,
1231
+ snap.perComponent.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1232
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsBreakdown,
1233
+ children: snap.perComponent.slice(0, 6).map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1234
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsRow,
1235
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1236
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsMuted,
1237
+ children: [
1238
+ row.kind === "offset" ? "−" : "+",
1239
+ " ",
1240
+ row.component,
1241
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("small", { children: [
1242
+ " (",
1243
+ row.basis === "exact-tokenizer" ? t("savings.basisExact") : t("savings.basisEstimated"),
1244
+ ")"
1245
+ ] })
1246
+ ]
1247
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1248
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsMuted,
1249
+ children: fmt(row.tokens)
1250
+ })]
1251
+ }, `${row.kind}:${row.component}:${row.basis}`))
1252
+ }) : null,
1253
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1254
+ className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.savingsNote,
1255
+ children: t("savings.basisNote")
1256
+ })
1257
+ ]
1258
+ });
1259
+ }
1260
+ //#endregion
1027
1261
  //#region src/client/settings-section.tsx
1028
1262
  /**
1029
1263
  * Full-page Settings surface backed by the same durable selector state.
@@ -1036,7 +1270,7 @@ window.__ModuleLoader__.load({
1036
1270
  function ContextCompressionSettingsSection(props) {
1037
1271
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingsCompressionProfileControls, { ...props });
1038
1272
  }
1039
- function SettingsCompressionProfileControls({ useCompression, select, saveCustom, resetCustom, saveAutoCompact, saveCodeSkeleton, savePresetOptions, t }) {
1273
+ function SettingsCompressionProfileControls({ useCompression, select, saveCustom, resetCustom, saveAutoCompact, saveCodeSkeleton, saveIntentSummary, savePresetOptions, t }) {
1040
1274
  const state = useCompression((snapshot) => snapshot);
1041
1275
  const [saving, setSaving] = (0, react.useState)(false);
1042
1276
  const [saveError, setSaveError] = (0, react.useState)(null);
@@ -1123,6 +1357,13 @@ window.__ModuleLoader__.load({
1123
1357
  settle,
1124
1358
  t
1125
1359
  }),
1360
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IntentSummaryControls, {
1361
+ value: state.value?.intentSummary?.enabled ?? false,
1362
+ disabled: busy || !state.writable || false,
1363
+ save: saveIntentSummary,
1364
+ settle,
1365
+ t
1366
+ }),
1126
1367
  current !== "tokenpilot-inspired" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EstimatorInactiveNotice, {
1127
1368
  profile: t(`profile.${current}`),
1128
1369
  t
@@ -1133,6 +1374,7 @@ window.__ModuleLoader__.load({
1133
1374
  settle,
1134
1375
  t
1135
1376
  }),
1377
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SavingsCard, { t }),
1136
1378
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1137
1379
  className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.pricing,
1138
1380
  children: t("pricing.disclosure")
@@ -1160,7 +1402,7 @@ window.__ModuleLoader__.load({
1160
1402
  /**
1161
1403
  * Decode one stored context-compression settings document with exactly the
1162
1404
  * runtime schema's strictness: a plain object with only `profile`, `custom`,
1163
- * `autoCompact`, and `codeSkeleton` keys, a supported profile, a valid Custom
1405
+ * `autoCompact`, `codeSkeleton`, and `intentSummary` keys, a supported profile, a valid Custom
1164
1406
  * document canonicalized to v3 exactly as the runtime resolver would, a
1165
1407
  * strictly-shaped autoCompact section (absent inherits the 80% default), and
1166
1408
  * a strictly-shaped codeSkeleton gate (absent inherits off). Anything else
@@ -1169,17 +1411,19 @@ window.__ModuleLoader__.load({
1169
1411
  */
1170
1412
  function decodeSettings(value) {
1171
1413
  if (!isPlainRecord(value)) return void 0;
1172
- if (Object.keys(value).some((key) => key !== "profile" && key !== "custom" && key !== "autoCompact" && key !== "codeSkeleton" && key !== "presetOptions")) return;
1414
+ if (Object.keys(value).some((key) => key !== "profile" && key !== "custom" && key !== "autoCompact" && key !== "codeSkeleton" && key !== "intentSummary" && key !== "presetOptions")) return;
1173
1415
  const profile = value.profile;
1174
1416
  const custom = value.custom;
1175
1417
  const autoCompact = decodeAutoCompactSettings(value.autoCompact);
1176
1418
  const codeSkeleton = decodeCodeSkeletonSettings(value.codeSkeleton);
1419
+ const intentSummary = decodeIntentSummarySettings(value.intentSummary);
1177
1420
  const presetOptions = decodePresetOptionsSettings(value.presetOptions);
1178
- return typeof profile === "string" && COMPRESSION_PROFILES.includes(profile) && isCustomCompressionPolicy(custom) && autoCompact !== void 0 && codeSkeleton !== void 0 ? {
1421
+ return typeof profile === "string" && COMPRESSION_PROFILES.includes(profile) && isCustomCompressionPolicy(custom) && autoCompact !== void 0 && codeSkeleton !== void 0 && intentSummary !== void 0 ? {
1179
1422
  profile,
1180
1423
  custom: canonicalizeCustomPolicy(custom),
1181
1424
  autoCompact,
1182
1425
  codeSkeleton,
1426
+ intentSummary,
1183
1427
  ...presetOptions === void 0 ? {} : { presetOptions }
1184
1428
  } : void 0;
1185
1429
  }
@@ -1249,6 +1493,11 @@ window.__ModuleLoader__.load({
1249
1493
  "codeSkeleton.enabled": "代码骨架压缩",
1250
1494
  "codeSkeleton.enabled.on": "开",
1251
1495
  "codeSkeleton.enabled.off": "关(默认)",
1496
+ "intentSummary.title": "回合末意图摘要(转向尾部压缩)",
1497
+ "intentSummary.description": "开启后,回合收尾阶段把本次消费的增量按语义角色折叠为意图摘要块:读类工具结果压成单行目标/规模记录,写类保留骨架头与逐字错误行,于下一次压力回合经既有折叠管线落地;仅当增长门控通过(活跃表面 >45% 且距上次折叠增长 >50K token)才触发。修改只影响新会话;当前会话可用 /ctx-summary off|on|status 临时覆盖。",
1498
+ "intentSummary.enabled": "回合末意图摘要",
1499
+ "intentSummary.enabled.on": "开",
1500
+ "intentSummary.enabled.off": "关(默认)",
1252
1501
  "custom.title": "Custom 策略",
1253
1502
  "custom.settingsHint": "具体参数请前往“设置 > 上下文压缩选择器”中编辑。",
1254
1503
  "custom.sessionScope": "保存后的修改会在当前压缩运行时随后首次观察某个 Session 时生效;已被该运行时观察的 Session 继续使用其冻结策略。",
@@ -1279,7 +1528,21 @@ window.__ModuleLoader__.load({
1279
1528
  "custom.tailTrim.warning": "TailTrim 只在精确 tokenizer 可用时,把一个完整、已结束且非错误的纯工具组替换为可恢复引用;它与 History 共用近期工具调用数、工具结果尾窗和最小回收参数。它会改写已发送前缀,可能降低缓存命中。",
1280
1529
  "custom.save": "保存 Custom 策略",
1281
1530
  "custom.reset": "重置 Custom 策略",
1282
- "custom.invalid": "Custom 策略参数无效。"
1531
+ "custom.invalid": "Custom 策略参数无效。",
1532
+ "savings.title": "节省统计(本进程)",
1533
+ "savings.netExact": "净节省(精确口径)",
1534
+ "savings.netEstimated": "净节省(估算口径)",
1535
+ "savings.gross": "毛节省(压缩落盘时)",
1536
+ "savings.offsets": "负节省(压缩后再读全文的抵消)",
1537
+ "savings.empty": "尚无压缩记录——发生首次裁剪后这里会显示净节省。",
1538
+ "savings.basisExact": "精确",
1539
+ "savings.basisEstimated": "估算",
1540
+ "savings.basisNote": "口径分列不混算:精确 = DeepSeek tokenizer;估算 = chars/4。先取骨架后取全文会计负节省(净额可能为负)。",
1541
+ "savings.requests": "请求轮次",
1542
+ "savings.cacheHit": "缓存命中率",
1543
+ "savings.actualCost": "实际成本(官方牌价)",
1544
+ "savings.savedMoney": "估算节省金额(按输入价)",
1545
+ "savings.perSession": "会话"
1283
1546
  };
1284
1547
  /** English copy matching every simplified Chinese selector key. */
1285
1548
  const en = {
@@ -1345,6 +1608,11 @@ window.__ModuleLoader__.load({
1345
1608
  "codeSkeleton.enabled": "Code skeleton compression",
1346
1609
  "codeSkeleton.enabled.on": "On",
1347
1610
  "codeSkeleton.enabled.off": "Off (default)",
1611
+ "intentSummary.title": "Turn-tail intent summary",
1612
+ "intentSummary.description": "When on, the turn-boundary postflight folds the consumed increment into intent-summary blocks by semantic role: read-class tool results become one-line target/scale records and write-class keep skeleton heads plus verbatim error lines, landing on the next pressure round through the ordinary fold pipeline. Only fires when the growth gate passes (live surface >45% and >50K tokens grown since the last fold). Applies to new sessions; override the current one with /ctx-summary off|on|status.",
1613
+ "intentSummary.enabled": "Turn-tail intent summary",
1614
+ "intentSummary.enabled.on": "On",
1615
+ "intentSummary.enabled.off": "Off (default)",
1348
1616
  "custom.title": "Custom policy",
1349
1617
  "custom.settingsHint": "Edit detailed parameters in Settings > Context compression selector.",
1350
1618
  "custom.sessionScope": "Saved changes apply when the current compression runtime next observes a Session for the first time. A Session already observed by that runtime keeps its frozen policy.",
@@ -1375,7 +1643,21 @@ window.__ModuleLoader__.load({
1375
1643
  "custom.tailTrim.warning": "TailTrim requires the exact tokenizer and replaces at most one complete, finished, non-error tool-only group with a recoverable reference. It shares Protected recent tool calls, Protected recent tool-result tail, and Minimum reclaim with History. It rewrites a sent prefix and may reduce cache hits.",
1376
1644
  "custom.save": "Save Custom policy",
1377
1645
  "custom.reset": "Reset Custom policy",
1378
- "custom.invalid": "Custom policy values are invalid."
1646
+ "custom.invalid": "Custom policy values are invalid.",
1647
+ "savings.title": "Savings (this process)",
1648
+ "savings.netExact": "Net saved (exact basis)",
1649
+ "savings.netEstimated": "Net saved (estimated basis)",
1650
+ "savings.gross": "Gross saved (at publish time)",
1651
+ "savings.offsets": "Offsets (compressed content re-read in full)",
1652
+ "savings.empty": "No compression yet — net savings appear after the first reduction lands.",
1653
+ "savings.basisExact": "exact",
1654
+ "savings.basisEstimated": "estimated",
1655
+ "savings.basisNote": "Bases are reported separately, never merged: exact = DeepSeek tokenizer; estimated = chars/4. A skeleton followed by a full read counts as negative savings (net can go below zero).",
1656
+ "savings.requests": "Requests",
1657
+ "savings.cacheHit": "Cache hit rate",
1658
+ "savings.actualCost": "Actual cost (official prices)",
1659
+ "savings.savedMoney": "Estimated saved cost (input price)",
1660
+ "savings.perSession": "Session"
1379
1661
  };
1380
1662
  //#endregion
1381
1663
  //#region src/client/locales/de.ts
@@ -1443,6 +1725,11 @@ window.__ModuleLoader__.load({
1443
1725
  "codeSkeleton.enabled": "Code-Skelettkomprimierung",
1444
1726
  "codeSkeleton.enabled.on": "Ein",
1445
1727
  "codeSkeleton.enabled.off": "Aus (Standard)",
1728
+ "intentSummary.title": "Abschluss-Zusammenfassung (Turn-Tail)",
1729
+ "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.",
1730
+ "intentSummary.enabled": "Abschluss-Zusammenfassung",
1731
+ "intentSummary.enabled.on": "Ein",
1732
+ "intentSummary.enabled.off": "Aus (Standard)",
1446
1733
  "custom.title": "Eigene Strategie",
1447
1734
  "custom.settingsHint": "Detaillierte Parameter unter Einstellungen > Kontextkomprimierung wählen bearbeiten.",
1448
1735
  "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.",
@@ -1473,7 +1760,21 @@ window.__ModuleLoader__.load({
1473
1760
  "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.",
1474
1761
  "custom.save": "Eigene Strategie speichern",
1475
1762
  "custom.reset": "Eigene Strategie zurücksetzen",
1476
- "custom.invalid": "Werte der eigenen Strategie sind ungültig."
1763
+ "custom.invalid": "Werte der eigenen Strategie sind ungültig.",
1764
+ "savings.title": "Einsparungen (dieser Prozess)",
1765
+ "savings.netExact": "Netto gespeichert (exakte Basis)",
1766
+ "savings.netEstimated": "Netto gespeichert (geschätzte Basis)",
1767
+ "savings.gross": "Brutto gespeichert (bei Veröffentlichung)",
1768
+ "savings.offsets": "Abschläge (komprimiert, später vollständig gelesen)",
1769
+ "savings.empty": "Noch keine Komprimierung — Nettoeinsparungen erscheinen nach der ersten Reduktion.",
1770
+ "savings.basisExact": "exakt",
1771
+ "savings.basisEstimated": "geschätzt",
1772
+ "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).",
1773
+ "savings.requests": "Requests",
1774
+ "savings.cacheHit": "Cache hit rate",
1775
+ "savings.actualCost": "Actual cost (official prices)",
1776
+ "savings.savedMoney": "Estimated saved cost (input price)",
1777
+ "savings.perSession": "Session"
1477
1778
  };
1478
1779
  //#endregion
1479
1780
  //#region src/client/locales/es.ts
@@ -1541,6 +1842,11 @@ window.__ModuleLoader__.load({
1541
1842
  "codeSkeleton.enabled": "Compresión de esqueleto del código",
1542
1843
  "codeSkeleton.enabled.on": "Activado",
1543
1844
  "codeSkeleton.enabled.off": "Desactivado (predeterminado)",
1845
+ "intentSummary.title": "Resumen de intención al cierre del turno",
1846
+ "intentSummary.description": "Al activarlo, el postflight de cierre de turno pliega el incremento consumido en bloques de resumen de intención por rol semántico: los resultados de herramientas de lectura se convierten en registros de una línea con objetivo/escala y los de escritura conservan la cabecera de esqueleto más las líneas de error textuales; aterriza en la siguiente ronda de presión por el conducto de plegado normal. Solo se dispara si se supera la puerta de crecimiento (superficie activa >45 % y >50K tokens desde el último plegado). Aplica a sesiones nuevas; la actual se gobierna con /ctx-summary off|on|status.",
1847
+ "intentSummary.enabled": "Resumen de intención al cierre",
1848
+ "intentSummary.enabled.on": "Sí",
1849
+ "intentSummary.enabled.off": "No (predeterminado)",
1544
1850
  "custom.title": "Política personalizada",
1545
1851
  "custom.settingsHint": "Edita los parámetros detallados en Ajustes > Selector de compresión de contexto.",
1546
1852
  "custom.sessionScope": "Los cambios guardados se aplican cuando el runtime de compresión actual observa una Session por primera vez. Una Session ya observada por ese runtime conserva su política congelada.",
@@ -1571,7 +1877,21 @@ window.__ModuleLoader__.load({
1571
1877
  "custom.tailTrim.warning": "TailTrim requiere el tokenizador exacto y sustituye como máximo un grupo completo, terminado y sin errores compuesto solo por herramientas por una referencia recuperable. Comparte con History las llamadas a herramientas recientes protegidas, la cola reciente de resultados de herramientas protegida y la recuperación mínima. Reescribe un prefijo enviado y puede reducir los aciertos de caché.",
1572
1878
  "custom.save": "Guardar la política personalizada",
1573
1879
  "custom.reset": "Restablecer la política personalizada",
1574
- "custom.invalid": "Los valores de la política personalizada no son válidos."
1880
+ "custom.invalid": "Los valores de la política personalizada no son válidos.",
1881
+ "savings.title": "Ahorro (este proceso)",
1882
+ "savings.netExact": "Ahorro neto (base exacta)",
1883
+ "savings.netEstimated": "Ahorro neto (base estimada)",
1884
+ "savings.gross": "Ahorro bruto (al publicar)",
1885
+ "savings.offsets": "Compensaciones (contenido comprimido y luego releído completo)",
1886
+ "savings.empty": "Aún sin compresión: el ahorro neto aparece tras la primera reducción.",
1887
+ "savings.basisExact": "exacta",
1888
+ "savings.basisEstimated": "estimada",
1889
+ "savings.basisNote": "Las bases se informan por separado, nunca mezcladas: exacta = tokenizador DeepSeek; estimada = chars/4. Esqueleto seguido de lectura completa cuenta como ahorro negativo (el neto puede ser negativo).",
1890
+ "savings.requests": "Anfragen",
1891
+ "savings.cacheHit": "Cache-Trefferquote",
1892
+ "savings.actualCost": "Tatsächliche Kosten (offizielle Preise)",
1893
+ "savings.savedMoney": "Geschätzte Einsparung (Eingabepreis)",
1894
+ "savings.perSession": "Sitzung"
1575
1895
  };
1576
1896
  //#endregion
1577
1897
  //#region src/client/locales/fr.ts
@@ -1639,6 +1959,11 @@ window.__ModuleLoader__.load({
1639
1959
  "codeSkeleton.enabled": "Compression du code en squelette",
1640
1960
  "codeSkeleton.enabled.on": "Activé",
1641
1961
  "codeSkeleton.enabled.off": "Désactivé (par défaut)",
1962
+ "intentSummary.title": "Résumé d'intention en fin de tour",
1963
+ "intentSummary.description": "Activé, le postflight de fin de tour plie l'incrément consommé en blocs de résumé d'intention par rôle sémantique : les résultats d'outils de lecture deviennent des enregistrements une-ligne objectif/échelle, les écrits gardent la tête de squelette plus les lignes d'erreur verbatim ; l'atterrissage se fait au prochain tour de pression via le pipeline de pliage habituel. Ne se déclenche que si la porte de croissance passe (surface active >45 % et >50K tokens depuis le dernier pliage). S'applique aux nouvelles sessions ; la session courante se pilote avec /ctx-summary off|on|status.",
1964
+ "intentSummary.enabled": "Résumé d'intention en fin de tour",
1965
+ "intentSummary.enabled.on": "Activé",
1966
+ "intentSummary.enabled.off": "Désactivé (par défaut)",
1642
1967
  "custom.title": "Stratégie personnalisée",
1643
1968
  "custom.settingsHint": "Modifiez les paramètres détaillés dans Réglages > Sélecteur de compression du contexte.",
1644
1969
  "custom.sessionScope": "Les changements enregistrés s’appliquent quand le runtime de compression actuel observe une Session pour la première fois. Une Session déjà observée par ce runtime garde sa stratégie figée.",
@@ -1669,7 +1994,21 @@ window.__ModuleLoader__.load({
1669
1994
  "custom.tailTrim.warning": "TailTrim exige le tokenizer exact et remplace au plus un groupe complet, terminé et sans erreur, composé uniquement d’outils, par une référence récupérable. Il partage avec History les appels d’outils récents protégés, la fin récente des résultats d’outils protégée et la récupération minimale. Il réécrit un préfixe envoyé et peut réduire les hits de cache.",
1670
1995
  "custom.save": "Enregistrer la stratégie personnalisée",
1671
1996
  "custom.reset": "Réinitialiser la stratégie personnalisée",
1672
- "custom.invalid": "Valeurs de la stratégie personnalisée invalides."
1997
+ "custom.invalid": "Valeurs de la stratégie personnalisée invalides.",
1998
+ "savings.title": "Économies (ce processus)",
1999
+ "savings.netExact": "Économie nette (base exacte)",
2000
+ "savings.netEstimated": "Économie nette (base estimée)",
2001
+ "savings.gross": "Économie brute (à la publication)",
2002
+ "savings.offsets": "Compensations (contenu compressé puis relu intégralement)",
2003
+ "savings.empty": "Aucune compression pour l’instant — l’économie nette apparaît après la première réduction.",
2004
+ "savings.basisExact": "exacte",
2005
+ "savings.basisEstimated": "estimée",
2006
+ "savings.basisNote": "Les bases sont présentées séparément, jamais mélangées : exacte = tokenizer DeepSeek ; estimée = chars/4. Un squelette suivi d’une lecture complète compte comme économie négative (le net peut être négatif).",
2007
+ "savings.requests": "Solicitudes",
2008
+ "savings.cacheHit": "Tasa de aciertos de caché",
2009
+ "savings.actualCost": "Coste real (precios oficiales)",
2010
+ "savings.savedMoney": "Ahorro estimado (precio de entrada)",
2011
+ "savings.perSession": "Sesión"
1673
2012
  };
1674
2013
  //#endregion
1675
2014
  //#region src/client/locales/it.ts
@@ -1737,6 +2076,11 @@ window.__ModuleLoader__.load({
1737
2076
  "codeSkeleton.enabled": "Compressione a scheletro del codice",
1738
2077
  "codeSkeleton.enabled.on": "Attivato",
1739
2078
  "codeSkeleton.enabled.off": "Disattivato (predefinito)",
2079
+ "intentSummary.title": "Riepilogo di intento a fine turno",
2080
+ "intentSummary.description": "Quando attivo, il postflight di fine turno piega l'incremento consumato in blocchi di riepilogo di intento per ruolo semantico: i risultati degli strumenti di lettura diventano record a riga singola obiettivo/scala, quelli di scrittura mantengono la testa dello scheletro più le righe di errore testuali; atterra al prossimo round di pressione tramite la pipeline di piegatura ordinaria. Si attiva solo se la soglia di crescita passa (superficie attiva >45% e >50K token dall'ultima piegatura). Vale per le nuove sessioni; quella corrente si governa con /ctx-summary off|on|status.",
2081
+ "intentSummary.enabled": "Riepilogo di intento a fine turno",
2082
+ "intentSummary.enabled.on": "On",
2083
+ "intentSummary.enabled.off": "Off (predefinito)",
1740
2084
  "custom.title": "Politica personalizzata",
1741
2085
  "custom.settingsHint": "Modifica i parametri dettagliati in Impostazioni > Selettore di compressione del contesto.",
1742
2086
  "custom.sessionScope": "Le modifiche salvate si applicano quando l’attuale runtime di compressione osserva una Sessione per la prima volta. Una Sessione già osservata da quel runtime mantiene la sua politica congelata.",
@@ -1767,7 +2111,21 @@ window.__ModuleLoader__.load({
1767
2111
  "custom.tailTrim.warning": "TailTrim richiede il tokenizer esatto e sostituisce al massimo un gruppo completo, concluso e senza errori composto solo da tool con un riferimento recuperabile. Condivide con History le chiamate ai tool recenti protette, la coda recente dei risultati dei tool protetta e il recupero minimo. Riscrive un prefisso inviato e può ridurre i hit della cache.",
1768
2112
  "custom.save": "Salva la politica personalizzata",
1769
2113
  "custom.reset": "Reimposta la politica personalizzata",
1770
- "custom.invalid": "I valori della politica personalizzata non sono validi."
2114
+ "custom.invalid": "I valori della politica personalizzata non sono validi.",
2115
+ "savings.title": "Risparmi (questo processo)",
2116
+ "savings.netExact": "Risparmio netto (base esatta)",
2117
+ "savings.netEstimated": "Risparmio netto (base stimata)",
2118
+ "savings.gross": "Risparmio lordo (alla pubblicazione)",
2119
+ "savings.offsets": "Compensazioni (contenuto compresso e poi riletto per intero)",
2120
+ "savings.empty": "Nessuna compressione — il risparmio netto appare dopo la prima riduzione.",
2121
+ "savings.basisExact": "esatta",
2122
+ "savings.basisEstimated": "stimata",
2123
+ "savings.basisNote": "Le basi sono riportate separatamente, mai miste: esatta = tokenizer DeepSeek; stimata = chars/4. Uno scheletro seguito dalla lettura completa conta come risparmio negativo (il netto può scendere sotto zero).",
2124
+ "savings.requests": "Requêtes",
2125
+ "savings.cacheHit": "Taux de cache",
2126
+ "savings.actualCost": "Coût réel (tarifs officiels)",
2127
+ "savings.savedMoney": "Économie estimée (prix d’entrée)",
2128
+ "savings.perSession": "Session"
1771
2129
  };
1772
2130
  //#endregion
1773
2131
  //#region src/client/locales/ja.ts
@@ -1835,6 +2193,11 @@ window.__ModuleLoader__.load({
1835
2193
  "codeSkeleton.enabled": "コードスケルトン圧縮",
1836
2194
  "codeSkeleton.enabled.on": "オン",
1837
2195
  "codeSkeleton.enabled.off": "オフ(既定)",
2196
+ "intentSummary.title": "ターン末尾インテント要約",
2197
+ "intentSummary.description": "有効にすると、ターン境界のポストフライトが消費済み増分を意味役割ごとにインテント要約ブロックへ折り畳みます。読み系ツール結果は目標/規模の 1 行レコードに、書き系は骨格ヘッダーと逐語エラー行を保持し、次の圧力ラウンドで通常の折り畳みパイプラインを通じて着地します。成長ゲート(ライブ表面 >45%、前回の折り畳みから >50K トークン増)を通過したときだけ発火します。変更は新セッションに適用され、現セッションは /ctx-summary off|on|status で上書きできます。",
2198
+ "intentSummary.enabled": "ターン末尾インテント要約",
2199
+ "intentSummary.enabled.on": "オン",
2200
+ "intentSummary.enabled.off": "オフ(既定)",
1838
2201
  "custom.title": "カスタムポリシー",
1839
2202
  "custom.settingsHint": "詳細パラメーターは「設定 > コンテキスト圧縮セレクター」で編集してください。",
1840
2203
  "custom.sessionScope": "保存した変更は、現在の圧縮ランタイムが次に Session を初めて観測したときに適用されます。そのランタイムに既に観測された Session は凍結済みポリシーを使い続けます。",
@@ -1865,7 +2228,21 @@ window.__ModuleLoader__.load({
1865
2228
  "custom.tailTrim.warning": "TailTrim は正確なトークナイザーが必要で、完全で終了済みかつエラーでないツールのみのグループを 1 つだけ回復可能な参照へ置き換えます。History と「保護する直近ツール呼び出し数」「保護するツール結果テール」「最小回収量」を共有します。送信済みプレフィックスを書き換えるため、キャッシュ命中が下がる可能性があります。",
1866
2229
  "custom.save": "カスタムポリシーを保存",
1867
2230
  "custom.reset": "カスタムポリシーをリセット",
1868
- "custom.invalid": "カスタムポリシーの値が不正です。"
2231
+ "custom.invalid": "カスタムポリシーの値が不正です。",
2232
+ "savings.title": "節約統計(このプロセス)",
2233
+ "savings.netExact": "純節約(正確口径)",
2234
+ "savings.netEstimated": "純節約(推定口径)",
2235
+ "savings.gross": "総節約(圧縮確定時)",
2236
+ "savings.offsets": "相殺(圧縮後に全文再読)",
2237
+ "savings.empty": "まだ圧縮がありません。最初の削減後に純節約が表示されます。",
2238
+ "savings.basisExact": "正確",
2239
+ "savings.basisEstimated": "推定",
2240
+ "savings.basisNote": "口径は分列し混算しません:正確 = DeepSeek トークナイザー、推定 = chars/4。スケルトン後に全文を読むと負の節約として計上されます(純額はマイナスになり得ます)。",
2241
+ "savings.requests": "Richieste",
2242
+ "savings.cacheHit": "Tasso di cache",
2243
+ "savings.actualCost": "Costo reale (prezzi ufficiali)",
2244
+ "savings.savedMoney": "Risparmio stimato (prezzo di input)",
2245
+ "savings.perSession": "Sessione"
1869
2246
  };
1870
2247
  //#endregion
1871
2248
  //#region src/client/locales/ko.ts
@@ -1933,6 +2310,11 @@ window.__ModuleLoader__.load({
1933
2310
  "codeSkeleton.enabled": "코드 스켈레톤 압축",
1934
2311
  "codeSkeleton.enabled.on": "켬",
1935
2312
  "codeSkeleton.enabled.off": "끔(기본값)",
2313
+ "intentSummary.title": "턴 말머리 인텐트 요약",
2314
+ "intentSummary.description": "켜면 턴 경계 포스트플라이트가 소비된 증분을 의미 역할별 인텐트 요약 블록으로 접습니다. 읽기 도구 결과는 목표/규모 한 줄 레코드가 되고 쓰기는 골격 헤더와 원문 오류 줄을 유지하며, 다음 압력 라운드에서 기존 접기 파이프라인을 통해 착지합니다. 성장 게이트(라이브 표면 >45%, 마지막 접기 이후 >50K 토큰 증가)를 통과할 때만 발동합니다. 새 세션에 적용되며, 현재 세션은 /ctx-summary off|on|status 로 임시 전환할 수 있습니다.",
2315
+ "intentSummary.enabled": "턴 말머리 인텐트 요약",
2316
+ "intentSummary.enabled.on": "켜기",
2317
+ "intentSummary.enabled.off": "끄기(기본)",
1936
2318
  "custom.title": "커스텀 정책",
1937
2319
  "custom.settingsHint": "세부 파라미터는 「설정 > 컨텍스트 압축 셀렉터」에서 편집하세요.",
1938
2320
  "custom.sessionScope": "저장된 변경 사항은 현재 압축 런타임이 Session을 처음 관측하는 시점에 적용됩니다. 해당 런타임이 이미 관측한 Session은 동결된 정책을 계속 사용합니다.",
@@ -1963,7 +2345,21 @@ window.__ModuleLoader__.load({
1963
2345
  "custom.tailTrim.warning": "TailTrim은 정확한 토크나이저를 필요로 하며, 완결되고 오류 없는 도구 전용 그룹 하나를 복구 가능한 참조로 대체합니다. History와 「보호하는 최근 도구 호출 수」「보호하는 도구 결과 테일」「최소 회수량」을 공유합니다. 전송 접두사를 재작성하므로 캐시 적중이 낮아질 수 있습니다.",
1964
2346
  "custom.save": "커스텀 정책 저장",
1965
2347
  "custom.reset": "커스텀 정책 초기화",
1966
- "custom.invalid": "커스텀 정책 값이 올바르지 않습니다."
2348
+ "custom.invalid": "커스텀 정책 값이 올바르지 않습니다.",
2349
+ "savings.title": "절감 통계(이 프로세스)",
2350
+ "savings.netExact": "순 절감(정확 기준)",
2351
+ "savings.netEstimated": "순 절감(추정 기준)",
2352
+ "savings.gross": "총 절감(게시 시점)",
2353
+ "savings.offsets": "상쇄(압축 후 전체 재판돈)",
2354
+ "savings.empty": "아직 압축이 없습니다. 첫 번째 축소 후 순 절감이 표시됩니다.",
2355
+ "savings.basisExact": "정확",
2356
+ "savings.basisEstimated": "추정",
2357
+ "savings.basisNote": "기준은 분리 표기하며 혼합하지 않습니다: 정확 = DeepSeek 토크나이저, 추정 = chars/4. 스켈레톤 후 전체 판독은 음의 절감으로 계산됩니다(순액은 마이너스 가능).",
2358
+ "savings.requests": "リクエスト数",
2359
+ "savings.cacheHit": "キャッシュ ヒット率",
2360
+ "savings.actualCost": "実際コスト(公式価格)",
2361
+ "savings.savedMoney": "推定節約額(入力価格)",
2362
+ "savings.perSession": "セッション"
1967
2363
  };
1968
2364
  //#endregion
1969
2365
  //#region src/client/locales/ru.ts
@@ -2031,6 +2427,11 @@ window.__ModuleLoader__.load({
2031
2427
  "codeSkeleton.enabled": "Скелетное сжатие кода",
2032
2428
  "codeSkeleton.enabled.on": "Вкл",
2033
2429
  "codeSkeleton.enabled.off": "Выкл (по умолчанию)",
2430
+ "intentSummary.title": "Итог намерения в конце хода",
2431
+ "intentSummary.description": "При включении постфлайт на границе хода сворачивает потреблённый прирост в блоки итогов намерения по семантическим ролям: результаты читающих инструментов становятся однострочными записями цель/масштаб, пишущие сохраняют заголовок скелета и дословные строки ошибок; приземляется в следующем раунде давления через обычный конвейер свёртки. Срабатывает только при прохождении шлюза роста (активная поверхность >45% и >50K токенов с последней свёртки). Действует на новые сессии; текущую можно переключить командой /ctx-summary off|on|status.",
2432
+ "intentSummary.enabled": "Итог намерения в конце хода",
2433
+ "intentSummary.enabled.on": "Вкл",
2434
+ "intentSummary.enabled.off": "Выкл (по умолчанию)",
2034
2435
  "custom.title": "Пользовательская стратегия",
2035
2436
  "custom.settingsHint": "Подробные параметры — в «Настройки > Выбор сжатия контекста».",
2036
2437
  "custom.sessionScope": "Сохранённые изменения применяются, когда текущий runtime сжатия впервые наблюдает Session. Session, уже наблюдаемая этим runtime, сохраняет свою замороженную стратегию.",
@@ -2061,7 +2462,21 @@ window.__ModuleLoader__.load({
2061
2462
  "custom.tailTrim.warning": "TailTrim требует точный токенизатор и заменяет максимум одну полную, завершённую, без ошибок группу только из инструментов на восстанавливаемую ссылку. Он использует общие с History защищённые недавние вызовы инструментов, защищённый недавний хвост результатов инструментов и минимальное освобождение. Он переписывает отправленный префикс и может снизить попадания в кэш.",
2062
2463
  "custom.save": "Сохранить пользовательскую стратегию",
2063
2464
  "custom.reset": "Сбросить пользовательскую стратегию",
2064
- "custom.invalid": "Значения пользовательской стратегии недопустимы."
2465
+ "custom.invalid": "Значения пользовательской стратегии недопустимы.",
2466
+ "savings.title": "Экономия (этот процесс)",
2467
+ "savings.netExact": "Чистая экономия (точная база)",
2468
+ "savings.netEstimated": "Чистая экономия (оценочная база)",
2469
+ "savings.gross": "Валовая экономия (при публикации)",
2470
+ "savings.offsets": "Компенсации (сжатый контент затем прочитан полностью)",
2471
+ "savings.empty": "Сжатия пока не было — чистая экономия появится после первого сокращения.",
2472
+ "savings.basisExact": "точно",
2473
+ "savings.basisEstimated": "оценка",
2474
+ "savings.basisNote": "Базы приводятся раздельно и не смешиваются: точно = токенизатор DeepSeek; оценка = chars/4. Скелет с последующим полным чтением учитывается как отрицательная экономия (чистая может уйти в минус).",
2475
+ "savings.requests": "요청 수",
2476
+ "savings.cacheHit": "캐시 적중률",
2477
+ "savings.actualCost": "실제 비용(공식 가격)",
2478
+ "savings.savedMoney": "추정 절감액(입력 가격)",
2479
+ "savings.perSession": "세션"
2065
2480
  };
2066
2481
  //#endregion
2067
2482
  //#region src/client/preset-options.ts
@@ -2273,6 +2688,7 @@ window.__ModuleLoader__.load({
2273
2688
  resetCustom: () => writeAndConfirm(() => scope.set("custom", structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY)), (settings) => isCustomCompressionPolicy(settings.custom) && sameCustomPolicy(settings.custom, DEFAULT_CUSTOM_COMPRESSION_POLICY)),
2274
2689
  saveAutoCompact: (thresholdPercent) => writeAndConfirm(() => scope.set("autoCompact", { thresholdPercent }), (settings) => settings.autoCompact.thresholdPercent === thresholdPercent),
2275
2690
  saveCodeSkeleton: (enabled) => writeAndConfirm(() => scope.set("codeSkeleton", { enabled }), (settings) => settings.codeSkeleton.enabled === enabled),
2691
+ saveIntentSummary: (enabled) => writeAndConfirm(() => scope.set("intentSummary", { enabled }), (settings) => settings.intentSummary.enabled === enabled),
2276
2692
  savePresetOptions: (options) => {
2277
2693
  const ops = planPresetOptionsOps(scope.getSnapshot().value?.presetOptions, options);
2278
2694
  if (ops.length === 0) return Promise.resolve();