Repository navigation
feat(apply): add Pi platform support - #14
Merged
Merged
Conversation
Adds support for Pi (@earendil-works/pi-coding-agent, pi.dev) as an apply target: rules sync to AGENTS.md, commands render as prompt templates under prompts/, and skills copy natively into skills/. Pi has no persona/subagent concept, so agents degrade to skills with a warning (mirroring the Cursor and Windsurf precedent); it also has no native MCP config surface, so MCP servers are skipped with a warning. Model frontmatter is dropped for all artifact kinds since Pi has no per-skill/per-prompt model field.
Documents the already-implemented Pi adapter (008-add-pi-platform) following this repo's per-feature spec-kit convention: spec, research, data-model, contracts, quickstart, plan, and tasks — retroactively recording the decisions and behavior already verified by the implementation commit.
- PiCommandRenderer: recover description/argument-hint from malformed frontmatter that is missing its opening `---` but has a closing one, instead of discarding the user's fields and dumping the raw lines into the body under an id-derived description (matches the ForgeCode/ OpenCode precedent for the same malformed-frontmatter shape). - PiAdapter.test.ts: assert the actual .pi/prompts/fix-lint.md and .pi/skills/architect/SKILL.md files (not just directory existence or warning text) so the command→prompt and agent→skill-degrade paths are covered by real file evidence. - Add PiCommandRenderer.test.ts following the existing per-renderer test convention, including a regression test for the malformed-frontmatter fix (confirmed red before the fix, green after). Also includes cosmetic prettier table realignment in two 008 spec docs.
Pi has no native MCP configuration surface, but the most popular community
extension (pi-mcp-adapter, ~1M npm downloads/month) reads project- and
user-scope .mcp.json files. PiAdapter now checks Pi's own package manifest
(packages: [{ source: "npm:pi-mcp-adapter" }] in .pi/settings.json or
~/.pi/agent/settings.json) before deciding what to do with MCP servers:
- Detected -> write to .mcp.json / <userRoot>/mcp.json in the standard
{ mcpServers: {...} } shape (new PiMcpConfigRenderer), no warning, and
the apply message notes "(via pi-mcp-adapter)".
- Not detected -> unchanged fallback: drop with the existing warning
naming the extension and its install command.
Detection is file-based and best-effort (it cannot observe Pi's live
"project trust" runtime state), and never throws on a missing or
malformed settings.json. Scoped to MCP only, per explicit request;
pi-subagents/agents still only get named in the warning.
Mirrors the pi-mcp-adapter detection pattern for agents: PiAdapter now checks Pi's package manifest for pi-subagents (~455K npm downloads/month) before deciding how to handle agent personas. - Detected -> write natively to .pi/agents/<id>.md / <userRoot>/agents/<id>.md via a new PiAgentRenderer (name always corrected to the true id; description only filled in when missing, never overwriting an existing user-authored value; tools/model/systemPromptMode preserved verbatim). No warning; the apply message notes "agents via pi-subagents". .pi/agents/ is now also cleaned on --override. - Not detected -> unchanged fallback: agents degrade to skills with the existing warning naming the extension and its install command. Reuses the same isPackageInstalled() helper added for MCP, just with a different package name -- detection logic is unchanged. Deliberately does not flip ModelCapabilityMatrix["pi"].agent away from drop(): pi-subagents' expected model value format isn't confirmed against agent-ctrl's canonical provider/model-id, so no model field is written or transformed for this surface (an existing one is preserved as-is). A regression caught during PiAgentRenderer's own tests: the frontmatter updater (modeled on ForgeCodeAgentRenderer) was unconditionally overwriting an already-authored `description` with a derived fallback; fixed to only fill in description when absent, matching the precedent already set for PiCommandRenderer.
- PiAdapter override cleanup no longer runs during --dry-run: a dry-run preview must not delete real .pi/prompts, .pi/skills, or .pi/agents files (the CLI allows --dry-run and --override together). - ModelCapabilityMatrix["pi"].agent is now passthrough() instead of drop(): the agent kind is only ever routed through syncAgentsAsMarkdown when pi-subagents is detected, and that extension's model field expects the same provider/model-id shape as agent-ctrl's canonical value — so the field was being silently deleted by applyModelFrontmatter before PiAgentRenderer ever ran, contradicting the renderer's own preserve-verbatim behavior and the shipped docs. README and docs/platforms/PI.md updated to match. - PiAdapter now resolves the user config root via Pi's own documented PI_CODING_AGENT_DIR env var (falling back to ~/.pi/agent), instead of silently ignoring it when no --path override is given. - PiCommandRenderer/PiAgentRenderer's malformed-frontmatter recovery no longer mistakes a body that starts with a "key: value"-looking line and later contains a horizontal rule (e.g. "Time: 10 min\n\nDo the thing.\n\n---\n\nNotes.") for real frontmatter — recovery now requires every line before the closing --- to be a YAML property. - PiMcpConfigRenderer now extends ForgeCodeMcpConfigRenderer instead of duplicating its mcpServers-merge logic byte-for-byte. - artifactCounts.mcpServers reports 0 (not the source count) when pi-mcp-adapter is absent and servers were dropped with a warning, so the CLI's "Artifacts:" summary no longer implies servers were applied when they weren't. - syncCommandsAsMarkdownFlattened (shared with ForgeCodeAdapter) now warns when flattening causes two differently-namespaced commands to collide on the same output filename, instead of silently letting the last one win. - docs/platforms/PI.md corrected: plain `apply pi` defaults to user scope like every other platform, not project scope. Regression tests added for each behavioral fix (dry-run+override, PI_CODING_AGENT_DIR, horizontal-rule-in-body for both renderers, model passthrough, and the zero-mcpServers-count case).
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.
🚀 Context
Adds Pi (
@earendil-works/pi-coding-agent, https://pi.dev) as a new supportedapplytarget, alongside the existing 10 platforms (Claude, Codex, Cursor, ForgeCode, Gemini, Kilo, OpenCode, Qwen, Windsurf, Antigravity).Pi reads project instructions from
AGENTS.md(also aliases Claude'sCLAUDE.md), discovers native Agent-Skills-specSKILL.mdskills, and supports custom "prompt templates" that become/nameslash commands. It has no first-class agent/persona file format and no native MCP configuration surface — both degrade gracefully with an explicit warning, mirroring the existing Cursor/Windsurf precedent for "no silent data loss."Note
Full design rationale (7 documented decisions, each backed by Pi's official docs) is in
specs/008-add-pi-platform/research.md.🔗 Related
⚙️ Implementation Details
PiAdapter(src/infrastructure/features/pi/adapters/) implementsIApplyPlatformAdapter, reusing existing shared sync helpers only (upsertManagedRuleDocument,syncCommandsAsMarkdownFlattened,syncSkills,syncAgentsAsSkills) — no new sync-utility or renderer contract added.PiCommandRenderer— Pi's prompt templates usedescription-only frontmatter (nonamefield; the command name is derived from the filename)..pi/skills/as skills, with a warning (Pi has no persona/subagent file format).ModelCapabilityMatrixgains api: { command: drop(), agent: drop(), skill: drop() }row — Pi has no per-skill/per-prompt model field (model choice is CLI/settings.json-scoped only).SupportedApplyPlatform,PlatformAdapterRegistry,CommandRendererFactory— the registry's own startup validation (ADAPTER_NOT_REGISTERED) and thePlatformCustomizationSurfaceContracttest enforce this is complete.specs/008-add-pi-platform/(spec, research, data-model, contracts, quickstart, plan, tasks) per this repo's existing per-feature convention (seespecs/001throughspecs/007).README.mdand newdocs/platforms/PI.mdupdated (supported-platform badge, model-frontmatter matrix row, settings validation list).Important
Purely additive — no existing platform's adapter code, renderer, or output changed.
bun test(1036 pass / 0 fail),bunx tsc --noEmit, andscripts/lint.sh(TypeScript + ESLint + ShellCheck) are all green, plus a manually-run, isolated (AGENT_CTRL_HOME-scoped) end-to-endapply pibehavioral check confirming rules→AGENTS.md, commands→prompts/, native skills, agent→skill degrade+warning, and MCP skip+warning.📋 Checklist for Reviewer