context-mode 0.9.6 → 0.9.7

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.6",
16
+ "version": "0.9.7",
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.6",
3
+ "version": "0.9.7",
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
@@ -370,21 +370,31 @@ async function upgrade() {
370
370
  timeout: 30000,
371
371
  });
372
372
  s.stop("Built successfully");
373
- // Step 3: Copy to plugin root
374
- s.start("Installing files");
375
- const items = [
376
- "build", "src", "hooks", "skills", ".claude-plugin",
377
- "start.mjs", "server.bundle.mjs", "package.json", ".mcp.json",
378
- ];
379
- for (const item of items) {
373
+ // Step 3: Nuke entire cache parent and install fresh with correct version dir
374
+ s.start("Installing fresh");
375
+ const cacheParentMatch = pluginRoot.match(/^(.*[\\/]plugins[\\/]cache[\\/][^\\/]+[\\/][^\\/]+[\\/])/);
376
+ const freshDir = cacheParentMatch
377
+ ? resolve(cacheParentMatch[1], newVersion)
378
+ : pluginRoot;
379
+ // Wipe all old cache directories
380
+ if (cacheParentMatch) {
381
+ const cacheParent = cacheParentMatch[1];
380
382
  try {
381
- rmSync(resolve(pluginRoot, item), { recursive: true, force: true });
382
- cpSync(resolve(srcDir, item), resolve(pluginRoot, item), { recursive: true });
383
+ const oldDirs = readdirSync(cacheParent);
384
+ for (const d of oldDirs) {
385
+ try {
386
+ rmSync(resolve(cacheParent, d), { recursive: true, force: true });
387
+ }
388
+ catch { /* skip */ }
389
+ }
383
390
  }
384
- catch { /* some files may not exist */ }
391
+ catch { /* parent may not exist */ }
385
392
  }
386
- s.stop(color.green("Files installed"));
387
- // Install production deps in plugin root
393
+ // Copy entire built source to fresh version directory
394
+ cpSync(srcDir, freshDir, { recursive: true });
395
+ pluginRoot = freshDir;
396
+ s.stop(color.green(`Installed to ${newVersion}`));
397
+ // Install production deps in fresh dir
388
398
  s.start("Installing production dependencies");
389
399
  execSync("npm install --production --no-audit --no-fund", {
390
400
  cwd: pluginRoot,
@@ -392,13 +402,12 @@ async function upgrade() {
392
402
  timeout: 60000,
393
403
  });
394
404
  s.stop("Dependencies ready");
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
405
+ // Step 4: Update installed_plugins.json via spawned script (works from any old version)
397
406
  s.start("Updating plugin registry");
398
407
  try {
399
408
  const scriptPath = resolve(tmpDir + "-post-upgrade.mjs");
400
409
  const scriptContent = [
401
- `import { readFileSync, writeFileSync, readdirSync, rmSync } from "fs";`,
410
+ `import { readFileSync, writeFileSync } from "fs";`,
402
411
  `import { resolve } from "path";`,
403
412
  `import { homedir } from "os";`,
404
413
  `const pluginRoot = ${JSON.stringify(pluginRoot)};`,
@@ -422,16 +431,6 @@ async function upgrade() {
422
431
  ` console.log("REGISTRY_UPDATED");`,
423
432
  ` }`,
424
433
  `} 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
434
  ].join("\n");
436
435
  writeFileSync(scriptPath, scriptContent, "utf-8");
437
436
  const result = execSync(`node ${scriptPath}`, {
@@ -450,10 +449,6 @@ async function upgrade() {
450
449
  else {
451
450
  s.stop(color.yellow("Plugin registry unchanged"));
452
451
  }
453
- const cleanMatch = result.match(/CLEANED:(\d+)/);
454
- if (cleanMatch) {
455
- p.log.info(color.dim(` Cleaned ${cleanMatch[1]} old cache dir(s)`));
456
- }
457
452
  }
458
453
  catch (err) {
459
454
  s.stop(color.yellow("Plugin registry update skipped"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "0.9.6",
3
+ "version": "0.9.7",
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",