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

Function tryOpenDb

packages/cli/src/utils/coding-agents/opencode.ts:60–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

58}
59
60function tryOpenDb(): SQLiteDatabase | null {
61 const dbPath = getDbPath();
62 if (!existsSync(dbPath)) return null;
63 try {
64 const {DatabaseSync} = _require('node:sqlite') as {
65 DatabaseSync: new (
66 path: string,
67 opts?: {readOnly?: boolean},
68 ) => SQLiteDatabase;
69 };
70 return new DatabaseSync(dbPath, {readOnly: true});
71 } catch {
72 return null;
73 }
74}
75
76// ─── JSON helpers ─────────────────────────────────────────────────────────────
77

Callers 5

scanFunction · 0.85
sessionExistsMethod · 0.85
sessionUpdatedSinceMethod · 0.85
readSessionOutputMethod · 0.85
scanSessionsMethod · 0.85

Calls 1

getDbPathFunction · 0.85

Tested by

no test coverage detected