context-mode 0.9.2 → 0.9.3

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.2",
16
+ "version": "0.9.3",
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.2",
3
+ "version": "0.9.3",
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
@@ -76,12 +76,26 @@ async function fetchLatestVersion() {
76
76
  }
77
77
  }
78
78
  function getMarketplaceVersion() {
79
- // Detect from our own path: .../plugins/cache/<marketplace>/<plugin>/<version>/
80
- const root = getPluginRoot();
81
- const match = root.match(/plugins\/cache\/[^/]+\/[^/]+\/(\d+\.\d+\.\d+[^/]*)/);
82
- if (match)
83
- return match[1];
84
- // Fallback: scan common plugin cache locations
79
+ // Primary: read from installed_plugins.json (source of truth for Claude Code)
80
+ try {
81
+ const ipPath = resolve(homedir(), ".claude", "plugins", "installed_plugins.json");
82
+ const ipRaw = JSON.parse(readFileSync(ipPath, "utf-8"));
83
+ const plugins = ipRaw.plugins ?? {};
84
+ for (const [key, entries] of Object.entries(plugins)) {
85
+ if (!key.toLowerCase().includes("context-mode"))
86
+ continue;
87
+ const arr = entries;
88
+ if (arr.length > 0 && typeof arr[0].version === "string") {
89
+ return arr[0].version;
90
+ }
91
+ }
92
+ }
93
+ catch { /* fallback below */ }
94
+ // Fallback: read from own package.json
95
+ const localVer = getLocalVersion();
96
+ if (localVer !== "unknown")
97
+ return localVer;
98
+ // Last resort: scan common plugin cache locations
85
99
  const bases = [
86
100
  resolve(homedir(), ".claude"),
87
101
  resolve(homedir(), ".config", "claude"),
@@ -378,26 +392,9 @@ async function upgrade() {
378
392
  timeout: 60000,
379
393
  });
380
394
  s.stop("Dependencies ready");
381
- // Step 2.5: Migrate versioned cache directory if version changed
382
- const cacheMatch = pluginRoot.match(/^(.*\/plugins\/cache\/[^/]+\/[^/]+\/)(\d+\.\d+\.\d+[^/]*)$/);
383
- if (cacheMatch && newVersion !== cacheMatch[2] && newVersion !== "unknown") {
384
- const oldDirVersion = cacheMatch[2];
385
- const newCacheDir = cacheMatch[1] + newVersion;
386
- s.start(`Migrating cache: ${oldDirVersion} → ${newVersion}`);
387
- try {
388
- rmSync(newCacheDir, { recursive: true, force: true });
389
- cpSync(pluginRoot, newCacheDir, { recursive: true });
390
- rmSync(pluginRoot, { recursive: true, force: true });
391
- pluginRoot = newCacheDir;
392
- s.stop(color.green(`Cache directory: ${newVersion}`));
393
- changes.push(`Migrated cache: ${oldDirVersion} → ${newVersion}`);
394
- }
395
- catch {
396
- s.stop(color.yellow("Cache migration skipped — using existing directory"));
397
- }
398
- }
399
- // Update installed_plugins.json so Claude Code loads from new path
395
+ // Step 2.5: Update installed_plugins.json to point to current directory with new version
400
396
  const installedPluginsPath = resolve(homedir(), ".claude", "plugins", "installed_plugins.json");
397
+ s.start("Updating plugin registry");
401
398
  try {
402
399
  const ipRaw = JSON.parse(readFileSync(installedPluginsPath, "utf-8"));
403
400
  const plugins = ipRaw.plugins ?? {};
@@ -414,12 +411,35 @@ async function upgrade() {
414
411
  }
415
412
  if (updated) {
416
413
  writeFileSync(installedPluginsPath, JSON.stringify(ipRaw, null, 2) + "\n", "utf-8");
417
- p.log.success(color.green("Plugin registry updated") + color.dim(` — installed_plugins.json`));
418
- changes.push("Updated plugin registry path");
414
+ s.stop(color.green("Plugin registry updated"));
415
+ changes.push("Updated plugin registry");
416
+ }
417
+ else {
418
+ s.stop(color.yellow("No context-mode entry found in plugin registry"));
419
419
  }
420
420
  }
421
- catch {
422
- p.log.warn(color.yellow("Could not update installed_plugins.json — marketplace may show old version"));
421
+ catch (err) {
422
+ 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 */ }
423
443
  }
424
444
  // Update global npm package from same GitHub source
425
445
  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.2",
3
+ "version": "0.9.3",
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",