OpenCode plugin that records the latest non-subagent session ID to a local state file so another LLM can investigate the exact interactive session.
Default state directory:
~/.local/state/opencode/current-session/
Files:
current.json Latest non-subagent session for the OpenCode process
history.jsonl Append-only session update history, including subagents
current.json is intentionally small:
{
"version": 1,
"timestamp": "2026-05-06T00:00:00.000Z",
"source": "chat.message",
"sessionID": "ses_...",
"directory": "/path/to/project",
"worktree": "/path/to/worktree",
"title": "Optional OpenCode title",
"isSubagent": false
}Override the state directory with:
OPENCODE_CURRENT_SESSION_DIR=/tmp/opencode-current-sessionbun install
bun run build
bun run install:localThe install script copies src/index.ts to:
~/.config/opencode/plugins/current-session.ts
Restart OpenCode after installing.
After an interactive OpenCode run:
opencode-current-session
opencode-current-session handoff
opencode-current-session jsonThe handoff command prints a copyable handoff:
Investigate OpenCode session ses_... in ~/.local/share/opencode/opencode.db.
Focus on routing behavior, tool use, subagent handoff quality, evidence quality, and where the agent drifted.
If you do not run it immediately, use the history:
opencode-current-session list
opencode-current-session handoff --index 2
opencode-current-session handoff --directory leadpilot --title CORE-75
opencode-current-session handoff --session-id ses_...prompt remains as an alias for handoff.
OpenCode loads TypeScript plugin files from:
~/.config/opencode/plugins/
No API keys or private logs are written by this plugin. It records only session metadata and local project paths.
bun run typecheck
bun run test
bun run check