context-mode 1.0.22 → 1.0.23
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 +4 -2
- package/.openclaw-plugin/index.ts +11 -0
- package/.openclaw-plugin/openclaw.plugin.json +23 -0
- package/.openclaw-plugin/package.json +28 -0
- package/README.md +165 -26
- package/build/adapters/antigravity/index.d.ts +49 -0
- package/build/adapters/antigravity/index.js +217 -0
- package/build/adapters/client-map.d.ts +10 -0
- package/build/adapters/client-map.js +18 -0
- package/build/adapters/detect.d.ts +8 -1
- package/build/adapters/detect.js +58 -1
- package/build/adapters/kiro/hooks.d.ts +32 -0
- package/build/adapters/kiro/hooks.js +47 -0
- package/build/adapters/kiro/index.d.ts +50 -0
- package/build/adapters/kiro/index.js +325 -0
- package/build/adapters/openclaw/config.d.ts +8 -0
- package/build/adapters/openclaw/config.js +8 -0
- package/build/adapters/openclaw/hooks.d.ts +50 -0
- package/build/adapters/openclaw/hooks.js +61 -0
- package/build/adapters/openclaw/index.d.ts +51 -0
- package/build/adapters/openclaw/index.js +459 -0
- package/build/adapters/openclaw/session-db.d.ts +55 -0
- package/build/adapters/openclaw/session-db.js +88 -0
- package/build/adapters/types.d.ts +1 -1
- package/build/cli.js +5 -3
- package/build/executor.js +99 -112
- package/build/openclaw/workspace-router.d.ts +29 -0
- package/build/openclaw/workspace-router.js +64 -0
- package/build/openclaw-plugin.d.ts +121 -0
- package/build/openclaw-plugin.js +525 -0
- package/build/server.js +45 -10
- package/build/session/db.d.ts +9 -0
- package/build/session/db.js +38 -0
- package/cli.bundle.mjs +135 -124
- package/configs/antigravity/GEMINI.md +58 -0
- package/configs/antigravity/mcp_config.json +7 -0
- package/configs/kiro/mcp_config.json +7 -0
- package/configs/openclaw/AGENTS.md +58 -0
- package/configs/openclaw/openclaw.json +13 -0
- package/hooks/core/routing.mjs +12 -7
- package/hooks/kiro/posttooluse.mjs +58 -0
- package/hooks/kiro/pretooluse.mjs +63 -0
- package/hooks/session-db.bundle.mjs +2 -2
- package/hooks/session-helpers.mjs +41 -3
- package/openclaw.plugin.json +23 -0
- package/package.json +12 -1
- package/server.bundle.mjs +93 -82
- package/start.mjs +1 -0
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
},
|
|
7
7
|
"metadata": {
|
|
8
8
|
"description": "Claude Code plugins by Mert Koseoğlu",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.23"
|
|
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.
|
|
16
|
+
"version": "1.0.23",
|
|
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.
|
|
3
|
+
"version": "1.0.23",
|
|
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",
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
"mcpServers": {
|
|
23
23
|
"context-mode": {
|
|
24
24
|
"command": "node",
|
|
25
|
-
"args": [
|
|
25
|
+
"args": [
|
|
26
|
+
"${CLAUDE_PLUGIN_ROOT}/start.mjs"
|
|
27
|
+
]
|
|
26
28
|
}
|
|
27
29
|
},
|
|
28
30
|
"skills": "./skills/"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenClaw plugin entry point for context-mode.
|
|
3
|
+
*
|
|
4
|
+
* This thin wrapper delegates to the compiled plugin logic.
|
|
5
|
+
* OpenClaw loads this file via jiti (TypeScript runtime) when
|
|
6
|
+
* discovering plugins from the .openclaw-plugin/ directory.
|
|
7
|
+
*
|
|
8
|
+
* The actual plugin definition (object form with id, name, configSchema,
|
|
9
|
+
* register) lives in src/openclaw-plugin.ts, compiled to build/openclaw-plugin.js.
|
|
10
|
+
*/
|
|
11
|
+
export { default } from "../build/openclaw-plugin.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "context-mode",
|
|
3
|
+
"name": "Context Mode",
|
|
4
|
+
"kind": "tool",
|
|
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.23",
|
|
7
|
+
"sandbox": {
|
|
8
|
+
"mode": "permissive",
|
|
9
|
+
"filesystem_access": "full",
|
|
10
|
+
"system_access": "full"
|
|
11
|
+
},
|
|
12
|
+
"configSchema": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"properties": {
|
|
15
|
+
"enabled": {
|
|
16
|
+
"type": "boolean",
|
|
17
|
+
"default": true,
|
|
18
|
+
"description": "Enable or disable the context-mode plugin."
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"additionalProperties": false
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "context-mode",
|
|
3
|
+
"version": "1.0.23",
|
|
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
|
+
"author": {
|
|
6
|
+
"name": "Mert Koseoğlu",
|
|
7
|
+
"url": "https://github.com/mksglu"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/mksglu/context-mode#readme",
|
|
10
|
+
"repository": "https://github.com/mksglu/context-mode",
|
|
11
|
+
"license": "Elastic-2.0",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"openclaw",
|
|
14
|
+
"mcp",
|
|
15
|
+
"context-window",
|
|
16
|
+
"sandbox",
|
|
17
|
+
"code-execution",
|
|
18
|
+
"fts5",
|
|
19
|
+
"bm25",
|
|
20
|
+
"playwright",
|
|
21
|
+
"context7"
|
|
22
|
+
],
|
|
23
|
+
"openclaw": {
|
|
24
|
+
"extensions": [
|
|
25
|
+
"./index.ts"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
}
|
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ This gives you the 6 sandbox tools but without automatic routing. The model can
|
|
|
56
56
|
</details>
|
|
57
57
|
|
|
58
58
|
<details>
|
|
59
|
-
<summary><strong>Gemini CLI</strong
|
|
59
|
+
<summary><strong>Gemini CLI</strong></summary>
|
|
60
60
|
|
|
61
61
|
**Step 1 — Install globally:**
|
|
62
62
|
|
|
@@ -118,7 +118,7 @@ Full hook config including PreCompress: [`configs/gemini-cli/settings.json`](con
|
|
|
118
118
|
</details>
|
|
119
119
|
|
|
120
120
|
<details>
|
|
121
|
-
<summary><strong>VS Code Copilot</strong
|
|
121
|
+
<summary><strong>VS Code Copilot</strong></summary>
|
|
122
122
|
|
|
123
123
|
**Step 1 — Install globally:**
|
|
124
124
|
|
|
@@ -171,7 +171,7 @@ Full hook config including PreCompact: [`configs/vscode-copilot/hooks.json`](con
|
|
|
171
171
|
</details>
|
|
172
172
|
|
|
173
173
|
<details>
|
|
174
|
-
<summary><strong>Cursor</strong
|
|
174
|
+
<summary><strong>Cursor</strong></summary>
|
|
175
175
|
|
|
176
176
|
**Step 1 — Install globally:**
|
|
177
177
|
|
|
@@ -226,7 +226,7 @@ Example MCP registration: [`configs/cursor/mcp.json`](configs/cursor/mcp.json)
|
|
|
226
226
|
</details>
|
|
227
227
|
|
|
228
228
|
<details>
|
|
229
|
-
<summary><strong>OpenCode</strong
|
|
229
|
+
<summary><strong>OpenCode</strong></summary>
|
|
230
230
|
|
|
231
231
|
**Step 1 — Install globally:**
|
|
232
232
|
|
|
@@ -266,7 +266,38 @@ This works alongside the plugin as a parallel enforcement layer — the plugin i
|
|
|
266
266
|
</details>
|
|
267
267
|
|
|
268
268
|
<details>
|
|
269
|
-
<summary><strong>
|
|
269
|
+
<summary><strong>OpenClaw / Pi Agent</strong></summary>
|
|
270
|
+
|
|
271
|
+
**Prerequisites:** OpenClaw gateway running ([>2026.1.29](https://github.com/openclaw/openclaw/pull/9761)), Node.js 22+.
|
|
272
|
+
|
|
273
|
+
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).
|
|
274
|
+
|
|
275
|
+
**Step 1 — Clone and install:**
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
git clone https://github.com/mksglu/context-mode.git
|
|
279
|
+
cd context-mode
|
|
280
|
+
scripts/install-openclaw-plugin.sh /path/to/openclaw-state
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Replace `/path/to/openclaw-state` with your `OPENCLAW_STATE_DIR` — the directory containing `runtime/openclaw.runtime.json`. Common locations:
|
|
284
|
+
- **Docker:** `/openclaw` (the installer default)
|
|
285
|
+
- **Local:** `~/.openclaw` or wherever you set `OPENCLAW_STATE_DIR`
|
|
286
|
+
|
|
287
|
+
The installer handles everything: `npm install`, `npm run build`, `better-sqlite3` native rebuild, extension registration in `runtime.json`, and gateway restart via SIGUSR1.
|
|
288
|
+
|
|
289
|
+
**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.
|
|
290
|
+
|
|
291
|
+
> **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.
|
|
292
|
+
>
|
|
293
|
+
> **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).
|
|
294
|
+
|
|
295
|
+
Full documentation: [`docs/adapters/openclaw.md`](docs/adapters/openclaw.md)
|
|
296
|
+
|
|
297
|
+
</details>
|
|
298
|
+
|
|
299
|
+
<details>
|
|
300
|
+
<summary><strong>Codex CLI</strong></summary>
|
|
270
301
|
|
|
271
302
|
**Step 1 — Install globally:**
|
|
272
303
|
|
|
@@ -295,6 +326,101 @@ Global `~/.codex/AGENTS.md` applies to all projects. Project-level `./AGENTS.md`
|
|
|
295
326
|
|
|
296
327
|
</details>
|
|
297
328
|
|
|
329
|
+
<details>
|
|
330
|
+
<summary><strong>Antigravity</strong></summary>
|
|
331
|
+
|
|
332
|
+
**Step 1 — Install globally:**
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
npm install -g context-mode
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
**Step 2 — Register the MCP server.** Add to `~/.gemini/antigravity/mcp_config.json`:
|
|
339
|
+
|
|
340
|
+
```json
|
|
341
|
+
{
|
|
342
|
+
"mcpServers": {
|
|
343
|
+
"context-mode": {
|
|
344
|
+
"command": "context-mode"
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
**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.
|
|
351
|
+
|
|
352
|
+
**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.
|
|
353
|
+
|
|
354
|
+
**Auto-detection:** context-mode detects Antigravity automatically via the MCP protocol handshake (`clientInfo.name`). No environment variables or manual platform configuration needed.
|
|
355
|
+
|
|
356
|
+
Example MCP config: [`configs/antigravity/mcp_config.json`](configs/antigravity/mcp_config.json)
|
|
357
|
+
Routing rules: [`configs/antigravity/GEMINI.md`](configs/antigravity/GEMINI.md)
|
|
358
|
+
|
|
359
|
+
</details>
|
|
360
|
+
|
|
361
|
+
<details>
|
|
362
|
+
<summary><strong>Kiro</strong></summary>
|
|
363
|
+
|
|
364
|
+
**Step 1 — Install globally:**
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
npm install -g context-mode
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
**Step 2 — Register the MCP server.** Add to `.kiro/settings/mcp.json` in your project root (or `~/.kiro/settings/mcp.json` for global):
|
|
371
|
+
|
|
372
|
+
```json
|
|
373
|
+
{
|
|
374
|
+
"mcpServers": {
|
|
375
|
+
"context-mode": {
|
|
376
|
+
"command": "context-mode"
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
**Step 3 — Restart Kiro.** On first MCP server startup, a `KIRO.md` routing instructions file is auto-created in your project root. Kiro reads `KIRO.md` automatically and learns to prefer context-mode sandbox tools.
|
|
383
|
+
|
|
384
|
+
**About hooks:** Kiro hook-based session continuity will be added once Kiro CLI hooks are fully tested. The `KIRO.md` routing instructions file is the current enforcement method (~60% compliance).
|
|
385
|
+
|
|
386
|
+
**Auto-detection:** context-mode detects Kiro automatically via the MCP protocol handshake (`clientInfo.name`). No environment variables or manual platform configuration needed.
|
|
387
|
+
|
|
388
|
+
</details>
|
|
389
|
+
|
|
390
|
+
<details>
|
|
391
|
+
<summary><strong>Build Prerequisites</strong> <sup>(CentOS, RHEL, Alpine)</sup></summary>
|
|
392
|
+
|
|
393
|
+
Context Mode uses [better-sqlite3](https://github.com/WiseLibs/better-sqlite3), which ships prebuilt native binaries for most platforms. On glibc >= 2.31 systems (Ubuntu 20.04+, Debian 11+, Fedora 34+, macOS, Windows), `npm install` works without any build tools.
|
|
394
|
+
|
|
395
|
+
On older glibc systems (CentOS 7/8, RHEL 8, Debian 10), prebuilt binaries don't load and better-sqlite3 **automatically falls back to compiling from source** via `prebuild-install || node-gyp rebuild --release`. This requires a C++20 compiler (GCC 10+), Make, and Python with setuptools.
|
|
396
|
+
|
|
397
|
+
**CentOS 8 / RHEL 8** (glibc 2.28):
|
|
398
|
+
|
|
399
|
+
```bash
|
|
400
|
+
dnf install -y gcc-toolset-10-gcc gcc-toolset-10-gcc-c++ make python3 python3-setuptools
|
|
401
|
+
scl enable gcc-toolset-10 'npm install -g context-mode'
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
**CentOS 7 / RHEL 7** (glibc 2.17):
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
yum install -y centos-release-scl
|
|
408
|
+
yum install -y devtoolset-10-gcc devtoolset-10-gcc-c++ make python3
|
|
409
|
+
pip3 install setuptools
|
|
410
|
+
scl enable devtoolset-10 'npm install -g context-mode'
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
**Alpine Linux:**
|
|
414
|
+
|
|
415
|
+
Alpine prebuilt binaries (musl) are available in better-sqlite3 v12.8.0+. With the `^12.6.2` dependency range, `npm install` resolves to the latest 12.x and works without build tools on Alpine. If you pin an older version:
|
|
416
|
+
|
|
417
|
+
```bash
|
|
418
|
+
apk add build-base python3 py3-setuptools
|
|
419
|
+
npm install -g context-mode
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
</details>
|
|
423
|
+
|
|
298
424
|
## Tools
|
|
299
425
|
|
|
300
426
|
| Tool | What it does | Context saved |
|
|
@@ -351,15 +477,15 @@ Context Mode captures every meaningful event during your session and persists th
|
|
|
351
477
|
|
|
352
478
|
Session continuity requires 4 hooks working together:
|
|
353
479
|
|
|
354
|
-
| Hook | Role | Claude Code | Gemini CLI | VS Code Copilot | Cursor | OpenCode | Codex CLI |
|
|
355
|
-
|
|
356
|
-
| **PostToolUse** | Captures events after each tool call | Yes | Yes | Yes | Yes | Plugin | -- |
|
|
357
|
-
| **UserPromptSubmit** | Captures user decisions and corrections | Yes | -- | -- | -- | -- | -- |
|
|
358
|
-
| **PreCompact** | Builds snapshot before compaction | Yes | Yes | Yes | -- | Plugin | -- |
|
|
359
|
-
| **SessionStart** | Restores state after compaction or resume | Yes | Yes | Yes | -- | -- | -- |
|
|
360
|
-
| | **Session completeness** | **Full** | **High** | **High** | **Partial** | **High** | **--** |
|
|
480
|
+
| Hook | Role | Claude Code | Gemini CLI | VS Code Copilot | Cursor | OpenCode | OpenClaw | Codex CLI | Antigravity | Kiro |
|
|
481
|
+
|---|---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
|
|
482
|
+
| **PostToolUse** | Captures events after each tool call | Yes | Yes | Yes | Yes | Plugin | Plugin | -- | -- | -- |
|
|
483
|
+
| **UserPromptSubmit** | Captures user decisions and corrections | Yes | -- | -- | -- | -- | -- | -- | -- | -- |
|
|
484
|
+
| **PreCompact** | Builds snapshot before compaction | Yes | Yes | Yes | -- | Plugin | Plugin | -- | -- | -- |
|
|
485
|
+
| **SessionStart** | Restores state after compaction or resume | Yes | Yes | Yes | -- | -- | Plugin | -- | -- | -- |
|
|
486
|
+
| | **Session completeness** | **Full** | **High** | **High** | **Partial** | **High** | **High** | **--** | **--** | **--** |
|
|
361
487
|
|
|
362
|
-
> **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. Codex CLI
|
|
488
|
+
> **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. **Codex CLI**, **Antigravity**, and **Kiro** have no hook support in the current release, so session tracking is not available.
|
|
363
489
|
|
|
364
490
|
<details>
|
|
365
491
|
<summary><strong>What gets captured</strong></summary>
|
|
@@ -438,28 +564,38 @@ Detailed event data is also indexed into FTS5 for on-demand retrieval via `searc
|
|
|
438
564
|
|
|
439
565
|
**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.
|
|
440
566
|
|
|
567
|
+
**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).
|
|
568
|
+
|
|
441
569
|
**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.
|
|
442
570
|
|
|
571
|
+
**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`).
|
|
572
|
+
|
|
573
|
+
**Kiro** — No session support in the current release. MCP-only. The `KIRO.md` routing instructions file is auto-written on first MCP server startup. Hook-based session continuity will be added once Kiro CLI hooks are fully tested. Auto-detected via MCP protocol handshake (`clientInfo.name`).
|
|
574
|
+
|
|
443
575
|
</details>
|
|
444
576
|
|
|
445
577
|
## Platform Compatibility
|
|
446
578
|
|
|
447
|
-
| Feature | Claude Code | Gemini CLI
|
|
448
|
-
|
|
449
|
-
| MCP Server | Yes | Yes | Yes | Yes | Yes | Yes |
|
|
450
|
-
| PreToolUse Hook | Yes | Yes | Yes | Yes | Plugin | -- |
|
|
451
|
-
| PostToolUse Hook | Yes | Yes | Yes | Yes | Plugin | -- |
|
|
452
|
-
| SessionStart Hook | Yes | Yes | Yes | -- | -- | -- |
|
|
453
|
-
| PreCompact Hook | Yes | Yes | Yes | -- | Plugin | -- |
|
|
454
|
-
| Can Modify Args | Yes | Yes | Yes | Yes | Plugin | -- |
|
|
455
|
-
| Can Block Tools | Yes | Yes | Yes | Yes | Plugin | -- |
|
|
456
|
-
| Utility Commands (ctx) | Yes | Yes | Yes | Yes | Yes | Yes |
|
|
457
|
-
| Slash Commands | Yes | -- | -- | -- | -- | -- |
|
|
458
|
-
| Plugin Marketplace | Yes | -- | -- | -- | -- | -- |
|
|
579
|
+
| Feature | Claude Code | Gemini CLI | VS Code Copilot | Cursor | OpenCode | OpenClaw | Codex CLI | Antigravity | Kiro |
|
|
580
|
+
|---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
|
|
581
|
+
| MCP Server | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
|
|
582
|
+
| PreToolUse Hook | Yes | Yes | Yes | Yes | Plugin | Plugin | -- | -- | -- |
|
|
583
|
+
| PostToolUse Hook | Yes | Yes | Yes | Yes | Plugin | Plugin | -- | -- | -- |
|
|
584
|
+
| SessionStart Hook | Yes | Yes | Yes | -- | -- | Plugin | -- | -- | -- |
|
|
585
|
+
| PreCompact Hook | Yes | Yes | Yes | -- | Plugin | Plugin | -- | -- | -- |
|
|
586
|
+
| Can Modify Args | Yes | Yes | Yes | Yes | Plugin | Plugin | -- | -- | -- |
|
|
587
|
+
| Can Block Tools | Yes | Yes | Yes | Yes | Plugin | Plugin | -- | -- | -- |
|
|
588
|
+
| Utility Commands (ctx) | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
|
|
589
|
+
| Slash Commands | Yes | -- | -- | -- | -- | -- | -- | -- | -- |
|
|
590
|
+
| Plugin Marketplace | Yes | -- | -- | -- | -- | -- | -- | -- | -- |
|
|
459
591
|
|
|
460
592
|
> **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.
|
|
461
593
|
>
|
|
462
|
-
> **
|
|
594
|
+
> **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).
|
|
595
|
+
>
|
|
596
|
+
> **Codex CLI** and **Antigravity** do not support hooks. They rely solely on routing instruction files (`AGENTS.md` / `GEMINI.md`) for enforcement (~60% compliance). Antigravity is auto-detected via MCP protocol handshake — no manual platform configuration needed.
|
|
597
|
+
>
|
|
598
|
+
> **Kiro** is MCP-only in the current release. Hook-based enforcement will be added once Kiro CLI hooks are fully tested. Kiro is auto-detected via MCP protocol handshake (`clientInfo.name`).
|
|
463
599
|
|
|
464
600
|
### Routing Enforcement
|
|
465
601
|
|
|
@@ -472,7 +608,10 @@ Hooks intercept tool calls programmatically — they can block dangerous command
|
|
|
472
608
|
| VS Code Copilot | Yes | [`copilot-instructions.md`](configs/vscode-copilot/copilot-instructions.md) | **~98% saved** | ~60% saved |
|
|
473
609
|
| Cursor | Yes | -- | **~98% saved** | Manual tool choice |
|
|
474
610
|
| OpenCode | Plugin | [`AGENTS.md`](configs/opencode/AGENTS.md) | **~98% saved** | ~60% saved |
|
|
611
|
+
| OpenClaw | Plugin | [`AGENTS.md`](configs/openclaw/AGENTS.md) | **~98% saved** | ~60% saved |
|
|
475
612
|
| Codex CLI | -- | [`AGENTS.md`](configs/codex/AGENTS.md) | -- | ~60% saved |
|
|
613
|
+
| Antigravity | -- | [`GEMINI.md`](configs/antigravity/GEMINI.md) | -- | ~60% saved |
|
|
614
|
+
| Kiro | -- | [`KIRO.md`](configs/kiro/KIRO.md) | -- | ~60% saved |
|
|
476
615
|
|
|
477
616
|
Without hooks, one unrouted `curl` or Playwright snapshot can dump 56 KB into context — wiping out an entire session's worth of savings.
|
|
478
617
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* adapters/antigravity — Google Antigravity platform adapter.
|
|
3
|
+
*
|
|
4
|
+
* Implements HookAdapter for Antigravity's MCP-only paradigm.
|
|
5
|
+
*
|
|
6
|
+
* Antigravity hook specifics:
|
|
7
|
+
* - NO hook support (MCP-only, same as Codex CLI)
|
|
8
|
+
* - Config: ~/.gemini/antigravity/mcp_config.json (JSON format)
|
|
9
|
+
* - MCP: full support via mcpServers in mcp_config.json
|
|
10
|
+
* - All capabilities are false — MCP is the only integration path
|
|
11
|
+
* - Session dir: ~/.gemini/context-mode/sessions/
|
|
12
|
+
* - Routing file: GEMINI.md (shared with Gemini CLI filename, different content)
|
|
13
|
+
*
|
|
14
|
+
* Sources:
|
|
15
|
+
* - Config path: https://github.com/google-gemini/gemini-cli/issues/16058
|
|
16
|
+
* - MCP support: https://antigravity.google/docs/mcp
|
|
17
|
+
* - Tool list: System prompt leak (21 verified tools)
|
|
18
|
+
*/
|
|
19
|
+
import type { HookAdapter, HookParadigm, PlatformCapabilities, DiagnosticResult, PreToolUseEvent, PostToolUseEvent, PreCompactEvent, SessionStartEvent, PreToolUseResponse, PostToolUseResponse, PreCompactResponse, SessionStartResponse, HookRegistration, RoutingInstructionsConfig } from "../types.js";
|
|
20
|
+
export declare class AntigravityAdapter implements HookAdapter {
|
|
21
|
+
readonly name = "Antigravity";
|
|
22
|
+
readonly paradigm: HookParadigm;
|
|
23
|
+
readonly capabilities: PlatformCapabilities;
|
|
24
|
+
parsePreToolUseInput(_raw: unknown): PreToolUseEvent;
|
|
25
|
+
parsePostToolUseInput(_raw: unknown): PostToolUseEvent;
|
|
26
|
+
parsePreCompactInput(_raw: unknown): PreCompactEvent;
|
|
27
|
+
parseSessionStartInput(_raw: unknown): SessionStartEvent;
|
|
28
|
+
formatPreToolUseResponse(_response: PreToolUseResponse): unknown;
|
|
29
|
+
formatPostToolUseResponse(_response: PostToolUseResponse): unknown;
|
|
30
|
+
formatPreCompactResponse(_response: PreCompactResponse): unknown;
|
|
31
|
+
formatSessionStartResponse(_response: SessionStartResponse): unknown;
|
|
32
|
+
getSettingsPath(): string;
|
|
33
|
+
getSessionDir(): string;
|
|
34
|
+
getSessionDBPath(projectDir: string): string;
|
|
35
|
+
getSessionEventsPath(projectDir: string): string;
|
|
36
|
+
generateHookConfig(_pluginRoot: string): HookRegistration;
|
|
37
|
+
readSettings(): Record<string, unknown> | null;
|
|
38
|
+
writeSettings(settings: Record<string, unknown>): void;
|
|
39
|
+
validateHooks(_pluginRoot: string): DiagnosticResult[];
|
|
40
|
+
checkPluginRegistration(): DiagnosticResult;
|
|
41
|
+
getInstalledVersion(): string;
|
|
42
|
+
configureAllHooks(_pluginRoot: string): string[];
|
|
43
|
+
backupSettings(): string | null;
|
|
44
|
+
setHookPermissions(_pluginRoot: string): string[];
|
|
45
|
+
updatePluginRegistry(_pluginRoot: string, _version: string): void;
|
|
46
|
+
getRoutingInstructionsConfig(): RoutingInstructionsConfig;
|
|
47
|
+
writeRoutingInstructions(projectDir: string, pluginRoot: string): string | null;
|
|
48
|
+
getRoutingInstructions(): string;
|
|
49
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* adapters/antigravity — Google Antigravity platform adapter.
|
|
3
|
+
*
|
|
4
|
+
* Implements HookAdapter for Antigravity's MCP-only paradigm.
|
|
5
|
+
*
|
|
6
|
+
* Antigravity hook specifics:
|
|
7
|
+
* - NO hook support (MCP-only, same as Codex CLI)
|
|
8
|
+
* - Config: ~/.gemini/antigravity/mcp_config.json (JSON format)
|
|
9
|
+
* - MCP: full support via mcpServers in mcp_config.json
|
|
10
|
+
* - All capabilities are false — MCP is the only integration path
|
|
11
|
+
* - Session dir: ~/.gemini/context-mode/sessions/
|
|
12
|
+
* - Routing file: GEMINI.md (shared with Gemini CLI filename, different content)
|
|
13
|
+
*
|
|
14
|
+
* Sources:
|
|
15
|
+
* - Config path: https://github.com/google-gemini/gemini-cli/issues/16058
|
|
16
|
+
* - MCP support: https://antigravity.google/docs/mcp
|
|
17
|
+
* - Tool list: System prompt leak (21 verified tools)
|
|
18
|
+
*/
|
|
19
|
+
import { createHash } from "node:crypto";
|
|
20
|
+
import { readFileSync, writeFileSync, mkdirSync, copyFileSync, accessSync, constants, } from "node:fs";
|
|
21
|
+
import { resolve, join, dirname } from "node:path";
|
|
22
|
+
import { fileURLToPath } from "node:url";
|
|
23
|
+
import { homedir } from "node:os";
|
|
24
|
+
// ─────────────────────────────────────────────────────────
|
|
25
|
+
// Adapter implementation
|
|
26
|
+
// ─────────────────────────────────────────────────────────
|
|
27
|
+
export class AntigravityAdapter {
|
|
28
|
+
name = "Antigravity";
|
|
29
|
+
paradigm = "mcp-only";
|
|
30
|
+
capabilities = {
|
|
31
|
+
preToolUse: false,
|
|
32
|
+
postToolUse: false,
|
|
33
|
+
preCompact: false,
|
|
34
|
+
sessionStart: false,
|
|
35
|
+
canModifyArgs: false,
|
|
36
|
+
canModifyOutput: false,
|
|
37
|
+
canInjectSessionContext: false,
|
|
38
|
+
};
|
|
39
|
+
// ── Input parsing ──────────────────────────────────────
|
|
40
|
+
// Antigravity does not support hooks. These methods exist to satisfy the
|
|
41
|
+
// interface contract but will throw if called.
|
|
42
|
+
parsePreToolUseInput(_raw) {
|
|
43
|
+
throw new Error("Antigravity does not support hooks");
|
|
44
|
+
}
|
|
45
|
+
parsePostToolUseInput(_raw) {
|
|
46
|
+
throw new Error("Antigravity does not support hooks");
|
|
47
|
+
}
|
|
48
|
+
parsePreCompactInput(_raw) {
|
|
49
|
+
throw new Error("Antigravity does not support hooks");
|
|
50
|
+
}
|
|
51
|
+
parseSessionStartInput(_raw) {
|
|
52
|
+
throw new Error("Antigravity does not support hooks");
|
|
53
|
+
}
|
|
54
|
+
// ── Response formatting ────────────────────────────────
|
|
55
|
+
// Antigravity does not support hooks. Return undefined for all responses.
|
|
56
|
+
formatPreToolUseResponse(_response) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
formatPostToolUseResponse(_response) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
formatPreCompactResponse(_response) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
formatSessionStartResponse(_response) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
// ── Configuration ──────────────────────────────────────
|
|
69
|
+
getSettingsPath() {
|
|
70
|
+
return resolve(homedir(), ".gemini", "antigravity", "mcp_config.json");
|
|
71
|
+
}
|
|
72
|
+
getSessionDir() {
|
|
73
|
+
const dir = join(homedir(), ".gemini", "context-mode", "sessions");
|
|
74
|
+
mkdirSync(dir, { recursive: true });
|
|
75
|
+
return dir;
|
|
76
|
+
}
|
|
77
|
+
getSessionDBPath(projectDir) {
|
|
78
|
+
const hash = createHash("sha256")
|
|
79
|
+
.update(projectDir)
|
|
80
|
+
.digest("hex")
|
|
81
|
+
.slice(0, 16);
|
|
82
|
+
return join(this.getSessionDir(), `${hash}.db`);
|
|
83
|
+
}
|
|
84
|
+
getSessionEventsPath(projectDir) {
|
|
85
|
+
const hash = createHash("sha256")
|
|
86
|
+
.update(projectDir)
|
|
87
|
+
.digest("hex")
|
|
88
|
+
.slice(0, 16);
|
|
89
|
+
return join(this.getSessionDir(), `${hash}-events.md`);
|
|
90
|
+
}
|
|
91
|
+
generateHookConfig(_pluginRoot) {
|
|
92
|
+
return {};
|
|
93
|
+
}
|
|
94
|
+
readSettings() {
|
|
95
|
+
try {
|
|
96
|
+
const raw = readFileSync(this.getSettingsPath(), "utf-8");
|
|
97
|
+
return JSON.parse(raw);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
writeSettings(settings) {
|
|
104
|
+
const settingsPath = this.getSettingsPath();
|
|
105
|
+
mkdirSync(dirname(settingsPath), { recursive: true });
|
|
106
|
+
writeFileSync(settingsPath, JSON.stringify(settings, null, 2), "utf-8");
|
|
107
|
+
}
|
|
108
|
+
// ── Diagnostics (doctor) ─────────────────────────────────
|
|
109
|
+
validateHooks(_pluginRoot) {
|
|
110
|
+
return [
|
|
111
|
+
{
|
|
112
|
+
check: "Hook support",
|
|
113
|
+
status: "warn",
|
|
114
|
+
message: "Antigravity does not support hooks. " +
|
|
115
|
+
"Only MCP integration is available.",
|
|
116
|
+
},
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
checkPluginRegistration() {
|
|
120
|
+
try {
|
|
121
|
+
const raw = readFileSync(this.getSettingsPath(), "utf-8");
|
|
122
|
+
const config = JSON.parse(raw);
|
|
123
|
+
const mcpServers = config?.mcpServers ?? {};
|
|
124
|
+
if ("context-mode" in mcpServers) {
|
|
125
|
+
return {
|
|
126
|
+
check: "MCP registration",
|
|
127
|
+
status: "pass",
|
|
128
|
+
message: "context-mode found in mcpServers config",
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
check: "MCP registration",
|
|
133
|
+
status: "fail",
|
|
134
|
+
message: "context-mode not found in mcpServers",
|
|
135
|
+
fix: "Add context-mode to mcpServers in ~/.gemini/antigravity/mcp_config.json",
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return {
|
|
140
|
+
check: "MCP registration",
|
|
141
|
+
status: "warn",
|
|
142
|
+
message: "Could not read ~/.gemini/antigravity/mcp_config.json",
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
getInstalledVersion() {
|
|
147
|
+
try {
|
|
148
|
+
const pkgPath = resolve(homedir(), ".gemini", "extensions", "context-mode", "package.json");
|
|
149
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
150
|
+
return pkg.version ?? "unknown";
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
return "not installed";
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// ── Upgrade ────────────────────────────────────────────
|
|
157
|
+
configureAllHooks(_pluginRoot) {
|
|
158
|
+
return [];
|
|
159
|
+
}
|
|
160
|
+
backupSettings() {
|
|
161
|
+
const settingsPath = this.getSettingsPath();
|
|
162
|
+
try {
|
|
163
|
+
accessSync(settingsPath, constants.R_OK);
|
|
164
|
+
const backupPath = settingsPath + ".bak";
|
|
165
|
+
copyFileSync(settingsPath, backupPath);
|
|
166
|
+
return backupPath;
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
setHookPermissions(_pluginRoot) {
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
updatePluginRegistry(_pluginRoot, _version) {
|
|
176
|
+
// Antigravity plugin registry is managed via mcp_config.json
|
|
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
|
+
getRoutingInstructions() {
|
|
209
|
+
const instructionsPath = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "configs", "antigravity", "GEMINI.md");
|
|
210
|
+
try {
|
|
211
|
+
return readFileSync(instructionsPath, "utf-8");
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
return "# context-mode\n\nUse context-mode MCP tools (execute, execute_file, batch_execute, fetch_and_index, search) instead of run_command/view_file for data-heavy operations.";
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* adapters/client-map — MCP clientInfo.name → PlatformId mapping.
|
|
3
|
+
*
|
|
4
|
+
* Source: Apify MCP Client Capabilities Registry
|
|
5
|
+
* https://github.com/apify/mcp-client-capabilities
|
|
6
|
+
*
|
|
7
|
+
* Only includes platforms we have adapters for.
|
|
8
|
+
*/
|
|
9
|
+
import type { PlatformId } from "./types.js";
|
|
10
|
+
export declare const CLIENT_NAME_TO_PLATFORM: Record<string, PlatformId>;
|