Skip to content

Commit 581cfad

Browse files
anandgupta42claude
andcommitted
fix: use .altimate-code/memory as primary storage path with .opencode fallback
Memory store was hardcoded to `.opencode/memory/` but the config system already uses `.altimate-code` as primary with `.opencode` as fallback. Now checks for `.altimate-code/` directory first, falls back to `.opencode/`, and defaults to `.altimate-code/` for new projects. Result is cached per process to avoid repeated filesystem checks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a3eaeca commit 581cfad

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

packages/opencode/src/memory/store.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// altimate_change - Altimate Memory persistent store
22
import fs from "fs/promises"
3+
import fsSync from "fs"
34
import path from "path"
45
import { Global } from "@/global"
56
import { Instance } from "@/project/instance"
@@ -12,9 +13,23 @@ function globalDir(): string {
1213
return path.join(Global.Path.data, "memory")
1314
}
1415

16+
// altimate_change start - use .altimate-code (primary) with .opencode (fallback)
17+
let _cachedProjectDir: string | undefined
1518
function projectDir(): string {
16-
return path.join(Instance.directory, ".opencode", "memory")
19+
if (_cachedProjectDir) return _cachedProjectDir
20+
const primary = path.join(Instance.directory, ".altimate-code", "memory")
21+
const fallback = path.join(Instance.directory, ".opencode", "memory")
22+
// Use .altimate-code if it exists, fall back to .opencode, default to .altimate-code for new projects
23+
if (fsSync.existsSync(path.join(Instance.directory, ".altimate-code"))) {
24+
_cachedProjectDir = primary
25+
} else if (fsSync.existsSync(path.join(Instance.directory, ".opencode"))) {
26+
_cachedProjectDir = fallback
27+
} else {
28+
_cachedProjectDir = primary
29+
}
30+
return _cachedProjectDir
1731
}
32+
// altimate_change end
1833

1934
function dirForScope(scope: "global" | "project"): string {
2035
return scope === "global" ? globalDir() : projectDir()

0 commit comments

Comments
 (0)