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]

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.

OptionDescription
--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.
--rootopencode only: resolve a sub-agent child session up to its top-level ancestor. Rejected for any other 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 session the environment points at. Accepts --editor, --max-entries, and --root.

Terminal window
archgate session-context show <session-id>

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.

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": []
}
FieldMeaning
detection.editorEditor whose sessions were read
detection.viaEnvironment variable that identified the editor, or --editor when you named one
detection.sessionpinned (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.candidatesEvery editor whose marker was present, in precedence order
sessionId / sessionFileIdentifies the session that was read; which of the two appears depends on the editor
totalEntriesEntries in the stored session
relevantEntriesConversational entries left after skipping bookkeeping events and turns with no prose
transcriptThe 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.

  • 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_DIR and PI_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 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