Hermes + OpenCode Session Manager
Manage Hermes Agent and OpenCode sessions directly within VS Code.
Features
- Hermes Session Manager
- Resume one or more Hermes sessions into VS Code terminal tabs.
- Show a session's recorded directory, with the Hermes CLI Workspace label as a fallback for older sessions.
- Resume a session in its recorded directory when that directory still exists.
- Rename sessions inline.
- Delete single or multiple stopped sessions.
- Optionally delete parent Hermes sessions discovered from
~/.hermes/state.db.
- Stop running sessions by PID.
- Clean untitled/empty sessions, including newly exposed empty child-session chains.
- Create a named session, rename it, and immediately resume it in a terminal.
- OpenCode Session Manager
- Supports both OpenCode V1 and V2 by detecting the installed CLI (
opencode --version, with --help as a fallback) and can be overridden with the hermesSessionManager.opencode.protocol setting.
- List OpenCode sessions across projects from
~/.local/share/opencode/opencode.db (V1 session table, V2 session_v2 table).
- Resume one or more sessions in their original project directories.
- Detect active OpenCode sessions with the matching protocol: V1 queries each process's local
--port status endpoint; V2 uses the shared background service (service.json + /api/session/active), so /fork and /new follow the current session instead of stale startup arguments.
- Discover manually started OpenCode processes, including retained processes after Reload Window.
- Use OpenCode session events to follow rename, fork, and new-session changes while the monitor is active (V1 per-port
/event; V2 shared /api/event).
- Show a directory-level count for idle OpenCode terminals; for a manual idle terminal without
--session, use the most recently updated same-directory session only as a title-sync candidate.
- Delete stopped sessions and stop running OpenCode processes.
- Clean empty/untitled sessions and generated subagent sessions.
- Start a new OpenCode terminal.
- Optionally append
--auto to every extension-started OpenCode terminal. On V1 only, useRandomPort/completionNotifications also append a probed random five-digit --port; V2 ignores --port.
- Notify through VS Code when a discovered session finishes a busy turn; the notification can focus its terminal when association is available.
- On V2 the TUI maintains its own terminal title (
OC | <title>); the extension never sets or rebuilds it.
- Toggle subagent-session visibility from the manager toolbar; the choice persists between openings.
- Explorer Context Menu
- Right-click a folder and run 打开 Hermes.
- Pick one or more Hermes sessions associated with that directory or Git repository, or start a new Hermes terminal in the folder.
- Right-click a folder and run 打开 opencode.
- Pick one or more existing OpenCode sessions for that directory or start a new one.
Requirements
- For Hermes features:
hermes must be installed and available in PATH.
- Hermes directory matching and cwd details require the
sqlite3 CLI because they are read from ~/.hermes/state.db.
- For OpenCode features:
opencode must be installed in PATH or at ~/.opencode/bin/opencode. OpenCode V1 and V2 are both supported.
- OpenCode session listing requires the
sqlite3 CLI because sessions are read from the local OpenCode database.
Settings
| Setting |
Default |
Description |
hermesSessionManager.hermes.yolo |
false |
Appends Hermes's --yolo option to every terminal launched by this extension. This bypasses dangerous command approval prompts. |
hermesSessionManager.opencode.protocol |
auto |
OpenCode protocol version: auto, v1, or v2. auto detects it with opencode --version and falls back to opencode --help. |
hermesSessionManager.opencode.autoApprove |
false |
Appends OpenCode's --auto permission-approval option to terminals launched by this extension. |
hermesSessionManager.opencode.useRandomPort |
false |
V1 only: probes a random port from 10000 to 65535, then passes it as --port <port> to terminals launched by this extension. V2 ignores this option. |
hermesSessionManager.opencode.completionNotifications |
true |
Sends a VS Code notification when a discovered OpenCode session finishes a busy turn and becomes idle. V1 enables a random port for extension-started sessions; V2 uses the shared background service. |
On OpenCode V2 the extension maintains no terminal titles and never rebuilds terminals: the TUI updates its own title and the extension only reports completions. /fork or /new sessions are attributed to a terminal through a best-effort directory match, because V2 exposes no per-terminal status API.
The OpenCode manager toolbar can hide subagent sessions. This choice is remembered locally and uses the session database's parent_id relationship.
Commands
This extension contributes the following command:
Hermes: Resume Sessions: opens the Hermes session manager.
打开 Hermes: folder context menu command for resuming a directory-associated Hermes session or starting one in that directory.
OpenCode: Resume Sessions: opens the OpenCode session manager.
打开 opencode: folder context menu command for opening OpenCode in that directory.
Development
cd extension
npm install
npm test # compile and run Node tests
npm run compile
npx vsce package
code --install-extension hermes-session-manager-0.2.1.vsix --force
Release Notes
0.2.1
Detect the OpenCode protocol on Windows by running the version probe through cmd.exe (npm installs OpenCode as an opencode.cmd shim). Previously detection failed and V2 launches received --port, which the V2 CLI rejects.
Also check opencode.exe/opencode.cmd under ~/.opencode/bin, fall back to a live V2 service registration when CLI probing fails, and log the detected protocol to the output channel.
Added OpenCode V2 support: detect the installed CLI protocol (auto, with a hermesSessionManager.opencode.protocol override), launch terminals without --port, and drive completion notifications from the shared background service (~/.local/state/opencode/service.json, /api/session/active, /api/event).
Read V2 sessions from the session_v2 table; V1 keeps reading the legacy session table.
OpenCode V1 behavior is unchanged: port-based status, per-port events, terminal titles, and explicit title rebuilding stay available for V1 users.
On V2, terminal titles are owned by the TUI (OC | <title>); the extension no longer rebuilds terminals and --port is never passed.
0.1.11
- Discover manually started, port-enabled OpenCode processes and continue monitoring them after Reload Window.
- Use OpenCode session events and idle-session lookup to detect rename, fork, and new-session changes while the monitor is active.
- Keep completion and title-update notifications non-blocking, expose detailed monitor diagnostics in the Output panel, and never rebuild a terminal without an explicit user action.
0.1.10
- Track active OpenCode sessions from each process's status port so
/fork and /new do not leave an old session marked as running.
- Show idle OpenCode terminal counts at the directory level and include session IDs in list details to distinguish same-title forks.
0.1.9
- Mark running OpenCode sessions only when the process explicitly carries
--session <id>.
- Show a directory-level notice for OpenCode processes without a session argument, without guessing a session ID.
- Added an opt-in Hermes
--yolo launch setting.
- Added batch recovery to both directory context-menu session pickers.
- Made Hermes empty-session cleanup rescan orphaned empty child-session chains.
- Added VS Code notifications for extension-started OpenCode sessions that return from busy work to idle.
0.1.8
- Added the
打开 Hermes Explorer action for directory-associated Hermes sessions and new directory-scoped terminals.
- Added title, workspace, and full-path filtering to both session managers.
- Fixed OpenCode session timestamps stored in milliseconds and simplified duplicate directory display.
0.1.7
- Added opt-in OpenCode
--auto and random five-digit --port launch settings.
- Added a persisted toolbar toggle for hiding or showing OpenCode subagent sessions.
0.1.6
- Renamed the public product to Hermes + OpenCode Session Manager.
- Preserved the existing Marketplace extension ID and command IDs for seamless upgrades.
0.1.5
- Refreshed README and changelog to match the current Hermes + OpenCode implementation.
- Updated package metadata for the next VSIX build.
0.1.4
- Added OpenCode session management.
- Added folder context menu entry for OpenCode.
- Added running-process detection, stop actions, cleanup actions, and new-session entry points.
- Fixed Hermes new-session creation in WSL by running
hermes chat -q from the user's home directory.
0.1.0
- Initial release of Hermes Session Manager.
- Features: Batch resume, rename, delete, and new session creation.
- Improved UI with status grouping for running sessions.
| |