context-mode 1.0.94 → 1.0.96
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/.openclaw-plugin/openclaw.plugin.json +1 -1
- package/.openclaw-plugin/package.json +1 -1
- package/build/cache-heal.d.ts +48 -0
- package/build/cache-heal.js +150 -0
- package/build/server.js +36 -1
- package/build/session/analytics.d.ts +11 -2
- package/build/session/analytics.js +38 -32
- package/cli.bundle.mjs +107 -107
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/scripts/postinstall.mjs +47 -1
- package/server.bundle.mjs +82 -82
- package/start.mjs +66 -14
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
},
|
|
7
7
|
"metadata": {
|
|
8
8
|
"description": "Claude Code plugins by Mert Koseoğlu",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.96"
|
|
10
10
|
},
|
|
11
11
|
"plugins": [
|
|
12
12
|
{
|
|
13
13
|
"name": "context-mode",
|
|
14
14
|
"source": "./",
|
|
15
15
|
"description": "Claude Code MCP plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
|
|
16
|
-
"version": "1.0.
|
|
16
|
+
"version": "1.0.96",
|
|
17
17
|
"author": {
|
|
18
18
|
"name": "Mert Koseoğlu"
|
|
19
19
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "context-mode",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.96",
|
|
4
4
|
"description": "MCP server that saves 98% of your context window with session continuity. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and automatic state restore across compactions.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Mert Koseoğlu",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "Context Mode",
|
|
4
4
|
"kind": "tool",
|
|
5
5
|
"description": "OpenClaw plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.96",
|
|
7
7
|
"sandbox": {
|
|
8
8
|
"mode": "permissive",
|
|
9
9
|
"filesystem_access": "full",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "context-mode",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.96",
|
|
4
4
|
"description": "OpenClaw plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Mert Koseoğlu",
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin cache self-heal — fixes broken CLAUDE_PLUGIN_ROOT references.
|
|
3
|
+
*
|
|
4
|
+
* Claude Code's plugin auto-update can leave installed_plugins.json pointing
|
|
5
|
+
* to a non-existent directory (anthropics/claude-code#46915). This module
|
|
6
|
+
* detects and repairs the mismatch by creating symlinks.
|
|
7
|
+
*
|
|
8
|
+
* 4-layer defense:
|
|
9
|
+
* 1. start.mjs startup — reverse heal (registry → symlink to us)
|
|
10
|
+
* 2. server.ts first tool call — mid-session heal
|
|
11
|
+
* 3. postinstall.mjs — backward symlink on new install
|
|
12
|
+
* 4. global hook auto-deploy — survives total plugin cache breakage
|
|
13
|
+
*/
|
|
14
|
+
export interface HealResult {
|
|
15
|
+
healed: boolean;
|
|
16
|
+
action?: "symlink" | "global-hook" | "none";
|
|
17
|
+
from?: string;
|
|
18
|
+
to?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Core heal: if installed_plugins.json points to a non-existent directory,
|
|
22
|
+
* create a symlink from that path to our actual directory.
|
|
23
|
+
*
|
|
24
|
+
* @param currentDir - The directory we're actually running from
|
|
25
|
+
* @param installedPluginsPath - Path to installed_plugins.json (injectable for testing)
|
|
26
|
+
*/
|
|
27
|
+
export declare function healRegistryMismatch(currentDir: string, installedPluginsPath?: string): HealResult;
|
|
28
|
+
/**
|
|
29
|
+
* Deploy a global SessionStart hook that heals plugin cache mismatches.
|
|
30
|
+
* This hook lives outside the plugin directory, so it survives cache breakage.
|
|
31
|
+
*
|
|
32
|
+
* Written to ~/.claude/hooks/context-mode-cache-heal.sh
|
|
33
|
+
*/
|
|
34
|
+
export declare function deployGlobalHealHook(): HealResult;
|
|
35
|
+
/**
|
|
36
|
+
* Backward symlink: during postinstall, if the registry points to a
|
|
37
|
+
* non-existent OLD path, create a symlink from old → new (our directory).
|
|
38
|
+
* Same as healRegistryMismatch but called from postinstall context.
|
|
39
|
+
*/
|
|
40
|
+
export { healRegistryMismatch as healBackwardCompat };
|
|
41
|
+
/**
|
|
42
|
+
* Mid-session heal — call on first MCP tool invocation.
|
|
43
|
+
* Checks if registry path differs from our running directory.
|
|
44
|
+
* Creates symlink if needed. Runs only once per process.
|
|
45
|
+
*/
|
|
46
|
+
export declare function healMidSession(currentDir: string): HealResult;
|
|
47
|
+
/** Reset mid-session flag (for testing only) */
|
|
48
|
+
export declare function _resetMidSession(): void;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin cache self-heal — fixes broken CLAUDE_PLUGIN_ROOT references.
|
|
3
|
+
*
|
|
4
|
+
* Claude Code's plugin auto-update can leave installed_plugins.json pointing
|
|
5
|
+
* to a non-existent directory (anthropics/claude-code#46915). This module
|
|
6
|
+
* detects and repairs the mismatch by creating symlinks.
|
|
7
|
+
*
|
|
8
|
+
* 4-layer defense:
|
|
9
|
+
* 1. start.mjs startup — reverse heal (registry → symlink to us)
|
|
10
|
+
* 2. server.ts first tool call — mid-session heal
|
|
11
|
+
* 3. postinstall.mjs — backward symlink on new install
|
|
12
|
+
* 4. global hook auto-deploy — survives total plugin cache breakage
|
|
13
|
+
*/
|
|
14
|
+
import { existsSync, readFileSync, symlinkSync, mkdirSync, writeFileSync } from "node:fs";
|
|
15
|
+
import { resolve, dirname } from "node:path";
|
|
16
|
+
import { homedir } from "node:os";
|
|
17
|
+
/**
|
|
18
|
+
* Core heal: if installed_plugins.json points to a non-existent directory,
|
|
19
|
+
* create a symlink from that path to our actual directory.
|
|
20
|
+
*
|
|
21
|
+
* @param currentDir - The directory we're actually running from
|
|
22
|
+
* @param installedPluginsPath - Path to installed_plugins.json (injectable for testing)
|
|
23
|
+
*/
|
|
24
|
+
export function healRegistryMismatch(currentDir, installedPluginsPath) {
|
|
25
|
+
const ipPath = installedPluginsPath ?? resolve(homedir(), ".claude", "plugins", "installed_plugins.json");
|
|
26
|
+
if (!existsSync(ipPath))
|
|
27
|
+
return { healed: false, action: "none" };
|
|
28
|
+
if (!existsSync(currentDir))
|
|
29
|
+
return { healed: false, action: "none" };
|
|
30
|
+
let ip;
|
|
31
|
+
try {
|
|
32
|
+
ip = JSON.parse(readFileSync(ipPath, "utf-8"));
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return { healed: false, action: "none" };
|
|
36
|
+
}
|
|
37
|
+
for (const [key, entries] of Object.entries(ip.plugins ?? {})) {
|
|
38
|
+
if (!key.toLowerCase().includes("context-mode"))
|
|
39
|
+
continue;
|
|
40
|
+
for (const entry of entries) {
|
|
41
|
+
const registryPath = entry.installPath;
|
|
42
|
+
if (!registryPath)
|
|
43
|
+
continue;
|
|
44
|
+
// Registry path exists — no healing needed
|
|
45
|
+
if (existsSync(registryPath))
|
|
46
|
+
continue;
|
|
47
|
+
// Registry path doesn't exist — create symlink to our directory
|
|
48
|
+
try {
|
|
49
|
+
const parent = dirname(registryPath);
|
|
50
|
+
if (!existsSync(parent))
|
|
51
|
+
mkdirSync(parent, { recursive: true });
|
|
52
|
+
if (process.platform === "win32") {
|
|
53
|
+
// Windows: use junction (no admin required)
|
|
54
|
+
symlinkSync(currentDir, registryPath, "junction");
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
symlinkSync(currentDir, registryPath);
|
|
58
|
+
}
|
|
59
|
+
return { healed: true, action: "symlink", from: registryPath, to: currentDir };
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return { healed: false, action: "none" };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return { healed: false, action: "none" };
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Deploy a global SessionStart hook that heals plugin cache mismatches.
|
|
70
|
+
* This hook lives outside the plugin directory, so it survives cache breakage.
|
|
71
|
+
*
|
|
72
|
+
* Written to ~/.claude/hooks/context-mode-cache-heal.sh
|
|
73
|
+
*/
|
|
74
|
+
export function deployGlobalHealHook() {
|
|
75
|
+
const hooksDir = resolve(homedir(), ".claude", "hooks");
|
|
76
|
+
const hookPath = resolve(hooksDir, "context-mode-cache-heal.sh");
|
|
77
|
+
// Already deployed
|
|
78
|
+
if (existsSync(hookPath))
|
|
79
|
+
return { healed: false, action: "none" };
|
|
80
|
+
try {
|
|
81
|
+
if (!existsSync(hooksDir))
|
|
82
|
+
mkdirSync(hooksDir, { recursive: true });
|
|
83
|
+
const script = `#!/usr/bin/env bash
|
|
84
|
+
# context-mode plugin cache self-heal — auto-deployed by context-mode MCP server
|
|
85
|
+
# Fixes anthropics/claude-code#46915: auto-update breaks CLAUDE_PLUGIN_ROOT
|
|
86
|
+
# This hook runs at SessionStart (global, not plugin-level) so it works even
|
|
87
|
+
# when the plugin cache is broken.
|
|
88
|
+
|
|
89
|
+
set -euo pipefail
|
|
90
|
+
|
|
91
|
+
PLUGINS_FILE="$HOME/.claude/plugins/installed_plugins.json"
|
|
92
|
+
[[ -f "$PLUGINS_FILE" ]] || exit 0
|
|
93
|
+
|
|
94
|
+
# Find context-mode entries and heal missing directories
|
|
95
|
+
node -e '
|
|
96
|
+
const fs = require("fs");
|
|
97
|
+
const path = require("path");
|
|
98
|
+
try {
|
|
99
|
+
const ip = JSON.parse(fs.readFileSync(process.argv[1], "utf-8"));
|
|
100
|
+
for (const [key, entries] of Object.entries(ip.plugins || {})) {
|
|
101
|
+
if (!key.toLowerCase().includes("context-mode")) continue;
|
|
102
|
+
for (const entry of entries) {
|
|
103
|
+
const p = entry.installPath;
|
|
104
|
+
if (!p || fs.existsSync(p)) continue;
|
|
105
|
+
const parent = path.dirname(p);
|
|
106
|
+
if (!fs.existsSync(parent)) continue;
|
|
107
|
+
const dirs = fs.readdirSync(parent).filter(d => /^\\d+\\.\\d+/.test(d) && fs.statSync(path.join(parent, d)).isDirectory());
|
|
108
|
+
if (dirs.length === 0) continue;
|
|
109
|
+
dirs.sort((a, b) => {
|
|
110
|
+
const pa = a.split(".").map(Number), pb = b.split(".").map(Number);
|
|
111
|
+
for (let i = 0; i < 3; i++) { if ((pa[i]||0) !== (pb[i]||0)) return (pa[i]||0) - (pb[i]||0); }
|
|
112
|
+
return 0;
|
|
113
|
+
});
|
|
114
|
+
const target = path.join(parent, dirs[dirs.length - 1]);
|
|
115
|
+
try { fs.symlinkSync(target, p); } catch {}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
} catch {}
|
|
119
|
+
' "$PLUGINS_FILE" 2>/dev/null || true
|
|
120
|
+
`;
|
|
121
|
+
writeFileSync(hookPath, script, { mode: 0o755 });
|
|
122
|
+
return { healed: true, action: "global-hook", from: hookPath };
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return { healed: false, action: "none" };
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Backward symlink: during postinstall, if the registry points to a
|
|
130
|
+
* non-existent OLD path, create a symlink from old → new (our directory).
|
|
131
|
+
* Same as healRegistryMismatch but called from postinstall context.
|
|
132
|
+
*/
|
|
133
|
+
export { healRegistryMismatch as healBackwardCompat };
|
|
134
|
+
/** One-shot flag for mid-session heal in server.ts */
|
|
135
|
+
let _midSessionHealed = false;
|
|
136
|
+
/**
|
|
137
|
+
* Mid-session heal — call on first MCP tool invocation.
|
|
138
|
+
* Checks if registry path differs from our running directory.
|
|
139
|
+
* Creates symlink if needed. Runs only once per process.
|
|
140
|
+
*/
|
|
141
|
+
export function healMidSession(currentDir) {
|
|
142
|
+
if (_midSessionHealed)
|
|
143
|
+
return { healed: false, action: "none" };
|
|
144
|
+
_midSessionHealed = true;
|
|
145
|
+
return healRegistryMismatch(currentDir);
|
|
146
|
+
}
|
|
147
|
+
/** Reset mid-session flag (for testing only) */
|
|
148
|
+
export function _resetMidSession() {
|
|
149
|
+
_midSessionHealed = false;
|
|
150
|
+
}
|
package/build/server.js
CHANGED
|
@@ -3,7 +3,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
|
-
import { existsSync, unlinkSync, readdirSync, readFileSync, writeFileSync, rmSync, mkdirSync, cpSync, statSync } from "node:fs";
|
|
6
|
+
import { existsSync, unlinkSync, readdirSync, readFileSync, writeFileSync, rmSync, mkdirSync, cpSync, statSync, symlinkSync } from "node:fs";
|
|
7
7
|
import { execSync } from "node:child_process";
|
|
8
8
|
import { join, dirname, resolve } from "node:path";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
@@ -262,7 +262,42 @@ function shouldShowVersionWarning() {
|
|
|
262
262
|
_warningBurstCount++;
|
|
263
263
|
return true;
|
|
264
264
|
}
|
|
265
|
+
// ── Self-heal Layer 2: Mid-session registry heal (anthropics/claude-code#46915) ──
|
|
266
|
+
// Runs once on first tool call. If Claude Code auto-updated the registry mid-session,
|
|
267
|
+
// hooks break because CLAUDE_PLUGIN_ROOT points to a deleted directory. We create a
|
|
268
|
+
// symlink from the broken path to our actual directory so hooks recover.
|
|
269
|
+
let _cacheHealDone = false;
|
|
270
|
+
function healCacheMidSession() {
|
|
271
|
+
if (_cacheHealDone)
|
|
272
|
+
return;
|
|
273
|
+
_cacheHealDone = true;
|
|
274
|
+
try {
|
|
275
|
+
const ipPath = resolve(homedir(), ".claude", "plugins", "installed_plugins.json");
|
|
276
|
+
if (!existsSync(ipPath))
|
|
277
|
+
return;
|
|
278
|
+
const ip = JSON.parse(readFileSync(ipPath, "utf-8"));
|
|
279
|
+
for (const [key, entries] of Object.entries((ip.plugins ?? {}))) {
|
|
280
|
+
if (!key.toLowerCase().includes("context-mode"))
|
|
281
|
+
continue;
|
|
282
|
+
for (const entry of entries) {
|
|
283
|
+
const rp = entry.installPath;
|
|
284
|
+
if (!rp || existsSync(rp))
|
|
285
|
+
continue;
|
|
286
|
+
const parent = dirname(rp);
|
|
287
|
+
if (!existsSync(parent))
|
|
288
|
+
mkdirSync(parent, { recursive: true });
|
|
289
|
+
const target = resolve(__pkg_dir, "..");
|
|
290
|
+
if (existsSync(target)) {
|
|
291
|
+
symlinkSync(target, rp, process.platform === "win32" ? "junction" : undefined);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
catch { /* best effort */ }
|
|
297
|
+
}
|
|
265
298
|
function trackResponse(toolName, response) {
|
|
299
|
+
// Mid-session cache heal — one-shot, first tool call
|
|
300
|
+
healCacheMidSession();
|
|
266
301
|
// Prepend version outdated warning if needed
|
|
267
302
|
if (shouldShowVersionWarning() && response.content.length > 0) {
|
|
268
303
|
const hint = getUpgradeHint();
|
|
@@ -96,6 +96,16 @@ export interface FullReport {
|
|
|
96
96
|
compact_count: number;
|
|
97
97
|
resume_ready: boolean;
|
|
98
98
|
};
|
|
99
|
+
/** Persistent project memory — all events across all sessions */
|
|
100
|
+
projectMemory: {
|
|
101
|
+
total_events: number;
|
|
102
|
+
session_count: number;
|
|
103
|
+
by_category: Array<{
|
|
104
|
+
category: string;
|
|
105
|
+
count: number;
|
|
106
|
+
label: string;
|
|
107
|
+
}>;
|
|
108
|
+
};
|
|
99
109
|
}
|
|
100
110
|
/** Human-readable labels for event categories. */
|
|
101
111
|
export declare const categoryLabels: Record<string, string>;
|
|
@@ -155,8 +165,7 @@ export declare class AnalyticsEngine {
|
|
|
155
165
|
* - Before/After comparison bar is the HERO — one glance = "wow"
|
|
156
166
|
* - "tokens saved" is the number people share
|
|
157
167
|
* - Per-tool breakdown shows what each tool SAVED, sorted by impact
|
|
158
|
-
* -
|
|
168
|
+
* - Project memory: category bars showing persistent data across sessions
|
|
159
169
|
* - No: Pct column, category tables, tips, jargon
|
|
160
|
-
* - Under 22 lines for heavy sessions, under 10 for fresh
|
|
161
170
|
*/
|
|
162
171
|
export declare function formatReport(report: FullReport, version?: string, latestVersion?: string | null): string;
|
|
@@ -199,6 +199,16 @@ export class AnalyticsEngine {
|
|
|
199
199
|
: "",
|
|
200
200
|
why: categoryHints[row.category] || "Survives context resets",
|
|
201
201
|
}));
|
|
202
|
+
// ── Project-wide persistent memory (all sessions, no session_id filter) ──
|
|
203
|
+
const projectTotals = this.db.prepare("SELECT COUNT(*) as cnt, COUNT(DISTINCT session_id) as sessions FROM session_events").get();
|
|
204
|
+
const projectByCategory = this.db.prepare("SELECT category, COUNT(*) as cnt FROM session_events GROUP BY category ORDER BY cnt DESC").all();
|
|
205
|
+
const projectMemoryByCategory = projectByCategory
|
|
206
|
+
.filter((row) => row.cnt > 0)
|
|
207
|
+
.map((row) => ({
|
|
208
|
+
category: row.category,
|
|
209
|
+
count: row.cnt,
|
|
210
|
+
label: categoryLabels[row.category] || row.category,
|
|
211
|
+
}));
|
|
202
212
|
return {
|
|
203
213
|
savings: {
|
|
204
214
|
processed_kb: Math.round(totalProcessed / 1024 * 10) / 10,
|
|
@@ -223,6 +233,11 @@ export class AnalyticsEngine {
|
|
|
223
233
|
compact_count: compactCount,
|
|
224
234
|
resume_ready: resumeReady,
|
|
225
235
|
},
|
|
236
|
+
projectMemory: {
|
|
237
|
+
total_events: projectTotals.cnt,
|
|
238
|
+
session_count: projectTotals.sessions,
|
|
239
|
+
by_category: projectMemoryByCategory,
|
|
240
|
+
},
|
|
226
241
|
};
|
|
227
242
|
}
|
|
228
243
|
}
|
|
@@ -266,6 +281,24 @@ function dataBar(bytes, maxBytes, width = 40) {
|
|
|
266
281
|
const filled = Math.max(1, Math.round((bytes / maxBytes) * width));
|
|
267
282
|
return "█".repeat(Math.min(filled, width)) + "░".repeat(Math.max(0, width - filled));
|
|
268
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* Render project memory section with category bars.
|
|
286
|
+
* Shows persistent event data across all sessions.
|
|
287
|
+
*/
|
|
288
|
+
function renderProjectMemory(pm) {
|
|
289
|
+
if (pm.total_events === 0)
|
|
290
|
+
return [];
|
|
291
|
+
const out = [];
|
|
292
|
+
out.push("");
|
|
293
|
+
const sessionLabel = pm.session_count === 1 ? "1 session" : `${pm.session_count} sessions`;
|
|
294
|
+
out.push(`${fmtNum(pm.total_events)} events remembered across ${sessionLabel} \u2014 searchable after compact & restart`);
|
|
295
|
+
out.push("");
|
|
296
|
+
const maxCount = pm.by_category.length > 0 ? pm.by_category[0].count : 1;
|
|
297
|
+
for (const cat of pm.by_category) {
|
|
298
|
+
out.push(` ${cat.label.padEnd(18)} ${String(cat.count).padStart(5)} ${dataBar(cat.count, maxCount, 30)}`);
|
|
299
|
+
}
|
|
300
|
+
return out;
|
|
301
|
+
}
|
|
269
302
|
/**
|
|
270
303
|
* Render a FullReport as a visual savings dashboard designed for screenshotting.
|
|
271
304
|
*
|
|
@@ -273,9 +306,8 @@ function dataBar(bytes, maxBytes, width = 40) {
|
|
|
273
306
|
* - Before/After comparison bar is the HERO — one glance = "wow"
|
|
274
307
|
* - "tokens saved" is the number people share
|
|
275
308
|
* - Per-tool breakdown shows what each tool SAVED, sorted by impact
|
|
276
|
-
* -
|
|
309
|
+
* - Project memory: category bars showing persistent data across sessions
|
|
277
310
|
* - No: Pct column, category tables, tips, jargon
|
|
278
|
-
* - Under 22 lines for heavy sessions, under 10 for fresh
|
|
279
311
|
*/
|
|
280
312
|
export function formatReport(report, version, latestVersion) {
|
|
281
313
|
const lines = [];
|
|
@@ -297,6 +329,8 @@ export function formatReport(report, version, latestVersion) {
|
|
|
297
329
|
else {
|
|
298
330
|
lines.push(`${kb(totalReturned)} entered context | 0 tokens saved`);
|
|
299
331
|
}
|
|
332
|
+
// Project memory
|
|
333
|
+
lines.push(...renderProjectMemory(report.projectMemory));
|
|
300
334
|
// Footer
|
|
301
335
|
lines.push("");
|
|
302
336
|
const versionStr = version ? `v${version}` : "context-mode";
|
|
@@ -342,36 +376,8 @@ export function formatReport(report, version, latestVersion) {
|
|
|
342
376
|
lines.push(` ${name.padEnd(22)} ${String(t.calls).padStart(4)} calls ${kb(t.estimatedSaved).padStart(8)} saved`);
|
|
343
377
|
}
|
|
344
378
|
}
|
|
345
|
-
// ──
|
|
346
|
-
|
|
347
|
-
lines.push("");
|
|
348
|
-
const cats = report.continuity.by_category;
|
|
349
|
-
// Pick the top 3-4 most impactful categories for a human-readable summary
|
|
350
|
-
const highlights = [];
|
|
351
|
-
const fileCount = cats.find(c => c.category === "file")?.count;
|
|
352
|
-
const gitCount = cats.find(c => c.category === "git")?.count;
|
|
353
|
-
const promptCount = cats.find(c => c.category === "prompt")?.count;
|
|
354
|
-
const errorCount = cats.find(c => c.category === "error")?.count;
|
|
355
|
-
const taskCount = cats.find(c => c.category === "task")?.count;
|
|
356
|
-
if (fileCount)
|
|
357
|
-
highlights.push(`${fileCount} files`);
|
|
358
|
-
if (gitCount)
|
|
359
|
-
highlights.push(`${gitCount} git ops`);
|
|
360
|
-
if (promptCount)
|
|
361
|
-
highlights.push(`${promptCount} prompts`);
|
|
362
|
-
if (errorCount)
|
|
363
|
-
highlights.push(`${errorCount} errors`);
|
|
364
|
-
if (taskCount)
|
|
365
|
-
highlights.push(`${taskCount} tasks`);
|
|
366
|
-
const summary = highlights.length > 0 ? ` · ${highlights.join(", ")}` : "";
|
|
367
|
-
if (report.continuity.compact_count > 0) {
|
|
368
|
-
lines.push(`${fmtNum(report.continuity.total_events)} events remembered across ${report.continuity.compact_count} compaction${report.continuity.compact_count !== 1 ? "s" : ""}${summary}`);
|
|
369
|
-
lines.push("Zero knowledge lost — picks up exactly where you left off.");
|
|
370
|
-
}
|
|
371
|
-
else {
|
|
372
|
-
lines.push(`${fmtNum(report.continuity.total_events)} events tracked${summary}`);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
379
|
+
// ── Project memory — persistent across sessions ──
|
|
380
|
+
lines.push(...renderProjectMemory(report.projectMemory));
|
|
375
381
|
// ── Footer ──
|
|
376
382
|
lines.push("");
|
|
377
383
|
const versionStr = version ? `v${version}` : "context-mode";
|