fix(opencode): support custom data dir and DB prefix#620
Open
ozymandiashh wants to merge 1 commit into
Open
Conversation
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
Fixes #617 by teaching the OpenCode provider how to read renamed or forked OpenCode-compatible installs without changing the default OpenCode behavior.
Root cause
The provider always derived the OpenCode data root as:
and only discovered SQLite files matching:
That works for upstream OpenCode, but forks such as MiMoCode can keep the same storage schema while writing to a different data directory and DB prefix, for example:
In that case CodeBurn silently reported zero OpenCode usage because neither the directory nor the DB filename matched the hard-coded defaults.
What changed
OPENCODE_DATA_DIRas an exact OpenCode-compatible data directory override.OPENCODE_DB_PREFIXfor SQLite discovery, so forks can expose files such asmimocode.dbormimocode-channel.db.$XDG_DATA_HOME/opencode~/.local/share/opencodeopencode*.dbstorage/.Behavior
OPENCODE_DATA_DIRis treated as the exact data directory. CodeBurn does not append anopencodesuffix to it.OPENCODE_DB_PREFIXonly affects SQLite discovery. File-based storage is still discovered from<OPENCODE_DATA_DIR>/storage/.One edge case is handled intentionally: an empty
OPENCODE_DB_PREFIXfalls back to the defaultopencodeprefix. Without that guard, an empty prefix would match every.dbfile in the data directory.Compatibility and safety
createOpenCodeProvider(tmpDir)test fixtures keep working because that explicit test seam still appendsopencode.Testing
Passed:
Also ran a held-out smoke test that creates both a fork-style
mimocode/mimicode.dband a defaultopencode/opencode.dbstore, then verifies both discovery modes. It printed:Full suite note:
The full suite still has unrelated failures in
tests/cli-proxy-path.test.tsandtests/cli-status-menubar.test.ts. I reproduced the same failure classes onmainbefore this change, so they are not introduced by this PR.