feat: respect XDG_DATA_HOME and CLAUDE_CONFIG_DIR for path resolution#217
feat: respect XDG_DATA_HOME and CLAUDE_CONFIG_DIR for path resolution#217troian wants to merge 1 commit into
Conversation
|
hey @griffinmartin any chance you can take a look |
|
@troian Sorry I've been pretty busy so haven't been testing all the open PRs as much as I have in the past. I'll get to it this week. |
|
I have a similar issue. Running three Claude Team accounts across different project dirs via CLAUDE_CONFIG_DIR + direnv, and the account selection bleeds across all of them because claude-account-source.txt is always written to the hardcoded path. Ended up pre-writing it from a shell wrapper before each opencode launch as a workaround, but that breaks every update. |
|
@markthepixel do you mind trying this PR? |
|
I made a chance to keep the XDG_DATA_HOME and CLAUDE_CONFIG_DIR behavior as-is, but adds OPENCODE_ACCOUNT_SOURCE_FILE as an explicit override for just the persisted account selection file. That covers the case where someone wants one shared OpenCode db and session history, but still wants Claude account selection pinned per workspace, which is my issue |
The plugin hardcoded ~/.local/share/opencode/ and ~/.claude/ for all file paths, ignoring XDG_DATA_HOME and CLAUDE_CONFIG_DIR. This prevented running multiple OpenCode instances in parallel with different Claude accounts, since all instances shared the same claude-account-source.txt. Changes: - credentials.ts: getAccountStateFile() and getAuthJsonPaths() use $XDG_DATA_HOME with fallback to ~/.local/share - keychain.ts: readCredentialsFile() and writeBackCredentials() use $CLAUDE_CONFIG_DIR with fallback to ~/.claude - logger.ts: getDefaultLogPath() uses $XDG_DATA_HOME with fallback to ~/.local/share - Tests added for all new paths; existing tests updated to isolate env vars that now affect path resolution - README updated with env var docs and parallel instance usage When unset, behavior is unchanged (same defaults as before). Signed-off-by: Artur Troian <troian@users.noreply.github.com>
5c134cf to
bed47d0
Compare
|
@griffinmartin bump for review |
The plugin hardcoded ~/.local/share/opencode/ and ~/.claude/ for all file paths, ignoring XDG_DATA_HOME and CLAUDE_CONFIG_DIR. This prevented running multiple OpenCode instances in parallel with different Claude accounts, since all instances shared the same claude-account-source.txt. Changes:
When unset, behavior is unchanged (same defaults as before).
Summary
Related issue
Testing
Checklist
feat:,fix:,docs:,chore:, etc.)make allpasses locally (runs lint, build, and test)