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.
@@ -6,14 +6,14 @@
6
6
  },
7
7
  "metadata": {
8
8
  "description": "Claude Code plugins by Mert Koseoğlu",
9
- "version": "1.0.41"
9
+ "version": "1.0.42"
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.41",
16
+ "version": "1.0.42",
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.41",
3
+ "version": "1.0.42",
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",
@@ -3,7 +3,7 @@
3
3
  "name": "Context Mode",
4
4
  "kind": "tool",
5
5
  "description": "OpenClaw plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
6
- "version": "1.0.41",
6
+ "version": "1.0.42",
7
7
  "sandbox": {
8
8
  "mode": "permissive",
9
9
  "filesystem_access": "full",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "description": "OpenClaw 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/README.md CHANGED
@@ -42,7 +42,7 @@ That's it. The plugin installs everything automatically:
42
42
  - MCP server with 6 sandbox tools (`ctx_batch_execute`, `ctx_execute`, `ctx_execute_file`, `ctx_index`, `ctx_search`, `ctx_fetch_and_index`)
43
43
  - PreToolUse hooks that intercept Bash, Read, WebFetch, Grep, and Task calls — nudging them toward sandbox execution
44
44
  - PostToolUse, PreCompact, and SessionStart hooks for session tracking and context injection
45
- - A `CLAUDE.md` routing instructions file auto-created in your project root
45
+ - Routing instructions injected automatically via SessionStart hook (no file written to your project)
46
46
  - Slash commands for diagnostics and upgrades (Claude Code only)
47
47
 
48
48
  | Command | What it does |
@@ -111,13 +111,7 @@ npm install -g context-mode
111
111
  }
112
112
  ```
113
113
 
114
- **Step 4 — Restart Gemini CLI.** On first session start, the sessionstart hook automatically manages `GEMINI.md` routing instructions in your project root:
115
-
116
- - **File does not exist** — the routing instructions file is written.
117
- - **File exists without context-mode rules** — routing instructions are appended after your existing content.
118
- - **File already contains context-mode rules** — skipped (idempotent, no duplicate content).
119
-
120
- This works alongside hooks as a parallel enforcement layer — hooks block dangerous commands programmatically, while `GEMINI.md` teaches the model to prefer sandbox tools from the start.
114
+ **Step 4 — Restart Gemini CLI.** Routing instructions are injected automatically via the SessionStart hook no file is written to your project. Hooks handle all enforcement programmatically.
121
115
 
122
116
  > **Why hooks matter:** Without hooks, context-mode relies on `GEMINI.md` instructions alone (~60% compliance). The model sometimes follows them, but regularly runs raw `curl`, reads large files directly, or dumps unprocessed output into context — a single unrouted Playwright snapshot (56 KB) wipes out an entire session's savings. With hooks, every tool call is intercepted before execution — dangerous commands are blocked, and routing guidance is injected in real-time. This is the difference between ~60% and ~98% context savings.
123
117
 
@@ -164,13 +158,7 @@ npm install -g context-mode
164
158
  }
165
159
  ```
166
160
 
167
- **Step 4 — Restart VS Code.** On first session start, the sessionstart hook automatically manages `.github/copilot-instructions.md` routing instructions in your project:
168
-
169
- - **File does not exist** — `.github/` is created and the routing instructions file is written.
170
- - **File exists without context-mode rules** — routing instructions are appended after your existing content, preserving project-level coding standards.
171
- - **File already contains context-mode rules** — skipped (idempotent, no duplicate content).
172
-
173
- This works alongside hooks as a parallel enforcement layer — hooks intercept tool calls programmatically, while `copilot-instructions.md` guides the model's tool selection from session start.
161
+ **Step 4 — Restart VS Code.** Routing instructions are injected automatically via the SessionStart hook no file is written to your project. Hooks handle all enforcement programmatically.
174
162
 
175
163
  > **Why hooks matter:** Without hooks, `copilot-instructions.md` guides the model but can't block commands. A single unrouted Playwright snapshot (56 KB) or `gh issue list` (59 KB) wipes out minutes of context savings. With hooks, these calls are intercepted and redirected to the sandbox before they execute.
176
164
 
@@ -222,9 +210,9 @@ npm install -g context-mode
222
210
 
223
211
  Note: the `preToolUse` hook matcher is optional. If you don't provide it, the hook will fire on all tools.
224
212
 
225
- **Step 4 — Restart Cursor or open a new agent session.** On first MCP server startup, routing instructions are auto-written to your project (same mechanism as Codex CLI).
213
+ **Step 4 — Restart Cursor or open a new agent session.** Routing is enforced via the `preToolUse` hook. Since Cursor lacks SessionStart support, you may want to manually add routing instructions copy `configs/cursor/.cursorrules` to your project root as `.cursorrules`, or place it in `.cursor/rules/`.
226
214
 
227
- > **Native Cursor scope:** `preToolUse` and `postToolUse` are supported. `sessionStart` is documented by Cursor but currently rejected by their validator ([forum report](https://forum.cursor.com/t/unknown-hook-type-sessionstart/149566)), so routing instructions are delivered via MCP server startup instead.
215
+ > **Native Cursor scope:** `preToolUse` and `postToolUse` are supported. `sessionStart` is documented by Cursor but currently rejected by their validator ([forum report](https://forum.cursor.com/t/unknown-hook-type-sessionstart/149566)).
228
216
  >
229
217
  > **Config precedence:** project `.cursor/hooks.json` overrides `~/.cursor/hooks.json`.
230
218
 
@@ -259,17 +247,11 @@ npm install -g context-mode
259
247
 
260
248
  The `mcp` entry gives you the 6 sandbox tools. The `plugin` entry enables hooks — OpenCode calls the plugin's TypeScript functions directly before and after each tool execution, blocking dangerous commands (like raw `curl`) and enforcing sandbox routing.
261
249
 
262
- **Step 3 — Restart OpenCode.** On first plugin init, the plugin automatically manages `AGENTS.md` routing instructions in your project root:
250
+ **Step 3 — Restart OpenCode.** The plugin intercepts tool calls at runtime via `tool.execute.before` and `tool.execute.after`, enforcing sandbox routing programmatically. No routing file is written to your project.
263
251
 
264
- - **File does not exist** the routing instructions file is written.
265
- - **File exists without context-mode rules** — routing instructions are appended after your existing content.
266
- - **File already contains context-mode rules** — skipped (idempotent, no duplicate content).
267
-
268
- This works alongside the plugin as a parallel enforcement layer — the plugin intercepts tool calls at runtime, while `AGENTS.md` guides the model's tool preferences from session start.
269
-
270
- > **Why the plugin matters:** Without the `plugin` entry, context-mode has no way to intercept tool calls. The model can run raw `curl`, read large files directly, or dump unprocessed output into context — ignoring `AGENTS.md` instructions. With the plugin, `tool.execute.before` fires on every tool call and blocks or redirects data-heavy commands before they execute. The `experimental.session.compacting` hook builds and injects resume snapshots when the conversation compacts, preserving session state.
252
+ > **Why the plugin matters:** Without the `plugin` entry, context-mode has no way to intercept tool calls. The model can run raw `curl`, read large files directly, or dump unprocessed output into context. With the plugin, `tool.execute.before` fires on every tool call and blocks or redirects data-heavy commands before they execute. The `experimental.session.compacting` hook builds and injects resume snapshots when the conversation compacts, preserving session state.
271
253
  >
272
- > Note: OpenCode's SessionStart hook is not yet available ([#14808](https://github.com/sst/opencode/issues/14808)), so startup/resume session restore is not supported — the `AGENTS.md` file is the primary way context-mode instructions reach the model at session start. Compaction recovery works fully via the plugin.
254
+ > Note: OpenCode's SessionStart hook is not yet available ([#14808](https://github.com/sst/opencode/issues/14808)), so startup/resume session restore is not supported. Compaction recovery works fully via the plugin.
273
255
 
274
256
  </details>
275
257
 
@@ -300,7 +282,7 @@ Common locations:
300
282
 
301
283
  The installer handles everything: `npm install`, `npm run build`, `better-sqlite3` native rebuild, extension registration in `runtime.json`, and gateway restart via SIGUSR1.
302
284
 
303
- **Step 2 — Verify.** Open a Pi Agent session. The plugin auto-injects `AGENTS.md` routing instructions and registers 8 hooks via [`api.on()`](https://docs.openclaw.ai/tools/plugin) (lifecycle) and [`api.registerHook()`](https://docs.openclaw.ai/tools/plugin) (commands). All tool interception, session tracking, and compaction recovery hooks activate automatically — no manual hook configuration needed.
285
+ **Step 2 — Verify.** Open a Pi Agent session. The plugin registers 8 hooks via [`api.on()`](https://docs.openclaw.ai/tools/plugin) (lifecycle) and [`api.registerHook()`](https://docs.openclaw.ai/tools/plugin) (commands). All tool interception, session tracking, and compaction recovery hooks activate automatically — no manual hook configuration or routing file needed.
304
286
 
305
287
  > **Why native plugin?** OpenClaw doesn't support shell-based hooks like Claude Code or Gemini CLI. Instead, plugins register TypeScript functions directly into the gateway runtime. This gives full access to tool interception, argument mutation, and session context injection — equivalent to the hook-based approach on other platforms.
306
288
  >
@@ -326,18 +308,22 @@ npm install -g context-mode
326
308
  command = "context-mode"
327
309
  ```
328
310
 
329
- **Step 3 — Restart Codex CLI.** On first run, an `AGENTS.md` routing instructions file is auto-created in your project root. Codex CLI reads `AGENTS.md` automatically and learns to prefer context-mode sandbox tools.
330
-
331
- **About hooks:** Codex CLI does not support hooks — PRs [#2904](https://github.com/openai/codex/pull/2904) and [#9796](https://github.com/openai/codex/pull/9796) were closed without merge. The `AGENTS.md` routing instructions file is the only enforcement method (~60% compliance). The model receives the instructions at session start and sometimes follows them, but there is no programmatic interception — it can run raw `curl`, read large files, or bypass sandbox tools at any time.
332
-
333
- For stronger enforcement, you can also add the instructions globally:
311
+ **Step 3 — Copy routing instructions.** Codex CLI has no hook support, so you need to manually add the routing file:
334
312
 
335
313
  ```bash
336
- cp ~/.codex/AGENTS.md # auto-created, or copy from node_modules/context-mode/configs/codex/AGENTS.md
314
+ # Copy to project root
315
+ cp node_modules/context-mode/configs/codex/AGENTS.md ./AGENTS.md
316
+
317
+ # Or for global use
318
+ cp node_modules/context-mode/configs/codex/AGENTS.md ~/.codex/AGENTS.md
337
319
  ```
338
320
 
339
321
  Global `~/.codex/AGENTS.md` applies to all projects. Project-level `./AGENTS.md` applies to the current project only. If both exist, Codex CLI merges them.
340
322
 
323
+ **Step 4 — Restart Codex CLI.** Codex CLI reads `AGENTS.md` automatically and learns to prefer context-mode sandbox tools.
324
+
325
+ **About hooks:** Codex CLI does not support hooks — PRs [#2904](https://github.com/openai/codex/pull/2904) and [#9796](https://github.com/openai/codex/pull/9796) were closed without merge. The `AGENTS.md` routing instructions file is the only enforcement method (~60% compliance). The model receives the instructions at session start and sometimes follows them, but there is no programmatic interception — it can run raw `curl`, read large files, or bypass sandbox tools at any time.
326
+
341
327
  </details>
342
328
 
343
329
  <details>
@@ -361,7 +347,13 @@ npm install -g context-mode
361
347
  }
362
348
  ```
363
349
 
364
- **Step 3 — Restart Antigravity.** On first MCP server startup, a `GEMINI.md` routing instructions file is auto-created in your project root. Antigravity reads `GEMINI.md` automatically and learns to prefer context-mode sandbox tools.
350
+ **Step 3 — Copy routing instructions.** Antigravity has no hook support, so you need to manually add the routing file:
351
+
352
+ ```bash
353
+ cp node_modules/context-mode/configs/antigravity/GEMINI.md ./GEMINI.md
354
+ ```
355
+
356
+ **Step 4 — Restart Antigravity.** Antigravity reads `GEMINI.md` automatically and learns to prefer context-mode sandbox tools.
365
357
 
366
358
  **About hooks:** Antigravity does not support hooks — there is no public hook API. The `GEMINI.md` routing instructions file is the only enforcement method (~60% compliance). The model receives the instructions at session start and sometimes follows them, but there is no programmatic interception — it can run raw `run_command`, read large files via `view_file`, or bypass sandbox tools at any time.
367
359
 
@@ -410,11 +402,13 @@ npm install -g context-mode
410
402
  }
411
403
  ```
412
404
 
413
- **Step 4 — Restart Kiro.** On first session start, the pretooluse hook automatically manages `KIRO.md` routing instructions in your project root:
405
+ **Step 4 — Copy routing instructions.** Kiro's `preToolUse`/`postToolUse` hooks enforce sandbox routing, but since `agentSpawn` (SessionStart) is not yet implemented, you should manually add the routing file so the model gets instructions at session start:
406
+
407
+ ```bash
408
+ cp node_modules/context-mode/configs/kiro/KIRO.md ./KIRO.md
409
+ ```
414
410
 
415
- - **File does not exist** the routing instructions file is written.
416
- - **File exists without context-mode rules** — routing instructions are appended after your existing content.
417
- - **File already contains context-mode rules** — skipped (idempotent, no duplicate content).
411
+ **Step 5Restart Kiro.**
418
412
 
419
413
  **Auto-detection:** context-mode detects Kiro automatically via the MCP protocol handshake (`clientInfo.name`). No environment variables or manual platform configuration needed.
420
414
 
@@ -443,7 +437,13 @@ npm install -g context-mode
443
437
  }
444
438
  ```
445
439
 
446
- **Step 3 — Restart Zed.** On first MCP server startup, an `AGENTS.md` routing instructions file is auto-created in your project root. Zed reads the MCP tools and the model learns to prefer context-mode sandbox tools.
440
+ **Step 3 — Copy routing instructions.** Zed has no hook support, so you need to manually add the routing file:
441
+
442
+ ```bash
443
+ cp node_modules/context-mode/configs/zed/AGENTS.md ./AGENTS.md
444
+ ```
445
+
446
+ **Step 4 — Restart Zed.** Zed reads the MCP tools and the model learns to prefer context-mode sandbox tools.
447
447
 
448
448
  **About hooks:** Zed does not support hooks — there is no public hook or extension API for tool-use lifecycle events. The `AGENTS.md` routing instructions file is the only enforcement method (~60% compliance). The model receives the instructions at session start and sometimes follows them, but there is no programmatic interception.
449
449
 
@@ -667,19 +667,19 @@ Detailed event data is also indexed into FTS5 for on-demand retrieval via `searc
667
667
 
668
668
  **Cursor** — Partial coverage. Native `preToolUse` and `postToolUse` hooks capture tool events. `sessionStart` is documented by Cursor but currently rejected by their validator, so session restore is not available. Routing instructions are delivered via MCP server startup instead.
669
669
 
670
- **OpenCode** — Partial. The TypeScript plugin captures PostToolUse events via `tool.execute.after`, but SessionStart is not yet available ([#14808](https://github.com/sst/opencode/issues/14808)). Events are stored but not automatically restored after compaction. The `AGENTS.md` routing instructions file compensates by re-teaching tool preferences at each session start.
670
+ **OpenCode** — Partial. The TypeScript plugin captures PostToolUse events via `tool.execute.after`, but SessionStart is not yet available ([#14808](https://github.com/sst/opencode/issues/14808)). Events are stored but not automatically restored after compaction.
671
671
 
672
672
  **OpenClaw / Pi Agent** — High coverage. All tool lifecycle hooks (`after_tool_call`, `before_compaction`, `session_start`) fire via the native gateway plugin. User decisions aren't captured but file edits, git ops, errors, and tasks are fully tracked. Falls back to DB snapshot reconstruction if compaction hooks fail on older gateway versions. See [`docs/adapters/openclaw.md`](docs/adapters/openclaw.md).
673
673
 
674
- **Codex CLI** — No session support. No hooks means no event capture. Each compaction or new session starts fresh. The `AGENTS.md` routing instructions file is the only continuity mechanism.
674
+ **Codex CLI** — No session support. No hooks means no event capture. Each compaction or new session starts fresh. Requires manually copying `AGENTS.md` to your project root.
675
675
 
676
- **Antigravity** — No session support. Same as Codex CLI — no hooks, no event capture. The `GEMINI.md` routing instructions file is auto-written on first MCP server startup. Auto-detected via MCP protocol handshake (`clientInfo.name`).
676
+ **Antigravity** — No session support. Same as Codex CLI — no hooks, no event capture. Requires manually copying `GEMINI.md` to your project root. Auto-detected via MCP protocol handshake (`clientInfo.name`).
677
677
 
678
- **Zed** — No session support. Same as Codex CLI — no hooks, no event capture. The `AGENTS.md` routing instructions file is auto-written on first MCP server startup. Auto-detected via MCP protocol handshake (`clientInfo.name`).
678
+ **Zed** — No session support. Same as Codex CLI — no hooks, no event capture. Requires manually copying `AGENTS.md` to your project root. Auto-detected via MCP protocol handshake (`clientInfo.name`).
679
679
 
680
- **Kiro** — Partial coverage. Native `preToolUse` and `postToolUse` hooks capture tool events and enforce sandbox routing. `agentSpawn` (the Kiro equivalent of SessionStart) is not yet implemented, so session restore after compaction is not available. The `KIRO.md` routing instructions file is auto-written on first session start. Auto-detected via MCP protocol handshake (`clientInfo.name`).
680
+ **Kiro** — Partial coverage. Native `preToolUse` and `postToolUse` hooks capture tool events and enforce sandbox routing. `agentSpawn` (the Kiro equivalent of SessionStart) is not yet implemented, so session restore after compaction is not available. Requires manually copying `KIRO.md` to your project root. Auto-detected via MCP protocol handshake (`clientInfo.name`).
681
681
 
682
- **Pi Coding Agent** — High coverage. The extension registers all key lifecycle events: `tool_call` (PreToolUse), `tool_result` (PostToolUse), `session_start` (SessionStart), and `session_before_compact` (PreCompact). File edits, git ops, errors, and tasks are fully tracked. Session restore after compaction works via the extension's event hooks. The `AGENTS.md` routing instructions file is auto-written on first session start.
682
+ **Pi Coding Agent** — High coverage. The extension registers all key lifecycle events: `tool_call` (PreToolUse), `tool_result` (PostToolUse), `session_start` (SessionStart), and `session_before_compact` (PreCompact). File edits, git ops, errors, and tasks are fully tracked. Session restore after compaction works via the extension's event hooks.
683
683
 
684
684
  </details>
685
685
 
@@ -702,11 +702,9 @@ Detailed event data is also indexed into FTS5 for on-demand retrieval via `searc
702
702
  >
703
703
  > **OpenClaw** runs context-mode as a native gateway plugin targeting Pi Agent sessions. Hooks register via `api.on()` (tool/lifecycle) and `api.registerHook()` (commands). All tool interception and compaction hooks are supported. See [`docs/adapters/openclaw.md`](docs/adapters/openclaw.md).
704
704
  >
705
- > **Codex CLI**, **Antigravity**, and **Zed** do not support hooks. They rely solely on routing instruction files (`AGENTS.md` / `GEMINI.md`) for enforcement (~60% compliance). Antigravity and Zed are auto-detected via MCP protocol handshake — no manual platform configuration needed.
706
- >
707
- > **Kiro** supports native `preToolUse` and `postToolUse` hooks for routing enforcement and tool event capture. `agentSpawn` (SessionStart equivalent) and `stop` are not yet wired. Kiro is auto-detected via MCP protocol handshake (`clientInfo.name`).
705
+ > **Codex CLI**, **Antigravity**, and **Zed** do not support hooks. They rely solely on manually-copied routing instruction files (`AGENTS.md` / `GEMINI.md`) for enforcement (~60% compliance). See each platform's install section for copy instructions. Antigravity and Zed are auto-detected via MCP protocol handshake — no manual platform configuration needed.
708
706
  >
709
- > **Zed** does not support hooks. It relies solely on the `AGENTS.md` routing instructions file for enforcement (~60% compliance). Zed is auto-detected via MCP protocol handshake — no manual platform configuration needed.
707
+ > **Kiro** supports native `preToolUse` and `postToolUse` hooks for routing enforcement and tool event capture. `agentSpawn` (SessionStart equivalent) and `stop` are not yet wired. Requires manually copying `KIRO.md` to your project root. Kiro is auto-detected via MCP protocol handshake (`clientInfo.name`).
710
708
  >
711
709
  > **Pi Coding Agent** runs context-mode as an extension with full hook support. The extension registers `tool_call`, `tool_result`, `session_start`, and `session_before_compact` events, providing high session continuity coverage. The MCP server provides the 6 sandbox tools.
712
710
 
@@ -714,6 +712,8 @@ Detailed event data is also indexed into FTS5 for on-demand retrieval via `searc
714
712
 
715
713
  Hooks intercept tool calls programmatically — they can block dangerous commands and redirect them to the sandbox before execution. Instruction files guide the model via prompt instructions but cannot block anything. **Always enable hooks where supported.**
716
714
 
715
+ > **Note:** Routing instruction files were previously auto-written to project directories on first session start. This was disabled to prevent git tree pollution ([#158](https://github.com/mksglu/context-mode/issues/158), [#164](https://github.com/mksglu/context-mode/issues/164)). Hook-capable platforms (Claude Code, Gemini CLI, VS Code Copilot, OpenCode, OpenClaw) inject routing via hooks and need no file. Non-hook platforms (Codex, Zed, Cursor, Kiro, Antigravity) require a one-time manual copy — see each platform's install section.
716
+
717
717
  | Platform | Hooks | Instruction File | With Hooks | Without Hooks |
718
718
  |---|:---:|---|:---:|:---:|
719
719
  | Claude Code | Yes (auto) | [`CLAUDE.md`](configs/claude-code/CLAUDE.md) | **~98% saved** | ~60% saved |
@@ -154,7 +154,7 @@ export default {
154
154
  const toolInput = e.params ?? {};
155
155
  let decision;
156
156
  try {
157
- decision = routing.routePreToolUse(toolName, toolInput, projectDir);
157
+ decision = routing.routePreToolUse(toolName, toolInput, projectDir, "openclaw");
158
158
  }
159
159
  catch {
160
160
  return; // Routing failure → allow passthrough
@@ -68,7 +68,7 @@ export const ContextModePlugin = async (ctx) => {
68
68
  const toolInput = output.args ?? {};
69
69
  let decision;
70
70
  try {
71
- decision = routing.routePreToolUse(toolName, toolInput, projectDir);
71
+ decision = routing.routePreToolUse(toolName, toolInput, projectDir, "opencode");
72
72
  }
73
73
  catch {
74
74
  return; // Routing failure → allow passthrough
package/build/server.js CHANGED
@@ -1693,13 +1693,17 @@ async function main() {
1693
1693
  if (clientInfo) {
1694
1694
  console.error(`MCP client: ${clientInfo.name} v${clientInfo.version} → ${signal.platform}`);
1695
1695
  }
1696
- if (!adapter.capabilities.sessionStart) {
1697
- const pluginRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
1698
- const projectDir = process.env.CLAUDE_PROJECT_DIR ?? process.env.CODEX_HOME ?? process.cwd();
1699
- const written = adapter.writeRoutingInstructions(projectDir, pluginRoot);
1700
- if (written)
1701
- console.error(`Wrote routing instructions: ${written}`);
1702
- }
1696
+ // Routing file auto-write DISABLED for all platforms (#158, #164).
1697
+ // Writing to project dirs dirties git trees and env var detection at
1698
+ // MCP startup is unreliable. Routing is injected via SessionStart hooks
1699
+ // for hook-capable platforms. Non-hook platforms rely on manual setup
1700
+ // until `context-mode init` command is implemented.
1701
+ // if (!adapter.capabilities.sessionStart) {
1702
+ // const pluginRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
1703
+ // const projectDir = process.env.CLAUDE_PROJECT_DIR ?? process.env.CODEX_HOME ?? process.cwd();
1704
+ // const written = adapter.writeRoutingInstructions(projectDir, pluginRoot);
1705
+ // if (written) console.error(`Wrote routing instructions: ${written}`);
1706
+ // }
1703
1707
  }
1704
1708
  catch { /* best effort — don't block server startup */ }
1705
1709
  console.error(`Context Mode MCP server v${VERSION} running on stdio`);