Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(pi): first-class support via pi-subagents + pi-ask-user#651

Merged
tmchow merged 3 commits into
mainfrom
tmchow/pi-subagent-research
Apr 22, 2026
Merged

feat(pi): first-class support via pi-subagents + pi-ask-user#651
tmchow merged 3 commits into
mainfrom
tmchow/pi-subagent-research

Conversation

@tmchow
Copy link
Copy Markdown
Collaborator

@tmchow tmchow commented Apr 22, 2026

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 subagent tool 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 subagent tool that shelled out to pi --no-session -p per 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 AskUserQuestion UX 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

Capability Before After
Parallel subagent dispatch Serialized pi --no-session subprocesses via homegrown tool Native parallel sessions via pi-subagents' subagent tool
Blocking user questions Thin ctx.ui.input / ctx.ui.select wrapper Rich overlay with options, descriptions, multi-select, freeform fallback via pi-ask-user
Agent resolution .pi/skills/<name>/SKILL.md (custom lookup baked into our compat tool) .pi/agents/<name>.md (Pi-native agent format, resolved by filename)
Plugin-shipped Pi extensions 1 (the source of the #449 collision) 0

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 worktree isolation, count: N fan-out, chain with {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

pi install npm:pi-subagents    # required — provides `subagent` for parallel agent dispatch
pi install npm:pi-ask-user     # recommended — provides `ask_user`; skills fall back to numbered prose when absent
bunx @every-env/compound-plugin install compound-engineering --to pi

The pi-subagents prereq is genuinely required — skills that dispatch parallel agents (every review workflow, ce-plan, ce-brainstorm, ce-compound, ce-agent-native-audit) rely on the subagent tool existing. The pi-ask-user prereq 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

Artifact Before After
CE skills (ce-plan, ce-code-review, …) ~/.pi/agent/skills/<name>/SKILL.md ~/.pi/agent/skills/<name>/SKILL.md (unchanged)
CE agents (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.ts extension ~/.pi/agent/extensions/ removed
compound-engineering/mcporter.json config ~/.pi/agent/compound-engineering/ swept on upgrade (compound-engineering ships no MCP servers); other plugins declaring mcpServers still get their own config generated

On 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 cleanupKnownLegacyPiArtifacts covers pre-manifest installs and stale compound-engineering mcporter.json files.

Source-side enumeration replaces the token regex

With the token-rewrite safety net gone (AskUserQuestion → ask_user_question dropped from claude-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.

  • Every AskUserQuestion enumeration across 40 skill files gained `ask_user` in Pi (requires the `pi-ask-user` extension).
  • ce-doc-review/SKILL.md:124 now lists Agent / spawn_agent / subagent for subagent dispatch, and fixes a pre-existing spawn in Codexspawn_agent typo along the way.
  • ce-agent-native-audit/SKILL.md:37 now enumerates per-platform equivalents (Agent with subagent_type: Explore in Claude Code, spawn_agent with agent_type: "explorer" in Codex, subagent with agent: "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's Explore).

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.ts extension and any stale compound-engineering/mcporter.json swept via hardcoded allowlists in src/targets/pi.ts. Generic plugins that declare mcpServers still produce a Pi mcporter.json via the preserved convertMcpToMcporter path — 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 (all ce-* names), but a new test in tests/frontmatter.test.ts asserts every skills/*/SKILL.md has a name: 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 (34 ce-* + lfg), down from 85 as agents-as-skills got swept.
  • ~/.pi/agent/extensions/ — empty. Community pi-subagents and pi-ask-user live at Pi's own extension registry, not our plugin install path.
  • Install manifest reports skills: 35, agents: 51, extensions: 0.
  • 5 user-owned symlinked skills (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:

[Extensions]
  pi-ask-user, pi-subagents, pi-subagents:notify.ts

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-subagents resolves our agent files by filename, (b) the agent's Scope: scoped-invocation pattern survives the Pi conversion, (c) parallel fan-out runs as real concurrent sessions, not serialized subprocesses.

ask_user dispatch via pi-ask-user also fires correctly for blocking questions.

Test plan

  • bun test — 902 tests pass.
  • bun run release:validate — clean.
  • End-to-end verification on a real Pi install is captured above.

Compound Engineering
Claude Code

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/converters/claude-to-pi.ts
Comment thread src/targets/pi.ts
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]>
@tmchow tmchow force-pushed the tmchow/pi-subagent-research branch from 58d6410 to 0199dbe Compare April 22, 2026 17:03
- 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]>
@tmchow tmchow changed the title fix(pi): drop compat extension, relocate agents for pi-subagents fix(pi): official Pi support relying on community subagent extension Apr 22, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/converters/claude-to-pi.ts
@tmchow tmchow changed the title fix(pi): official Pi support relying on community subagent extension feat(pi): first-class support via pi-subagents + pi-ask-user Apr 22, 2026
- 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]>
@tmchow tmchow merged commit 7ddfbed into main Apr 22, 2026
2 checks passed
This was referenced Apr 22, 2026
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.

1 participant