feat(pi): add a pi target so rig delegates for real on pi.dev - #72
Merged
Merged
Conversation
pi has no built-in subagents, so rig's `agents.*` role indirection had nowhere to resolve to there — the personas could only be adopted inline. With pi-subagents installed, that indirection now becomes real delegation with isolated context per role. New `pi/` adapter: - `pi/agents/*.yml` carry frontmatter ONLY. The persona body stays in `agents/<name>.md`, shared by every target; install.sh assembles `---` + yml + `---` + body. Nothing is duplicated across trees. `pi/agents/README.md` documents the assembly contract and the full Claude -> pi mapping (tool names, dropped tools, model tier -> thinking level). - `pi/prompts/rig.md` is the `/rig <skill> [args]` dispatcher: it reads the profile, loads the skill, and applies the delegation contract — children get self-contained tasks, children don't delegate further, read-only roles stay read-only, one writer per worktree, fixed sequences go through `workflowScript` while convergence loops keep the parent session as controller. install.sh grows a `pi` adapter with `.pi/` auto-detection. It also fixes a latent bug found while adding it: the AGENTS.md pointer block was written per-target, and since it's replaced wholesale between its markers, a two-target install had the last target silently win. It's now written once, after all adapters, describing every target installed. package.json gains a `pi` manifest key, so the repo is additionally installable as a pi package (`pi install git:github.com/agent-rig/rig`) for the skills + dispatcher layer, updatable with `pi update`. Git installs run `npm install --omit=dev`, so the kit's dev toolchain does not leak into consumers. tooling/pi-adapter.test.ts guards the sync invariant the design rests on: every persona has pi frontmatter, name/description byte-identical across trees, only real pi tool names, no `subagent` for children, architect/reviewer have no write/edit, and the assembly round-trips. Verified against pi 0.84.1 + pi-subagents in a scratch project: all 11 skills and the /rig template discovered, all five personas parsed, a delegation round-trip returned, and `/rig review find` ran the whole arc (profile -> skill -> fresh-context rig-reviewer -> REVIEWER.md catalog -> scope-reviewer.ts -> triaged P0-P3 findings). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MBaTgFSa8va6PTaFfuSRsz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
pi ships with no built-in subagents — delegation is an extension you opt into. That left rig's
agents.*role indirection with nowhere to resolve on pi, so the personas could only ever be adopted inline. Withpi-subagentsinstalled, that same indirection now becomes real delegation with isolated context per role.Worth noting up front: rig's skills already worked on pi before this PR — pi scans project
.agents/skills/natively, which is exactly where theagents-mdtarget writes them. The gap was the other three layers: personas, invocation, and distribution.agents-md)pitargetsubagenttool/rig review findpi update(package path)What's in it
pi/agents/*.yml— frontmatter only. The persona body stays inagents/<name>.md, shared by every target;install.shassembles---+ yml +---+ body at install time. Nothing is duplicated across trees.pi/agents/README.mddocuments the assembly contract and the full Claude → pi mapping: lowercase tool names (Glob→find), tools with no pi equivalent dropped (WebFetch,WebSearch,TodoWrite,LSP— the bodies already treat LSP as "when available"), noTaskfor children, andmodel: opus|sonnet→thinking: high|mediumso nothing is pinned to a Claude-only model.pi/prompts/rig.md— the/rig <skill> [args]dispatcher. This is where the pairing lives. It reads the profile, loads the skill, and applies the delegation contract: children get self-contained tasks, children don't delegate further, read-only roles stay read-only, one writer per worktree, fixed sequences go throughworkflowScriptwhile convergence loops keep the parent session as controller.install.sh— apiadapter with.pi/auto-detection, plus a latent bug fix found while adding it: theAGENTS.mdpointer block was written per target, and since it's replaced wholesale between its markers, a two-target install had the last target silently win. It's now written once, after all adapters, describing every target installed.package.json— apimanifest key, so the repo is additionally installable as a pi package (pi install git:github.com/agent-rig/rig) for the skills + dispatcher layer. Git installs runnpm install --omit=dev, so the kit's dev toolchain doesn't leak into consumers.tooling/pi-adapter.test.tsguards the invariant the whole design rests on — every persona has pi frontmatter, name/description byte-identical across trees, only real pi tool names, nosubagentfor children, architect/reviewer have nowrite/edit, and the assembly round-trips.Verification
Against pi 0.84.1 +
pi-subagentsin a scratch project:/rigtemplatepi-subagentsparsed all five personas with the expected toolsrig-reviewerreturned/rig review findran the full arc: profile → skill → fresh-contextrig-reviewer→REVIEWER.mdcatalog →scope-reviewer.ts→ triaged P0–P3 findings → pointer to/rig review fixAGENTS.mdblock after three runs), and multi-target wordingbun run test: 67 pass, 0 fail.Testing changed one design decision: the dispatcher originally located skills purely by path, which fails when rig is installed as a pi package (the skill isn't at any of those paths). It now resolves from pi's Agent Skills listing first and falls back to paths.
Notes for the reviewer
bun run cifails at HEAD, unrelated to this PR.tooling/prepare-smithers-typecheck.shneedssmithers/agents.example.ts, which isn't tracked (git ls-files smithersis empty). Untouched here;bun run testpasses.pi-subagentsis third-party and on a fast cadence. Rig depends on three things from it — agent definitions in.pi/agents/, thesubagenttool, andworkflowScript. If a release moves any of those,pi/prompts/rig.mdis the single file to update..github/workflows/; no plugin model changes that.🤖 Generated with Claude Code
https://claude.ai/code/session_01MBaTgFSa8va6PTaFfuSRsz