Skip to content

Respect XDG_DATA_HOME when syncing auth.json #232

Description

@exiast

Problem

On Linux setups where OpenCode uses a custom XDG_DATA_HOME, this plugin syncs Anthropic OAuth creds to ~/.local/share/opencode/auth.json instead of the active OpenCode data dir.

Repro

  1. Set XDG_DATA_HOME to a non-default path (example: /home/user/work/.local/share).
  2. Use opencode-claude-auth@latest with valid Claude credentials (~/.claude/.credentials.json).
  3. Run OpenCode and check providers.

Observed

  • Plugin debug log shows writes to ~/.local/share/opencode/auth.json.
  • OpenCode reads credentials from $XDG_DATA_HOME/opencode/auth.json.
  • Anthropic provider/models are missing until manual copy is done.

Expected

Plugin should write to $XDG_DATA_HOME/opencode/auth.json on non-Windows (with fallback to ~/.local/share/opencode/auth.json when XDG_DATA_HOME is unset).

Notes

This also affects persisted account source path (claude-account-source.txt) for the same reason.

I have a fix ready and can open PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions