context-mode 0.9.3 → 0.9.4

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.3",
16
+ "version": "0.9.4",
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.3",
3
+ "version": "0.9.4",
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,54 +392,70 @@ async function upgrade() {
392
392
  timeout: 60000,
393
393
  });
394
394
  s.stop("Dependencies ready");
395
- // Step 2.5: Update installed_plugins.json to point to current directory with new version
396
- const installedPluginsPath = resolve(homedir(), ".claude", "plugins", "installed_plugins.json");
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
397
397
  s.start("Updating plugin registry");
398
398
  try {
399
- const ipRaw = JSON.parse(readFileSync(installedPluginsPath, "utf-8"));
400
- const plugins = ipRaw.plugins ?? {};
401
- let updated = false;
402
- for (const [key, entries] of Object.entries(plugins)) {
403
- if (!key.toLowerCase().includes("context-mode"))
404
- continue;
405
- for (const entry of entries) {
406
- entry.installPath = pluginRoot;
407
- entry.version = newVersion;
408
- entry.lastUpdated = new Date().toISOString();
409
- updated = true;
410
- }
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 {}
411
434
  }
412
- if (updated) {
413
- writeFileSync(installedPluginsPath, JSON.stringify(ipRaw, null, 2) + "\n", "utf-8");
435
+ if (dirs.length > 0) console.log("CLEANED:" + dirs.length);
436
+ } catch {}
437
+ }
438
+ `;
439
+ const result = execSync(`node -e ${JSON.stringify(postUpgradeScript)}`, {
440
+ stdio: "pipe",
441
+ timeout: 10000,
442
+ encoding: "utf-8",
443
+ });
444
+ if (result.includes("REGISTRY_UPDATED")) {
414
445
  s.stop(color.green("Plugin registry updated"));
415
446
  changes.push("Updated plugin registry");
416
447
  }
417
448
  else {
418
- s.stop(color.yellow("No context-mode entry found in plugin registry"));
449
+ s.stop(color.yellow("Plugin registry unchanged"));
450
+ }
451
+ const cleanMatch = result.match(/CLEANED:(\d+)/);
452
+ if (cleanMatch) {
453
+ p.log.info(color.dim(` Cleaned ${cleanMatch[1]} old cache dir(s)`));
419
454
  }
420
455
  }
421
456
  catch (err) {
422
457
  s.stop(color.yellow("Plugin registry update skipped"));
423
- p.log.warn(color.yellow("Could not update installed_plugins.json") + color.dim(` — ${err instanceof Error ? err.message : String(err)}`));
424
- }
425
- // Clean up old cache directories (keep only current)
426
- const cacheMatch = pluginRoot.match(/^(.*\/plugins\/cache\/[^/]+\/[^/]+\/)([^/]+)$/);
427
- if (cacheMatch) {
428
- const cacheParent = cacheMatch[1];
429
- const currentDir = cacheMatch[2];
430
- try {
431
- const dirs = readdirSync(cacheParent).filter(d => d !== currentDir);
432
- for (const old of dirs) {
433
- try {
434
- rmSync(resolve(cacheParent, old), { recursive: true, force: true });
435
- }
436
- catch { /* skip */ }
437
- }
438
- if (dirs.length > 0) {
439
- p.log.info(color.dim(` Cleaned ${dirs.length} old cache dir(s)`));
440
- }
441
- }
442
- catch { /* parent doesn't exist or not readable */ }
458
+ p.log.warn(color.yellow("Could not update plugin registry") + color.dim(` — ${err instanceof Error ? err.message : String(err)}`));
443
459
  }
444
460
  // Update global npm package from same GitHub source
445
461
  s.start("Updating npm global package");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
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",