Skip to content

feat: add pi source backend#116

Merged
sorafujitani merged 3 commits into
mainfrom
feat/pi-source
Jul 7, 2026
Merged

feat: add pi source backend#116
sorafujitani merged 3 commits into
mainfrom
feat/pi-source

Conversation

@sorafujitani

Copy link
Copy Markdown
Owner

Adds a pi session backend for the pi coding agent, following the structure of the existing codex backend.

Pi stores sessions as JSONL under ~/.pi/agent/sessions/<munged-cwd>/<timestamp>_<uuid>.jsonl. The first line is a header carrying the session id, start time, and cwd; later entries carry messages, model changes, and session_info display names. The parser is grounded in pi's official docs/session-format.md and verified against a real session store.

  • internal/pi parses the store: header id/cwd, label from the latest session_info name (an empty name clears it, matching pi's own /resume picker) with fallback to the first user message, last activity from entry timestamps, preview messages from user/assistant text blocks.
  • internal/source registers the backend as --source=pi, with a --pi shorthand and inclusion in --source=all. Resume execs pi --session <jsonl-path>.
  • PI_CODING_AGENT_SESSION_DIR (pi's own env var) overrides the sessions directory.

Verified live against a real ~/.pi/agent/sessions store: list, preview, resume spec, and --source=all interleaving all render correctly.

Known limitations, matching the codex backend's tradeoffs: the parser walks entries linearly, so previews of branched sessions include abandoned branches, and compaction/branch summaries are not shown. Follow-up candidates kept out of this PR: extracting the JSONL-store helpers now duplicated across grok/codex/pi, and generalizing the per-backend shorthand flags in cmd/ccsession.

@sorafujitani sorafujitani merged commit bde8f25 into main Jul 7, 2026
7 checks passed
@sorafujitani sorafujitani deleted the feat/pi-source branch July 7, 2026 06:38
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