Repository navigation
Add Oh My Pi as a second configurable agent - #1
Conversation
9bcd5df to
ad48a63
Compare
|
Thanks for this — it's careful work, and two pieces of it fix live bugs on main, so I want the direction clear before the rebase rather than in the middle of it. Heads-up: main moved todayv0.9.6 (released an hour ago) landed five-agent support — Grok, Pi, Codex and Antigravity — and it touched a lot of the same files this PR does. This PR is based on Everything else ( What should survive the rebase exactly as written
Revision direction, in the order I'd do it
Everything else — the mapping table, the mechanism-driven wording, the tests, the docs — reads ready to go. Ping me on the rebase if any of the conflict resolution is ambiguous; happy to help with the join. |
|
Answering the one question first, then what I'm doing about the rest.
So for omp the pair really is Split done: #2 carries the two fixes — pruning by age, and the second spelling of Rebase in progress, along the lines you laid out: all six agents kept in both registries; I'll force-push the rebase onto this branch and ping you; if any join turns out ambiguous I'll ask rather than guess. |
ad48a63 to
5b15025
Compare
|
Rebased onto The joins you called out
Convergence
Payload spelling converges on what Pi's extension already sent ( One thing I did not decide for you The two configurators still recognise their own file differently: Pi on its marker plus the recorded shim path, Oh My Pi on the marker plus the recorded Heads-up, unrelated to this PR: Evidence: 542 tests ( Also: the two fixes from #2 are still contained here, so they'll drop out of this diff once #2 lands. |
5b15025 to
eecf5a7
Compare
A backup's name starts with the file it came from, so `agentpet.json.…` sorted before `settings.json.…` no matter how new it was — and the moment a second integration backed a file up into the same directory, the backup taken during that very call was the first one pruned and the path the caller had just been handed was gone. Age now comes from the filesystem, with the name only as a tiebreak inside one clock tick. Ported from #1; author CaffreySun. Co-Authored-By: CaffreySun <sunhongwei0913@163.com> Co-Authored-By: Claude Code <noreply@anthropic.com>
An in-process extension names the session `sessionId`; the capture allowlist only knew the hook spelling `session_id`, so an event spooled while the app was down replayed under a process-derived name — a second row beside the real one. Both spellings of the session id and the tool name are now captured; the list stays hand-written for the reason its comment gives (a profile's summaryField is the user's own prompt). Ported from #1; author CaffreySun. Co-Authored-By: CaffreySun <sunhongwei0913@163.com> Co-Authored-By: Claude Code <noreply@anthropic.com>
An extension that spawns the shim from inside the agent's own runtime writes to a pipe queued on an event loop the agent may be holding — measured, 30 ms of a busy loop is enough for the shim's stdin deadline to expire and the event to arrive with no session id. The shim now reads AGENTPET_PAYLOAD_BASE64 first and falls back to stdin, so the hook contract is untouched and an in-process reporter has nothing to be late for. Ported from #1; author CaffreySun. Co-Authored-By: CaffreySun <sunhongwei0913@163.com> Co-Authored-By: Claude Code <noreply@anthropic.com>
|
Quick follow-up: rather than let the fixes wait on the rebase, I've landed three pieces of this on main now — each with a regression test, and with you credited in the commit (
And So when you rebase, expect those hunks to already be present; keep the parts of your branch that build on them (the
Everything else stands as reviewed — happy to help with any of the reconciliation. |
|
Status from this side, then the rebase recipe, then the decision you asked for. Your Your lint heads-up was right, and the fault was ours. Your wording fix from #2 ( One more rebase and this is ready. The branch sits on
One line main does not have and yours needs: With that resolution: The decision you asked for: yes, fold Pi onto the shared rule — with one amendment. The rule to share is exactly what
If you would rather not hand-merge the architecture doc, say so and I will push the resolved merge as a branch you can start from — the tests above are from it. Otherwise: force-push when ready and I will run the suite on the head. |
Oh My Pi is a rebranded Pi (`@oh-my-pi/pi-coding-agent`): the same extension API, `~/.omp/agent` instead of `~/.pi/agent`. It is the first agent here whose integration is a *file* rather than an edit — it loads every `*.ts` in `~/.omp/agent/extensions/` at session start — so the runtime installs one file it owns outright: snapshot, back up, write atomically, read back, refuse to touch a file that does not carry the marker it recorded, and delete only while the recorded `// shim:` line is still in it. Two things about the integration are worth knowing before reading the diff. What it reports is the extension's own event set, so the profile maps `tool_approval_requested` to waiting (the approval gate — the counterpart of Claude Code's permission prompt) and `tool_execution_start` carrying `ask` to waitingInput (the `ask` tool *is* a question put to the user). `agent_end` is dropped by the extension itself when the payload says `willContinue` — a retry is already scheduled, so the turn has not settled. A new rule condition, `whenToolName`, exists so the narrow rule can precede the general one for the same event. The payload reaches the shim in the environment, not down a pipe. The extension runs inside the agent's own runtime, where a write to a pipe is queued on an event loop the agent may be holding: measured, 30ms of a busy stretch between spawning the shim and writing to it was enough for the shim's 20ms stdin deadline to expire, and the event then arrived with no session id at all — a row the pet could never fill. `AGENTPET_PAYLOAD_BASE64` is handed to the process by the kernel at spawn time. The stdin path is untouched, byte for byte, for Claude Code, Grok and Codex. Two defects surfaced while wiring it up, both triggered by there being a second integration in the runtime: - Backups were pruned by file name, which is chronological only while every backup in the directory came from the same file: `agentpet.ts.…` sorts before `settings.json.…` however new it is, so the backup taken during a call was the first one that call deleted, and the path it had just printed was already gone. Pruning goes by modification date now, and the new test fails against the old ordering. - The spool and event-log allowlist knew only Claude Code's `session_id` and `tool_name`, so a spooled Oh My Pi event lost its session: replaying it after a restart drew that session under a process-derived name, beside the real one. Both spellings are kept, and the test pins it. Verified against omp 18.1.22 on this machine: the file is picked up at session start (no `--extension` flag), a real session delivers `session_start / agent_start / tool_execution_start / tool_execution_end / agent_end / session_shutdown` with one session id and the working directory, the app's own verbose log shows the row `Oh My Pi · 950be5 · tmp · Needs input — ask` while a question is pending, and `--unconfigure omp` removes exactly that file and leaves the two extensions that were already there. 471 tests. The cost is stated in the installed file's header as well as in the docs: any extension handler on one of the four tool-lifecycle events turns off Oh My Pi's experimental speculative local reads (`tools.speculativeExecution.enabled`, off by default) while the file is installed; this file takes the two approval events, which is what makes an approval show as "Needs input". Not included: model, context and cost for Oh My Pi (§6.7 records why), and Pi itself stays detect-only.
Pi and Oh My Pi extend their agent the same way — one marked file the runtime owns, in a directory the agent scans — so they now share the generated file, with the event set as an explicit parameter (ExtensionTemplate). The events are the only thing that really differs, and they differ in both directions: `agent_settled` does not exist in omp 18.1.22 (checked event by event against the installed package), and a plain `agent_end` is not a settle on Pi, which may still retry or run a queued follow-up after it. One file could not be right for both, which is what the parameter encodes. Sharing the file also shares the fixes that were in only one of them: - The payload travels in the environment for both (AGENTPET_PAYLOAD_BASE64), not down a pipe — the race the Pi extension had shipped with, measured at 30ms of busy loop. - The context reading (ctx.getContextUsage() / ctx.model) is taken at every settle for both, in the one reduced shape the status-line taps use. - The write goes through ConfigTransaction.performText for both, so the Oh My Pi path no longer carries its own copy of snapshot / backup / atomic write / read-back. Field spelling converges on what Pi's extension already sent — `session_id`, `cwd`, `toolName` — so each profile has one reader and the generator has one payload builder. Six rounds of adversarial review followed, and their fixes are folded into this commit rather than left as a trail of "fix the review" commits: the cost note is per event set (it had leaked Oh My Pi's paragraph into Pi's file), the Pi half of the event-set parameter is now guarded by a test that reads the generated file, the docs stopped describing the pre-convergence world in the places this commit created, and the CLI labels one quantity the same way on every surface. Not unified yet, and worth a decision rather than a guess: the two configurators still recognise their own file differently. Pi checks its marker plus the recorded shim path; Oh My Pi checks the marker plus the recorded `// shim:` line, which is strictly stronger — that line carries both the path and the agent id. Folding Pi onto it is a one-line change to `PiConfigurator.entriesPresent`, but it changes a rule that shipped today, so it is proposed rather than taken. 542 tests. The review of this commit's delta is folded in: the generated file's comment line is comment-safe now (a path with a line separator used to end the comment and break the file, while the record still claimed it present), the cost note is no longer prefixed twice, `report()`'s payload build is wrapped again, the Pi suite pins its event set instead of deriving it from the file under test, the profile's field names are tied to both payload builders, and the docs stopped claiming Oh My Pi awaits this branch.
You asked for this and specified how, and it is the same change the review round was asking for from the other side: the docs claimed one backup policy covered every edit while Pi's uninstall wrote its own copy straight into the directory, bypassing the retention pass. - Presence and removal now ask one question for both agents: is every line the record says was written still in the file. They move together, as you asked — a file that fails presence cannot be deleted by a different rule. - Pi's record entry is the `// shim:` line from here on, defined once in `ExtensionTemplate.markerLine` and both written into the file and recorded verbatim. A v0.9.6 record needs no branch: its entry is the marker line, the old file still contains it, so it reads present and uninstalls cleanly. Both generations have tests. - Pi's uninstall backs up through `ConfigTransaction.backUp`, so the retention policy bounds it too; `PiConfigurator` no longer keeps a backup directory of its own, nor the `jsStringLiteral` only its old presence check used. - The tests that pinned the old rule were rewritten rather than dropped: a moved shim is drift because the entry carries the path, and that case fails if the rule stops reading the record (checked by breaking it). Docs: §6.7b and §8.8 describe one rule for both agents and name what still differs — the marker string, the refusal error, the cost note, the event set. Counts moved to 546. The review of this delta is folded in too: the entry `configure` records is pinned by a test, the v0.9.6 case uses the frozen literal rather than the constant it is meant to outlive, a case makes the retention policy visible (the hand-rolled backup this replaced fails it), and two texts that still described the pre-fold rule were corrected.
eecf5a7 to
d52efda
Compare
|
Rebased onto The rule is shared now. Presence and removal ask one question for both agents: is every line the record says was written still in the file. They move together, as you said — the same call decides both, so a file cannot fail presence and still be deleted by a different check. Old records need no branch, exactly as you described. A v0.9.6 record's entry is the marker line, the file it wrote still contains it, so it reads present and uninstalls cleanly; both generations have tests ( Two things fell out of doing it:
The rebase matched your table. I had already resolved the same seven files the same way before your message arrived — main's for the three ported files and their two regression tests, the converged Thanks for the lint fix, and for taking the #2 wording as The branch is force-pushed at Verification: 546 tests on |
|
Merged and released. Nothing further needed from you here. The v0.9.6-record test using the frozen literal instead of the constant is the detail I would have asked for if you had not gotten there first. |
A backup's name starts with the file it came from, so `agentpet.json.…` sorted before `settings.json.…` no matter how new it was — and the moment a second integration backed a file up into the same directory, the backup taken during that very call was the first one pruned and the path the caller had just been handed was gone. Age now comes from the filesystem, with the name only as a tiebreak inside one clock tick. Ported from #1; author CaffreySun. Co-Authored-By: CaffreySun <sunhongwei0913@163.com> Co-Authored-By: Claude Code <noreply@anthropic.com>
An in-process extension names the session `sessionId`; the capture allowlist only knew the hook spelling `session_id`, so an event spooled while the app was down replayed under a process-derived name — a second row beside the real one. Both spellings of the session id and the tool name are now captured; the list stays hand-written for the reason its comment gives (a profile's summaryField is the user's own prompt). Ported from #1; author CaffreySun. Co-Authored-By: CaffreySun <sunhongwei0913@163.com> Co-Authored-By: Claude Code <noreply@anthropic.com>
An extension that spawns the shim from inside the agent's own runtime writes to a pipe queued on an event loop the agent may be holding — measured, 30 ms of a busy loop is enough for the shim's stdin deadline to expire and the event to arrive with no session id. The shim now reads AGENTPET_PAYLOAD_BASE64 first and falls back to stdin, so the hook contract is untouched and an in-process reporter has nothing to be late for. Ported from #1; author CaffreySun. Co-Authored-By: CaffreySun <sunhongwei0913@163.com> Co-Authored-By: Claude Code <noreply@anthropic.com>
Adds Oh My Pi (
omp— upstream Pi rebranded,@oh-my-pi/pi-coding-agent) as a sixth configurable agent beside Claude Code, Grok, Codex, Pi and Antigravity. Rebased onto2421f3d; the feature and the Pi/Oh My Pi convergence are two separate commits.Why its integration has a different shape
Oh My Pi loads every
*.tsin~/.omp/agent/extensions/when a session starts — the same mechanism Pi uses — so its integration is one file the runtime owns outright rather than lines inside a file the agent owns:ConfigTransaction.performText)// shim:line the record says was written; a copy is taken firstConfigurationError.foreignFile, nothing writtenExtensionTemplateis now the one generated source for both extension-file agents, with the event set as an explicit parameter. Sharing it also shared three things that had been in one file only: the environment payload channel (AGENTPET_PAYLOAD_BASE64, so Pi's extension loses the 30ms stdin race too), the context reading at each settle, and the write path.What it reports
tool_approval_requestedtool_execution_startcarryingaskasktool is a question put to the useragent_start, tool start/end,tool_approval_resolvedagent_endwillContinueitself, which is the retry casecontext_update(sent at each settle, not listened for)session_start/session_shutdownturn_start/turn_endare deliberately unmapped (omp's turn is one model call, not one prompt).whenToolNameis the new rule condition the ask-tool mapping needs, and it reads throughEventNormalizer.string(payload, field)so a dotted path can satisfy it the way the engine reads it.agent_settleddoes not exist in omp 18.1.22 (checked against the installed package'son(...)overloads), andsession_stopis the pre-settle gate that may be followed by a continuation — so the settle isagent_endminuswillContinue. That is the one place the two event sets cannot be the same file.Two defects this work found, now on main
ConfigTransaction.pruneBackupspruned by file name, which is chronological only while one file name uses the directory — so the backup taken during a call could be the first one that call deleted, leaving the path just printed dead.f865c95, ordered by modification date.EventCapture.capturableKeysknew only one spelling of the session id, so a payload that used the other was spooled without one and replayed as a phantom row.55194e9.AGENTPET_PAYLOAD_BASE64, landed as1cb66a6, anddf57b40moved Pi's extension onto it.They are therefore not part of this diff; #2 was closed as superseded.
Verification
swift test --parallel); CI's gates run locally —swift build --build-tests, both lint scans (clean; thanks for69b37f7),Scripts/build-app.sh+plutil -lint,--selftest.node --check, including one built from a shim path containing a newline.Oh My Pi · 950be5 · tmp · Needs input — askwhile a question is pending, and--unconfigure ompremoves exactly that file.The shared ownership rule (adopted)
Presence and removal ask one question for both agents — is every line the record says was written still in the file — and they move together, so a file that fails presence cannot be deleted by a different check.
ExtensionTemplate.markerLineis the one definition of the// shim:line: the generated file writes it and Pi's record stores it verbatim. A v0.9.6 record needs no branch; its entry is the marker line, which the file it wrote still contains, and both generations have tests. Pi's uninstall backs up throughConfigTransaction.backUp, so the retention policy covers it too;backUpis internal for that reason (its doc comment says so), andPiConfiguratorlost the backup directory and thejsStringLiteralonly its old presence check used.Scope
No version, workflow or release-metadata changes; the Homebrew template's
version "__VERSION__"is untouched (its diff is the caveat, which now names both extension directories and prints--unconfigurefor claude-code, pi and omp). The hunks that look unrelated are consequences of the sixth agent: agent lists, the status tables, mechanism-driven wording (hooks:vsextension:), the glyph enumeration, and the# N testsline.Scope, one line of note:
ConfigTransaction.backUpis widened from private to internal so both extension-file configurators share one backup policy; nothing else outsideSources/,Tests/, the two READMEs,docs/ARCHITECTURE.mdand the cask caveat is touched.Not included: cost for Oh My Pi (the panel's cost item has no source; model and context now arrive), and Pi itself stays as it is on main.