-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: add Claude Code provider for local CLI integration #4864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR integrates support for the Claude Code provider via a locally installed CLI tool, extending both the backend API and the settings UI.
- Introduces new provider-specific files for handling CLI execution and streaming responses.
- Updates UI components and provider settings to include configuration for the Claude Code CLI tool.
- Refactors type definitions and API handler resolution to support the new provider.
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| webview-ui/src/components/settings/providers/index.ts | Exports the new ClaudeCode settings component. |
| webview-ui/src/components/settings/providers/ClaudeCode.tsx | Adds the UI component for configuring the Claude Code CLI path. |
| webview-ui/src/components/settings/constants.ts | Updates provider models and provider list to include Claude Code. |
| webview-ui/src/components/settings/ApiOptions.tsx | Integrates the new Claude Code option in the provider selection UI. |
| src/shared/api.ts | Refactors ApiHandlerOptions type import for consistency. |
| src/integrations/claude-code/types.ts | Adds type definitions for messages from the Claude Code CLI integration. |
| src/integrations/claude-code/run.ts | Implements CLI execution logic for the Claude Code provider. |
| src/api/transform/stream.ts | Extends stream types to include error chunk handling. |
| src/api/retry.ts | Incorporates retry logic for API calls with error handling. |
| src/api/providers/index.ts | Exports the new ClaudeCodeHandler for API provider resolution. |
| src/api/providers/claude-code.ts | Implements the Claude Code API handler with streaming support. |
| src/api/index.ts | Updates handler construction to include the Claude Code provider. |
| packages/types/src/providers/index.ts | Exports new provider types including Claude Code. |
| packages/types/src/providers/claude-code.ts | Defines type information and default model IDs for Claude Code. |
| packages/types/src/provider-settings.ts | Extends provider settings schemas to include Claude Code configuration. |
| packages/types/src/api.ts | Updates ApiHandlerOptions definition for new provider support. |
|
✅ Fixed the knip CI failure by removing the unused |
daniel-lxs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
- Use cost_usd from CLI response when available - Fall back to calculating cost based on token usage and model pricing - Ensures consistent cost reporting across all providers
- Only use cost_usd from CLI response when provided - Default to 0 when CLI doesn't provide cost (e.g., subscription users) - Don't calculate cost based on token usage as it may not apply to all users
5770341 to
7dd9357
Compare
- Added processExitedWithError translation key to all supported languages - This replaces concatenated translation calls with a single unified key - Allows for more natural word order in non-English languages - Addresses review feedback from PR #4864
daniel-lxs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleaned this up a bit, it had some changes to the types that were unnecessary.
Co-authored-by: Copilot <[email protected]> Co-authored-by: Daniel <[email protected]> Co-authored-by: Daniel Riccio <[email protected]> Co-authored-by: Matt Rubens <[email protected]>
…4864) Co-authored-by: Copilot <[email protected]> Co-authored-by: Daniel <[email protected]> Co-authored-by: Daniel Riccio <[email protected]> Co-authored-by: Matt Rubens <[email protected]>
…4864) Co-authored-by: Copilot <[email protected]> Co-authored-by: Daniel <[email protected]> Co-authored-by: Daniel Riccio <[email protected]> Co-authored-by: Matt Rubens <[email protected]>
Description
This PR adds the "Claude Code" provider, adding support for using Claude models through a locally installed command-line tool so users can take advantage of their Claude Code Pro and Max subscriptions within Roo Code
Changes Made
claudeCLI toolApiHandlerOptionstype to the shared types package for proper module boundariesTechnical Details
New Files
packages/types/src/providers/claude-code.ts- Model definitions for Claude Codesrc/api/providers/claude-code.ts- Main handler implementationsrc/integrations/claude-code/run.ts- CLI execution logic using execasrc/integrations/claude-code/types.ts- Response type definitionswebview-ui/src/components/settings/providers/ClaudeCode.tsx- Settings UI componentModified Files
claudeCodePathconfigurationTesting
How to Use
claudeexecutable (or leave blank to use PATH)Notes
This PR ports the "Claude Code" provider from an external pull request (cline/cline PR #4111), adding support for using Claude models through a locally installed command-line tool.
Important
Adds Claude Code provider for local CLI integration, including model definitions, handler implementation, CLI execution logic, and UI configuration.
claude-code.ts: Model definitions.claude-code.ts: Main handler implementation.run.ts: CLI execution logic using execa.ClaudeCode.tsxfor settings UI component.ApiHandlerOptionsto shared types package.This description was created by
for c32f71c. You can customize this summary. It will automatically update as commits are pushed.