Skip to content

OpenCode provider: add configurable data directory (for renamed/forked builds) #617

Description

@rafalskalski

Summary

The opencode provider hardcodes the data directory to ~/.local/share/opencode/ and only matches DB filenames prefixed opencode. Forks/renamed builds (e.g. MiMoCode → writes to ~/.local/share/mimocode/mimocode.db) silently produce no sessions, with no error to the user.

Reference: src/providers/opencode.ts

function getDataDir(dataDir?: string): string {
  const base =
    dataDir ??
    process.env['XDG_DATA_HOME'] ??
    join(homedir(), '.local', 'share')
  return join(base, 'opencode')   // ← hardcoded; can't point at a fork dir
}

dbFilePrefix: 'opencode' is also hardcoded, so even within the resolved dir only opencode*.db files match.

Reproduction

  1. Install a renamed/forked build of OpenCode that writes session data to e.g. ~/.local/share/mymod/mymod.db (same Drizzle schema: session, message, part).
  2. Run codeburn status --provider opencode.
  3. Result: empty / "no data" — provider silently finds nothing. The user has no signal that the provider is just looking in the wrong place.

Proposed change

Allow users to point the opencode provider at a custom directory and DB filename prefix, mirroring the existing pattern in src/providers/codex.ts (which already accepts CODEX_HOME):

  • Add an env var OPENCODE_DATA_DIR (default: $XDG_DATA_HOME/opencode or ~/.local/share/opencode).
  • Optionally OPENCODE_DB_PREFIX (default: opencode) so the glob opencode*.db is configurable.
  • Or, expose a --provider-data-dir opencode=<path> flag.

Once configurable, the README's "Environment Variables" section should document the new vars.

Workaround

Until this lands, users with renamed builds can symlink:

mv ~/.local/share/opencode/opencode.db{,.stale}
ln -s ~/.local/share/mimocode/mimocode.db ~/.local/share/opencode/opencode.db

Schemas are compatible (verified: session, message, part all present with matching columns), so the symlink works.

Environment

  • codeburn v0.9.15
  • macOS, Node 22.13+
  • Tested DB: fork writes to ~/.local/share/mimocode/mimocode.db (195 MB, 62 non-subtask sessions)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions