Skip to content

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

Open
makoMakoGo wants to merge 4 commits intortk-ai:masterfrom
makoMakoGo:feat/omp-extension-rewrite
Open

feat(omp): add extension-based rewrite integration for Oh My Pi#1365
makoMakoGo wants to merge 4 commits intortk-ai:masterfrom
makoMakoGo:feat/omp-extension-rewrite

Conversation

@makoMakoGo
Copy link
Copy Markdown

Summary

Adds Oh My Pi (OMP) as a first-class RTK agent target via a runtime
extension that intercepts tool_call events for the bash tool and
rewrites the command through rtk rewrite.

  • New agent: rtk init --agent omp / rtk init -g --agent omp
  • Installs a self-contained TS extension to ./.omp/extensions/rtk.ts
    (project) or ~/.omp/agent/extensions/rtk.ts (global)
  • Extension is a thin delegate — all rewrite logic stays in the Rust
    registry (src/discover/registry.rs); the TS file only dispatches
    rtk rewrite and applies the result
  • Auto-rewrite on Allow / Ask-Default; Deny still blocks. Matches the
    opencode plugin's precedent of "rewrite = allow" rather than
    replicating Claude's exit-3 ask semantics in-agent
  • Startup check: if rtk is not on PATH at load time, the extension
    registers no handler and stays silent (same pattern as the opencode
    plugin's await \$\which rtk``)
  • --agent omp is mutually exclusive with --codex, --gemini,
    --opencode, --claude-md, --hook-only, --auto-patch,
    --no-patch, --copilot (validated in validate_init_target_selection)
  • Idempotent install: stock content is detected and not rewritten;
    pre-existing non-stock files are refused rather than clobbered
  • --show and --uninstall both supported and scoped to the stock
    extension marker

Closes #591.

Review changes applied

Two rounds of review before opening:

  1. Initial self-review against the OMP source at
    packages/coding-agent/src/extensibility/extensions/ to verify
    tool_call dispatch, ToolCallEventResult block semantics, and
    BashToolInput.command shape
  2. Cross-check against peer hook implementations
    (hooks/claude/rtk-rewrite.sh, hooks/cursor/rtk-rewrite.sh,
    hooks/opencode/rtk.ts) to avoid over-engineering relative to
    established RTK conventions. Peers have no spawn timeout, silent
    catch {}, and no TS tests — so those suggestions were dropped. The
    surviving fix was the startup PATH check (from opencode) replacing
    the per-call `rtkMissing` latch.

Test plan

  • `cargo fmt --all` clean
  • `cargo clippy --all-targets` — no new warnings
  • `cargo test test_omp` — 5/5 passing
    (install + idempotent + stale reject + unmanaged reject + global + project)
  • `cargo test test_validate_init_target_selection` — OMP flag
    conflicts rejected as expected
  • `bun --eval 'await import(".../hooks/omp/rtk.ts")'` loads
    cleanly (self-contained, no `@oh-my-pi/pi-coding-agent` runtime
    dependency that was causing `pi_natives` TLS failures on WSL2)
  • Live OMP session: `git status`, `ls src`, `ls -la src`
    observed to be transparently rewritten to RTK's compact output

🤖 Generated with Claude Code

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 17, 2026

CLA assistant check
All committers have signed the CLA.

makoMakoGo and others added 3 commits April 17, 2026 22:43
Mirror opencode plugin pattern: check rtk on PATH once at extension load
via Bun.which. If missing, register no tool_call handler and stay silent,
avoiding the per-call spawn cost and sticky session-wide latch flag.

Also document multi-extension chaining (downstream handlers observe the
rewritten command), Bun runtime requirement, and the startup check in
hooks/omp/README.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@makoMakoGo makoMakoGo force-pushed the feat/omp-extension-rewrite branch from abc616a to 915ef53 Compare April 17, 2026 14:46
…rewrite

# Conflicts:
#	docs/guide/getting-started/supported-agents.md
#	docs/guide/index.md
@makoMakoGo
Copy link
Copy Markdown
Author

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

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

2 participants