Skip to content

Add Claude Code agent support alongside pi #14

@goyamegh

Description

@goyamegh

Summary

Add first-class support for Anthropic's Claude Code as a selectable agent inside pi-web, alongside the existing pi agent. Today the drawer/composer assumes the pi agent's session model exclusively; running CC requires an external terminal and gives up the entire pi-web session UX.

Motivation

  • Many of us already use Claude Code daily for the same kinds of tasks pi handles. Forcing a context switch to a terminal pane for CC defeats the purpose of pi-web's tab/drawer/marker/folder UX.
  • CC's session files (~/.claude/...) follow a different layout than pi's (~/.pi/agent/sessions/...). A small adapter layer can normalise both into the existing SessionInfo shape so the drawer, marker buckets, pinned tabs, search, etc. all "just work".
  • CC has its own user / project / plugin slash commands and skills. Surfacing those in the composer's slash-command palette is a natural extension once the agent is wired up.

Proposed scope

A first cut should include:

  1. Agent abstraction in server.ts — extract a small interface (start session, stream events, list sessions, fork, rename, delete, send message) and have both pi and claude-code implement it. Pick the implementation per-tab from a UI selector or per-cwd default.
  2. Claude Code adapter — wraps the CC CLI / SDK and translates its event stream into pi-web's existing agent_event envelope (text deltas, tool start/end, message_end, agent_end, errors, replay).
  3. Session translator — read CC's on-disk session format and project it onto pi-web's SessionInfo (id, title, cwd, firstMessage, updatedAt, etc.) so the drawer renders CC sessions next to pi sessions, with the agent shown as a small badge / icon.
  4. Open-anywhere session lookup — when a CC session is clicked, search across every cwd we know about (CC's per-project session dirs are not 1:1 with pi's). Cache the lookup so the common case stays cheap.
  5. Slash-command bridge — surface CC's user / project / plugin commands and skills in the composer's slash-command palette, keyed off the active agent.
  6. Tests — unit tests for the translator + adapter (event mapping, error paths), and Playwright e2e covering the end-to-end agent UI on a CC session (replay, tool turn, slash command).

Notes / context

  • Locally I have a working prototype that does all of the above (feat(claude-code): add Claude Code agent alongside pi and follow-ups). Happy to clean it up and open a PR against main once the upstream direction is confirmed — wanted to file the issue first so the design choices (single adapter interface vs per-agent server modules; how to identify the active agent in SessionInfo; whether to ship a CC selector in the drawer footer or in settings) can be discussed before code review.
  • Some adjacent papercuts surfaced while building this — see Drawer hides whole folders when filter is applied or sessions are empty #13 for the folder-visibility one.

Out of scope (for now)

  • Bidirectional session migration between pi and CC.
  • Cross-agent message replay (one CC turn replayed under pi, etc.).
  • Renaming / re-homing CC sessions on disk.

Acceptance criteria

  • An agent picker exists in pi-web (default = pi) and toggles which backend handles a tab's session.
  • CC sessions appear in the drawer alongside pi sessions, with a clear visual distinction.
  • Opening, replaying, and continuing a CC session works end-to-end inside pi-web.
  • CC slash commands are listed in the composer palette when CC is the active agent.
  • Unit + e2e tests cover the new agent adapter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions