Skip to content

feat(hooks): add OMP (Oh My Pi) agent support - #3151

Closed
DavidHLP wants to merge 5 commits into
rtk-ai:developfrom
DavidHLP:feat/hooks-add-omp-agent-support
Closed

feat(hooks): add OMP (Oh My Pi) agent support#3151
DavidHLP wants to merge 5 commits into
rtk-ai:developfrom
DavidHLP:feat/hooks-add-omp-agent-support

Conversation

@DavidHLP

@DavidHLP DavidHLP commented Jul 22, 2026

Copy link
Copy Markdown

Summary

  • Add rtk init --agent omp to install RTK transparent rewrite support for OMP (Oh My Pi) coding agent
  • TypeScript extension loaded from hooks/pre/ that intercepts tool_call events and calls rtk rewrite for in-place command mutation — same architecture as the existing Pi extension
  • Adds OMP as the 16th supported agent across README.md, hooks/README.md, and docs/guide/getting-started/supported-agents.md

Closes #591.

ℹ️ Note on #1365: This PR is an independent OMP implementation that supersedes #1365 (stale since June 2025). Both close #591. This PR uses --agent omp (consistent with Pi/Hermes/Droid) rather than #1365's --omp flag.

ℹ️ Conflict note for maintainers: This PR is intentionally left DIRTY (conflicting). The conflict is README.md only — develop reworded the "Supported AI Tools" intro while this PR bumped the count 15 → 16. Resolution: keep 16, adopt develop's wording (reducing the bash output the agent reads). The other two overlapping files auto-merge cleanly. develop was not merged into this branch to keep the commit history focused on the OMP feature.


Install / Uninstall

# Install
rtk init -g --agent omp          # global → ~/.omp/agent/hooks/pre/rtk.ts
rtk init --agent omp             # project → .omp/hooks/pre/rtk.ts

# Uninstall
rtk init --uninstall -g --agent omp   # global
rtk init --uninstall --agent omp      # project

# Preview
rtk init --agent omp --dry-run

Both install and uninstall honor the OMP_AGENT_DIR environment variable (mirrors PI_CODING_AGENT_DIR) for custom install locations.


Test plan

  • cargo fmt --all --check — pass
  • cargo clippy --all-targets — no issues
  • cargo test — 2535 passed, 0 failed (14 new OMP tests)
  • Manual testing: rtk init --agent omp install/uninstall/dry-run verified
  • End-to-end: OMP 17.0.8 loads the extension and rewrites commands

Runtime evidence

Environment: rtk 0.42.4, omp 17.0.8, Linux x86_64.

1. rtk rewrite on OMP-rewritable commands:

$ rtk rewrite "git status"     → rtk git status
$ rtk rewrite "cargo test"     → rtk cargo test
$ rtk rewrite "ls ."           → rtk ls .
$ rtk rewrite "grep pattern ." → rtk grep pattern .
$ rtk rewrite "pytest"         → rtk pytest
$ rtk rewrite "ruff check"     → rtk ruff check

Exit code 1 (passthrough) for unsupported commands — correct.

2. Install (dry-run → real → file identity check):

$ rtk init --agent omp --dry-run
[dry-run] would create local OMP hooks/pre directory: .omp/hooks/pre
[dry-run] would create OMP extension: .omp/hooks/pre/rtk.ts
[dry-run] Nothing written.

$ rtk init --agent omp
RTK OMP extension installed:
  Extension: .omp/hooks/pre/rtk.ts

$ diff .omp/hooks/pre/rtk.ts hooks/omp/rtk.ts   # no diff — identical

3. Uninstall + idempotency:

$ rtk init --uninstall --agent omp
RTK uninstalled (OMP):
  - OMP extension: .omp/hooks/pre/rtk.ts

$ rtk init --uninstall --agent omp
RTK OMP extension was not installed (nothing to remove)

4. OMP loads the extension end-to-end:

$ rtk init --agent omp
$ omp -p --mode text --no-session "Run: git status"
Working...
On branch `feat/hooks-add-omp-agent-support`. One untracked path: `.omp/`.
Working tree is otherwise clean (no staged or modified files).

OMP called the extension, rtk rewrite turned git statusrtk git status, and the agent received compact filtered output instead of raw git status.

Note on UI screenshots: setLabel("RTK") and session_start status-line behavior (visible in OMP's TUI when rtk is missing) require a live interactive OMP TUI session — only CLI text evidence is included here.


Changes (8 files)

File Change
src/hooks/constants.rs OMP_DIR, OMP_LOCAL_DIR, OMP_HOOKS_PRE_SUBDIR, OMP_PLUGIN_FILE, OMP_AGENT_DIR_ENV
src/hooks/init.rs resolve_omp_dir(), omp_plugin_path_for_scope(), ensure_omp_plugin_installed(), uninstall_omp(), run_omp_mode(), print_omp_result()
src/main.rs Omp variant in AgentTarget, install/uninstall routing
hooks/omp/rtk.ts TypeScript extension (new)
hooks/omp/README.md Agent-specific docs (new)
README.md Quick Start + agent table (16 tools)
hooks/README.md Directory structure + agent table
docs/guide/getting-started/supported-agents.md OMP section + table row

Design notes

  • Same tool_call event + in-place mutation as Pi — shared extension API lineage (Earendil Works)
  • Local interface declarations (no SDK import) for portability across OMP versions
  • setLabel("RTK") + session_start status — persistent warning when rtk missing/too old (requested in feat(omp): add extension-based rewrite integration for Oh My Pi #1365)
  • Hook-only — no AGENTS.md injection (transparent rewrite)

@CLAassistant

CLAassistant commented Jul 22, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Add `rtk init --agent omp` to install RTK transparent rewrite support
for OMP (Oh My Pi) coding agent. Same architecture as the Pi extension:
TypeScript hook loaded from `hooks/pre/`, intercepts `tool_call` events,
calls `rtk rewrite` for command mutation.

Install paths:
- global:   $OMP_AGENT_DIR/hooks/pre/rtk.ts (or ~/.omp/agent/hooks/pre/)
- project:  .omp/hooks/pre/rtk.ts

Changes:
- Add OMP constants (OMP_DIR, OMP_PLUGIN_FILE, OMP_AGENT_DIR_ENV, etc.)
- Add run_omp_mode/uninstall_omp/resolve_omp_dir to init.rs
- Add Omp variant to AgentTarget enum + CLI routing in main.rs
- Add hooks/omp/rtk.ts extension (rewriteCommand, signal, killed guard)
- Add hooks/omp/README.md
- Add 14 integration tests (12 init.rs + 2 main.rs CLI parse)
- Update README.md, hooks/README.md, supported-agents.md

Signed-off-by: DavidHLP <lysf15520112973@163.com>
@DavidHLP
DavidHLP force-pushed the feat/hooks-add-omp-agent-support branch from 13f9663 to dbb30e0 Compare July 22, 2026 14:51
DavidHLP added 4 commits July 22, 2026 23:20
Add two features that competing PRs (rtk-ai#1365, rtk-ai#2166) include and that
maintainer KuSh specifically requested in rtk-ai#1365 review:

- setLabel('RTK') — set extension label in OMP UI
- session_start + ctx.ui.setStatus — show persistent warning in OMP UI
  when rtk binary is missing or too old

Also extends ExtensionAPI interface with setLabel() and session_start
event support (optional ui field for backward compatibility).

Signed-off-by: DavidHLP <lysf15520112973@163.com>
Two tests had false positive risks where they would pass even if the
code was broken:

1. test_run_omp_mode_local_installs_plugin — only checked file exists,
   not content. Added content.contains('rtk rewrite') assertion to
   match the global variant.

2. test_omp_local_uninstall_removes_plugin — did not assert plugin
   exists before uninstall. If install was a no-op (bug), uninstall
   would succeed vacuously and assert!(!exists) would pass on an empty
   state. Added assert!(plugin.exists()) guard before uninstall.

Signed-off-by: DavidHLP <lysf15520112973@163.com>
The OMP install line used one extra padding space (comment marker at
column 34 instead of 33), misaligning it from all other agents in the
Quick Start block. Trimmed one space so 'rtk init -g --agent omp' aligns
with the rest.

Signed-off-by: DavidHLP <lysf15520112973@163.com>
hooks/omp/README.md previously only had an Uninstall section and a
generic version-guard bullet. Added:

- Install section (project-local + global, matching supported-agents.md)
- OMP_AGENT_DIR override mention
- --dry-run usage
- Specifics: setLabel("RTK") and session_start status-line warning
  when rtk binary is missing — both are OMP-exclusive behaviors absent
  from the Pi extension

No code changes.

Signed-off-by: DavidHLP <lysf15520112973@163.com>
@DavidHLP
DavidHLP force-pushed the feat/hooks-add-omp-agent-support branch from f770633 to e209154 Compare July 23, 2026 09:16
@peterrauscher

Copy link
Copy Markdown

would love to see this!

@aancw

aancw commented Aug 12, 2026

Copy link
Copy Markdown

Nice job, can't wait to see this implementation.

@thinhngotony

Copy link
Copy Markdown

I opened DavidHLP#1 with the OMP hook compatibility fixes: remove unsupported setLabel, mutate input for older runtimes, and return revised input for newer runtimes.

@DavidHLP

Copy link
Copy Markdown
Author

Closing this in favor of #3707.

After reviewing the current state of things, #3707 is the better path forward:

Thanks to @peterrauscher, @aancw and everyone who showed interest here — OMP support
is arriving, just via a shared-extension design instead of a standalone file. I'll be
testing #3707 against my OMP setup and contributing review feedback there as well.

@DavidHLP DavidHLP closed this Aug 29, 2026
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.

Add support for Oh-My-Pi

5 participants