Skip to content

prandelicious/opencode-current-session

opencode-current-session

OpenCode plugin that records the latest non-subagent session ID to a local state file so another LLM can investigate the exact interactive session.

What It Writes

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-session

Install Locally

bun install
bun run build
bun run install:local

The install script copies src/index.ts to:

~/.config/opencode/plugins/current-session.ts

Restart OpenCode after installing.

CLI

After an interactive OpenCode run:

opencode-current-session
opencode-current-session handoff
opencode-current-session json

The 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 Config

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.

Development

bun run typecheck
bun run test
bun run check

About

opencode-current-session records the latest active parent OpenCode session to a local JSON file so other tools or agents can quickly find and hand off into the right session context.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors