Skip to content

feat(hosts): add Pi as a new host target#846

Open
mlarabi wants to merge 1 commit intogarrytan:mainfrom
mlarabi:feat/add-pi-host
Open

feat(hosts): add Pi as a new host target#846
mlarabi wants to merge 1 commit intogarrytan:mainfrom
mlarabi:feat/add-pi-host

Conversation

@mlarabi
Copy link
Copy Markdown

@mlarabi mlarabi commented Apr 6, 2026

Summary

Add Pi as a new supported host. Pi is an open-source AI coding agent harness that uses Claude Opus under the hood, with its own skill discovery system following the Agent Skills specification.

New host config (hosts/pi.ts):

  • Paths matching Pi's skill discovery (~/.pi/agent/skills/ global, .pi/skills/ project-local)
  • Agent Skills spec compliance: 1024 char description limit, allowlist frontmatter mode
  • frontmatter.prefixName: true — Pi validates that name: matches the parent directory name (reviewgstack-review)
  • Lowercase tool name rewrites (Bashbash, Readread, AskUserQuestionask_user_question)
  • Boundary instructions include ~/.pi/ so Codex avoids reading Pi skill files
  • Self-identity rewrites where skills refer to "this Claude Code window" → "this Pi window"
  • PR footer removed (Pi doesn't inject unsolicited branding)
  • Full learnings mode (same model capabilities as Claude)
  • Co-author trailer: Claude Opus 4.6 via Pi

New config option (scripts/host-config.ts):

  • frontmatter.prefixName — when true, the name: field in generated SKILL.md is prefixed with gstack- to match the output directory name. Pi requires this at runtime; other hosts don't enforce it.

Setup script (setup):

  • --host pi accepted, pi added to auto-detect (command -v pi)
  • Step 1d: generates .pi/ skill docs via bun run gen:skill-docs --host pi
  • Step 6c: creates ~/.pi/agent/skills/gstack/ runtime root with symlinked assets (bin/, browse/dist, browse/bin, ETHOS.md, review sidecars), copies generated Pi-native SKILL.md files into ~/.pi/agent/skills/gstack-*/

Upgrade template (gstack-upgrade/SKILL.md.tmpl):

  • Detects .pi/skills/gstack (local-git) and ~/.pi/agent/skills/gstack (vendored-global) install paths
  • Vendored copy sync (Step 4.5) checks .pi/skills/gstack alongside .claude/skills/gstack

Uninstall (bin/gstack-uninstall):

  • Removes ~/.pi/agent/skills/gstack* (global Pi install)
  • Removes .pi/skills/gstack* (project-local Pi sidecar)
  • Does NOT rmdir .pi/ itself — Pi owns that directory and may have settings.json, sessions, or other state there

Infrastructure:

  • Registered in hosts/index.ts (9 hosts total)
  • .pi/ added to .gitignore
  • Host count assertion updated in tests (8 → 9)
  • Setup validation tests updated for Pi host detection
  • Golden baselines regenerated
  • Pi added to README agents table

Follows docs/ADDING_A_HOST.md step-by-step. Zero changes to the generator's core logic — only a 3-line prefixName implementation in transformFrontmatter.

Design decisions

Always prefixed — no short names for Pi

Pi validates at runtime that the name: field in SKILL.md matches the parent directory name. The generator outputs skills to gstack-* directories (e.g., gstack-review/SKILL.md), so the frontmatter must say name: gstack-review. Short names (/skill:review in a directory called review/) would require both renaming the install directory and rewriting the frontmatter during setup — fragile and not worth the complexity.

The setup script skips the prefix prompt entirely for --host pi. The check uses $HOST (available early, before INSTALL_* flags are resolved) rather than $INSTALL_PI (set later) to avoid the prompt showing before the flag exists.

Suppress gstack-relink warning for Pi

When skill_prefix: true is saved in ~/.gstack/config.yaml, gen:skill-docs prints a reminder to run gstack-relink to re-apply Claude symlink name patches. This is irrelevant for Pi (Pi doesn't use symlinks — it copies SKILL.md files). The warning is suppressed when --host pi is the active generation target.

Don't rmdir .pi/ on uninstall

Other host directories (.agents/, .factory/) are created exclusively by gstack and can be safely removed. .pi/ is owned by Pi itself and may contain settings.json, session data, or other user config. Uninstall removes gstack* entries inside .pi/skills/ but leaves the directory intact.

Boundary instructions include ~/.pi/

When Codex is invoked as a second opinion from a Pi session, the boundary instruction now tells Codex to avoid ~/.pi/ alongside ~/.claude/ and ~/.agents/. Without this, Codex could waste tokens reading Pi skill definitions.

Test Coverage

All new code paths covered by existing parameterized smoke tests that auto-pick up new hosts.

bun run scripts/host-config-export.ts validate  → All 9 configs valid
bun run skill:check                             → Pi: 35/35 skills, freshness ✅
bun test test/host-config.test.ts               → All pass (host count, uniqueness, validation)
bun test test/gen-skill-docs.test.ts            → All pass (freshness, setup validation, Pi host detection)
grep -r ".claude/skills" .pi/skills/            → No leakage

Pre-Landing Review

No issues found. One new config file (hosts/pi.ts), one new config option (prefixName), setup script Pi section, upgrade template awareness, uninstall support, and standard test/gitignore updates. No changes to existing host configs or generator core logic.

Test plan

  • bun run gen:skill-docs --host pi generates 35 skills
  • Pi SKILL.md name: fields match directory names (gstack-review, gstack-ship, etc.)
  • bun run scripts/host-config-export.ts validate — all 9 configs valid
  • bun run skill:check — Pi: 35/35 skills, 0 missing, freshness ✅
  • bun test test/host-config.test.ts — all pass
  • bun test test/gen-skill-docs.test.ts — all pass (including setup Pi validation)
  • grep -r ".claude/skills" .pi/skills/ — empty (no path leakage)
  • bun run build — full build succeeds
  • ./setup --host pi — no prefix prompt, installs to ~/.pi/agent/skills/, Pi discovers all 35 skills
  • ./bin/gstack-uninstall — lists Pi paths in confirmation, removes gstack* entries, preserves .pi/

@mlarabi mlarabi force-pushed the feat/add-pi-host branch 6 times, most recently from 17149c7 to 5574d80 Compare April 6, 2026 06:49
Add Pi (https://github.com/mariozechner/pi-coding-agent) as a supported
host. Pi uses Claude Opus under the hood with its own skill discovery
system (~/.pi/agent/skills/ global, .pi/skills/ project-local).

Changes:
- hosts/pi.ts: Pi host config with Agent Skills spec compliance
  (1024 char description limit, allowlist frontmatter, prefixName),
  lowercase tool name rewrites, boundary instructions including ~/.pi/
  for Codex isolation, self-identity rewrites, full learnings mode
- scripts/host-config.ts: add frontmatter.prefixName option — Pi
  requires name: field to match parent directory (gstack-review, etc.)
- scripts/gen-skill-docs.ts: implement prefixName in transformFrontmatter
- hosts/index.ts: register Pi (9 hosts total)
- .gitignore: add .pi/
- setup: add Pi host support (--host pi, auto-detect, generate .pi/
  skill docs, install to ~/.pi/agent/skills/ with runtime asset
  symlinks and copied SKILL.md files). Skip prefix prompt for Pi-only
  installs — Pi always uses gstack-* names (name: must match dirname).
- gstack-upgrade/SKILL.md.tmpl: detect .pi/ install paths for upgrades
- test/host-config.test.ts: update host count assertion (8 → 9)
- test/gen-skill-docs.test.ts: update setup validation for pi host
- test/fixtures/golden/: regenerate baselines
- README.md: add Pi to agents table
@mlarabi mlarabi force-pushed the feat/add-pi-host branch from 5574d80 to 00f506b Compare April 6, 2026 06:51
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