Skip to content

Add OpenCode, Kilo Code, Cline and pi hook adapters; resolve shell paths against the agent's directory - #14

Merged
rustfuture merged 9 commits into
mainfrom
feat/opencode-cline-pi-hooks
Oct 2, 2026
Merged

rustfuture merged 9 commits into
mainfrom
feat/opencode-cline-pi-hooks

Conversation

@rustfuture

Copy link
Copy Markdown
Owner

Adds hook adapters for four more agents and fixes three problems found while reviewing them.

Adapters

  • OpenCode, Kilo Code and pi get a small plugin or extension (embedded in reflex, source in
    integrations/) that relays tool calls and finished turns to reflex hook; Cline gets a
    PreToolUse script. What each agent can block, ask or send back is listed in docs/agent-hooks.md.
  • Golden fixtures for every adapter (crates/reflex-hooks/tests/fixtures/), install/uninstall tests,
    and Node drivers that load the real plugin sources.

Fixes from review

  • Shell paths are judged from the agent's directory (affects every adapter with a shell tool,
    including Claude Code, Codex and Cursor). With the agent in app/, echo x > ../secrets/token.txt
    used to be allowed and echo x > secrets/token.txt (really app/secrets/token.txt) blocked.
    Relative targets are now resolved against the agent's directory, falling back to the project root
    when the agent does not report one; absolute paths outside the project no longer match root-relative
    patterns. A cd inside the command is not followed (documented under the shell-check limits).
  • The JS plugins fail open on a failed reflex run. A non-zero exit or timeout used to apply
    whatever JSON was already on stdout.
  • OpenCode/Kilo never drop a turn-end check. An idle that arrived while a check was running was
    discarded, so a run that finished during the check went unchecked. It is now rechecked, unless the
    running check already sent the agent back with a retry.

Testing

  • cargo fmt --check, cargo clippy --workspace --all-targets -D warnings,
    cargo test --workspace --all-targets (206 passed), the demo commands and the fixture check, locally.
  • The three bugs reproduced against the built binary / real plugin sources before the fix and pass after.
  • Not run: real sessions in OpenCode, Kilo Code, Cline and pi, and the Cline PowerShell script.

OpenCode, Kilo Code and pi get a small plugin file (embedded from
integrations/) that relays tool calls and finished turns to
reflex hook <agent> <event> and applies the JSON verdict. Cline gets a
PreToolUse script that calls reflex directly. Cline has no hook that can
send the agent back, so it is guarded before tool calls only.
…cument the new agents

Relative paths in OpenCode, Kilo Code, Cline and pi tool calls are made
absolute against the agent's working directory before they are checked,
so a write from a subdirectory is matched the way the agent resolves it.
The patch header parser and path resolver from the Codex adapter are
shared. Adds docs/agent-hooks.md sections for the four agents (what each
can and cannot do, what was verified from source and what was not), the
installer file table, the --agent help text and a changelog entry.
@rustfuture
rustfuture force-pushed the feat/opencode-cline-pi-hooks branch from a9c3f88 to dc646a2 Compare October 2, 2026 07:34
@rustfuture
rustfuture merged commit 34a11e4 into main Oct 2, 2026
7 checks passed
@rustfuture
rustfuture deleted the feat/opencode-cline-pi-hooks branch October 2, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant