context-mode 1.0.41 → 1.0.42
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/.openclaw-plugin/openclaw.plugin.json +1 -1
- package/.openclaw-plugin/package.json +1 -1
- package/README.md +49 -49
- package/build/openclaw-plugin.js +1 -1
- package/build/opencode-plugin.js +1 -1
- package/build/server.js +11 -7
- package/cli.bundle.mjs +77 -77
- package/hooks/core/routing.mjs +29 -11
- package/hooks/core/tool-naming.mjs +50 -0
- package/hooks/cursor/pretooluse.mjs +1 -1
- package/hooks/cursor/sessionstart.mjs +4 -1
- package/hooks/gemini-cli/beforetool.mjs +1 -1
- package/hooks/gemini-cli/sessionstart.mjs +4 -1
- package/hooks/kiro/pretooluse.mjs +1 -1
- package/hooks/pretooluse.mjs +1 -1
- package/hooks/routing-block.mjs +34 -8
- package/hooks/sessionstart.mjs +4 -1
- package/hooks/vscode-copilot/pretooluse.mjs +1 -1
- package/hooks/vscode-copilot/sessionstart.mjs +4 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/server.bundle.mjs +52 -52
- package/start.mjs +8 -65
package/start.mjs
CHANGED
|
@@ -56,71 +56,14 @@ if (!process.env.CLAUDE_PROJECT_DIR) {
|
|
|
56
56
|
process.env.CLAUDE_PROJECT_DIR = originalCwd;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"CLAUDE_SESSION_ID", // Claude Code
|
|
68
|
-
"GEMINI_PROJECT_DIR", // Gemini CLI (GEMINI_CLI also valid)
|
|
69
|
-
"OPENCODE", // OpenCode (OPENCODE_PID also valid)
|
|
70
|
-
"OPENCLAW_HOME", // OpenClaw (user-set home dir)
|
|
71
|
-
"OPENCLAW_CLI", // OpenClaw (set at runtime by openclaw CLI)
|
|
72
|
-
// VS Code Copilot: VSCODE_PID is too broad (set for ALL VS Code extensions).
|
|
73
|
-
// Accept occasional harmless write rather than false-positive suppression.
|
|
74
|
-
];
|
|
75
|
-
const hasHookSupport = hookCapableSessionVars.some((e) => process.env[e]);
|
|
76
|
-
|
|
77
|
-
if (!hasHookSupport) {
|
|
78
|
-
const projectDir =
|
|
79
|
-
process.env.CLAUDE_PROJECT_DIR ||
|
|
80
|
-
process.env.GEMINI_PROJECT_DIR ||
|
|
81
|
-
process.env.VSCODE_CWD ||
|
|
82
|
-
process.cwd();
|
|
83
|
-
|
|
84
|
-
const configsDir = resolve(__dirname, "configs");
|
|
85
|
-
|
|
86
|
-
// Detect platform and determine instruction file
|
|
87
|
-
const platformConfigs = [
|
|
88
|
-
{ env: ["CLAUDE_PROJECT_DIR"], dir: "claude-code", file: "CLAUDE.md", target: "CLAUDE.md" },
|
|
89
|
-
{ env: ["GEMINI_PROJECT_DIR"], dir: "gemini-cli", file: "GEMINI.md", target: "GEMINI.md" },
|
|
90
|
-
{ env: ["VSCODE_CWD"], dir: "vscode-copilot", file: "copilot-instructions.md", target: ".github/copilot-instructions.md" },
|
|
91
|
-
{ env: ["OPENCODE_PROJECT_DIR"], dir: "opencode", file: "AGENTS.md", target: "AGENTS.md" },
|
|
92
|
-
{ env: ["OPENCLAW_HOME"], dir: "openclaw", file: "AGENTS.md", target: "AGENTS.md" },
|
|
93
|
-
{ env: ["CODEX_HOME"], dir: "codex", file: "AGENTS.md", target: "AGENTS.md" },
|
|
94
|
-
];
|
|
95
|
-
|
|
96
|
-
const detected = platformConfigs.find((p) => p.env.some((e) => process.env[e]));
|
|
97
|
-
if (detected) {
|
|
98
|
-
const targetPath = resolve(projectDir, detected.target);
|
|
99
|
-
const sourcePath = resolve(configsDir, detected.dir, detected.file);
|
|
100
|
-
|
|
101
|
-
// Ensure parent dir exists (for .github/copilot-instructions.md)
|
|
102
|
-
const targetDir = resolve(targetPath, "..");
|
|
103
|
-
if (!existsSync(targetDir)) {
|
|
104
|
-
const { mkdirSync } = await import("node:fs");
|
|
105
|
-
mkdirSync(targetDir, { recursive: true });
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (existsSync(sourcePath)) {
|
|
109
|
-
const content = readFileSync(sourcePath, "utf-8");
|
|
110
|
-
if (existsSync(targetPath)) {
|
|
111
|
-
const existing = readFileSync(targetPath, "utf-8");
|
|
112
|
-
if (!existing.includes("context-mode")) {
|
|
113
|
-
writeFileSync(targetPath, existing.trimEnd() + "\n\n" + content, "utf-8");
|
|
114
|
-
}
|
|
115
|
-
} else {
|
|
116
|
-
writeFileSync(targetPath, content, "utf-8");
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
} catch {
|
|
122
|
-
/* best effort — don't block server startup */
|
|
123
|
-
}
|
|
59
|
+
// Routing instructions file auto-write DISABLED for all platforms (#158, #164).
|
|
60
|
+
// Env vars like CLAUDE_SESSION_ID may not be set at MCP startup time, making
|
|
61
|
+
// the hook-capability guard unreliable. Writing to project dirs dirties git trees
|
|
62
|
+
// and causes double context injection on hook-capable platforms.
|
|
63
|
+
// Routing is handled by:
|
|
64
|
+
// - Hook-capable platforms: SessionStart hook injects ROUTING_BLOCK
|
|
65
|
+
// - Non-hook platforms: server.ts writeRoutingInstructions() on MCP connect
|
|
66
|
+
// - Future: explicit `context-mode init` command
|
|
124
67
|
|
|
125
68
|
// Self-heal: if a newer version dir exists, update registry so next session uses it
|
|
126
69
|
const cacheMatch = __dirname.match(
|