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)
This commit is contained in:
@@ -2,27 +2,20 @@ import * as path from "node:path"
|
||||
import * as os from "node:os"
|
||||
|
||||
/**
|
||||
* Returns the user-level data directory based on the OS.
|
||||
* - Linux/macOS: XDG_DATA_HOME or ~/.local/share
|
||||
* - Windows: %LOCALAPPDATA%
|
||||
* Returns the user-level data directory.
|
||||
* Matches OpenCode's behavior via xdg-basedir:
|
||||
* - All platforms: XDG_DATA_HOME or ~/.local/share
|
||||
*
|
||||
* This follows XDG Base Directory specification on Unix systems
|
||||
* and Windows conventions on Windows.
|
||||
* Note: OpenCode uses xdg-basedir which returns ~/.local/share on ALL platforms
|
||||
* including Windows, so we match that behavior exactly.
|
||||
*/
|
||||
export function getDataDir(): string {
|
||||
if (process.platform === "win32") {
|
||||
// Windows: Use %LOCALAPPDATA% (e.g., C:\Users\Username\AppData\Local)
|
||||
return process.env.LOCALAPPDATA ?? path.join(os.homedir(), "AppData", "Local")
|
||||
}
|
||||
|
||||
// Unix: Use XDG_DATA_HOME or fallback to ~/.local/share
|
||||
return process.env.XDG_DATA_HOME ?? path.join(os.homedir(), ".local", "share")
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the OpenCode storage directory path.
|
||||
* - Linux/macOS: ~/.local/share/opencode/storage
|
||||
* - Windows: %LOCALAPPDATA%\opencode\storage
|
||||
* All platforms: ~/.local/share/opencode/storage
|
||||
*/
|
||||
export function getOpenCodeStorageDir(): string {
|
||||
return path.join(getDataDir(), "opencode", "storage")
|
||||
|
||||
Reference in New Issue
Block a user