context-mode 1.0.168 → 1.0.169

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "1.0.168",
3
+ "version": "1.0.169",
4
4
  "description": "context-mode for Antigravity CLI (agy): sandboxed code execution, FTS5 knowledge base, and session capture. Saves your context window by keeping raw bytes out of the conversation.",
5
5
  "author": {
6
6
  "name": "Mert Koseoğlu",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "context-mode",
3
3
  "description": "context-mode for GitHub Copilot CLI: sandboxed code execution in 11 languages, an FTS5 knowledge base with BM25 ranking, and session capture. Saves your context window by keeping raw bytes out of the conversation.",
4
- "version": "1.0.168",
4
+ "version": "1.0.169",
5
5
  "keywords": [
6
6
  "mcp",
7
7
  "context-window",
@@ -21,7 +21,7 @@ await runHook(async () => {
21
21
  getInputProjectDir,
22
22
  } = await import("./session-helpers.mjs");
23
23
  const { createSessionLoaders, attributeAndInsertEvents } = await import("./session-loaders.mjs");
24
- const { dirname, resolve } = await import("node:path");
24
+ const { dirname, resolve, basename } = await import("node:path");
25
25
  const { fileURLToPath } = await import("node:url");
26
26
  const { readFileSync, unlinkSync } = await import("node:fs");
27
27
  const { tmpdir } = await import("node:os");
@@ -178,6 +178,44 @@ await runHook(async () => {
178
178
  }
179
179
  } catch { /* latency tracking is best-effort */ }
180
180
 
181
+ // ─── Retrieval bridge: emit the "With context-mode" (bytes_retrieved) row ───
182
+ // The MCP server appended ctx_search / ctx_fetch_and_index response bytes to
183
+ // a marker keyed by the session DB basename (the hook NEVER fires for the
184
+ // plugin's own MCP tools, so this is the only place that signal can enter
185
+ // the forward stream). Consume + emit one forwardable event so the platform
186
+ // kept_out_pct goes "measured". Mirrors the redirect-marker handshake above.
187
+ try {
188
+ const marker = resolve(tmpdir(), `context-mode-retrieval-${basename(dbPath)}.txt`);
189
+ let retrievedBytes = 0;
190
+ try {
191
+ const raw = readFileSync(marker, "utf-8");
192
+ for (const line of raw.split("\n")) {
193
+ const n = parseInt(line, 10);
194
+ if (Number.isFinite(n) && n > 0) retrievedBytes += n;
195
+ }
196
+ unlinkSync(marker); // consume-once — next fire cannot re-forward
197
+ } catch { /* no marker — phantom-event guard */ }
198
+ if (retrievedBytes > 0) {
199
+ // session-loaders stamps bytes_retrieved onto the platform payload from
200
+ // this in-memory field (session_events has no such column — forward-only).
201
+ attributeAndInsertEvents(
202
+ db,
203
+ sessionId,
204
+ [{
205
+ type: "mcp_tool_call",
206
+ category: "retrieval",
207
+ data: `retrieval: ${retrievedBytes} bytes accessed`,
208
+ priority: 2,
209
+ bytes_retrieved: retrievedBytes,
210
+ }],
211
+ input,
212
+ projectDir,
213
+ "PostToolUse",
214
+ resolveProjectAttributions,
215
+ );
216
+ }
217
+ } catch { /* best-effort — never block the hook */ }
218
+
181
219
  db.close();
182
220
  } catch {
183
221
  // PostToolUse must never block the session — silent fallback
@@ -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.168",
6
+ "version": "1.0.169",
7
7
  "sandbox": {
8
8
  "mode": "permissive",
9
9
  "filesystem_access": "full",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "1.0.168",
3
+ "version": "1.0.169",
4
4
  "type": "module",
5
5
  "description": "MCP plugin that saves 98% of your context window. Works with Claude Code, Gemini CLI, VS Code Copilot, OpenCode, and Codex CLI. Sandboxed code execution, FTS5 knowledge base, and intent-driven search.",
6
6
  "author": "Mert Koseoğlu",