Skip to content

feat(omp): add extension-based rewrite integration for Oh My Pi#1365

Open
makoMakoGo wants to merge 1 commit into
rtk-ai:developfrom
makoMakoGo:feat/omp-extension-rewrite
Open

feat(omp): add extension-based rewrite integration for Oh My Pi#1365
makoMakoGo wants to merge 1 commit into
rtk-ai:developfrom
makoMakoGo:feat/omp-extension-rewrite

Conversation

@makoMakoGo
Copy link
Copy Markdown

@makoMakoGo makoMakoGo commented Apr 17, 2026

Summary

Adds Oh My Pi (OMP) as a first-class RTK CLI integration via a TypeScript extension that intercepts tool_call events for the bash tool and delegates command rewrite decisions to rtk rewrite.

  • New init flag: rtk init --omp / rtk init -g --omp
  • Installs ./.omp/extensions/rtk.ts for project scope or ~/.omp/agent/extensions/rtk.ts for global scope
  • Keeps rewrite logic in the Rust registry; the OMP extension is a thin runtime adapter
  • Supports --show, --uninstall, --dry-run, project-scoped install, and global install
  • Refuses to overwrite pre-existing non-stock OMP extension files

Closes #591.

Review cleanup

This version was rebased onto current develop to keep the PR focused on OMP only:

  • Removed the previous docs noise and broad wording changes
  • Kept Hermes and existing agent documentation intact
  • Switched OMP from --agent omp to --omp because OMP is a CLI/runtime integration, closer to OpenCode/Gemini/Codex than IDE rules-file integrations

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets
  • cargo test
  • bun --eval 'await import("./hooks/omp/rtk.ts")'
  • cargo run -- init --help
  • cargo run -- init --omp --dry-run
  • cargo run -- init --omp --show

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 17, 2026

CLA assistant check
All committers have signed the CLA.

@makoMakoGo makoMakoGo force-pushed the feat/omp-extension-rewrite branch from abc616a to 915ef53 Compare April 17, 2026 14:46
@makoMakoGo
Copy link
Copy Markdown
Author

I have used this pr for about 2 days on my omp.

@makoMakoGo
Copy link
Copy Markdown
Author

@aeppling @KuSh @FlorianBruniaux this is now rebased onto current master, the PR description matches the current fail-closed OMP behavior, and the targeted checks were rerun:

  • cargo test test_omp
  • cargo test test_validate_init_target_selection
  • cargo test test_npx_unknown_tool_passthrough
  • bun --eval await import("./hooks/omp/rtk.ts")

This PR has been open since 2026-04-17. Could one of you review it when you have time? Thanks.

@makoMakoGo
Copy link
Copy Markdown
Author

@pszymkowiak also pinging you here since you merge/review a lot of RTK work and this touches init/hook integration paths.

@tsubus
Copy link
Copy Markdown

tsubus commented May 6, 2026

this looks like a vibe coded mess, isn't this other one looking much better? https://github.com/beeemT/rtk/pull/2

@makoMakoGo
Copy link
Copy Markdown
Author

makoMakoGo commented May 6, 2026

this looks like a vibe coded mess, isn't this other one looking much better? beeemT#2

PR #2 is prompt-only, while OMP supports a cleaner command-rewrite path via tool_call. My personal opinion is that using event.input.command before the native BashTool runs, so RTK keeps transparent behavior without overriding the bash tool or relying on the model to remember rtk.

PR #2 describes Capability A(which I mentioned above), but the actual patch does not implement it; it ends up as Capability B (prompt-injection) only.

Copy link
Copy Markdown
Collaborator

@KuSh KuSh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @makoMakoGo, thanks for your PR.

There's a lot of documentation changes that feels like nitpicks around terms (extensions/hooks/...). That seems uneeded and unwanted. Could you try to stay closer to what we already have?

Also OMP do have pre hooks, why not just use that? Why did you choose to use an extension?

@makoMakoGo
Copy link
Copy Markdown
Author

makoMakoGo commented May 14, 2026

Thanks for the review, @KuSh.

On the docs: Agreed — I'll strip the broad terminology changes and keep the diff to OMP-specific additions
only. The hook/plugin/extension wording updates aren't needed for this integration.

On extension vs pre hook: The goal is the same as a pre-execution rewrite: intercept the bash tool call before it runs and replace the command with the rtk rewrite result.

I chose the extension path because it's the actively maintained surface for tool interception in current OMP. Specifically:

  • --hook is treated as an alias for an extension path in current OMP
  • Extension modules are auto-discovered from .omp/extensions/ and ~/.omp/agent/extensions/
  • OMP's authoring docs recommend ExtensionAPI for new integrations
  • The hook subsystem's tool_call event can only block/allow — it cannot mutate tool input in-place, which is needed for command rewriting. In other words, the legacy hook result contract is block/allow-oriented and does not expose an explicit updated-input return shape for command rewriting.

This also aligns with RTK's existing transparent-rewrite integrations (OpenCode plugin, OpenClaw plugin) rather than the rules-file approach or hooks.

That said — if you'd prefer a pre-hook implementation, or would rather wait for another contributor's take, I'm happy to adjust or close. Just let me know which direction you'd prefer. 🤗

@KuSh
Copy link
Copy Markdown
Collaborator

KuSh commented May 15, 2026

On extension vs pre hook: The goal is the same as a pre-execution rewrite: intercept the bash tool call before it runs and replace the command with the rtk rewrite result.

I chose the extension path because it's the actively maintained surface for tool interception in current OMP. Specifically:

* `--hook` is treated as an alias for an extension path in current OMP

* Extension modules are auto-discovered from .omp/extensions/ and ~/.omp/agent/extensions/

* OMP's authoring docs recommend ExtensionAPI for new integrations

* The hook subsystem's tool_call event can only block/allow — it cannot mutate tool input in-place, which is needed for command rewriting. In other words, the legacy hook result contract is block/allow-oriented and does not expose an explicit updated-input return shape for command rewriting.

This also aligns with RTK's existing transparent-rewrite integrations (OpenCode plugin, OpenClaw plugin) rather than the rules-file approach or hooks.

That said — if you'd prefer a pre-hook implementation, or would rather wait for another contributor's take, I'm happy to adjust or close. Just let me know which direction you'd prefer. 🤗

No, I was just questioning the choice since, after a quick review of the OMP repo, I didn't find anything that prioritizes extensions over hooks. But after your explanation and a closer review of the documentation, extensions seem like the right choice.

So rebase, handle conflicts, and reduce documentation noise—the principles remain the same even if OMP chooses different wording.

@makoMakoGo makoMakoGo force-pushed the feat/omp-extension-rewrite branch from 32043fc to f22686a Compare May 15, 2026 11:22
@rtk-release-bot rtk-release-bot Bot added the wrong-base PR targets master instead of develop label May 15, 2026
@rtk-release-bot
Copy link
Copy Markdown

Automatic message from CI checks : It seems like this branch is targeting the wrong branch, any contribution should target develop branch.

See CONTRIBUTING.md for details.

@makoMakoGo makoMakoGo force-pushed the feat/omp-extension-rewrite branch 4 times, most recently from 9a2fba8 to 2e4b84c Compare May 15, 2026 12:44
@makoMakoGo makoMakoGo changed the base branch from master to develop May 15, 2026 12:44
@makoMakoGo makoMakoGo marked this pull request as draft May 15, 2026 13:01
@makoMakoGo makoMakoGo force-pushed the feat/omp-extension-rewrite branch from 2e4b84c to c13a98a Compare May 15, 2026 13:22
Add Oh My Pi (OMP) as a CLI integration. OMP loads TypeScript
extensions that intercept tool_call events; RTK installs a dedicated
rtk.ts extension that delegates bash command rewrites to rtk rewrite.

- hooks/omp/rtk.ts: extension source (Bun runtime, tool_call handler)
- hooks/omp/README.md: hook-specific documentation
- src/hooks/constants.rs: OMP extension path constants
- src/hooks/init.rs: run_omp_mode, uninstall_omp, show_omp_config
- src/main.rs: --omp init flag and dispatch
- Docs: additive OMP entries in README, supported-agents, hooks/README

Supports both project-scoped (.omp/extensions/rtk.ts) and global
(~/.omp/agent/extensions/rtk.ts) installation. Fails closed when
rtk binary is not on PATH.
@makoMakoGo makoMakoGo force-pushed the feat/omp-extension-rewrite branch from c13a98a to 6f39049 Compare May 15, 2026 13:28
@makoMakoGo
Copy link
Copy Markdown
Author

@KuSh updated.

Changed:

  • Kept docs to OMP-additive entries only; no broad terminology changes
  • Aligned OMP extension with RTK's fail-open convention used by Hermes/OpenCode etc: missing rtk or rewrite
    failures leave the original command unchanged

Verified:

  • cargo fmt --all -- --check
  • cargo clippy --all-targets
  • cargo test
  • bun --eval 'await import("./hooks/omp/rtk.ts")'
  • Local OMP simulation: tool_call rewrites supported bash commands through rtk
  • Manual fail-open check: hid the rtk binary; command passed through unchanged, no block

Ready for re-review when you have time.

@makoMakoGo makoMakoGo marked this pull request as ready for review May 15, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wrong-base PR targets master instead of develop

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Oh-My-Pi

4 participants