Skip to content

fix: rewrite opencode session-context to read from SQLite database#275

Merged
rhuanbarreto merged 1 commit into
mainfrom
fix/opencode-session-context-sqlite
May 6, 2026
Merged

fix: rewrite opencode session-context to read from SQLite database#275
rhuanbarreto merged 1 commit into
mainfrom
fix/opencode-session-context-sqlite

Conversation

@rhuanbarreto

Copy link
Copy Markdown
Contributor

Summary

  • Opencode migrated from JSON file storage (storage/session/, storage/message/) to a SQLite database (opencode.db). The previous implementation read from directories that no longer exist, causing archgate session-context opencode to always fail with "No opencode session storage found".
  • Rewrote readOpencodeSession to query the SQLite database directly using bun:sqlite, matching sessions by the directory column, joining messages and parts for transcript building, and filtering out synthetic parts (editor context).
  • Added opencodeDbPath() helper to paths.ts for resolving the database location ($XDG_DATA_HOME/opencode/opencode.db).
  • Rewrote all tests to use SQLite fixtures with try/catch cleanup for Windows EBUSY resilience.

Test plan

  • All 11 readOpencodeSession tests pass (happy path, session lookup, role filtering, maxEntries, truncation, synthetic filtering, tool parts, error cases)
  • All 4 command registration tests pass
  • bun run validate passes (725 tests, 23 ADR rules, build check)
  • Manual test: run archgate session-context opencode in a project with opencode sessions and verify transcript is returned

Opencode migrated from JSON files (storage/session/, storage/message/)
to a SQLite database (opencode.db). The previous implementation read
from directories that no longer exist, causing session-context to always
fail with "No opencode session storage found".

Rewrite readOpencodeSession to query the SQLite database directly using
bun:sqlite. Sessions are matched by comparing the directory column to
the project root. Messages and parts are joined to build the transcript,
with synthetic parts (editor context) filtered out.

Add opencodeDbPath() helper to paths.ts for resolving the database
location ($XDG_DATA_HOME/opencode/opencode.db).

Rewrite all tests to use SQLite fixtures with try/catch cleanup for
Windows EBUSY resilience.

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying archgate-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: f58d379
Status: ✅  Deploy successful!
Preview URL: https://9e18f916.archgate-cli.pages.dev
Branch Preview URL: https://fix-opencode-session-context.archgate-cli.pages.dev

View logs

@rhuanbarreto rhuanbarreto merged commit fc7857e into main May 6, 2026
10 checks passed
@rhuanbarreto rhuanbarreto deleted the fix/opencode-session-context-sqlite branch May 6, 2026 11:32
@archgatebot archgatebot Bot mentioned this pull request May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant