Implements Claude Code as a new AI provider that uses the Claude Code CLI without requiring API keys. This enables users to leverage Claude models through their local Claude Code installation. Key changes: - Add complete AI SDK v1 implementation for Claude Code provider - Custom SDK with streaming/non-streaming support - Session management for conversation continuity - JSON extraction for object generation mode - Support for advanced settings (maxTurns, allowedTools, etc.) - Integrate Claude Code into Task Master's provider system - Update ai-services-unified.js to handle keyless authentication - Add provider to supported-models.json with opus/sonnet models - Ensure correct maxTokens values are applied (opus: 32000, sonnet: 64000) - Fix maxTokens configuration issue - Add max_tokens property to getAvailableModels() output - Update setModel() to properly handle claude-code models - Create update-config-tokens.js utility for init process - Add comprehensive documentation - User guide with configuration examples - Advanced settings explanation and future integration options The implementation maintains full backward compatibility with existing providers while adding seamless Claude Code support to all Task Master commands.
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
/**
|
|
* src/ai-providers/claude-code.js
|
|
*
|
|
* Implementation for interacting with Claude models via Claude Code CLI
|
|
* using a custom AI SDK implementation.
|
|
*/
|
|
|
|
import { createClaudeCode } from './custom-sdk/claude-code/index.js';
|
|
import { BaseAIProvider } from './base-provider.js';
|
|
|
|
export class ClaudeCodeProvider extends BaseAIProvider {
|
|
constructor() {
|
|
super();
|
|
this.name = 'Claude Code';
|
|
}
|
|
|
|
/**
|
|
* Override validateAuth to skip API key validation for Claude Code
|
|
* @param {object} params - Parameters to validate
|
|
*/
|
|
validateAuth(params) {
|
|
// Claude Code doesn't require an API key
|
|
// No validation needed
|
|
}
|
|
|
|
/**
|
|
* Creates and returns a Claude Code client instance.
|
|
* @param {object} params - Parameters for client initialization
|
|
* @param {string} [params.baseURL] - Optional custom API endpoint (not used by Claude Code)
|
|
* @returns {Function} Claude Code client function
|
|
* @throws {Error} If initialization fails
|
|
*/
|
|
getClient(params) {
|
|
try {
|
|
// Claude Code doesn't use API keys or base URLs
|
|
// Just return the provider factory
|
|
return createClaudeCode({
|
|
defaultSettings: {
|
|
// Add any default settings if needed
|
|
// These can be overridden per request
|
|
}
|
|
});
|
|
} catch (error) {
|
|
this.handleError('client initialization', error);
|
|
}
|
|
}
|
|
} |