Skip to content

feat: respect XDG_DATA_HOME and CLAUDE_CONFIG_DIR for path resolution#217

Open
troian wants to merge 1 commit intogriffinmartin:mainfrom
troian:feat/xdg-data-home-support
Open

feat: respect XDG_DATA_HOME and CLAUDE_CONFIG_DIR for path resolution#217
troian wants to merge 1 commit intogriffinmartin:mainfrom
troian:feat/xdg-data-home-support

Conversation

@troian
Copy link
Copy Markdown

@troian troian commented May 1, 2026

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).

Summary

Related issue

Testing

Checklist

  • PR title follows Conventional Commits (feat:, fix:, docs:, chore:, etc.)
  • make all passes locally (runs lint, build, and test)
  • Tests added or updated where applicable
  • README or docs updated where applicable

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant