Skip to content

Feature/support for vertexai accounts#2

Open
giefferre wants to merge 8 commits into
dr5hn:mainfrom
giefferre:feature/support-for-vertexai-accounts
Open

Feature/support for vertexai accounts#2
giefferre wants to merge 8 commits into
dr5hn:mainfrom
giefferre:feature/support-for-vertexai-accounts

Conversation

@giefferre
Copy link
Copy Markdown

Summary

Add first-class Google VertexAI account support alongside existing OAuth accounts. CCM can now manage mixed fleets of OAuth and VertexAI identities with full feature parity: switching, isolated profiles, export/import, health checks, and statusline display.

Motivation

Claude Code supports authentication via Google VertexAI (CLAUDE_CODE_USE_VERTEX=1 in settings.json), but CCM's account model was built entirely around OAuth email-based identity. Users running VertexAI cannot use CCM at all — ccm add fails because no .oauthAccount exists. This PR makes VertexAI a first-class account type, identified by GCP project ID instead of email.

Design decisions

  • Auto-detection over manual flags: ccm add reads settings.json for CLAUDE_CODE_USE_VERTEX=1 and branches automatically — no --type vertex flag needed.
  • Full env block as credential: The entire VertexAI env var set from settings.json (project ID, region, model pins, caching flags, service account path) is captured and restored as a unit, preserving configuration fidelity across switches.
  • Clean transitions: Switching between OAuth and VertexAI removes the inactive type's configuration (.oauthAccount or VertexAI env vars) to prevent ambiguous auth state.
  • Display format: VertexAI accounts render as vertex:project-id everywhere (list, statusline, history, export).

Changes

ccm.sh (+1114 / -375 lines):

  • Schema bump 3.1 → 4.0 with additive migration (adds "type": "oauth" to existing accounts)
  • ~10 new VertexAI helper functions: get_account_type(), get_account_display_id(), get_current_account_type(), read_vertex_env() / write_vertex_env() / clear_vertex_env(), credential backup/restore, account_exists_by_project(), validate_vertex_project_id()
  • Type-aware perform_switch() dispatching four scenarios: OAuth↔OAuth, OAuth→Vertex, Vertex→OAuth, Vertex↔Vertex
  • cmd_add_account() refactored into _add_oauth_account() + _add_vertex_account()
  • Updated: cmd_list, cmd_verify, cmd_remove_account, cmd_export, cmd_import, cmd_reorder, cmd_recover, switch_isolated, profiles_sync, cmd_history, cmd_setup, embedded statusline heredoc
  • resolve_account_identifier() now searches by project ID (4th dimension after number, email, alias)

statusline.sh: Mirrored VertexAI detection from embedded heredoc — reads CLAUDE_CODE_USE_VERTEX and ANTHROPIC_VERTEX_PROJECT_ID from settings.json, matches against sequence.json by .projectId.

Documentation: CHANGELOG.md, README.md, CLAUDE.md, ccm/SKILL.md, index.html, statusline.html updated with VertexAI references, examples, and corrected architecture line ranges.

Retro-compatibility

  • Existing OAuth accounts are unaffected. The schema migration is purely additive.
  • All existing commands, flags, and output formats are preserved for OAuth accounts.
  • bash -n ccm.sh passes on every commit.

Test plan

  • ccm version — shows 4.3.0
  • ccm doctor — all 13 checks pass
  • ccm list — existing OAuth accounts display normally with type: "oauth" after migration
  • Configure a VertexAI session in settings.json, run ccm add — auto-detects and registers as vertex type
  • ccm list — shows vertex:project-id for VertexAI account
  • ccm switch between OAuth and VertexAI — clean transition, correct config state
  • ccm switch --isolated <vertex-alias> — creates profile with correct env vars
  • ccm verify — validates both OAuth and VertexAI backups
  • ccm recover — detects VertexAI-specific inconsistencies
  • ccm export / ccm import round-trip with mixed account types
  • ccm remove <vertex-account> — cleans up vertex env backup and config
  • Statusline displays vertex:project-id for active VertexAI session
  • index.html and statusline.html render correctly in browser

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