MCPcopy
hub / github.com/RedPlanetHQ/core / getDbPath

Function getDbPath

packages/cli/src/utils/coding-agents/opencode.ts:41–58  ·  view source on GitHub ↗

* Return the path to OpenCode's SQLite database. * * Resolution order: * 1. $XDG_DATA_HOME/opencode/opencode.db — explicit override always wins * 2. ~/Library/Application Support/opencode/opencode.db — macOS native path * (checked only when the file actually exists, so Linux is never pe

()

Source from the content-addressed store, hash-verified

39 * 3. ~/.local/share/opencode/opencode.db — XDG default for Linux + macOS
40 */
41function getDbPath(): string {
42 if (process.env['XDG_DATA_HOME']) {
43 return join(process.env['XDG_DATA_HOME'], 'opencode', 'opencode.db');
44 }
45
46 if (process.platform === 'darwin') {
47 const macPath = join(
48 homedir(),
49 'Library',
50 'Application Support',
51 'opencode',
52 'opencode.db',
53 );
54 if (existsSync(macPath)) return macPath;
55 }
56
57 return join(homedir(), '.local', 'share', 'opencode', 'opencode.db');
58}
59
60function tryOpenDb(): SQLiteDatabase | null {
61 const dbPath = getDbPath();

Callers 3

tryOpenDbFunction · 0.85
getSessionFilePathMethod · 0.85
scanSessionsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected