feat: add pi source backend#116
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
pisession backend for the pi coding agent, following the structure of the existingcodexbackend.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, andsession_infodisplay names. The parser is grounded in pi's officialdocs/session-format.mdand verified against a real session store.internal/piparses the store: header id/cwd, label from the latestsession_infoname (an empty name clears it, matching pi's own/resumepicker) with fallback to the first user message, last activity from entry timestamps, preview messages from user/assistant text blocks.internal/sourceregisters the backend as--source=pi, with a--pishorthand and inclusion in--source=all. Resume execspi --session <jsonl-path>.PI_CODING_AGENT_SESSION_DIR(pi's own env var) overrides the sessions directory.Verified live against a real
~/.pi/agent/sessionsstore:list,preview,resumespec, and--source=allinterleaving 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.