bun:sqlite Fallback Adapter
Bun runtime is now fully supported. Users running context-mode under Bun (e.g. OpenCode, custom setups) no longer crash with "better-sqlite3 is not yet supported in Bun". The plugin transparently falls back to Bun's built-in bun:sqlite module.
What changed
-
BunSQLiteAdapter— wrapsbun:sqlitewith a better-sqlite3-compatible API. Bridges.pragma(), multi-statement.exec(), and.get()null→undefined conversion. -
loadDatabase()fallback — triesbetter-sqlite3first (Node.js), catches failure → detectsglobalThis.Bun→ loadsbun:sqlitevia adapter. Zero config, zero user action needed. -
SQL-aware statement splitting —
exec()splits multi-statement SQL respecting string literals (won't break on';'inside quotes). -
Direct import fixes —
server.ts(ctx_stats) andcli.ts(doctor) previously hardcodedrequire("better-sqlite3"), bypassing the fallback. Now useloadDatabase().
TDD
8 new tests covering: pragma scalar/array, multi-statement exec, semicolons in string literals, get() null→undefined, run() return shape, transactions, and interface completeness.
Verification
- TypeScript: PASS
- esbuild bundle: PASS (bun:sqlite not statically resolved — uses
Array.join()trick) - Full test suite: 1166 tests, 39 files, 3 OS — all green
- 6-agent architecture review: CI, API compat, cross-OS, adapters/plugins, docs, test coverage
Closes #45
Full diff: v1.0.26...v1.0.27