context-mode 1.0.37 → 1.0.39

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.37"
9
+ "version": "1.0.39"
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.37",
16
+ "version": "1.0.39",
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.37",
3
+ "version": "1.0.39",
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.37",
6
+ "version": "1.0.39",
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.37",
3
+ "version": "1.0.39",
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",
package/build/cli.js CHANGED
@@ -396,8 +396,8 @@ async function upgrade() {
396
396
  catch { /* parent may not exist */ }
397
397
  }
398
398
  const items = [
399
- "build", "src", "hooks", "skills", ".claude-plugin",
400
- "start.mjs", "native-abi.mjs", "server.bundle.mjs", "cli.bundle.mjs", "package.json",
399
+ "build", "src", "hooks", "skills", "scripts", ".claude-plugin",
400
+ "start.mjs", "server.bundle.mjs", "cli.bundle.mjs", "package.json",
401
401
  ];
402
402
  for (const item of items) {
403
403
  try {
package/cli.bundle.mjs CHANGED
@@ -524,7 +524,7 @@ ${be("gray",d+Rh.repeat(c+2)+A0)}
524
524
  Run: ${h.fix}`):""));I.step("Checking hook script...");let l=dt(c,"hooks","pretooluse.mjs");try{o0(l,s0.R_OK),I.success(T.default.green("Hook script exists: PASS")+T.default.dim(` \u2014 ${l}`))}catch{I.error(T.default.red("Hook script exists: FAIL")+T.default.dim(` \u2014 not found at ${l}`))}I.step(`Checking ${e.name} plugin registration...`);let d=e.checkPluginRegistration();d.status==="pass"?I.success(T.default.green("Plugin enabled: PASS")+T.default.dim(` \u2014 ${d.message}`)):I.warn(T.default.yellow("Plugin enabled: WARN")+` \u2014 ${d.message}`),I.step("Checking FTS5 / SQLite...");try{let h=(await Promise.resolve().then(()=>(ii(),Ek))).loadDatabase(),g=new h(":memory:");g.exec("CREATE VIRTUAL TABLE fts_test USING fts5(content)"),g.exec("INSERT INTO fts_test(content) VALUES ('hello world')");let _=g.prepare("SELECT * FROM fts_test WHERE fts_test MATCH 'hello'").get();g.close(),_&&_.content==="hello world"?I.success(T.default.green("FTS5 / SQLite: PASS")+" \u2014 native module works"):(r++,I.error(T.default.red("FTS5 / SQLite: FAIL")+" \u2014 query returned unexpected result"))}catch(h){let g=h instanceof Error?h.message:String(h);g.includes("Cannot find module")||g.includes("MODULE_NOT_FOUND")?I.warn(T.default.yellow("FTS5 / better-sqlite3: SKIP")+T.default.dim(" \u2014 module not available (restart session after upgrade)")):(r++,I.error(T.default.red("FTS5 / better-sqlite3: FAIL")+` \u2014 ${g}`+T.default.dim(`
525
525
  Try: npm rebuild better-sqlite3`)))}I.step("Checking versions...");let m=a0(),f=await r2(),p=e.getInstalledVersion();return f==="unknown"?I.warn(T.default.yellow("npm (MCP): WARN")+` \u2014 local v${m}, could not reach npm registry`):m===f?I.success(T.default.green("npm (MCP): PASS")+` \u2014 v${m}`):I.warn(T.default.yellow("npm (MCP): WARN")+` \u2014 local v${m}, latest v${f}`+T.default.dim(`
526
526
  Run: /context-mode:ctx-upgrade`)),p==="not installed"?I.info(T.default.dim(`${e.name}: not installed`)+" \u2014 using standalone MCP mode"):f!=="unknown"&&p===f?I.success(T.default.green(`${e.name}: PASS`)+` \u2014 v${p}`):f!=="unknown"?I.warn(T.default.yellow(`${e.name}: WARN`)+` \u2014 v${p}, latest v${f}`+T.default.dim(`
527
- Run: /context-mode:ctx-upgrade`)):I.info(`${e.name}: v${p}`+T.default.dim(" \u2014 could not verify against npm registry")),r>0?(gi(T.default.red(`Diagnostics failed \u2014 ${r} critical issue(s) found`)),1):(gi(s.length>=4?T.default.green("Diagnostics complete!"):T.default.yellow("Some checks need attention \u2014 see above for details")),0)}async function o2(){process.stdout.isTTY&&console.clear();let t=Ko(),e=await Ni(t.platform);ou(T.default.bgCyan(T.default.black(" context-mode upgrade "))),I.info(`Platform: ${T.default.cyan(e.name)}`+T.default.dim(` (${t.confidence} confidence)`));let r=Bc(),n=[],o=iu();I.step("Pulling latest from GitHub...");let s=a0(),i=i0(JA(),`context-mode-upgrade-${Date.now()}`);o.start("Cloning mksglu/context-mode");try{Vr(`git clone --depth 1 https://github.com/mksglu/context-mode.git "${i}"`,{stdio:"pipe",timeout:3e4}),o.stop("Downloaded");let l=i,m=JSON.parse(n0(dt(l,"package.json"),"utf-8")).version??"unknown";m===s?I.success(T.default.green("Already on latest")+` \u2014 v${s}`):I.info(`Update available: ${T.default.yellow("v"+s)} \u2192 ${T.default.green("v"+m)}`),o.start("Installing dependencies & building"),Vr("npm install --no-audit --no-fund",{cwd:l,stdio:"pipe",timeout:6e4}),Vr("npm run build",{cwd:l,stdio:"pipe",timeout:3e4}),o.stop("Built successfully"),o.start("Updating files in-place");let f=r.match(/^(.*[\\/]plugins[\\/]cache[\\/][^\\/]+[\\/][^\\/]+[\\/])/);if(f){let g=f[1],_=r.replace(g,"").replace(/[\\/]/g,"");try{let y=VA(g).filter(S=>S!==_);for(let S of y)try{Vc(dt(g,S),{recursive:!0,force:!0})}catch{}y.length>0&&I.info(T.default.dim(` Cleaned ${y.length} stale cache dir(s)`))}catch{}}let p=["build","src","hooks","skills",".claude-plugin","start.mjs","native-abi.mjs","server.bundle.mjs","cli.bundle.mjs","package.json"];for(let g of p)try{Vc(dt(r,g),{recursive:!0,force:!0}),FA(dt(l,g),dt(r,g),{recursive:!0})}catch{}let h={mcpServers:{"context-mode":{command:"node",args:[dt(r,"start.mjs")]}}};HA(dt(r,".mcp.json"),JSON.stringify(h,null,2)+`
527
+ Run: /context-mode:ctx-upgrade`)):I.info(`${e.name}: v${p}`+T.default.dim(" \u2014 could not verify against npm registry")),r>0?(gi(T.default.red(`Diagnostics failed \u2014 ${r} critical issue(s) found`)),1):(gi(s.length>=4?T.default.green("Diagnostics complete!"):T.default.yellow("Some checks need attention \u2014 see above for details")),0)}async function o2(){process.stdout.isTTY&&console.clear();let t=Ko(),e=await Ni(t.platform);ou(T.default.bgCyan(T.default.black(" context-mode upgrade "))),I.info(`Platform: ${T.default.cyan(e.name)}`+T.default.dim(` (${t.confidence} confidence)`));let r=Bc(),n=[],o=iu();I.step("Pulling latest from GitHub...");let s=a0(),i=i0(JA(),`context-mode-upgrade-${Date.now()}`);o.start("Cloning mksglu/context-mode");try{Vr(`git clone --depth 1 https://github.com/mksglu/context-mode.git "${i}"`,{stdio:"pipe",timeout:3e4}),o.stop("Downloaded");let l=i,m=JSON.parse(n0(dt(l,"package.json"),"utf-8")).version??"unknown";m===s?I.success(T.default.green("Already on latest")+` \u2014 v${s}`):I.info(`Update available: ${T.default.yellow("v"+s)} \u2192 ${T.default.green("v"+m)}`),o.start("Installing dependencies & building"),Vr("npm install --no-audit --no-fund",{cwd:l,stdio:"pipe",timeout:6e4}),Vr("npm run build",{cwd:l,stdio:"pipe",timeout:3e4}),o.stop("Built successfully"),o.start("Updating files in-place");let f=r.match(/^(.*[\\/]plugins[\\/]cache[\\/][^\\/]+[\\/][^\\/]+[\\/])/);if(f){let g=f[1],_=r.replace(g,"").replace(/[\\/]/g,"");try{let y=VA(g).filter(S=>S!==_);for(let S of y)try{Vc(dt(g,S),{recursive:!0,force:!0})}catch{}y.length>0&&I.info(T.default.dim(` Cleaned ${y.length} stale cache dir(s)`))}catch{}}let p=["build","src","hooks","skills","scripts",".claude-plugin","start.mjs","server.bundle.mjs","cli.bundle.mjs","package.json"];for(let g of p)try{Vc(dt(r,g),{recursive:!0,force:!0}),FA(dt(l,g),dt(r,g),{recursive:!0})}catch{}let h={mcpServers:{"context-mode":{command:"node",args:[dt(r,"start.mjs")]}}};HA(dt(r,".mcp.json"),JSON.stringify(h,null,2)+`
528
528
  `),o.stop(T.default.green(`Updated in-place to v${m}`)),e.updatePluginRegistry(r,m),I.info(T.default.dim(" Registry synced to "+r)),o.start("Installing production dependencies"),Vr("npm install --production --no-audit --no-fund",{cwd:r,stdio:"pipe",timeout:6e4}),o.stop("Dependencies ready"),o.start("Rebuilding native addons");try{Vr("npm rebuild better-sqlite3",{cwd:r,stdio:"pipe",timeout:6e4}),o.stop(T.default.green("Native addons rebuilt")),n.push("Rebuilt better-sqlite3 for current Node.js")}catch(g){let _=g instanceof Error?g.message:String(g);o.stop(T.default.yellow("Native addon rebuild warning")),I.warn(T.default.yellow("better-sqlite3 rebuild issue")+` \u2014 ${_}`+T.default.dim(`
529
529
  Try manually: cd "${r}" && npm rebuild better-sqlite3`))}o.start("Updating npm global package");try{Vr(`npm install -g "${r}" --no-audit --no-fund`,{stdio:"pipe",timeout:3e4}),o.stop(T.default.green("npm global updated")),n.push("Updated npm global package")}catch{o.stop(T.default.yellow("npm global update skipped")),I.info(T.default.dim(" Could not update global npm \u2014 may need sudo or standalone install"))}Vc(i,{recursive:!0,force:!0}),n.push(m!==s?`Updated v${s} \u2192 v${m}`:`Reinstalled v${s} from GitHub`),I.success(T.default.green("Plugin reinstalled from GitHub!")+T.default.dim(` \u2014 v${m}`))}catch(l){let d=l instanceof Error?l.message:String(l);o.stop(T.default.red("Update failed")),I.error(T.default.red("GitHub pull failed")+` \u2014 ${d}`),I.info(T.default.dim("Continuing with hooks/settings fix..."));try{Vc(i,{recursive:!0,force:!0})}catch{}}I.step(`Backing up ${e.name} settings...`);let a=e.backupSettings();a?(I.success(T.default.green("Backup created")+T.default.dim(" -> "+a)),n.push("Backed up settings")):I.warn(T.default.yellow("No existing settings to backup")+" \u2014 a new one will be created"),I.step(`Configuring ${e.name} hooks...`);let c=e.configureAllHooks(r);for(let l of c)I.info(T.default.dim(` ${l}`)),n.push(l);I.success(T.default.green("Hooks configured")+T.default.dim(` \u2014 ${e.name}`)),I.step("Setting hook script permissions...");let u=e.setHookPermissions(r);if(process.platform!=="win32")for(let l of["build/cli.js","cli.bundle.mjs"]){let d=dt(r,l);try{o0(d,s0.F_OK),Vr(`chmod +x "${d}"`,{stdio:"ignore"}),u.push(d)}catch{}}u.length>0?(I.success(T.default.green("Permissions set")+T.default.dim(` \u2014 ${u.length} hook script(s)`)),n.push(`Set ${u.length} hook scripts as executable`)):I.error(T.default.red("No hook scripts found")+T.default.dim(" \u2014 expected in "+dt(r,"hooks"))),n.length>0?su(n.map(l=>T.default.green(" + ")+l).join(`
530
530
  `),"Changes Applied"):I.info(T.default.dim("No changes were needed.")),I.step("Running doctor to verify..."),console.log();try{let l=dt(r,"cli.bundle.mjs"),d=dt(r,"build","cli.js"),m=qA(l)?l:d;Vr(`node "${m}" doctor`,{stdio:"inherit",timeout:3e4,cwd:r})}catch{I.warn(T.default.yellow("Doctor had warnings")+T.default.dim(` \u2014 restart your ${e.name} session to pick up the new version`))}}export{mH as toUnixPath};
@@ -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.37",
6
+ "version": "1.0.39",
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.37",
3
+ "version": "1.0.39",
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",
@@ -8,7 +8,7 @@
8
8
  * Creates a directory junction so npm's %~dp0\node_modules\... resolves.
9
9
  */
10
10
 
11
- import { existsSync, mkdirSync, readFileSync } from "node:fs";
11
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
12
12
  import { execSync } from "node:child_process";
13
13
  import { dirname, resolve, join } from "node:path";
14
14
  import { fileURLToPath } from "node:url";
@@ -32,32 +32,75 @@ if (process.env.OPENCLAW_STATE_DIR) {
32
32
 
33
33
  if (process.platform === "win32" && process.env.npm_config_global === "true") {
34
34
  try {
35
- // Where npm puts bin shims (the directory the .cmd lives in)
36
- const binDir = execSync("npm bin -g", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim();
37
- // Where our package actually lives
35
+ // npm prefix is where both the .cmd shims and node_modules live
36
+ // Use npm_config_prefix env (set during install) or fall back to `npm config get prefix`
37
+ // Note: `npm bin -g` was removed in npm v9+, so we use prefix instead
38
+ const prefix = (
39
+ process.env.npm_config_prefix ||
40
+ execSync("npm config get prefix", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim()
41
+ );
42
+
38
43
  const actualPkgDir = pkgRoot;
39
- // Where the .cmd shim expects us to be
40
- const expectedPkgDir = join(binDir, "node_modules", "context-mode");
41
44
 
42
- // If shim expects a different path than where we actually are, create a junction
43
- if (
44
- resolve(expectedPkgDir).toLowerCase() !== resolve(actualPkgDir).toLowerCase() &&
45
- !existsSync(expectedPkgDir)
46
- ) {
47
- // Ensure parent node_modules dir exists
48
- const expectedNodeModules = join(binDir, "node_modules");
49
- if (!existsSync(expectedNodeModules)) {
50
- mkdirSync(expectedNodeModules, { recursive: true });
45
+ // npm's .cmd shim uses %~dp0\node_modules\<pkg>\... to find the entry point.
46
+ // On nvm4w, stale shims at C:\nvm4w\nodejs\ may exist alongside correct ones
47
+ // at the npm prefix. We create junctions at ALL known shim locations.
48
+ const shimDirs = new Set([prefix]);
49
+
50
+ // Detect stale shim locations via `where` command
51
+ try {
52
+ const whereOutput = execSync("where context-mode.cmd", {
53
+ encoding: "utf-8",
54
+ stdio: ["pipe", "pipe", "pipe"],
55
+ }).trim();
56
+ for (const line of whereOutput.split(/\r?\n/)) {
57
+ if (line.endsWith("context-mode.cmd")) {
58
+ shimDirs.add(dirname(line));
59
+ }
51
60
  }
61
+ } catch { /* where may fail if not installed yet */ }
62
+
63
+ for (const shimDir of shimDirs) {
64
+ const expectedPkgDir = join(shimDir, "node_modules", "context-mode");
65
+
66
+ if (
67
+ resolve(expectedPkgDir).toLowerCase() !== resolve(actualPkgDir).toLowerCase() &&
68
+ !existsSync(expectedPkgDir)
69
+ ) {
70
+ const expectedNodeModules = join(shimDir, "node_modules");
71
+ if (!existsSync(expectedNodeModules)) {
72
+ mkdirSync(expectedNodeModules, { recursive: true });
73
+ }
52
74
 
53
- // Create directory junction (no admin privileges needed on Windows 10+)
54
- execSync(`mklink /J "${expectedPkgDir}" "${actualPkgDir}"`, {
55
- shell: "cmd.exe",
56
- stdio: "pipe",
57
- });
58
- console.log(`\n context-mode: created junction for nvm4w compatibility`);
59
- console.log(` ${expectedPkgDir} → ${actualPkgDir}\n`);
75
+ // Create directory junction (no admin privileges needed on Windows 10+)
76
+ execSync(`mklink /J "${expectedPkgDir}" "${actualPkgDir}"`, {
77
+ shell: "cmd.exe",
78
+ stdio: "pipe",
79
+ });
80
+ console.log(`\n context-mode: created junction for nvm4w compatibility`);
81
+ console.log(` ${expectedPkgDir} → ${actualPkgDir}\n`);
82
+ }
60
83
  }
84
+
85
+ // Also fix stale shims that reference old bin entry (build/cli.js → cli.bundle.mjs)
86
+ try {
87
+ const whereOutput = execSync("where context-mode.cmd", {
88
+ encoding: "utf-8",
89
+ stdio: ["pipe", "pipe", "pipe"],
90
+ }).trim();
91
+ for (const line of whereOutput.split(/\r?\n/)) {
92
+ if (line.endsWith("context-mode.cmd")) {
93
+ const content = readFileSync(line, "utf-8");
94
+ if (content.includes("build\\cli.js") || content.includes("build/cli.js")) {
95
+ // Rewrite stale shim to use cli.bundle.mjs
96
+ const fixed = content
97
+ .replace(/build[\\\/]cli\.js/g, "cli.bundle.mjs");
98
+ writeFileSync(line, fixed);
99
+ console.log(` context-mode: fixed stale shim at ${line}`);
100
+ }
101
+ }
102
+ }
103
+ } catch { /* best effort */ }
61
104
  } catch {
62
105
  // Best effort — don't block install. User can use npx as fallback.
63
106
  }