context-mode 1.0.145 → 1.0.146

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.145"
9
+ "version": "1.0.146"
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.145",
16
+ "version": "1.0.146",
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.145",
3
+ "version": "1.0.146",
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",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "1.0.145",
3
+ "version": "1.0.146",
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.145",
6
+ "version": "1.0.146",
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.145",
3
+ "version": "1.0.146",
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",
@@ -34,6 +34,7 @@ import { homedir } from "node:os";
34
34
  import { dirname, join, resolve } from "node:path";
35
35
  import { fileURLToPath, pathToFileURL } from "node:url";
36
36
  import { resolveContextModeDataRoot } from "../base.js";
37
+ import { resolveSessionDbPath } from "../../session/db.js";
37
38
  import { OpenClawSessionDB } from "./session-db.js";
38
39
  import { extractEvents, extractUserEvents } from "../../session/extract.js";
39
40
  import { buildResumeSnapshot } from "../../session/snapshot.js";
@@ -83,22 +84,44 @@ function getSessionDir() {
83
84
  mkdirSync(dir, { recursive: true });
84
85
  return dir;
85
86
  }
87
+ // Issue #645 follow-up — route through the canonical per-project
88
+ // resolver the MCP server uses (src/server.ts ctx_stats / ctx_search
89
+ // timeline). The previous raw `sha256(projectDir).slice(0, 16)` shape
90
+ // produced a different file from the `<canonical-hash>.db` the server
91
+ // reads on darwin/win32 (case-fold) and inside linked worktrees
92
+ // (suffix). The result was silent degradation of `ctx_stats` (zero
93
+ // history) and `ctx_search(sort: "timeline")` (sort dropped) for any
94
+ // OpenClaw user with an uppercase character in their projectDir.
95
+ // Mirrors the matching Pi (src/adapters/pi/extension.ts:223) and OMP
96
+ // (src/adapters/omp/plugin.ts:90) fixes, and the opencode plugin
97
+ // pattern (src/adapters/opencode/plugin.ts:307).
86
98
  function getDBPath(projectDir) {
87
- const hash = createHash("sha256")
88
- .update(projectDir)
89
- .digest("hex")
90
- .slice(0, 16);
91
- return join(getSessionDir(), `${hash}.db`);
99
+ return resolveSessionDbPath({ projectDir, sessionsDir: getSessionDir() });
92
100
  }
93
101
  // ── Module-level DB singleton ─────────────────────────────
94
102
  // Shared across all register() calls (one per agent session).
95
103
  // Lazy-initialized on first register() using the first projectDir seen.
96
104
  // Uses OpenClawSessionDB for session_key mapping and rename support.
97
105
  let _dbSingleton = null;
106
+ let _dbSingletonPath = "";
98
107
  function getOrCreateDB(projectDir) {
99
- if (!_dbSingleton) {
100
- const dbPath = getDBPath(projectDir);
108
+ // Reopen the singleton if the resolved DB path changes. Production
109
+ // code normally loads the plugin once per process with a single
110
+ // workspace, but defensive re-keying on resolved path keeps the
111
+ // contract honest if a host ever calls register() twice with
112
+ // different projectDirs, and removes a subtle test-isolation
113
+ // foot-gun where a stale singleton pointed at a prior test's
114
+ // `<hash>.db`. Mirrors the Pi/OMP fix (#645).
115
+ const dbPath = getDBPath(projectDir);
116
+ if (!_dbSingleton || _dbSingletonPath !== dbPath) {
117
+ if (_dbSingleton) {
118
+ try {
119
+ _dbSingleton.close();
120
+ }
121
+ catch { /* best effort */ }
122
+ }
101
123
  _dbSingleton = new OpenClawSessionDB({ dbPath });
124
+ _dbSingletonPath = dbPath;
102
125
  _dbSingleton.cleanupOldSessions(7);
103
126
  }
104
127
  return _dbSingleton;
@@ -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.145",
6
+ "version": "1.0.146",
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.145",
3
+ "version": "1.0.146",
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",