context-mode 1.0.42 → 1.0.44
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 +369 -295
- package/build/adapters/kiro/index.d.ts +2 -2
- package/build/adapters/kiro/index.js +6 -6
- package/build/db-base.js +7 -1
- package/cli.bundle.mjs +102 -110
- package/configs/codex/AGENTS.md +13 -13
- package/configs/cursor/context-mode.mdc +27 -0
- package/configs/openclaw/AGENTS.md +13 -13
- package/configs/opencode/AGENTS.md +13 -13
- package/configs/pi/AGENTS.md +13 -13
- package/configs/zed/AGENTS.md +13 -13
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/server.bundle.mjs +87 -95
- /package/configs/kiro/{mcp_config.json → mcp.json} +0 -0
package/README.md
CHANGED
|
@@ -26,266 +26,315 @@ https://github.com/user-attachments/assets/07013dbf-07c0-4ef1-974a-33ea1207637b
|
|
|
26
26
|
|
|
27
27
|
## Install
|
|
28
28
|
|
|
29
|
+
Platforms are grouped by install complexity. Hook-capable platforms get automatic routing enforcement. Non-hook platforms need a one-time routing file copy.
|
|
30
|
+
|
|
29
31
|
<details open>
|
|
30
|
-
<summary><strong>Claude Code</strong
|
|
32
|
+
<summary><strong>Claude Code</strong> — plugin marketplace, fully automatic</summary>
|
|
33
|
+
|
|
34
|
+
**Prerequisites:** Claude Code v1.0.33+ (`claude --version`). If `/plugin` is not recognized, update first: `brew upgrade claude-code` or `npm update -g @anthropic-ai/claude-code`.
|
|
31
35
|
|
|
32
|
-
**
|
|
36
|
+
**Install:**
|
|
33
37
|
|
|
34
38
|
```bash
|
|
35
39
|
/plugin marketplace add mksglu/context-mode
|
|
36
40
|
/plugin install context-mode@context-mode
|
|
37
41
|
```
|
|
38
42
|
|
|
39
|
-
|
|
43
|
+
Restart Claude Code (or run `/reload-plugins`).
|
|
44
|
+
|
|
45
|
+
**Verify:**
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
/context-mode:ctx-doctor
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
All checks should show `[x]`. The doctor validates runtimes, hooks, FTS5, and plugin registration.
|
|
40
52
|
|
|
41
|
-
|
|
42
|
-
- MCP server with 6 sandbox tools (`ctx_batch_execute`, `ctx_execute`, `ctx_execute_file`, `ctx_index`, `ctx_search`, `ctx_fetch_and_index`)
|
|
43
|
-
- PreToolUse hooks that intercept Bash, Read, WebFetch, Grep, and Task calls — nudging them toward sandbox execution
|
|
44
|
-
- PostToolUse, PreCompact, and SessionStart hooks for session tracking and context injection
|
|
45
|
-
- Routing instructions injected automatically via SessionStart hook (no file written to your project)
|
|
46
|
-
- Slash commands for diagnostics and upgrades (Claude Code only)
|
|
53
|
+
**Routing:** Automatic. The SessionStart hook injects routing instructions at runtime — no file is written to your project. The plugin registers all hooks (PreToolUse, PostToolUse, PreCompact, SessionStart) and 6 sandbox tools (`ctx_batch_execute`, `ctx_execute`, `ctx_execute_file`, `ctx_index`, `ctx_search`, `ctx_fetch_and_index`).
|
|
47
54
|
|
|
48
|
-
| Command | What it does |
|
|
55
|
+
| Slash Command | What it does |
|
|
49
56
|
|---|---|
|
|
50
57
|
| `/context-mode:ctx-stats` | Context savings — per-tool breakdown, tokens consumed, savings ratio. |
|
|
51
58
|
| `/context-mode:ctx-doctor` | Diagnostics — runtimes, hooks, FTS5, plugin registration, versions. |
|
|
52
59
|
| `/context-mode:ctx-upgrade` | Pull latest, rebuild, migrate cache, fix hooks. |
|
|
53
60
|
|
|
54
|
-
> **Note:** Slash commands are a Claude Code plugin feature. On other platforms,
|
|
61
|
+
> **Note:** Slash commands are a Claude Code plugin feature. On other platforms, type `ctx stats`, `ctx doctor`, or `ctx upgrade` in the chat — the model calls the MCP tool automatically. See [Utility Commands](#utility-commands).
|
|
55
62
|
|
|
56
|
-
|
|
63
|
+
<details>
|
|
64
|
+
<summary>Alternative — MCP-only install (no hooks or slash commands)</summary>
|
|
57
65
|
|
|
58
66
|
```bash
|
|
59
67
|
claude mcp add context-mode -- npx -y context-mode
|
|
60
68
|
```
|
|
61
69
|
|
|
62
|
-
This gives you the 6 sandbox tools
|
|
70
|
+
This gives you the 6 sandbox tools without automatic routing. The model can still use them — it just won't be nudged to prefer them over raw Bash/Read/WebFetch. Good for trying it out before committing to the full plugin.
|
|
71
|
+
|
|
72
|
+
</details>
|
|
63
73
|
|
|
64
74
|
</details>
|
|
65
75
|
|
|
66
76
|
<details>
|
|
67
|
-
<summary><strong>Gemini CLI</strong
|
|
77
|
+
<summary><strong>Gemini CLI</strong> — one config file, hooks included</summary>
|
|
68
78
|
|
|
69
|
-
**
|
|
79
|
+
**Prerequisites:** Node.js 18+, Gemini CLI installed.
|
|
70
80
|
|
|
71
|
-
|
|
72
|
-
npm install -g context-mode
|
|
73
|
-
```
|
|
81
|
+
**Install:**
|
|
74
82
|
|
|
75
|
-
|
|
83
|
+
1. Install context-mode globally:
|
|
76
84
|
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"context-mode": {
|
|
81
|
-
"command": "context-mode"
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
```
|
|
85
|
+
```bash
|
|
86
|
+
npm install -g context-mode
|
|
87
|
+
```
|
|
86
88
|
|
|
87
|
-
|
|
89
|
+
2. Add the following to `~/.gemini/settings.json`. This single file registers the MCP server and all four hooks:
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"mcpServers": {
|
|
94
|
+
"context-mode": {
|
|
95
|
+
"command": "context-mode"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"hooks": {
|
|
99
|
+
"BeforeTool": [
|
|
100
|
+
{
|
|
101
|
+
"matcher": "run_shell_command|read_file|read_many_files|grep_search|search_file_content|web_fetch|activate_skill|mcp__plugin_context-mode",
|
|
102
|
+
"hooks": [{ "type": "command", "command": "context-mode hook gemini-cli beforetool" }]
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"AfterTool": [
|
|
106
|
+
{
|
|
107
|
+
"matcher": "",
|
|
108
|
+
"hooks": [{ "type": "command", "command": "context-mode hook gemini-cli aftertool" }]
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
"PreCompress": [
|
|
112
|
+
{
|
|
113
|
+
"matcher": "",
|
|
114
|
+
"hooks": [{ "type": "command", "command": "context-mode hook gemini-cli precompress" }]
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
"SessionStart": [
|
|
118
|
+
{
|
|
119
|
+
"matcher": "",
|
|
120
|
+
"hooks": [{ "type": "command", "command": "context-mode hook gemini-cli sessionstart" }]
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
3. Restart Gemini CLI.
|
|
128
|
+
|
|
129
|
+
**Verify:**
|
|
88
130
|
|
|
89
|
-
```json
|
|
90
|
-
{
|
|
91
|
-
"hooks": {
|
|
92
|
-
"BeforeTool": [
|
|
93
|
-
{
|
|
94
|
-
"matcher": "",
|
|
95
|
-
"hooks": [{ "type": "command", "command": "context-mode hook gemini-cli beforetool" }]
|
|
96
|
-
}
|
|
97
|
-
],
|
|
98
|
-
"AfterTool": [
|
|
99
|
-
{
|
|
100
|
-
"matcher": "",
|
|
101
|
-
"hooks": [{ "type": "command", "command": "context-mode hook gemini-cli aftertool" }]
|
|
102
|
-
}
|
|
103
|
-
],
|
|
104
|
-
"SessionStart": [
|
|
105
|
-
{
|
|
106
|
-
"matcher": "",
|
|
107
|
-
"hooks": [{ "type": "command", "command": "context-mode hook gemini-cli sessionstart" }]
|
|
108
|
-
}
|
|
109
|
-
]
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
131
|
```
|
|
132
|
+
/mcp list
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
You should see `context-mode: ... - Connected`.
|
|
113
136
|
|
|
114
|
-
**
|
|
137
|
+
**Routing:** Automatic. The SessionStart hook injects routing instructions at runtime — no `GEMINI.md` file is written to your project. All four hooks (BeforeTool, AfterTool, PreCompress, SessionStart) handle enforcement programmatically.
|
|
115
138
|
|
|
116
|
-
> **Why
|
|
139
|
+
> **Why the BeforeTool matcher?** It targets only tools that produce large output (`run_shell_command`, `read_file`, `read_many_files`, `grep_search`, `search_file_content`, `web_fetch`, `activate_skill`) plus context-mode's own tools (`mcp__plugin_context-mode`). This avoids unnecessary hook overhead on lightweight tools while intercepting every tool that could flood your context window.
|
|
117
140
|
|
|
118
|
-
Full
|
|
141
|
+
Full config reference: [`configs/gemini-cli/settings.json`](configs/gemini-cli/settings.json)
|
|
119
142
|
|
|
120
143
|
</details>
|
|
121
144
|
|
|
122
145
|
<details>
|
|
123
|
-
<summary><strong>VS Code Copilot</strong
|
|
146
|
+
<summary><strong>VS Code Copilot</strong> — hooks with SessionStart</summary>
|
|
124
147
|
|
|
125
|
-
**
|
|
148
|
+
**Prerequisites:** Node.js 18+, VS Code with Copilot Chat v0.32+.
|
|
126
149
|
|
|
127
|
-
|
|
128
|
-
npm install -g context-mode
|
|
129
|
-
```
|
|
150
|
+
**Install:**
|
|
130
151
|
|
|
131
|
-
|
|
152
|
+
1. Install context-mode globally:
|
|
132
153
|
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
"context-mode": {
|
|
137
|
-
"command": "context-mode"
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
```
|
|
154
|
+
```bash
|
|
155
|
+
npm install -g context-mode
|
|
156
|
+
```
|
|
142
157
|
|
|
143
|
-
|
|
158
|
+
2. Create `.vscode/mcp.json` in your project root:
|
|
144
159
|
|
|
145
|
-
```json
|
|
146
|
-
{
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"servers": {
|
|
163
|
+
"context-mode": {
|
|
164
|
+
"command": "context-mode"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
3. Create `.github/hooks/context-mode.json`:
|
|
171
|
+
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"hooks": {
|
|
175
|
+
"PreToolUse": [
|
|
176
|
+
{ "type": "command", "command": "context-mode hook vscode-copilot pretooluse" }
|
|
177
|
+
],
|
|
178
|
+
"PostToolUse": [
|
|
179
|
+
{ "type": "command", "command": "context-mode hook vscode-copilot posttooluse" }
|
|
180
|
+
],
|
|
181
|
+
"SessionStart": [
|
|
182
|
+
{ "type": "command", "command": "context-mode hook vscode-copilot sessionstart" }
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
4. Restart VS Code.
|
|
160
189
|
|
|
161
|
-
**
|
|
190
|
+
**Verify:** Open Copilot Chat and type `ctx stats`. Context-mode tools should appear and respond.
|
|
162
191
|
|
|
163
|
-
|
|
192
|
+
**Routing:** Automatic. The SessionStart hook injects routing instructions at runtime — no `copilot-instructions.md` file is written to your project.
|
|
164
193
|
|
|
165
194
|
Full hook config including PreCompact: [`configs/vscode-copilot/hooks.json`](configs/vscode-copilot/hooks.json)
|
|
166
195
|
|
|
167
196
|
</details>
|
|
168
197
|
|
|
169
198
|
<details>
|
|
170
|
-
<summary><strong>Cursor</strong
|
|
199
|
+
<summary><strong>Cursor</strong> — hooks without SessionStart</summary>
|
|
171
200
|
|
|
172
|
-
**
|
|
201
|
+
**Prerequisites:** Node.js 18+, Cursor with agent mode.
|
|
173
202
|
|
|
174
|
-
|
|
175
|
-
npm install -g context-mode
|
|
176
|
-
```
|
|
203
|
+
**Install:**
|
|
177
204
|
|
|
178
|
-
|
|
205
|
+
1. Install context-mode globally:
|
|
179
206
|
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
"context-mode": {
|
|
184
|
-
"command": "context-mode"
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
```
|
|
207
|
+
```bash
|
|
208
|
+
npm install -g context-mode
|
|
209
|
+
```
|
|
189
210
|
|
|
190
|
-
|
|
211
|
+
2. Create `.cursor/mcp.json` in your project root (or `~/.cursor/mcp.json` for global):
|
|
191
212
|
|
|
192
|
-
```json
|
|
193
|
-
{
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
],
|
|
202
|
-
"postToolUse": [
|
|
203
|
-
{
|
|
204
|
-
"command": "context-mode hook cursor posttooluse"
|
|
205
|
-
}
|
|
206
|
-
]
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
```
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"mcpServers": {
|
|
216
|
+
"context-mode": {
|
|
217
|
+
"command": "context-mode"
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
```
|
|
210
222
|
|
|
211
|
-
|
|
223
|
+
3. Create `.cursor/hooks.json` (or `~/.cursor/hooks.json` for global):
|
|
212
224
|
|
|
213
|
-
|
|
225
|
+
```json
|
|
226
|
+
{
|
|
227
|
+
"version": 1,
|
|
228
|
+
"hooks": {
|
|
229
|
+
"preToolUse": [
|
|
230
|
+
{
|
|
231
|
+
"command": "context-mode hook cursor pretooluse",
|
|
232
|
+
"matcher": "Shell|Read|Grep|WebFetch|Task|MCP:ctx_execute|MCP:ctx_execute_file|MCP:ctx_batch_execute"
|
|
233
|
+
}
|
|
234
|
+
],
|
|
235
|
+
"postToolUse": [
|
|
236
|
+
{
|
|
237
|
+
"command": "context-mode hook cursor posttooluse"
|
|
238
|
+
}
|
|
239
|
+
]
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
```
|
|
214
243
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
244
|
+
The `preToolUse` matcher is optional — without it, the hook fires on all tools.
|
|
245
|
+
|
|
246
|
+
4. Copy the routing rules file. Cursor lacks a SessionStart hook, so the model needs a rules file for routing awareness:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
mkdir -p .cursor/rules
|
|
250
|
+
cp node_modules/context-mode/configs/cursor/context-mode.mdc .cursor/rules/context-mode.mdc
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
5. Restart Cursor or open a new agent session.
|
|
254
|
+
|
|
255
|
+
**Verify:** Open Cursor Settings > MCP and confirm "context-mode" shows as connected. In agent chat, type `ctx stats`.
|
|
218
256
|
|
|
219
|
-
|
|
220
|
-
|
|
257
|
+
**Routing:** Hooks enforce routing programmatically via `preToolUse`/`postToolUse`. The `.cursor/rules/context-mode.mdc` file provides routing instructions at session start since Cursor's `sessionStart` hook is currently rejected by their validator ([forum report](https://forum.cursor.com/t/unknown-hook-type-sessionstart/149566)). Project `.cursor/hooks.json` overrides `~/.cursor/hooks.json`.
|
|
258
|
+
|
|
259
|
+
Full configs: [`configs/cursor/hooks.json`](configs/cursor/hooks.json) | [`configs/cursor/mcp.json`](configs/cursor/mcp.json) | [`configs/cursor/context-mode.mdc`](configs/cursor/context-mode.mdc)
|
|
221
260
|
|
|
222
261
|
</details>
|
|
223
262
|
|
|
224
263
|
<details>
|
|
225
|
-
<summary><strong>OpenCode</strong
|
|
264
|
+
<summary><strong>OpenCode</strong> — TypeScript plugin with hooks</summary>
|
|
226
265
|
|
|
227
|
-
**
|
|
266
|
+
**Prerequisites:** Node.js 18+, OpenCode installed.
|
|
228
267
|
|
|
229
|
-
|
|
230
|
-
npm install -g context-mode
|
|
231
|
-
```
|
|
268
|
+
**Install:**
|
|
232
269
|
|
|
233
|
-
|
|
270
|
+
1. Install context-mode globally:
|
|
234
271
|
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
"mcp": {
|
|
239
|
-
"context-mode": {
|
|
240
|
-
"type": "local",
|
|
241
|
-
"command": ["context-mode"]
|
|
242
|
-
}
|
|
243
|
-
},
|
|
244
|
-
"plugin": ["context-mode"]
|
|
245
|
-
}
|
|
246
|
-
```
|
|
272
|
+
```bash
|
|
273
|
+
npm install -g context-mode
|
|
274
|
+
```
|
|
247
275
|
|
|
248
|
-
|
|
276
|
+
2. Add to `opencode.json` in your project root (or `~/.config/opencode/opencode.json` for global):
|
|
249
277
|
|
|
250
|
-
|
|
278
|
+
```json
|
|
279
|
+
{
|
|
280
|
+
"$schema": "https://opencode.ai/config.json",
|
|
281
|
+
"mcp": {
|
|
282
|
+
"context-mode": {
|
|
283
|
+
"type": "local",
|
|
284
|
+
"command": ["context-mode"]
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
"plugin": ["context-mode"]
|
|
288
|
+
}
|
|
289
|
+
```
|
|
251
290
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
291
|
+
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
|
+
|
|
293
|
+
3. Restart OpenCode.
|
|
294
|
+
|
|
295
|
+
**Verify:** In the OpenCode session, type `ctx stats`. Context-mode tools should appear and respond.
|
|
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.
|
|
298
|
+
|
|
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
|
+
|
|
301
|
+
Full config: [`configs/opencode/opencode.json`](configs/opencode/opencode.json)
|
|
255
302
|
|
|
256
303
|
</details>
|
|
257
304
|
|
|
258
305
|
<details>
|
|
259
|
-
<summary><strong>OpenClaw / Pi Agent</strong
|
|
306
|
+
<summary><strong>OpenClaw / Pi Agent</strong> — native gateway plugin</summary>
|
|
260
307
|
|
|
261
308
|
**Prerequisites:** OpenClaw gateway running ([>2026.1.29](https://github.com/openclaw/openclaw/pull/9761)), Node.js 22+.
|
|
262
309
|
|
|
263
310
|
context-mode runs as a native [OpenClaw](https://github.com/openclaw) gateway plugin, targeting **Pi Agent** sessions (Read/Write/Edit/Bash tools). Unlike other platforms, there's no separate MCP server — the plugin registers directly into the gateway runtime via OpenClaw's [plugin API](https://docs.openclaw.ai/tools/plugin).
|
|
264
311
|
|
|
265
|
-
**
|
|
312
|
+
**Install:**
|
|
266
313
|
|
|
267
|
-
|
|
268
|
-
git clone https://github.com/mksglu/context-mode.git
|
|
269
|
-
cd context-mode
|
|
270
|
-
npm run install:openclaw
|
|
271
|
-
```
|
|
314
|
+
1. Clone and install:
|
|
272
315
|
|
|
273
|
-
|
|
316
|
+
```bash
|
|
317
|
+
git clone https://github.com/mksglu/context-mode.git
|
|
318
|
+
cd context-mode
|
|
319
|
+
npm run install:openclaw
|
|
320
|
+
```
|
|
274
321
|
|
|
275
|
-
|
|
276
|
-
npm run install:openclaw -- /path/to/openclaw-state
|
|
277
|
-
```
|
|
322
|
+
The installer uses `$OPENCLAW_STATE_DIR` from your environment (default: `/openclaw`). To specify a custom path:
|
|
278
323
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
324
|
+
```bash
|
|
325
|
+
npm run install:openclaw -- /path/to/openclaw-state
|
|
326
|
+
```
|
|
282
327
|
|
|
283
|
-
|
|
328
|
+
Common locations: **Docker** — `/openclaw` (the default). **Local** — `~/.openclaw` or wherever you set `OPENCLAW_STATE_DIR`.
|
|
284
329
|
|
|
285
|
-
|
|
330
|
+
The installer handles everything: `npm install`, `npm run build`, `better-sqlite3` native rebuild, extension registration in `runtime.json`, and gateway restart via SIGUSR1.
|
|
331
|
+
|
|
332
|
+
2. Open a Pi Agent session.
|
|
333
|
+
|
|
334
|
+
**Verify:** 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). Type `ctx stats` to confirm tools are loaded.
|
|
335
|
+
|
|
336
|
+
**Routing:** Automatic. All tool interception, session tracking, and compaction recovery hooks activate automatically — no manual hook configuration or routing file needed.
|
|
286
337
|
|
|
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.
|
|
288
|
-
>
|
|
289
338
|
> **Minimum version:** OpenClaw >2026.1.29 — this includes the `api.on()` lifecycle fix from [PR #9761](https://github.com/openclaw/openclaw/pull/9761). On older versions, lifecycle hooks silently fail. The adapter falls back to DB snapshot reconstruction (less precise but preserves critical state).
|
|
290
339
|
|
|
291
340
|
Full documentation: [`docs/adapters/openclaw.md`](docs/adapters/openclaw.md)
|
|
@@ -293,191 +342,216 @@ Full documentation: [`docs/adapters/openclaw.md`](docs/adapters/openclaw.md)
|
|
|
293
342
|
</details>
|
|
294
343
|
|
|
295
344
|
<details>
|
|
296
|
-
<summary><strong>Codex CLI</strong
|
|
345
|
+
<summary><strong>Codex CLI</strong> — MCP-only, no hooks</summary>
|
|
297
346
|
|
|
298
|
-
**
|
|
347
|
+
**Prerequisites:** Node.js 18+, Codex CLI installed.
|
|
299
348
|
|
|
300
|
-
|
|
301
|
-
npm install -g context-mode
|
|
302
|
-
```
|
|
349
|
+
**Install:**
|
|
303
350
|
|
|
304
|
-
|
|
351
|
+
1. Install context-mode globally:
|
|
305
352
|
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
```
|
|
353
|
+
```bash
|
|
354
|
+
npm install -g context-mode
|
|
355
|
+
```
|
|
310
356
|
|
|
311
|
-
|
|
357
|
+
2. Add to `~/.codex/config.toml`:
|
|
312
358
|
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
|
|
359
|
+
```toml
|
|
360
|
+
[mcp_servers.context-mode]
|
|
361
|
+
command = "context-mode"
|
|
362
|
+
```
|
|
316
363
|
|
|
317
|
-
|
|
318
|
-
cp node_modules/context-mode/configs/codex/AGENTS.md ~/.codex/AGENTS.md
|
|
319
|
-
```
|
|
364
|
+
3. Copy routing instructions (Codex CLI has no hook support):
|
|
320
365
|
|
|
321
|
-
|
|
366
|
+
```bash
|
|
367
|
+
cp node_modules/context-mode/configs/codex/AGENTS.md ./AGENTS.md
|
|
368
|
+
```
|
|
322
369
|
|
|
323
|
-
|
|
370
|
+
For global use: `cp node_modules/context-mode/configs/codex/AGENTS.md ~/.codex/AGENTS.md`. Global applies to all projects. If both exist, Codex CLI merges them.
|
|
324
371
|
|
|
325
|
-
|
|
372
|
+
4. Restart Codex CLI.
|
|
373
|
+
|
|
374
|
+
**Verify:** Start a session and type `ctx stats`. Context-mode tools should appear and respond.
|
|
375
|
+
|
|
376
|
+
**Routing:** Manual. The `AGENTS.md` file is the only enforcement method (~60% compliance). There is no programmatic interception — the model can run raw `curl`, read large files, or bypass sandbox tools at any time. Hook support PRs [#2904](https://github.com/openai/codex/pull/2904) and [#9796](https://github.com/openai/codex/pull/9796) were closed without merge.
|
|
326
377
|
|
|
327
378
|
</details>
|
|
328
379
|
|
|
329
380
|
<details>
|
|
330
|
-
<summary><strong>Antigravity</strong
|
|
381
|
+
<summary><strong>Antigravity</strong> — MCP-only, no hooks</summary>
|
|
331
382
|
|
|
332
|
-
**
|
|
383
|
+
**Prerequisites:** Node.js 18+, Antigravity installed.
|
|
333
384
|
|
|
334
|
-
|
|
335
|
-
npm install -g context-mode
|
|
336
|
-
```
|
|
385
|
+
**Install:**
|
|
337
386
|
|
|
338
|
-
|
|
387
|
+
1. Install context-mode globally:
|
|
339
388
|
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
"context-mode": {
|
|
344
|
-
"command": "context-mode"
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
```
|
|
389
|
+
```bash
|
|
390
|
+
npm install -g context-mode
|
|
391
|
+
```
|
|
349
392
|
|
|
350
|
-
|
|
393
|
+
2. Add to `~/.gemini/antigravity/mcp_config.json`:
|
|
351
394
|
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
|
|
395
|
+
```json
|
|
396
|
+
{
|
|
397
|
+
"mcpServers": {
|
|
398
|
+
"context-mode": {
|
|
399
|
+
"command": "context-mode"
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
3. Copy routing instructions (Antigravity has no hook support):
|
|
355
406
|
|
|
356
|
-
|
|
407
|
+
```bash
|
|
408
|
+
cp node_modules/context-mode/configs/antigravity/GEMINI.md ./GEMINI.md
|
|
409
|
+
```
|
|
357
410
|
|
|
358
|
-
|
|
411
|
+
4. Restart Antigravity.
|
|
359
412
|
|
|
360
|
-
**
|
|
413
|
+
**Verify:** In an Antigravity session, type `ctx stats`. Context-mode tools should appear and respond.
|
|
361
414
|
|
|
362
|
-
|
|
363
|
-
|
|
415
|
+
**Routing:** Manual. The `GEMINI.md` file is the only enforcement method (~60% compliance). There is no programmatic interception. Auto-detected via MCP protocol handshake (`clientInfo.name`) — no manual platform configuration needed.
|
|
416
|
+
|
|
417
|
+
Full configs: [`configs/antigravity/mcp_config.json`](configs/antigravity/mcp_config.json) | [`configs/antigravity/GEMINI.md`](configs/antigravity/GEMINI.md)
|
|
364
418
|
|
|
365
419
|
</details>
|
|
366
420
|
|
|
367
421
|
<details>
|
|
368
|
-
<summary><strong>Kiro</strong
|
|
422
|
+
<summary><strong>Kiro</strong> — hooks with steering file</summary>
|
|
369
423
|
|
|
370
|
-
**
|
|
424
|
+
**Prerequisites:** Node.js 18+, Kiro with MCP enabled (Settings > search "MCP").
|
|
371
425
|
|
|
372
|
-
|
|
373
|
-
npm install -g context-mode
|
|
374
|
-
```
|
|
426
|
+
**Install:**
|
|
375
427
|
|
|
376
|
-
|
|
428
|
+
1. Install context-mode globally:
|
|
377
429
|
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
"context-mode": {
|
|
382
|
-
"command": "context-mode"
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
```
|
|
430
|
+
```bash
|
|
431
|
+
npm install -g context-mode
|
|
432
|
+
```
|
|
387
433
|
|
|
388
|
-
|
|
434
|
+
2. Add to `.kiro/settings/mcp.json` in your project (or `~/.kiro/settings/mcp.json` for global):
|
|
389
435
|
|
|
390
|
-
```json
|
|
391
|
-
{
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
{ "matcher": "*", "command": "context-mode hook kiro posttooluse" }
|
|
400
|
-
]
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
```
|
|
436
|
+
```json
|
|
437
|
+
{
|
|
438
|
+
"mcpServers": {
|
|
439
|
+
"context-mode": {
|
|
440
|
+
"command": "context-mode"
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
```
|
|
404
445
|
|
|
405
|
-
|
|
446
|
+
3. Create `.kiro/hooks/context-mode.json`:
|
|
406
447
|
|
|
407
|
-
```
|
|
408
|
-
|
|
409
|
-
|
|
448
|
+
```json
|
|
449
|
+
{
|
|
450
|
+
"name": "context-mode",
|
|
451
|
+
"description": "Context-mode hooks for context window protection",
|
|
452
|
+
"hooks": {
|
|
453
|
+
"preToolUse": [
|
|
454
|
+
{ "matcher": "*", "command": "context-mode hook kiro pretooluse" }
|
|
455
|
+
],
|
|
456
|
+
"postToolUse": [
|
|
457
|
+
{ "matcher": "*", "command": "context-mode hook kiro posttooluse" }
|
|
458
|
+
]
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
4. Copy routing instructions. Kiro's `agentSpawn` (SessionStart) is not yet implemented, so the model needs a routing file at session start:
|
|
464
|
+
|
|
465
|
+
```bash
|
|
466
|
+
cp node_modules/context-mode/configs/kiro/KIRO.md ./KIRO.md
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
5. Restart Kiro.
|
|
410
470
|
|
|
411
|
-
**
|
|
471
|
+
**Verify:** Open the Kiro panel > MCP Servers tab and confirm "context-mode" shows a green status indicator. In chat, type `ctx stats`.
|
|
412
472
|
|
|
413
|
-
**
|
|
473
|
+
**Routing:** Hooks enforce routing programmatically via `preToolUse`/`postToolUse`. The `KIRO.md` file provides routing instructions since `agentSpawn` (SessionStart equivalent) is not yet wired. Tool names appear as `@context-mode/ctx_batch_execute`, `@context-mode/ctx_search`, etc. Auto-detected via MCP protocol handshake.
|
|
474
|
+
|
|
475
|
+
Full configs: [`configs/kiro/mcp.json`](configs/kiro/mcp.json) | [`configs/kiro/agent.json`](configs/kiro/agent.json) | [`configs/kiro/KIRO.md`](configs/kiro/KIRO.md)
|
|
414
476
|
|
|
415
477
|
</details>
|
|
416
478
|
|
|
417
479
|
<details>
|
|
418
|
-
<summary><strong>Zed</strong
|
|
480
|
+
<summary><strong>Zed</strong> — MCP-only, no hooks</summary>
|
|
419
481
|
|
|
420
|
-
**
|
|
482
|
+
**Prerequisites:** Node.js 18+, Zed installed.
|
|
421
483
|
|
|
422
|
-
|
|
423
|
-
npm install -g context-mode
|
|
424
|
-
```
|
|
484
|
+
**Install:**
|
|
425
485
|
|
|
426
|
-
|
|
486
|
+
1. Install context-mode globally:
|
|
427
487
|
|
|
428
|
-
```
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
"context-mode": {
|
|
432
|
-
"command": {
|
|
433
|
-
"path": "context-mode"
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
```
|
|
488
|
+
```bash
|
|
489
|
+
npm install -g context-mode
|
|
490
|
+
```
|
|
439
491
|
|
|
440
|
-
|
|
492
|
+
2. Add to `~/.config/zed/settings.json` (Windows: `%APPDATA%\Zed\settings.json`):
|
|
441
493
|
|
|
442
|
-
```
|
|
443
|
-
|
|
444
|
-
|
|
494
|
+
```json
|
|
495
|
+
{
|
|
496
|
+
"context_servers": {
|
|
497
|
+
"context-mode": {
|
|
498
|
+
"command": {
|
|
499
|
+
"path": "context-mode"
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
Note: Zed uses `"context_servers"` and `"command": { "path": "..." }` syntax, not `"mcpServers"` or `"command": "..."` like other platforms.
|
|
507
|
+
|
|
508
|
+
3. Copy routing instructions (Zed has no hook support):
|
|
445
509
|
|
|
446
|
-
|
|
510
|
+
```bash
|
|
511
|
+
cp node_modules/context-mode/configs/zed/AGENTS.md ./AGENTS.md
|
|
512
|
+
```
|
|
447
513
|
|
|
448
|
-
|
|
514
|
+
4. Restart Zed (or save `settings.json` — Zed auto-restarts context servers on config change).
|
|
449
515
|
|
|
450
|
-
**
|
|
516
|
+
**Verify:** Open the Agent Panel (`Cmd+Shift+A`), go to settings, and check the indicator dot next to "context-mode" — green means active. Type `ctx stats` in the agent chat.
|
|
517
|
+
|
|
518
|
+
**Routing:** Manual. The `AGENTS.md` file is the only enforcement method (~60% compliance). There is no programmatic interception. Tool names appear as `mcp:context-mode:ctx_batch_execute`, `mcp:context-mode:ctx_search`, etc. Auto-detected via MCP protocol handshake.
|
|
451
519
|
|
|
452
520
|
</details>
|
|
453
521
|
|
|
454
522
|
<details>
|
|
455
|
-
<summary><strong>Pi Coding Agent</strong
|
|
523
|
+
<summary><strong>Pi Coding Agent</strong> — extension with full hook support</summary>
|
|
456
524
|
|
|
457
|
-
**
|
|
525
|
+
**Prerequisites:** Node.js 18+, Pi Coding Agent installed.
|
|
458
526
|
|
|
459
|
-
|
|
460
|
-
git clone https://github.com/mksglu/context-mode.git ~/.pi/extensions/context-mode
|
|
461
|
-
cd ~/.pi/extensions/context-mode
|
|
462
|
-
npm install
|
|
463
|
-
```
|
|
527
|
+
**Install:**
|
|
464
528
|
|
|
465
|
-
|
|
529
|
+
1. Clone the extension:
|
|
466
530
|
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
531
|
+
```bash
|
|
532
|
+
git clone https://github.com/mksglu/context-mode.git ~/.pi/extensions/context-mode
|
|
533
|
+
cd ~/.pi/extensions/context-mode
|
|
534
|
+
npm install
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
2. Add to `~/.pi/settings/mcp.json` (or `.pi/settings/mcp.json` for project-level):
|
|
538
|
+
|
|
539
|
+
```json
|
|
540
|
+
{
|
|
541
|
+
"mcpServers": {
|
|
542
|
+
"context-mode": {
|
|
543
|
+
"command": "node",
|
|
544
|
+
"args": ["~/.pi/extensions/context-mode/node_modules/context-mode/start.mjs"]
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
3. Restart Pi.
|
|
477
551
|
|
|
478
|
-
**
|
|
552
|
+
**Verify:** In a Pi session, type `ctx stats`. Context-mode tools should appear and respond.
|
|
479
553
|
|
|
480
|
-
The extension
|
|
554
|
+
**Routing:** Automatic. The extension registers all key lifecycle events (`tool_call`, `tool_result`, `session_start`, `session_before_compact`), providing full session continuity and routing enforcement.
|
|
481
555
|
|
|
482
556
|
</details>
|
|
483
557
|
|
|
@@ -719,7 +793,7 @@ Hooks intercept tool calls programmatically — they can block dangerous command
|
|
|
719
793
|
| Claude Code | Yes (auto) | [`CLAUDE.md`](configs/claude-code/CLAUDE.md) | **~98% saved** | ~60% saved |
|
|
720
794
|
| Gemini CLI | Yes | [`GEMINI.md`](configs/gemini-cli/GEMINI.md) | **~98% saved** | ~60% saved |
|
|
721
795
|
| VS Code Copilot | Yes | [`copilot-instructions.md`](configs/vscode-copilot/copilot-instructions.md) | **~98% saved** | ~60% saved |
|
|
722
|
-
| Cursor | Yes |
|
|
796
|
+
| Cursor | Yes | [`context-mode.mdc`](configs/cursor/context-mode.mdc) | **~98% saved** | ~60% saved |
|
|
723
797
|
| OpenCode | Plugin | [`AGENTS.md`](configs/opencode/AGENTS.md) | **~98% saved** | ~60% saved |
|
|
724
798
|
| OpenClaw | Plugin | [`AGENTS.md`](configs/openclaw/AGENTS.md) | **~98% saved** | ~60% saved |
|
|
725
799
|
| Codex CLI | -- | [`AGENTS.md`](configs/codex/AGENTS.md) | -- | ~60% saved |
|