feat: make @anthropic-ai/claude-code an optional dependency

This change makes the Claude Code SDK package optional, preventing installation failures for users who don't need Claude Code functionality.

Changes:
- Added @anthropic-ai/claude-code to optionalDependencies in package.json
- Implemented lazy loading in language-model.js to only import the SDK when actually used
- Updated documentation to explain the optional installation requirement
- Applied formatting fixes to ensure code consistency

Benefits:
- Users without Claude Code subscriptions don't need to install the dependency
- Reduces package size for users who don't use Claude Code
- Prevents installation failures if the package is unavailable
- Provides clear error messages when the package is needed but not installed

The implementation uses dynamic imports to load the SDK only when doGenerate() or doStream() is called, ensuring the provider can be instantiated without the package present.
This commit is contained in:
Ben Vargas
2025-06-17 11:54:59 -06:00
committed by Ralph Khreish
parent 7defcba465
commit b62cb1bbe7
12 changed files with 321 additions and 40 deletions

View File

@@ -60,7 +60,11 @@ task-master set-status --id=task-001 --status=in-progress
## Requirements
1. Claude Code CLI must be installed and authenticated on your system
2. No API key is required in your environment variables or MCP configuration
2. Install the optional `@anthropic-ai/claude-code` package if you enable this provider:
```bash
npm install @anthropic-ai/claude-code
```
3. No API key is required in your environment variables or MCP configuration
## Advanced Settings