dsh-context-compression-improved 0.8.0-beta.6 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  All notable changes use this file. The project follows semantic versioning after `0.1.0`.
4
4
 
5
+ ## 0.8.0 - 2026-10-02
6
+
7
+ > 0.2.0-beta 渠道(beta.3-beta.7)转正。本期主线功能(节省统计、意图摘要、
8
+ > 压缩监控悬浮球、会话绑定、上下文占用条、灾难性遗忘区建议压缩)已同步
9
+ > cherry-pick 到 compat/0.1.7 / compat/0.1.5 / compat/0.1.2 三条适配线。
10
+ > 各 beta 节保留于下方,内容即 0.8.0 的完整变更清单。
11
+
12
+ ## 0.8.0-beta.7 - 2026-10-02
13
+
14
+ ### Added
15
+
16
+ - **灾难性遗忘区建议压缩**: the monitor snapshot carries a `suggestion` block — when
17
+ observed context occupancy reaches `MONITOR_SUGGEST_PCT` (0.7, deliberately one notch
18
+ below the host Auto Compact default of 80%) the floating bubble lights up (breathing
19
+ tint) and the panel shows a localized hint recommending compression or history trimming.
20
+ - Context occupancy observation is decoupled from the intent-summary gate: every turn
21
+ records live tokens vs the auto-compact-derived window, so the occupancy bar and the
22
+ suggestion work even with intent summaries off (previously the bar stayed empty).
23
+
5
24
  ## 0.8.0-beta.6 - 2026-10-02
6
25
 
7
26
  ### Added
package/package.json CHANGED
@@ -1,163 +1,162 @@
1
- {
2
- "name": "dsh-context-compression-improved",
3
- "version": "0.8.0-beta.6",
4
- "publishConfig": {
5
- "tag": "dsh-0.2.0"
6
- },
7
- "type": "module",
8
- "main": "packages/selector/lib/index.js",
9
- "types": "packages/selector/lib/index.d.ts",
10
- "exports": {
11
- ".": {
12
- "types": "./packages/selector/lib/index.d.ts",
13
- "default": "./packages/selector/lib/index.js"
14
- },
15
- "./invariant": {
16
- "types": "./packages/selector/lib/invariant.d.ts",
17
- "default": "./packages/selector/lib/invariant.js"
18
- },
19
- "./pruner": {
20
- "types": "./packages/selector/lib/pruner.d.ts",
21
- "default": "./packages/selector/lib/pruner.js"
22
- },
23
- "./client": {
24
- "types": "./packages/selector/lib/client.d.ts",
25
- "default": "./packages/selector/lib/client.js"
26
- },
27
- "./package.json": "./package.json"
28
- },
29
- "dependencies": {
30
- "@deepseek-ai/schemastery": "3.18.4",
31
- "@huggingface/tokenizers": "0.1.3",
32
- "js-yaml": "^4.3.2"
33
- },
34
- "dsh": {
35
- "client": {
36
- "inject": [
37
- "@deepseek-ai/dsh-client-locale",
38
- "@deepseek-ai/dsh-client-ui-primitives",
39
- "@deepseek-ai/dsh-client-ui-slots",
40
- "@deepseek-ai/dsh-client-ui-settings"
41
- ],
42
- "platform": "web"
43
- },
44
- "bundle": {
45
- "patch": "./packages/selector/cordis.patch.yml"
46
- }
47
- },
48
- "license": "MIT",
49
- "repository": {
50
- "type": "git",
51
- "url": "git+https://github.com/drscrewdriver/dsh-context-compression-improved.git"
52
- },
53
- "packageManager": "pnpm@11.7.0",
54
- "engines": {
55
- "node": "^22.19.0 || >=24.0.0",
56
- "dsh": ">=0.2.0-rc.1 <0.2.1-0"
57
- },
58
- "scripts": {
59
- "build": "pnpm -r --if-present run bundle",
60
- "typecheck": "pnpm --filter dsh-context-compression-improved run bundle && pnpm --filter dsh-context-compression-improved run typecheck && pnpm run typecheck:tests",
61
- "typecheck:tests": "tsc --noEmit -p tsconfig.tests.json",
62
- "lint": "eslint packages scripts eslint.config.js",
63
- "lint:fix": "eslint packages scripts eslint.config.js --fix",
64
- "test": "vitest run",
65
- "test:watch": "vitest",
66
- "test:built": "vitest run --config vitest.built.config.ts",
67
- "test:e2e:packed": "node scripts/packed-install-e2e.mjs",
68
- "test:unit": "vitest run",
69
- "verify:release": "node scripts/verify-release.mjs",
70
- "pack:dry-run": "pnpm -r --if-present run pack:dry-run"
71
- },
72
- "peerDependencies": {
73
- "@deepseek-ai/dsh-client-locale": ">=0.2.0-rc.1 <0.2.1-0",
74
- "@deepseek-ai/dsh-client-ui-primitives": ">=0.2.0-rc.1 <0.2.1-0",
75
- "@deepseek-ai/dsh-client-ui-settings": ">=0.2.0-rc.1 <0.2.1-0",
76
- "@deepseek-ai/dsh-client-ui-slots": ">=0.2.0-rc.1 <0.2.1-0"
77
- },
78
- "peerDependenciesMeta": {
79
- "@deepseek-ai/dsh-client-locale": {
80
- "optional": true
81
- },
82
- "@deepseek-ai/dsh-client-ui-primitives": {
83
- "optional": true
84
- },
85
- "@deepseek-ai/dsh-client-ui-settings": {
86
- "optional": true
87
- },
88
- "@deepseek-ai/dsh-client-ui-slots": {
89
- "optional": true
90
- }
91
- },
92
- "devDependencies": {
93
- "@deepseek-ai/cordis": "4.0.1",
94
- "@deepseek-ai/cordis-plugin-group": "1.0.1",
95
- "@deepseek-ai/cordis-plugin-include": "1.0.6",
96
- "@deepseek-ai/cordis-plugin-loader": "1.0.2",
97
- "@deepseek-ai/dsh-agent": "0.2.0-rc.1",
98
- "@deepseek-ai/dsh-agent-loop": "0.2.0-rc.1",
99
- "@deepseek-ai/dsh-agent-loop-testkit": "0.2.0-rc.1",
100
- "@deepseek-ai/dsh-agent-presets": "0.1.6-alpha.2",
101
- "@deepseek-ai/dsh-anonymous-user-id": "0.2.0-rc.1",
102
- "@deepseek-ai/dsh-api-remotes": "0.2.0-rc.1",
103
- "@deepseek-ai/dsh-api-session-controller": "0.2.0-rc.1",
104
- "@deepseek-ai/dsh-atomic-write": "0.2.0-rc.1",
105
- "@deepseek-ai/dsh-attachment": "0.2.0-rc.1",
106
- "@deepseek-ai/dsh-client-locale": "0.2.0-rc.1",
107
- "@deepseek-ai/dsh-client-store": "0.2.0-rc.1",
108
- "@deepseek-ai/dsh-client-ui-primitives": "0.2.0-rc.1",
109
- "@deepseek-ai/dsh-client-ui-session": "0.2.0-rc.1",
110
- "@deepseek-ai/dsh-client-ui-settings": "0.2.0-rc.1",
111
- "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.1",
112
- "@deepseek-ai/dsh-client-ui-workspace": "0.2.0-rc.1",
113
- "@deepseek-ai/dsh-code-runtime": "0.1.5-rc.3",
114
- "@deepseek-ai/dsh-command-compact": "0.2.0-rc.1",
115
- "@deepseek-ai/dsh-commands": "0.2.0-rc.1",
116
- "@deepseek-ai/dsh-compaction": "0.2.0-rc.1",
117
- "@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.1",
118
- "@deepseek-ai/dsh-cordis-host-runner": "0.2.0-rc.1",
119
- "@deepseek-ai/dsh-credentials": "0.2.0-rc.1",
120
- "@deepseek-ai/dsh-goal": "0.2.0-rc.1",
121
- "@deepseek-ai/dsh-home-paths": "0.2.0-rc.1",
122
- "@deepseek-ai/dsh-host-plugin-inventory": "0.2.0-rc.1",
123
- "@deepseek-ai/dsh-invariants": "0.2.0-rc.1",
124
- "@deepseek-ai/dsh-jobs": "0.2.0-rc.1",
125
- "@deepseek-ai/dsh-launch-environment": "0.2.0-rc.1",
126
- "@deepseek-ai/dsh-llm": "0.2.0-rc.1",
127
- "@deepseek-ai/dsh-llm-deepseek": "0.2.0-rc.1",
128
- "@deepseek-ai/dsh-llm-retry": "0.2.0-rc.1",
129
- "@deepseek-ai/dsh-message-feedback": "0.2.0-rc.1",
130
- "@deepseek-ai/dsh-sandbox": "0.2.0-rc.1",
131
- "@deepseek-ai/dsh-scope": "0.2.0-rc.1",
132
- "@deepseek-ai/dsh-session": "0.2.0-rc.1",
133
- "@deepseek-ai/dsh-session-persistence": "0.2.0-rc.1",
134
- "@deepseek-ai/dsh-session-projection": "0.2.0-rc.1",
135
- "@deepseek-ai/dsh-settings": "0.2.0-rc.1",
136
- "@deepseek-ai/dsh-subagent": "0.2.0-rc.1",
137
- "@deepseek-ai/dsh-subagent-fork-in-process": "0.2.0-rc.1",
138
- "@deepseek-ai/dsh-subagent-in-process-driver": "0.2.0-rc.1",
139
- "@deepseek-ai/dsh-subagent-spawn-in-process": "0.2.0-rc.1",
140
- "@deepseek-ai/dsh-system-prompt": "0.2.0-rc.1",
141
- "@deepseek-ai/dsh-token-meter": "0.2.0-rc.1",
142
- "@deepseek-ai/dsh-tools": "0.2.0-rc.1",
143
- "@deepseek-ai/dsh-user-approval": "0.2.0-rc.1",
144
- "@deepseek-ai/dsh-user-questions": "0.2.0-rc.1",
145
- "@deepseek-ai/schemastery": "3.18.4",
146
- "@eslint/js": "^10.0.1",
147
- "@testing-library/react": "^16.3.2",
148
- "@tsdown/css": "^0.22.14",
149
- "@types/js-yaml": "^4.0.9",
150
- "@types/node": "^22.20.0",
151
- "@types/react": "~18.3.1",
152
- "eslint": "^10.10.0",
153
- "globals": "^17.12.0",
154
- "jsdom": "29.1.1",
155
- "lightningcss": "^1.33.0",
156
- "react": "^18.2.0",
157
- "react-dom": "^18.2.0",
158
- "tsdown": "^0.22.2",
159
- "typescript": "^6.0.3",
160
- "typescript-eslint": "^8.69.0",
161
- "vitest": "^4.1.8"
162
- }
163
- }
1
+ {
2
+ "name": "dsh-context-compression-improved",
3
+ "version": "0.8.0",
4
+ "publishConfig": {
5
+ "tag": "dsh-0.2.0"
6
+ },
7
+ "type": "module",
8
+ "main": "packages/selector/lib/index.js",
9
+ "types": "packages/selector/lib/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./packages/selector/lib/index.d.ts",
13
+ "default": "./packages/selector/lib/index.js"
14
+ },
15
+ "./invariant": {
16
+ "types": "./packages/selector/lib/invariant.d.ts",
17
+ "default": "./packages/selector/lib/invariant.js"
18
+ },
19
+ "./pruner": {
20
+ "types": "./packages/selector/lib/pruner.d.ts",
21
+ "default": "./packages/selector/lib/pruner.js"
22
+ },
23
+ "./client": {
24
+ "types": "./packages/selector/lib/client.d.ts",
25
+ "default": "./packages/selector/lib/client.js"
26
+ },
27
+ "./package.json": "./package.json"
28
+ },
29
+ "dependencies": {
30
+ "@deepseek-ai/schemastery": "3.18.4",
31
+ "@huggingface/tokenizers": "0.1.3",
32
+ "js-yaml": "^4.3.2"
33
+ },
34
+ "dsh": {
35
+ "client": {
36
+ "inject": [
37
+ "@deepseek-ai/dsh-client-locale",
38
+ "@deepseek-ai/dsh-client-ui-primitives",
39
+ "@deepseek-ai/dsh-client-ui-slots",
40
+ "@deepseek-ai/dsh-client-ui-settings"
41
+ ],
42
+ "platform": "web"
43
+ },
44
+ "bundle": {
45
+ "patch": "./packages/selector/cordis.patch.yml"
46
+ }
47
+ },
48
+ "license": "MIT",
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/drscrewdriver/dsh-context-compression-improved.git"
52
+ },
53
+ "engines": {
54
+ "node": "^22.19.0 || >=24.0.0",
55
+ "dsh": ">=0.2.0-rc.1 <0.2.1-0"
56
+ },
57
+ "peerDependencies": {
58
+ "@deepseek-ai/dsh-client-locale": ">=0.2.0-rc.1 <0.2.1-0",
59
+ "@deepseek-ai/dsh-client-ui-primitives": ">=0.2.0-rc.1 <0.2.1-0",
60
+ "@deepseek-ai/dsh-client-ui-settings": ">=0.2.0-rc.1 <0.2.1-0",
61
+ "@deepseek-ai/dsh-client-ui-slots": ">=0.2.0-rc.1 <0.2.1-0"
62
+ },
63
+ "peerDependenciesMeta": {
64
+ "@deepseek-ai/dsh-client-locale": {
65
+ "optional": true
66
+ },
67
+ "@deepseek-ai/dsh-client-ui-primitives": {
68
+ "optional": true
69
+ },
70
+ "@deepseek-ai/dsh-client-ui-settings": {
71
+ "optional": true
72
+ },
73
+ "@deepseek-ai/dsh-client-ui-slots": {
74
+ "optional": true
75
+ }
76
+ },
77
+ "devDependencies": {
78
+ "@deepseek-ai/cordis": "4.0.1",
79
+ "@deepseek-ai/cordis-plugin-group": "1.0.1",
80
+ "@deepseek-ai/cordis-plugin-include": "1.0.6",
81
+ "@deepseek-ai/cordis-plugin-loader": "1.0.2",
82
+ "@deepseek-ai/dsh-agent": "0.2.0-rc.1",
83
+ "@deepseek-ai/dsh-agent-loop": "0.2.0-rc.1",
84
+ "@deepseek-ai/dsh-agent-loop-testkit": "0.2.0-rc.1",
85
+ "@deepseek-ai/dsh-agent-presets": "0.1.6-alpha.2",
86
+ "@deepseek-ai/dsh-anonymous-user-id": "0.2.0-rc.1",
87
+ "@deepseek-ai/dsh-api-remotes": "0.2.0-rc.1",
88
+ "@deepseek-ai/dsh-api-session-controller": "0.2.0-rc.1",
89
+ "@deepseek-ai/dsh-atomic-write": "0.2.0-rc.1",
90
+ "@deepseek-ai/dsh-attachment": "0.2.0-rc.1",
91
+ "@deepseek-ai/dsh-client-locale": "0.2.0-rc.1",
92
+ "@deepseek-ai/dsh-client-store": "0.2.0-rc.1",
93
+ "@deepseek-ai/dsh-client-ui-primitives": "0.2.0-rc.1",
94
+ "@deepseek-ai/dsh-client-ui-session": "0.2.0-rc.1",
95
+ "@deepseek-ai/dsh-client-ui-settings": "0.2.0-rc.1",
96
+ "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.1",
97
+ "@deepseek-ai/dsh-client-ui-workspace": "0.2.0-rc.1",
98
+ "@deepseek-ai/dsh-code-runtime": "0.1.5-rc.3",
99
+ "@deepseek-ai/dsh-command-compact": "0.2.0-rc.1",
100
+ "@deepseek-ai/dsh-commands": "0.2.0-rc.1",
101
+ "@deepseek-ai/dsh-compaction": "0.2.0-rc.1",
102
+ "@deepseek-ai/dsh-compaction-basic": "0.2.0-rc.1",
103
+ "@deepseek-ai/dsh-cordis-host-runner": "0.2.0-rc.1",
104
+ "@deepseek-ai/dsh-credentials": "0.2.0-rc.1",
105
+ "@deepseek-ai/dsh-goal": "0.2.0-rc.1",
106
+ "@deepseek-ai/dsh-home-paths": "0.2.0-rc.1",
107
+ "@deepseek-ai/dsh-host-plugin-inventory": "0.2.0-rc.1",
108
+ "@deepseek-ai/dsh-invariants": "0.2.0-rc.1",
109
+ "@deepseek-ai/dsh-jobs": "0.2.0-rc.1",
110
+ "@deepseek-ai/dsh-launch-environment": "0.2.0-rc.1",
111
+ "@deepseek-ai/dsh-llm": "0.2.0-rc.1",
112
+ "@deepseek-ai/dsh-llm-deepseek": "0.2.0-rc.1",
113
+ "@deepseek-ai/dsh-llm-retry": "0.2.0-rc.1",
114
+ "@deepseek-ai/dsh-message-feedback": "0.2.0-rc.1",
115
+ "@deepseek-ai/dsh-sandbox": "0.2.0-rc.1",
116
+ "@deepseek-ai/dsh-scope": "0.2.0-rc.1",
117
+ "@deepseek-ai/dsh-session": "0.2.0-rc.1",
118
+ "@deepseek-ai/dsh-session-persistence": "0.2.0-rc.1",
119
+ "@deepseek-ai/dsh-session-projection": "0.2.0-rc.1",
120
+ "@deepseek-ai/dsh-settings": "0.2.0-rc.1",
121
+ "@deepseek-ai/dsh-subagent": "0.2.0-rc.1",
122
+ "@deepseek-ai/dsh-subagent-fork-in-process": "0.2.0-rc.1",
123
+ "@deepseek-ai/dsh-subagent-in-process-driver": "0.2.0-rc.1",
124
+ "@deepseek-ai/dsh-subagent-spawn-in-process": "0.2.0-rc.1",
125
+ "@deepseek-ai/dsh-system-prompt": "0.2.0-rc.1",
126
+ "@deepseek-ai/dsh-token-meter": "0.2.0-rc.1",
127
+ "@deepseek-ai/dsh-tools": "0.2.0-rc.1",
128
+ "@deepseek-ai/dsh-user-approval": "0.2.0-rc.1",
129
+ "@deepseek-ai/dsh-user-questions": "0.2.0-rc.1",
130
+ "@deepseek-ai/schemastery": "3.18.4",
131
+ "@eslint/js": "^10.0.1",
132
+ "@testing-library/react": "^16.3.2",
133
+ "@tsdown/css": "^0.22.14",
134
+ "@types/js-yaml": "^4.0.9",
135
+ "@types/node": "^22.20.0",
136
+ "@types/react": "~18.3.1",
137
+ "eslint": "^10.10.0",
138
+ "globals": "^17.12.0",
139
+ "jsdom": "29.1.1",
140
+ "lightningcss": "^1.33.0",
141
+ "react": "^18.2.0",
142
+ "react-dom": "^18.2.0",
143
+ "tsdown": "^0.22.2",
144
+ "typescript": "^6.0.3",
145
+ "typescript-eslint": "^8.69.0",
146
+ "vitest": "^4.1.8"
147
+ },
148
+ "scripts": {
149
+ "build": "pnpm -r --if-present run bundle",
150
+ "typecheck": "pnpm --filter dsh-context-compression-improved run bundle && pnpm --filter dsh-context-compression-improved run typecheck && pnpm run typecheck:tests",
151
+ "typecheck:tests": "tsc --noEmit -p tsconfig.tests.json",
152
+ "lint": "eslint packages scripts eslint.config.js",
153
+ "lint:fix": "eslint packages scripts eslint.config.js --fix",
154
+ "test": "vitest run",
155
+ "test:watch": "vitest",
156
+ "test:built": "vitest run --config vitest.built.config.ts",
157
+ "test:e2e:packed": "node scripts/packed-install-e2e.mjs",
158
+ "test:unit": "vitest run",
159
+ "verify:release": "node scripts/verify-release.mjs",
160
+ "pack:dry-run": "pnpm -r --if-present run pack:dry-run"
161
+ }
162
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-context-compression-improved",
3
- "version": "0.8.0-beta.6",
3
+ "version": "0.8.0",
4
4
  "main": "./lib/index.js",
5
5
  "description": "Auditable tool-result context-compression selector with code-skeleton gate for DeepSeek Harness",
6
6
  "engines": {
@@ -82,6 +82,7 @@ declare const zh: {
82
82
  'monitor.panel.gross': string;
83
83
  'monitor.panel.offsets': string;
84
84
  'monitor.panel.context': string;
85
+ 'monitor.panel.suggest': string;
85
86
  'monitor.panel.cacheHit': string;
86
87
  'monitor.panel.cost': string;
87
88
  'monitor.panel.intent': string;
@@ -1543,6 +1543,9 @@ window.__ModuleLoader__.load({
1543
1543
  #${PANEL_ID} button.ghost { background: transparent; }
1544
1544
  #${PANEL_ID} button:disabled { opacity: .45; cursor: default; }
1545
1545
  #${PANEL_ID} .stale { padding: 4px 14px 8px; color: #ffd60a; display: none; }
1546
+ #${PANEL_ID} .hint { margin: 0; padding: 8px 14px; color: #ffd60a; display: none;
1547
+ border-bottom: 1px solid rgba(255,255,255,.09); }
1548
+ #${PANEL_ID} .hint.show { display: block; }
1546
1549
  #${PANEL_ID} .stale.show { display: block; }
1547
1550
  #${PANEL_ID} .recent { max-height: 132px; overflow: auto; padding: 2px 14px 8px;
1548
1551
  color: rgba(245,245,247,.8); white-space: pre-wrap; }
@@ -1559,6 +1562,7 @@ window.__ModuleLoader__.load({
1559
1562
  panel.hidden = true;
1560
1563
  panel.innerHTML = `
1561
1564
  <h4>${t("monitor.panel.title")}</h4>
1565
+ <div class="hint" data-hint></div>
1562
1566
  <div class="row"><span class="label">${t("monitor.panel.net")}</span><span data-net>–</span></div>
1563
1567
  <div class="row"><span class="label">${t("monitor.panel.gross")}</span><span data-gross class="muted">–</span></div>
1564
1568
  <div class="row"><span class="label">${t("monitor.panel.offsets")}</span><span data-offsets class="muted">–</span></div>
@@ -1664,9 +1668,16 @@ window.__ModuleLoader__.load({
1664
1668
  const render = (snap) => {
1665
1669
  const net = num(snap.net?.exact) + num(snap.net?.estimated);
1666
1670
  const netEl = panel.querySelector("[data-net]");
1667
- netEl.textContent = `${net >= 0 ? "" : ""}${fmtTokens(snap.net?.exact)}${num(snap.net?.estimated) > 0 ? ` (+${fmtTokens(snap.net?.estimated)} est)` : ""}`;
1671
+ netEl.textContent = `${fmtTokens(snap.net?.exact)}${num(snap.net?.estimated) > 0 ? ` (+${fmtTokens(snap.net?.estimated)} est)` : ""}`;
1668
1672
  netEl.classList.toggle("neg", net < 0);
1669
- fab.classList.toggle("lit", net < 0);
1673
+ const suggest = snap.suggestion?.suggest === true;
1674
+ fab.classList.toggle("lit", suggest || net < 0);
1675
+ const hint = panel.querySelector("[data-hint]");
1676
+ if (suggest) {
1677
+ const pct = typeof snap.suggestion?.occupancyPct === "number" ? Math.round(snap.suggestion.occupancyPct * 100) : null;
1678
+ hint.textContent = t("monitor.panel.suggest").replace("{pct}", String(pct ?? "–"));
1679
+ hint.classList.add("show");
1680
+ } else hint.classList.remove("show");
1670
1681
  panel.querySelector("[data-gross]").textContent = fmtTokens(snap.gross?.exact);
1671
1682
  panel.querySelector("[data-offsets]").textContent = `-${fmtTokens(snap.offsets?.exact)}`;
1672
1683
  const ctxBar = panel.querySelector("[data-ctxbar]");
@@ -1824,6 +1835,7 @@ window.__ModuleLoader__.load({
1824
1835
  "monitor.panel.gross": "毛节省",
1825
1836
  "monitor.panel.offsets": "抵消",
1826
1837
  "monitor.panel.context": "上下文占用",
1838
+ "monitor.panel.suggest": "上下文占用已达 {pct}%——临近灾难性遗忘区,建议压缩或裁剪历史",
1827
1839
  "monitor.panel.cacheHit": "缓存命中率",
1828
1840
  "monitor.panel.cost": "成本(实际 / 省估)",
1829
1841
  "monitor.panel.intent": "意图摘要",
@@ -1961,6 +1973,7 @@ window.__ModuleLoader__.load({
1961
1973
  "monitor.panel.gross": "Gross savings",
1962
1974
  "monitor.panel.offsets": "Offsets",
1963
1975
  "monitor.panel.context": "Context occupancy",
1976
+ "monitor.panel.suggest": "Context occupancy reached {pct}% — nearing the catastrophic-forgetting zone; consider compressing or trimming history",
1964
1977
  "monitor.panel.cacheHit": "Cache hit rate",
1965
1978
  "monitor.panel.cost": "Cost (actual / saved est.)",
1966
1979
  "monitor.panel.intent": "Intent summary",
@@ -2100,6 +2113,7 @@ window.__ModuleLoader__.load({
2100
2113
  "monitor.panel.gross": "Bruttoeinsparung",
2101
2114
  "monitor.panel.offsets": "Ausgleiche",
2102
2115
  "monitor.panel.context": "Kontextbelegung",
2116
+ "monitor.panel.suggest": "Kontextbelegung bei {pct}% — nahe der katastrophalen Vergessenszone; Komprimieren oder Kürzen des Verlaufs empfohlen",
2103
2117
  "monitor.panel.cacheHit": "Cache-Trefferquote",
2104
2118
  "monitor.panel.cost": "Kosten (ist / gespart gesch.)",
2105
2119
  "monitor.panel.intent": "Intent-Zusammenfassung",
@@ -2239,6 +2253,7 @@ window.__ModuleLoader__.load({
2239
2253
  "monitor.panel.gross": "Ahorro bruto",
2240
2254
  "monitor.panel.offsets": "Compensaciones",
2241
2255
  "monitor.panel.context": "Ocupación del contexto",
2256
+ "monitor.panel.suggest": "La ocupación del contexto alcanzó el {pct} % — cerca de la zona de olvido catastrófico; se recomienda comprimir o recortar el historial",
2242
2257
  "monitor.panel.cacheHit": "Tasa de acierto de caché",
2243
2258
  "monitor.panel.cost": "Coste (real / ahorro est.)",
2244
2259
  "monitor.panel.intent": "Resumen de intención",
@@ -2378,6 +2393,7 @@ window.__ModuleLoader__.load({
2378
2393
  "monitor.panel.gross": "Économie brute",
2379
2394
  "monitor.panel.offsets": "Compensations",
2380
2395
  "monitor.panel.context": "Occupation du contexte",
2396
+ "monitor.panel.suggest": "Occupation du contexte à {pct} % — zone de perte de contexte imminente ; pensez à lancer une compression ou à réduire les anciens échanges",
2381
2397
  "monitor.panel.cacheHit": "Taux de réussite du cache",
2382
2398
  "monitor.panel.cost": "Coût (réel / écon. est.)",
2383
2399
  "monitor.panel.intent": "Résumé d'intention",
@@ -2517,6 +2533,7 @@ window.__ModuleLoader__.load({
2517
2533
  "monitor.panel.gross": "Risparmio lordo",
2518
2534
  "monitor.panel.offsets": "Compensazioni",
2519
2535
  "monitor.panel.context": "Occupazione del contesto",
2536
+ "monitor.panel.suggest": "Occupazione del contesto al {pct}% — vicini alla zona di dimenticanza catastrofica; consigliato comprimere o tagliare la cronologia",
2520
2537
  "monitor.panel.cacheHit": "Tasso di hit della cache",
2521
2538
  "monitor.panel.cost": "Costo (effettivo / stimo)",
2522
2539
  "monitor.panel.intent": "Riepilogo di intento",
@@ -2656,6 +2673,7 @@ window.__ModuleLoader__.load({
2656
2673
  "monitor.panel.gross": "総節約",
2657
2674
  "monitor.panel.offsets": "相殺",
2658
2675
  "monitor.panel.context": "コンテキスト占有",
2676
+ "monitor.panel.suggest": "コンテキスト占有が {pct}% に達しました——壊滅的忘却ゾーンに近づいています。圧縮または履歴の削減を推奨",
2659
2677
  "monitor.panel.cacheHit": "キャッシュ ヒット率",
2660
2678
  "monitor.panel.cost": "コスト(実績 / 節約概算)",
2661
2679
  "monitor.panel.intent": "インテント要約",
@@ -2795,6 +2813,7 @@ window.__ModuleLoader__.load({
2795
2813
  "monitor.panel.gross": "총 절감",
2796
2814
  "monitor.panel.offsets": "상쇄",
2797
2815
  "monitor.panel.context": "컨텍스트 점유",
2816
+ "monitor.panel.suggest": "컨텍스트 점유가 {pct}%에 도달——치명적 망각 구간에 근접, 압축이나 기록 정리를 권장",
2798
2817
  "monitor.panel.cacheHit": "캐시 적중률",
2799
2818
  "monitor.panel.cost": "비용 (실제 / 절감 추정)",
2800
2819
  "monitor.panel.intent": "인텐트 요약",
@@ -2934,6 +2953,7 @@ window.__ModuleLoader__.load({
2934
2953
  "monitor.panel.gross": "Валовая экономия",
2935
2954
  "monitor.panel.offsets": "Компенсации",
2936
2955
  "monitor.panel.context": "Заполнение контекста",
2956
+ "monitor.panel.suggest": "Заполнение контекста достигло {pct}% — близко к зоне катастрофического забывания; рекомендуется сжать или обрезать историю",
2937
2957
  "monitor.panel.cacheHit": "Процент попаданий кэша",
2938
2958
  "monitor.panel.cost": "Стоимость (факт / эконом. оценка)",
2939
2959
  "monitor.panel.intent": "Итог намерения",
@@ -636,6 +636,12 @@ function evaluateIntentGate(input) {
636
636
  //#endregion
637
637
  //#region src/runtime/monitor.ts
638
638
  /**
639
+ * 灾难性遗忘区建议阈值:占用达到该比例即建议压缩/裁剪(DeepSeek 等长上下文
640
+ * 模型在高占用段对早期内容的召回显著退化)。有意低于宿主 Auto Compact 阈值
641
+ * (默认 80%)——提前一档给出人工干预窗口。
642
+ */
643
+ const MONITOR_SUGGEST_PCT = .7;
644
+ /**
639
645
  * Savings snapshot plus the intent-summary control block. Ledger is
640
646
  * injectable so tests seed a private instance instead of the process
641
647
  * singleton.
@@ -650,9 +656,15 @@ function buildMonitorSnapshot(sessionId, ledger = getSavingsLedger()) {
650
656
  pct: observedContext.contextWindow !== void 0 && observedContext.contextWindow > 0 ? Math.round(observedContext.liveTokens / observedContext.contextWindow * 1e3) / 1e3 : null,
651
657
  sessionId: observedContext.sessionId
652
658
  };
659
+ const suggestion = contextBlock === void 0 || contextBlock.pct === null ? void 0 : {
660
+ suggest: contextBlock.pct >= MONITOR_SUGGEST_PCT,
661
+ thresholdPct: MONITOR_SUGGEST_PCT,
662
+ occupancyPct: contextBlock.pct
663
+ };
653
664
  return {
654
665
  ...ledger.snapshot(sessionId),
655
666
  ...contextBlock === void 0 ? {} : { context: contextBlock },
667
+ ...suggestion === void 0 ? {} : { suggestion },
656
668
  intent: {
657
669
  override,
658
670
  observedEnabled: getObservedIntentEnabled(scopeKey),
@@ -4064,6 +4064,9 @@ var ToolResultPruner = class extends Service {
4064
4064
  this.auditFailure(agent.session, "fresh", "terminal-pass", error);
4065
4065
  ctx.logger.warn("context-compression terminal pass failed open: %o", error);
4066
4066
  }
4067
+ try {
4068
+ observeContextUsage(String(agent.session.id), measureForCompaction(this.ctx, agent.session).totalTokens, this.contextWindowForRequest(agent.session));
4069
+ } catch {}
4067
4070
  this.postflightEstimatorPass(agent.session, signal).catch(() => void 0);
4068
4071
  this.postflightAdvisorPass(agent.session, turn, signal).catch(() => void 0);
4069
4072
  this.postflightIntentFoldPass(agent.session, turn, signal).catch(() => void 0);
@@ -4421,15 +4424,13 @@ var ToolResultPruner = class extends Service {
4421
4424
  const view = measureForCompaction(this.ctx, session);
4422
4425
  const thresholdPercent = settings.autoCompact.thresholdPercent;
4423
4426
  const contextWindow = policy.autoCompactTokens !== void 0 && thresholdPercent > 0 ? Math.round(policy.autoCompactTokens / (thresholdPercent / 100)) : void 0;
4424
- const gate = evaluateIntentGate({
4427
+ if (!evaluateIntentGate({
4425
4428
  enabled: intentEnabled,
4426
4429
  override,
4427
4430
  liveTokens: view.totalTokens,
4428
4431
  contextWindow,
4429
4432
  baselineTokens: this.state.intentBaselines.get(session) ?? 0
4430
- });
4431
- observeContextUsage(sessionId, view.totalTokens, contextWindow);
4432
- if (!gate.decision) return;
4433
+ }).decision) return;
4433
4434
  const settingsPreset = settings.presetOptions;
4434
4435
  if (settingsPreset === void 0) return;
4435
4436
  if (settingsPreset.estimatorBaseUrl === void 0 || settingsPreset.estimatorBaseUrl.length === 0 || settingsPreset.estimatorModel === void 0 || settingsPreset.estimatorModel.length === 0) {
@@ -75,6 +75,7 @@ export const de = {
75
75
  'monitor.panel.gross': 'Bruttoeinsparung',
76
76
  'monitor.panel.offsets': 'Ausgleiche',
77
77
  'monitor.panel.context': 'Kontextbelegung',
78
+ 'monitor.panel.suggest': 'Kontextbelegung bei {pct}% — nahe der katastrophalen Vergessenszone; Komprimieren oder Kürzen des Verlaufs empfohlen',
78
79
  'monitor.panel.cacheHit': 'Cache-Trefferquote',
79
80
  'monitor.panel.cost': 'Kosten (ist / gespart gesch.)',
80
81
  'monitor.panel.intent': 'Intent-Zusammenfassung',
@@ -75,6 +75,7 @@ export const es = {
75
75
  'monitor.panel.gross': 'Ahorro bruto',
76
76
  'monitor.panel.offsets': 'Compensaciones',
77
77
  'monitor.panel.context': 'Ocupación del contexto',
78
+ 'monitor.panel.suggest': 'La ocupación del contexto alcanzó el {pct} % — cerca de la zona de olvido catastrófico; se recomienda comprimir o recortar el historial',
78
79
  'monitor.panel.cacheHit': 'Tasa de acierto de caché',
79
80
  'monitor.panel.cost': 'Coste (real / ahorro est.)',
80
81
  'monitor.panel.intent': 'Resumen de intención',
@@ -75,6 +75,7 @@ export const fr = {
75
75
  'monitor.panel.gross': 'Économie brute',
76
76
  'monitor.panel.offsets': 'Compensations',
77
77
  'monitor.panel.context': 'Occupation du contexte',
78
+ 'monitor.panel.suggest': 'Occupation du contexte à {pct} % — zone de perte de contexte imminente ; pensez à lancer une compression ou à réduire les anciens échanges',
78
79
  'monitor.panel.cacheHit': 'Taux de réussite du cache',
79
80
  'monitor.panel.cost': 'Coût (réel / écon. est.)',
80
81
  'monitor.panel.intent': 'Résumé d\'intention',
@@ -75,6 +75,7 @@ export const it = {
75
75
  'monitor.panel.gross': 'Risparmio lordo',
76
76
  'monitor.panel.offsets': 'Compensazioni',
77
77
  'monitor.panel.context': 'Occupazione del contesto',
78
+ 'monitor.panel.suggest': 'Occupazione del contesto al {pct}% — vicini alla zona di dimenticanza catastrofica; consigliato comprimere o tagliare la cronologia',
78
79
  'monitor.panel.cacheHit': 'Tasso di hit della cache',
79
80
  'monitor.panel.cost': 'Costo (effettivo / stimo)',
80
81
  'monitor.panel.intent': 'Riepilogo di intento',
@@ -75,6 +75,7 @@ export const ja = {
75
75
  'monitor.panel.gross': '総節約',
76
76
  'monitor.panel.offsets': '相殺',
77
77
  'monitor.panel.context': 'コンテキスト占有',
78
+ 'monitor.panel.suggest': 'コンテキスト占有が {pct}% に達しました——壊滅的忘却ゾーンに近づいています。圧縮または履歴の削減を推奨',
78
79
  'monitor.panel.cacheHit': 'キャッシュ ヒット率',
79
80
  'monitor.panel.cost': 'コスト(実績 / 節約概算)',
80
81
  'monitor.panel.intent': 'インテント要約',
@@ -75,6 +75,7 @@ export const ko = {
75
75
  'monitor.panel.gross': '총 절감',
76
76
  'monitor.panel.offsets': '상쇄',
77
77
  'monitor.panel.context': '컨텍스트 점유',
78
+ 'monitor.panel.suggest': '컨텍스트 점유가 {pct}%에 도달——치명적 망각 구간에 근접, 압축이나 기록 정리를 권장',
78
79
  'monitor.panel.cacheHit': '캐시 적중률',
79
80
  'monitor.panel.cost': '비용 (실제 / 절감 추정)',
80
81
  'monitor.panel.intent': '인텐트 요약',
@@ -75,6 +75,7 @@ export const ru = {
75
75
  'monitor.panel.gross': 'Валовая экономия',
76
76
  'monitor.panel.offsets': 'Компенсации',
77
77
  'monitor.panel.context': 'Заполнение контекста',
78
+ 'monitor.panel.suggest': 'Заполнение контекста достигло {pct}% — близко к зоне катастрофического забывания; рекомендуется сжать или обрезать историю',
78
79
  'monitor.panel.cacheHit': 'Процент попаданий кэша',
79
80
  'monitor.panel.cost': 'Стоимость (факт / эконом. оценка)',
80
81
  'monitor.panel.intent': 'Итог намерения',
@@ -73,6 +73,7 @@ export const zh = {
73
73
  'monitor.panel.gross': '毛节省',
74
74
  'monitor.panel.offsets': '抵消',
75
75
  'monitor.panel.context': '上下文占用',
76
+ 'monitor.panel.suggest': '上下文占用已达 {pct}%——临近灾难性遗忘区,建议压缩或裁剪历史',
76
77
  'monitor.panel.cacheHit': '缓存命中率',
77
78
  'monitor.panel.cost': '成本(实际 / 省估)',
78
79
  'monitor.panel.intent': '意图摘要',
@@ -216,6 +217,7 @@ export const en = {
216
217
  'monitor.panel.gross': 'Gross savings',
217
218
  'monitor.panel.offsets': 'Offsets',
218
219
  'monitor.panel.context': 'Context occupancy',
220
+ 'monitor.panel.suggest': 'Context occupancy reached {pct}% — nearing the catastrophic-forgetting zone; consider compressing or trimming history',
219
221
  'monitor.panel.cacheHit': 'Cache hit rate',
220
222
  'monitor.panel.cost': 'Cost (actual / saved est.)',
221
223
  'monitor.panel.intent': 'Intent summary',
@@ -38,6 +38,7 @@ export interface MonitorSnapshotPayload {
38
38
  lastFold?: { turn?: unknown; startSeq?: unknown; endSeq?: unknown } | undefined
39
39
  }
40
40
  context?: { liveTokens?: unknown; contextWindow?: unknown; pct?: unknown }
41
+ suggestion?: { suggest?: unknown; thresholdPct?: unknown; occupancyPct?: unknown }
41
42
  recentOffsets?: Array<{ component?: unknown; tokens?: unknown }>
42
43
  sessionScope?: string | null
43
44
  }
@@ -92,6 +93,9 @@ export function initMonitorFab(deps: MonitorFabDeps): void {
92
93
  #${PANEL_ID} button.ghost { background: transparent; }
93
94
  #${PANEL_ID} button:disabled { opacity: .45; cursor: default; }
94
95
  #${PANEL_ID} .stale { padding: 4px 14px 8px; color: #ffd60a; display: none; }
96
+ #${PANEL_ID} .hint { margin: 0; padding: 8px 14px; color: #ffd60a; display: none;
97
+ border-bottom: 1px solid rgba(255,255,255,.09); }
98
+ #${PANEL_ID} .hint.show { display: block; }
95
99
  #${PANEL_ID} .stale.show { display: block; }
96
100
  #${PANEL_ID} .recent { max-height: 132px; overflow: auto; padding: 2px 14px 8px;
97
101
  color: rgba(245,245,247,.8); white-space: pre-wrap; }
@@ -109,6 +113,7 @@ export function initMonitorFab(deps: MonitorFabDeps): void {
109
113
  panel.hidden = true;
110
114
  panel.innerHTML = `
111
115
  <h4>${t('monitor.panel.title')}</h4>
116
+ <div class="hint" data-hint></div>
112
117
  <div class="row"><span class="label">${t('monitor.panel.net')}</span><span data-net>–</span></div>
113
118
  <div class="row"><span class="label">${t('monitor.panel.gross')}</span><span data-gross class="muted">–</span></div>
114
119
  <div class="row"><span class="label">${t('monitor.panel.offsets')}</span><span data-offsets class="muted">–</span></div>
@@ -212,9 +217,20 @@ export function initMonitorFab(deps: MonitorFabDeps): void {
212
217
  last = snap;
213
218
  const net = num(snap.net?.exact) + num(snap.net?.estimated);
214
219
  const netEl = panel.querySelector('[data-net]') as HTMLElement;
215
- netEl.textContent = `${net >= 0 ? '' : ''}${fmtTokens(snap.net?.exact)}${num(snap.net?.estimated) > 0 ? ` (+${fmtTokens(snap.net?.estimated)} est)` : ''}`;
220
+ netEl.textContent = `${fmtTokens(snap.net?.exact)}${num(snap.net?.estimated) > 0 ? ` (+${fmtTokens(snap.net?.estimated)} est)` : ''}`;
216
221
  netEl.classList.toggle('neg', net < 0);
217
- fab.classList.toggle('lit', net < 0);
222
+ const suggest = snap.suggestion?.suggest === true;
223
+ fab.classList.toggle('lit', suggest || net < 0);
224
+ const hint = panel.querySelector('[data-hint]') as HTMLElement;
225
+ if (suggest) {
226
+ const pct = typeof snap.suggestion?.occupancyPct === 'number'
227
+ ? Math.round(snap.suggestion.occupancyPct * 100)
228
+ : null;
229
+ hint.textContent = (t('monitor.panel.suggest') as string).replace('{pct}', String(pct ?? '–'));
230
+ hint.classList.add('show');
231
+ } else {
232
+ hint.classList.remove('show');
233
+ }
218
234
  (panel.querySelector('[data-gross]') as HTMLElement).textContent = fmtTokens(snap.gross?.exact);
219
235
  (panel.querySelector('[data-offsets]') as HTMLElement).textContent = `-${fmtTokens(snap.offsets?.exact)}`;
220
236
  const ctxBar = panel.querySelector('[data-ctxbar]') as HTMLElement;
@@ -346,6 +346,15 @@ export class ToolResultPruner extends Service {
346
346
  this.auditFailure(agent.session, 'fresh', 'terminal-pass', error)
347
347
  ctx.logger.warn('context-compression terminal pass failed open: %o', error)
348
348
  }
349
+ // 压缩监控观测:每回合无条件记录上下文占用——面板占用条与
350
+ // 灾难性遗忘区建议的数据源,与 intentSummary 门控解耦(门关也可观测)。
351
+ try {
352
+ observeContextUsage(
353
+ String(agent.session.id),
354
+ measureForCompaction(this.ctx, agent.session).totalTokens,
355
+ this.contextWindowForRequest(agent.session),
356
+ )
357
+ } catch { /* 观测失败静默:面板显示陈旧/空态 */ }
349
358
  // TokenPilot-inspired E1: advisory estimator pass, strictly off the
350
359
  // synchronous chain. Verdicts only feed the next pressure pass.
351
360
  void this.postflightEstimatorPass(agent.session, signal).catch(() => undefined)
@@ -822,7 +831,6 @@ export class ToolResultPruner extends Service {
822
831
  contextWindow,
823
832
  baselineTokens: this.state.intentBaselines.get(session) ?? 0,
824
833
  })
825
- observeContextUsage(sessionId, view.totalTokens, contextWindow)
826
834
  if (!gate.decision) return
827
835
 
828
836
  const settingsPreset = settings.presetOptions
@@ -37,6 +37,13 @@ import {
37
37
  } from './tokenpilot/advisor-state.ts'
38
38
  import { INTENT_GATE_FLOOR_FRACTION, INTENT_GATE_GROWTH_TOKENS } from './tokenpilot/intent-gate.ts'
39
39
 
40
+ /**
41
+ * 灾难性遗忘区建议阈值:占用达到该比例即建议压缩/裁剪(DeepSeek 等长上下文
42
+ * 模型在高占用段对早期内容的召回显著退化)。有意低于宿主 Auto Compact 阈值
43
+ * (默认 80%)——提前一档给出人工干预窗口。
44
+ */
45
+ export const MONITOR_SUGGEST_PCT = 0.7
46
+
40
47
  export interface MonitorIntentBlock {
41
48
  /** Session-scoped override; absent = settings-driven. */
42
49
  override: 'on' | 'off' | undefined
@@ -54,10 +61,19 @@ export interface MonitorContextBlock {
54
61
  sessionId: string
55
62
  }
56
63
 
64
+ export interface MonitorSuggestionBlock {
65
+ /** 占用达到建议阈值——客户端点亮悬浮球并展示提示行。 */
66
+ suggest: boolean
67
+ thresholdPct: number
68
+ occupancyPct: number | null
69
+ }
70
+
57
71
  export type MonitorSnapshot = SavingsSnapshot & {
58
72
  intent: MonitorIntentBlock
59
73
  /** Latest observed context occupancy; undefined until the pruner observes a turn. */
60
74
  context?: MonitorContextBlock
75
+ /** 灾难性遗忘区建议;未观测前 absent。 */
76
+ suggestion?: MonitorSuggestionBlock
61
77
  /** The session the snapshot was filtered to; `null` = all-sessions aggregate. */
62
78
  sessionScope: string | null
63
79
  }
@@ -86,9 +102,17 @@ export function buildMonitorSnapshot(
86
102
  : null,
87
103
  sessionId: observedContext.sessionId,
88
104
  }
105
+ const suggestion = contextBlock === undefined || contextBlock.pct === null
106
+ ? undefined
107
+ : {
108
+ suggest: contextBlock.pct >= MONITOR_SUGGEST_PCT,
109
+ thresholdPct: MONITOR_SUGGEST_PCT,
110
+ occupancyPct: contextBlock.pct,
111
+ }
89
112
  return {
90
113
  ...ledger.snapshot(sessionId),
91
114
  ...(contextBlock === undefined ? {} : { context: contextBlock }),
115
+ ...(suggestion === undefined ? {} : { suggestion }),
92
116
  intent: {
93
117
  override,
94
118
  observedEnabled: getObservedIntentEnabled(scopeKey),
@@ -107,6 +107,27 @@ describe('monitor fab (body-level overlay)', () => {
107
107
  await waitFor(() => (deps.fetchSnapshot as ReturnType<typeof vi.fn>).mock.calls.length >= 2)
108
108
  })
109
109
 
110
+ it('灾难性遗忘区建议:点亮悬浮球并展示提示行', async () => {
111
+ const deps = makeDeps({
112
+ snapshots: [snapshotPatch({
113
+ net: { exact: 0, estimated: 0 },
114
+ context: { liveTokens: 90_000, contextWindow: 100_000, pct: 0.9 },
115
+ suggestion: { suggest: true, thresholdPct: 0.7, occupancyPct: 0.9 },
116
+ })],
117
+ })
118
+ initMonitorFab(deps)
119
+ await waitFor(() => (document.getElementById(FAB_ID) as HTMLElement).classList.contains('lit'))
120
+ const hint = document.querySelector('[data-hint]') as HTMLElement
121
+ expect(hint.classList.contains('show')).toBe(true)
122
+ expect(hint.textContent).toBe('monitor.panel.suggest')
123
+ })
124
+
125
+ it('无建议时提示行隐藏', async () => {
126
+ initMonitorFab(makeDeps())
127
+ await waitFor(() => (document.querySelector('[data-net]') as HTMLElement).textContent !== '')
128
+ expect(document.querySelector('[data-hint]')?.classList.contains('show')).toBe(false)
129
+ })
130
+
110
131
  it('position persists across drag-free re-init via localStorage', () => {
111
132
  localStorage.setItem('dsh.cci.monitor.pos', JSON.stringify({ x: 40, y: 60 }))
112
133
  initMonitorFab(makeDeps())
@@ -3,6 +3,7 @@ import { parseContextCompressionSettings, DEFAULT_CONTEXT_COMPRESSION_SETTINGS }
3
3
  import { SavingsLedger } from '../../src/runtime/savings.ts'
4
4
  import {
5
5
  applySessionOverride,
6
+ MONITOR_SUGGEST_PCT,
6
7
  observeContextUsage,
7
8
  buildMonitorSnapshot,
8
9
  estimateSavingsPricing,
@@ -272,3 +273,29 @@ describe('context occupancy observation (task_6.2)', () => {
272
273
  })
273
274
  })
274
275
 
276
+ describe('catastrophic-forgetting suggestion (task: 建议压缩)', () => {
277
+ it('occupancy past the threshold suggests compression', () => {
278
+ const sessionId = uniqueSession()
279
+ observeContextUsage(sessionId, 90_000, 100_000)
280
+ const snap = buildMonitorSnapshot(sessionId, new SavingsLedger())
281
+ expect(snap.suggestion?.suggest).toBe(true)
282
+ expect(snap.suggestion?.thresholdPct).toBe(MONITOR_SUGGEST_PCT)
283
+ expect(snap.suggestion?.occupancyPct).toBe(0.9)
284
+ })
285
+
286
+ it('below the threshold stays silent', () => {
287
+ const sessionId = uniqueSession()
288
+ observeContextUsage(sessionId, 50_000, 100_000)
289
+ const snap = buildMonitorSnapshot(sessionId, new SavingsLedger())
290
+ expect(snap.suggestion?.suggest).toBe(false)
291
+ })
292
+
293
+ it('threshold sits below the host auto-compact default (提前一档人工干预窗口)', () => {
294
+ expect(MONITOR_SUGGEST_PCT).toBeLessThan(0.8)
295
+ })
296
+
297
+ it('unobserved sessions carry no suggestion block', () => {
298
+ expect(buildMonitorSnapshot(uniqueSession(), new SavingsLedger()).suggestion).toBeUndefined()
299
+ })
300
+ })
301
+