feat(pi): first-class support via pi-subagents + pi-ask-user#651
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 58d64104f2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Resolves #449 by delegating Pi's subagent and blocking-question primitives to community extensions (pi-subagents required, pi-ask-user recommended) instead of shipping a bundled compat extension that collided with pi-subagents' `subagent` tool. - Delete `compound-engineering-compat.ts` and its mcporter / ask-user bridge code. The community pi-subagents (nicobailon) and pi-ask-user (edlsh) extensions cover the same surface without collision. - Write CE Claude agents to `.pi/agents/<name>.md` (Pi agent format) so pi-subagents resolves them by filename. New `PiGeneratedAgent` type, `agents` field on PiBundle, install-manifest agent tracking (back-compat with v2.x manifests), `cleanupRemovedAgents` + `cleanupCurrentManagedAgentFile`. - Add Pi to every skill-body platform-tool enumeration and to the plugin's AGENTS.md authoring conventions for ask-user and subagent dispatch (new Cross-Platform Sub-Agent Dispatch section). - ce-agent-native-audit: swap hardcoded `Task / subagent_type: Explore` for a per-platform enumeration (Claude `Explore`, Codex `spawn_agent` / `agent_type: "explorer"`, Pi `subagent` / `agent: "scout"`). - ce-doc-review:124: add Pi and fix pre-existing "spawn in Codex" typo to `spawn_agent`. - README documents both Pi prereqs with links to their GitHub repos. - Legacy cleanup: install-manifest diff handles the v2.x -> v3.x transition automatically; a belt-and-suspenders sweep in `cleanupKnownLegacyPiArtifacts` covers pre-manifest installs. - Frontmatter test: every `skills/*/SKILL.md` `name:` must match its parent directory and contain only `[a-z0-9-]` — catches the `ce:brainstorm` frontmatter bug that was the second half of #449. Verified end-to-end against a local Pi install: subagent dispatch resolves, parallel fan-out works, pi-subagents + pi-ask-user coexist with CE skills and agents without collision. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
58d6410 to
0199dbe
Compare
- Restore convertMcpToMcporter so plugins with mcpServers still produce Pi mcporter.json; updated pi-converter + cli tests. - Sweep stale compound-engineering/mcporter.json in cleanupKnownLegacyPiArtifacts on upgrade (guarded by plugin allowlist + current bundle check so it never deletes a just-written config); added pi-writer test. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 68b2657a02
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- Add Pi to the blocking-question enumeration at ce-debug/SKILL.md:206. The line was introduced by main's ce-debug feature commit during rebase, so the initial Pi-enumeration pass did not see it. Fix matches the existing source-side enumeration pattern (same addition the 40 earlier files received); no need to reintroduce the converter's token regex. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Pi becomes a first-class CE target on par with Claude Code and Codex: native parallel subagent dispatch, a polished blocking user-question UX, and Pi-native agent resolution. The install now delegates these primitives to two well-maintained community extensions instead of shipping our own bridge. Issue #449 (the
subagenttool collision at Pi startup) resolves as a consequence of the architectural shift, not the primary work.Before this PR, Pi users got a bundled compat extension that collided with the most popular community subagent plugin and blocked the whole install from loading. Even when it did load, dispatch ran through our homegrown
subagenttool that shelled out topi --no-session -pper call — no real parallelism, a thin question-prompt UX, and an awkward mismatch with how Pi itself expects agents to be structured.After this PR, a standard Pi install plus two one-line extension installs unlocks the same multi-agent workflows CE users already get on Claude Code and Codex. Dispatch runs as Pi-native parallel sessions. Blocking questions render through an overlay that mirrors Claude's
AskUserQuestionUX rather than a prose fallback. Our converter ships zero Pi-specific runtime TypeScript — the install is skills, agents, and a README.What Pi users get
pi --no-sessionsubprocesses via homegrown toolpi-subagents'subagenttoolctx.ui.input/ctx.ui.selectwrapperpi-ask-user.pi/skills/<name>/SKILL.md(custom lookup baked into our compat tool).pi/agents/<name>.md(Pi-native agent format, resolved by filename)Why delegate to community extensions
The Pi ecosystem has matured since we shipped our compat extension. nicobailon/pi-subagents is the dominant community subagent plugin — actively maintained, and its tool surface is a strict superset of what we shipped (adds
worktreeisolation,count: Nfan-out,chainwith{previous}templating, async runs with status inspection). edlsh/pi-ask-user ships a richer blocking-question UX than our thin wrapper (per-option descriptions, multi-select, optional comments, timeout).Rolling our own means competing with their maintenance, risking collisions indefinitely, and shipping a worse experience. Adopting them means Pi users get the same compound-engineering workflows backed by community-grade infrastructure instead of our homegrown bridge, and we stop maintaining duplicate code we never had the budget to make excellent.
Install contract
The
pi-subagentsprereq is genuinely required — skills that dispatch parallel agents (every review workflow,ce-plan,ce-brainstorm,ce-compound,ce-agent-native-audit) rely on thesubagenttool existing. Thepi-ask-userprereq is recommended — skills with blocking questions degrade gracefully to numbered-list prose when the tool isn't installed, but the overlay UX is meaningfully better.Install layout
ce-plan,ce-code-review, …)~/.pi/agent/skills/<name>/SKILL.md~/.pi/agent/skills/<name>/SKILL.md(unchanged)ce-correctness-reviewer,ce-repo-research-analyst, …)~/.pi/agent/skills/<name>/SKILL.md(wrong layout — not reachable by community subagent tools)~/.pi/agent/agents/<name>.md(Pi-native, resolved by filename)compound-engineering-compat.tsextension~/.pi/agent/extensions/compound-engineering/mcporter.jsonconfig~/.pi/agent/compound-engineering/mcpServersstill get their own config generatedOn upgrade from v2.x, the install-manifest diff sweeps the old agents-as-skills directories and the compat extension automatically. A belt-and-suspenders sweep in
cleanupKnownLegacyPiArtifactscovers pre-manifest installs and stale compound-engineeringmcporter.jsonfiles.Source-side enumeration replaces the token regex
With the token-rewrite safety net gone (
AskUserQuestion → ask_user_questiondropped fromclaude-to-pi.ts), every skill that asks a blocking question or dispatches a subagent now enumerates the Pi tool inline alongside Claude, Codex, and Gemini. The pattern matches how Codex and Gemini conversion already worked: source-side enumeration, no runtime token swap.AskUserQuestionenumeration across 40 skill files gained`ask_user` in Pi (requires the `pi-ask-user` extension).ce-doc-review/SKILL.md:124now listsAgent/spawn_agent/subagentfor subagent dispatch, and fixes a pre-existingspawn in Codex→spawn_agenttypo along the way.ce-agent-native-audit/SKILL.md:37now enumerates per-platform equivalents (Agentwithsubagent_type: Explorein Claude Code,spawn_agentwithagent_type: "explorer"in Codex,subagentwithagent: "scout"in Pi) instead of hardcoding the Claude-only form.plugins/compound-engineering/AGENTS.md(plugin authoring guide) gains a new Cross-Platform Sub-Agent Dispatch section that formalizes the enumeration pattern and the "prefer ce-shipped agents over platform built-ins" rule, with an exception for built-ins worth keeping (like Claude'sExplore).Backward compatibility
The install-manifest schema gained an
agents: string[]field. Older v2.x manifests do not have it; the reader defaults missing or invalid values to[]so the writer still validates old manifests cleanly. On upgrade, the diff-based cleanup tracks both old and new shapes without a migration step.Users on pre-manifest installs (very early CE-on-Pi adopters) get both the legacy
compound-engineering-compat.tsextension and any stalecompound-engineering/mcporter.jsonswept via hardcoded allowlists insrc/targets/pi.ts. Generic plugins that declaremcpServersstill produce a Pimcporter.jsonvia the preservedconvertMcpToMcporterpath — only the plugin-specific cleanup runs on the compound-engineering namespace.Frontmatter guard for issue #449's second bug
Issue #449 also reported
name "ce:brainstorm" does not match parent directory "ce-brainstorm". Our current source is clean (allce-*names), but a new test intests/frontmatter.test.tsasserts everyskills/*/SKILL.mdhas aname:that matches its parent directory and contains only[a-z0-9-]. Any regression to a namespaced form fails at CI rather than at a user's Pi startup.Verification
Verified end-to-end against a local Pi install at
~/.pi/agent.Post-install file layout (after upgrading from v2.68.x with 5 unrelated user skills already in place):
~/.pi/agent/agents/— 51 CE agents (ce-correctness-reviewer.md,ce-adversarial-reviewer.md,ce-repo-research-analyst.md, …).~/.pi/agent/skills/— 35 CE skills (34ce-*+lfg), down from 85 as agents-as-skills got swept.~/.pi/agent/extensions/— empty. Communitypi-subagentsandpi-ask-userlive at Pi's own extension registry, not our plugin install path.skills: 35,agents: 51,extensions: 0.agent-browser,agentcore,dogfood,electron,find-skills) not touched.Pi startup is clean. No
Failed to load extension "compound-engineering-compat.ts"error. Extensions on startup:Parallel subagent dispatch works end-to-end. Asked Pi to run
subagent(agent="ce-repo-research-analyst", task="Scope: technology. Summarize what tech stack this project uses.")three times in parallel. All three resolved to~/.pi/agent/agents/ce-repo-research-analyst.md, ran 25 to 33 seconds each with 5 to 6 tool calls each as Pi-native concurrent sessions, and produced consistent accurate repo-research output. This validates three things at once: (a)pi-subagentsresolves our agent files by filename, (b) the agent'sScope:scoped-invocation pattern survives the Pi conversion, (c) parallel fan-out runs as real concurrent sessions, not serialized subprocesses.ask_userdispatch viapi-ask-useralso fires correctly for blocking questions.Test plan
bun test— 902 tests pass.bun run release:validate— clean.