feat(omp): add extension-based rewrite integration for Oh My Pi - #1365
feat(omp): add extension-based rewrite integration for Oh My Pi#1365makoMakoGo wants to merge 5 commits into
Conversation
abc616a to
915ef53
Compare
|
I have used this pr for about 2 days on my omp. |
|
@aeppling @KuSh @FlorianBruniaux this is now rebased onto current
This PR has been open since 2026-04-17. Could one of you review it when you have time? Thanks. |
|
@pszymkowiak also pinging you here since you merge/review a lot of RTK work and this touches init/hook integration paths. |
|
this looks like a vibe coded mess, isn't this other one looking much better? https://github.com/beeemT/rtk/pull/2 |
PR #2 is prompt-only, while OMP supports a cleaner command-rewrite path via 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. |
There was a problem hiding this comment.
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?
|
Thanks for the review, @KuSh. On the docs: Agreed — I'll strip the broad terminology changes and keep the diff to OMP-specific additions 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:
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. |
32043fc to
f22686a
Compare
|
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. |
9a2fba8 to
2e4b84c
Compare
c13a98a to
6f39049
Compare
|
@KuSh updated. Changed:
Verified:
Ready for re-review when you have time. |
|
|
||
| const hasRtk = Boolean(Bun.which("rtk")); | ||
|
|
||
| pi.on("tool_call", async (event) => { |
There was a problem hiding this comment.
nitpick, why not just skip registering the tool_call hook if RTK isn't available?
How could we alert the user about that?
There was a problem hiding this comment.
Got it. I moved the RTK availability check to extension setup: when rtk is missing, the extension now registers only a session_start warning via OMP's UI and skips the
tool_call handler; when rtk is available, it registers the rewrite hook as before.
There was a problem hiding this comment.
There was a problem hiding this comment.
I tried to align this with the OpenCode plugin behavior: when rtk is missing, don't register the tool hook and surface a warning.
For OMP, it's a little werid.
mode.init()
-> UI start
-> initHooksAndCustomTools()
-> emit session_start
-> extension: ctx.ui.notify(...)
-> showWarning -->chatContainer
main.ts
-> mode.renderInitialMessages()
-> chatContainer.clear()
-> warning clear (not show)As a result, I cant see any warning expected.
There was a problem hiding this comment.
Does persistent hook status works flawlessly? It seems enough. I'm not sure to understand your latest message.
| hooks::init::uninstall, | ||
| )?; | ||
| if omp { | ||
| hooks::init::uninstall_omp(global, ctx)?; |
There was a problem hiding this comment.
Ideally this should go into uninstall_init_dispatch as user could want to uninstall multiple things in one go
|
@makoMakoGo in the meantime Pi support has been merged. Could you rebase your work on what has been done here. Perhaps some mutualization could be used. |
Thanks for the heads-up. I’ll take a look at the merged Pi support and coordinate with @thedavemarshall on the best path forward. 🫡 |
|
I rebased this on top of the merged Pi support (#1741) and tested the OMP path locally. I confirmed that OMP v15.2.4 can load the merged Pi extension unchanged when the file is installed under OMP's native extension directories ( OMP provides legacy-pi-compat: it uniformly remaps the scopes of historical Pi internal packages — @mariozechner/, @earendil-works/, and @oh-my-pi/* — to OMP's own bundled @oh-my-pi/*. Given that, I think this PR should not maintain a separate OMP runtime extension. 🤔 I'll update it to reuse the merged Pi extension implementation and keep only the OMP-specific install/init paths, docs, and tests. The intended final shape is:
Any other suggestions on the intended shape before I push the update ? I'm happy to do that. |
|
wait I tested pure reuse of the merged Pi extension under OMP, including the missing-rtk path. The normal rewrite mechanism is compatible and should stay aligned with Pi: listen to related to #1365 (comment) However, reusing the Pi extension file unchanged has a bad OMP startup UX when I want do something like this: to do this, I need to use the but I can only do this to alert the user about that:
the persistent status worked in my manual OMP testing and stayed visible after startup. |
Try to keep the spirit of the pi extension, even for install/uninstall, follow what have been documented. Rebase and resolve conflicts. If the pi extension doesn't work as is, we can duplicate it, but asking OMP maintainer about that usage which seems legit to me, could be a better option. Keep up the good work! |
|
Opened the issue for that notify bug, and it's fixed in oh-my-pi. Will move on, need some time though. |
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.
bb67262 to
32dd7e6
Compare
|
any news for this PR? |
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>
|
Yes also looking for this @makoMakoGo @thedavemarshall |
PR reply draft (comment on #1365, voice: alvins82)@makoMakoGo @KuSh — I picked this up and reworked it against current ShapeYour 05-23 message ("the intended final shape is: no separate OMP rewrite logic; install the Pi-compatible RTK extension into
Your 05-23 "wait" finding is addressedThe missing-rtk startup UX you hit — silent failure of
Your 05-14 questionsDocs: agreed — the rework is strictly additive. One row per agent table, one OMP section in Extensions vs. pre-hooks: with mutualization this question resolves itself — OMP has no new surface to maintain at all. The OMP compat layer executes the Pi extension natively (tool_call → bash-only → 05-22 review items — all five
OMP 18.0.4 discovery findings (corrected, source-verified)I went through the OMP 18.0.4 sources (
Verification
Two design questions for you, @KuSh
Where it standsRebased onto |
|
@alvins82 Thanks! I'm currently busy working toward my Ph.D. I'm glad you can continue supporting OMP RTK support and let me know. I'll close the PR. Best of luck! |




Summary
Adds Oh My Pi (OMP) as a first-class RTK CLI integration via a TypeScript extension that intercepts
tool_callevents for thebashtool and delegates command rewrite decisions tortk rewrite.rtk init --omp/rtk init -g --omp./.omp/extensions/rtk.tsfor project scope or~/.omp/agent/extensions/rtk.tsfor global scope--show,--uninstall,--dry-run, project-scoped install, and global installCloses #591.
Review cleanup
This version was rebased onto current
developto keep the PR focused on OMP only:--agent ompto--ompbecause OMP is a CLI/runtime integration, closer to OpenCode/Gemini/Codex than IDE rules-file integrationsTest plan
cargo fmt --all -- --checkcargo clippy --all-targetscargo testbun --eval 'await import("./hooks/omp/rtk.ts")'cargo run -- init --helpcargo run -- init --omp --dry-runcargo run -- init --omp --show