From b4f8765be2d95aa33863ef32e230483390bb1f52 Mon Sep 17 00:00:00 2001 From: Sean Smith Date: Wed, 4 Feb 2026 12:39:04 -0600 Subject: [PATCH 1/2] fix: respect XDG base directory env vars for config and log paths Config loader now checks XDG_CONFIG_HOME before falling back to ~/.config/opencode. Logger now uses XDG_DATA_HOME (defaulting to ~/.local/share) for log storage, which is where runtime data belongs per the XDG Base Directory Specification. No behavior change for users with default (unset) XDG paths. --- lib/config.ts | 4 +++- lib/logger.ts | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/config.ts b/lib/config.ts index 714daffb..2eb12cdf 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -526,7 +526,9 @@ const defaultConfig: PluginConfig = { }, } -const GLOBAL_CONFIG_DIR = join(homedir(), ".config", "opencode") +const GLOBAL_CONFIG_DIR = process.env.XDG_CONFIG_HOME + ? join(process.env.XDG_CONFIG_HOME, "opencode") + : join(homedir(), ".config", "opencode") const GLOBAL_CONFIG_PATH_JSONC = join(GLOBAL_CONFIG_DIR, "dcp.jsonc") const GLOBAL_CONFIG_PATH_JSON = join(GLOBAL_CONFIG_DIR, "dcp.json") diff --git a/lib/logger.ts b/lib/logger.ts index 972a1fb1..79aff818 100644 --- a/lib/logger.ts +++ b/lib/logger.ts @@ -9,8 +9,9 @@ export class Logger { constructor(enabled: boolean) { this.enabled = enabled - const opencodeConfigDir = join(homedir(), ".config", "opencode") - this.logDir = join(opencodeConfigDir, "logs", "dcp") + const dataHome = + process.env.XDG_DATA_HOME || join(homedir(), ".local", "share") + this.logDir = join(dataHome, "opencode", "logs", "dcp") } private async ensureLogDir() { From 29191fe2923d2720c02ad1cd08ec23560fc206ad Mon Sep 17 00:00:00 2001 From: Sean Smith Date: Wed, 4 Feb 2026 15:33:58 -0600 Subject: [PATCH 2/2] fix: respect XDG_DATA_HOME in state persistence storage path STORAGE_DIR in persistence.ts also hardcoded ~/.local/share instead of checking XDG_DATA_HOME. Same pattern as the logger fix. --- lib/state/persistence.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/state/persistence.ts b/lib/state/persistence.ts index e73f78f0..0c368380 100644 --- a/lib/state/persistence.ts +++ b/lib/state/persistence.ts @@ -25,7 +25,13 @@ export interface PersistedSessionState { lastUpdated: string } -const STORAGE_DIR = join(homedir(), ".local", "share", "opencode", "storage", "plugin", "dcp") +const STORAGE_DIR = join( + process.env.XDG_DATA_HOME || join(homedir(), ".local", "share"), + "opencode", + "storage", + "plugin", + "dcp", +) async function ensureStorageDir(): Promise { if (!existsSync(STORAGE_DIR)) {