context-mode 0.9.5 → 0.9.6

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.
@@ -13,7 +13,7 @@
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": "0.9.5",
16
+ "version": "0.9.6",
17
17
  "author": {
18
18
  "name": "Mert Koseoğlu"
19
19
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
4
4
  "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.",
5
5
  "author": {
6
6
  "name": "Mert Koseoğlu",
package/build/cli.js CHANGED
@@ -392,55 +392,57 @@ async function upgrade() {
392
392
  timeout: 60000,
393
393
  });
394
394
  s.stop("Dependencies ready");
395
- // Step 2.5: Spawn post-upgrade from NEW code on disk to update registry & clean cache
396
- // This ensures even users upgrading from old versions get the fix
395
+ // Step 2.5: Write temp script and spawn to update registry & clean cache
396
+ // Uses a file instead of node -e to avoid shell escaping issues
397
397
  s.start("Updating plugin registry");
398
398
  try {
399
- const postUpgradeScript = `
400
- const fs = require("fs");
401
- const path = require("path");
402
- const home = require("os").homedir();
403
- const pluginRoot = ${JSON.stringify(pluginRoot)};
404
- const newVersion = ${JSON.stringify(newVersion)};
405
-
406
- // Update installed_plugins.json
407
- const ipPath = path.resolve(home, ".claude", "plugins", "installed_plugins.json");
408
- try {
409
- const ipRaw = JSON.parse(fs.readFileSync(ipPath, "utf-8"));
410
- const plugins = ipRaw.plugins || {};
411
- let updated = false;
412
- for (const [key, entries] of Object.entries(plugins)) {
413
- if (!key.toLowerCase().includes("context-mode")) continue;
414
- for (const entry of entries) {
415
- entry.installPath = pluginRoot;
416
- entry.version = newVersion;
417
- entry.lastUpdated = new Date().toISOString();
418
- updated = true;
419
- }
420
- }
421
- if (updated) {
422
- fs.writeFileSync(ipPath, JSON.stringify(ipRaw, null, 2) + "\\n", "utf-8");
423
- console.log("REGISTRY_UPDATED");
424
- }
425
- } catch (e) { console.error("REGISTRY_FAILED:" + e.message); }
426
-
427
- // Clean old cache directories
428
- const m = pluginRoot.match(/^(.*\\/plugins\\/cache\\/[^/]+\\/[^/]+\\/)([^/]+)$/);
429
- if (m) {
430
- try {
431
- const dirs = fs.readdirSync(m[1]).filter(d => d !== m[2]);
432
- for (const old of dirs) {
433
- try { fs.rmSync(path.resolve(m[1], old), { recursive: true, force: true }); } catch {}
434
- }
435
- if (dirs.length > 0) console.log("CLEANED:" + dirs.length);
436
- } catch {}
437
- }
438
- `;
439
- const result = execSync(`node -e ${JSON.stringify(postUpgradeScript)}`, {
399
+ const scriptPath = resolve(tmpDir + "-post-upgrade.mjs");
400
+ const scriptContent = [
401
+ `import { readFileSync, writeFileSync, readdirSync, rmSync } from "fs";`,
402
+ `import { resolve } from "path";`,
403
+ `import { homedir } from "os";`,
404
+ `const pluginRoot = ${JSON.stringify(pluginRoot)};`,
405
+ `const newVersion = ${JSON.stringify(newVersion)};`,
406
+ `const ipPath = resolve(homedir(), ".claude", "plugins", "installed_plugins.json");`,
407
+ `try {`,
408
+ ` const ipRaw = JSON.parse(readFileSync(ipPath, "utf-8"));`,
409
+ ` const plugins = ipRaw.plugins || {};`,
410
+ ` let updated = false;`,
411
+ ` for (const [key, entries] of Object.entries(plugins)) {`,
412
+ ` if (!key.toLowerCase().includes("context-mode")) continue;`,
413
+ ` for (const entry of entries) {`,
414
+ ` entry.installPath = pluginRoot;`,
415
+ ` entry.version = newVersion;`,
416
+ ` entry.lastUpdated = new Date().toISOString();`,
417
+ ` updated = true;`,
418
+ ` }`,
419
+ ` }`,
420
+ ` if (updated) {`,
421
+ ` writeFileSync(ipPath, JSON.stringify(ipRaw, null, 2) + "\\n", "utf-8");`,
422
+ ` console.log("REGISTRY_UPDATED");`,
423
+ ` }`,
424
+ `} catch (e) { console.error("REGISTRY_FAILED:" + e.message); }`,
425
+ `const m = pluginRoot.match(/^(.*[\\\\/]plugins[\\\\/]cache[\\\\/][^\\\\/]+[\\\\/][^\\\\/]+[\\\\/])([^\\\\/]+)$/);`,
426
+ `if (m) {`,
427
+ ` try {`,
428
+ ` const dirs = readdirSync(m[1]).filter(d => d !== m[2]);`,
429
+ ` for (const old of dirs) {`,
430
+ ` try { rmSync(resolve(m[1], old), { recursive: true, force: true }); } catch {}`,
431
+ ` }`,
432
+ ` if (dirs.length > 0) console.log("CLEANED:" + dirs.length);`,
433
+ ` } catch {}`,
434
+ `}`,
435
+ ].join("\n");
436
+ writeFileSync(scriptPath, scriptContent, "utf-8");
437
+ const result = execSync(`node ${scriptPath}`, {
440
438
  stdio: "pipe",
441
439
  timeout: 10000,
442
440
  encoding: "utf-8",
443
441
  });
442
+ try {
443
+ rmSync(scriptPath, { force: true });
444
+ }
445
+ catch { /* ignore */ }
444
446
  if (result.includes("REGISTRY_UPDATED")) {
445
447
  s.stop(color.green("Plugin registry updated"));
446
448
  changes.push("Updated plugin registry");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
4
4
  "type": "module",
5
5
  "description": "Claude Code MCP plugin that saves 98% of your context window. Sandboxed code execution, FTS5 knowledge base, and intent-driven search.",
6
6
  "author": "Mert Koseoğlu",