Skip to content

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

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

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

Conversation

@thedavemarshall

@thedavemarshall thedavemarshall commented May 11, 2026 •

Copy link
Copy Markdown

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

CLAassistant commented May 11, 2026 •

Copy link
Copy Markdown

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 Resolved
@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]>
@KuSh

KuSh commented May 23, 2026

Copy link
Copy Markdown
Collaborator

Hi @thedavemarshall, thanks for your contribution. There was already a MR for OMP here. And in the meantime Pi support has been merged.

Could you sync with @makoMakoGo to see how to proceed? The OMP integration should build on Pi support, see if some mutualization could happen. Thanks

@rtk-release-bot

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale due to 90 days of inactivity. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. Your contribution is very much appreciated — we're sorry we haven't been able to review it yet.

@rtk-release-bot rtk-release-bot Bot added the stale label Sep 3, 2026
@KuSh

KuSh commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this. Oh My Pi support landed in #3707 on 2026-09-05, which installs the extension through the shared Pi file at ~/.omp/agent/extensions rather than a separate omp hook script, so the install, uninstall and hook paths here are now covered by a different layout. One thing this PR had that develop still lacks: rtk discover does not mention an installed OMP hook in its agent notes, since AgentIntegrationStatus only tracks cursor, hermes and copilot. That would be worth a small issue or a narrow PR against the current constants. If anything else here was missed, please say so or reopen.

@KuSh KuSh closed this Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants