context-mode 1.0.51 → 1.0.52

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.51"
9
+ "version": "1.0.52"
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.51",
16
+ "version": "1.0.52",
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.51",
3
+ "version": "1.0.52",
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.51",
6
+ "version": "1.0.52",
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.51",
3
+ "version": "1.0.52",
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",
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import "../suppress-stderr.mjs";
3
+ import "../ensure-deps.mjs";
3
4
  /**
4
5
  * Cursor postToolUse hook — session event capture.
5
6
  */
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import "../suppress-stderr.mjs";
3
+ import "../ensure-deps.mjs";
3
4
  /**
4
5
  * Cursor sessionStart hook for context-mode.
5
6
  */
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Shared dependency bootstrap for hooks and start.mjs.
3
+ *
4
+ * Single source of truth — ensures native deps (better-sqlite3) are
5
+ * installed in the plugin cache before any hook or server code runs.
6
+ *
7
+ * Pattern: same as suppress-stderr.mjs — imported at the top of every
8
+ * hook that needs native modules. Fast path: existsSync check (~0.1ms).
9
+ * Slow path: npm install (first run only, ~5-30s).
10
+ *
11
+ * @see https://github.com/mksglu/context-mode/issues/172
12
+ */
13
+
14
+ import { existsSync } from "node:fs";
15
+ import { execSync } from "node:child_process";
16
+ import { resolve, dirname } from "node:path";
17
+ import { fileURLToPath } from "node:url";
18
+
19
+ const __dirname = dirname(fileURLToPath(import.meta.url));
20
+ const root = resolve(__dirname, "..");
21
+
22
+ const NATIVE_DEPS = ["better-sqlite3"];
23
+
24
+ export function ensureDeps() {
25
+ for (const pkg of NATIVE_DEPS) {
26
+ if (!existsSync(resolve(root, "node_modules", pkg))) {
27
+ try {
28
+ execSync(`npm install ${pkg} --no-package-lock --no-save --silent`, {
29
+ cwd: root,
30
+ stdio: "pipe",
31
+ timeout: 120000,
32
+ });
33
+ } catch { /* best effort — hook degrades gracefully without DB */ }
34
+ }
35
+ }
36
+ }
37
+
38
+ // Auto-run on import (like suppress-stderr.mjs)
39
+ ensureDeps();
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import "../suppress-stderr.mjs";
3
+ import "../ensure-deps.mjs";
3
4
  /**
4
5
  * Gemini CLI AfterTool hook — session event capture.
5
6
  *
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import "../suppress-stderr.mjs";
3
+ import "../ensure-deps.mjs";
3
4
  /**
4
5
  * Gemini CLI PreCompress hook — snapshot generation.
5
6
  *
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import "../suppress-stderr.mjs";
3
+ import "../ensure-deps.mjs";
3
4
  /**
4
5
  * Gemini CLI SessionStart hook for context-mode
5
6
  *
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import "../suppress-stderr.mjs";
3
+ import "../ensure-deps.mjs";
3
4
  /**
4
5
  * Kiro CLI PostToolUse hook — session event capture.
5
6
  * Must be fast (<20ms). No network, no LLM, just SQLite writes.
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import "./suppress-stderr.mjs";
3
+ import "./ensure-deps.mjs";
3
4
  /**
4
5
  * PostToolUse hook for context-mode session continuity.
5
6
  *
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import "./suppress-stderr.mjs";
3
+ import "./ensure-deps.mjs";
3
4
  /**
4
5
  * PreCompact hook for context-mode session continuity.
5
6
  *
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import "./suppress-stderr.mjs";
3
+ import "./ensure-deps.mjs";
3
4
  /**
4
5
  * SessionStart hook for context-mode
5
6
  *
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import "./suppress-stderr.mjs";
3
+ import "./ensure-deps.mjs";
3
4
  /**
4
5
  * UserPromptSubmit hook for context-mode session continuity.
5
6
  *
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import "../suppress-stderr.mjs";
3
+ import "../ensure-deps.mjs";
3
4
  /**
4
5
  * VS Code Copilot PostToolUse hook — session event capture.
5
6
  *
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import "../suppress-stderr.mjs";
3
+ import "../ensure-deps.mjs";
3
4
  /**
4
5
  * VS Code Copilot PreCompact hook — snapshot generation.
5
6
  *
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import "../suppress-stderr.mjs";
3
+ import "../ensure-deps.mjs";
3
4
  /**
4
5
  * VS Code Copilot SessionStart hook for context-mode
5
6
  *
@@ -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.51",
6
+ "version": "1.0.52",
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.51",
3
+ "version": "1.0.52",
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",
package/start.mjs CHANGED
@@ -115,14 +115,16 @@ if (cacheMatch) {
115
115
  }
116
116
  }
117
117
 
118
- // Ensure external dependencies are available
119
- for (const pkg of ["better-sqlite3", "turndown", "turndown-plugin-gfm", "@mixmark-io/domino"]) {
118
+ // Ensure native dependencies are available (shared with hooks via ensure-deps.mjs)
119
+ import { ensureDeps } from "./hooks/ensure-deps.mjs";
120
+ // ensure-deps handles better-sqlite3; also install pure-JS deps used by server
121
+ for (const pkg of ["turndown", "turndown-plugin-gfm", "@mixmark-io/domino"]) {
120
122
  if (!existsSync(resolve(__dirname, "node_modules", pkg))) {
121
123
  try {
122
124
  execSync(`npm install ${pkg} --no-package-lock --no-save --silent`, {
123
125
  cwd: __dirname,
124
126
  stdio: "pipe",
125
- timeout: 60000,
127
+ timeout: 120000,
126
128
  });
127
129
  } catch { /* best effort */ }
128
130
  }