archgate session-context
Read AI editor session transcripts for the project. Useful for auditing what an AI agent did during a coding session.
archgate session-context [subcommand] [options]With no subcommand it reads the current conversation for the editor running the command, which Archgate works out from the environment. Two subcommands cover the rest: list to discover earlier sessions, and show <session-id> to read a specific one. Every form prints JSON to stdout, and only sessions belonging to the current project are considered.
Options
Section titled “Options”| Option | Description |
|---|---|
--editor <name> | Editor to read: antigravity, claude-code, codex, copilot, cursor, opencode, or pi. Defaults to the detected editor. |
--max-entries <n> | Maximum transcript entries to return, most recent first (default: 200). Must be a positive integer. |
--root | opencode only: resolve a sub-agent child session up to its top-level ancestor. Rejected for any other editor. |
Subcommands
Section titled “Subcommands”archgate session-context list
Section titled “archgate session-context list”List available sessions for the project as JSON (id, updatedAt, and title for editors that store one), most recent first. Accepts --editor.
archgate session-context listarchgate session-context show
Section titled “archgate session-context show”Read a specific session by ID (from list). An explicit ID always wins over the session the environment points at. Accepts --editor, --max-entries, and --root.
archgate session-context show <session-id>Editor detection
Section titled “Editor detection”Every supported editor marks the processes it spawns, and Archgate reads those markers to work out which editor is asking. Pass --editor to override the result, or to read a different editor’s transcripts.
Some editors also publish the ID of the conversation they are currently running. When one does, Archgate reads that exact conversation rather than the most recent one. This matters when a project has several sessions open at once, where the most recent may not be the conversation you are part of. A published ID that matches no session for the project is ignored and recency applies, so a stale ID never turns a working command into an error.
A published ID only ever applies to the editor that published it. Passing --editor cursor from inside Claude Code reads Cursor’s transcripts by recency.
When more than one editor’s markers are present — an agent running inside another agent — the winner is decided by a fixed order: antigravity, claude-code, codex, copilot, cursor, pi, then opencode. Every match is still reported in the output. That order applies whatever session IDs happen to be published: an empty or unusable ID changes which session is selected, never which editor.
Detection fails when Archgate runs from a plain shell rather than inside an AI editor. The command then exits 1 and asks for --editor.
Output
Section titled “Output”Every invocation reports what it resolved in a detection object alongside the session payload:
{ "detection": { "editor": "claude-code", "via": "CLAUDECODE", "session": "pinned", "candidates": ["claude-code"] }, "sessionFile": "6ee6f0a5-1b2c-4d5e-8f90-a1b2c3d4e5f6.jsonl", "totalEntries": 182, "relevantEntries": 125, "transcript": []}| Field | Meaning |
|---|---|
detection.editor | Editor whose sessions were read |
detection.via | Environment variable that identified the editor, or --editor when you named one |
detection.session | pinned (the editor’s own session ID was used), recent (the most recent session was taken), or explicit (an ID was passed to show). Not reported by list, which selects no single session. |
detection.candidates | Every editor whose marker was present, in precedence order |
sessionId / sessionFile | Identifies the session that was read; which of the two appears depends on the editor |
totalEntries | Entries in the stored session |
relevantEntries | Conversational entries left after skipping bookkeeping events and turns with no prose |
transcript | The last --max-entries of those entries, each with role and contentPreview |
list replaces the session payload with a sessions array. When no session can be read, the reason is written to stderr and the command exits 1.
Editor-specific behavior
Section titled “Editor-specific behavior”- Antigravity and Codex each ship a CLI and a desktop app, and conversations from both distributions are read.
- Codex honors
CODEX_HOME. - Pi honors
PI_CODING_AGENT_DIRandPI_CODING_AGENT_SESSION_DIR. Pi branches a session in place rather than starting a new one, so only the active branch is read — a forked or rewound turn is left out. Pi publishes its session ID only to commands its agent runs, so a command you type yourself is still detected as Pi but selected by recency. - opencode records sub-agent runs as child sessions of the conversation that started them. Child sessions are excluded from
listand from recency selection, so the most recent top-level session is always the main development session. They can still be read by ID withshow, and--rootresolves a child session up to its top-level ancestor — useful when a sub-agent knows its own session ID and needs the conversation it belongs to.
Examples
Section titled “Examples”Read the current session, whichever editor is running:
archgate session-contextList sessions for the detected editor:
archgate session-context listRead another editor’s current session:
archgate session-context --editor opencodeRead a specific earlier session:
archgate session-context show 6ee6f0a5-1b2c-4d5e-8f90-a1b2c3d4e5f6Resolve an opencode sub-agent child session to its top-level ancestor:
archgate session-context show ses_child123 --editor opencode --root