[PR #13620] feat: add Claude Code CLI as AI provider #14742

Closed
opened 2026-02-16 18:19:30 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13620

State: closed
Merged: No


Summary

  • Adds claude-cli provider: spawns claude -p --output-format json subprocess for AI completions
  • Adds claude-api provider: borrows Claude Code CLI OAuth credentials to call Anthropic API directly (lower latency)
  • Both providers auto-detected when Claude Code CLI is installed (which claude)

Models

Provider Models How it works
claude-cli opus, opus-4.6, sonnet, haiku Subprocess spawn
claude-api claude-opus-4-5, claude-opus-4-6, claude-sonnet-4-5, claude-haiku-4-5 Direct API with borrowed credentials

Latency Improvements

  • 10min timeout (was 5min) for long pentest analysis prompts
  • Session ID reuse for context continuity across sequential calls
  • Bun.spawnSync instead of execSync for credential reading
  • Cached which claude check (avoids repeated filesystem lookups)
  • Proper process cleanup on timeout (kill + dispose)

New Files

  • packages/cyberstrike/src/auth/cli-credentials.ts - Keychain + file credential reading
  • packages/cyberstrike/src/provider/claude-cli-backend.ts - Subprocess spawn + JSON parse
  • packages/cyberstrike/src/provider/claude-cli-provider.ts - AI SDK LanguageModelV2 wrapper

Test plan

  • Verify claude-cli provider appears in model list when Claude CLI is installed
  • Verify claude-api provider appears when valid credentials exist
  • Test subprocess execution with claude-cli/sonnet model
  • Test API mode with claude-api/claude-sonnet-4-5-20250514
  • Verify graceful fallback when Claude CLI is not installed (no errors, providers just don't appear)

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13620 **State:** closed **Merged:** No --- ## Summary - Adds **claude-cli** provider: spawns `claude -p --output-format json` subprocess for AI completions - Adds **claude-api** provider: borrows Claude Code CLI OAuth credentials to call Anthropic API directly (lower latency) - Both providers auto-detected when Claude Code CLI is installed (`which claude`) ## Models | Provider | Models | How it works | |---|---|---| | `claude-cli` | opus, opus-4.6, sonnet, haiku | Subprocess spawn | | `claude-api` | claude-opus-4-5, claude-opus-4-6, claude-sonnet-4-5, claude-haiku-4-5 | Direct API with borrowed credentials | ## Latency Improvements - 10min timeout (was 5min) for long pentest analysis prompts - Session ID reuse for context continuity across sequential calls - `Bun.spawnSync` instead of `execSync` for credential reading - Cached `which claude` check (avoids repeated filesystem lookups) - Proper process cleanup on timeout (kill + dispose) ## New Files - `packages/cyberstrike/src/auth/cli-credentials.ts` - Keychain + file credential reading - `packages/cyberstrike/src/provider/claude-cli-backend.ts` - Subprocess spawn + JSON parse - `packages/cyberstrike/src/provider/claude-cli-provider.ts` - AI SDK LanguageModelV2 wrapper ## Test plan - [ ] Verify `claude-cli` provider appears in model list when Claude CLI is installed - [ ] Verify `claude-api` provider appears when valid credentials exist - [ ] Test subprocess execution with `claude-cli/sonnet` model - [ ] Test API mode with `claude-api/claude-sonnet-4-5-20250514` - [ ] Verify graceful fallback when Claude CLI is not installed (no errors, providers just don't appear) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
yindo added the pull-request label 2026-02-16 18:19:30 -05:00
yindo closed this issue 2026-02-16 18:19:30 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14742