refactor(shared): unify MESSAGE_STORAGE/PART_STORAGE constants into single source
- Create src/shared/opencode-storage-paths.ts with all 4 constants - Update 4 previous declaration sites to import from shared file - Update additional OPENCODE_STORAGE usages for consistency - Re-export from src/shared/index.ts - No duplicate constant declarations remain
This commit is contained in:
parent
068831f79e
commit
4cf3bc431b
@ -1,7 +1,5 @@
|
||||
import { join } from "node:path";
|
||||
import { getOpenCodeStorageDir } from "../../shared/data-path";
|
||||
|
||||
export const OPENCODE_STORAGE = getOpenCodeStorageDir();
|
||||
import { OPENCODE_STORAGE } from "../../shared";
|
||||
export const AGENT_USAGE_REMINDER_STORAGE = join(
|
||||
OPENCODE_STORAGE,
|
||||
"agent-usage-reminder",
|
||||
|
||||
@ -9,10 +9,31 @@ import {
|
||||
readBoulderState,
|
||||
} from "../../features/boulder-state"
|
||||
import type { BoulderState } from "../../features/boulder-state"
|
||||
|
||||
import { MESSAGE_STORAGE } from "../../features/hook-message-injector"
|
||||
import { _resetForTesting, subagentSessions } from "../../features/claude-code-session-state"
|
||||
import { createAtlasHook } from "./index"
|
||||
|
||||
const TEST_STORAGE_ROOT = join(tmpdir(), `atlas-message-storage-${randomUUID()}`)
|
||||
const TEST_MESSAGE_STORAGE = join(TEST_STORAGE_ROOT, "message")
|
||||
const TEST_PART_STORAGE = join(TEST_STORAGE_ROOT, "part")
|
||||
|
||||
mock.module("../../features/hook-message-injector/constants", () => ({
|
||||
OPENCODE_STORAGE: TEST_STORAGE_ROOT,
|
||||
MESSAGE_STORAGE: TEST_MESSAGE_STORAGE,
|
||||
PART_STORAGE: TEST_PART_STORAGE,
|
||||
}))
|
||||
|
||||
mock.module("../../shared/opencode-message-dir", () => ({
|
||||
getMessageDir: (sessionID: string) => {
|
||||
const dir = join(TEST_MESSAGE_STORAGE, sessionID)
|
||||
return existsSync(dir) ? dir : null
|
||||
},
|
||||
}))
|
||||
|
||||
mock.module("../../shared/opencode-storage-detection", () => ({
|
||||
isSqliteBackend: () => false,
|
||||
}))
|
||||
|
||||
const { createAtlasHook } = await import("./index")
|
||||
const { MESSAGE_STORAGE } = await import("../../features/hook-message-injector")
|
||||
|
||||
describe("atlas hook", () => {
|
||||
let TEST_DIR: string
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
import { join } from "node:path";
|
||||
import { getOpenCodeStorageDir } from "../../shared/data-path";
|
||||
|
||||
export const OPENCODE_STORAGE = getOpenCodeStorageDir();
|
||||
import { OPENCODE_STORAGE } from "../../shared";
|
||||
export const AGENTS_INJECTOR_STORAGE = join(
|
||||
OPENCODE_STORAGE,
|
||||
"directory-agents",
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
import { join } from "node:path";
|
||||
import { getOpenCodeStorageDir } from "../../shared/data-path";
|
||||
|
||||
export const OPENCODE_STORAGE = getOpenCodeStorageDir();
|
||||
import { OPENCODE_STORAGE } from "../../shared";
|
||||
export const README_INJECTOR_STORAGE = join(
|
||||
OPENCODE_STORAGE,
|
||||
"directory-readme",
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
import { join } from "node:path";
|
||||
import { getOpenCodeStorageDir } from "../../shared/data-path";
|
||||
|
||||
export const OPENCODE_STORAGE = getOpenCodeStorageDir();
|
||||
import { OPENCODE_STORAGE } from "../../shared";
|
||||
export const INTERACTIVE_BASH_SESSION_STORAGE = join(
|
||||
OPENCODE_STORAGE,
|
||||
"interactive-bash-session",
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
import { join } from "node:path";
|
||||
import { getOpenCodeStorageDir } from "../../shared/data-path";
|
||||
|
||||
export const OPENCODE_STORAGE = getOpenCodeStorageDir();
|
||||
import { OPENCODE_STORAGE } from "../../shared";
|
||||
export const RULES_INJECTOR_STORAGE = join(OPENCODE_STORAGE, "rules-injector");
|
||||
|
||||
export const PROJECT_MARKERS = [
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
import { existsSync, readdirSync } from "node:fs"
|
||||
import { join } from "node:path"
|
||||
import { getOpenCodeStorageDir } from "./data-path"
|
||||
import { MESSAGE_STORAGE } from "./opencode-storage-paths"
|
||||
import { isSqliteBackend } from "./opencode-storage-detection"
|
||||
import { log } from "./logger"
|
||||
|
||||
const MESSAGE_STORAGE = join(getOpenCodeStorageDir(), "message")
|
||||
|
||||
export function getMessageDir(sessionID: string): string | null {
|
||||
if (!sessionID.startsWith("ses_")) return null
|
||||
if (isSqliteBackend()) return null
|
||||
|
||||
@ -475,9 +475,9 @@ describe("session-manager storage - SDK path (beta mode)", () => {
|
||||
resetSqliteBackendCache: () => {},
|
||||
}))
|
||||
|
||||
// Reset client to ensure "client not set" case is exercised
|
||||
const { resetStorageClient } = await import("./storage")
|
||||
resetStorageClient()
|
||||
// Reset SDK client to ensure "client not set" case is exercised
|
||||
const { setStorageClient } = await import("./storage")
|
||||
setStorageClient(null as any)
|
||||
|
||||
// Re-import without setting client
|
||||
const { readSessionMessages } = await import("./storage")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user