microsoft / microsoft/AI-Engineering-Coach
feat(opencode): add SQLite parser so OpenCode sessions load in VS Code
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.2k
- Forks
- 585
- Avg merge
- 22h 5m
- Merged PRs (30d)
- 16
Description
Description
OpenCode migrated its session storage from JSON files to SQLite (opencode.db) in version 0.1.x. This PR restores OpenCode session loading for all users on the current version of OpenCode.
From PR #78
Problem
The extension called parseOpenCodeSessions(storageDir) which looked for JSON files under:
~/.local/share/opencode/storage/session/global/*.json
That directory no longer exists. The data now lives in a SQLite database:
~/.local/share/opencode/opencode.db
Because the directory was empty the parser returned zero sessions silently, so only Claude Code sessions appeared in the dashboard.
Root cause (VS Code runtime)
An initial attempt using better-sqlite3 (native module) also failed silently. child_process.fork() spawns the parse worker using VS Code's Electron binary as the runtime. Electron has its own NODE_MODULE_VERSION (ABI), different from the system Node ABI that better-sqlite3 was compiled against. The require() threw an ABI mismatch error that the try/catch swallowed, returning null with no sessions loaded.
Solution
Use node:sqlite — the built-in SQLite module added in Node 22.5 (stable in Node 23+, always available in Node 24+). VS Code 1.121 ships Electron 37+ / Node 24, so node:sqlite is available in both the extension host and its forked child processes with no native binary, no ABI concerns, and no packaging changes.
The loader tries three backends in order so older VS Code versions and non-standard environments are covered:
node:sqlite— built-in, preferred (works in VS Code 1.121+ and Node 24+)@vscode/sqlite3— async, compiled for VS Code's Electron (fallback for older VS Code)better-sqlite3— synchronous, system-Node compiled (fallback for test environments)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at parseOpenCodeSessions(storageDir) and the forked parse worker; trace how the existing JSON lookup and swallowed errors select a storage backend. Verify completion by loading sessions from ~/.local/share/opencode/opencode.db and checking the documented node:sqlite, @vscode/sqlite3, and better-sqlite3 fallback paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, sqlite, typescript, vscode
- Domain
- desktop, devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100