Skip to content

archgate session-context

Read AI editor session transcripts for the project. Useful for auditing what an AI agent did during a coding session.

Terminal window
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.

OptionDescription
--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)
--rootopencode only: resolve a sub-agent child session up to its top-level ancestor

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.

EditorDetected byPins the exact session via
AntigravityANTIGRAVITY_AGENTANTIGRAVITY_CONVERSATION_ID, or conversationId inside ANTIGRAVITY_SOURCE_METADATA
Claude CodeCLAUDECODECLAUDE_CODE_SESSION_ID
CodexCODEX_THREAD_IDCODEX_THREAD_ID
Copilot CLICOPILOT_CLICOPILOT_AGENT_SESSION_ID
CursorCURSOR_AGENTCURSOR_CONVERSATION_ID
opencodeOPENCODE, OPENCODE_CLIENT(none — falls back to recency)
PiPI_CODING_AGENTPI_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.

List available sessions for the project as JSON (id, updatedAt, and title for editors that store one), most recent first. Accepts --editor.

Terminal window
archgate session-context list

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.

Terminal window
archgate session-context show <session-id>
  • Antigravity — both the agy CLI and the desktop app write conversations as JSONL under brain/<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 the cwd recorded in each rollout’s session_meta line, 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. Honors CODEX_HOME.
  • Copilot CLI — sessions are matched by their workspace cwd field.
  • 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 cwd is verified as well, so a relocated session directory still resolves. Honors PI_CODING_AGENT_DIR and PI_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 directory field to the project root. Sub-agent runs are recorded as child sessions sharing the parent’s directory; these are excluded from list and from recency selection, so the most recent top-level session is always the main development session. They can still be read by ID with show, and --root resolves 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.

Read the current session, whichever editor is running:

Terminal window
archgate session-context

List sessions for the detected editor:

Terminal window
archgate session-context list

Read another editor’s current session:

Terminal window
archgate session-context --editor opencode

Read a specific earlier session:

Terminal window
archgate session-context show 6ee6f0a5-1b2c-4d5e-8f90-a1b2c3d4e5f6

Resolve an opencode sub-agent child session to its top-level ancestor:

Terminal window
archgate session-context show ses_child123 --editor opencode --root