Skip to content

armgit / agtx

Public Imported from GitHub
0

πŸ„πŸΌβ€β™‚οΈ The blackboard for coding agents - agentic development environment for claude code, codex, cursor, opencode, grok and more.

feat: add pi (rebase of #135 onto the AgentSpec table) (#142)

Max Wengd84ba08a5e57
diff --git a/CLAUDE.md b/CLAUDE.md
index f964d41..0a26043 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -172,7 +172,7 @@ Plugins customize the task lifecycle per phase. A plugin is a TOML file (`plugin
- **copy_files**: Individual files to copy from project root into worktrees (merged with project-level `copy_files`)
- **copy_back**: Files/dirs to copy from worktree back to project root when a phase completes
- **cyclic**: When true, enables Review β†’ Planning transition with incrementing phase counter (`p` on the board)
-- **clear_context_on_advance**: When true, send an agent-specific clear-context command before the phase skill/prompt on transitions (only Claude Code's `/clear` is honored today)
+- **clear_context_on_advance**: When true, send an agent-specific clear-context command before the phase skill/prompt on transitions. Honored for the agents whose `clear_context_command` is verified β€” Claude's `/clear` and pi's `/new` β€” and a no-op for the rest (issue #46). Delivery follows the agent's `send_strategy`: an Ink-class composer drops a combined text+Enter `send_keys`, and the parked text would then be concatenated with the skill+prompt into one unusable message, so those agents get the same paste-and-confirm path the message itself takes
- **supported_agents**: Agent whitelist (empty = all supported)
- **auto_dismiss**: Rules to auto-dismiss interactive prompts before sending the task prompt
@@ -208,8 +208,9 @@ Canonical copy always at `.agtx/skills/agtx-plan/SKILL.md`.
| grok | `.grok/config.toml` | TOML, `[mcp_servers.agtx]` |
| antigravity | `.agents/mcp_config.json` | JSON, `mcpServers` |
| opencode | opencode config | JSON, `mcp` |
+| pi | `.pi/mcp.json` | JSON, `mcpServers` |
-Three writers **merge** instead of overwriting, because their file may already exist in the worktree β€” either tracked in the repo, or copied in from the project root by `AGENT_CONFIG_DIRS`. Grok appends `[mcp_servers.agtx]` to any existing `.grok/config.toml`; antigravity parses `.agents/mcp_config.json` and inserts `mcpServers.agtx`, preserving other servers and top-level sibling keys (`.agents/` is vendor-neutral, so a project is more likely to ship one); gemini inserts into `.gemini/settings.json`, which otherwise loses the user's theme, model and any other `mcpServers`. Claude's `settings.local.json` side-effect below merges for the same reason.
+Four writers **merge** instead of overwriting, because their file may already exist in the worktree β€” either tracked in the repo, or (for `.gemini`, `.grok` and `.agents`) copied in from the project root by `AGENT_CONFIG_DIRS`; `.pi` is not in that list, so only the tracked-in-the-repo half applies to it. Grok appends `[mcp_servers.agtx]` to any existing `.grok/config.toml`; antigravity parses `.agents/mcp_config.json` and inserts `mcpServers.agtx`, preserving other servers and top-level sibling keys (`.agents/` is vendor-neutral, so a project is more likely to ship one); gemini inserts into `.gemini/settings.json`, which otherwise loses the user's theme, model and any other `mcpServers`; pi's `.pi/mcp.json` is where the `pi-mcp-adapter` package persists its own per-server `disabled` flags, so clobbering it re-enables servers the user switched off. pi has no MCP client of its own β€” without that package the file is inert, not harmful. Claude's `settings.local.json` side-effect below merges for the same reason.
Claude needs an extra side-effect to avoid an interactive dialog on first open: `.claude/settings.local.json` gets `enableAllProjectMcpServers: true` plus `skipDangerousModePermissionPrompt: true`, which is what actually preflights the bypass-permissions warning (see the dialog table).
@@ -242,7 +243,7 @@ Two consequences worth knowing: `resolve_skill_command(collapse: false)` is used
**Mid-session lane β€” phase advances into an already-running agent.** `send_skill_and_prompt()`, three paths, because agent TUIs disagree about how a slash command plus arguments must arrive:
1. **opencode** β€” its picker strips arguments if the whole string is typed at once. So: send the bare command name β†’ wait for the picker β†’ Enter (inserts it) β†’ send the args β†’ Enter. Still on the typed path: it is the one flow where the text has to arrive in two pieces by design
-2. **gemini / codex / cursor / antigravity** β€” skill + prompt combined into a *single* message delivered by **bracketed paste** (`paste_text`), then one Enter. The paste is atomic, so the old poll-until-it-renders step is gone, and the `\n\n` joining command to prompt stays literal text instead of arriving as a real Enter that submits the message half-written. Gemini executes-and-loses a separately sent prompt; Codex's `$skill` mentions are inline references that do nothing when sent standalone. **How many Enters this takes is not fixed** β€” see *Submitting is its own delivery problem* below
+2. **gemini / codex / cursor / antigravity / pi** β€” skill + prompt combined into a *single* message delivered by **bracketed paste** (`paste_text`), then one Enter. The paste is atomic, so the old poll-until-it-renders step is gone, and the `\n\n` joining command to prompt stays literal text instead of arriving as a real Enter that submits the message half-written. Gemini executes-and-loses a separately sent prompt; Codex's `$skill` mentions are inline references that do nothing when sent standalone; pi's composer takes a paste as literal text but leaves a combined text+Enter `send_keys` sitting unsent. **How many Enters this takes is not fixed** β€” see *Submitting is its own delivery problem* below
3. **everything else** (claude, copilot, grok) β€” the generic `match (skill_cmd, prompt_trigger)` path using `send_keys`, waiting on `prompt_triggers` between the command and the prompt when configured
**Submitting is its own delivery problem.** A message with a prompt after the command submits on the first Enter. A **bare skill command** β€” what a phase whose command carries no `{task}`/`{task_id}` sends, which is `review` β€” exactly matches a skill name, so the composer's command picker opens *on the paste*. That Enter is then consumed by the picker ("Press enter to insert"), which inserts the command and repaints, leaving it parked. Measured against codex-cli 0.144.5 and cursor-agent 2026.08.25: both open the picker on a pasted bare command, and both submit on the second Enter.
@@ -274,7 +275,7 @@ Measured per agent (see `src/agent/trust.rs` for the table and the versions):
- **Trust is inherited from the project root** for claude, codex and gemini β€” the default
`worktree_dir` is inside the project, so a user who opened the agent there once never sees the
- prompt again. cursor and grok are launched with `--trust`; opencode has no trust gate.
+ prompt again. cursor and grok are launched with `--trust`, and pi with `--approve`; opencode has no trust gate. pi's flag does double duty: it is also what lets it load the `.pi/skills/` agtx wrote into the worktree, since pi gates project-local skills on the same trust decision.
- **antigravity is the exception**: it matches trusted paths *exactly*, at any depth. agtx seeds
each new worktree into its `trustedWorkspaces` β€” but only when the project root is already there,
so it replays a consent the user gave rather than creating one.
@@ -687,7 +688,7 @@ pane-hash heuristic β€” is a supported state, not a degraded one.
| grok | `.grok/hooks/agtx.json` | `{hooks:[{type,command}]}` | `hookEventName`, **snake_case value** | yes β€” `Notification` scoped to `permission_prompt` |
| antigravity | `.agents/hooks.json` | keyed by hook *name*, then event | **none** β€” passed as `--event` | no |
| codex | `.codex/hooks.json` | `{description, hooks:{…}}` | `hook_event_name`, PascalCase | mapped, **not deployed** |
-| opencode, copilot | β€” | β€” | β€” | no hooks; see `HookConfigKind` |
+| opencode, copilot, pi | β€” | β€” | β€” | no hooks; see `HookConfigKind` |
The formats are **not interchangeable**, and every mismatch below fails silently β€” a valid-looking
config in the worktree and no status file ever written. This is why `tests/smoke/agent_smoke.py` is
diff --git a/Cargo.lock b/Cargo.lock
index efed45c..0115781 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4,7 +4,7 @@ version = 4
[[package]]
name = "agtx"
-version = "1.0.0"
+version = "1.0.1"
dependencies = [
"anyhow",
"chrono",
diff --git a/README.md b/README.md
index d8b086c..7337b5c 100644
--- a/README.md
+++ b/README.md
@@ -57,6 +57,7 @@
<a href="https://github.com/google-antigravity/antigravity-cli"><kbd><img src="docs/logos/antigravity.png" width="18" valign="middle" /> Antigravity</kbd></a>
<a href="https://github.com/google-gemini/gemini-cli"><kbd><img src="docs/logos/gemini.svg" width="18" valign="middle" /> Gemini CLI</kbd></a>
<a href="https://github.com/github/copilot-cli"><kbd><img src="docs/logos/copilot-dark.svg" width="18" valign="middle" /> Copilot</kbd></a>
+<a href="https://github.com/earendil-works/pi"><kbd><img src="docs/logos/pi-dark.svg" width="18" valign="middle" /> pi</kbd></a>
- **Multi-agent task lifecycle**: Configure different agents per workflow phase β€” e.g. Gemini for research, Claude for implementation, Codex for review β€” with automatic agent switching.
- **Multi-project dashboard**: Manage agent sessions across all projects via a single TUI.
- **Parallel execution**: Every task gets its own git worktree and tmux window β€” run as many agents as needed, simultaneously.
@@ -342,6 +343,21 @@ cp skills/sweep/SKILL.md ~/.gemini/antigravity-cli/skills/agtx-sweep/SKILL.md
</details>
+<details>
+<summary><strong>pi</strong></summary>
+
+pi has no MCP client of its own β€” the `pi-mcp-adapter` package provides one and
+reads servers in the standard `mcpServers` shape:
+
+```bash
+mkdir -p ~/.pi/skills/agtx-sweep && cp skills/sweep/SKILL.md ~/.pi/skills/agtx-sweep/SKILL.md
+```
+
+Register `agtx mcp-serve` with the adapter, then in any pi session:
+`/skill:agtx-sweep` / `/skill:agtx-brainstorm`
+
+</details>
+
<details>
<summary><strong>Other</strong></summary>
@@ -453,21 +469,21 @@ Press `P` to switch plugins. Ships with 10 built-in:
Commands are written once in canonical format and automatically translated per agent:
-| Canonical (plugin.toml) | Claude / Gemini | Codex | OpenCode | Cursor | Grok | Antigravity |
-|--------------------------|-----------------|-------|----------|--------|------|-------------|
-| `/agtx:plan` | `/agtx:plan` | `$agtx-plan` | `/agtx-plan` | `/agtx-plan` | `/agtx-plan` | `/agtx-plan` |
-
-| | Claude | Codex | Gemini | OpenCode | Cursor | Copilot | Grok | Antigravity |
-|--|:------:|:-----:|:------:|:--------:|:------:|:-------:|:----:|:-----------:|
-| **agtx** | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… | βœ… |
-| **gsd** | βœ… | βœ… | βœ… | βœ… | βœ… | ❌ | βœ… | ❌ |
-| **spec-kit** | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… | βœ… |
-| **openspec** | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… | βœ… |
-| **bmad** | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… | βœ… |
-| **superpowers** | βœ… | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
-| **oh-my-claudecode** | βœ… | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
-| **agent-skills** | βœ… | 🟑 | 🟑 | 🟑 | 🟑 | 🟑 | 🟑 | 🟑 |
-| **void** | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
+| Canonical (plugin.toml) | Claude / Gemini | Codex | OpenCode | Cursor | Grok | Antigravity | pi |
+|--------------------------|-----------------|-------|----------|--------|------|-------------|----|
+| `/agtx:plan` | `/agtx:plan` | `$agtx-plan` | `/agtx-plan` | `/agtx-plan` | `/agtx-plan` | `/agtx-plan` | `/skill:agtx-plan` |
+
+| | Claude | Codex | Gemini | OpenCode | Cursor | Copilot | Grok | Antigravity | pi |
+|--|:------:|:-----:|:------:|:--------:|:------:|:-------:|:----:|:-----------:|:--:|
+| **agtx** | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… | βœ… | βœ… |
+| **gsd** | βœ… | βœ… | βœ… | βœ… | βœ… | ❌ | βœ… | ❌ | ❌ |
+| **spec-kit** | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… | βœ… | 🟑 |
+| **openspec** | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… | βœ… | 🟑 |
+| **bmad** | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… | βœ… | 🟑 |
+| **superpowers** | βœ… | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
+| **oh-my-claudecode** | βœ… | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
+| **agent-skills** | βœ… | 🟑 | 🟑 | 🟑 | 🟑 | 🟑 | 🟑 | 🟑 | 🟑 |
+| **void** | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
βœ… Skills, commands, and prompts fully supported Β· 🟑 Prompt only, no interactive skill support Β· ❌ Not supported
diff --git a/docs/logos/pi-dark.svg b/docs/logos/pi-dark.svg
new file mode 100644
index 0000000..03fc1d7
--- /dev/null
+++ b/docs/logos/pi-dark.svg
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg width="256px" height="256px" viewBox="0 0 256 256" version="1.1" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid">
+ <title>pi</title>
+ <g>
+ <path d="M0,0 L192,0 L192,128 L128,128 L128,192 L64,192 L64,256 L0,256 Z M64,64 L64,128 L128,128 L128,64 Z" fill="#FFFFFF" fill-rule="evenodd"></path>
+ <path d="M192,128 L256,128 L256,256 L192,256 Z" fill="#FFFFFF"></path>
+ </g>
+</svg>
diff --git a/docs/logos/pi.svg b/docs/logos/pi.svg
new file mode 100644
index 0000000..8c1bb9a
--- /dev/null
+++ b/docs/logos/pi.svg
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg width="256px" height="256px" viewBox="0 0 256 256" version="1.1" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid">
+ <title>pi</title>
+ <g>
+ <path d="M0,0 L192,0 L192,128 L128,128 L128,192 L64,192 L64,256 L0,256 Z M64,64 L64,128 L128,128 L128,64 Z" fill="#000000" fill-rule="evenodd"></path>
+ <path d="M192,128 L256,128 L256,256 L192,256 Z" fill="#000000"></path>
+ </g>
+</svg>
diff --git a/src/agent/spec.rs b/src/agent/spec.rs
index a553218..cbeb6cb 100644
--- a/src/agent/spec.rs
+++ b/src/agent/spec.rs
@@ -58,6 +58,11 @@ pub enum CommandSyntax {
Hyphen,
/// `$ns-command` β€” Codex's inline skill reference.
Dollar,
+ /// `/skill:ns-command` β€” pi's skill commands live in one `skill:` namespace
+ /// of their own, so the plugin's namespace collapses into the skill *name*
+ /// (`/agtx:plan` β†’ `/skill:agtx-plan`) rather than staying a prefix.
+ /// Verified against pi 0.84.3.
+ PiSkill,
/// No interactive skill invocation; callers fall back to a file-path
/// reference. Copilot, and any agent agtx has not been taught.
None,
@@ -168,6 +173,11 @@ pub enum McpConfigKind {
AntigravityJsonMerge,
/// `opencode.json`, whose key is `mcp` and whose entry shape differs.
OpenCode,
+ /// `.pi/mcp.json` β€” parsed, agtx inserted, written back, so other servers
+ /// survive. pi has no MCP client of its own; the `pi-mcp-adapter` package
+ /// reads this path as its highest-precedence project layer, and without the
+ /// adapter installed the file is inert rather than harmful.
+ PiJsonMerge,
}
/// Where and how an agent's lifecycle-hook config is written, and which event
@@ -291,6 +301,16 @@ pub struct AgentSpec {
/// Needed for agents that run inside bash/node and so never show their own
/// name in `pane_current_command`.
pub active_indicators: &'static [&'static str],
+ /// Readiness needles that count **only in this agent's own pane**.
+ ///
+ /// [`active_indicators`](Self::active_indicators) is also matched against
+ /// panes whose agent is unknown, flattened across every spec, so a needle
+ /// that occurs in ordinary output would report an exited agent as still
+ /// running. pi has no startup banner β€” the one unconditional part of its
+ /// footer is the context display (`0.0%/1.0M`), giving `%/`, which also
+ /// occurs in text like `Coverage: 85%/90%`. Such a needle goes here: used
+ /// when agtx knows the pane runs this agent, ignored otherwise.
+ pub scoped_indicators: &'static [&'static str],
/// Command that makes the agent exit cleanly, or `None` when Ctrl+C is the
/// only way out.
pub exit_command: Option<&'static str>,
@@ -347,6 +367,7 @@ pub const AGENT_SPECS: &[AgentSpec] = &[
hook_event_source: HookEventSource::Payload,
process_names: &["claude"],
active_indicators: &["Claude Code"],
+ scoped_indicators: &[],
exit_command: Some("/exit"),
label_fg: (227, 148, 62), // orange
label_bg: None,
@@ -444,6 +465,7 @@ pub const AGENT_SPECS: &[AgentSpec] = &[
hook_event_source: HookEventSource::Payload,
process_names: &["codex"],
active_indicators: &["OpenAI Codex"],
+ scoped_indicators: &[],
exit_command: None,
label_fg: (255, 255, 255), // white on black
label_bg: Some((20, 20, 20)),
@@ -535,6 +557,7 @@ pub const AGENT_SPECS: &[AgentSpec] = &[
hook_event_source: HookEventSource::Payload,
process_names: &["copilot"],
active_indicators: &[],
+ scoped_indicators: &[],
exit_command: Some("/exit"),
label_fg: (255, 255, 255), // default white
label_bg: None,
@@ -576,6 +599,7 @@ pub const AGENT_SPECS: &[AgentSpec] = &[
hook_event_source: HookEventSource::Payload,
process_names: &["gemini"],
active_indicators: &["Type your message"],
+ scoped_indicators: &[],
exit_command: Some("/quit"),
label_fg: (234, 130, 180), // pink
label_bg: None,
@@ -630,6 +654,7 @@ pub const AGENT_SPECS: &[AgentSpec] = &[
hook_event_source: HookEventSource::Payload,
process_names: &["opencode"],
active_indicators: &["Ask anything"],
+ scoped_indicators: &[],
exit_command: Some("/exit"),
label_fg: (255, 255, 255), // white on grey
label_bg: Some((80, 80, 80)),
@@ -667,6 +692,7 @@ pub const AGENT_SPECS: &[AgentSpec] = &[
hook_event_source: HookEventSource::Payload,
process_names: &["agent"],
active_indicators: &["Cursor Agent"],
+ scoped_indicators: &[],
exit_command: None,
label_fg: (255, 255, 255), // default white
label_bg: None,
@@ -722,6 +748,7 @@ pub const AGENT_SPECS: &[AgentSpec] = &[
hook_event_source: HookEventSource::Payload,
process_names: &["grok"],
active_indicators: &["Grok Build", "Shift+Tab:mode"],
+ scoped_indicators: &[],
exit_command: Some("/quit"),
label_fg: (20, 20, 20), // black on white
label_bg: Some((255, 255, 255)),
@@ -776,6 +803,7 @@ pub const AGENT_SPECS: &[AgentSpec] = &[
// npm wrapper, and the content-stabilisation fallback needs three pane
// changes where its splash produces two.
active_indicators: &["? for shortcuts"],
+ scoped_indicators: &[],
exit_command: Some("/exit"),
label_fg: (120, 190, 255), // light blue
label_bg: None,
@@ -807,6 +835,75 @@ pub const AGENT_SPECS: &[AgentSpec] = &[
},
],
},
+ AgentSpec {
+ name: "pi",
+ binary: "pi",
+ description: "Earendil's pi coding agent",
+ co_author: "Pi <[email protected]>",
+ // pi is provider-agnostic: the variable that matters is the one for the
+ // provider `settings.json` selects, and its shipped default is google.
+ // Listed default-first, then the two providers whose keys a runner is
+ // most likely to already hold. `pi auth` otherwise reads
+ // ~/.pi/agent/auth.json, which a runner has no way to produce.
+ // Verified against pi 0.84.3 (docs/providers.md).
+ api_key_env: &["GEMINI_API_KEY", "ANTHROPIC_API_KEY", "OPENAI_API_KEY"],
+ env: &[],
+ // pi ships no permission system, so there is no --yolo equivalent and
+ // none is needed. What does block an unattended start is the project
+ // trust prompt, which fires in any directory carrying project-local
+ // settings, skills or extensions β€” i.e. every worktree agtx writes a
+ // skill into. `--approve` answers it for this run only and, unlike the
+ // codex arm, writes nothing to the user's global config.
+ base_args: &["--approve"],
+ prompt_form: PromptForm::Argv,
+ // Verified against pi 0.84.3 in tmux: `pi --approve '<prompt>'` starts
+ // interactively with the prompt submitted, and a leading
+ // `/skill:agtx-plan` still resolves as a skill command.
+ launch_prompt_verified: true,
+ resume: ResumeArgs::Append(&["--continue"]),
+ // `--no-approve` for the headless lane: a one-shot PR description has no
+ // need of the repo's own skills or extensions, so it declines them.
+ headless_args: &["--no-approve", "-p"],
+ // Project skills live in `.pi/skills/<name>/SKILL.md`, loaded only once
+ // the project is trusted β€” which is what `--approve` above buys.
+ skill_dir: Some((".pi/skills", "")),
+ skill_layout: SkillLayout::SkillDir,
+ skill_scan_dir: Some(".pi/skills"),
+ command_syntax: CommandSyntax::PiSkill,
+ mcp_config: Some(McpConfigKind::PiJsonMerge),
+ // pi has no lifecycle-hook mechanism, so phase status falls back to the
+ // pane-hash heuristic, as it does for opencode and copilot.
+ hook_config: None,
+ hook_event_source: HookEventSource::Payload,
+ // macOS fixes `p_comm` at exec, so the pane reports `node` however pi
+ // sets `process.title` β€” `scoped_indicators` is what actually detects it
+ // there. Kept because Linux does pick the rewrite up. Note `node` must
+ // NOT be added: it is every Ink agent's pane name and would make any
+ // node process read as a live agent.
+ process_names: &["pi"],
+ // Nothing distinctive enough to match in any pane: pi's last lines are
+ // editor borders, the cwd and a stats line. See `scoped_indicators`.
+ active_indicators: &[],
+ // The context display is the only unconditional part of the footer:
+ // `0.0%/1.0M (auto)` on a fresh session, `1.0%/1.0M` after a turn.
+ // Reads `?/` for a moment after a compaction, until the next response.
+ // Verified against pi 0.84.3.
+ scoped_indicators: &["%/"],
+ exit_command: Some("/quit"),
+ label_fg: (120, 220, 200), // teal
+ label_bg: None,
+ // Ink-class composer: a bracketed paste lands as literal text and a
+ // single Enter submits the whole multi-line message. Verified against pi
+ // 0.84.3 β€” a combined text+Enter `send-keys` leaves it unsent instead.
+ send_strategy: SendStrategy::Combined,
+ // `/new` starts a fresh session with no confirmation step; verified
+ // against pi 0.84.3 by watching the context display return to 0.0%.
+ clear_context_command: Some("/new"),
+ // None: `--approve` suppresses the only launch dialog pi has, and it is
+ // the same flag whose absence would leave the worktree's skills
+ // unloaded β€” so a pane that reaches the dialog is already misconfigured.
+ dialogs: &[],
+ },
// TODO: investigate CLI usage before enabling
// aider β€” "AI pair programming in your terminal", Aider <[email protected]>
// cline β€” "AI coding assistant for VS Code", Cline <[email protected]>
diff --git a/src/agent/trust.rs b/src/agent/trust.rs
index ea06999..f53aa68 100644
--- a/src/agent/trust.rs
+++ b/src/agent/trust.rs
@@ -19,11 +19,12 @@
//! | gemini | `~/.gemini/trustedFolders.json` β†’ `{"<dir>": "TRUST_FOLDER"}`, **lowercased** | ancestor |
//! | antigravity | `~/.gemini/antigravity-cli/settings.json` β†’ `trustedWorkspaces: [...]` | **exact** |
//! | cursor, grok | launch flag `--trust` | n/a |
+//! | pi | launch flag `--approve` (store is `~/.pi/agent/trust.json`) | n/a |
//! | opencode | no trust concept | n/a |
//! | copilot | unmeasured | n/a |
//!
//! Versions the table was measured against: claude 2.1.246, codex 0.144.5,
-//! gemini 0.46.0, agy 1.1.21, cursor-agent 2026.08.11, opencode 1.18.20.
+//! gemini 0.46.0, agy 1.1.21, cursor-agent 2026.08.11, opencode 1.18.20, pi 0.84.3.
//!
//! **copilot is deliberately `NotApplicable`, not "assumed inherited".** It is not
//! installed on any machine this was measured on, so nothing is known about its
@@ -184,8 +185,11 @@ fn store_for(agent: &str) -> Option<Store> {
"codex" => Some(Store::CodexToml),
"gemini" => Some(Store::GeminiTrustedFolders),
"antigravity" => Some(Store::AntigravityWorkspaces),
- // cursor and grok pass `--trust` at launch; opencode has no trust gate;
- // copilot is unmeasured. None of them are a blocker agtx can reason about.
+ // cursor and grok pass `--trust` at launch and pi passes `--approve`;
+ // opencode has no trust gate; copilot is unmeasured. None of them are a
+ // blocker agtx can reason about. pi does keep a store
+ // (`~/.pi/agent/trust.json`), but agtx never needs to read or seed it:
+ // the flag decides the run, and unlike codex it writes nothing global.
_ => None,
}
}
diff --git a/src/skills.rs b/src/skills.rs
index ae698db..c229ede 100644
--- a/src/skills.rs
+++ b/src/skills.rs
@@ -151,6 +151,8 @@ pub fn skill_dir_to_filename(skill_dir_name: &str, agent_name: &str) -> String {
/// - `Colon` (Claude, Gemini): unchanged (`/gsd:plan-phase 1`)
/// - `Hyphen` (OpenCode, Cursor, Grok, Antigravity): colon β†’ hyphen (`/gsd-plan-phase 1`)
/// - `Dollar` (Codex): slash β†’ dollar, colon β†’ hyphen (`$gsd-plan-phase 1`)
+/// - `PiSkill` (pi): colon β†’ hyphen, then re-namespaced under `skill:`
+/// (`/skill:gsd-plan-phase 1`)
/// - `None` (Copilot, unknown agents): None β€” callers fall back to a file-path reference
///
/// Only the first colon is rewritten; arguments may legitimately contain more.
@@ -165,6 +167,16 @@ pub fn transform_plugin_command(canonical_cmd: &str, agent_name: &str) -> Option
None => transformed,
})
}
+ // pi registers every skill as `/skill:<skill-name>`, and the skill name
+ // is the hyphenated form the SKILL.md frontmatter carries. So the
+ // namespace does not survive as a prefix β€” it is folded into the name.
+ Some(CommandSyntax::PiSkill) => {
+ let transformed = canonical_cmd.replacen(':', "-", 1);
+ Some(match transformed.strip_prefix('/') {
+ Some(rest) => format!("/skill:{}", rest),
+ None => transformed,
+ })
+ }
Some(CommandSyntax::None) | None => None,
}
}
@@ -339,10 +351,13 @@ pub fn scan_agent_skills(
}
// Skill subdirectories each holding a SKILL.md, invoked by directory name.
SkillLayout::SkillDir => {
- let prefix = if spec.command_syntax == CommandSyntax::Dollar {
- "$"
- } else {
- "/"
+ // The directory name is the skill name; the prefix is how the
+ // agent's TUI invokes it. pi namespaces every skill under `skill:`,
+ // so the directory `agtx-plan` is typed as `/skill:agtx-plan`.
+ let prefix = match spec.command_syntax {
+ CommandSyntax::Dollar => "$",
+ CommandSyntax::PiSkill => "/skill:",
+ _ => "/",
};
scan_skill_dirs(&base, prefix)
}
diff --git a/src/tui/app.rs b/src/tui/app.rs
index d7bf792..e42e38e 100644
--- a/src/tui/app.rs
+++ b/src/tui/app.rs
@@ -9773,13 +9773,30 @@ fn send_skill_and_prompt(
auto_dismiss: &[crate::config::AutoDismiss],
clear_context: bool,
) {
+ // How this agent's composer takes a message. Read once: it decides both the
+ // clear-context send below and the skill+prompt send after it.
+ let strategy =
+ agent::spec(agent_name).map_or(agent::SendStrategy::Generic, |s| s.send_strategy);
+
// Opt-in context clear on phase advance. Agents with no known clear command
// (`clear_context_command: None`, tbd per issue #46) fall through to a normal
// send unchanged.
let clear_cmd = agent::spec(agent_name).and_then(|s| s.clear_context_command);
if let (true, Some(cmd)) = (clear_context, clear_cmd) {
- let _ = tmux_ops.send_keys(target, cmd);
- // Wait for Claude to clear its buffer and return to idle prompt.
+ // An Ink-class composer (`SendStrategy::Combined`) drops a combined
+ // text+Enter `send-keys`: the Enter fires before the TUI has rendered the
+ // input, so the command is left parked. That is worse than not clearing β€”
+ // the skill+prompt below is then pasted *onto the end* of the parked text
+ // and the whole thing submits as one message, so the phase command never
+ // resolves. Deliver it the way a message is delivered and confirm it left
+ // the composer. Verified against pi 0.84.3, which is why pi is `Combined`.
+ if strategy == agent::SendStrategy::Combined {
+ deliver_message(tmux_ops, target, cmd, true);
+ submit_message(tmux_ops, target, cmd);
+ } else {
+ let _ = tmux_ops.send_keys(target, cmd);
+ }
+ // Wait for the agent to clear its buffer and return to idle prompt.
// Pattern mirrors the stability-poll loops used elsewhere in this
// function: poll until pane content stabilises (no changes for ~1s),
// capped at ~5s total.
@@ -9808,9 +9825,6 @@ fn send_skill_and_prompt(
//
// Fix: send just the command name, wait for picker, Enter to confirm (inserts cmd),
// then send the args (picker dismissed, input now has just the command), then Enter.
- let strategy =
- agent::spec(agent_name).map_or(agent::SendStrategy::Generic, |s| s.send_strategy);
-
if strategy == agent::SendStrategy::OpenCodePicker {
// Build the full message: skill command (if any) + prompt (if any)
let full_text = if let Some(cmd) = skill_cmd {
@@ -10305,7 +10319,14 @@ static AGENT_ACTIVE_INDICATORS: std::sync::LazyLock<Vec<&'static str>> =
/// rather than an agent process.
fn is_pane_at_shell(tmux_ops: &dyn TmuxOperations, target: &str) -> bool {
if let Some(cmd) = tmux_ops.pane_current_command(target) {
- !AGENT_COMMANDS.iter().any(|a| cmd.contains(a))
+ // Compared whole, not by substring. `pane_current_command` reports the
+ // command *name*, so equality is what the field means β€” and a substring
+ // test lets short names swallow unrelated processes: `pi` matches `pip`,
+ // `pipx`, `pipenv` and `pinentry`, and `agent` (cursor) matches anything
+ // ending in it. Every one of those would read as "an agent is running"
+ // for *every* task, since this list is flattened across all agents.
+ let cmd = cmd.trim();
+ !AGENT_COMMANDS.iter().any(|a| cmd == *a)
} else {
false
}
@@ -10402,10 +10423,7 @@ fn is_agent_active(tmux_ops: &dyn TmuxOperations, target: &str, agent_name: Opti
// Only the last few lines are checked to avoid false positives from
// indicator strings appearing in conversation output higher up.
if let Ok(content) = tmux_ops.capture_pane(target) {
- let lines: Vec<&str> = content.lines().collect();
- let bottom = lines.len().saturating_sub(5);
- let tail = &lines[bottom..];
- let tail_text = tail.join("\n");
+ let tail_text = pane_tail(&content, PANE_TAIL_LINES);
if active_indicators_for(agent_name)
.iter()
.any(|s| tail_text.contains(s))
@@ -10452,10 +10470,10 @@ fn ensure_window_or_recover(
/// Terminates the current agent, waits for the shell prompt,
/// then starts the new agent.
///
-/// Exit commands per agent:
-/// - Claude, OpenCode: `/exit`
-/// - Gemini, Codex: `/quit`
-/// - Fallback: Ctrl+C + Ctrl+D as last resort
+/// The exit command comes from `AgentSpec::exit_command`; `None` (codex, cursor)
+/// means Ctrl+C is the only way out, and Ctrl+C + Ctrl+D is the last resort when
+/// the command does not take. How it is *delivered* is decided by
+/// `AgentSpec::send_strategy` β€” see the comment on the send below.
///
/// Detection uses `tmux display -p #{pane_current_command}` which reports
/// the actual process name (e.g. "claude", "node", "bash"), avoiding
@@ -10472,10 +10490,18 @@ fn switch_agent_in_tmux(
let exit_cmd = agent::spec(current_agent).map_or(Some("/exit"), |s| s.exit_command);
if let Some(cmd) = exit_cmd {
- // For Gemini (Ink/Node TUI): send text first, wait for it to appear in pane,
- // then send Enter β€” same pattern as send_skill_and_prompt. Without this delay,
- // Enter fires before the Ink TUI has rendered the input, and /quit is lost.
- if current_agent == "gemini" {
+ // An Ink-class composer (`SendStrategy::Combined`) loses a combined
+ // text+Enter `send-keys`: Enter fires before the TUI has rendered the
+ // input, and the exit command is lost. Send the text, wait for it to
+ // echo, then Enter β€” the same pattern as `send_skill_and_prompt`. Found
+ // with gemini; pi's spec records the identical measurement, and
+ // antigravity is the same class of TUI. Without this the graceful path is
+ // dead code for those agents: the command sits unsent, the 3s poll times
+ // out, and every switch away from them kills the agent with Ctrl+C
+ // mid-turn β€” after which the unsent text lands in the bare shell.
+ let split_enter = agent::spec(current_agent)
+ .is_some_and(|s| s.send_strategy == agent::SendStrategy::Combined);
+ if split_enter {
let _ = tmux_ops.send_text(target, cmd);
for _ in 0..20 {
std::thread::sleep(std::time::Duration::from_millis(200));
@@ -10660,12 +10686,63 @@ fn launch_dialogs_for(agent_name: Option<&str>) -> Vec<&'static agent::AgentDial
/// Same reasoning: "Ask anything" appearing in a Claude pane used to read as
/// OpenCode being ready. Unknown agents keep the flat list.
fn active_indicators_for(agent_name: Option<&str>) -> Vec<&'static str> {
+ match agent_name.and_then(agent::spec) {
+ // `scoped_indicators` are added only here, where the pane's agent is
+ // known. They are deliberately absent from AGENT_ACTIVE_INDICATORS: pi's
+ // `%/` occurs in ordinary output, so in the flat list it would report an
+ // exited claude or codex as still running.
+ Some(spec) => spec
+ .active_indicators
+ .iter()
+ .chain(spec.scoped_indicators.iter())
+ .copied()
+ .collect(),
+ None => AGENT_ACTIVE_INDICATORS.clone(),
+ }
+}
+
+/// The indicators distinctive enough to match anywhere in a pane.
+///
+/// The counterpart of [`scoped_indicators_for`]: the split exists because the two
+/// halves need different match windows. Only [`is_agent_active`] uses the merged
+/// list, and it looks at the tail either way.
+fn flat_indicators_for(agent_name: Option<&str>) -> Vec<&'static str> {
match agent_name.and_then(agent::spec) {
Some(spec) => spec.active_indicators.to_vec(),
None => AGENT_ACTIVE_INDICATORS.clone(),
}
}
+/// Indicators that are only meaningful at the *bottom* of the pane.
+///
+/// pi's `%/` is one field of its footer and also occurs in ordinary output
+/// (`Coverage: 85%/90%`), so matching it against a whole capture β€” scrollback
+/// included β€” finds an earlier turn's text rather than a live footer. On the
+/// agent-switch path that scrollback belongs to the *previous* agent, so a stale
+/// percentage would end the readiness wait before the new agent had execed.
+fn scoped_indicators_for(agent_name: Option<&str>) -> &'static [&'static str] {
+ agent_name
+ .and_then(agent::spec)
+ .map_or(&[][..], |spec| spec.scoped_indicators)
+}
+
+/// How many lines from the bottom of a capture count as "live now".
+const PANE_TAIL_LINES: usize = 5;
+
+/// The bottom `n` lines of a captured pane, trailing blank rows dropped first.
+///
+/// `capture-pane -p` emits one line per pane *row*, so the raw end of a capture
+/// is padding whenever the agent's output has not filled the pane; anchoring the
+/// window there would look at nothing. Same reasoning as `composer_holds`.
+fn pane_tail(content: &str, n: usize) -> String {
+ let mut lines: Vec<&str> = content.lines().collect();
+ while lines.last().is_some_and(|l| l.trim().is_empty()) {
+ lines.pop();
+ }
+ let start = lines.len().saturating_sub(n);
+ lines[start..].join("\n")
+}
+
/// Per-launch state for [`dismiss_launch_dialog`].
#[derive(Default)]
struct LaunchDialogState {
@@ -10848,10 +10925,20 @@ fn wait_for_agent_ready(
// Check 2 & 3: pane content checks
if let Some(content) = content {
- // Check 2: known ready indicator in pane content
- if active_indicators_for(agent_name)
- .iter()
- .any(|s| content.contains(s))
+ // Check 2: known ready indicator in pane content. Flat indicators
+ // are distinctive enough to match anywhere; `scoped_indicators` are
+ // not, so they get the same tail window `is_agent_active` uses β€”
+ // otherwise the previous agent's scrollback answers for the new one.
+ let scoped_hit = {
+ let tail = pane_tail(&content, PANE_TAIL_LINES);
+ scoped_indicators_for(agent_name)
+ .iter()
+ .any(|s| tail.contains(s))
+ };
+ if scoped_hit
+ || flat_indicators_for(agent_name)
+ .iter()
+ .any(|s| content.contains(s))
{
break;
}
@@ -11524,6 +11611,35 @@ fn merge_hooks_into_json_settings(path: &Path, ours: serde_json::Value) {
write_json(path, &serde_json::Value::Object(settings));
}
+/// Insert agtx's entry into a `mcpServers` JSON file without disturbing the rest.
+///
+/// Shared by the two `…Merge` JSON kinds (antigravity, pi), which differ only in
+/// directory and filename: their file is vendor-neutral or written back by the
+/// agent's own tooling, so the project's other servers β€” and any sibling
+/// top-level keys β€” have to survive. A missing or unparseable file starts from an
+/// empty object rather than failing, on the same best-effort footing as the rest
+/// of worktree setup.
+fn merge_mcp_servers_json(dir: &Path, filename: &str, agtx_bin: &str, project_path_str: &str) {
+ let _ = std::fs::create_dir_all(dir);
+ let path = dir.join(filename);
+ let mut root = std::fs::read_to_string(&path)
+ .ok()
+ .and_then(|s| serde_json::from_str::<serde_json::Value>(&s).ok())
+ .filter(|v| v.is_object())
+ .unwrap_or_else(|| serde_json::json!({}));
+ if !root["mcpServers"].is_object() {
+ root["mcpServers"] = serde_json::json!({});
+ }
+ root["mcpServers"]["agtx"] = serde_json::json!({
+ "command": agtx_bin,
+ "args": ["mcp-serve", project_path_str]
+ });
+ let _ = std::fs::write(
+ &path,
+ serde_json::to_string_pretty(&root).unwrap_or_default(),
+ );
+}
+
/// Write the project-scoped MCP server config for one agent into its worktree.
///
/// Selected by [`McpConfigKind`](agent::McpConfigKind) rather than agent name.
@@ -11690,24 +11806,24 @@ fn write_mcp_config(
// (JSON, `mcpServers`). `.agents/` is vendor-neutral and may already be
// tracked in the repo, so merge the agtx entry into any existing file
// instead of clobbering the project's own servers.
- let dir = Path::new(worktree_path).join(".agents");
- let _ = std::fs::create_dir_all(&dir);
- let path = dir.join("mcp_config.json");
- let mut root = std::fs::read_to_string(&path)
- .ok()
- .and_then(|s| serde_json::from_str::<serde_json::Value>(&s).ok())
- .filter(|v| v.is_object())
- .unwrap_or_else(|| serde_json::json!({}));
- if !root["mcpServers"].is_object() {
- root["mcpServers"] = serde_json::json!({});
- }
- root["mcpServers"]["agtx"] = serde_json::json!({
- "command": &agtx_bin,
- "args": ["mcp-serve", &project_path_str]
- });
- let _ = std::fs::write(
- &path,
- serde_json::to_string_pretty(&root).unwrap_or_default(),
+ merge_mcp_servers_json(
+ &Path::new(worktree_path).join(".agents"),
+ "mcp_config.json",
+ &agtx_bin,
+ &project_path_str,
+ );
+ }
+ agent::McpConfigKind::PiJsonMerge => {
+ // pi itself has no MCP client; the `pi-mcp-adapter` package provides
+ // one and reads `.pi/mcp.json` as its highest-precedence project
+ // layer, in the standard `mcpServers` shape. Merged rather than
+ // overwritten because the adapter also persists its own per-server
+ // `disabled` flags into this file.
+ merge_mcp_servers_json(
+ &Path::new(worktree_path).join(".pi"),
+ "mcp.json",
+ &agtx_bin,
+ &project_path_str,
);
}
agent::McpConfigKind::OpenCode => {
diff --git a/src/tui/app_tests.rs b/src/tui/app_tests.rs
index f1ce698..2fdade6 100644
--- a/src/tui/app_tests.rs
+++ b/src/tui/app_tests.rs
@@ -2829,6 +2829,48 @@ fn test_resolve_prompt_research_with_task() {
assert_eq!(prompt, "Task: add tests");
}
+/// The pi column of the README plugin matrix, for the half of it that is
+/// code-enforced rather than a claim about a third-party installer.
+///
+/// gsd's `init_script` passes `--{agent}` to its own installer, which has no pi
+/// target, so pi is absent from its `supported_agents` and the plugin is filtered
+/// out for a pi task entirely (❌). Every other bundled plugin leaves
+/// `supported_agents` empty and so accepts pi, and whether its commands *resolve*
+/// there is the framework's business, not agtx's (βœ… / 🟑). Locked because the
+/// exclusion is a whitelist omission β€” nothing names pi, so nothing fails if the
+/// list later grows an entry that should not be there.
+#[test]
+fn test_bundled_plugin_support_for_pi() {
+ use crate::config::WorkflowPlugin;
+ let plugin = |name: &str| -> WorkflowPlugin {
+ let (_n, _d, content) = skills::BUNDLED_PLUGINS
+ .iter()
+ .find(|(n, _, _)| *n == name)
+ .unwrap_or_else(|| panic!("{name} plugin should be bundled"));
+ toml::from_str(content).unwrap()
+ };
+
+ assert!(
+ !plugin("gsd").supports_agent("pi"),
+ "gsd's installer has no pi target, so pi must stay out of supported_agents"
+ );
+ // The same whitelist already excludes these two; pi joins them rather than
+ // being a new kind of case.
+ assert!(!plugin("gsd").supports_agent("antigravity"));
+ assert!(!plugin("gsd").supports_agent("copilot"));
+
+ for name in ["agtx", "agtx-terse", "spec-kit", "openspec", "bmad", "void"] {
+ assert!(
+ plugin(name).supports_agent("pi"),
+ "{name} declares no supported_agents, so it must accept pi"
+ );
+ }
+ // Claude-only plugins stay claude-only.
+ for name in ["superpowers", "oh-my-claudecode"] {
+ assert!(!plugin(name).supports_agent("pi"), "{name}");
+ }
+}
+
#[test]
fn test_gsd_plugin_toml_has_research_command() {
use crate::config::WorkflowPlugin;
@@ -3202,6 +3244,72 @@ fn test_is_pane_at_shell_returns_false_when_none() {
assert!(!is_pane_at_shell(&mock, "sess:win"));
}
+/// A process name is matched whole, not by substring.
+///
+/// `pi` is two characters and `AGENT_COMMANDS` is flat across every agent, so a
+/// `contains` test made `pip`, `pipx`, `pipenv` and `pinentry` read as "an agent
+/// is running" in *any* task's pane β€” and `is_pane_at_shell` is the signal for
+/// "the agent has exited". Cursor's `agent` had the same shape.
+#[test]
+#[cfg(feature = "test-mocks")]
+fn test_is_pane_at_shell_does_not_match_process_names_by_substring() {
+ for cmd in ["pip", "pip3", "pipx", "pipenv", "pinentry", "agentless"] {
+ let mut mock = MockTmuxOperations::new();
+ mock.expect_pane_current_command()
+ .returning(move |_| Some(cmd.to_string()));
+ assert!(
+ is_pane_at_shell(&mock, "sess:win"),
+ "{cmd} must not read as a live agent"
+ );
+ }
+
+ // The names themselves still match, surrounding whitespace included.
+ for cmd in ["pi", "agent", " claude "] {
+ let mut mock = MockTmuxOperations::new();
+ mock.expect_pane_current_command()
+ .returning(move |_| Some(cmd.to_string()));
+ assert!(!is_pane_at_shell(&mock, "sess:win"), "{cmd}");
+ }
+}
+
+// === indicator scoping tests ===
+
+/// `scoped_indicators` must be matched against the bottom of the pane only.
+///
+/// pi's `%/` is one field of its footer and also occurs in ordinary output, so
+/// over a whole capture it finds scrollback rather than a live footer. On the
+/// agent-switch path that scrollback belongs to the *previous* agent, which would
+/// end the readiness wait before the new agent had execed.
+#[test]
+fn test_scoped_indicators_are_not_found_in_scrollback() {
+ let scrollback_only = format!("Coverage: 85%/90%\n{}", "some later output\n".repeat(20));
+ let tail = pane_tail(&scrollback_only, PANE_TAIL_LINES);
+ assert!(!tail.contains("%/"), "tail was: {tail:?}");
+
+ // ...and still found where pi actually draws it.
+ let live = format!("{}0.0%/1.0M (auto)", "older output\n".repeat(20));
+ assert!(pane_tail(&live, PANE_TAIL_LINES).contains("%/"));
+}
+
+/// Trailing blank rows must not push the window off the content: `capture-pane -p`
+/// emits one line per pane *row*, so an unfilled pane ends in padding.
+#[test]
+fn test_pane_tail_ignores_trailing_blank_rows() {
+ let pane = format!("0.0%/1.0M (auto){}", "\n".repeat(30));
+ assert!(pane_tail(&pane, PANE_TAIL_LINES).contains("%/"));
+}
+
+/// The flat list is what an unknown agent's pane is matched against, and pi's
+/// `%/` must stay out of it in both directions.
+#[test]
+fn test_flat_and_scoped_indicators_are_disjoint_for_pi() {
+ assert!(!flat_indicators_for(Some("pi")).contains(&"%/"));
+ assert!(scoped_indicators_for(Some("pi")).contains(&"%/"));
+ // An unknown agent gets the flat list and no scoped strings at all.
+ assert!(scoped_indicators_for(Some("mistral")).is_empty());
+ assert!(scoped_indicators_for(None).is_empty());
+}
+
// === kill_windows_by_name tests ===
#[test]
@@ -4593,6 +4701,57 @@ fn test_write_skills_to_worktree_mcp_antigravity() {
assert_eq!(v["mcpServers"]["agtx"]["args"][0], "mcp-serve");
}
+#[test]
+fn test_write_skills_to_worktree_pi() {
+ let dir = tempfile::tempdir().unwrap();
+ let wt = dir.path().to_string_lossy().to_string();
+
+ write_skills_to_worktree(&wt, dir.path(), &None, &["pi"], false);
+
+ // pi discovers `.pi/skills/<name>/SKILL.md`, and only once the project is
+ // trusted β€” which is what the `--approve` in its launch args buys.
+ assert!(
+ dir.path().join(".pi/skills/agtx-plan/SKILL.md").exists(),
+ ".pi/skills/agtx-plan/SKILL.md should be deployed for pi"
+ );
+
+ let cfg = dir.path().join(".pi/mcp.json");
+ assert!(cfg.exists(), ".pi/mcp.json should be written for pi");
+ let v: serde_json::Value =
+ serde_json::from_str(&std::fs::read_to_string(&cfg).unwrap()).unwrap();
+ assert!(v["mcpServers"]["agtx"]["command"].is_string());
+ assert_eq!(v["mcpServers"]["agtx"]["args"][0], "mcp-serve");
+}
+
+/// The adapter persists its own per-server `disabled` flags into this same file,
+/// so the writer must merge rather than clobber.
+#[test]
+fn test_write_skills_to_worktree_mcp_pi_preserves_existing_config() {
+ let dir = tempfile::tempdir().unwrap();
+ let wt = dir.path().to_string_lossy().to_string();
+ let pi_dir = dir.path().join(".pi");
+ std::fs::create_dir_all(&pi_dir).unwrap();
+ std::fs::write(
+ pi_dir.join("mcp.json"),
+ r#"{"mcpServers":{"other":{"command":"other","disabled":true}},"somethingElse":true}"#,
+ )
+ .unwrap();
+
+ write_skills_to_worktree(&wt, dir.path(), &None, &["pi"], false);
+
+ let content = std::fs::read_to_string(pi_dir.join("mcp.json")).unwrap();
+ let v: serde_json::Value = serde_json::from_str(&content).unwrap();
+ assert_eq!(
+ v["mcpServers"]["other"]["disabled"], true,
+ "a project's own .pi/mcp.json must not be clobbered: {content}"
+ );
+ assert_eq!(
+ v["somethingElse"], true,
+ "top-level sibling keys must survive: {content}"
+ );
+ assert!(v["mcpServers"]["agtx"]["command"].is_string());
+}
+
#[test]
fn test_write_skills_to_worktree_mcp_antigravity_preserves_existing_config() {
let dir = tempfile::tempdir().unwrap();
@@ -9319,6 +9478,40 @@ fn test_is_agent_active_true_when_gemini_indicator_in_pane() {
assert!(is_agent_active(&mock_tmux, "proj:task", None));
}
+/// pi has no banner: the only unconditional part of its footer is the context
+/// display, so `%/` is what proves the TUI is up. It counts only in a pane agtx
+/// knows is pi's β€” the same string elsewhere must not.
+#[test]
+#[cfg(feature = "test-mocks")]
+fn test_is_agent_active_scoped_indicator_counts_only_for_its_own_agent() {
+ let pane = || Ok("cwd (main)\n0.0%/1.0M (auto)".to_string());
+
+ let mut as_pi = MockTmuxOperations::new();
+ as_pi
+ .expect_pane_current_command()
+ // macOS reports pi's Ink process as `node`, i.e. "at the shell".
+ .returning(|_| Some("bash".to_string()));
+ as_pi.expect_capture_pane().returning(move |_| pane());
+ assert!(is_agent_active(&as_pi, "proj:task", Some("pi")));
+
+ let mut as_claude = MockTmuxOperations::new();
+ as_claude
+ .expect_pane_current_command()
+ .returning(|_| Some("bash".to_string()));
+ as_claude.expect_capture_pane().returning(move |_| pane());
+ assert!(!is_agent_active(&as_claude, "proj:task", Some("claude")));
+
+ let mut as_unknown = MockTmuxOperations::new();
+ as_unknown
+ .expect_pane_current_command()
+ .returning(|_| Some("bash".to_string()));
+ as_unknown.expect_capture_pane().returning(move |_| pane());
+ assert!(
+ !is_agent_active(&as_unknown, "proj:task", None),
+ "an unknown pane must not read a bare percent-slash as a live agent"
+ );
+}
+
#[test]
#[cfg(feature = "test-mocks")]
fn test_is_agent_active_false_when_at_shell_no_indicator() {
@@ -12294,6 +12487,11 @@ fn test_agent_commands_derivation_matches_the_previous_literals() {
got.sort_unstable();
let mut want = vec![
"claude", "codex", "gemini", "copilot", "opencode", "agent", "grok", "agy",
+ // pi. Only fires on Linux β€” macOS fixes `p_comm` at exec, so the pane
+ // reports `node` and pi's scoped indicator does the detecting there.
+ // `node` itself must never join this list: it is every Ink agent's pane
+ // name, and would make any node process read as a live agent.
+ "pi",
// Not agent binaries, but a Python entry point must not read as "shell".
"python3", "python",
];
@@ -12321,6 +12519,11 @@ fn test_active_indicator_derivation_matches_the_previous_literals() {
"? for shortcuts",
];
want.sort_unstable();
+ // pi's "%/" is deliberately absent: it lives in `scoped_indicators`, which
+ // is matched only in a pane agtx knows is running pi. In this flat list β€”
+ // used for panes whose agent is unknown β€” it would report an exited claude
+ // or codex as still running the moment output contained "85%/90%".
+ assert!(!got.contains(&"%/"));
assert_eq!(got, want);
}
@@ -12328,22 +12531,25 @@ fn test_active_indicator_derivation_matches_the_previous_literals() {
/// Ctrl+C, not a `/exit` typed into a TUI that does not understand it.
#[test]
fn test_exit_command_per_agent() {
- for (agent, want) in [
+ let table = [
("claude", Some("/exit")),
("opencode", Some("/exit")),
("copilot", Some("/exit")),
("antigravity", Some("/exit")),
("gemini", Some("/quit")),
("grok", Some("/quit")),
+ ("pi", Some("/quit")),
("codex", None),
("cursor", None),
- ] {
+ ];
+ for (agent, want) in table {
assert_eq!(
crate::agent::spec(agent).unwrap().exit_command,
want,
"{agent}"
);
}
+ assert_covers_every_agent(&table.map(|(a, _)| a), "test_exit_command_per_agent");
// An agent agtx has never heard of keeps the historical default.
assert!(crate::agent::spec("mistral").is_none());
}
@@ -12354,7 +12560,7 @@ fn test_exit_command_per_agent() {
#[test]
fn test_send_strategy_per_agent() {
use crate::agent::SendStrategy;
- for (agent, want) in [
+ let table = [
("claude", SendStrategy::Generic),
("copilot", SendStrategy::Generic),
("grok", SendStrategy::Generic),
@@ -12362,40 +12568,87 @@ fn test_send_strategy_per_agent() {
("codex", SendStrategy::Combined),
("cursor", SendStrategy::Combined),
("antigravity", SendStrategy::Combined),
+ ("pi", SendStrategy::Combined),
("opencode", SendStrategy::OpenCodePicker),
- ] {
+ ];
+ for (agent, want) in table {
assert_eq!(
crate::agent::spec(agent).unwrap().send_strategy,
want,
"{agent}"
);
}
+ assert_covers_every_agent(&table.map(|(a, _)| a), "test_send_strategy_per_agent");
}
-/// `/clear` is Claude-only today (issue #46). An agent with `None` must fall
-/// through to a normal send rather than typing a command it does not understand
-/// into its composer.
+/// Which agents have a verified clear-context command (issue #46). An agent with
+/// `None` must fall through to a normal send rather than typing a command it does
+/// not understand into its composer.
#[test]
-fn test_clear_context_command_is_claude_only() {
- assert_eq!(
- crate::agent::spec("claude").unwrap().clear_context_command,
- Some("/clear")
- );
- for agent in [
- "codex",
- "gemini",
- "cursor",
- "antigravity",
- "opencode",
- "grok",
- "copilot",
- ] {
+fn test_clear_context_command_per_agent() {
+ let table = [
+ ("claude", Some("/clear")),
+ ("pi", Some("/new")),
+ ("codex", None),
+ ("gemini", None),
+ ("cursor", None),
+ ("antigravity", None),
+ ("opencode", None),
+ ("grok", None),
+ ("copilot", None),
+ ];
+ for (agent, want) in table {
assert_eq!(
crate::agent::spec(agent).unwrap().clear_context_command,
- None,
+ want,
"{agent}"
);
}
+ assert_covers_every_agent(
+ &table.map(|(a, _)| a),
+ "test_clear_context_command_per_agent",
+ );
+}
+
+/// Every agent that *has* a clear-context command must be reachable by a delivery
+/// path that actually submits it.
+///
+/// The gap this pins cost pi its whole phase command: `/new` was declared while
+/// the send was an unconditional `send_keys`, which pi's own spec comment records
+/// as leaving the text unsent β€” so the skill+prompt was pasted onto the parked
+/// `/new` and submitted as one message. `SendStrategy::Combined` now takes the
+/// paste-and-confirm path and `Generic` keeps the typed one, so what is asserted
+/// is that the strategy is one the send has an arm for.
+#[test]
+fn test_clear_context_agents_have_a_delivery_path() {
+ use crate::agent::SendStrategy;
+ for spec in crate::agent::AGENT_SPECS.iter() {
+ if spec.clear_context_command.is_none() {
+ continue;
+ }
+ assert!(
+ matches!(
+ spec.send_strategy,
+ SendStrategy::Generic | SendStrategy::Combined
+ ),
+ "{}: clear_context_command is delivered by send_skill_and_prompt, \
+ which has no arm for {:?}",
+ spec.name,
+ spec.send_strategy
+ );
+ }
+}
+
+/// Helper for the per-agent literal tables: a new agent must be added to each one
+/// rather than silently escaping the lock it exists to provide. This is how pi
+/// slipped past three of them at once.
+fn assert_covers_every_agent(covered: &[&str], table: &str) {
+ let missing: Vec<&str> = crate::agent::AGENT_SPECS
+ .iter()
+ .map(|s| s.name)
+ .filter(|n| !covered.contains(n))
+ .collect();
+ assert!(missing.is_empty(), "{table} is missing: {missing:?}");
}
/// `LAUNCH_DIALOGS` is now derived from `AGENT_SPECS`. Pinned against the
diff --git a/tests/agent_parity_tests.rs b/tests/agent_parity_tests.rs
index 857c5be..8eff71c 100644
--- a/tests/agent_parity_tests.rs
+++ b/tests/agent_parity_tests.rs
@@ -24,6 +24,7 @@ const AGENTS: &[&str] = &[
"cursor",
"grok",
"antigravity",
+ "pi",
];
fn agent(name: &str) -> Agent {
@@ -72,6 +73,9 @@ fn interactive_command_parity_without_prompt() {
"antigravity",
"agy --dangerously-skip-permissions --mode accept-edits",
),
+ // pi has no permission system to bypass; `--approve` is project trust,
+ // without which the worktree's own skills are never loaded.
+ ("pi", "pi --approve"),
];
for (name, want) in expected {
assert_eq!(&agent(name).build_interactive_command(""), want, "{name}");
@@ -99,6 +103,7 @@ fn interactive_command_parity_with_prompt() {
"antigravity",
"agy --dangerously-skip-permissions --mode accept-edits -i 'hi'",
),
+ ("pi", "pi --approve 'hi'"),
];
for (name, want) in expected {
assert_eq!(&agent(name).build_interactive_command("hi"), want, "{name}");
@@ -148,6 +153,7 @@ fn resume_command_parity() {
"antigravity",
"agy --dangerously-skip-permissions --mode accept-edits --continue",
),
+ ("pi", "pi --approve --continue"),
];
for (name, want) in expected {
assert_eq!(&agent(name).build_resume_command(), want, "{name}");
@@ -171,6 +177,9 @@ fn headless_invocation_parity() {
("cursor", "agent", &["--print", "--yolo"]),
("grok", "grok", &["-p"]),
("antigravity", "agy", &["-p"]),
+ // `--no-approve`: a one-shot PR description has no use for the repo's
+ // own skills or extensions, so it declines them.
+ ("pi", "pi", &["--no-approve", "-p"]),
];
for (name, bin, flags) in expected {
let a = agent(name);
@@ -223,6 +232,8 @@ fn prompt_injection_parity() {
("opencode", PromptInjection::FlagInteractive("--prompt")),
// agy 1.1.21 β€” an argv prompt is queued behind the trust dialog, not eaten
("antigravity", PromptInjection::FlagInteractive("-i")),
+ // pi 0.84.3 β€” `pi --approve '<prompt>'` stays interactive and submits it
+ ("pi", PromptInjection::Argv),
];
for (name, want) in verified {
assert_eq!(agent(name).prompt_injection(), *want, "{name}");
@@ -265,6 +276,7 @@ fn native_skill_dir_parity() {
("grok", Some((".grok/skills", ""))),
// Vendor-neutral tree, not an agent dotdir.
("antigravity", Some((".agents/skills", ""))),
+ ("pi", Some((".pi/skills", ""))),
];
for (name, want) in expected {
assert_eq!(agent_native_skill_dir(name), *want, "{name}");
@@ -297,6 +309,7 @@ fn skill_filename_parity() {
("cursor", "plan.md"),
("grok", "plan.md"),
("antigravity", "plan.md"),
+ ("pi", "plan.md"),
];
for (name, want) in expected {
assert_eq!(&skill_dir_to_filename("agtx-plan", name), want, "{name}");
@@ -326,6 +339,9 @@ fn plugin_command_parity() {
("cursor", Some("/gsd-plan-phase 1")),
("grok", Some("/gsd-plan-phase 1")),
("antigravity", Some("/gsd-plan-phase 1")),
+ // pi has one `skill:` namespace for every skill, so the plugin's own
+ // namespace is folded into the skill name rather than kept as a prefix.
+ ("pi", Some("/skill:gsd-plan-phase 1")),
];
for (name, want) in expected {
assert_eq!(
@@ -408,6 +424,12 @@ fn identity_parity() {
"Google's Antigravity CLI",
"Antigravity <[email protected]>",
),
+ (
+ "pi",
+ "pi",
+ "Earendil's pi coding agent",
+ ),
];
for (name, binary, description, co_author) in expected {
let a = agent(name);
@@ -446,6 +468,7 @@ fn scan_agent_skills_parity() {
write(root, ".cursor/skills/agtx-plan/SKILL.md", MD_SKILL);
write(root, ".grok/skills/agtx-plan/SKILL.md", MD_SKILL);
write(root, ".agents/skills/agtx-plan/SKILL.md", MD_SKILL);
+ write(root, ".pi/skills/agtx-plan/SKILL.md", MD_SKILL);
// OpenCode's project commands live under .config/, not in the tree agtx
// deploys into (.opencode/command). Both are written here to lock which one
// the scan reads.
@@ -464,6 +487,8 @@ fn scan_agent_skills_parity() {
("cursor", &[("/agtx-plan", "Plan the work")]),
("grok", &[("/agtx-plan", "Plan the work")]),
("antigravity", &[("/agtx-plan", "Plan the work")]),
+ // Same SkillDir layout, but pi types it under its own namespace.
+ ("pi", &[("/skill:agtx-plan", "Plan the work")]),
];
for (name, want) in expected {
let got = agtx::skills::scan_agent_skills(name, root);
diff --git a/tests/smoke/agent_matrix.rs b/tests/smoke/agent_matrix.rs
index 73b9a60..83b5a37 100644
--- a/tests/smoke/agent_matrix.rs
+++ b/tests/smoke/agent_matrix.rs
@@ -127,10 +127,13 @@ fn main() {
spec::CommandSyntax::Colon => "colon",
spec::CommandSyntax::Hyphen => "hyphen",
spec::CommandSyntax::Dollar => "dollar",
+ spec::CommandSyntax::PiSkill => "pi_skill",
spec::CommandSyntax::None => "none",
},
"process_names": s.process_names,
"active_indicators": s.active_indicators,
+ // Matched only in this agent's own pane β€” see AgentSpec.
+ "scoped_indicators": s.scoped_indicators,
"dialogs": dialogs,
"commands": commands,
}));
diff --git a/tests/smoke/agent_smoke.py b/tests/smoke/agent_smoke.py
index f52c26c..8f05821 100755
--- a/tests/smoke/agent_smoke.py
+++ b/tests/smoke/agent_smoke.py
@@ -515,9 +515,9 @@ def setup_agent_trust(agent: str, repo: Path) -> bool:
inherits, so agtx must seed each worktree from this consent β€” if that seeding
breaks, its cases park and the run says so.
- Returns whether anything was written. cursor and grok pass `--trust` at launch,
- opencode has no trust gate, and copilot is unmeasured β€” nothing to set up, and
- nothing to guess at.
+ Returns whether anything was written. cursor and grok pass `--trust` at launch
+ and pi passes `--approve`, opencode has no trust gate, and copilot is
+ unmeasured β€” nothing to set up, and nothing to guess at.
"""
kind = AGENT_TRUST_STORES.get(agent)
if kind is None: