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]Reads the current conversation — by default for the editor running the command, which Archgate detects from the environment. Two subcommands cover the rest: list to discover earlier sessions, and show <session-id> to read a specific one.
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 entries to return (default: 200) |
--root | opencode only: resolve a sub-agent child session up to its top-level ancestor |
Automatic editor detection
Section titled “Automatic editor detection”Every supported editor sets environment variables on the commands it runs, and Archgate reads them to work out which editor is asking. Pass --editor to override the result, or to read a different editor’s transcripts.
| Editor | Detected by | Pins the exact session via |
|---|---|---|
| Antigravity | ANTIGRAVITY_AGENT | ANTIGRAVITY_CONVERSATION_ID, or conversationId inside ANTIGRAVITY_SOURCE_METADATA |
| Claude Code | CLAUDECODE | CLAUDE_CODE_SESSION_ID |
| Codex | CODEX_THREAD_ID | CODEX_THREAD_ID |
| Copilot CLI | COPILOT_CLI | COPILOT_AGENT_SESSION_ID |
| Cursor | CURSOR_AGENT | CURSOR_CONVERSATION_ID |
| opencode | OPENCODE, OPENCODE_CLIENT | (none — falls back to recency) |
| Pi | PI_CODING_AGENT | PI_SESSION_ID |
Editors that publish their own session id get the 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 session id only ever pins the editor that published it. Passing --editor cursor from inside Claude Code reads Cursor’s transcripts by recency and ignores CLAUDE_CODE_SESSION_ID.
Every command reports what it resolved in a detection object:
{ "detection": { "editor": "claude-code", "via": "CLAUDECODE", "session": "pinned", "candidates": ["claude-code"] }, "sessionFile": "6ee6f0a5-1b2c-4d5e-8f90-a1b2c3d4e5f6.jsonl", "totalEntries": 182, "relevantEntries": 125, "transcript": []}via is the environment variable that identified the editor, or --editor when you named one. session is pinned when the editor’s own session id was used, recent when the most recent session was taken, and explicit when a session id was passed on the command line. candidates lists every editor whose marker was present — more than one appears when an agent runs inside another agent. The winner then comes from a fixed order — Antigravity, Claude Code, Codex, Copilot, Cursor, Pi, then opencode — which ranks the editors that publish a session id ahead of the one that does not. That order applies whatever the ids happen to be: 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.
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 one published by the environment. Accepts --editor, --max-entries, and --root.
archgate session-context show <session-id>How each editor stores sessions
Section titled “How each editor stores sessions”- Antigravity — both the
agyCLI and the desktop app write conversations as JSONL underbrain/<id>/.system_generated/logs/, in~/.gemini/antigravity-cli/and~/.gemini/antigravity/respectively; both are read. The CLI records the workspace in each conversation’s own database, the app in a shared summaries index. A conversation the caller is running inside is read even before that index catches up, since the environment names it. - Claude Code — one JSONL transcript per session, keyed by the encoded project path. Session IDs are the transcript filenames.
- Codex — rollout files under date shards (
sessions/YYYY/MM/DD/), shared by the Codex CLI and the desktop app. Sessions are matched by thecwdrecorded in each rollout’ssession_metaline, and the session ID is the thread ID. The CLI and the desktop app record turns in different event shapes and both are read. Rollouts older than a week are zstd-compressed in place; both forms are read. HonorsCODEX_HOME. - Copilot CLI — sessions are matched by their workspace
cwdfield. - Cursor — sessions are matched by the encoded project path; IDs are UUIDs.
- Pi — sessions live under a directory encoding the working directory, and each file’s header
cwdis verified as well, so a relocated session directory still resolves. HonorsPI_CODING_AGENT_DIRandPI_CODING_AGENT_SESSION_DIR. Pi branches a session in place rather than starting a new file, 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 manually typed command is detected but selected by recency. - opencode — sessions are matched by comparing the session
directoryfield to the project root. Sub-agent runs are recorded as child sessions sharing the parent’s directory; these are excluded fromlistand 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