context-mode 1.0.10 → 1.0.11

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.
@@ -6,14 +6,14 @@
6
6
  },
7
7
  "metadata": {
8
8
  "description": "Claude Code plugins by Mert Koseoğlu",
9
- "version": "1.0.10"
9
+ "version": "1.0.11"
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.10",
16
+ "version": "1.0.11",
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.10",
3
+ "version": "1.0.11",
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",
package/build/server.js CHANGED
@@ -13,7 +13,7 @@ import { ContentStore, cleanupStaleDBs } from "./store.js";
13
13
  import { readBashPolicies, evaluateCommandDenyOnly, extractShellCommands, readToolDenyPatterns, evaluateFilePath, } from "./security.js";
14
14
  import { detectRuntimes, getRuntimeSummary, getAvailableLanguages, hasBunRuntime, } from "./runtime.js";
15
15
  import { classifyNonZeroExit } from "./exit-classify.js";
16
- const VERSION = "1.0.10";
16
+ const VERSION = "1.0.11";
17
17
  // Prevent silent server death from unhandled async errors
18
18
  process.on("unhandledRejection", (err) => {
19
19
  process.stderr.write(`[context-mode] unhandledRejection: ${err}\n`);
@@ -11,7 +11,7 @@ import "../suppress-stderr.mjs";
11
11
  */
12
12
 
13
13
  import { ROUTING_BLOCK } from "../routing-block.mjs";
14
- import { writeSessionEventsFile, buildSessionDirective, getAllProjectEvents } from "../session-directive.mjs";
14
+ import { writeSessionEventsFile, buildSessionDirective, getSessionEvents, getLatestSessionEvents } from "../session-directive.mjs";
15
15
  import {
16
16
  readStdin, getSessionId, getSessionDBPath, getSessionEventsPath, getCleanupFlagPath,
17
17
  getProjectDir, GEMINI_OPTS,
@@ -43,7 +43,7 @@ try {
43
43
  db.markResumeConsumed(sessionId);
44
44
  }
45
45
 
46
- const events = getAllProjectEvents(db);
46
+ const events = getSessionEvents(db, sessionId);
47
47
  if (events.length > 0) {
48
48
  const eventMeta = writeSessionEventsFile(events, getSessionEventsPath(OPTS));
49
49
  additionalContext += buildSessionDirective("compact", eventMeta);
@@ -57,7 +57,7 @@ try {
57
57
  const dbPath = getSessionDBPath(OPTS);
58
58
  const db = new SessionDB({ dbPath });
59
59
 
60
- const events = getAllProjectEvents(db);
60
+ const events = getLatestSessionEvents(db);
61
61
  if (events.length > 0) {
62
62
  const eventMeta = writeSessionEventsFile(events, getSessionEventsPath(OPTS));
63
63
  additionalContext += buildSessionDirective("resume", eventMeta);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Shared session directive builder for all platform adaptors.
3
3
  *
4
- * Contains: groupEvents, writeSessionEventsFile, buildSessionDirective, getAllProjectEvents.
4
+ * Contains: groupEvents, writeSessionEventsFile, buildSessionDirective, getSessionEvents, getLatestSessionEvents.
5
5
  * Each adaptor imports these instead of duplicating the logic.
6
6
  */
7
7
 
@@ -386,10 +386,22 @@ export function buildSessionDirective(source, eventMeta) {
386
386
  return block;
387
387
  }
388
388
 
389
- // ── Get ALL events for this project (across all session_ids) ──
390
- export function getAllProjectEvents(db) {
389
+ // ── Get events for a specific session (used by compact) ──
390
+ export function getSessionEvents(db, sessionId) {
391
391
  return db.db.prepare(
392
392
  `SELECT session_id, type, category, priority, data, source_hook, created_at
393
- FROM session_events ORDER BY created_at ASC`
394
- ).all();
393
+ FROM session_events WHERE session_id = ? ORDER BY created_at ASC`
394
+ ).all(sessionId);
395
+ }
396
+
397
+ // ── Get events from the most recent session that has events (used by resume) ──
398
+ export function getLatestSessionEvents(db) {
399
+ const latest = db.db.prepare(
400
+ `SELECT m.session_id FROM session_meta m
401
+ JOIN session_events e ON m.session_id = e.session_id
402
+ GROUP BY m.session_id
403
+ ORDER BY m.started_at DESC LIMIT 1`
404
+ ).get();
405
+ if (!latest) return [];
406
+ return getSessionEvents(db, latest.session_id);
395
407
  }
@@ -16,7 +16,7 @@ import "./suppress-stderr.mjs";
16
16
 
17
17
  import { ROUTING_BLOCK } from "./routing-block.mjs";
18
18
  import { readStdin, getSessionId, getSessionDBPath, getSessionEventsPath, getCleanupFlagPath } from "./session-helpers.mjs";
19
- import { writeSessionEventsFile, buildSessionDirective, getAllProjectEvents } from "./session-directive.mjs";
19
+ import { writeSessionEventsFile, buildSessionDirective, getSessionEvents, getLatestSessionEvents } from "./session-directive.mjs";
20
20
  import { join, dirname } from "node:path";
21
21
  import { fileURLToPath, pathToFileURL } from "node:url";
22
22
  import { readFileSync, writeFileSync, unlinkSync } from "node:fs";
@@ -45,7 +45,7 @@ try {
45
45
  db.markResumeConsumed(sessionId);
46
46
  }
47
47
 
48
- const events = getAllProjectEvents(db);
48
+ const events = getSessionEvents(db, sessionId);
49
49
  if (events.length > 0) {
50
50
  const eventMeta = writeSessionEventsFile(events, getSessionEventsPath());
51
51
  additionalContext += buildSessionDirective("compact", eventMeta);
@@ -60,7 +60,7 @@ try {
60
60
  const dbPath = getSessionDBPath();
61
61
  const db = new SessionDB({ dbPath });
62
62
 
63
- const events = getAllProjectEvents(db);
63
+ const events = getLatestSessionEvents(db);
64
64
  if (events.length > 0) {
65
65
  const eventMeta = writeSessionEventsFile(events, getSessionEventsPath());
66
66
  additionalContext += buildSessionDirective("resume", eventMeta);
@@ -11,7 +11,7 @@ import "../suppress-stderr.mjs";
11
11
  */
12
12
 
13
13
  import { ROUTING_BLOCK } from "../routing-block.mjs";
14
- import { writeSessionEventsFile, buildSessionDirective, getAllProjectEvents } from "../session-directive.mjs";
14
+ import { writeSessionEventsFile, buildSessionDirective, getSessionEvents, getLatestSessionEvents } from "../session-directive.mjs";
15
15
  import {
16
16
  readStdin, getSessionId, getSessionDBPath, getSessionEventsPath, getCleanupFlagPath,
17
17
  getProjectDir, VSCODE_OPTS,
@@ -43,7 +43,7 @@ try {
43
43
  db.markResumeConsumed(sessionId);
44
44
  }
45
45
 
46
- const events = getAllProjectEvents(db);
46
+ const events = getSessionEvents(db, sessionId);
47
47
  if (events.length > 0) {
48
48
  const eventMeta = writeSessionEventsFile(events, getSessionEventsPath(OPTS));
49
49
  additionalContext += buildSessionDirective("compact", eventMeta);
@@ -57,7 +57,7 @@ try {
57
57
  const dbPath = getSessionDBPath(OPTS);
58
58
  const db = new SessionDB({ dbPath });
59
59
 
60
- const events = getAllProjectEvents(db);
60
+ const events = getLatestSessionEvents(db);
61
61
  if (events.length > 0) {
62
62
  const eventMeta = writeSessionEventsFile(events, getSessionEventsPath(OPTS));
63
63
  additionalContext += buildSessionDirective("resume", eventMeta);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
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",