You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creates `~/.config/opencode/plugins/rtk.ts`. Uses the `tool.execute.before` hook.
87
88
89
+
### Pi
90
+
91
+
```bash
92
+
# Project-local (default)
93
+
rtk init --agent pi
94
+
95
+
# Global — all projects
96
+
rtk init --agent pi --global
97
+
```
98
+
99
+
Creates `.pi/extensions/rtk.ts` (local) or `~/.pi/agent/extensions/rtk.ts` (global). Pi auto-discovers extensions from both paths on startup.
100
+
101
+
Uninstall:
102
+
103
+
```bash
104
+
rtk init --uninstall --agent pi
105
+
rtk init --uninstall --agent pi --global
106
+
```
107
+
108
+
Removes only the installed Pi extension file.
109
+
88
110
### OpenClaw
89
111
90
112
```bash
@@ -151,7 +173,7 @@ Support is blocked on upstream `BeforeToolCallback` ([mistral-vibe#531](https://
151
173
|**Plugin**| TypeScript, JavaScript, or Python in agent's plugin system | Transparent, in-place mutation when the agent allows it |
152
174
|**Rules file**| Prompt-level instructions | Guidance only — agent is told to prefer `rtk <cmd>`|
153
175
154
-
Rules file integrations (Cline, Windsurf, Codex, Kilo Code, Antigravity) rely on the model following instructions. Full hook integrations (Claude Code, Cursor, Gemini) are guaranteed — the command is rewritten before the agent sees it.
176
+
Rules file integrations (Cline, Windsurf, Codex, Kilo Code, Antigravity) rely on the model following instructions. Full hook integrations (Claude Code, Cursor, Gemini) are guaranteed — the command is rewritten before the agent sees it. Plugin integrations (OpenCode, Pi) use in-place mutation via the agent's TypeScript extension API.
Copy file name to clipboardExpand all lines: hooks/README.md
+13-2Lines changed: 13 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
**Deployed hook artifacts** — the actual files installed on user machines by `rtk init`. These are shell scripts, TypeScript plugins, and rules files that run outside the Rust binary. They are **thin delegates**: parse agent-specific JSON, call `rtk rewrite` as a subprocess, format agent-specific response. Zero filtering logic lives here.
6
6
7
-
Owns: per-agent hook scripts and configuration files for 8 supported agents (Claude Code, Copilot, Cursor, Cline, Windsurf, Codex, OpenCode, Hermes).
@@ -70,6 +73,7 @@ Each agent subdirectory has its own README with hook-specific details:
70
73
```
71
74
72
75
**Output** (stdout, when rewritten):
76
+
73
77
```json
74
78
{
75
79
"hookSpecificOutput": {
@@ -86,6 +90,7 @@ Each agent subdirectory has its own README with hook-specific details:
86
90
**Input**: Same as Claude Code.
87
91
88
92
**Output** (stdout, when rewritten):
93
+
89
94
```json
90
95
{
91
96
"permission": "allow",
@@ -98,6 +103,7 @@ Returns `{}` when no rewrite (Cursor requires JSON for all paths).
98
103
### Copilot CLI (Rust Binary)
99
104
100
105
**Input** (stdin, camelCase, `toolArgs` is JSON-stringified):
106
+
101
107
```json
102
108
{
103
109
"toolName": "bash",
@@ -106,6 +112,7 @@ Returns `{}` when no rewrite (Cursor requires JSON for all paths).
106
112
```
107
113
108
114
**Output** (no `updatedInput` support -- uses deny-with-suggestion):
115
+
109
116
```json
110
117
{
111
118
"permissionDecision": "deny",
@@ -116,6 +123,7 @@ Returns `{}` when no rewrite (Cursor requires JSON for all paths).
116
123
### VS Code Copilot Chat (Rust Binary)
117
124
118
125
**Input** (stdin, snake_case):
126
+
119
127
```json
120
128
{
121
129
"tool_name": "Bash",
@@ -128,6 +136,7 @@ Returns `{}` when no rewrite (Cursor requires JSON for all paths).
128
136
### Gemini CLI (Rust Binary)
129
137
130
138
**Input** (stdin):
139
+
131
140
```json
132
141
{
133
142
"tool_name": "run_shell_command",
@@ -136,6 +145,7 @@ Returns `{}` when no rewrite (Cursor requires JSON for all paths).
136
145
```
137
146
138
147
**Output** (when rewritten):
148
+
139
149
```json
140
150
{
141
151
"decision": "allow",
@@ -150,6 +160,7 @@ Returns `{}` when no rewrite (Cursor requires JSON for all paths).
150
160
### OpenCode (TypeScript Plugin)
151
161
152
162
Mutates `args.command` in-place via the zx library:
163
+
153
164
```typescript
154
165
const result =await$`rtk rewrite ${command}`.quiet().nothrow()
155
166
const rewritten =String(result.stdout).trim()
@@ -230,7 +241,7 @@ New integrations must follow the [Exit Code Contract](#exit-code-contract) and [
230
241
| Tier | Mechanism | Maintenance | Examples |
231
242
|------|-----------|-------------|----------|
232
243
|**Full hook**| Shell script or Rust binary, intercepts commands via agent's hook API | High — must track agent API changes | Claude Code, Cursor, Copilot, Gemini |
233
-
|**Plugin**| TypeScript/JS/Python plugin in agent's plugin system | Medium — agent manages loading | OpenCode, Hermes |
244
+
|**Plugin**| TypeScript/JS/Python plugin in agent's plugin system | Medium — agent manages loading | OpenCode, Hermes, Pi|
234
245
|**Rules file**| Prompt-level instructions the agent reads | Low — no code to break | Cline, Windsurf, Codex |
Copy file name to clipboardExpand all lines: src/hooks/README.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@
6
6
7
7
The **lifecycle management** layer for LLM agent hooks: install, uninstall, verify integrity, audit usage, and manage trust. This component creates and maintains the hook artifacts that live in `hooks/` (root), but does **not** execute rewrite logic itself — that lives in `discover/registry`.
8
8
9
-
Owns: `rtk init` installation flows (4 agents via `AgentTarget` enum + 3 special modes: Gemini, Codex, OpenCode), SHA-256 integrity verification, hook version checking, audit log analysis, `rtk rewrite` CLI entry point, and TOML filter trust management.
9
+
Owns: `rtk init` installation flows (5 agents via `AgentTarget` enum + 3 special modes: Gemini, Codex, OpenCode), SHA-256 integrity verification, hook version checking, audit log analysis, `rtk rewrite` CLI entry point, and TOML filter trust management.
10
10
11
11
Does **not** own: the deployed hook scripts themselves (that's `hooks/`), the rewrite pattern registry (that's `discover/`), or command filtering (that's `cmds/`).
12
12
@@ -22,14 +22,15 @@ LLM agent integration layer that installs, validates, and executes command-rewri
0 commit comments