context-mode 1.0.16 → 1.0.18
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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/build/executor.js +10 -10
- package/build/server.js +1 -29
- package/cli.bundle.mjs +104 -93
- package/package.json +1 -1
- package/server.bundle.mjs +77 -66
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
},
|
|
7
7
|
"metadata": {
|
|
8
8
|
"description": "Claude Code plugins by Mert Koseoğlu",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.18"
|
|
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.
|
|
16
|
+
"version": "1.0.18",
|
|
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.
|
|
3
|
+
"version": "1.0.18",
|
|
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",
|
package/build/executor.js
CHANGED
|
@@ -396,28 +396,28 @@ export class PolyglotExecutor {
|
|
|
396
396
|
switch (language) {
|
|
397
397
|
case "javascript":
|
|
398
398
|
case "typescript":
|
|
399
|
-
return `const FILE_CONTENT_PATH = ${escaped};\nconst FILE_CONTENT = require("fs").readFileSync(FILE_CONTENT_PATH, "utf-8");\n${code}`;
|
|
399
|
+
return `const FILE_CONTENT_PATH = ${escaped};\nconst file_path = FILE_CONTENT_PATH;\nconst FILE_CONTENT = require("fs").readFileSync(FILE_CONTENT_PATH, "utf-8");\n${code}`;
|
|
400
400
|
case "python":
|
|
401
|
-
return `FILE_CONTENT_PATH = ${escaped}\nwith open(FILE_CONTENT_PATH, "r", encoding="utf-8") as _f:\n FILE_CONTENT = _f.read()\n${code}`;
|
|
401
|
+
return `FILE_CONTENT_PATH = ${escaped}\nfile_path = FILE_CONTENT_PATH\nwith open(FILE_CONTENT_PATH, "r", encoding="utf-8") as _f:\n FILE_CONTENT = _f.read()\n${code}`;
|
|
402
402
|
case "shell": {
|
|
403
403
|
// Single-quote the path to prevent $, backtick, and ! expansion
|
|
404
404
|
const sq = "'" + absolutePath.replace(/'/g, "'\\''") + "'";
|
|
405
|
-
return `FILE_CONTENT_PATH=${sq}\nFILE_CONTENT=$(cat ${sq})\n${code}`;
|
|
405
|
+
return `FILE_CONTENT_PATH=${sq}\nfile_path=${sq}\nFILE_CONTENT=$(cat ${sq})\n${code}`;
|
|
406
406
|
}
|
|
407
407
|
case "ruby":
|
|
408
|
-
return `FILE_CONTENT_PATH = ${escaped}\nFILE_CONTENT = File.read(FILE_CONTENT_PATH, encoding: "utf-8")\n${code}`;
|
|
408
|
+
return `FILE_CONTENT_PATH = ${escaped}\nfile_path = FILE_CONTENT_PATH\nFILE_CONTENT = File.read(FILE_CONTENT_PATH, encoding: "utf-8")\n${code}`;
|
|
409
409
|
case "go":
|
|
410
|
-
return `package main\n\nimport (\n\t"fmt"\n\t"os"\n)\n\nvar FILE_CONTENT_PATH = ${escaped}\n\nfunc main() {\n\tb, _ := os.ReadFile(FILE_CONTENT_PATH)\n\tFILE_CONTENT := string(b)\n\t_ = FILE_CONTENT\n\t_ = fmt.Sprint()\n${code}\n}\n`;
|
|
410
|
+
return `package main\n\nimport (\n\t"fmt"\n\t"os"\n)\n\nvar FILE_CONTENT_PATH = ${escaped}\nvar file_path = FILE_CONTENT_PATH\n\nfunc main() {\n\tb, _ := os.ReadFile(FILE_CONTENT_PATH)\n\tFILE_CONTENT := string(b)\n\t_ = FILE_CONTENT\n\t_ = fmt.Sprint()\n${code}\n}\n`;
|
|
411
411
|
case "rust":
|
|
412
|
-
return `use std::fs;\n\nfn main() {\n let file_content_path = ${escaped};\n let file_content = fs::read_to_string(file_content_path).unwrap();\n${code}\n}\n`;
|
|
412
|
+
return `use std::fs;\n\nfn main() {\n let file_content_path = ${escaped};\n let file_path = file_content_path;\n let file_content = fs::read_to_string(file_content_path).unwrap();\n${code}\n}\n`;
|
|
413
413
|
case "php":
|
|
414
|
-
return `<?php\n$FILE_CONTENT_PATH = ${escaped};\n$FILE_CONTENT = file_get_contents($FILE_CONTENT_PATH);\n${code}`;
|
|
414
|
+
return `<?php\n$FILE_CONTENT_PATH = ${escaped};\n$file_path = $FILE_CONTENT_PATH;\n$FILE_CONTENT = file_get_contents($FILE_CONTENT_PATH);\n${code}`;
|
|
415
415
|
case "perl":
|
|
416
|
-
return `my $FILE_CONTENT_PATH = ${escaped};\nopen(my $fh, '<:encoding(UTF-8)', $FILE_CONTENT_PATH) or die "Cannot open: $!";\nmy $FILE_CONTENT = do { local $/; <$fh> };\nclose($fh);\n${code}`;
|
|
416
|
+
return `my $FILE_CONTENT_PATH = ${escaped};\nmy $file_path = $FILE_CONTENT_PATH;\nopen(my $fh, '<:encoding(UTF-8)', $FILE_CONTENT_PATH) or die "Cannot open: $!";\nmy $FILE_CONTENT = do { local $/; <$fh> };\nclose($fh);\n${code}`;
|
|
417
417
|
case "r":
|
|
418
|
-
return `FILE_CONTENT_PATH <- ${escaped}\nFILE_CONTENT <- readLines(FILE_CONTENT_PATH, warn=FALSE, encoding="UTF-8")\nFILE_CONTENT <- paste(FILE_CONTENT, collapse="\\n")\n${code}`;
|
|
418
|
+
return `FILE_CONTENT_PATH <- ${escaped}\nfile_path <- FILE_CONTENT_PATH\nFILE_CONTENT <- readLines(FILE_CONTENT_PATH, warn=FALSE, encoding="UTF-8")\nFILE_CONTENT <- paste(FILE_CONTENT, collapse="\\n")\n${code}`;
|
|
419
419
|
case "elixir":
|
|
420
|
-
return `file_content_path = ${escaped}\nfile_content = File.read!(file_content_path)\n${code}`;
|
|
420
|
+
return `file_content_path = ${escaped}\nfile_path = file_content_path\nfile_content = File.read!(file_content_path)\n${code}`;
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
423
|
}
|
package/build/server.js
CHANGED
|
@@ -13,8 +13,7 @@ import { ContentStore, cleanupStaleDBs } from "./store.js";
|
|
|
13
13
|
import { readBashPolicies, evaluateCommandDenyOnly, extractShellCommands, readToolDenyPatterns, evaluateFilePath, } from "./security.js";
|
|
14
14
|
import { detectRuntimes, getRuntimeSummary, getAvailableLanguages, hasBunRuntime, } from "./runtime.js";
|
|
15
15
|
import { classifyNonZeroExit } from "./exit-classify.js";
|
|
16
|
-
|
|
17
|
-
const VERSION = "1.0.16";
|
|
16
|
+
const VERSION = "1.0.18";
|
|
18
17
|
// Prevent silent server death from unhandled async errors
|
|
19
18
|
process.on("unhandledRejection", (err) => {
|
|
20
19
|
process.stderr.write(`[context-mode] unhandledRejection: ${err}\n`);
|
|
@@ -1455,16 +1454,8 @@ async function main() {
|
|
|
1455
1454
|
executor.cleanupBackgrounded();
|
|
1456
1455
|
if (_store)
|
|
1457
1456
|
_store.cleanup();
|
|
1458
|
-
try {
|
|
1459
|
-
destroySync();
|
|
1460
|
-
}
|
|
1461
|
-
catch { /* sync cleanup is best-effort */ }
|
|
1462
1457
|
};
|
|
1463
1458
|
const gracefulShutdown = async () => {
|
|
1464
|
-
try {
|
|
1465
|
-
await flushSync();
|
|
1466
|
-
}
|
|
1467
|
-
catch { /* flush is best-effort */ }
|
|
1468
1459
|
shutdown();
|
|
1469
1460
|
process.exit(0);
|
|
1470
1461
|
};
|
|
@@ -1487,25 +1478,6 @@ async function main() {
|
|
|
1487
1478
|
}
|
|
1488
1479
|
}
|
|
1489
1480
|
catch { /* best effort — don't block server startup */ }
|
|
1490
|
-
// Initialize cloud sync (fire-and-forget, never blocks server)
|
|
1491
|
-
try {
|
|
1492
|
-
const syncProjectDir = process.env.CLAUDE_PROJECT_DIR ?? process.cwd();
|
|
1493
|
-
const syncSessionId = createHash("sha256").update(syncProjectDir + ":" + Date.now()).digest("hex").slice(0, 16);
|
|
1494
|
-
let gitRemote;
|
|
1495
|
-
try {
|
|
1496
|
-
const { execSync } = await import("node:child_process");
|
|
1497
|
-
gitRemote = execSync("git remote get-url origin", {
|
|
1498
|
-
cwd: syncProjectDir,
|
|
1499
|
-
timeout: 3000,
|
|
1500
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
1501
|
-
}).toString().trim() || undefined;
|
|
1502
|
-
}
|
|
1503
|
-
catch { /* no git remote available */ }
|
|
1504
|
-
const syncOk = initSync(syncSessionId, syncProjectDir, gitRemote);
|
|
1505
|
-
if (syncOk)
|
|
1506
|
-
console.error("[context-mode] Cloud sync initialized");
|
|
1507
|
-
}
|
|
1508
|
-
catch { /* sync init failure must never block the plugin */ }
|
|
1509
1481
|
console.error(`Context Mode MCP server v${VERSION} running on stdio`);
|
|
1510
1482
|
console.error(`Detected runtimes:\n${getRuntimeSummary(runtimes)}`);
|
|
1511
1483
|
if (!hasBunRuntime()) {
|