Skip to content

feat(omp) add OMP hook that rewrites bash tool calls through rtk rewrite#1827

Open
thedavemarshall wants to merge 2 commits into
rtk-ai:developfrom
thedavemarshall:feat/omp-rewrite-extension
Open

feat(omp) add OMP hook that rewrites bash tool calls through rtk rewrite#1827
thedavemarshall wants to merge 2 commits into
rtk-ai:developfrom
thedavemarshall:feat/omp-rewrite-extension

Conversation

@thedavemarshall
Copy link
Copy Markdown

@thedavemarshall thedavemarshall commented May 11, 2026

Summary

  • Adds Oh My Pi (OMP) agent support via a TypeScript extension module that intercepts bash tool calls and delegates rewriting to rtk rewrite
  • Supports rtk init --agent omp (project: ./.omp/extensions/rtk.ts) and rtk init -g --agent omp (global: ~/.omp/agent/extensions/rtk.ts), plus uninstall and config inspection
  • Fail-open design: if rtk is unavailable or the rewrite subprocess fails, commands run raw unchanged
  • Aiming for a simple and rtk-idiomatic approach to Add support for Oh-My-Pi #591

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • Manual testing: rtk init --agent ompandrtk init -g --agent omp` output inspected
  • Installed locally and verified in an omp session that asking git status got re-written to rtk git status

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 11, 2026

CLA assistant check
All committers have signed the CLA.

@thedavemarshall thedavemarshall changed the title add OMP extension that rewrites bash tool calls through rtk rewrite feat(omp) add OMP extension that rewrites bash tool calls through rtk rewrite May 11, 2026
Comment thread hooks/omp/rtk.ts Outdated
@thedavemarshall thedavemarshall force-pushed the feat/omp-rewrite-extension branch from c9bd4d5 to cc0f452 Compare May 11, 2026 04:52
@thedavemarshall thedavemarshall changed the title feat(omp) add OMP extension that rewrites bash tool calls through rtk rewrite feat(omp) add OMP hook that rewrites bash tool calls through rtk rewrite May 11, 2026
@thedavemarshall thedavemarshall force-pushed the feat/omp-rewrite-extension branch from 35b9e36 to 887f616 Compare May 13, 2026 14:01
…uninstall

OMP hook (hooks/omp/rtk.ts):
- Intercepts bash tool_call events, delegates to `rtk rewrite`
- Exit code 0 (allow), 1 (no equivalent), 2 (deny — silent passthrough), 3 (ask)
- Thin spawner wrapper enables test injection without real subprocess
- 2-second spawn timeout with cleanup
- Fail-open: missing rtk, spawn errors, unexpected exits all passthrough

Test suite (hooks/omp/tests/rtk.test.ts):
- 13 behavioral tests covering all exit codes, error paths, edge cases
- Mirrors Hermes test pattern with fake subprocess injection

Discover integration (src/discover/):
- AgentIntegrationStatus extended with omp_hook_installed detection
- detect_from_home checks ~/.omp/agent/hooks/pre/rtk.ts
- append_agent_notes reports OMP alongside Cursor and Hermes

hook_check integration (src/hooks/hook_check.rs):
- OMP hook path added to other_integration_installed detection
- Tests cover OMP hook presence in empty-dir guard

Init support (src/hooks/init.rs, src/main.rs):
- `rtk init --agent omp` / `rtk init -g --agent omp` for project/global
- OMP extension file installation with collision/idempotency checks
- `rtk init --uninstall` handles OMP cleanup via uninstall_init_dispatch
- run_omp_mode, install_omp_extension_file, uninstall_omp functions
- OMP_GLOBAL_HOOK_PATH / OMP_PROJECT_HOOK_PATH constants

Documentation:
- README, supported-agents guide, TECHNICAL.md updated for OMP
- Hook README documents installation paths and verdict behavior

Signed-off-by: David Marshall <[email protected]>
@thedavemarshall thedavemarshall force-pushed the feat/omp-rewrite-extension branch from 887f616 to 8a23aa8 Compare May 13, 2026 14:07
…ion cleanup

uninstall_omp now returns Result<()> and owns the user-facing summary, while
uninstall_omp_at returns Result<Vec<String>> silently — matching the split
established by uninstall_hermes_at and uninstall_codex_at (PR rtk-ai#1614). Removes
the discarded return value at the caller and the duplicated println! channel
inside _at.

Also: complete dependency injection in resolve_omp_agent_dir_from_env so
the PI_CONFIG_DIR branch is unit-testable; drop the misleading underscore
prefix on rtkMissingWarned (TS convention reserves _ for unused bindings);
restore the blank line between tests in discover::report.

Co-Authored-By: Claude Opus 4.7 (1M context) <[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.

2 participants