Skip to content

Read and share authentication credentials from OpenCode #10

Description

@yan-ad

Summary

Make Crabcode read and share authentication credentials from OpenCode so users can switch from OpenCode without re-entering provider credentials.

Motivation

Crabcode is intended to replace the Node-based OpenCode CLI and already reads OpenCode configuration files such as opencode.jsonc. However, authentication is currently stored separately at:

~/.local/state/crabcode/auth.json

OpenCode stores credentials at:

~/.local/share/opencode/auth.json

This requires users to authenticate again and creates duplicate credential stores.

Proposed solution

Adopt OpenCode's authentication file as Crabcode's canonical auth source:

  • Read $XDG_DATA_HOME/opencode/auth.json
  • Default to ~/.local/share/opencode/auth.json
  • Preserve existing Crabcode credentials through a one-time migration or safe fallback
  • Ensure login, logout, and credential updates use the canonical OpenCode path
  • Preserve secure file permissions and test isolation

Acceptance criteria

  • Existing OpenCode credentials are detected automatically
  • Crabcode can authenticate using ~/.local/share/opencode/auth.json
  • Existing Crabcode credentials are migrated or safely used as fallback
  • OpenCode credentials are never overwritten unintentionally
  • Login and logout operate on the selected canonical store
  • XDG path behavior is covered by tests
  • Authentication documentation is updated

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