chore: apply requested coderabbit changes#1388
Conversation
|
WalkthroughRemoved upfront API-key presence checks across multiple AI provider Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Provider.getClient(params)
participant Base as BaseAIProvider
participant SDK as Provider SDK (createX)
rect rgb(240, 248, 255)
Caller->>Base: this.createProxyFetch()
Base-->>Caller: fetchImpl (maybe falsy)
end
alt fetchImpl truthy
rect rgb(220, 255, 220)
Caller->>SDK: createX({ ..., fetch: fetchImpl, ... })
SDK-->>Caller: client
end
else fetchImpl falsy
rect rgb(255, 250, 220)
Caller->>SDK: createX({ ... }) Note right of SDK: no fetch injected
SDK-->>Caller: client
end
end
alt initialization error
SDK-->>Caller: throws
Caller->>Caller: this.handleError('client initialization', error)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–25 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🧰 Additional context used📓 Path-based instructions (9)tests/unit/ai-providers/*.test.js📄 CodeRabbit inference engine (.cursor/rules/ai_providers.mdc)
Files:
tests/{unit,integration,e2e,fixtures}/**/*.js📄 CodeRabbit inference engine (.cursor/rules/architecture.mdc)
Files:
**/*.{test,spec}.{js,ts,jsx,tsx}📄 CodeRabbit inference engine (.cursor/rules/git_workflow.mdc)
Files:
**/*.test.js📄 CodeRabbit inference engine (.cursor/rules/tests.mdc)
Files:
tests/unit/**/*.test.js📄 CodeRabbit inference engine (.cursor/rules/tests.mdc)
Files:
tests/{unit,integration,e2e}/**/*.test.js📄 CodeRabbit inference engine (.cursor/rules/tests.mdc)
Files:
**/*.js📄 CodeRabbit inference engine (.cursor/rules/tests.mdc)
Files:
**/*.{test,spec}.*📄 CodeRabbit inference engine (.cursor/rules/test_workflow.mdc)
Files:
tests/{unit,integration,e2e}/**📄 CodeRabbit inference engine (.cursor/rules/test_workflow.mdc)
Files:
🧠 Learnings (17)📓 Common learnings📚 Learning: 2025-07-18T17:16:13.793ZApplied to files:
📚 Learning: 2025-07-18T17:16:13.793ZApplied to files:
📚 Learning: 2025-10-31T18:07:17.402ZApplied to files:
📚 Learning: 2025-07-18T17:06:04.909ZApplied to files:
📚 Learning: 2025-07-18T17:06:57.833ZApplied to files:
📚 Learning: 2025-07-18T17:18:17.759ZApplied to files:
📚 Learning: 2025-07-18T17:06:57.833ZApplied to files:
📚 Learning: 2025-07-18T17:06:04.909ZApplied to files:
📚 Learning: 2025-07-18T17:12:57.903ZApplied to files:
📚 Learning: 2025-07-18T17:06:57.833ZApplied to files:
📚 Learning: 2025-07-18T17:06:04.909ZApplied to files:
📚 Learning: 2025-09-29T13:33:46.952ZApplied to files:
📚 Learning: 2025-07-18T17:07:39.336ZApplied to files:
📚 Learning: 2025-07-18T17:16:13.793ZApplied to files:
📚 Learning: 2025-07-18T17:16:13.793ZApplied to files:
📚 Learning: 2025-07-18T17:06:04.909ZApplied to files:
🧬 Code graph analysis (1)tests/unit/ai-providers/openai-compatible.test.js (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (4)
Comment |
a8b27ab to
219a350
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
src/ai-providers/google.js (1)
31-44: Update JSDoc to reflect deferred validation.The JSDoc comment at line 29 states the method "throws Error If API key is missing," but there's no explicit API key validation before calling
createGoogleGenerativeAI. Validation is now deferred to the SDK initialization.Apply this diff to update the JSDoc:
/** * Creates and returns a Google AI client instance. * @param {object} params - Parameters for client initialization * @param {string} params.apiKey - Google API key * @param {string} [params.baseURL] - Optional custom API endpoint * @returns {Function} Google AI client function - * @throws {Error} If API key is missing or initialization fails + * @throws {Error} If initialization fails */src/ai-providers/perplexity.js (1)
31-44: Update JSDoc to reflect deferred validation.Similar to other providers, the JSDoc comment at line 29 states the method "throws Error If API key is missing," but validation is now deferred to SDK initialization.
Apply this diff:
/** * Creates and returns a Perplexity client instance. * @param {object} params - Parameters for client initialization * @param {string} params.apiKey - Perplexity API key * @param {string} [params.baseURL] - Optional custom API endpoint * @returns {Function} Perplexity client function - * @throws {Error} If API key is missing or initialization fails + * @throws {Error} If initialization fails */src/ai-providers/anthropic.js (1)
42-58: Update JSDoc to reflect deferred validation.The JSDoc at line 40 states the method "throws Error If API key is missing," but there's no explicit validation. Validation is deferred to SDK initialization.
Apply this diff:
/** * Creates and returns an Anthropic client instance. * @param {object} params - Parameters for client initialization * @param {string} params.apiKey - Anthropic API key * @param {string} [params.baseURL] - Optional custom API endpoint * @returns {Function} Anthropic client function - * @throws {Error} If API key is missing or initialization fails + * @throws {Error} If initialization fails */src/ai-providers/openai.js (1)
31-44: Update JSDoc to reflect deferred validation.The JSDoc at line 29 states the method "throws Error If API key is missing," but validation is now deferred to SDK initialization.
Apply this diff:
/** * Creates and returns an OpenAI client instance. * @param {object} params - Parameters for client initialization * @param {string} params.apiKey - OpenAI API key * @param {string} [params.baseURL] - Optional custom API endpoint * @returns {Function} OpenAI client function - * @throws {Error} If API key is missing or initialization fails + * @throws {Error} If initialization fails */
🧹 Nitpick comments (1)
src/ai-providers/azure.js (1)
48-61: Update JSDoc forgetClientto clarify validation timing.The JSDoc at line 46 incorrectly claims the method "throws Error If required parameters are missing," but validation is deferred to
validateParams(called beforegetClientin the public API methods). ThevalidateAuthmethod is used invalidateParams(base-provider.js line 93) and should not be removed.Update the JSDoc to remove the misleading
@throwsclause regarding required parameters, since parameter validation happens invalidateParamsbeforegetClientis invoked:/** * Creates and returns an Azure OpenAI client instance. * @param {object} params - Parameters for client initialization * @param {string} params.apiKey - Azure OpenAI API key * @param {string} params.baseURL - Azure OpenAI endpoint URL * @returns {Function} Azure OpenAI client function * @throws {Error} If client initialization fails */
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
src/ai-providers/anthropic.js(1 hunks)src/ai-providers/azure.js(1 hunks)src/ai-providers/bedrock.js(1 hunks)src/ai-providers/google-vertex.js(2 hunks)src/ai-providers/google.js(1 hunks)src/ai-providers/groq.js(0 hunks)src/ai-providers/openai-compatible.js(2 hunks)src/ai-providers/openai.js(1 hunks)src/ai-providers/openrouter.js(0 hunks)src/ai-providers/perplexity.js(1 hunks)src/ai-providers/xai.js(0 hunks)tests/unit/config-manager.test.js(1 hunks)
💤 Files with no reviewable changes (3)
- src/ai-providers/groq.js
- src/ai-providers/openrouter.js
- src/ai-providers/xai.js
🧰 Additional context used
📓 Path-based instructions (10)
src/ai-providers/*.js
📄 CodeRabbit inference engine (.cursor/rules/ai_providers.mdc)
src/ai-providers/*.js: Create a new provider module file in src/ai-providers/ named .js when adding a new AI provider.
Provider modules must export three functions: generateText, streamText, and generateObject.
Provider modules must import the provider's create function from @ai-sdk/, and import generateText, streamText, generateObject from the core ai package, as well as the log utility from ../../scripts/modules/utils.js.
Implement generateText, streamText, and generateObject functions in provider modules with basic validation and try/catch error handling.Provider-specific wrappers for Vercel AI SDK functions must be implemented in src/ai-providers/*.js, each file corresponding to a provider.
Files:
src/ai-providers/openai.jssrc/ai-providers/bedrock.jssrc/ai-providers/azure.jssrc/ai-providers/anthropic.jssrc/ai-providers/openai-compatible.jssrc/ai-providers/google-vertex.jssrc/ai-providers/google.jssrc/ai-providers/perplexity.js
**/*.js
📄 CodeRabbit inference engine (.cursor/rules/tests.mdc)
**/*.js: Declare and initialize global variables at the top of modules to avoid hoisting issues.
Use proper function declarations to avoid hoisting issues and initialize variables before they are referenced.
Do not reference variables before their declaration in module scope.
Use dynamic imports (import()) to avoid initialization order issues in modules.
Files:
src/ai-providers/openai.jssrc/ai-providers/bedrock.jssrc/ai-providers/azure.jssrc/ai-providers/anthropic.jssrc/ai-providers/openai-compatible.jstests/unit/config-manager.test.jssrc/ai-providers/google-vertex.jssrc/ai-providers/google.jssrc/ai-providers/perplexity.js
tests/{unit,integration,e2e,fixtures}/**/*.js
📄 CodeRabbit inference engine (.cursor/rules/architecture.mdc)
Test files must be organized as follows: unit tests in tests/unit/, integration tests in tests/integration/, end-to-end tests in tests/e2e/, and test fixtures in tests/fixtures/.
Files:
tests/unit/config-manager.test.js
tests/unit/*.js
📄 CodeRabbit inference engine (.cursor/rules/architecture.mdc)
Each module should have a corresponding unit test file in tests/unit/ that reflects the module structure (one test file per module).
Files:
tests/unit/config-manager.test.js
**/*.{test,spec}.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/git_workflow.mdc)
**/*.{test,spec}.{js,ts,jsx,tsx}: Create a test file and ensure all tests pass when all subtasks are complete; commit tests if added or modified
When all subtasks are complete, run final testing using the appropriate test runner (e.g., npm test, jest, or manual testing)
Files:
tests/unit/config-manager.test.js
**/*.test.js
📄 CodeRabbit inference engine (.cursor/rules/tests.mdc)
**/*.test.js: Never use asynchronous operations in tests. Make all mocks return synchronous values when possible.
Always mock tests properly based on the way the tested functions are defined and used.
Follow the test file organization: mocks must be set up before importing modules under test, and spies on mocked modules should be set up after imports.
Use fixtures from tests/fixtures/ for consistent sample data across tests.
Always declare mocks before importing the modules being tested in Jest test files.
Use jest.spyOn() after imports to create spies on mock functions and reference these spies in test assertions.
When testing functions with callbacks, get the callback from your mock's call arguments, execute it directly with test inputs, and verify the results.
For ES modules, use jest.mock() before static imports and jest.unstable_mockModule() before dynamic imports to mock dependencies.
Reset mock functions (mockFn.mockReset()) before dynamic imports if they might have been called previously.
When verifying console assertions, assert against the actual arguments passed (single formatted string), not multiple arguments.
Use mock-fs to mock file system operations in tests, and restore the file system after each test.
Mock API calls (e.g., Anthropic/Claude) by mocking the entire module and providing predictable responses.
Set mock environment variables in test setup and restore them after each test.
Maintain test fixtures separate from test logic.
Follow the mock-first-then-import pattern for all Jest mocks.
Do not define mock variables before jest.mock() calls (they won't be accessible due to hoisting).
Use test-specific file paths (e.g., 'test-tasks.json') for all file operations in tests.
Mock readJSON and writeJSON to avoid real file system interactions in tests.
Verify file operations use the correct paths in expect statements.
Use different file paths for each test to avoid test interdependence.
Verify modifications on the in-memory task objects passed to w...
Files:
tests/unit/config-manager.test.js
tests/unit/**/*.test.js
📄 CodeRabbit inference engine (.cursor/rules/tests.mdc)
tests/unit/**/*.test.js: Unit tests must be located in tests/unit/, test individual functions and utilities in isolation, mock all external dependencies, and keep tests small, focused, and fast.
Do not include actual command execution in unit tests.
Files:
tests/unit/config-manager.test.js
tests/{unit,integration,e2e}/**/*.test.js
📄 CodeRabbit inference engine (.cursor/rules/tests.mdc)
tests/{unit,integration,e2e}/**/*.test.js: When testing CLI commands built with Commander.js, test the command action handlers directly rather than trying to mock the entire Commander.js chain.
When mocking the Commander.js chain, mock ALL chainable methods (option, argument, action, on, etc.) and return this (or the mock object) from all chainable method mocks.
Explicitly handle all options, including defaults and shorthand flags (e.g., -p for --prompt), and include null/undefined checks in test implementations for parameters that might be optional.
Do not try to use the real action implementation without proper mocking, and do not mock Commander partially—either mock it completely or test the action directly.
Mock the action handlers for CLI commands and verify they're called with correct arguments.
Use sample task fixtures for consistent test data, mock file system operations, and test both success and error paths for task operations.
Mock console output and verify correct formatting in UI function tests. Use flexible assertions like toContain() or toMatch() for formatted output.
Mock chalk functions to return the input text to make testing easier while still verifying correct function calls.
Files:
tests/unit/config-manager.test.js
**/*.{test,spec}.*
📄 CodeRabbit inference engine (.cursor/rules/test_workflow.mdc)
Test files should follow naming conventions: .test., .spec., or _test. depending on the language
Files:
tests/unit/config-manager.test.js
tests/{unit,integration,e2e}/**
📄 CodeRabbit inference engine (.cursor/rules/test_workflow.mdc)
Organize test directories by test type (unit, integration, e2e) and mirror source structure where possible
Files:
tests/unit/config-manager.test.js
🧠 Learnings (25)
📓 Common learnings
Learnt from: Crunchyman-ralph
Repo: eyaltoledano/claude-task-master PR: 1232
File: packages/build-config/package.json:14-15
Timestamp: 2025-09-22T19:45:13.323Z
Learning: In the eyaltoledano/claude-task-master repository, Crunchyman-ralph intentionally omits version fields from internal packages (like tm/build-config) to prevent changesets from releasing new versions for these packages. This is the desired behavior for internal tooling packages that should not be published or versioned independently.
Learnt from: Crunchyman-ralph
Repo: eyaltoledano/claude-task-master PR: 1232
File: packages/tm-core/package.json:50-51
Timestamp: 2025-09-22T19:45:04.337Z
Learning: In the eyaltoledano/claude-task-master project, Crunchyman-ralph intentionally omits version fields from internal/private packages in package.json files to prevent changesets from releasing new versions of these packages while still allowing them to be processed for dependency updates. The changesets warnings about missing versions are acceptable as they don't break the process and achieve the desired behavior of only releasing public packages.
Learnt from: Crunchyman-ralph
Repo: eyaltoledano/claude-task-master PR: 1246
File: src/ai-providers/claude-code.js:40-42
Timestamp: 2025-09-29T13:33:46.952Z
Learning: Claude Code provider should use environment variable isolation to control API key access, temporarily managing ANTHROPIC_API_KEY during client creation to prevent the ai-sdk-provider-claude-code package from automatically picking up API keys intended for other providers, while allowing explicit CLAUDE_CODE_API_KEY usage as a fallback to OAuth authentication.
Learnt from: Crunchyman-ralph
Repo: eyaltoledano/claude-task-master PR: 1246
File: src/ai-providers/claude-code.js:40-42
Timestamp: 2025-09-29T13:33:46.952Z
Learning: Claude Code provider should use environment variable isolation to temporarily manage ANTHROPIC_API_KEY during client creation: if CLAUDE_CODE_API_KEY is set, temporarily set ANTHROPIC_API_KEY to that value; if CLAUDE_CODE_API_KEY is not set but ANTHROPIC_API_KEY exists, temporarily unset ANTHROPIC_API_KEY to force OAuth mode. This prevents the ai-sdk-provider-claude-code package from accidentally using API keys intended for the regular Anthropic provider while still allowing explicit API key usage as a fallback.
Learnt from: Crunchyman-ralph
Repo: eyaltoledano/claude-task-master PR: 1178
File: packages/tm-core/src/auth/config.ts:5-7
Timestamp: 2025-09-02T21:51:27.921Z
Learning: The user Crunchyman-ralph prefers not to use node: scheme imports (e.g., 'node:os', 'node:path') for Node.js core modules and considers suggestions to change bare imports to node: scheme as too nitpicky.
Learnt from: Crunchyman-ralph
Repo: eyaltoledano/claude-task-master PR: 1069
File: .changeset/fix-tag-complexity-detection.md:0-0
Timestamp: 2025-08-02T15:33:22.656Z
Learning: For changeset files (.changeset/*.md), Crunchyman-ralph prefers to ignore formatting nitpicks about blank lines between frontmatter and descriptions, as he doesn't mind having them and wants to avoid such comments in future reviews.
Learnt from: Crunchyman-ralph
Repo: eyaltoledano/claude-task-master PR: 1132
File: .github/workflows/weekly-metrics-discord.yml:81-93
Timestamp: 2025-08-13T22:10:46.958Z
Learning: Crunchyman-ralph ignores YAML formatting nitpicks about trailing spaces when there's no project-specific YAML formatter configured, preferring to focus on functionality over cosmetic formatting issues.
Learnt from: Crunchyman-ralph
Repo: eyaltoledano/claude-task-master PR: 1132
File: .github/workflows/weekly-metrics-discord.yml:81-93
Timestamp: 2025-08-13T22:10:46.958Z
Learning: Crunchyman-ralph ignores YAML formatting nitpicks about trailing spaces when there's no project-specific YAML formatter configured, preferring to focus on functionality over cosmetic formatting issues.
Learnt from: Crunchyman-ralph
Repo: eyaltoledano/claude-task-master PR: 1105
File: scripts/modules/supported-models.json:242-254
Timestamp: 2025-08-08T11:33:15.297Z
Learning: Preference: In scripts/modules/supported-models.json, the "name" field is optional. For OpenAI entries (e.g., "gpt-5"), Crunchyman-ralph prefers omitting "name" when the id is explicit enough; avoid nitpicks requesting a "name" in such cases.
Learnt from: Crunchyman-ralph
Repo: eyaltoledano/claude-task-master PR: 1200
File: src/ai-providers/custom-sdk/grok-cli/language-model.js:96-100
Timestamp: 2025-09-19T16:06:42.182Z
Learning: The user Crunchyman-ralph prefers to keep environment variable names explicit (like GROK_CLI_API_KEY) rather than supporting multiple aliases, to avoid overlap and ensure clear separation between different CLI implementations.
Learnt from: Crunchyman-ralph
Repo: eyaltoledano/claude-task-master PR: 1178
File: packages/tm-core/src/subpath-exports.test.ts:6-9
Timestamp: 2025-09-03T12:45:30.724Z
Learning: The user Crunchyman-ralph prefers to avoid overly nitpicky or detailed suggestions in code reviews, especially for test coverage of minor import paths. Focus on more substantial issues rather than comprehensive coverage of all possible edge cases.
Learnt from: Crunchyman-ralph
Repo: eyaltoledano/claude-task-master PR: 1217
File: apps/cli/src/index.ts:16-21
Timestamp: 2025-09-18T16:35:35.147Z
Learning: The user Crunchyman-ralph considers suggestions to export types for better ergonomics (like exporting UpdateInfo type alongside related functions) as nitpicky and prefers not to implement such suggestions.
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
Repo: eyaltoledano/claude-task-master PR: 0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : Do not use real AI client initialization logic in tests; create test-specific paths that bypass client initialization.
Applied to files:
src/ai-providers/openai.jssrc/ai-providers/bedrock.jstests/unit/config-manager.test.jssrc/ai-providers/google-vertex.jssrc/ai-providers/google.js
📚 Learning: 2025-07-18T17:06:57.833Z
Learnt from: CR
Repo: eyaltoledano/claude-task-master PR: 0
File: .cursor/rules/ai_services.mdc:0-0
Timestamp: 2025-07-18T17:06:57.833Z
Learning: Applies to scripts/modules/ai-services-unified.js : Do not handle API key resolution outside the service layer (it uses `utils.js` internally).
Applied to files:
src/ai-providers/openai.jssrc/ai-providers/google.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
Repo: eyaltoledano/claude-task-master PR: 0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : Do not import real AI service clients in tests; create fully mocked versions that return predictable responses.
Applied to files:
src/ai-providers/openai.jssrc/ai-providers/bedrock.jstests/unit/config-manager.test.jssrc/ai-providers/google-vertex.jssrc/ai-providers/google.js
📚 Learning: 2025-09-24T15:46:28.029Z
Learnt from: Crunchyman-ralph
Repo: eyaltoledano/claude-task-master PR: 1114
File: src/ai-providers/gemini-cli.js:12-12
Timestamp: 2025-09-24T15:46:28.029Z
Learning: When AI SDK provider packages are moved from optional dependencies to required dependencies in package.json, static imports should be used instead of dynamic imports with error handling, as the package is guaranteed to be available at runtime.
Applied to files:
src/ai-providers/openai.jssrc/ai-providers/google.js
📚 Learning: 2025-07-18T17:18:17.759Z
Learnt from: CR
Repo: eyaltoledano/claude-task-master PR: 0
File: .cursor/rules/utilities.mdc:0-0
Timestamp: 2025-07-18T17:18:17.759Z
Learning: Applies to scripts/modules/config-manager.js : Use `isApiKeySet(providerName, session)` from `config-manager.js` to check if a provider's key is available before attempting an AI call.
Applied to files:
src/ai-providers/openai.jssrc/ai-providers/google.js
📚 Learning: 2025-07-18T17:06:57.833Z
Learnt from: CR
Repo: eyaltoledano/claude-task-master PR: 0
File: .cursor/rules/ai_services.mdc:0-0
Timestamp: 2025-07-18T17:06:57.833Z
Learning: Applies to scripts/modules/ai-services-unified.js : Do not fetch AI-specific parameters (model ID, max tokens, temp) using `config-manager.js` getters for the AI call. Pass the `role` instead.
Applied to files:
src/ai-providers/openai.jssrc/ai-providers/google-vertex.jssrc/ai-providers/google.js
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
Repo: eyaltoledano/claude-task-master PR: 0
File: .cursor/rules/ai_providers.mdc:0-0
Timestamp: 2025-07-18T17:06:04.909Z
Learning: Applies to src/ai-providers/*.js : Provider modules must import the provider's create<ProviderName> function from ai-sdk/<provider-name>, and import generateText, streamText, generateObject from the core ai package, as well as the log utility from ../../scripts/modules/utils.js.
Applied to files:
src/ai-providers/openai.jssrc/ai-providers/bedrock.jssrc/ai-providers/google.js
📚 Learning: 2025-07-18T17:06:57.833Z
Learnt from: CR
Repo: eyaltoledano/claude-task-master PR: 0
File: .cursor/rules/ai_services.mdc:0-0
Timestamp: 2025-07-18T17:06:57.833Z
Learning: Applies to scripts/modules/task-manager/*.js : Do not fetch AI-specific parameters (model ID, max tokens, temp) using `config-manager.js` getters for the AI call. Pass the `role` instead.
Applied to files:
src/ai-providers/openai.js
📚 Learning: 2025-07-18T17:06:57.833Z
Learnt from: CR
Repo: eyaltoledano/claude-task-master PR: 0
File: .cursor/rules/ai_services.mdc:0-0
Timestamp: 2025-07-18T17:06:57.833Z
Learning: Applies to scripts/modules/commands.js : Do not fetch AI-specific parameters (model ID, max tokens, temp) using `config-manager.js` getters for the AI call. Pass the `role` instead.
Applied to files:
src/ai-providers/openai.js
📚 Learning: 2025-10-31T18:07:17.402Z
Learnt from: Crunchyman-ralph
Repo: eyaltoledano/claude-task-master PR: 1360
File: src/ai-providers/glm.js:0-0
Timestamp: 2025-10-31T18:07:17.402Z
Learning: In src/ai-providers/glm.js, the GLM provider's getClient method should allow defaulting to the 'coding' endpoint when an invalid or unspecified route parameter is provided, as this is the correct behavior per Z.ai's OpenAI-compatible API documentation. Do not enforce strict route validation that throws errors for unknown routes.
Applied to files:
src/ai-providers/openai.jssrc/ai-providers/bedrock.jssrc/ai-providers/azure.jssrc/ai-providers/anthropic.jssrc/ai-providers/openai-compatible.jssrc/ai-providers/google-vertex.jssrc/ai-providers/google.js
📚 Learning: 2025-09-29T13:33:46.952Z
Learnt from: Crunchyman-ralph
Repo: eyaltoledano/claude-task-master PR: 1246
File: src/ai-providers/claude-code.js:40-42
Timestamp: 2025-09-29T13:33:46.952Z
Learning: Claude Code provider should use environment variable isolation to temporarily manage ANTHROPIC_API_KEY during client creation: if CLAUDE_CODE_API_KEY is set, temporarily set ANTHROPIC_API_KEY to that value; if CLAUDE_CODE_API_KEY is not set but ANTHROPIC_API_KEY exists, temporarily unset ANTHROPIC_API_KEY to force OAuth mode. This prevents the ai-sdk-provider-claude-code package from accidentally using API keys intended for the regular Anthropic provider while still allowing explicit API key usage as a fallback.
Applied to files:
src/ai-providers/anthropic.js
📚 Learning: 2025-09-29T13:33:46.952Z
Learnt from: Crunchyman-ralph
Repo: eyaltoledano/claude-task-master PR: 1246
File: src/ai-providers/claude-code.js:40-42
Timestamp: 2025-09-29T13:33:46.952Z
Learning: Claude Code provider should use environment variable isolation to control API key access, temporarily managing ANTHROPIC_API_KEY during client creation to prevent the ai-sdk-provider-claude-code package from automatically picking up API keys intended for other providers, while allowing explicit CLAUDE_CODE_API_KEY usage as a fallback to OAuth authentication.
Applied to files:
src/ai-providers/anthropic.js
📚 Learning: 2025-09-29T13:33:46.952Z
Learnt from: Crunchyman-ralph
Repo: eyaltoledano/claude-task-master PR: 1246
File: src/ai-providers/claude-code.js:40-42
Timestamp: 2025-09-29T13:33:46.952Z
Learning: Claude Code provider should use CLAUDE_CODE_API_KEY environment variable instead of automatically picking up ANTHROPIC_API_KEY to avoid conflicts, since the ai-sdk-provider-claude-code package follows standard Anthropic patterns and prioritizes API keys over OAuth authentication, which can cause unexpected API charges.
Applied to files:
src/ai-providers/anthropic.js
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
Repo: eyaltoledano/claude-task-master PR: 0
File: .cursor/rules/ai_providers.mdc:0-0
Timestamp: 2025-07-18T17:06:04.909Z
Learning: Applies to scripts/modules/config-manager.js : Update scripts/modules/config-manager.js to add the new provider to MODEL_MAP, ensure it is included in VALID_PROVIDERS, and update API key handling logic.
Applied to files:
src/ai-providers/openai-compatible.jstests/unit/config-manager.test.js
📚 Learning: 2025-07-18T17:12:57.903Z
Learnt from: CR
Repo: eyaltoledano/claude-task-master PR: 0
File: .cursor/rules/new_features.mdc:0-0
Timestamp: 2025-07-18T17:12:57.903Z
Learning: Applies to scripts/modules/**/*.test.js : Test core logic independently with both data formats, mock file system operations, test tag resolution behavior, and verify migration compatibility in unit tests.
Applied to files:
tests/unit/config-manager.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
Repo: eyaltoledano/claude-task-master PR: 0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to tests/{unit,integration,e2e}/**/*.test.js : Use sample task fixtures for consistent test data, mock file system operations, and test both success and error paths for task operations.
Applied to files:
tests/unit/config-manager.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
Repo: eyaltoledano/claude-task-master PR: 0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to tests/{integration,e2e}/**/*.test.js : Properly mock session objects when required by functions, and reset environment variables between tests if modified.
Applied to files:
tests/unit/config-manager.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
Repo: eyaltoledano/claude-task-master PR: 0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : Do not test exact error messages; test for error presence and general properties instead.
Applied to files:
tests/unit/config-manager.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
Repo: eyaltoledano/claude-task-master PR: 0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to tests/{unit,integration,e2e}/**/*.test.js : Do not try to use the real action implementation without proper mocking, and do not mock Commander partially—either mock it completely or test the action directly.
Applied to files:
tests/unit/config-manager.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
Repo: eyaltoledano/claude-task-master PR: 0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : Verify modifications on the in-memory task objects passed to writeJSON.
Applied to files:
tests/unit/config-manager.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
Repo: eyaltoledano/claude-task-master PR: 0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : Use fixtures from tests/fixtures/ for consistent sample data across tests.
Applied to files:
tests/unit/config-manager.test.js
📚 Learning: 2025-08-08T11:34:45.482Z
Learnt from: Crunchyman-ralph
Repo: eyaltoledano/claude-task-master PR: 1105
File: .changeset/vast-weeks-fetch.md:5-5
Timestamp: 2025-08-08T11:34:45.482Z
Learning: In this repo, the supported models list is auto-generated by CI into docs/models.md from scripts/modules/supported-models.json via .github/workflows/update-models-md.yml and docs/scripts/models-json-to-markdown.js. Don’t request manual edits to the Markdown; ensure the JSON is correct instead.
Applied to files:
tests/unit/config-manager.test.js
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
Repo: eyaltoledano/claude-task-master PR: 0
File: .cursor/rules/ai_providers.mdc:0-0
Timestamp: 2025-07-18T17:06:04.909Z
Learning: Applies to src/ai-providers/*.js : Implement generate<ProviderName>Text, stream<ProviderName>Text, and generate<ProviderName>Object functions in provider modules with basic validation and try/catch error handling.
Applied to files:
src/ai-providers/google.js
📚 Learning: 2025-07-18T17:07:39.336Z
Learnt from: CR
Repo: eyaltoledano/claude-task-master PR: 0
File: .cursor/rules/architecture.mdc:0-0
Timestamp: 2025-07-18T17:07:39.336Z
Learning: Applies to src/ai-providers/*.js : Provider-specific wrappers for Vercel AI SDK functions must be implemented in src/ai-providers/*.js, each file corresponding to a provider.
Applied to files:
src/ai-providers/google.js
🧬 Code graph analysis (2)
tests/unit/config-manager.test.js (1)
tests/unit/config-manager.test.mjs (3)
REAL_SUPPORTED_MODELS_DATA(24-24)REAL_SUPPORTED_MODELS_CONTENT(23-23)realSupportedModelsPath(19-22)
src/ai-providers/perplexity.js (1)
scripts/modules/ai-services-unified.js (1)
baseURL(544-544)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test
🔇 Additional comments (12)
tests/unit/config-manager.test.js (1)
73-88: LGTM! Improved error handling for test setup.The variable rename removes the underscore prefix for clearer naming, and the enhanced error handling with
process.exit(1)ensures tests fail fast when critical test data cannot be loaded. Setting defaults prevents undefined behavior in edge cases.src/ai-providers/google-vertex.js (2)
95-111: Conditional fetch implementation looks good.The pattern of creating
fetchImpllocally and conditionally including it in the client configuration is correct and consistent with the broader refactor across providers.
92-116:validateAuthis not unused—it's called through the inheritance chain; the validation architecture is working as designed.The validation flow is:
- Public API methods (
generateText,streamText, etc.) →validateParams()→validateAuth()getClient()is a lower-level method that assumes validation already occurred upstreamThe
validateAuthmethod at lines 56-79 is properly invoked throughvalidateParams(inherited fromBaseAIProviderline 93) whenever callers use the public API methods. The JSDoc comment at lines 81-89 is slightly misleading sincegetClient()itself doesn't directly validate, but this is intentional design—validation occurs at the public API level, not the client creation level.No changes are needed; the implementation is correct.
Likely an incorrect or invalid review comment.
src/ai-providers/google.js (1)
34-39: Conditional fetch implementation is correct.The pattern is consistent with other providers in this refactor.
src/ai-providers/perplexity.js (1)
34-39: Conditional fetch implementation is correct.src/ai-providers/bedrock.js (1)
35-47: Conditional fetch implementation is correct.The pattern is consistent with other providers. The empty
validateAuthoverride at line 28 is appropriate for Bedrock since it uses AWS credential chains rather than API keys.src/ai-providers/azure.js (1)
51-56: Conditional fetch implementation is correct.src/ai-providers/anthropic.js (1)
45-53: Conditional fetch implementation is correct.src/ai-providers/openai.js (1)
34-39: Conditional fetch implementation is correct.src/ai-providers/openai-compatible.js (3)
123-126: LGTM: Clean conditional fetch assignment.The conditional fetch assignment follows the same defensive pattern used for other optional config properties (apiKey, baseURL, supportsStructuredOutputs) and prevents adding undefined/null values to the client configuration.
96-132: Disregard the validation concern—validateAuth is properly invoked before getClient at a higher level.The original review comment assumes
validateAuthis bypassed, but it's actually called fromvalidateParams()(in base-provider.js lines 91–93) before any of the generation methods invokegetClient(). The call order is:validateParams()→validateAuth()→getClient(). SincevalidateAuth()throws an error whenrequiresApiKeyis true andapiKeyis missing, the SDK is never initialized with incomplete credentials. This is the correct architectural pattern, and the implementation is working as intended.
99-99: createProxyFetch is correctly implemented and accessible.The method exists in BaseAIProvider at line 63 and is properly invoked in getClient at line 99.
Regarding the validation pattern: the review comment's concern about deferred API key validation is inaccurate. Validation still occurs before getClient is called—the validateAuth method is invoked during the validateParams chain in generateText/streamText/generateObject, which happens at line 201/249/280 of base-provider.js. The conditional apiKey inclusion in clientConfig at lines 109-110 is the correct pattern; it only adds the key if needed, and the SDK will work appropriately whether the key is present or absent based on the provider's requirements.
All changes in the snippet are correct implementations.
…ply.requested.changes chore: apply requested coderabbit changes
What type of PR is this?
Description
Related Issues
How to Test This
# Example commands or stepsExpected result:
Contributor Checklist
npm run changesetnpm testnpm run format-check(ornpm run formatto fix)Changelog Entry
For Maintainers
Summary by CodeRabbit
Refactor
Tests