fix: rewrite opencode session-context to read from SQLite database#275
Merged
Conversation
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>
Deploying archgate-cli with
|
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
storage/session/,storage/message/) to a SQLite database (opencode.db). The previous implementation read from directories that no longer exist, causingarchgate session-context opencodeto always fail with "No opencode session storage found".readOpencodeSessionto query the SQLite database directly usingbun:sqlite, matching sessions by thedirectorycolumn, joining messages and parts for transcript building, and filtering out synthetic parts (editor context).opencodeDbPath()helper topaths.tsfor resolving the database location ($XDG_DATA_HOME/opencode/opencode.db).try/catchcleanup for Windows EBUSY resilience.Test plan
readOpencodeSessiontests pass (happy path, session lookup, role filtering, maxEntries, truncation, synthetic filtering, tool parts, error cases)bun run validatepasses (725 tests, 23 ADR rules, build check)archgate session-context opencodein a project with opencode sessions and verify transcript is returned