oh-my-opencode/src/shared/data-path.ts
YeonGyu-Kim 7b7c14301e fix(dcp): correct storage path to match OpenCode's actual location
DCP was failing to find session messages because it was looking in
~/.config/opencode/sessions instead of ~/.local/share/opencode/storage.
Unified all hooks to use getOpenCodeStorageDir() for cross-platform consistency.

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-28 16:13:50 +09:00

23 lines
693 B
TypeScript

import * as path from "node:path"
import * as os from "node:os"
/**
* Returns the user-level data directory.
* Matches OpenCode's behavior via xdg-basedir:
* - All platforms: XDG_DATA_HOME or ~/.local/share
*
* Note: OpenCode uses xdg-basedir which returns ~/.local/share on ALL platforms
* including Windows, so we match that behavior exactly.
*/
export function getDataDir(): string {
return process.env.XDG_DATA_HOME ?? path.join(os.homedir(), ".local", "share")
}
/**
* Returns the OpenCode storage directory path.
* All platforms: ~/.local/share/opencode/storage
*/
export function getOpenCodeStorageDir(): string {
return path.join(getDataDir(), "opencode", "storage")
}