context-mode 1.0.53 → 1.0.56

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.
Files changed (66) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.openclaw-plugin/openclaw.plugin.json +1 -1
  4. package/.openclaw-plugin/package.json +1 -1
  5. package/README.md +103 -32
  6. package/build/adapters/antigravity/index.d.ts +1 -3
  7. package/build/adapters/antigravity/index.js +0 -30
  8. package/build/adapters/claude-code/hooks.d.ts +18 -0
  9. package/build/adapters/claude-code/hooks.js +23 -0
  10. package/build/adapters/claude-code/index.d.ts +1 -3
  11. package/build/adapters/claude-code/index.js +48 -35
  12. package/build/adapters/client-map.js +1 -0
  13. package/build/adapters/codex/index.d.ts +1 -3
  14. package/build/adapters/codex/index.js +1 -31
  15. package/build/adapters/cursor/index.d.ts +1 -3
  16. package/build/adapters/cursor/index.js +0 -11
  17. package/build/adapters/detect.d.ts +1 -0
  18. package/build/adapters/detect.js +18 -2
  19. package/build/adapters/gemini-cli/index.d.ts +1 -3
  20. package/build/adapters/gemini-cli/index.js +0 -30
  21. package/build/adapters/kiro/index.d.ts +1 -3
  22. package/build/adapters/kiro/index.js +0 -30
  23. package/build/adapters/openclaw/index.d.ts +1 -3
  24. package/build/adapters/openclaw/index.js +0 -38
  25. package/build/adapters/opencode/index.d.ts +5 -4
  26. package/build/adapters/opencode/index.js +37 -41
  27. package/build/adapters/types.d.ts +1 -14
  28. package/build/adapters/vscode-copilot/index.d.ts +1 -3
  29. package/build/adapters/vscode-copilot/index.js +0 -32
  30. package/build/adapters/zed/index.d.ts +1 -3
  31. package/build/adapters/zed/index.js +0 -30
  32. package/build/cli.js +12 -28
  33. package/build/executor.d.ts +0 -1
  34. package/build/executor.js +28 -16
  35. package/build/openclaw-plugin.js +12 -34
  36. package/build/opencode-plugin.d.ts +1 -0
  37. package/build/opencode-plugin.js +5 -9
  38. package/build/runtime.js +29 -11
  39. package/build/server.d.ts +2 -0
  40. package/build/server.js +69 -61
  41. package/build/store.d.ts +4 -3
  42. package/build/store.js +101 -34
  43. package/build/truncate.d.ts +4 -17
  44. package/build/truncate.js +4 -52
  45. package/cli.bundle.mjs +184 -157
  46. package/configs/codex/AGENTS.md +19 -0
  47. package/configs/kilo/AGENTS.md +58 -0
  48. package/configs/kilo/kilo.json +10 -0
  49. package/hooks/core/tool-naming.mjs +1 -0
  50. package/hooks/ensure-deps.mjs +80 -2
  51. package/hooks/pretooluse.mjs +25 -20
  52. package/hooks/routing-block.mjs +10 -1
  53. package/hooks/session-snapshot.bundle.mjs +13 -13
  54. package/hooks/sessionstart.mjs +25 -1
  55. package/openclaw.plugin.json +1 -1
  56. package/package.json +1 -1
  57. package/server.bundle.mjs +159 -129
  58. package/skills/context-mode-ops/SKILL.md +111 -0
  59. package/skills/context-mode-ops/agent-teams.md +198 -0
  60. package/skills/context-mode-ops/communication.md +224 -0
  61. package/skills/context-mode-ops/release.md +199 -0
  62. package/skills/context-mode-ops/review-pr.md +269 -0
  63. package/skills/context-mode-ops/tdd.md +329 -0
  64. package/skills/context-mode-ops/triage-issue.md +218 -0
  65. package/skills/context-mode-ops/validation.md +238 -0
  66. package/start.mjs +5 -52
@@ -6,14 +6,14 @@
6
6
  },
7
7
  "metadata": {
8
8
  "description": "Claude Code plugins by Mert Koseoğlu",
9
- "version": "1.0.53"
9
+ "version": "1.0.56"
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.53",
16
+ "version": "1.0.56",
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.53",
3
+ "version": "1.0.56",
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.53",
6
+ "version": "1.0.56",
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.53",
3
+ "version": "1.0.56",
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
@@ -5,14 +5,6 @@
5
5
  [![users](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fcdn.jsdelivr.net%2Fgh%2Fmksglu%2Fcontext-mode%40main%2Fstats.json&query=%24.message&label=users&color=brightgreen)](https://www.npmjs.com/package/context-mode) [![npm](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fcdn.jsdelivr.net%2Fgh%2Fmksglu%2Fcontext-mode%40main%2Fstats.json&query=%24.npm&label=npm&color=blue)](https://www.npmjs.com/package/context-mode) [![marketplace](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fcdn.jsdelivr.net%2Fgh%2Fmksglu%2Fcontext-mode%40main%2Fstats.json&query=%24.marketplace&label=marketplace&color=blue)](https://github.com/mksglu/context-mode) [![GitHub stars](https://img.shields.io/github/stars/mksglu/context-mode?style=flat&color=yellow)](https://github.com/mksglu/context-mode/stargazers) [![GitHub forks](https://img.shields.io/github/forks/mksglu/context-mode?style=flat&color=blue)](https://github.com/mksglu/context-mode/network/members) [![Last commit](https://img.shields.io/github/last-commit/mksglu/context-mode?color=green)](https://github.com/mksglu/context-mode/commits) [![License: ELv2](https://img.shields.io/badge/License-ELv2-blue.svg)](LICENSE)
6
6
  [![Discord](https://img.shields.io/discord/1478479412700909750?label=Discord&logo=discord&color=5865f2)](https://discord.gg/DCN9jUgN5v)
7
7
 
8
- ## Privacy & Architecture
9
-
10
- Context Mode is not a CLI output filter or a cloud analytics dashboard. It operates at the MCP protocol layer — raw data stays in a sandboxed subprocess and never enters your context window. Web pages, API responses, file analysis, Playwright snapshots, log files — everything is processed in complete isolation.
11
-
12
- **Nothing leaves your machine.** No telemetry, no cloud sync, no usage tracking, no account required. Your code, your prompts, your session data — all local. The SQLite databases live in your home directory and die when you're done.
13
-
14
- This is a deliberate architectural choice, not a missing feature. Context optimization should happen at the source, not in a dashboard behind a per-seat subscription. Privacy-first is our philosophy — and every design decision follows from it. [License →](#license)
15
-
16
8
  ## The Problem
17
9
 
18
10
  Every MCP tool call dumps raw data into your context window. A Playwright snapshot costs 56 KB. Twenty GitHub issues cost 59 KB. One access log — 45 KB. After 30 minutes, 40% of your context is gone. And when the agent compacts the conversation to free space, it forgets which files it was editing, what tasks are in progress, and what you last asked for.
@@ -290,15 +282,69 @@ Full configs: [`configs/cursor/hooks.json`](configs/cursor/hooks.json) | [`confi
290
282
 
291
283
  The `mcp` entry registers 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 and enforcing sandbox routing.
292
284
 
293
- 3. Restart OpenCode.
285
+ 3. *(Optional)* Copy the routing rules file. OpenCode lacks a SessionStart hook, so the model needs an `AGENTS.md` file for routing awareness:
286
+
287
+ ```bash
288
+ cp node_modules/context-mode/configs/opencode/AGENTS.md AGENTS.md
289
+ ```
290
+
291
+ This tells the model which tools to use and which commands are blocked. Without it, hooks still enforce routing — but the model won't know *why* a command was denied.
292
+
293
+ 4. Restart OpenCode.
294
294
 
295
295
  **Verify:** In the OpenCode session, type `ctx stats`. Context-mode tools should appear and respond.
296
296
 
297
- **Routing:** Automatic. The plugin intercepts tool calls at runtime via `tool.execute.before` and `tool.execute.after`. No routing file is written to your project. The `experimental.session.compacting` hook builds resume snapshots when the conversation compacts.
297
+ **Routing:** Hooks enforce routing programmatically via `tool.execute.before` and `tool.execute.after`. The optional [`AGENTS.md`](configs/opencode/AGENTS.md) file provides routing instructions for model awareness. The `experimental.session.compacting` hook builds resume snapshots when the conversation compacts.
298
298
 
299
299
  > **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.
300
300
 
301
- Full config: [`configs/opencode/opencode.json`](configs/opencode/opencode.json)
301
+ Full configs: [`configs/opencode/opencode.json`](configs/opencode/opencode.json) | [`configs/opencode/AGENTS.md`](configs/opencode/AGENTS.md)
302
+
303
+ </details>
304
+
305
+ <details>
306
+ <summary><strong>KiloCode</strong> — TypeScript plugin with hooks</summary>
307
+
308
+ **Prerequisites:** Node.js 18+, KiloCode installed.
309
+
310
+ **Install:**
311
+
312
+ 1. Install context-mode globally:
313
+
314
+ ```bash
315
+ npm install -g context-mode
316
+ ```
317
+
318
+ 2. Add to `kilo.json` in your project root (or `~/.config/kilo/kilo.json` for global):
319
+
320
+ ```json
321
+ {
322
+ "$schema": "https://app.kilo.ai/config.json",
323
+ "mcp": {
324
+ "context-mode": {
325
+ "type": "local",
326
+ "command": ["context-mode"]
327
+ }
328
+ },
329
+ "plugin": ["context-mode"]
330
+ }
331
+ ```
332
+
333
+ The `mcp` entry registers the 6 sandbox tools. The `plugin` entry enables hooks — KiloCode calls the plugin's TypeScript functions directly before and after each tool execution, blocking dangerous commands and enforcing sandbox routing.
334
+
335
+ 3. *(Optional)* Copy the routing rules file. KiloCode shares the OpenCode plugin architecture and lacks SessionStart, so the model needs an `AGENTS.md` file for routing awareness:
336
+
337
+ ```bash
338
+ cp node_modules/context-mode/configs/opencode/AGENTS.md AGENTS.md
339
+ ```
340
+
341
+ 4. Restart KiloCode.
342
+
343
+ **Verify:** In the KiloCode session, type `ctx stats`. Context-mode tools should appear and respond.
344
+
345
+ **Routing:** Hooks enforce routing programmatically via `tool.execute.before` and `tool.execute.after`. The optional [`AGENTS.md`](configs/opencode/AGENTS.md) file provides routing instructions for model awareness. The `experimental.session.compacting` hook builds resume snapshots when the conversation compacts.
346
+
347
+ > **Note:** KiloCode shares the same plugin architecture as OpenCode, using the OpenCodeAdapter with platform-specific configuration paths (`kilo.json` instead of `opencode.json`, `~/.config/kilo/` instead of `~/.config/opencode/`). SessionStart hook availability depends on KiloCode's implementation.
302
348
 
303
349
  </details>
304
350
 
@@ -601,7 +647,7 @@ npm install -g context-mode
601
647
  | `ctx_execute_file` | Process files in sandbox. Raw content never leaves. | 45 KB → 155 B |
602
648
  | `ctx_index` | Chunk markdown into FTS5 with BM25 ranking. | 60 KB → 40 B |
603
649
  | `ctx_search` | Query indexed content with multiple queries in one call. | On-demand retrieval |
604
- | `ctx_fetch_and_index` | Fetch URL, detect content type (HTML/JSON/text), chunk and index. | 60 KB → 40 B |
650
+ | `ctx_fetch_and_index` | Fetch URL, chunk and index. 24h TTL cache — repeat calls skip network. `force: true` to bypass. | 60 KB → 40 B |
605
651
  | `ctx_stats` | Show context savings, call counts, and session statistics. | — |
606
652
  | `ctx_doctor` | Diagnose installation: runtimes, hooks, FTS5, versions. | — |
607
653
  | `ctx_upgrade` | Upgrade to latest version from GitHub, rebuild, reconfigure hooks. | — |
@@ -643,6 +689,19 @@ Levenshtein distance corrects typos before re-searching. "kuberntes" becomes "ku
643
689
 
644
690
  Search results use intelligent extraction instead of truncation. Instead of returning the first N characters (which might miss the important part), Context Mode finds where your query terms appear in the content and returns windows around those matches.
645
691
 
692
+ ### TTL Cache
693
+
694
+ Indexed content persists in a per-project SQLite database at `~/.context-mode/content/`. When `ctx_fetch_and_index` is called for a URL that was already indexed within the last 24 hours, the fetch is skipped entirely. The model searches the existing index directly.
695
+
696
+ - **Fresh (<24h):** Returns a cache hint (0.3KB) instead of re-fetching (48KB+). Model proceeds to `ctx_search`.
697
+ - **Stale (>24h):** Re-fetches silently. No user action needed.
698
+ - **`force: true`:** Bypasses cache and re-fetches regardless of TTL.
699
+ - **14-day cleanup:** Content databases and sources older than 14 days are removed on startup.
700
+
701
+ This means `--continue` sessions preserve indexed docs across restarts. No re-fetching, no wasted context tokens.
702
+
703
+ `ctx_stats` reports cache performance separately: hits, data avoided, network requests saved, and total context savings including cache.
704
+
646
705
  ### Progressive Throttling
647
706
 
648
707
  - **Calls 1-3:** Normal results (2 per query)
@@ -657,15 +716,15 @@ Context Mode captures every meaningful event during your session and persists th
657
716
 
658
717
  Session continuity requires 4 hooks working together:
659
718
 
660
- | Hook | Role | Claude Code | Gemini CLI | VS Code Copilot | Cursor | OpenCode | OpenClaw | Codex CLI | Antigravity | Kiro | Zed | Pi |
661
- |---|---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
662
- | **PostToolUse** | Captures events after each tool call | Yes | Yes | Yes | Yes | Plugin | Plugin | -- | -- | Yes | -- | ✓ (via tool_result event) |
663
- | **UserPromptSubmit** | Captures user decisions and corrections | Yes | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- |
664
- | **PreCompact** | Builds snapshot before compaction | Yes | Yes | Yes | -- | Plugin | Plugin | -- | -- | -- | -- | ✓ (via session_before_compact) |
665
- | **SessionStart** | Restores state after compaction or resume | Yes | Yes | Yes | -- | -- | Plugin | -- | -- | -- | -- | ✓ (via session_start event) |
666
- | | **Session completeness** | **Full** | **High** | **High** | **Partial** | **High** | **High** | **--** | **--** | **Partial** | **--** | **High** |
719
+ | Hook | Role | Claude Code | Gemini CLI | VS Code Copilot | Cursor | OpenCode | KiloCode | OpenClaw | Codex CLI | Antigravity | Kiro | Zed | Pi |
720
+ |---|---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
721
+ | **PostToolUse** | Captures events after each tool call | Yes | Yes | Yes | Yes | Plugin | Plugin | Plugin | -- | -- | Yes | -- | ✓ (via tool_result event) |
722
+ | **UserPromptSubmit** | Captures user decisions and corrections | Yes | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- |
723
+ | **PreCompact** | Builds snapshot before compaction | Yes | Yes | Yes | -- | Plugin | Plugin | Plugin | -- | -- | -- | -- | ✓ (via session_before_compact) |
724
+ | **SessionStart** | Restores state after compaction or resume | Yes | Yes | Yes | -- | -- | -- | Plugin | -- | -- | -- | -- | ✓ (via session_start event) |
725
+ | | **Session completeness** | **Full** | **High** | **High** | **Partial** | **High** | **High** | **High** | **--** | **--** | **Partial** | **--** | **High** |
667
726
 
668
- > **Note:** Full session continuity (capture + snapshot + restore) works on **Claude Code**, **Gemini CLI**, **VS Code Copilot**, and **OpenCode**. **Cursor** captures tool events via `preToolUse`/`postToolUse`, but `sessionStart` is currently rejected by Cursor's validator ([forum report](https://forum.cursor.com/t/unknown-hook-type-sessionstart/149566)), so session restore after compaction is not available yet. **OpenCode** uses the `experimental.session.compacting` plugin hook for compaction recovery, but SessionStart is not yet available ([#14808](https://github.com/sst/opencode/issues/14808)), so startup/resume is not supported. **OpenClaw** uses native gateway plugin hooks (`api.on()`) for full session continuity. **Pi Coding Agent** provides high session continuity via extension hooks (`tool_call`, `tool_result`, `session_start`, `session_before_compact`). **Codex CLI**, **Antigravity**, **Kiro**, and **Zed** have no hook support in the current release, so session tracking is not available.
727
+ > **Note:** Full session continuity (capture + snapshot + restore) works on **Claude Code**, **Gemini CLI**, and **VS Code Copilot**. **OpenCode** provides **high** session continuity: it captures tool events and injects compaction snapshots via the plugin, but SessionStart is not yet available ([#14808](https://github.com/sst/opencode/issues/14808)), so startup/resume restore is not supported. **KiloCode** shares the same plugin architecture as OpenCode via the OpenCodeAdapter, so its continuity level depends on KiloCode's SessionStart support. **Cursor** captures tool events via `preToolUse`/`postToolUse`, but `sessionStart` is currently rejected by Cursor's validator ([forum report](https://forum.cursor.com/t/unknown-hook-type-sessionstart/149566)), so session restore after compaction is not available yet. **OpenClaw** uses native gateway plugin hooks (`api.on()`) for full session continuity. **Pi Coding Agent** provides high session continuity via extension hooks (`tool_call`, `tool_result`, `session_start`, `session_before_compact`). **Codex CLI**, **Antigravity**, **Kiro**, and **Zed** have no hook support in the current release, so session tracking is not available.
669
728
 
670
729
  <details>
671
730
  <summary><strong>What gets captured</strong></summary>
@@ -744,6 +803,8 @@ Detailed event data is also indexed into FTS5 for on-demand retrieval via `searc
744
803
 
745
804
  **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.
746
805
 
806
+ **KiloCode** — Partial. Shares the same plugin architecture as OpenCode via the OpenCodeAdapter. The TypeScript plugin captures PostToolUse events via `tool.execute.after`, but SessionStart availability depends on KiloCode's implementation. Events are stored but may not be automatically restored after compaction.
807
+
747
808
  **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).
748
809
 
749
810
  **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.
@@ -760,21 +821,23 @@ Detailed event data is also indexed into FTS5 for on-demand retrieval via `searc
760
821
 
761
822
  ## Platform Compatibility
762
823
 
763
- | Feature | Claude Code | Gemini CLI | VS Code Copilot | Cursor | OpenCode | OpenClaw | Codex CLI | Antigravity | Kiro | Zed | Pi |
764
- |---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
765
- | MCP Server | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
766
- | PreToolUse Hook | Yes | Yes | Yes | Yes | Plugin | Plugin | -- | -- | Yes | -- | Yes (extension) |
767
- | PostToolUse Hook | Yes | Yes | Yes | Yes | Plugin | Plugin | -- | -- | Yes | -- | Yes (extension) |
768
- | SessionStart Hook | Yes | Yes | Yes | -- | -- | Plugin | -- | -- | -- | -- | Yes (extension) |
769
- | PreCompact Hook | Yes | Yes | Yes | -- | Plugin | Plugin | -- | -- | -- | -- | Yes (extension) |
770
- | Can Modify Args | Yes | Yes | Yes | Yes | Plugin | Plugin | -- | -- | -- | -- | Yes (extension) |
771
- | Can Block Tools | Yes | Yes | Yes | Yes | Plugin | Plugin | -- | -- | Yes | -- | Yes (extension) |
772
- | Utility Commands (ctx) | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes (/ctx-stats, /ctx-doctor) |
773
- | Slash Commands | Yes | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- |
774
- | Plugin Marketplace | Yes | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- |
824
+ | Feature | Claude Code | Gemini CLI | VS Code Copilot | Cursor | OpenCode | KiloCode | OpenClaw | Codex CLI | Antigravity | Kiro | Zed | Pi |
825
+ |---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
826
+ | MCP Server | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
827
+ | PreToolUse Hook | Yes | Yes | Yes | Yes | Plugin | Plugin | Plugin | -- | -- | Yes | -- | Yes (extension) |
828
+ | PostToolUse Hook | Yes | Yes | Yes | Yes | Plugin | Plugin | Plugin | -- | -- | Yes | -- | Yes (extension) |
829
+ | SessionStart Hook | Yes | Yes | Yes | -- | -- | -- | Plugin | -- | -- | -- | -- | Yes (extension) |
830
+ | PreCompact Hook | Yes | Yes | Yes | -- | Plugin | Plugin | Plugin | -- | -- | -- | -- | Yes (extension) |
831
+ | Can Modify Args | Yes | Yes | Yes | Yes | Plugin | Plugin | Plugin | -- | -- | -- | -- | Yes (extension) |
832
+ | Can Block Tools | Yes | Yes | Yes | Yes | Plugin | Plugin | Plugin | -- | -- | Yes | -- | Yes (extension) |
833
+ | Utility Commands (ctx) | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes (/ctx-stats, /ctx-doctor) |
834
+ | Slash Commands | Yes | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- |
835
+ | Plugin Marketplace | Yes | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- |
775
836
 
776
837
  > **OpenCode** uses a TypeScript plugin paradigm — hooks run as in-process functions via `tool.execute.before`, `tool.execute.after`, and `experimental.session.compacting`, providing the same routing enforcement and session continuity as shell-based hooks. SessionStart is not yet available ([#14808](https://github.com/sst/opencode/issues/14808)), but compaction recovery works via the plugin's compacting hook.
777
838
  >
839
+ > **KiloCode** shares the same TypeScript plugin architecture as OpenCode via the OpenCodeAdapter, with platform-specific configuration paths (`kilo.json` instead of `opencode.json`, `~/.config/kilo/` instead of `~/.config/opencode/`). Hook capabilities depend on KiloCode's implementation of the plugin interface.
840
+ >
778
841
  > **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).
779
842
  >
780
843
  > **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.
@@ -887,6 +950,14 @@ event count. When context compacts, the model continues from your last prompt
887
950
  with tasks, files, and decisions intact — no re-prompting needed.
888
951
  ```
889
952
 
953
+ ## Privacy & Architecture
954
+
955
+ Context Mode is not a CLI output filter or a cloud analytics dashboard. It operates at the MCP protocol layer — raw data stays in a sandboxed subprocess and never enters your context window. Web pages, API responses, file analysis, Playwright snapshots, log files — everything is processed in complete isolation.
956
+
957
+ **Nothing leaves your machine.** No telemetry, no cloud sync, no usage tracking, no account required. Your code, your prompts, your session data — all local. The SQLite databases live in your home directory and die when you're done.
958
+
959
+ This is a deliberate architectural choice, not a missing feature. Context optimization should happen at the source, not in a dashboard behind a per-seat subscription. Privacy-first is our philosophy — and every design decision follows from it. [License →](#license)
960
+
890
961
  ## Security
891
962
 
892
963
  Context Mode enforces the same permission rules you already use — but extends them to the MCP sandbox. If you block `sudo`, it's also blocked inside `ctx_execute`, `ctx_execute_file`, and `ctx_batch_execute`.
@@ -16,7 +16,7 @@
16
16
  * - MCP support: https://antigravity.google/docs/mcp
17
17
  * - Tool list: System prompt leak (21 verified tools)
18
18
  */
19
- import type { HookAdapter, HookParadigm, PlatformCapabilities, DiagnosticResult, PreToolUseEvent, PostToolUseEvent, PreCompactEvent, SessionStartEvent, PreToolUseResponse, PostToolUseResponse, PreCompactResponse, SessionStartResponse, HookRegistration, RoutingInstructionsConfig } from "../types.js";
19
+ import type { HookAdapter, HookParadigm, PlatformCapabilities, DiagnosticResult, PreToolUseEvent, PostToolUseEvent, PreCompactEvent, SessionStartEvent, PreToolUseResponse, PostToolUseResponse, PreCompactResponse, SessionStartResponse, HookRegistration } from "../types.js";
20
20
  export declare class AntigravityAdapter implements HookAdapter {
21
21
  readonly name = "Antigravity";
22
22
  readonly paradigm: HookParadigm;
@@ -43,7 +43,5 @@ export declare class AntigravityAdapter implements HookAdapter {
43
43
  backupSettings(): string | null;
44
44
  setHookPermissions(_pluginRoot: string): string[];
45
45
  updatePluginRegistry(_pluginRoot: string, _version: string): void;
46
- getRoutingInstructionsConfig(): RoutingInstructionsConfig;
47
- writeRoutingInstructions(projectDir: string, pluginRoot: string): string | null;
48
46
  getRoutingInstructions(): string;
49
47
  }
@@ -175,36 +175,6 @@ export class AntigravityAdapter {
175
175
  updatePluginRegistry(_pluginRoot, _version) {
176
176
  // Antigravity plugin registry is managed via mcp_config.json
177
177
  }
178
- // ── Routing Instructions (soft enforcement) ────────────
179
- getRoutingInstructionsConfig() {
180
- return {
181
- fileName: "GEMINI.md",
182
- globalPath: resolve(homedir(), ".gemini", "GEMINI.md"),
183
- projectRelativePath: "GEMINI.md",
184
- };
185
- }
186
- writeRoutingInstructions(projectDir, pluginRoot) {
187
- const config = this.getRoutingInstructionsConfig();
188
- const targetPath = resolve(projectDir, config.projectRelativePath);
189
- const sourcePath = resolve(pluginRoot, "configs", "antigravity", config.fileName);
190
- try {
191
- const content = readFileSync(sourcePath, "utf-8");
192
- try {
193
- const existing = readFileSync(targetPath, "utf-8");
194
- if (existing.includes("context-mode"))
195
- return null;
196
- writeFileSync(targetPath, existing.trimEnd() + "\n\n" + content, "utf-8");
197
- return targetPath;
198
- }
199
- catch {
200
- writeFileSync(targetPath, content, "utf-8");
201
- return targetPath;
202
- }
203
- }
204
- catch {
205
- return null;
206
- }
207
- }
208
178
  getRoutingInstructions() {
209
179
  const instructionsPath = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "configs", "antigravity", "GEMINI.md");
210
180
  try {
@@ -53,3 +53,21 @@ export declare function isContextModeHook(entry: {
53
53
  * Falls back to CLI dispatcher if pluginRoot is not provided.
54
54
  */
55
55
  export declare function buildHookCommand(hookType: HookType, pluginRoot?: string): string;
56
+ /**
57
+ * Extract the hook script file path from a command string.
58
+ * Returns the path if the command uses the `node "/path/to/hook.mjs"` format,
59
+ * or null if it uses the CLI dispatcher format (which is path-independent).
60
+ *
61
+ * Handles both quoted and unquoted paths, and both forward/back slashes.
62
+ */
63
+ export declare function extractHookScriptPath(command: string): string | null;
64
+ /**
65
+ * Check if a hook entry is a context-mode hook (any hook type).
66
+ * Broader than `isContextModeHook` — matches any context-mode script name
67
+ * without requiring a specific hookType.
68
+ */
69
+ export declare function isAnyContextModeHook(entry: {
70
+ hooks?: Array<{
71
+ command?: string;
72
+ }>;
73
+ }): boolean;
@@ -93,3 +93,26 @@ export function buildHookCommand(hookType, pluginRoot) {
93
93
  }
94
94
  return `context-mode hook claude-code ${hookType.toLowerCase()}`;
95
95
  }
96
+ /**
97
+ * Extract the hook script file path from a command string.
98
+ * Returns the path if the command uses the `node "/path/to/hook.mjs"` format,
99
+ * or null if it uses the CLI dispatcher format (which is path-independent).
100
+ *
101
+ * Handles both quoted and unquoted paths, and both forward/back slashes.
102
+ */
103
+ export function extractHookScriptPath(command) {
104
+ // Match: node "/path/to/hooks/scriptname.mjs" or node /path/to/hooks/scriptname.mjs
105
+ const match = command.match(/node\s+"?([^"]+\.mjs)"?/);
106
+ return match?.[1] ?? null;
107
+ }
108
+ /**
109
+ * Check if a hook entry is a context-mode hook (any hook type).
110
+ * Broader than `isContextModeHook` — matches any context-mode script name
111
+ * without requiring a specific hookType.
112
+ */
113
+ export function isAnyContextModeHook(entry) {
114
+ const scriptNames = Object.values(HOOK_SCRIPTS);
115
+ return (entry.hooks?.some((h) => h.command != null &&
116
+ (scriptNames.some((s) => h.command.includes(s)) ||
117
+ h.command.includes("context-mode hook"))) ?? false);
118
+ }
@@ -13,7 +13,7 @@
13
13
  * - Config: ~/.claude/settings.json
14
14
  * - Session dir: ~/.claude/context-mode/sessions/
15
15
  */
16
- import type { HookAdapter, HookParadigm, PlatformCapabilities, DiagnosticResult, PreToolUseEvent, PostToolUseEvent, PreCompactEvent, SessionStartEvent, PreToolUseResponse, PostToolUseResponse, PreCompactResponse, SessionStartResponse, HookRegistration, RoutingInstructionsConfig } from "../types.js";
16
+ import type { HookAdapter, HookParadigm, PlatformCapabilities, DiagnosticResult, PreToolUseEvent, PostToolUseEvent, PreCompactEvent, SessionStartEvent, PreToolUseResponse, PostToolUseResponse, PreCompactResponse, SessionStartResponse, HookRegistration } from "../types.js";
17
17
  export declare class ClaudeCodeAdapter implements HookAdapter {
18
18
  readonly name = "Claude Code";
19
19
  readonly paradigm: HookParadigm;
@@ -44,8 +44,6 @@ export declare class ClaudeCodeAdapter implements HookAdapter {
44
44
  backupSettings(): string | null;
45
45
  setHookPermissions(pluginRoot: string): string[];
46
46
  updatePluginRegistry(pluginRoot: string, version: string): void;
47
- getRoutingInstructionsConfig(): RoutingInstructionsConfig;
48
- writeRoutingInstructions(projectDir: string, pluginRoot: string): string | null;
49
47
  /**
50
48
  * Extract session ID from Claude Code hook input.
51
49
  * Priority: transcript_path UUID > session_id field > CLAUDE_SESSION_ID env > ppid fallback.
@@ -14,10 +14,10 @@
14
14
  * - Session dir: ~/.claude/context-mode/sessions/
15
15
  */
16
16
  import { createHash } from "node:crypto";
17
- import { readFileSync, writeFileSync, mkdirSync, copyFileSync, accessSync, readdirSync, chmodSync, constants, } from "node:fs";
17
+ import { readFileSync, writeFileSync, mkdirSync, copyFileSync, accessSync, existsSync, readdirSync, chmodSync, constants, } from "node:fs";
18
18
  import { resolve, join } from "node:path";
19
19
  import { homedir } from "node:os";
20
- import { HOOK_TYPES, HOOK_SCRIPTS, PRE_TOOL_USE_MATCHER_PATTERN, isContextModeHook, buildHookCommand, } from "./hooks.js";
20
+ import { HOOK_TYPES, HOOK_SCRIPTS, REQUIRED_HOOKS, PRE_TOOL_USE_MATCHER_PATTERN, isContextModeHook, isAnyContextModeHook, extractHookScriptPath, buildHookCommand, } from "./hooks.js";
21
21
  // ─────────────────────────────────────────────────────────
22
22
  // Adapter implementation
23
23
  // ─────────────────────────────────────────────────────────
@@ -383,6 +383,52 @@ export class ClaudeCodeAdapter {
383
383
  const settings = this.readSettings() ?? {};
384
384
  const hooks = (settings.hooks ?? {});
385
385
  const changes = [];
386
+ // Remove stale context-mode hook entries across ALL hook types (fixes #187).
387
+ // After a marketplace auto-update or version change, settings.json may contain
388
+ // hardcoded paths pointing to deleted version directories (e.g., .../0.9.17/hooks/...).
389
+ // Clean these before registering fresh entries to prevent SessionStart errors.
390
+ for (const hookType of Object.keys(hooks)) {
391
+ const entries = hooks[hookType];
392
+ if (!Array.isArray(entries))
393
+ continue;
394
+ const filtered = entries.filter((entry) => {
395
+ const typedEntry = entry;
396
+ if (!isAnyContextModeHook(typedEntry))
397
+ return true; // preserve non-context-mode hooks
398
+ // Keep CLI dispatcher entries (path-independent, never stale)
399
+ const commands = typedEntry.hooks ?? [];
400
+ const hasOnlyDispatcherCommands = commands.every((h) => !h.command || !extractHookScriptPath(h.command));
401
+ if (hasOnlyDispatcherCommands)
402
+ return true;
403
+ // For node path commands, check if the referenced script file exists
404
+ return commands.every((h) => {
405
+ const scriptPath = h.command ? extractHookScriptPath(h.command) : null;
406
+ if (!scriptPath)
407
+ return true; // not a path-based command
408
+ return existsSync(scriptPath);
409
+ });
410
+ });
411
+ const removed = entries.length - filtered.length;
412
+ if (removed > 0) {
413
+ hooks[hookType] = filtered;
414
+ changes.push(`Removed ${removed} stale ${hookType} hook(s)`);
415
+ }
416
+ }
417
+ // If plugin hooks.json already covers all required hooks, skip settings.json
418
+ // registration entirely (Issue #198). Plugin installs don't need settings.json
419
+ // entries — hooks.json with ${CLAUDE_PLUGIN_ROOT} is the source of truth.
420
+ const pluginHooks = this.readPluginHooks(pluginRoot);
421
+ if (pluginHooks) {
422
+ const allCovered = REQUIRED_HOOKS.every((ht) => this.checkHookType(undefined, pluginHooks, ht));
423
+ if (allCovered) {
424
+ // Still write cleaned settings (stale removal) but don't add new entries
425
+ settings.hooks = hooks;
426
+ this.writeSettings(settings);
427
+ changes.push("Skipped settings.json registration — plugin hooks.json is sufficient");
428
+ return changes;
429
+ }
430
+ }
431
+ // Register fresh hooks for required hook types
386
432
  const hookTypes = [
387
433
  HOOK_TYPES.PRE_TOOL_USE,
388
434
  HOOK_TYPES.SESSION_START,
@@ -486,39 +532,6 @@ export class ClaudeCodeAdapter {
486
532
  /* best effort */
487
533
  }
488
534
  }
489
- // ── Routing Instructions (soft enforcement) ────────────
490
- getRoutingInstructionsConfig() {
491
- return {
492
- fileName: "CLAUDE.md",
493
- globalPath: resolve(homedir(), ".claude", "CLAUDE.md"),
494
- projectRelativePath: "CLAUDE.md",
495
- };
496
- }
497
- writeRoutingInstructions(projectDir, pluginRoot) {
498
- const config = this.getRoutingInstructionsConfig();
499
- const targetPath = resolve(projectDir, config.projectRelativePath);
500
- const sourcePath = resolve(pluginRoot, "configs", "claude-code", config.fileName);
501
- try {
502
- const content = readFileSync(sourcePath, "utf-8");
503
- // Check if file exists and already has context-mode instructions
504
- try {
505
- const existing = readFileSync(targetPath, "utf-8");
506
- if (existing.includes("context-mode"))
507
- return null;
508
- // Append to existing file
509
- writeFileSync(targetPath, existing.trimEnd() + "\n\n" + content, "utf-8");
510
- return targetPath;
511
- }
512
- catch {
513
- // File doesn't exist — create it
514
- writeFileSync(targetPath, content, "utf-8");
515
- return targetPath;
516
- }
517
- }
518
- catch {
519
- return null;
520
- }
521
- }
522
535
  // ── Internal helpers ───────────────────────────────────
523
536
  /**
524
537
  * Extract session ID from Claude Code hook input.
@@ -14,6 +14,7 @@ export const CLIENT_NAME_TO_PLATFORM = {
14
14
  "Visual-Studio-Code": "vscode-copilot",
15
15
  "Codex": "codex",
16
16
  "codex-mcp-client": "codex",
17
+ "Kilo Code": "kilo",
17
18
  "Kiro CLI": "kiro",
18
19
  "Pi CLI": "pi",
19
20
  "Pi Coding Agent": "pi",
@@ -11,7 +11,7 @@
11
11
  * - All capabilities are false — MCP is the only integration path
12
12
  * - Session dir: ~/.codex/context-mode/sessions/
13
13
  */
14
- import type { HookAdapter, HookParadigm, PlatformCapabilities, DiagnosticResult, PreToolUseEvent, PostToolUseEvent, PreCompactEvent, SessionStartEvent, PreToolUseResponse, PostToolUseResponse, PreCompactResponse, SessionStartResponse, HookRegistration, RoutingInstructionsConfig } from "../types.js";
14
+ import type { HookAdapter, HookParadigm, PlatformCapabilities, DiagnosticResult, PreToolUseEvent, PostToolUseEvent, PreCompactEvent, SessionStartEvent, PreToolUseResponse, PostToolUseResponse, PreCompactResponse, SessionStartResponse, HookRegistration } from "../types.js";
15
15
  export declare class CodexAdapter implements HookAdapter {
16
16
  readonly name = "Codex CLI";
17
17
  readonly paradigm: HookParadigm;
@@ -38,7 +38,5 @@ export declare class CodexAdapter implements HookAdapter {
38
38
  backupSettings(): string | null;
39
39
  setHookPermissions(_pluginRoot: string): string[];
40
40
  updatePluginRegistry(_pluginRoot: string, _version: string): void;
41
- getRoutingInstructionsConfig(): RoutingInstructionsConfig;
42
- writeRoutingInstructions(projectDir: string, pluginRoot: string): string | null;
43
41
  getRoutingInstructions(): string;
44
42
  }
@@ -12,7 +12,7 @@
12
12
  * - Session dir: ~/.codex/context-mode/sessions/
13
13
  */
14
14
  import { createHash } from "node:crypto";
15
- import { readFileSync, writeFileSync, mkdirSync, copyFileSync, accessSync, constants, } from "node:fs";
15
+ import { readFileSync, mkdirSync, copyFileSync, accessSync, constants, } from "node:fs";
16
16
  import { resolve, join, dirname } from "node:path";
17
17
  import { fileURLToPath } from "node:url";
18
18
  import { homedir } from "node:os";
@@ -180,36 +180,6 @@ export class CodexAdapter {
180
180
  updatePluginRegistry(_pluginRoot, _version) {
181
181
  // Codex CLI has no plugin registry
182
182
  }
183
- // ── Routing Instructions (soft enforcement) ────────────
184
- getRoutingInstructionsConfig() {
185
- return {
186
- fileName: "AGENTS.md",
187
- globalPath: resolve(homedir(), ".codex", "AGENTS.md"),
188
- projectRelativePath: "AGENTS.md",
189
- };
190
- }
191
- writeRoutingInstructions(projectDir, pluginRoot) {
192
- const config = this.getRoutingInstructionsConfig();
193
- const targetPath = resolve(projectDir, config.projectRelativePath);
194
- const sourcePath = resolve(pluginRoot, "configs", "codex", config.fileName);
195
- try {
196
- const content = readFileSync(sourcePath, "utf-8");
197
- try {
198
- const existing = readFileSync(targetPath, "utf-8");
199
- if (existing.includes("context-mode"))
200
- return null;
201
- writeFileSync(targetPath, existing.trimEnd() + "\n\n" + content, "utf-8");
202
- return targetPath;
203
- }
204
- catch {
205
- writeFileSync(targetPath, content, "utf-8");
206
- return targetPath;
207
- }
208
- }
209
- catch {
210
- return null;
211
- }
212
- }
213
183
  getRoutingInstructions() {
214
184
  const instructionsPath = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "configs", "codex", "AGENTS.md");
215
185
  try {
@@ -4,7 +4,7 @@
4
4
  * Native Cursor hooks use lower-camel hook names and flat command entries in
5
5
  * `.cursor/hooks.json` / `~/.cursor/hooks.json`.
6
6
  */
7
- import type { HookAdapter, HookParadigm, PlatformCapabilities, DiagnosticResult, PreToolUseEvent, PostToolUseEvent, SessionStartEvent, PreToolUseResponse, PostToolUseResponse, SessionStartResponse, HookRegistration, RoutingInstructionsConfig } from "../types.js";
7
+ import type { HookAdapter, HookParadigm, PlatformCapabilities, DiagnosticResult, PreToolUseEvent, PostToolUseEvent, SessionStartEvent, PreToolUseResponse, PostToolUseResponse, SessionStartResponse, HookRegistration } from "../types.js";
8
8
  export declare class CursorAdapter implements HookAdapter {
9
9
  readonly name = "Cursor";
10
10
  readonly paradigm: HookParadigm;
@@ -29,8 +29,6 @@ export declare class CursorAdapter implements HookAdapter {
29
29
  backupSettings(): string | null;
30
30
  setHookPermissions(pluginRoot: string): string[];
31
31
  updatePluginRegistry(_pluginRoot: string, _version: string): void;
32
- getRoutingInstructionsConfig(): RoutingInstructionsConfig;
33
- writeRoutingInstructions(_projectDir: string, _pluginRoot: string): string | null;
34
32
  private getCandidateHookConfigPaths;
35
33
  private getProjectDir;
36
34
  private extractSessionId;
@@ -338,17 +338,6 @@ export class CursorAdapter {
338
338
  updatePluginRegistry(_pluginRoot, _version) {
339
339
  // Cursor manages extensions and native hooks internally.
340
340
  }
341
- getRoutingInstructionsConfig() {
342
- return {
343
- fileName: "AGENTS.md",
344
- globalPath: "",
345
- projectRelativePath: "AGENTS.md",
346
- };
347
- }
348
- writeRoutingInstructions(_projectDir, _pluginRoot) {
349
- // Native Cursor hook support ships independently from any instruction-file story.
350
- return null;
351
- }
352
341
  getCandidateHookConfigPaths() {
353
342
  const paths = [this.getSettingsPath(), join(homedir(), ".cursor", "hooks.json")];
354
343
  if (process.platform === "darwin") {
@@ -9,6 +9,7 @@
9
9
  * Verified env vars per platform (from source code audit):
10
10
  * - Claude Code: CLAUDE_PROJECT_DIR, CLAUDE_SESSION_ID | ~/.claude/
11
11
  * - Gemini CLI: GEMINI_PROJECT_DIR (hooks), GEMINI_CLI (MCP) | ~/.gemini/
12
+ * - KiloCode: KILO, KILO_PID | ~/.config/kilo/
12
13
  * - OpenCode: OPENCODE, OPENCODE_PID | ~/.config/opencode/
13
14
  * - OpenClaw: OPENCLAW_HOME, OPENCLAW_CLI | ~/.openclaw/
14
15
  * - Codex CLI: CODEX_CI, CODEX_THREAD_ID | ~/.codex/