8000 feat(apply): add Pi platform support by ahmet-cetinkaya · Pull Request #14 · ahmet-cetinkaya/agent-ctrl · GitHub
[go: up one dir, main page]

Skip to content

feat(apply): add Pi platform support - #14

Merged
ahmet-cetinkaya merged 6 commits into
mainfrom
008-add-pi-platform
Sep 24, 2026
Merged

ahmet-cetinkaya merged 6 commits into
mainfrom
008-add-pi-platform

Conversation

@ahmet-cetinkaya
Copy link
Copy Markdown
Owner

🚀 Context

Adds Pi (@earendil-works/pi-coding-agent, https://pi.dev) as a new supported apply target, 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's CLAUDE.md), discovers native Agent-Skills-spec SKILL.md skills, and supports custom "prompt templates" that become /name slash 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/) implements IApplyPlatformAdapter, reusing existing shared sync helpers only (upsertManagedRuleDocument, syncCommandsAsMarkdownFlattened, syncSkills, syncAgentsAsSkills) — no new sync-utility or renderer contract added.
  • New PiCommandRenderer — Pi's prompt templates use description-only frontmatter (no name field; the command name is derived from the filename).
  • Agents → written into .pi/skills/ as skills, with a warning (Pi has no persona/subagent file format).
  • MCP servers → not applied, with a warning (Pi has no native MCP config surface).
  • ModelCapabilityMatrix gains a pi: { command: drop(), agent: drop(), skill: drop() } row — Pi has no per-skill/per-prompt model field (model choice is CLI/settings.json-scoped only).
  • Registered in SupportedApplyPlatform, PlatformAdapterRegistry, CommandRendererFactory — the registry's own startup validation (ADAPTER_NOT_REGISTERED) and the PlatformCustomizationSurfaceContract test enforce this is complete.
  • Full spec-kit documentation added under specs/008-add-pi-platform/ (spec, research, data-model, contracts, quickstart, plan, tasks) per this repo's existing per-feature convention (see specs/001 through specs/007).
  • README.md and new docs/platforms/PI.md updated (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, and scripts/lint.sh (TypeScript + ESLint + ShellCheck) are all green, plus a manually-run, isolated (AGENT_CTRL_HOME-scoped) end-to-end apply pi behavioral check confirming rules→AGENTS.md, commands→prompts/, native skills, agent→skill degrade+warning, and MCP skip+warning.


📋 Checklist for Reviewer

  • Tests passed locally.
  • Commit history is clean and descriptive.
  • Documentation updated (if applicable).
  • Code quality standards met (e.g., linter passed).

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.
@ahmet-cetinkaya ahmet-cetinkaya added the enhancement New feature or request label Sep 23, 2026
@ahmet-cetinkaya ahmet-cetinkaya self-assigned this Sep 23, 2026
- 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).
@ahmet-cetinkaya
ahmet-cetinkaya marked this pull request as ready for review September 24, 2026 11:39
@ahmet-cetinkaya
ahmet-cetinkaya merged commit 46708dc into main Sep 24, 2026
@ahmet-cetinkaya
ahmet-cetinkaya deleted the 008-add-pi-platform branch October 30, 2026 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0