refactor(shared): unify MESSAGE_STORAGE/PART_STORAGE constants into single source
- Add src/shared/opencode-storage-paths.ts with consolidated constants - Update imports in hook-message-injector and session-manager - Add src/shared/opencode-storage-detection.ts with isSqliteBackend() - Add OPENCODE_SQLITE_VERSION constant - Export all from shared/index.ts
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { existsSync } from "node:fs"
|
||||
import { join } from "node:path"
|
||||
import { getDataDir } from "./data-path"
|
||||
import { isOpenCodeVersionAtLeast, OPENCODE_SQLITE_VERSION } from "./opencode-version"
|
||||
|
||||
let cachedResult: boolean | null = null
|
||||
|
||||
export function isSqliteBackend(): boolean {
|
||||
if (cachedResult !== null) {
|
||||
return cachedResult
|
||||
}
|
||||
|
||||
const versionOk = isOpenCodeVersionAtLeast(OPENCODE_SQLITE_VERSION)
|
||||
const dbPath = join(getDataDir(), "opencode", "opencode.db")
|
||||
const dbExists = existsSync(dbPath)
|
||||
|
||||
cachedResult = versionOk && dbExists
|
||||
return cachedResult
|
||||
}
|
||||
|
||||
export function resetSqliteBackendCache(): void {
|
||||
cachedResult = null
|
||||
}
|
||||
Reference in New Issue
Block a user