context-mode 1.0.41 → 1.0.43

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/README.md CHANGED
@@ -26,284 +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></summary>
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
- **Step 1 — Install the plugin:**
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
- **Step 2 Restart Claude Code.**
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
- That's it. The plugin installs everything automatically:
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
- - A `CLAUDE.md` routing instructions file auto-created in your project root
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, all three utility commands (`ctx stats`, `ctx doctor`, `ctx upgrade`) work as MCP tools just type the command name and the model will invoke it. See [Utility Commands](#utility-commands).
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
- **Alternative — MCP-only install** (no hooks or slash commands):
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 but 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.
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></summary>
77
+ <summary><strong>Gemini CLI</strong> — one config file, hooks included</summary>
68
78
 
69
- **Step 1 Install globally:**
79
+ **Prerequisites:** Node.js 18+, Gemini CLI installed.
70
80
 
71
- ```bash
72
- npm install -g context-mode
73
- ```
81
+ **Install:**
74
82
 
75
- **Step 2 Register the MCP server.** Add to `~/.gemini/settings.json`:
83
+ 1. Install context-mode globally:
76
84
 
77
- ```json
78
- {
79
- "mcpServers": {
80
- "context-mode": {
81
- "command": "context-mode"
82
- }
83
- }
84
- }
85
- ```
85
+ ```bash
86
+ npm install -g context-mode
87
+ ```
86
88
 
87
- **Step 3 — Add hooks.** Without hooks, the model can ignore routing instructions and dump raw output into your context window. Hooks intercept every tool call and enforce sandbox routing programmatically — blocking `curl`, `wget`, and other data-heavy commands before they execute. Add to the same `~/.gemini/settings.json`:
89
+ 2. Add the following to `~/.gemini/settings.json`. This single file registers the MCP server and all four hooks:
88
90
 
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
- ```
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:**
113
130
 
114
- **Step 4 — Restart Gemini CLI.** On first session start, the sessionstart hook automatically manages `GEMINI.md` routing instructions in your project root:
131
+ ```
132
+ /mcp list
133
+ ```
115
134
 
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).
135
+ You should see `context-mode: ... - Connected`.
119
136
 
120
- This works alongside hooks as a parallel enforcement layerhooks block dangerous commands programmatically, while `GEMINI.md` teaches the model to prefer sandbox tools from the start.
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.
121
138
 
122
- > **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.
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.
123
140
 
124
- Full hook config including PreCompress: [`configs/gemini-cli/settings.json`](configs/gemini-cli/settings.json)
141
+ Full config reference: [`configs/gemini-cli/settings.json`](configs/gemini-cli/settings.json)
125
142
 
126
143
  </details>
127
144
 
128
145
  <details>
129
- <summary><strong>VS Code Copilot</strong></summary>
146
+ <summary><strong>VS Code Copilot</strong> — hooks with SessionStart</summary>
130
147
 
131
- **Step 1 Install globally:**
148
+ **Prerequisites:** Node.js 18+, VS Code with Copilot Chat v0.32+.
132
149
 
133
- ```bash
134
- npm install -g context-mode
135
- ```
150
+ **Install:**
136
151
 
137
- **Step 2 — Register the MCP server.** Create `.vscode/mcp.json` in your project root:
152
+ 1. Install context-mode globally:
138
153
 
139
- ```json
140
- {
141
- "servers": {
142
- "context-mode": {
143
- "command": "context-mode"
144
- }
145
- }
146
- }
147
- ```
154
+ ```bash
155
+ npm install -g context-mode
156
+ ```
148
157
 
149
- **Step 3 — Add hooks.** Without hooks, the model can bypass routing and dump raw output into your context. Hooks intercept every tool call and enforce sandbox routing programmatically. Create `.github/hooks/context-mode.json`:
158
+ 2. Create `.vscode/mcp.json` in your project root:
150
159
 
151
- ```json
152
- {
153
- "hooks": {
154
- "PreToolUse": [
155
- { "type": "command", "command": "context-mode hook vscode-copilot pretooluse" }
156
- ],
157
- "PostToolUse": [
158
- { "type": "command", "command": "context-mode hook vscode-copilot posttooluse" }
159
- ],
160
- "SessionStart": [
161
- { "type": "command", "command": "context-mode hook vscode-copilot sessionstart" }
162
- ]
163
- }
164
- }
165
- ```
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`:
166
171
 
167
- **Step 4 — Restart VS Code.** On first session start, the sessionstart hook automatically manages `.github/copilot-instructions.md` routing instructions in your project:
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
+ ```
168
187
 
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).
188
+ 4. Restart VS Code.
172
189
 
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.
190
+ **Verify:** Open Copilot Chat and type `ctx stats`. Context-mode tools should appear and respond.
174
191
 
175
- > **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.
192
+ **Routing:** Automatic. The SessionStart hook injects routing instructions at runtime no `copilot-instructions.md` file is written to your project.
176
193
 
177
194
  Full hook config including PreCompact: [`configs/vscode-copilot/hooks.json`](configs/vscode-copilot/hooks.json)
178
195
 
179
196
  </details>
180
197
 
181
198
  <details>
182
- <summary><strong>Cursor</strong></summary>
199
+ <summary><strong>Cursor</strong> — hooks without SessionStart</summary>
183
200
 
184
- **Step 1 Install globally:**
201
+ **Prerequisites:** Node.js 18+, Cursor with agent mode.
185
202
 
186
- ```bash
187
- npm install -g context-mode
188
- ```
203
+ **Install:**
189
204
 
190
- **Step 2 — Register the MCP server.** Create `.cursor/mcp.json` in your project root or `~/.cursor/mcp.json` for a global install:
205
+ 1. Install context-mode globally:
191
206
 
192
- ```json
193
- {
194
- "mcpServers": {
195
- "context-mode": {
196
- "command": "context-mode"
197
- }
198
- }
199
- }
200
- ```
207
+ ```bash
208
+ npm install -g context-mode
209
+ ```
201
210
 
202
- **Step 3 — Add native Cursor hooks.** Cursor v1 support uses native `.cursor/hooks.json` or `~/.cursor/hooks.json` only. Create either path with:
211
+ 2. Create `.cursor/mcp.json` in your project root (or `~/.cursor/mcp.json` for global):
203
212
 
204
- ```json
205
- {
206
- "version": 1,
207
- "hooks": {
208
- "preToolUse": [
209
- {
210
- "command": "context-mode hook cursor pretooluse",
211
- "matcher": "Shell|Read|Grep|WebFetch|Task|MCP:ctx_execute|MCP:ctx_execute_file|MCP:ctx_batch_execute"
212
- }
213
- ],
214
- "postToolUse": [
215
- {
216
- "command": "context-mode hook cursor posttooluse"
217
- }
218
- ]
219
- }
220
- }
221
- ```
213
+ ```json
214
+ {
215
+ "mcpServers": {
216
+ "context-mode": {
217
+ "command": "context-mode"
218
+ }
219
+ }
220
+ }
221
+ ```
222
222
 
223
- Note: the `preToolUse` hook matcher is optional. If you don't provide it, the hook will fire on all tools.
223
+ 3. Create `.cursor/hooks.json` (or `~/.cursor/hooks.json` for global):
224
224
 
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).
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
+ ```
226
243
 
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.
228
- >
229
- > **Config precedence:** project `.cursor/hooks.json` overrides `~/.cursor/hooks.json`.
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`.
256
+
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`.
230
258
 
231
- Full native hook config: [`configs/cursor/hooks.json`](configs/cursor/hooks.json)
232
- Example MCP registration: [`configs/cursor/mcp.json`](configs/cursor/mcp.json)
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)
233
260
 
234
261
  </details>
235
262
 
236
263
  <details>
237
- <summary><strong>OpenCode</strong></summary>
264
+ <summary><strong>OpenCode</strong> — TypeScript plugin with hooks</summary>
238
265
 
239
- **Step 1 Install globally:**
266
+ **Prerequisites:** Node.js 18+, OpenCode installed.
240
267
 
241
- ```bash
242
- npm install -g context-mode
243
- ```
268
+ **Install:**
244
269
 
245
- **Step 2 — Register the MCP server and plugin.** OpenCode uses a TypeScript plugin paradigm instead of JSON hooks. Add both the MCP server and the plugin to `opencode.json` in your project root:
270
+ 1. Install context-mode globally:
246
271
 
247
- ```json
248
- {
249
- "$schema": "https://opencode.ai/config.json",
250
- "mcp": {
251
- "context-mode": {
252
- "type": "local",
253
- "command": ["context-mode"]
254
- }
255
- },
256
- "plugin": ["context-mode"]
257
- }
258
- ```
272
+ ```bash
273
+ npm install -g context-mode
274
+ ```
259
275
 
260
- 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.
276
+ 2. Add to `opencode.json` in your project root (or `~/.config/opencode/opencode.json` for global):
261
277
 
262
- **Step 3 — Restart OpenCode.** On first plugin init, the plugin automatically manages `AGENTS.md` routing instructions in your project root:
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
+ ```
263
290
 
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).
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.
267
292
 
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.
293
+ 3. Restart OpenCode.
269
294
 
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.
271
- >
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.
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)
273
302
 
274
303
  </details>
275
304
 
276
305
  <details>
277
- <summary><strong>OpenClaw / Pi Agent</strong></summary>
306
+ <summary><strong>OpenClaw / Pi Agent</strong> — native gateway plugin</summary>
278
307
 
279
308
  **Prerequisites:** OpenClaw gateway running ([>2026.1.29](https://github.com/openclaw/openclaw/pull/9761)), Node.js 22+.
280
309
 
281
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).
282
311
 
283
- **Step 1 — Clone and install:**
312
+ **Install:**
284
313
 
285
- ```bash
286
- git clone https://github.com/mksglu/context-mode.git
287
- cd context-mode
288
- npm run install:openclaw
289
- ```
314
+ 1. Clone and install:
290
315
 
291
- The installer uses `$OPENCLAW_STATE_DIR` from your environment (default: `/openclaw`). To specify a custom path:
316
+ ```bash
317
+ git clone https://github.com/mksglu/context-mode.git
318
+ cd context-mode
319
+ npm run install:openclaw
320
+ ```
292
321
 
293
- ```bash
294
- npm run install:openclaw -- /path/to/openclaw-state
295
- ```
322
+ The installer uses `$OPENCLAW_STATE_DIR` from your environment (default: `/openclaw`). To specify a custom path:
296
323
 
297
- Common locations:
298
- - **Docker:** `/openclaw` (the default)
299
- - **Local:** `~/.openclaw` or wherever you set `OPENCLAW_STATE_DIR`
324
+ ```bash
325
+ npm run install:openclaw -- /path/to/openclaw-state
326
+ ```
300
327
 
301
- The installer handles everything: `npm install`, `npm run build`, `better-sqlite3` native rebuild, extension registration in `runtime.json`, and gateway restart via SIGUSR1.
328
+ Common locations: **Docker** `/openclaw` (the default). **Local** `~/.openclaw` or wherever you set `OPENCLAW_STATE_DIR`.
302
329
 
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.
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.
304
337
 
305
- > **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
- >
307
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).
308
339
 
309
340
  Full documentation: [`docs/adapters/openclaw.md`](docs/adapters/openclaw.md)
@@ -311,173 +342,216 @@ Full documentation: [`docs/adapters/openclaw.md`](docs/adapters/openclaw.md)
311
342
  </details>
312
343
 
313
344
  <details>
314
- <summary><strong>Codex CLI</strong></summary>
345
+ <summary><strong>Codex CLI</strong> — MCP-only, no hooks</summary>
315
346
 
316
- **Step 1 Install globally:**
347
+ **Prerequisites:** Node.js 18+, Codex CLI installed.
317
348
 
318
- ```bash
319
- npm install -g context-mode
320
- ```
349
+ **Install:**
321
350
 
322
- **Step 2 Register the MCP server.** Add to `~/.codex/config.toml`:
351
+ 1. Install context-mode globally:
323
352
 
324
- ```toml
325
- [mcp_servers.context-mode]
326
- command = "context-mode"
327
- ```
353
+ ```bash
354
+ npm install -g context-mode
355
+ ```
328
356
 
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.
357
+ 2. Add to `~/.codex/config.toml`:
330
358
 
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.
359
+ ```toml
360
+ [mcp_servers.context-mode]
361
+ command = "context-mode"
362
+ ```
332
363
 
333
- For stronger enforcement, you can also add the instructions globally:
364
+ 3. Copy routing instructions (Codex CLI has no hook support):
334
365
 
335
- ```bash
336
- cp ~/.codex/AGENTS.md # auto-created, or copy from node_modules/context-mode/configs/codex/AGENTS.md
337
- ```
366
+ ```bash
367
+ cp node_modules/context-mode/configs/codex/AGENTS.md ./AGENTS.md
368
+ ```
369
+
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.
371
+
372
+ 4. Restart Codex CLI.
373
+
374
+ **Verify:** Start a session and type `ctx stats`. Context-mode tools should appear and respond.
338
375
 
339
- 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.
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.
340
377
 
341
378
  </details>
342
379
 
343
380
  <details>
344
- <summary><strong>Antigravity</strong></summary>
381
+ <summary><strong>Antigravity</strong> — MCP-only, no hooks</summary>
345
382
 
346
- **Step 1 Install globally:**
383
+ **Prerequisites:** Node.js 18+, Antigravity installed.
347
384
 
348
- ```bash
349
- npm install -g context-mode
350
- ```
385
+ **Install:**
351
386
 
352
- **Step 2 Register the MCP server.** Add to `~/.gemini/antigravity/mcp_config.json`:
387
+ 1. Install context-mode globally:
353
388
 
354
- ```json
355
- {
356
- "mcpServers": {
357
- "context-mode": {
358
- "command": "context-mode"
359
- }
360
- }
361
- }
362
- ```
389
+ ```bash
390
+ npm install -g context-mode
391
+ ```
392
+
393
+ 2. Add to `~/.gemini/antigravity/mcp_config.json`:
394
+
395
+ ```json
396
+ {
397
+ "mcpServers": {
398
+ "context-mode": {
399
+ "command": "context-mode"
400
+ }
401
+ }
402
+ }
403
+ ```
363
404
 
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.
405
+ 3. Copy routing instructions (Antigravity has no hook support):
365
406
 
366
- **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.
407
+ ```bash
408
+ cp node_modules/context-mode/configs/antigravity/GEMINI.md ./GEMINI.md
409
+ ```
367
410
 
368
- **Auto-detection:** context-mode detects Antigravity automatically via the MCP protocol handshake (`clientInfo.name`). No environment variables or manual platform configuration needed.
411
+ 4. Restart Antigravity.
369
412
 
370
- Example MCP config: [`configs/antigravity/mcp_config.json`](configs/antigravity/mcp_config.json)
371
- Routing rules: [`configs/antigravity/GEMINI.md`](configs/antigravity/GEMINI.md)
413
+ **Verify:** In an Antigravity session, type `ctx stats`. Context-mode tools should appear and respond.
414
+
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)
372
418
 
373
419
  </details>
374
420
 
375
421
  <details>
376
- <summary><strong>Kiro</strong></summary>
422
+ <summary><strong>Kiro</strong> — hooks with steering file</summary>
377
423
 
378
- **Step 1 Install globally:**
424
+ **Prerequisites:** Node.js 18+, Kiro with MCP enabled (Settings > search "MCP").
379
425
 
380
- ```bash
381
- npm install -g context-mode
382
- ```
426
+ **Install:**
383
427
 
384
- **Step 2 — Register the MCP server.** Add to `.kiro/settings/mcp.json` in your project root (or `~/.kiro/settings/mcp.json` for global):
428
+ 1. Install context-mode globally:
385
429
 
386
- ```json
387
- {
388
- "mcpServers": {
389
- "context-mode": {
390
- "command": "context-mode"
391
- }
392
- }
393
- }
394
- ```
430
+ ```bash
431
+ npm install -g context-mode
432
+ ```
395
433
 
396
- **Step 3 — Add hooks.** Without hooks, the model can bypass routing and dump raw output into your context. Hooks intercept every tool call and enforce sandbox routing programmatically. Create `.kiro/hooks/context-mode.json` (or copy from [`configs/kiro/agent.json`](configs/kiro/agent.json)):
434
+ 2. Add to `.kiro/settings/mcp.json` in your project (or `~/.kiro/settings/mcp.json` for global):
397
435
 
398
- ```json
399
- {
400
- "name": "context-mode",
401
- "description": "Context-mode hooks for context window protection",
402
- "hooks": {
403
- "preToolUse": [
404
- { "matcher": "*", "command": "context-mode hook kiro pretooluse" }
405
- ],
406
- "postToolUse": [
407
- { "matcher": "*", "command": "context-mode hook kiro posttooluse" }
408
- ]
409
- }
410
- }
411
- ```
436
+ ```json
437
+ {
438
+ "mcpServers": {
439
+ "context-mode": {
440
+ "command": "context-mode"
441
+ }
442
+ }
443
+ }
444
+ ```
445
+
446
+ 3. Create `.kiro/hooks/context-mode.json`:
447
+
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
+ ```
412
462
 
413
- **Step 4 Restart Kiro.** On first session start, the pretooluse hook automatically manages `KIRO.md` routing instructions in your project root:
463
+ 4. Copy routing instructions. Kiro's `agentSpawn` (SessionStart) is not yet implemented, so the model needs a routing file at session start:
414
464
 
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).
465
+ ```bash
466
+ cp node_modules/context-mode/configs/kiro/KIRO.md ./KIRO.md
467
+ ```
418
468
 
419
- **Auto-detection:** context-mode detects Kiro automatically via the MCP protocol handshake (`clientInfo.name`). No environment variables or manual platform configuration needed.
469
+ 5. Restart Kiro.
470
+
471
+ **Verify:** Open the Kiro panel > MCP Servers tab and confirm "context-mode" shows a green status indicator. In chat, type `ctx stats`.
472
+
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)
420
476
 
421
477
  </details>
422
478
 
423
479
  <details>
424
- <summary><strong>Zed</strong></summary>
480
+ <summary><strong>Zed</strong> — MCP-only, no hooks</summary>
425
481
 
426
- **Step 1 Install globally:**
482
+ **Prerequisites:** Node.js 18+, Zed installed.
427
483
 
428
- ```bash
429
- npm install -g context-mode
430
- ```
484
+ **Install:**
431
485
 
432
- **Step 2 Add to Zed settings** (`~/.config/zed/settings.json`):
486
+ 1. Install context-mode globally:
433
487
 
434
- ```json
435
- {
436
- "context_servers": {
437
- "context-mode": {
438
- "command": {
439
- "path": "context-mode"
440
- }
441
- }
442
- }
443
- }
444
- ```
488
+ ```bash
489
+ npm install -g context-mode
490
+ ```
491
+
492
+ 2. Add to `~/.config/zed/settings.json` (Windows: `%APPDATA%\Zed\settings.json`):
493
+
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.
445
507
 
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.
508
+ 3. Copy routing instructions (Zed has no hook support):
447
509
 
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.
510
+ ```bash
511
+ cp node_modules/context-mode/configs/zed/AGENTS.md ./AGENTS.md
512
+ ```
449
513
 
450
- **Auto-detection:** context-mode detects Zed automatically via the MCP protocol handshake (`clientInfo.name`). No environment variables or manual platform configuration needed.
514
+ 4. Restart Zed (or save `settings.json` Zed auto-restarts context servers on config change).
515
+
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></summary>
523
+ <summary><strong>Pi Coding Agent</strong> — extension with full hook support</summary>
456
524
 
457
- **Step 1 Install the extension:**
525
+ **Prerequisites:** Node.js 18+, Pi Coding Agent installed.
458
526
 
459
- ```bash
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
- **Step 2 Add MCP server** to `~/.pi/settings/mcp.json` or `.pi/settings/mcp.json`:
529
+ 1. Clone the extension:
466
530
 
467
- ```json
468
- {
469
- "mcpServers": {
470
- "context-mode": {
471
- "command": "node",
472
- "args": ["~/.pi/extensions/context-mode/node_modules/context-mode/start.mjs"]
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):
477
538
 
478
- **Step 3 — Restart Pi.**
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
+ ```
479
549
 
480
- The extension handles session continuity (event capture, resume snapshots, compaction recovery). The MCP server provides sandbox tools (batch_execute, execute, search, etc.).
550
+ 3. Restart Pi.
551
+
552
+ **Verify:** In a Pi session, type `ctx stats`. Context-mode tools should appear and respond.
553
+
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
 
@@ -667,19 +741,19 @@ Detailed event data is also indexed into FTS5 for on-demand retrieval via `searc
667
741
 
668
742
  **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
743
 
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.
744
+ **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
745
 
672
746
  **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
747
 
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.
748
+ **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
749
 
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`).
750
+ **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
751
 
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`).
752
+ **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
753
 
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`).
754
+ **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
755
 
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.
756
+ **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
757
 
684
758
  </details>
685
759
 
@@ -702,11 +776,9 @@ Detailed event data is also indexed into FTS5 for on-demand retrieval via `searc
702
776
  >
703
777
  > **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
778
  >
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.
779
+ > **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.
706
780
  >
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`).
708
- >
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.
781
+ > **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
782
  >
711
783
  > **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
784
 
@@ -714,12 +786,14 @@ Detailed event data is also indexed into FTS5 for on-demand retrieval via `searc
714
786
 
715
787
  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
788
 
789
+ > **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.
790
+
717
791
  | Platform | Hooks | Instruction File | With Hooks | Without Hooks |
718
792
  |---|:---:|---|:---:|:---:|
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 | -- | **~98% saved** | Manual tool choice |
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 |