Skip to content

feat(pi): add Pi as a terminal-only agent provider with transcript support #1132

Closed

Description

@Juliusolsson05

Motivation

Pi (https://pi.dev, @earendil-works/pi-coding-agent, CLI pi) is a fast-moving, extension-first coding agent with subscription logins for Claude, ChatGPT/Codex, Copilot and others. Users should be able to run it in Agent Code the way OpenCode Terminal runs OpenCode: Pi's own native TUI in a pane, while the rest of Agent Code (status badges, Dispatch, orchestration, MCP transcript reads, Reader Mode, conversation catalog, provider switch) sees it as a real agent rather than a dumb shell.

Pi has no permission system, no MCP and no server mode that coexists with its TUI. Its only integration surface that keeps the TUI is its extension API (pi -e <file.ts>), and its durable transcript is a JSONL tree (branches from /tree live in the same file). Both facts shape the design.

Intended behavior

  • New provider kind pi, terminal-only: every Pi pane is the native TUI, from every spawn path, resolved at read time by one effectiveProviderRuntime helper instead of relying on each spawn site to set providerRuntime: 'terminal'.
  • New public package pi-terminal-headless (submodule), mirroring opencode-terminal-headless:
    • durable channel: tails the session JSONL and projects it onto the active branch;
    • live channel: a bridge extension that Agent Code ships and Pi loads with -e. It connects to a host-owned Unix socket and reports activity, turns, session switches and blocking dialogs. It also handles prompt delivery and abort;
    • isolated reconcile/ sequencer between the two;
    • the app owns the PTY.
  • Honest prompt delivery through the bridge: delivered / refused / unknown, never a silent paste (bug(opencode): prompts sent to a just-started OpenCode Terminal pane are silently lost #877 lesson).
  • History, Reader Mode, View Prompts, Copy Last Response, agent_transcript_* and orchestration reads return the active branch.
  • In-TUI /new, /resume, /fork and /tree are followed.
  • Pi sessions appear in the Conversations picker and support a verified resume command.
  • agent-transcript-parser gains a Pi decoder and projector, so Pi can switch to and from every other provider and be duplicated.
  • The built-in MCP (TLDR, Goal, orchestration) is exposed inside Pi through the bridge's tool proxy.
  • Degradation: without the bridge the pane still works, the transcript still arrives, status is "unknown" rather than wrong, and prompt delivery refuses with a visible diagnostic.

Spec: docs/decomposition/pi-terminal.md. Plan: docs/superpowers/plans/2026-09-22-pi-terminal-harness.md (branch feat/pi-terminal-harness).

Acceptance criteria

  • "New Pi" is offered when pi is on PATH; Setup shows the install hint otherwise
  • Pi panes are always the TUI surface (picker, split, catalog resume, MCP create_agent, control API, duplicate, switch target, restart restore)
  • Busy/idle follows Pi's own agent_start / agent_settled, with no idle flicker between tool steps
  • Committed transcript and history cover the active branch only; abandoned branches never appear
  • Orchestration / Dispatch prompt delivery works with truthful outcomes
  • Blocking Pi dialogs raise attention and clear when answered in the TUI
  • /new, /resume, /fork and /tree are followed with a history reset boundary
  • Conversations catalog lists and resumes Pi sessions; "Copy Resume Command" is verified
  • Switch Pi ↔ Claude/Codex/OpenCode/Grok and Duplicate work
  • Built-in MCP tools are callable from inside Pi
  • Bridge failure degrades visibly and never crashes pi
  • Tests are built from recorded real Pi runs (sandboxed faux provider); package, parser and app gates are green

Activity

  1. 13 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions