context-mode 1.0.50 → 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.
@@ -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.50",
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.50",
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",
@@ -59,7 +59,7 @@
59
59
  "LICENSE"
60
60
  ],
61
61
  "scripts": {
62
- "build": "tsc && node -e \"if(process.platform!=='win32'){require('fs').chmodSync('build/cli.js',0o755)}\"",
62
+ "build": "tsc && node -e \"if(process.platform!=='win32'){require('fs').chmodSync('build/cli.js',0o755)}\" && npm run bundle",
63
63
  "bundle": "esbuild src/server.ts --bundle --platform=node --target=node18 --format=esm --outfile=server.bundle.mjs --external:better-sqlite3 --external:turndown --external:turndown-plugin-gfm --external:@mixmark-io/domino --minify && esbuild src/cli.ts --bundle --platform=node --target=node18 --format=esm --outfile=cli.bundle.mjs --external:better-sqlite3 --minify && esbuild src/session/extract.ts --bundle --platform=node --target=node18 --format=esm --outfile=hooks/session-extract.bundle.mjs --minify && esbuild src/session/snapshot.ts --bundle --platform=node --target=node18 --format=esm --outfile=hooks/session-snapshot.bundle.mjs --minify && esbuild src/session/db.ts --bundle --platform=node --target=node18 --format=esm --outfile=hooks/session-db.bundle.mjs --external:better-sqlite3 --minify",
64
64
  "version-sync": "node scripts/version-sync.mjs",
65
65
  "version": "node scripts/version-sync.mjs && git add .claude-plugin/plugin.json .claude-plugin/marketplace.json .openclaw-plugin/openclaw.plugin.json .openclaw-plugin/package.json openclaw.plugin.json .pi/extensions/context-mode/package.json",