Skip to content

feat(refacto-core): binary hook w/ native cmd exec + streaming#956

Open
aeppling wants to merge 7 commits intodevelopfrom
feat-hook-engine
Open

feat(refacto-core): binary hook w/ native cmd exec + streaming#956
aeppling wants to merge 7 commits intodevelopfrom
feat-hook-engine

Conversation

@aeppling
Copy link
Copy Markdown
Contributor

@aeppling aeppling commented Mar 31, 2026

From the idea of #536

Summary

  • Binary hook engine: RTK can now process Claude Code hooks directly as a binary (rtk hook claude), reading JSON from stdin and responding on stdout without shell script dependencies (no jq/bash required)
  • Native command executor: rtk run executes commands natively with operator logic (&&/||/;), shell builtins (cd, export, pwd), and streaming output filters — all in a single process
  • Hook check command: rtk hook check [--agent] for dry-run testing of hook routing decisions
  • Streaming filter infrastructure: Line-by-line output filtering with per-binary filter modes (Streaming/Buffered/Passthrough) and RAII child process management
  • Multi-remote branch support: git branch -a now correctly deduplicates branches across multiple remotes
  • Documentation: Added src/cmd/README.md, updated docs/TECHNICAL.md architecture diagram, folder map, and flow sections

Test plan

  • 1583 tests pass (cargo test --all)
  • Hook routing retest
  • 20+ Chained commands

Should fix :

ISSUE #154
ISSUE #532
ISSUE #530
ISSUE #963
ISSUE #222
ISSUE #897
ISSUE #732
ISSUE #917 (for the env var prefix part)
ISSUE #294 (cover ~40%)
ISSUE #361

@aeppling
Copy link
Copy Markdown
Contributor Author

aeppling commented Apr 1, 2026

Removed strip_quote from last release requirements, will be added back for this

@aeppling
Copy link
Copy Markdown
Contributor Author

aeppling commented Apr 2, 2026

not ready for review, need fix for a full standardized flow

aeppling and others added 4 commits April 4, 2026 18:45
  What changed:
  - Add `run_claude()` with permissions check, audit logging, tool_input
    preservation, and Ask/Allow/Deny support
  - Add `run_cursor()` with flat JSON format (`permission`/`updated_input`)
  - Add `audit_log()` (best-effort append when RTK_HOOK_AUDIT=1)
  - Fix `run_gemini()` to load exclude_commands from config
  - Convert all hook stdout to `writeln!` with `#[deny(clippy::print_stdout)]`
    to prevent JSON protocol corruption (Claude Code bug #4669)
  - Replace string-based heredoc detection with lexer-based `has_heredoc()`
    (quote-aware: `<<` inside quotes no longer false-positives)
  - Add shell prefix peeling (noglob, command, builtin, exec, nocorrect)
    to `rewrite_segment()` in registry.rs
  - Fix python3 -m pytest pattern, add pip show, add gt (Graphite) to RULES
  - Remove `command ` from IGNORED_PREFIXES (was blocking `command git status`)
  - Register `rtk hook claude`/`rtk hook cursor` binary commands in
    settings.json instead of writing bash script files
  - Add legacy script migration (deletes old rtk-rewrite.sh on `rtk init`)
  - Simplify hook_check and integrity for script-free model
Integrates ~30 develop commits (PR #997): AWS expansion (8→25 cmds),
SSH signing for git commit/push, go test context, grep stdin leak fix,
default-to-ask permissions, gh pr merge passthrough.

Conflict resolution (4 files):
- git.rs: kept .output()+stdin(inherit) for commit/push (SSH/GPG signing)
- go_cmd.rs: accepted incoming + added pub(crate) visibility
- hook_check.rs: merged binary_hook_registered + other_integration_installed
- hook_cmd.rs: fixed permissions path, println→writeln for Gemini deny

Verified: 1445 tests pass, 0 clippy errors, all manual integration tests pass.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
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