Repository navigation
Commit 9520f69
Add Cursor and OpenCode adapters (#25)
* Add a Cursor agent-hook adapter
Cursor's agent hooks are a flat `hooks.json` of per-event command entries with a
`matcher` field on the entry itself, and its permission-bearing hooks answer with a
top-level `permission` of allow/deny/ask. That is close enough to the Codex adapter's
config-file shape to reuse its installer idioms, but the event set and response schema
are Cursor's own, so the parsing lives in a new module.
The supported slice stays deliberately narrow: `beforeShellExecution` for commands
Cursor does not sandbox, `preToolUse` matching `Write` and `Delete` for the mutating
file tools, and `stop` for completion. Cursor runs the shell hook for every command
rather than only when it would prompt, so this is a strict pre-tool gate with no native
policy; sandboxed executions are skipped because Cursor never prompts for those.
Cursor documents `preToolUse` `tool_input` as an open object, which for a write can hold
the whole proposed file body, so the summary names the action from the tool type and
speaks only a path it can resolve — never the argument object. `stop` carries no final
assistant text, so completion is announced and no turn is ever continued. Every parse,
transport, and broker failure emits no hook output, which is also Cursor's documented
default for a failed hook.
Wire format from https://cursor.com/docs/agent/hooks; fixtures in the tests are written
from that reference rather than recorded from a pinned client release.
Co-Authored-By: Claude Fable 5 <[email protected]>
* Add `tapq integration cursor` install, status, and uninstall
Matches the existing integration UX: TapQ-managed entries only, unrelated hook data
preserved, a restrictive backup before an existing file changes, and repair on rerun.
Cursor has no hook-trust step and no local command that reports hook activation, so
status validates TapQ's file layout and then states the documented client coverage
instead of executing a Cursor binary. That coverage matters: the desktop app fires every
installed hook, while `cursor-agent` does not fire `preToolUse`, leaving writes and
deletes native there.
Co-Authored-By: Claude Fable 5 <[email protected]>
* Document the Cursor adapter
Adds the integration-guide and CLI-reference sections plus a manual test plan modeled on
the Codex one. The plan carries extra weight here: this adapter ships no versioned Cursor
fixture corpus, so it is the only place the real payload shape is confirmed against a
live client, and several cases ask the tester to record observed field names.
Co-Authored-By: Claude Fable 5 <[email protected]>
* Add the OpenCode adapter module and relay executable
OpenCode has no hook-registration file comparable to Claude Code's
settings.json or Codex's hooks.json. Its documented extension surface is a
JavaScript plugin loaded from the OpenCode configuration directory at
startup, so the unit of installation is one file TapQ owns end to end.
TapQOpenCodeAdapter therefore generates and installs that plugin, and
tapq-opencode-hook is the executable edge it relays to. The plugin observes
OpenCode's permission.asked and session-idle bus events, pipes a small TapQ
relay envelope to the hook, and applies the returned decision through
OpenCode's own permission API. All policy, broker authentication, and speech
rendering stay in Swift, so the JavaScript layer carries no security-relevant
logic and a bus-event rename is a one-line plugin edit.
The plugin's permission.ask hook is deliberately unused: it is declared in
@opencode-ai/plugin's types but no OpenCode code path triggers it
(anomalyco/opencode#7006), so a plugin built on it would silently never run.
Replies prefer POST /permission/{requestID}/reply and fall back to the
deprecated session-scoped route on the injected SDK client.
The plugin is embedded as source text rather than an SPM resource because
package-runtime-app.sh assembles TapQRuntime.app from executables alone, so a
resource bundle would be absent exactly where the installer normally runs.
Embedding also makes install, repair detection, and idempotence a plain
string comparison.
The supported slice stays narrow. Allow becomes a one-time `once` reply and
deny becomes `reject`; the remembered `always` reply is never sent, because a
hands-free answer is scoped to the prompt it was spoken for. bash, edit, and
webfetch get kind-specific speech from documented scalar metadata, with a URL
contributing only its host, and every other kind is spoken from its name
alone, so a permission's open-ended metadata object never reaches speech.
There is no question interception or final-response continuation, because
OpenCode exposes no equivalent surface.
Every parse, transport, and broker failure applies no reply at all, leaving
OpenCode's own prompt pending and answerable on screen.
Co-Authored-By: Claude Fable 5 <[email protected]>
* Add tapq integration opencode install/status/uninstall
The command matches the existing integration UX: TapQ-managed content only,
a restrictive timestamped backup before changing an existing file, atomic
replacement, and repair-on-rerun for a plugin left stale by a moved checkout
or a hand edit. A plugin whose contents already match is a byte-for-byte
no-op that creates no backup.
Because TapQ owns the whole file here rather than merging entries into a
shared one, ownership is explicit: only a file carrying TapQ's marker is
rewritten or removed. Install refuses to overwrite anything else at the
managed path and reports it instead, and uninstall leaves such a file alone,
so neighbouring plugins in the same directory are never touched.
The default path resolves the OpenCode configuration directory the way
OpenCode does — OPENCODE_CONFIG_DIR, then XDG_CONFIG_HOME/opencode, then
~/.config/opencode — and ignores a non-absolute value in either variable so
the plugin cannot land somewhere OpenCode will not scan.
Co-Authored-By: Claude Fable 5 <[email protected]>
* Package and boundary-check the OpenCode hook executable
package-runtime-app.sh now builds, copies, and signs tapq-opencode-hook
alongside the other adapters, so the installer running from TapQRuntime.app
can point at a hook that exists beside it. check-public-boundary.sh adds the
new module to the portable target list.
Co-Authored-By: Claude Fable 5 <[email protected]>
* Document the OpenCode adapter
Adds an OpenCode section to the integration guide and the CLI reference, a
manual test plan modeled on the Codex one, and the roadmap, README, and
changelog updates.
The docs are explicit about what the automated coverage does and does not
claim: the process contracts drive the real hook against a real broker, but
they do not start OpenCode, load the plugin into its runtime, or prove that
OpenCode accepted the reply the plugin issues. The manual plan owns those
boundaries, along with the once-per-turn completion announcement, the speech
boundary for permission metadata, and answering on screen while TapQ is still
speaking.
Co-Authored-By: Claude Fable 5 <[email protected]>
---------
Co-authored-by: spaceamoeba_t <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>1 parent 0529a36 commit 9520f69
37 files changed
Lines changed: 6493 additions & 25 deletions
File tree
- Executables
- tapq-cursor-hook
- tapq-opencode-hook
- Sources
- TapQCLI
- TapQContextBaseline
- TapQContracts
- TapQCursorAdapter
- TapQOpenCodeAdapter
- Tests
- TapQCLITests
- TapQContextBaselineTests
- TapQCursorAdapterTests
- TapQOpenCodeAdapterTests
- TapQOpenCodeProcessTests
- Fixtures
- opencode-1.18.15
- docs
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
39 | 83 | | |
40 | 84 | | |
41 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| 22 | + | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| |||
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
69 | 83 | | |
70 | 84 | | |
71 | 85 | | |
| |||
80 | 94 | | |
81 | 95 | | |
82 | 96 | | |
| 97 | + | |
83 | 98 | | |
| 99 | + | |
84 | 100 | | |
85 | 101 | | |
86 | 102 | | |
| |||
99 | 115 | | |
100 | 116 | | |
101 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
102 | 124 | | |
103 | 125 | | |
104 | 126 | | |
| |||
159 | 181 | | |
160 | 182 | | |
161 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
162 | 220 | | |
163 | 221 | | |
164 | 222 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
| 30 | + | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
71 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
72 | 73 | | |
73 | | - | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
99 | | - | |
100 | | - | |
| 100 | + | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| |||
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
129 | 136 | | |
130 | 137 | | |
131 | 138 | | |
| |||
136 | 143 | | |
137 | 144 | | |
138 | 145 | | |
139 | | - | |
| 146 | + | |
| 147 | + | |
140 | 148 | | |
141 | 149 | | |
142 | 150 | | |
| |||
154 | 162 | | |
155 | 163 | | |
156 | 164 | | |
157 | | - | |
| 165 | + | |
158 | 166 | | |
159 | 167 | | |
160 | 168 | | |
| |||
169 | 177 | | |
170 | 178 | | |
171 | 179 | | |
172 | | - | |
| 180 | + | |
173 | 181 | | |
174 | 182 | | |
175 | 183 | | |
| |||
0 commit comments