feat: Claude Code AI SDK v5 Integration#1114
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (5)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughAdds Claude Code provider integration and docs, standardizes token parameter to maxOutputTokens across providers, switches Gemini CLI to direct import and parameter renaming, updates Ollama provider import, removes GPT-5-specific token handling in OpenAI provider and related tests, introduces a direct Claude Code test script, updates dependencies, and adds API Keys docs/navigation. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User as User/Script
participant TM as Task Master
participant CCP as ClaudeCodeProvider
participant SDK as ai-sdk-provider-claude-code
participant CLI as Claude Code CLI (OAuth)
User->>TM: request text/stream with model "claude-code:sonnet"
TM->>CCP: getClient({ commandName })
CCP->>SDK: createClaudeCode({ defaultSettings })
SDK-->>CLI: resolve token via CLI / ENV
CLI-->>SDK: access token or error
SDK-->>CCP: provider instance
CCP-->>TM: client with languageModel/chat
alt generate
TM->>SDK: generateText(...)
SDK-->>TM: { text, usage }
else stream
TM->>SDK: streamText(...)
SDK-->>TM: textStream chunks + usage
end
note over TM,CCP: Errors mentioning "Claude Code CLI" are wrapped with CLI-not-available guidance
sequenceDiagram
autonumber
participant Call as Caller
participant BP as BaseAIProvider
participant Prov as Concrete Provider
Call->>BP: prepareTokenParam(modelId, maxTokens)
BP-->>Call: { maxOutputTokens: value }
Call->>Prov: generate/stream(..., { maxOutputTokens })
Prov-->>Call: result/stream
note over BP,Prov: All providers now consume maxOutputTokens (no maxTokens/max_completion_tokens branching)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 16
🔭 Outside diff range comments (3)
package.json (1)
13-27: Add missing test scripts to align with repository conventionsPer coding guidelines, please include unit/integration/ci scripts so contributors can run targeted suites.
"scripts": { "test": "node --experimental-vm-modules node_modules/.bin/jest", "test:fails": "node --experimental-vm-modules node_modules/.bin/jest --onlyFailures", "test:watch": "node --experimental-vm-modules node_modules/.bin/jest --watch", "test:coverage": "node --experimental-vm-modules node_modules/.bin/jest --coverage", + "test:unit": "node --experimental-vm-modules node_modules/.bin/jest tests/unit --runInBand", + "test:integration": "node --experimental-vm-modules node_modules/.bin/jest tests/integration --runInBand", + "test:ci": "node --experimental-vm-modules node_modules/.bin/jest --ci --coverage", "test:e2e": "./tests/e2e/run_e2e.sh", "test:e2e-report": "./tests/e2e/run_e2e.sh --analyze-log", "prepare": "chmod +x bin/task-master.js mcp-server/server.js", "changeset": "changeset", "release": "changeset publish", "inspector": "npx @modelcontextprotocol/inspector node mcp-server/server.js", "mcp-server": "node mcp-server/server.js", "format-check": "biome format .", "format": "biome format . --write" },tests/unit/ai-providers/claude-code.test.js (1)
31-34: Avoid top-level dynamic import; move under beforeAll after mocksKeep imports inside lifecycle hooks to reduce async at module scope and better follow mock-first-then-import pattern.
-// Import after mocking -const { ClaudeCodeProvider } = await import( - '../../../src/ai-providers/claude-code.js' -); +// Import after mocking +let ClaudeCodeProvider; +beforeAll(async () => { + const mod = await import('../../../src/ai-providers/claude-code.js'); + ({ ClaudeCodeProvider } = mod); +});src/ai-providers/claude-code.js (1)
97-98: Export required wrapper functions in src/ai-providers/claude-code.js
Theclaude-codeprovider is already registered inscripts/modules/ai-services-unified.js(line 71), but per our AI-provider module guidelines every file insrc/ai-providers/*.jsmust export these three module-level wrappers. Please add the following at the bottom ofsrc/ai-providers/claude-code.js:export class ClaudeCodeProvider extends BaseAIProvider { … } +/** + * Module-level wrappers required by provider guidelines. + * Delegate to ClaudeCodeProvider instance methods. + */ +export function generateClaudeCodeText(...args) { + return new ClaudeCodeProvider().generateText(...args); +} + +export function streamClaudeCodeText(...args) { + return new ClaudeCodeProvider().streamText(...args); +} + +export function generateClaudeCodeObject(...args) { + return new ClaudeCodeProvider().generateObject(...args); +}
- File to update:
src/ai-providers/claude-code.js
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (6)
docs/claude-code-integration.md(1 hunks)package.json(2 hunks)scripts/test-claude-code-direct.js(1 hunks)src/ai-providers/claude-code.js(1 hunks)tests/integration/claude-code-optional.test.js(1 hunks)tests/unit/ai-providers/claude-code.test.js(3 hunks)
🧰 Additional context used
📓 Path-based instructions (15)
package.json
📄 CodeRabbit Inference Engine (.cursor/rules/test_workflow.mdc)
Add and update test scripts in package.json to include test, test:watch, test:coverage, test:unit, test:integration, test:e2e, and test:ci
Files:
package.json
**/*.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:
scripts/test-claude-code-direct.jstests/unit/ai-providers/claude-code.test.jstests/integration/claude-code-optional.test.jssrc/ai-providers/claude-code.js
tests/unit/ai-providers/*.test.js
📄 CodeRabbit Inference Engine (.cursor/rules/ai_providers.mdc)
Create unit tests for the new provider in tests/unit/ai-providers/.test.js, mocking @ai-sdk/ and core ai module functions, and testing all exported functions for correct behavior and error handling.
Files:
tests/unit/ai-providers/claude-code.test.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/ai-providers/claude-code.test.jstests/integration/claude-code-optional.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/ai-providers/claude-code.test.jstests/integration/claude-code-optional.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/ai-providers/claude-code.test.jstests/integration/claude-code-optional.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/ai-providers/claude-code.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/ai-providers/claude-code.test.jstests/integration/claude-code-optional.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/ai-providers/claude-code.test.jstests/integration/claude-code-optional.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/ai-providers/claude-code.test.jstests/integration/claude-code-optional.test.js
tests/integration/*.js
📄 CodeRabbit Inference Engine (.cursor/rules/architecture.mdc)
Integration tests in tests/integration/ should test interactions between modules.
Files:
tests/integration/claude-code-optional.test.js
tests/integration/**/*.test.js
📄 CodeRabbit Inference Engine (.cursor/rules/tests.mdc)
Integration tests must be located in tests/integration/, test interactions between modules, and focus on component interfaces rather than implementation details.
Files:
tests/integration/claude-code-optional.test.js
tests/{integration,e2e}/**/*.test.js
📄 CodeRabbit Inference Engine (.cursor/rules/tests.mdc)
Properly mock session objects when required by functions, and reset environment variables between tests if modified.
Files:
tests/integration/claude-code-optional.test.js
docs/**/*
📄 CodeRabbit Inference Engine (.cursor/rules/new_features.mdc)
Add feature documentation to '/docs' folder, include tagged system usage examples, update command reference documentation, and provide migration notes if relevant.
Files:
docs/claude-code-integration.md
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/claude-code.js
🧠 Learnings (50)
📓 Common learnings
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/glossary.mdc:0-0
Timestamp: 2025-07-18T17:10:53.657Z
Learning: Guidelines for integrating new features into the Task Master CLI with tagged system considerations (new_features.mdc).
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/ai_providers.mdc:0-0
Timestamp: 2025-07-18T17:06:04.909Z
Learning: Applies to scripts/modules/ai-services-unified.js : Integrate the new provider module with scripts/modules/ai-services-unified.js by importing it and adding an entry to the PROVIDER_FUNCTIONS map.
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/ai_providers.mdc:0-0
Timestamp: 2025-07-18T17:06:04.909Z
Learning: Update relevant documentation files (such as README.md) to mention the new provider and its configuration.
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/ai_providers.mdc:0-0
Timestamp: 2025-07-18T17:06:04.909Z
Learning: Applies to tests/unit/ai-providers/*.test.js : Create unit tests for the new provider in tests/unit/ai-providers/<provider-name>.test.js, mocking ai-sdk/<provider-name> and core ai module functions, and testing all exported functions for correct behavior and error handling.
Learnt from: CR
PR: eyaltoledano/claude-task-master#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.
Learnt from: CR
PR: eyaltoledano/claude-task-master#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.
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/new_features.mdc:0-0
Timestamp: 2025-07-18T17:12:57.903Z
Learning: Applies to scripts/modules/ai-services.js : Features that use AI models belong in 'scripts/modules/ai-services.js'.
📚 Learning: 2025-08-07T13:00:22.923Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1090
File: apps/extension/package.json:241-243
Timestamp: 2025-08-07T13:00:22.923Z
Learning: In monorepos, local packages should use "*" as the version constraint in package.json dependencies, as recommended by npm. This ensures the local version from within the same workspace is always used, rather than attempting to resolve from external registries. This applies to packages like task-master-ai within the eyaltoledano/claude-task-master monorepo.
Applied to files:
package.json
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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:
package.jsonscripts/test-claude-code-direct.jstests/unit/ai-providers/claude-code.test.jstests/integration/claude-code-optional.test.jssrc/ai-providers/claude-code.js
📚 Learning: 2025-07-18T17:13:11.229Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/self_improve.mdc:0-0
Timestamp: 2025-07-18T17:13:11.229Z
Learning: Document breaking changes
Applied to files:
package.json
📚 Learning: 2025-07-18T17:06:57.833Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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 import or call anything from the old `ai-services.js`, `ai-client-factory.js`, or `ai-client-utils.js` files.
Applied to files:
package.jsonscripts/test-claude-code-direct.jssrc/ai-providers/claude-code.js
📚 Learning: 2025-07-18T17:07:39.336Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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:
package.jsontests/unit/ai-providers/claude-code.test.jstests/integration/claude-code-optional.test.jssrc/ai-providers/claude-code.js
📚 Learning: 2025-07-17T21:33:57.585Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1002
File: .changeset/puny-friends-give.md:2-3
Timestamp: 2025-07-17T21:33:57.585Z
Learning: In the eyaltoledano/claude-task-master repository, the MCP server code in mcp-server/src/ is part of the main "task-master-ai" package, not a separate "mcp-server" package. When creating changesets for MCP server changes, use "task-master-ai" as the package name.
Applied to files:
package.json
📚 Learning: 2025-07-18T17:06:57.833Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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 import or call anything from the old `ai-services.js`, `ai-client-factory.js`, or `ai-client-utils.js` files.
Applied to files:
package.json
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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:
package.jsonscripts/test-claude-code-direct.jstests/unit/ai-providers/claude-code.test.jstests/integration/claude-code-optional.test.js
📚 Learning: 2025-07-31T20:49:04.638Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#997
File: apps/extension/package.publish.json:2-8
Timestamp: 2025-07-31T20:49:04.638Z
Learning: In the eyaltoledano/claude-task-master repository, the VS Code extension uses a 3-file packaging system where package.json (with name "extension") is for development within the monorepo, while package.publish.json (with name "task-master-hamster") contains the clean manifest for VS Code marketplace publishing. The different names are intentional and serve distinct purposes in the build and publishing workflow.
Applied to files:
package.json
📚 Learning: 2025-07-18T17:06:57.833Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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 import or call anything from the old `ai-services.js`, `ai-client-factory.js`, or `ai-client-utils.js` files.
Applied to files:
package.jsonsrc/ai-providers/claude-code.js
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/ai_providers.mdc:0-0
Timestamp: 2025-07-18T17:06:04.909Z
Learning: Applies to tests/unit/ai-providers/*.test.js : Create unit tests for the new provider in tests/unit/ai-providers/<provider-name>.test.js, mocking ai-sdk/<provider-name> and core ai module functions, and testing all exported functions for correct behavior and error handling.
Applied to files:
package.jsonscripts/test-claude-code-direct.jstests/unit/ai-providers/claude-code.test.jstests/integration/claude-code-optional.test.jssrc/ai-providers/claude-code.js
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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 export three functions: generate<ProviderName>Text, stream<ProviderName>Text, and generate<ProviderName>Object.
Applied to files:
package.jsonscripts/test-claude-code-direct.jstests/unit/ai-providers/claude-code.test.jstests/integration/claude-code-optional.test.jssrc/ai-providers/claude-code.js
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/ai_providers.mdc:0-0
Timestamp: 2025-07-18T17:06:04.909Z
Learning: Applies to src/ai-providers/*.js : Create a new provider module file in src/ai-providers/ named <provider-name>.js when adding a new AI provider.
Applied to files:
package.jsontests/unit/ai-providers/claude-code.test.jssrc/ai-providers/claude-code.js
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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:
package.jsonscripts/test-claude-code-direct.jstests/unit/ai-providers/claude-code.test.jstests/integration/claude-code-optional.test.jssrc/ai-providers/claude-code.js
📚 Learning: 2025-07-18T17:12:57.903Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/new_features.mdc:0-0
Timestamp: 2025-07-18T17:12:57.903Z
Learning: Applies to scripts/modules/ai-services.js : Features that use AI models belong in 'scripts/modules/ai-services.js'.
Applied to files:
package.jsonsrc/ai-providers/claude-code.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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:
scripts/test-claude-code-direct.jstests/unit/ai-providers/claude-code.test.jstests/integration/claude-code-optional.test.js
📚 Learning: 2025-07-18T17:12:57.903Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/new_features.mdc:0-0
Timestamp: 2025-07-18T17:12:57.903Z
Learning: Applies to scripts/modules/**/*.test.js : Test CLI and MCP interfaces with real task data, verify end-to-end workflows across tag contexts, and test error scenarios and recovery in integration tests.
Applied to files:
scripts/test-claude-code-direct.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : Mock API calls (e.g., Anthropic/Claude) by mocking the entire module and providing predictable responses.
Applied to files:
scripts/test-claude-code-direct.jstests/unit/ai-providers/claude-code.test.jstests/integration/claude-code-optional.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to 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.
Applied to files:
scripts/test-claude-code-direct.jstests/unit/ai-providers/claude-code.test.jstests/integration/claude-code-optional.test.js
📚 Learning: 2025-08-03T12:13:33.875Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/test_workflow.mdc:0-0
Timestamp: 2025-08-03T12:13:33.875Z
Learning: Applies to {tests/integration/**/*.test.ts,src/**/*.integration.test.ts} : Use supertest for API endpoint testing in integration test files
Applied to files:
scripts/test-claude-code-direct.js
📚 Learning: 2025-07-18T17:07:39.336Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/architecture.mdc:0-0
Timestamp: 2025-07-18T17:07:39.336Z
Learning: Applies to tests/integration/*.js : Integration tests in tests/integration/ should test interactions between modules.
Applied to files:
scripts/test-claude-code-direct.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to tests/{unit,integration,e2e}/**/*.test.js : Mock the action handlers for CLI commands and verify they're called with correct arguments.
Applied to files:
tests/unit/ai-providers/claude-code.test.jstests/integration/claude-code-optional.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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/ai-providers/claude-code.test.jstests/integration/claude-code-optional.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to tests/{unit,integration,e2e}/**/*.test.js : Mock chalk functions to return the input text to make testing easier while still verifying correct function calls.
Applied to files:
tests/unit/ai-providers/claude-code.test.jstests/integration/claude-code-optional.test.js
📚 Learning: 2025-07-18T17:07:39.336Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/architecture.mdc:0-0
Timestamp: 2025-07-18T17:07:39.336Z
Learning: Module dependencies should be mocked before importing the test module, following Jest's hoisting behavior.
Applied to files:
tests/unit/ai-providers/claude-code.test.jstests/integration/claude-code-optional.test.js
📚 Learning: 2025-07-18T17:07:39.336Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/architecture.mdc:0-0
Timestamp: 2025-07-18T17:07:39.336Z
Learning: Mock external libraries (e.g., fs, commander, anthropic-ai/sdk) at the module level in tests.
Applied to files:
tests/unit/ai-providers/claude-code.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : For ES modules, use jest.mock() before static imports and jest.unstable_mockModule() before dynamic imports to mock dependencies.
Applied to files:
tests/unit/ai-providers/claude-code.test.js
📚 Learning: 2025-07-18T17:07:39.336Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/architecture.mdc:0-0
Timestamp: 2025-07-18T17:07:39.336Z
Learning: Each module should have well-defined exports that can be mocked in tests.
Applied to files:
tests/unit/ai-providers/claude-code.test.js
📚 Learning: 2025-07-18T17:18:17.759Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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:
tests/unit/ai-providers/claude-code.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to tests/{unit,integration,e2e}/**/*.test.js : 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.
Applied to files:
tests/unit/ai-providers/claude-code.test.jstests/integration/claude-code-optional.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to tests/{unit,integration,e2e}/**/*.test.js : 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.
Applied to files:
tests/unit/ai-providers/claude-code.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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/integration/claude-code-optional.test.js
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/ai_providers.mdc:0-0
Timestamp: 2025-07-18T17:06:04.909Z
Learning: Applies to scripts/modules/ai-services-unified.js : Integrate the new provider module with scripts/modules/ai-services-unified.js by importing it and adding an entry to the PROVIDER_FUNCTIONS map.
Applied to files:
tests/integration/claude-code-optional.test.jssrc/ai-providers/claude-code.js
📚 Learning: 2025-07-31T22:07:14.034Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-31T22:07:14.034Z
Learning: Import Task Master's development workflow commands and guidelines, treat as if import is in the main CLAUDE.md file.
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-07-18T17:10:53.657Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/glossary.mdc:0-0
Timestamp: 2025-07-18T17:10:53.657Z
Learning: Guidelines for integrating new features into the Task Master CLI with tagged system considerations (new_features.mdc).
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-07-18T17:10:53.657Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/glossary.mdc:0-0
Timestamp: 2025-07-18T17:10:53.657Z
Learning: Guidelines for integrating AI usage telemetry across Task Master (telemetry.mdc).
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-07-18T17:10:12.881Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/dev_workflow.mdc:0-0
Timestamp: 2025-07-18T17:10:12.881Z
Learning: For CLI usage, install Taskmaster globally with `npm install -g task-master-ai` or use locally via `npx task-master-ai ...`.
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-08-06T21:12:43.673Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1091
File: assets/claude/agents/task-orchestrator.md:1-6
Timestamp: 2025-08-06T21:12:43.673Z
Learning: In the eyaltoledano/claude-task-master repository, agent files are intentionally duplicated between `.claude/agents/` (for internal project use) and `assets/claude/agents/` (as template files for users to copy). This duplication serves different purposes and should be maintained to support both internal development and user distribution needs.
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-07-18T17:19:27.365Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: assets/.windsurfrules:0-0
Timestamp: 2025-07-18T17:19:27.365Z
Learning: Use `task-master add-task` to add a new task to tasks.json using AI.
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-07-18T17:10:53.657Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/glossary.mdc:0-0
Timestamp: 2025-07-18T17:10:53.657Z
Learning: Describes the high-level architecture of the Task Master CLI application, including the new tagged task lists system (architecture.mdc).
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-08-06T21:12:20.956Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1091
File: assets/claude/agents/task-executor.md:1-6
Timestamp: 2025-08-06T21:12:20.956Z
Learning: In the eyaltoledano/claude-task-master repository, agent files in assets/claude/agents/ are intended for distribution to users (for copying), while identical files in .claude/agents/ are for internal project use. This intentional duplication serves different purposes and is not a DRY violation.
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-08-06T21:13:05.213Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1091
File: assets/claude/agents/task-orchestrator.md:69-78
Timestamp: 2025-08-06T21:13:05.213Z
Learning: For Claude agent instruction files in .claude/agents/ and assets/claude/agents/ directories, ignore markdownlint issues (like MD031 blanks-around-fences, MD040 fenced-code-language, MD041 missing top-level heading) as these files follow Claude's specific agent format requirements rather than standard markdown documentation conventions.
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-07-18T17:18:17.759Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/utilities.mdc:0-0
Timestamp: 2025-07-18T17:18:17.759Z
Learning: Applies to scripts/modules/task-manager/**/*.js : Do not call AI-specific getters (like `getMainModelId`, `getMainMaxTokens`) from core logic functions in `scripts/modules/task-manager/*`; instead, pass the `role` to the unified AI service.
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-07-18T17:10:53.657Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/glossary.mdc:0-0
Timestamp: 2025-07-18T17:10:53.657Z
Learning: Guide for using Task Master to manage task-driven development workflows with tagged task lists support (dev_workflow.mdc).
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-07-18T17:10:53.657Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/glossary.mdc:0-0
Timestamp: 2025-07-18T17:10:53.657Z
Learning: Comprehensive reference for Taskmaster MCP tools and CLI commands with tagged task lists information (taskmaster.mdc).
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-07-31T21:48:00.389Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#997
File: apps/extension/src/services/task-repository.ts:25-57
Timestamp: 2025-07-31T21:48:00.389Z
Learning: In the eyaltoledano/claude-task-master repository, every task is always part of a tag - there is no concept of untagged tasks. The tag system is mandatory and comprehensive, meaning all tasks exist within a tag context (with 'master' as the default tag if none specified).
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-07-18T17:10:53.657Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/glossary.mdc:0-0
Timestamp: 2025-07-18T17:10:53.657Z
Learning: Guidelines for implementing and maintaining tests for Task Master CLI (tests.mdc).
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-07-18T17:10:12.881Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/dev_workflow.mdc:0-0
Timestamp: 2025-07-18T17:10:12.881Z
Learning: Applies to .taskmaster/config.json : Store Taskmaster configuration settings (AI model selections, parameters, logging level, default subtasks/priority, project name, etc.) in the `.taskmaster/config.json` file located in the project root directory. Do not configure non-API key settings via environment variables.
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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/claude-code.js
🧬 Code Graph Analysis (4)
scripts/test-claude-code-direct.js (2)
src/ai-providers/custom-sdk/claude-code/index.js (1)
createClaudeCode(20-65)tests/integration/claude-code-optional.test.js (2)
generateText(5-5)streamText(6-6)
tests/unit/ai-providers/claude-code.test.js (2)
src/ai-providers/custom-sdk/claude-code/index.js (1)
createClaudeCode(20-65)src/ai-providers/claude-code.js (1)
ClaudeCodeProvider(25-97)
tests/integration/claude-code-optional.test.js (1)
src/ai-providers/claude-code.js (1)
ClaudeCodeProvider(25-97)
src/ai-providers/claude-code.js (3)
src/ai-providers/base-provider.js (1)
BaseAIProvider(15-311)scripts/modules/config-manager.js (2)
settings(388-388)modelId(556-556)src/ai-providers/custom-sdk/claude-code/index.js (1)
createClaudeCode(20-65)
🪛 LanguageTool
docs/claude-code-integration.md
[grammar] ~1-~1: Use correct spacing
Context: # Claude Code Integration Guide This guide covers how to use Task Master...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~3-~3: Use correct spacing
Context: ...ion for enhanced AI-powered development workflows. ## Overview Claude Code integration allows...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~7-~7: Use correct spacing
Context: ...h tokens managed by the Claude Code CLI itself. ## Authentication Setup The Claude Code pr...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~9-~9: Use correct spacing
Context: ...ude Code CLI itself. ## Authentication Setup The Claude Code provider uses token auth...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~11-~11: Use correct spacing
Context: ...thentication managed by the Claude Code CLI. ### Prerequisites 1. **Install Claude Code ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~15-~15: Use correct spacing
Context: ...stall Claude Code CLI** (if not already installed): bash # Installation method depends on your system # Follow Claude Code documentation for installation 2. Set up OAuth token using Claude Code C...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~21-~21: There might be a mistake here.
Context: ...Set up OAuth token* using Claude Code CLI: bash claude setup-token This command will: - Guide you th...
(QB_NEW_EN_OTHER)
[grammar] ~27-~27: There might be a mistake here.
Context: ...mand will: - Guide you through OAuth authentication - Store the token securely for CLI usage ...
(QB_NEW_EN_OTHER)
[grammar] ~28-~28: There might be a mistake here.
Context: ...n - Store the token securely for CLI usage - Enable Task Master to use Claude Code wi...
(QB_NEW_EN_OTHER)
[grammar] ~29-~29: There might be a mistake here.
Context: ... use Claude Code without manual API key configuration ### Authentication Priority Task Master wil...
(QB_NEW_EN_OTHER)
[grammar] ~31-~31: Use correct spacing
Context: ...I key configuration ### Authentication Priority Task Master will attempt authentication ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~33-~33: There might be a mistake here.
Context: ...ter will attempt authentication in this order: 1. Environment Variable (optional): `CLA...
(QB_NEW_EN_OTHER)
[grammar] ~35-~35: Use correct spacing
Context: ...his order: 1. Environment Variable (optional): CLAUDE_CODE_OAUTH_TOKEN - Useful for CI/CD environments or when you want...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~36-~36: There might be a mistake here.
Context: ...r when you want to override the default token - Not required if you've set up the CLI to...
(QB_NEW_EN_OTHER)
[grammar] ~37-~37: There might be a mistake here.
Context: ...- Not required if you've set up the CLI token 2. Claude Code CLI Token (recommended): T...
(QB_NEW_EN_OTHER)
[grammar] ~40-~40: Insert the missing word
Context: ...tup-token` - Automatically used when available - Most convenient for local developm...
(QB_NEW_EN_OTHER_ERROR_IDS_32)
[grammar] ~41-~41: There might be a mistake here.
Context: ...vailable - Most convenient for local development 3. Fallback: Error if neither is availabl...
(QB_NEW_EN_OTHER)
[grammar] ~43-~43: Use correct spacing
Context: ...t 3. Fallback: Error if neither is available ## Configuration ### Basic Configuration ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~47-~47: Use correct spacing
Context: ... available ## Configuration ### Basic Configuration Add Claude Code to your Task Master conf...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~49-~49: There might be a mistake here.
Context: ...on Add Claude Code to your Task Master configuration: javascript // In your .taskmaster/config.json or via task-master models command { "models": { "main": "claude-code:sonnet", // Use Claude Code with Sonnet "research": "perplexity-llama-3.1-sonar-large-128k-online", "fallback": "claude-code:opus" // Use Claude Code with Opus as fallback } } ### Supported Models - `claude-...
(QB_NEW_EN_OTHER)
[grammar] ~62-~62: Use correct spacing
Context: ...us as fallback } } ``` ### Supported Models - claude-code:sonnet - Claude 3.5 Sonnet via Claude Code CLI...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~64-~64: Use correct spacing
Context: ...et- Claude 3.5 Sonnet via Claude Code CLI -claude-code:opus` - Claude 3 Opus via Claude Code CLI ### ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~65-~65: Use correct spacing
Context: ...e:opus` - Claude 3 Opus via Claude Code CLI ### Environment Variables (Optional) While ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~67-~67: Use correct spacing
Context: ...ude Code CLI ### Environment Variables (Optional) While not required, you can optionally s...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~69-~69: There might be a mistake here.
Context: ... While not required, you can optionally set: bash export CLAUDE_CODE_OAUTH_TOKEN="your_oauth_token_here" This is only needed in specific scenario...
(QB_NEW_EN_OTHER)
[grammar] ~75-~75: There might be a mistake here.
Context: ...is is only needed in specific scenarios like: - CI/CD pipelines - Docker containers ...
(QB_NEW_EN_OTHER)
[grammar] ~76-~76: There might be a mistake here.
Context: ...ded in specific scenarios like: - CI/CD pipelines - Docker containers - When you want to use...
(QB_NEW_EN_OTHER)
[grammar] ~77-~77: There might be a mistake here.
Context: ...narios like: - CI/CD pipelines - Docker containers - When you want to use a different token t...
(QB_NEW_EN_OTHER)
[grammar] ~78-~78: There might be a mistake here.
Context: ...t to use a different token than the CLI default ## Usage Examples ### Basic Task Operation...
(QB_NEW_EN_OTHER)
[grammar] ~80-~80: Use correct spacing
Context: ...nt token than the CLI default ## Usage Examples ### Basic Task Operations ```bash # Use Cla...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~82-~82: Use correct spacing
Context: ...ault ## Usage Examples ### Basic Task Operations bash # Use Claude Code for task operations task-master add-task --prompt="Implement user authentication system" --research task-master expand --id=1 --research task-master update-task --id=1.1 --prompt="Add JWT token validation" ### Model Configuration Commands ```bash # ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~91-~91: Use correct spacing
Context: ...alidation" ### Model Configuration Commands bash # Set Claude Code as main model task-master models --set-main claude-code:sonnet # Use interactive setup task-master models --setup # Then select "claude-code" from the provider list ``` ## Troubleshooting ### Common Issues ####...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~104-~104: Use correct spacing
Context: ...ist ``` ## Troubleshooting ### Common Issues #### 1. "Claude Code CLI not available" Error...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~106-~106: Use correct spacing
Context: ...#### 1. "Claude Code CLI not available" Error Problem: Task Master cannot connect to...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~108-~108: Use correct spacing
Context: ...sk Master cannot connect to Claude Code CLI. Solutions: - Ensure Claude Code CLI is...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~111-~111: Use proper capitalization
Context: ...laude Code CLI is installed and in your PATH - Run claude setup-token to configure au...
(QB_NEW_EN_OTHER_ERROR_IDS_6)
[grammar] ~112-~112: There might be a mistake here.
Context: ...- Run claude setup-token to configure authentication - Verify Claude Code CLI works: `claude --...
(QB_NEW_EN_OTHER)
[grammar] ~113-~113: Use correct spacing
Context: ...authentication - Verify Claude Code CLI works: claude --help #### 2. Authentication Failures Problem:...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~115-~115: Use correct spacing
Context: ...claude --help #### 2. Authentication Failures Problem: Token authentication is faili...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~117-~117: Use correct spacing
Context: ...s Problem: Token authentication is failing. Solutions: - Re-run `claude setup-toke...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~120-~120: There might be a mistake here.
Context: ...aude setup-token` to refresh your OAuth token - Check if your token has expired - Verify...
(QB_NEW_EN_OTHER)
[grammar] ~121-~121: There might be a mistake here.
Context: ...r OAuth token - Check if your token has expired - Verify Claude Code CLI can authenticate:...
(QB_NEW_EN_OTHER)
[grammar] ~122-~122: There might be a mistake here.
Context: ...can authenticate: try a simple claude command #### 3. Model Not Available Problem: Spe...
(QB_NEW_EN_OTHER)
[grammar] ~124-~124: Use correct spacing
Context: ...ple claude command #### 3. Model Not Available Problem: Specified Claude Code model i...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~126-~126: Use correct spacing
Context: ...m**: Specified Claude Code model is not supported. Solutions: - Use supported models: `so...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~130-~130: There might be a mistake here.
Context: ...odels: sonnet or opus - Check model availability: task-master models --list - Verify your Claude Code CLI has access to the ...
(QB_NEW_EN_OTHER)
[grammar] ~131-~131: There might be a mistake here.
Context: ...de Code CLI has access to the requested model ### Debug Steps 1. **Test Claude Code CLI d...
(QB_NEW_EN_OTHER)
[grammar] ~133-~133: Use correct spacing
Context: ...ccess to the requested model ### Debug Steps 1. Test Claude Code CLI directly: ```b...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~135-~135: There might be a mistake here.
Context: ... Debug Steps 1. Test Claude Code CLI directly: bash claude --help # Should show help without errors 2. Test authentication: ```bash ...
(QB_NEW_EN_OTHER)
[grammar] ~141-~141: There might be a mistake here.
Context: ...w help without errors 2. **Test authentication**: bash claude setup-token --verify # Should confirm token is valid ``` 3. Test Task Master integration: ...
(QB_NEW_EN_OTHER)
[grammar] ~147-~147: There might be a mistake here.
Context: ... is valid 3. **Test Task Master integration**: bash task-master models --test claude-code:sonnet # Should successfully connect and test the model ``` 4. Check logs: - Task Master logs...
(QB_NEW_EN_OTHER)
[grammar] ~154-~154: There might be a problem here.
Context: ...sk Master logs will show detailed error messages - Use --verbose flag for more detailed outp...
(QB_NEW_EN_MERGED_MATCH)
[grammar] ~155-~155: There might be a mistake here.
Context: ... Use --verbose flag for more detailed output ### Environment-Specific Configuration ####...
(QB_NEW_EN_OTHER)
[grammar] ~157-~157: Use correct spacing
Context: ...tailed output ### Environment-Specific Configuration #### Docker/Containers When running in Docke...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~161-~161: There might be a mistake here.
Context: ...rs When running in Docker, you'll need to: 1. Install Claude Code CLI in your contain...
(QB_NEW_EN_OTHER)
[grammar] ~163-~163: There might be a mistake here.
Context: ...to: 1. Install Claude Code CLI in your container 2. Set up authentication via environment va...
(QB_NEW_EN_OTHER)
[grammar] ~164-~164: There might be a mistake here.
Context: .... Set up authentication via environment variable: dockerfile ENV CLAUDE_CODE_OAUTH_TOKEN="your_token_here" #### CI/CD Pipelines For automated envir...
(QB_NEW_EN_OTHER)
[grammar] ~169-~169: Use correct spacing
Context: ...EN="your_token_here" ``` #### CI/CD Pipelines For automated environments: 1. Set up a...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~171-~171: There might be a mistake here.
Context: ...`` #### CI/CD Pipelines For automated environments: 1. Set up a service account token or use e...
(QB_NEW_EN_OTHER)
[grammar] ~173-~173: There might be a mistake here.
Context: ...ervice account token or use environment variables 2. Ensure Claude Code CLI is available in t...
(QB_NEW_EN_OTHER)
[grammar] ~174-~174: There might be a mistake here.
Context: ...e Code CLI is available in the pipeline environment 3. Configure authentication before running ...
(QB_NEW_EN_OTHER)
[grammar] ~175-~175: There might be a mistake here.
Context: ...thentication before running Task Master commands ## Integration with AI SDK Task Master's C...
(QB_NEW_EN_OTHER)
[grammar] ~177-~177: Use correct spacing
Context: ...Master commands ## Integration with AI SDK Task Master's Claude Code integration us...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~179-~179: There might be a mistake here.
Context: ... ai-sdk-provider-claude-code package, providing: - Streaming Support: Real-time token st...
(QB_NEW_EN_OTHER)
[grammar] ~184-~184: Use correct spacing
Context: ...ull TypeScript support with proper type definitions ### Example AI SDK Usage ```javascript impo...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~186-~186: Use correct spacing
Context: ...er type definitions ### Example AI SDK Usage javascript import { generateText } from 'ai'; import { ClaudeCodeProvider } from './src/ai-providers/claude-code.js'; const provider = new ClaudeCodeProvider(); const client = provider.getClient(); const result = await generateText({ model: client('sonnet'), messages: [ { role: 'user', content: 'Hello Claude!' } ] }); console.log(result.text); ## Security Notes - OAuth tokens are manag...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~205-~205: Use correct spacing
Context: ...sole.log(result.text); ``` ## Security Notes - OAuth tokens are managed securely by Cla...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~207-~207: Use proper capitalization
Context: ...ens are managed securely by Claude Code CLI - No API keys need to be stored in your pr...
(QB_NEW_EN_OTHER_ERROR_IDS_6)
[grammar] ~208-~208: There might be a mistake here.
Context: ... keys need to be stored in your project files - Tokens are automatically refreshed by th...
(QB_NEW_EN_OTHER)
[grammar] ~209-~209: Use proper capitalization
Context: ...omatically refreshed by the Claude Code CLI - Environment variables should only be use...
(QB_NEW_EN_OTHER_ERROR_IDS_6)
[grammar] ~210-~210: There might be a mistake here.
Context: ...variables should only be used in secure environments ## Getting Help If you encounter issues: ...
(QB_NEW_EN_OTHER)
[grammar] ~212-~212: Use correct spacing
Context: ...used in secure environments ## Getting Help If you encounter issues: 1. Check the C...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~214-~214: There might be a mistake here.
Context: ...ents ## Getting Help If you encounter issues: 1. Check the Claude Code CLI documentation...
(QB_NEW_EN_OTHER)
[grammar] ~216-~216: There might be a mistake here.
Context: ...r issues: 1. Check the Claude Code CLI documentation 2. Verify your authentication setup with `c...
(QB_NEW_EN_OTHER)
[grammar] ~218-~218: There might be a mistake here.
Context: ...iew Task Master logs for detailed error messages 4. Open an issue with both Task Master and ...
(QB_NEW_EN_OTHER)
[grammar] ~219-~219: Use a period to end declarative sentences
Context: ...oth Task Master and Claude Code version information
(QB_NEW_EN_OTHER_ERROR_IDS_25)
🪛 markdownlint-cli2 (0.17.2)
docs/claude-code-integration.md
16-16: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
22-22: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
76-76: Lists should be surrounded by blank lines
(MD032, blanks-around-lists)
111-111: Lists should be surrounded by blank lines
(MD032, blanks-around-lists)
120-120: Lists should be surrounded by blank lines
(MD032, blanks-around-lists)
129-129: Lists should be surrounded by blank lines
(MD032, blanks-around-lists)
136-136: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
142-142: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
148-148: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
165-165: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
219-219: Files should end with a single newline character
(MD047, single-trailing-newline)
🔇 Additional comments (10)
package.json (2)
88-88: Optional dependency bump looks goodKeeping the CLI SDK under optionalDependencies is appropriate to avoid forcing installs where unused.
57-58: Consider pinning theaibeta dependency for CI stabilityA caret range on a beta release can lead to unexpected upgrades. To lock your builds, pin
aito the exact beta version:"overrides": { - "node-fetch": "^2.6.12", - "whatwg-url": "^11.0.0", + "node-fetch": "^2.6.12", + "whatwg-url": "^11.0.0", + "ai": "5.0.0-beta.34" }Verification checklist:
- Ensure all calls to
generateTextandstreamTextinsrc/ai-providers/*match the v5 API signatures.- Confirm the ESM/Jest setup (
--experimental-vm-modules) continues to work with AI SDK v5.tests/unit/ai-providers/claude-code.test.js (3)
69-94: getClient tests: good coverage of creation and API surfaceValidates factory function shape and aliases.
96-108: Model support API is clear and explicitGood to have both getSupportedModels and isModelSupported unit-tested.
69-75: Mock settings resolution to avoid accidental I/O or env couplinggetClient calls a settings resolver internally. Ensure the module providing it is mocked so tests stay pure and fast.
If it currently hits real config, add an unstable_mockModule for the settings module to return a minimal object, then import the provider.
tests/integration/claude-code-optional.test.js (1)
23-35: Missing CLI path: error expectation is correctGood regex-based assertion for the enhanced missing-CLI error.
src/ai-providers/claude-code.js (4)
17-24: Model identifiers: confirm canonical IDsDocs list 'sonnet' and 'opus'. Validate these are the canonical IDs expected by the provider (vs. e.g., claude-3-5-sonnet). If a mapping is needed, add a translation layer.
82-88: LGTM: supported models accessorStraightforward and clear.
13-13: Import and dependency verifiedThe
ai-sdk-provider-claude-codepackage is declared in package.json at version ^1.0.0-beta.1 and provides a named exportcreateClaudeCode. No changes required.
15-15: No action required: getClaudeCodeSettingsForCommand is properly exported
Verified thatgetClaudeCodeSettingsForCommandis defined at line 383 and included in the named exports at line 967 ofscripts/modules/config-manager.js. No fallback needed.
| # Claude Code Integration Guide | ||
|
|
||
| This guide covers how to use Task Master with Claude Code AI SDK integration for enhanced AI-powered development workflows. | ||
|
|
||
| ## Overview | ||
|
|
||
| Claude Code integration allows Task Master to leverage the Claude Code CLI for AI operations without requiring direct API keys. The integration uses OAuth tokens managed by the Claude Code CLI itself. | ||
|
|
||
| ## Authentication Setup | ||
|
|
||
| The Claude Code provider uses token authentication managed by the Claude Code CLI. | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| 1. **Install Claude Code CLI** (if not already installed): | ||
| ```bash | ||
| # Installation method depends on your system | ||
| # Follow Claude Code documentation for installation | ||
| ``` | ||
|
|
||
| 2. **Set up OAuth token** using Claude Code CLI: | ||
| ```bash | ||
| claude setup-token | ||
| ``` | ||
|
|
||
| This command will: | ||
| - Guide you through OAuth authentication | ||
| - Store the token securely for CLI usage | ||
| - Enable Task Master to use Claude Code without manual API key configuration | ||
|
|
||
| ### Authentication Priority | ||
|
|
||
| Task Master will attempt authentication in this order: | ||
|
|
||
| 1. **Environment Variable** (optional): `CLAUDE_CODE_OAUTH_TOKEN` | ||
| - Useful for CI/CD environments or when you want to override the default token | ||
| - Not required if you've set up the CLI token | ||
|
|
||
| 2. **Claude Code CLI Token** (recommended): Token managed by `claude setup-token` | ||
| - Automatically used when available | ||
| - Most convenient for local development | ||
|
|
||
| 3. **Fallback**: Error if neither is available | ||
|
|
||
| ## Configuration | ||
|
|
||
| ### Basic Configuration | ||
|
|
||
| Add Claude Code to your Task Master configuration: | ||
|
|
||
| ```javascript | ||
| // In your .taskmaster/config.json or via task-master models command | ||
| { | ||
| "models": { | ||
| "main": "claude-code:sonnet", // Use Claude Code with Sonnet | ||
| "research": "perplexity-llama-3.1-sonar-large-128k-online", | ||
| "fallback": "claude-code:opus" // Use Claude Code with Opus as fallback | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Supported Models | ||
|
|
||
| - `claude-code:sonnet` - Claude 3.5 Sonnet via Claude Code CLI | ||
| - `claude-code:opus` - Claude 3 Opus via Claude Code CLI | ||
|
|
||
| ### Environment Variables (Optional) | ||
|
|
||
| While not required, you can optionally set: | ||
|
|
||
| ```bash | ||
| export CLAUDE_CODE_OAUTH_TOKEN="your_oauth_token_here" | ||
| ``` | ||
|
|
||
| This is only needed in specific scenarios like: | ||
| - CI/CD pipelines | ||
| - Docker containers | ||
| - When you want to use a different token than the CLI default | ||
|
|
||
| ## Usage Examples | ||
|
|
||
| ### Basic Task Operations | ||
|
|
||
| ```bash | ||
| # Use Claude Code for task operations | ||
| task-master add-task --prompt="Implement user authentication system" --research | ||
| task-master expand --id=1 --research | ||
| task-master update-task --id=1.1 --prompt="Add JWT token validation" | ||
| ``` | ||
|
|
||
| ### Model Configuration Commands | ||
|
|
||
| ```bash | ||
| # Set Claude Code as main model | ||
| task-master models --set-main claude-code:sonnet | ||
|
|
||
| # Use interactive setup | ||
| task-master models --setup | ||
| # Then select "claude-code" from the provider list | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Common Issues | ||
|
|
||
| #### 1. "Claude Code CLI not available" Error | ||
|
|
||
| **Problem**: Task Master cannot connect to Claude Code CLI. | ||
|
|
||
| **Solutions**: | ||
| - Ensure Claude Code CLI is installed and in your PATH | ||
| - Run `claude setup-token` to configure authentication | ||
| - Verify Claude Code CLI works: `claude --help` | ||
|
|
||
| #### 2. Authentication Failures | ||
|
|
||
| **Problem**: Token authentication is failing. | ||
|
|
||
| **Solutions**: | ||
| - Re-run `claude setup-token` to refresh your OAuth token | ||
| - Check if your token has expired | ||
| - Verify Claude Code CLI can authenticate: try a simple `claude` command | ||
|
|
||
| #### 3. Model Not Available | ||
|
|
||
| **Problem**: Specified Claude Code model is not supported. | ||
|
|
||
| **Solutions**: | ||
| - Use supported models: `sonnet` or `opus` | ||
| - Check model availability: `task-master models --list` | ||
| - Verify your Claude Code CLI has access to the requested model | ||
|
|
||
| ### Debug Steps | ||
|
|
||
| 1. **Test Claude Code CLI directly**: | ||
| ```bash | ||
| claude --help | ||
| # Should show help without errors | ||
| ``` | ||
|
|
||
| 2. **Test authentication**: | ||
| ```bash | ||
| claude setup-token --verify | ||
| # Should confirm token is valid | ||
| ``` | ||
|
|
||
| 3. **Test Task Master integration**: | ||
| ```bash | ||
| task-master models --test claude-code:sonnet | ||
| # Should successfully connect and test the model | ||
| ``` | ||
|
|
||
| 4. **Check logs**: | ||
| - Task Master logs will show detailed error messages | ||
| - Use `--verbose` flag for more detailed output | ||
|
|
||
| ### Environment-Specific Configuration | ||
|
|
||
| #### Docker/Containers | ||
|
|
||
| When running in Docker, you'll need to: | ||
|
|
||
| 1. Install Claude Code CLI in your container | ||
| 2. Set up authentication via environment variable: | ||
| ```dockerfile | ||
| ENV CLAUDE_CODE_OAUTH_TOKEN="your_token_here" | ||
| ``` | ||
|
|
||
| #### CI/CD Pipelines | ||
|
|
||
| For automated environments: | ||
|
|
||
| 1. Set up a service account token or use environment variables | ||
| 2. Ensure Claude Code CLI is available in the pipeline environment | ||
| 3. Configure authentication before running Task Master commands | ||
|
|
||
| ## Integration with AI SDK | ||
|
|
||
| Task Master's Claude Code integration uses the official `ai-sdk-provider-claude-code` package, providing: | ||
|
|
||
| - **Streaming Support**: Real-time token streaming for interactive experiences | ||
| - **Full AI SDK Compatibility**: Works with generateText, streamText, and other AI SDK functions | ||
| - **Automatic Error Handling**: Graceful degradation when Claude Code is unavailable | ||
| - **Type Safety**: Full TypeScript support with proper type definitions | ||
|
|
||
| ### Example AI SDK Usage | ||
|
|
||
| ```javascript | ||
| import { generateText } from 'ai'; | ||
| import { ClaudeCodeProvider } from './src/ai-providers/claude-code.js'; | ||
|
|
||
| const provider = new ClaudeCodeProvider(); | ||
| const client = provider.getClient(); | ||
|
|
||
| const result = await generateText({ | ||
| model: client('sonnet'), | ||
| messages: [ | ||
| { role: 'user', content: 'Hello Claude!' } | ||
| ] | ||
| }); | ||
|
|
||
| console.log(result.text); | ||
| ``` | ||
|
|
||
| ## Security Notes | ||
|
|
||
| - OAuth tokens are managed securely by Claude Code CLI | ||
| - No API keys need to be stored in your project files | ||
| - Tokens are automatically refreshed by the Claude Code CLI | ||
| - Environment variables should only be used in secure environments | ||
|
|
||
| ## Getting Help | ||
|
|
||
| If you encounter issues: | ||
|
|
||
| 1. Check the Claude Code CLI documentation | ||
| 2. Verify your authentication setup with `claude setup-token --verify` | ||
| 3. Review Task Master logs for detailed error messages | ||
| 4. Open an issue with both Task Master and Claude Code version information No newline at end of file |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Fix markdownlint spacing issues and add trailing newline
Several MD031/MD032 findings: add blank lines before/after fenced code blocks and around lists; end file with a single newline.
Quick fix pattern:
- Ensure a blank line before and after each ``` block.
- Ensure a blank line before and after lists.
- Add a final newline (MD047).
🧰 Tools
🪛 LanguageTool
[grammar] ~1-~1: Use correct spacing
Context: # Claude Code Integration Guide This guide covers how to use Task Master...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~3-~3: Use correct spacing
Context: ...ion for enhanced AI-powered development workflows. ## Overview Claude Code integration allows...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~7-~7: Use correct spacing
Context: ...h tokens managed by the Claude Code CLI itself. ## Authentication Setup The Claude Code pr...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~9-~9: Use correct spacing
Context: ...ude Code CLI itself. ## Authentication Setup The Claude Code provider uses token auth...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~11-~11: Use correct spacing
Context: ...thentication managed by the Claude Code CLI. ### Prerequisites 1. **Install Claude Code ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~15-~15: Use correct spacing
Context: ...stall Claude Code CLI** (if not already installed): bash # Installation method depends on your system # Follow Claude Code documentation for installation 2. Set up OAuth token using Claude Code C...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~21-~21: There might be a mistake here.
Context: ...Set up OAuth token* using Claude Code CLI: bash claude setup-token This command will: - Guide you th...
(QB_NEW_EN_OTHER)
[grammar] ~27-~27: There might be a mistake here.
Context: ...mand will: - Guide you through OAuth authentication - Store the token securely for CLI usage ...
(QB_NEW_EN_OTHER)
[grammar] ~28-~28: There might be a mistake here.
Context: ...n - Store the token securely for CLI usage - Enable Task Master to use Claude Code wi...
(QB_NEW_EN_OTHER)
[grammar] ~29-~29: There might be a mistake here.
Context: ... use Claude Code without manual API key configuration ### Authentication Priority Task Master wil...
(QB_NEW_EN_OTHER)
[grammar] ~31-~31: Use correct spacing
Context: ...I key configuration ### Authentication Priority Task Master will attempt authentication ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~33-~33: There might be a mistake here.
Context: ...ter will attempt authentication in this order: 1. Environment Variable (optional): `CLA...
(QB_NEW_EN_OTHER)
[grammar] ~35-~35: Use correct spacing
Context: ...his order: 1. Environment Variable (optional): CLAUDE_CODE_OAUTH_TOKEN - Useful for CI/CD environments or when you want...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~36-~36: There might be a mistake here.
Context: ...r when you want to override the default token - Not required if you've set up the CLI to...
(QB_NEW_EN_OTHER)
[grammar] ~37-~37: There might be a mistake here.
Context: ...- Not required if you've set up the CLI token 2. Claude Code CLI Token (recommended): T...
(QB_NEW_EN_OTHER)
[grammar] ~40-~40: Insert the missing word
Context: ...tup-token` - Automatically used when available - Most convenient for local developm...
(QB_NEW_EN_OTHER_ERROR_IDS_32)
[grammar] ~41-~41: There might be a mistake here.
Context: ...vailable - Most convenient for local development 3. Fallback: Error if neither is availabl...
(QB_NEW_EN_OTHER)
[grammar] ~43-~43: Use correct spacing
Context: ...t 3. Fallback: Error if neither is available ## Configuration ### Basic Configuration ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~47-~47: Use correct spacing
Context: ... available ## Configuration ### Basic Configuration Add Claude Code to your Task Master conf...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~49-~49: There might be a mistake here.
Context: ...on Add Claude Code to your Task Master configuration: javascript // In your .taskmaster/config.json or via task-master models command { "models": { "main": "claude-code:sonnet", // Use Claude Code with Sonnet "research": "perplexity-llama-3.1-sonar-large-128k-online", "fallback": "claude-code:opus" // Use Claude Code with Opus as fallback } } ### Supported Models - `claude-...
(QB_NEW_EN_OTHER)
[grammar] ~62-~62: Use correct spacing
Context: ...us as fallback } } ``` ### Supported Models - claude-code:sonnet - Claude 3.5 Sonnet via Claude Code CLI...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~64-~64: Use correct spacing
Context: ...et- Claude 3.5 Sonnet via Claude Code CLI -claude-code:opus` - Claude 3 Opus via Claude Code CLI ### ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~65-~65: Use correct spacing
Context: ...e:opus` - Claude 3 Opus via Claude Code CLI ### Environment Variables (Optional) While ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~67-~67: Use correct spacing
Context: ...ude Code CLI ### Environment Variables (Optional) While not required, you can optionally s...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~69-~69: There might be a mistake here.
Context: ... While not required, you can optionally set: bash export CLAUDE_CODE_OAUTH_TOKEN="your_oauth_token_here" This is only needed in specific scenario...
(QB_NEW_EN_OTHER)
[grammar] ~75-~75: There might be a mistake here.
Context: ...is is only needed in specific scenarios like: - CI/CD pipelines - Docker containers ...
(QB_NEW_EN_OTHER)
[grammar] ~76-~76: There might be a mistake here.
Context: ...ded in specific scenarios like: - CI/CD pipelines - Docker containers - When you want to use...
(QB_NEW_EN_OTHER)
[grammar] ~77-~77: There might be a mistake here.
Context: ...narios like: - CI/CD pipelines - Docker containers - When you want to use a different token t...
(QB_NEW_EN_OTHER)
[grammar] ~78-~78: There might be a mistake here.
Context: ...t to use a different token than the CLI default ## Usage Examples ### Basic Task Operation...
(QB_NEW_EN_OTHER)
[grammar] ~80-~80: Use correct spacing
Context: ...nt token than the CLI default ## Usage Examples ### Basic Task Operations ```bash # Use Cla...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~82-~82: Use correct spacing
Context: ...ault ## Usage Examples ### Basic Task Operations bash # Use Claude Code for task operations task-master add-task --prompt="Implement user authentication system" --research task-master expand --id=1 --research task-master update-task --id=1.1 --prompt="Add JWT token validation" ### Model Configuration Commands ```bash # ...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~91-~91: Use correct spacing
Context: ...alidation" ### Model Configuration Commands bash # Set Claude Code as main model task-master models --set-main claude-code:sonnet # Use interactive setup task-master models --setup # Then select "claude-code" from the provider list ``` ## Troubleshooting ### Common Issues ####...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~104-~104: Use correct spacing
Context: ...ist ``` ## Troubleshooting ### Common Issues #### 1. "Claude Code CLI not available" Error...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~106-~106: Use correct spacing
Context: ...#### 1. "Claude Code CLI not available" Error Problem: Task Master cannot connect to...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~108-~108: Use correct spacing
Context: ...sk Master cannot connect to Claude Code CLI. Solutions: - Ensure Claude Code CLI is...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~111-~111: Use proper capitalization
Context: ...laude Code CLI is installed and in your PATH - Run claude setup-token to configure au...
(QB_NEW_EN_OTHER_ERROR_IDS_6)
[grammar] ~112-~112: There might be a mistake here.
Context: ...- Run claude setup-token to configure authentication - Verify Claude Code CLI works: `claude --...
(QB_NEW_EN_OTHER)
[grammar] ~113-~113: Use correct spacing
Context: ...authentication - Verify Claude Code CLI works: claude --help #### 2. Authentication Failures Problem:...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~115-~115: Use correct spacing
Context: ...claude --help #### 2. Authentication Failures Problem: Token authentication is faili...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~117-~117: Use correct spacing
Context: ...s Problem: Token authentication is failing. Solutions: - Re-run `claude setup-toke...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~120-~120: There might be a mistake here.
Context: ...aude setup-token` to refresh your OAuth token - Check if your token has expired - Verify...
(QB_NEW_EN_OTHER)
[grammar] ~121-~121: There might be a mistake here.
Context: ...r OAuth token - Check if your token has expired - Verify Claude Code CLI can authenticate:...
(QB_NEW_EN_OTHER)
[grammar] ~122-~122: There might be a mistake here.
Context: ...can authenticate: try a simple claude command #### 3. Model Not Available Problem: Spe...
(QB_NEW_EN_OTHER)
[grammar] ~124-~124: Use correct spacing
Context: ...ple claude command #### 3. Model Not Available Problem: Specified Claude Code model i...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~126-~126: Use correct spacing
Context: ...m**: Specified Claude Code model is not supported. Solutions: - Use supported models: `so...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~130-~130: There might be a mistake here.
Context: ...odels: sonnet or opus - Check model availability: task-master models --list - Verify your Claude Code CLI has access to the ...
(QB_NEW_EN_OTHER)
[grammar] ~131-~131: There might be a mistake here.
Context: ...de Code CLI has access to the requested model ### Debug Steps 1. **Test Claude Code CLI d...
(QB_NEW_EN_OTHER)
[grammar] ~133-~133: Use correct spacing
Context: ...ccess to the requested model ### Debug Steps 1. Test Claude Code CLI directly: ```b...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~135-~135: There might be a mistake here.
Context: ... Debug Steps 1. Test Claude Code CLI directly: bash claude --help # Should show help without errors 2. Test authentication: ```bash ...
(QB_NEW_EN_OTHER)
[grammar] ~141-~141: There might be a mistake here.
Context: ...w help without errors 2. **Test authentication**: bash claude setup-token --verify # Should confirm token is valid ``` 3. Test Task Master integration: ...
(QB_NEW_EN_OTHER)
[grammar] ~147-~147: There might be a mistake here.
Context: ... is valid 3. **Test Task Master integration**: bash task-master models --test claude-code:sonnet # Should successfully connect and test the model ``` 4. Check logs: - Task Master logs...
(QB_NEW_EN_OTHER)
[grammar] ~154-~154: There might be a problem here.
Context: ...sk Master logs will show detailed error messages - Use --verbose flag for more detailed outp...
(QB_NEW_EN_MERGED_MATCH)
[grammar] ~155-~155: There might be a mistake here.
Context: ... Use --verbose flag for more detailed output ### Environment-Specific Configuration ####...
(QB_NEW_EN_OTHER)
[grammar] ~157-~157: Use correct spacing
Context: ...tailed output ### Environment-Specific Configuration #### Docker/Containers When running in Docke...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~161-~161: There might be a mistake here.
Context: ...rs When running in Docker, you'll need to: 1. Install Claude Code CLI in your contain...
(QB_NEW_EN_OTHER)
[grammar] ~163-~163: There might be a mistake here.
Context: ...to: 1. Install Claude Code CLI in your container 2. Set up authentication via environment va...
(QB_NEW_EN_OTHER)
[grammar] ~164-~164: There might be a mistake here.
Context: .... Set up authentication via environment variable: dockerfile ENV CLAUDE_CODE_OAUTH_TOKEN="your_token_here" #### CI/CD Pipelines For automated envir...
(QB_NEW_EN_OTHER)
[grammar] ~169-~169: Use correct spacing
Context: ...EN="your_token_here" ``` #### CI/CD Pipelines For automated environments: 1. Set up a...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~171-~171: There might be a mistake here.
Context: ...`` #### CI/CD Pipelines For automated environments: 1. Set up a service account token or use e...
(QB_NEW_EN_OTHER)
[grammar] ~173-~173: There might be a mistake here.
Context: ...ervice account token or use environment variables 2. Ensure Claude Code CLI is available in t...
(QB_NEW_EN_OTHER)
[grammar] ~174-~174: There might be a mistake here.
Context: ...e Code CLI is available in the pipeline environment 3. Configure authentication before running ...
(QB_NEW_EN_OTHER)
[grammar] ~175-~175: There might be a mistake here.
Context: ...thentication before running Task Master commands ## Integration with AI SDK Task Master's C...
(QB_NEW_EN_OTHER)
[grammar] ~177-~177: Use correct spacing
Context: ...Master commands ## Integration with AI SDK Task Master's Claude Code integration us...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~179-~179: There might be a mistake here.
Context: ... ai-sdk-provider-claude-code package, providing: - Streaming Support: Real-time token st...
(QB_NEW_EN_OTHER)
[grammar] ~184-~184: Use correct spacing
Context: ...ull TypeScript support with proper type definitions ### Example AI SDK Usage ```javascript impo...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~186-~186: Use correct spacing
Context: ...er type definitions ### Example AI SDK Usage javascript import { generateText } from 'ai'; import { ClaudeCodeProvider } from './src/ai-providers/claude-code.js'; const provider = new ClaudeCodeProvider(); const client = provider.getClient(); const result = await generateText({ model: client('sonnet'), messages: [ { role: 'user', content: 'Hello Claude!' } ] }); console.log(result.text); ## Security Notes - OAuth tokens are manag...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~205-~205: Use correct spacing
Context: ...sole.log(result.text); ``` ## Security Notes - OAuth tokens are managed securely by Cla...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~207-~207: Use proper capitalization
Context: ...ens are managed securely by Claude Code CLI - No API keys need to be stored in your pr...
(QB_NEW_EN_OTHER_ERROR_IDS_6)
[grammar] ~208-~208: There might be a mistake here.
Context: ... keys need to be stored in your project files - Tokens are automatically refreshed by th...
(QB_NEW_EN_OTHER)
[grammar] ~209-~209: Use proper capitalization
Context: ...omatically refreshed by the Claude Code CLI - Environment variables should only be use...
(QB_NEW_EN_OTHER_ERROR_IDS_6)
[grammar] ~210-~210: There might be a mistake here.
Context: ...variables should only be used in secure environments ## Getting Help If you encounter issues: ...
(QB_NEW_EN_OTHER)
[grammar] ~212-~212: Use correct spacing
Context: ...used in secure environments ## Getting Help If you encounter issues: 1. Check the C...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~214-~214: There might be a mistake here.
Context: ...ents ## Getting Help If you encounter issues: 1. Check the Claude Code CLI documentation...
(QB_NEW_EN_OTHER)
[grammar] ~216-~216: There might be a mistake here.
Context: ...r issues: 1. Check the Claude Code CLI documentation 2. Verify your authentication setup with `c...
(QB_NEW_EN_OTHER)
[grammar] ~218-~218: There might be a mistake here.
Context: ...iew Task Master logs for detailed error messages 4. Open an issue with both Task Master and ...
(QB_NEW_EN_OTHER)
[grammar] ~219-~219: Use a period to end declarative sentences
Context: ...oth Task Master and Claude Code version information
(QB_NEW_EN_OTHER_ERROR_IDS_25)
🪛 markdownlint-cli2 (0.17.2)
16-16: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
22-22: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
76-76: Lists should be surrounded by blank lines
(MD032, blanks-around-lists)
111-111: Lists should be surrounded by blank lines
(MD032, blanks-around-lists)
120-120: Lists should be surrounded by blank lines
(MD032, blanks-around-lists)
129-129: Lists should be surrounded by blank lines
(MD032, blanks-around-lists)
136-136: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
142-142: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
148-148: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
165-165: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
219-219: Files should end with a single newline character
(MD047, single-trailing-newline)
🤖 Prompt for AI Agents
In docs/claude-code-integration.md from lines 1 to 219, fix markdownlint spacing
issues by adding blank lines before and after each fenced code block and around
all lists to comply with MD031 and MD032 rules. Also, ensure the file ends with
a single newline character to satisfy MD047. Review the entire document to
insert these blank lines consistently without altering content.
| 3. Configure authentication before running Task Master commands | ||
|
|
||
| ## Integration with AI SDK | ||
|
|
||
| Task Master's Claude Code integration uses the official `ai-sdk-provider-claude-code` package, providing: | ||
|
|
||
| - **Streaming Support**: Real-time token streaming for interactive experiences | ||
| - **Full AI SDK Compatibility**: Works with generateText, streamText, and other AI SDK functions | ||
| - **Automatic Error Handling**: Graceful degradation when Claude Code is unavailable | ||
| - **Type Safety**: Full TypeScript support with proper type definitions | ||
|
|
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Add “Migration from AI SDK v4.x” notes
Given the v5 upgrade, add a short section with key migration points (e.g., API surface expectations, streaming usage, error shape changes) and any Task Master command changes.
I can draft the migration snippet if you confirm areas users commonly trip on here.
🧰 Tools
🪛 LanguageTool
[grammar] ~175-~175: There might be a mistake here.
Context: ...thentication before running Task Master commands ## Integration with AI SDK Task Master's C...
(QB_NEW_EN_OTHER)
[grammar] ~177-~177: Use correct spacing
Context: ...Master commands ## Integration with AI SDK Task Master's Claude Code integration us...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~179-~179: There might be a mistake here.
Context: ... ai-sdk-provider-claude-code package, providing: - Streaming Support: Real-time token st...
(QB_NEW_EN_OTHER)
[grammar] ~184-~184: Use correct spacing
Context: ...ull TypeScript support with proper type definitions ### Example AI SDK Usage ```javascript impo...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
🤖 Prompt for AI Agents
In docs/claude-code-integration.md around lines 175 to 185, add a new section
titled "Migration from AI SDK v4.x" that outlines key migration points such as
changes in API surface expectations, updates in streaming usage, modifications
in error shapes, and any relevant Task Master command changes. This section
should provide clear guidance to users upgrading to v5 to help them avoid common
pitfalls. Coordinate with the team to confirm typical user issues before
drafting the migration notes.
| } catch (error) { | ||
| console.error('\n❌ Test failed with error:'); | ||
| console.error('Error message:', error.message); | ||
|
|
||
| if (error.message.includes('Claude Code CLI')) { | ||
| console.error('\n💡 Troubleshooting suggestions:'); | ||
| console.error('1. Ensure Claude Code CLI is installed'); | ||
| console.error('2. Run: claude setup-token'); | ||
| console.error('3. Verify CLI works: claude --help'); | ||
| } | ||
|
|
||
| console.error('\nStack trace:', error.stack); | ||
| process.exit(1); |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Harden error logging for non-Error throws and surfaced causes
Guard against non-Error values and log nested causes if available.
} catch (error) {
- console.error('\n❌ Test failed with error:');
- console.error('Error message:', error.message);
+ console.error('\n❌ Test failed with error:');
+ const isObj = error && typeof error === 'object';
+ const message = isObj && 'message' in error ? error.message : String(error);
+ console.error('Error message:', message);
- if (error.message.includes('Claude Code CLI')) {
+ if (typeof message === 'string' && message.includes('Claude Code CLI')) {
console.error('\n💡 Troubleshooting suggestions:');
console.error('1. Ensure Claude Code CLI is installed');
console.error('2. Run: claude setup-token');
console.error('3. Verify CLI works: claude --help');
}
- console.error('\nStack trace:', error.stack);
+ if (isObj && 'cause' in error && error.cause) {
+ console.error('\nCaused by:', error.cause);
+ }
+ console.error('\nStack trace:', isObj ? error.stack : 'N/A');
process.exit(1);
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| } catch (error) { | |
| console.error('\n❌ Test failed with error:'); | |
| console.error('Error message:', error.message); | |
| if (error.message.includes('Claude Code CLI')) { | |
| console.error('\n💡 Troubleshooting suggestions:'); | |
| console.error('1. Ensure Claude Code CLI is installed'); | |
| console.error('2. Run: claude setup-token'); | |
| console.error('3. Verify CLI works: claude --help'); | |
| } | |
| console.error('\nStack trace:', error.stack); | |
| process.exit(1); | |
| } catch (error) { | |
| console.error('\n❌ Test failed with error:'); | |
| const isObj = error && typeof error === 'object'; | |
| const message = isObj && 'message' in error ? error.message : String(error); | |
| console.error('Error message:', message); | |
| if (typeof message === 'string' && message.includes('Claude Code CLI')) { | |
| console.error('\n💡 Troubleshooting suggestions:'); | |
| console.error('1. Ensure Claude Code CLI is installed'); | |
| console.error('2. Run: claude setup-token'); | |
| console.error('3. Verify CLI works: claude --help'); | |
| } | |
| if (isObj && 'cause' in error && error.cause) { | |
| console.error('\nCaused by:', error.cause); | |
| } | |
| console.error('\nStack trace:', isObj ? error.stack : 'N/A'); | |
| process.exit(1); | |
| } |
🤖 Prompt for AI Agents
In scripts/test-claude-code-direct.js around lines 54 to 66, the error handling
assumes the caught error is always an Error object, which may not be true.
Update the catch block to first check if the error is an object with a message
property before accessing error.message, and handle cases where the error might
be a string or other type. Additionally, if the error has a nested cause
property, log that cause to provide more detailed debugging information. This
will harden the error logging against non-Error throws and surface nested causes
if available.
| if (import.meta.url === `file://${process.argv[1]}`) { | ||
| testClaudeCodeIntegration().catch(console.error); | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Make ESM “run directly” check cross-platform
String-compare on import.meta.url can fail on Windows or with encoded paths. Use fileURLToPath + path.resolve.
+import { fileURLToPath } from 'node:url';
+import path from 'node:path';
+
// Handle CLI usage
-if (import.meta.url === `file://${process.argv[1]}`) {
- testClaudeCodeIntegration().catch(console.error);
-}
+if (process.argv[1]) {
+ const thisFile = fileURLToPath(import.meta.url);
+ if (path.resolve(thisFile) === path.resolve(process.argv[1])) {
+ testClaudeCodeIntegration().catch(console.error);
+ }
+}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (import.meta.url === `file://${process.argv[1]}`) { | |
| testClaudeCodeIntegration().catch(console.error); | |
| } | |
| import { fileURLToPath } from 'node:url'; | |
| import path from 'node:path'; | |
| // Handle CLI usage | |
| if (process.argv[1]) { | |
| const thisFile = fileURLToPath(import.meta.url); | |
| if (path.resolve(thisFile) === path.resolve(process.argv[1])) { | |
| testClaudeCodeIntegration().catch(console.error); | |
| } | |
| } |
🤖 Prompt for AI Agents
In scripts/test-claude-code-direct.js around lines 71 to 73, the current check
using string comparison on import.meta.url to determine if the script is run
directly is not cross-platform and can fail on Windows or with encoded paths.
Replace the string comparison with a comparison between the resolved file paths
by converting import.meta.url to a file path using fileURLToPath and then
resolving it with path.resolve, comparing it to the resolved process.argv[1]
path. This ensures the check works correctly across different operating systems.
| * Claude Code provider implementation using the ai-sdk-provider-claude-code package. | ||
| * This provider uses the local Claude Code CLI with OAuth token authentication. | ||
| * | ||
| * Authentication: | ||
| * - Uses CLAUDE_CODE_OAUTH_TOKEN managed by Claude Code CLI | ||
| * - Token is set up via: claude setup-token | ||
| * - No manual API key configuration required |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Docs/env var mismatch: clarify whether any env var is used
Header mentions CLAUDE_CODE_OAUTH_TOKEN, yet the class returns CLAUDE_CODE_API_KEY as the “(not used)” key. Align docs and code to avoid confusion.
If you intend to reference the CLI-managed token for messaging only, also align getRequiredApiKeyName:
- * - Uses CLAUDE_CODE_OAUTH_TOKEN managed by Claude Code CLI
+ * - Uses CLI-managed OAuth; no manual env var required📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| * Claude Code provider implementation using the ai-sdk-provider-claude-code package. | |
| * This provider uses the local Claude Code CLI with OAuth token authentication. | |
| * | |
| * Authentication: | |
| * - Uses CLAUDE_CODE_OAUTH_TOKEN managed by Claude Code CLI | |
| * - Token is set up via: claude setup-token | |
| * - No manual API key configuration required | |
| * Claude Code provider implementation using the ai-sdk-provider-claude-code package. | |
| * This provider uses the local Claude Code CLI with OAuth token authentication. | |
| * | |
| * Authentication: | |
| * - Uses CLI-managed OAuth; no manual env var required | |
| * - Token is set up via: claude setup-token | |
| * - No manual API key configuration required |
🤖 Prompt for AI Agents
In src/ai-providers/claude-code.js around lines 4 to 10, the documentation
mentions using the CLAUDE_CODE_OAUTH_TOKEN environment variable, but the class
method getRequiredApiKeyName returns CLAUDE_CODE_API_KEY as the key name,
causing confusion. To fix this, update the getRequiredApiKeyName method to
return CLAUDE_CODE_OAUTH_TOKEN instead, aligning the code with the documentation
and clarifying that this token is used for authentication.
| beforeAll(async () => { | ||
| // Mock AI SDK functions | ||
| generateText = jest.fn(); | ||
| streamText = jest.fn(); | ||
|
|
||
| jest.unstable_mockModule('ai', () => ({ | ||
| generateText, | ||
| streamText | ||
| })); | ||
| }); |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
beforeAll doesn’t need to be async here
No awaits are used; keep it sync to reduce async in tests per guidelines.
-beforeAll(async () => {
+beforeAll(() => {
// Mock AI SDK functions
generateText = jest.fn();
streamText = jest.fn();
jest.unstable_mockModule('ai', () => ({
generateText,
streamText
}));
-});
+});📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| beforeAll(async () => { | |
| // Mock AI SDK functions | |
| generateText = jest.fn(); | |
| streamText = jest.fn(); | |
| jest.unstable_mockModule('ai', () => ({ | |
| generateText, | |
| streamText | |
| })); | |
| }); | |
| beforeAll(() => { | |
| // Mock AI SDK functions | |
| generateText = jest.fn(); | |
| streamText = jest.fn(); | |
| jest.unstable_mockModule('ai', () => ({ | |
| generateText, | |
| streamText | |
| })); | |
| }); |
🤖 Prompt for AI Agents
In tests/integration/claude-code-optional.test.js around lines 8 to 17, the
beforeAll function is marked async but does not use any await expressions.
Remove the async keyword from beforeAll to keep it synchronous, following test
guidelines to reduce unnecessary async usage.
| beforeEach(async () => { | ||
| // Mock successful provider creation | ||
| const mockProvider = jest.fn((modelId) => ({ | ||
| id: modelId, | ||
| doGenerate: jest.fn(), | ||
| doStream: jest.fn() | ||
| })); | ||
|
|
||
| jest.unstable_mockModule('ai-sdk-provider-claude-code', () => ({ | ||
| createClaudeCode: jest.fn(() => mockProvider) | ||
| })); | ||
|
|
||
| // The actual usage should fail with the lazy loading error | ||
| await expect( | ||
| model.doGenerate({ | ||
| prompt: [{ role: 'user', content: 'Hello' }], | ||
| mode: { type: 'regular' } | ||
| }) | ||
| ).rejects.toThrow( | ||
| "Claude Code SDK is not installed. Please install '@anthropic-ai/claude-code' to use the claude-code provider." | ||
| ); | ||
| const module = await import('../../src/ai-providers/claude-code.js'); | ||
| ClaudeCodeProvider = module.ClaudeCodeProvider; | ||
| }); |
There was a problem hiding this comment.
Reset module registry between different mock setups
You import the provider once with a “CLI missing” mock, then re-mock for “available” without resetting the cache. Add jest.resetModules() before the second import to ensure the new mock applies.
describe('with Claude Code available', () => {
- beforeEach(async () => {
+ beforeEach(async () => {
+ jest.resetModules();
// Mock successful provider creation
const mockProvider = jest.fn((modelId) => ({
id: modelId,
doGenerate: jest.fn(),
doStream: jest.fn()
}));
jest.unstable_mockModule('ai-sdk-provider-claude-code', () => ({
createClaudeCode: jest.fn(() => mockProvider)
}));
const module = await import('../../src/ai-providers/claude-code.js');
ClaudeCodeProvider = module.ClaudeCodeProvider;
});Also consider calling jest.resetModules() before the import in the “CLI missing” test for symmetry.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| beforeEach(async () => { | |
| // Mock successful provider creation | |
| const mockProvider = jest.fn((modelId) => ({ | |
| id: modelId, | |
| doGenerate: jest.fn(), | |
| doStream: jest.fn() | |
| })); | |
| jest.unstable_mockModule('ai-sdk-provider-claude-code', () => ({ | |
| createClaudeCode: jest.fn(() => mockProvider) | |
| })); | |
| // The actual usage should fail with the lazy loading error | |
| await expect( | |
| model.doGenerate({ | |
| prompt: [{ role: 'user', content: 'Hello' }], | |
| mode: { type: 'regular' } | |
| }) | |
| ).rejects.toThrow( | |
| "Claude Code SDK is not installed. Please install '@anthropic-ai/claude-code' to use the claude-code provider." | |
| ); | |
| const module = await import('../../src/ai-providers/claude-code.js'); | |
| ClaudeCodeProvider = module.ClaudeCodeProvider; | |
| }); | |
| describe('with Claude Code available', () => { | |
| beforeEach(async () => { | |
| jest.resetModules(); | |
| // Mock successful provider creation | |
| const mockProvider = jest.fn((modelId) => ({ | |
| id: modelId, | |
| doGenerate: jest.fn(), | |
| doStream: jest.fn() | |
| })); | |
| jest.unstable_mockModule('ai-sdk-provider-claude-code', () => ({ | |
| createClaudeCode: jest.fn(() => mockProvider) | |
| })); | |
| const module = await import('../../src/ai-providers/claude-code.js'); | |
| ClaudeCodeProvider = module.ClaudeCodeProvider; | |
| }); | |
| // ... other tests ... | |
| }); |
🤖 Prompt for AI Agents
In tests/integration/claude-code-optional.test.js around lines 38 to 52, you
need to add jest.resetModules() before importing the module in each beforeEach
block that sets up different mocks. This ensures the module cache is cleared so
the new mock definitions take effect properly. Add jest.resetModules() at the
start of the beforeEach function before calling jest.unstable_mockModule and
importing the module, both for the "CLI missing" and "available" mock setups.
| it('should integrate with AI SDK streamText', async () => { | ||
| const provider = new ClaudeCodeProvider(); | ||
| expect(provider).toBeDefined(); | ||
| const client = provider.getClient(); | ||
|
|
||
| // Mock successful streaming | ||
| const mockStream = { | ||
| textStream: (async function* () { | ||
| yield 'Hello '; | ||
| yield 'from '; | ||
| yield 'Claude Code!'; | ||
| })() | ||
| }; | ||
| streamText.mockResolvedValueOnce(mockStream); | ||
|
|
||
| const result = await streamText({ | ||
| model: client('sonnet'), | ||
| messages: [{ role: 'user', content: 'Hello' }] | ||
| }); | ||
|
|
||
| // In real usage, ai-services-unified would: | ||
| // 1. Get the provider instance (works) | ||
| // 2. Call provider.getClient() (works) | ||
| // 3. Create a model (works) | ||
| // 4. Try to generate (fails with clear error) | ||
| expect(result.textStream).toBeDefined(); | ||
| expect(streamText).toHaveBeenCalledWith({ | ||
| model: expect.any(Object), | ||
| messages: [{ role: 'user', content: 'Hello' }] | ||
| }); | ||
| }); |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Make streamText test fully synchronous
Same rationale as above. Return a sync object from the mock.
- it('should integrate with AI SDK streamText', async () => {
+ it('should integrate with AI SDK streamText', () => {
const provider = new ClaudeCodeProvider();
const client = provider.getClient();
// Mock successful streaming
const mockStream = {
textStream: (async function* () {
yield 'Hello ';
yield 'from ';
yield 'Claude Code!';
})()
};
- streamText.mockResolvedValueOnce(mockStream);
+ streamText.mockReturnValueOnce(mockStream);
- const result = await streamText({
+ const result = streamText({
model: client('sonnet'),
messages: [{ role: 'user', content: 'Hello' }]
});
expect(result.textStream).toBeDefined();
expect(streamText).toHaveBeenCalledWith({
model: expect.any(Object),
messages: [{ role: 'user', content: 'Hello' }]
});
});📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| it('should integrate with AI SDK streamText', async () => { | |
| const provider = new ClaudeCodeProvider(); | |
| expect(provider).toBeDefined(); | |
| const client = provider.getClient(); | |
| // Mock successful streaming | |
| const mockStream = { | |
| textStream: (async function* () { | |
| yield 'Hello '; | |
| yield 'from '; | |
| yield 'Claude Code!'; | |
| })() | |
| }; | |
| streamText.mockResolvedValueOnce(mockStream); | |
| const result = await streamText({ | |
| model: client('sonnet'), | |
| messages: [{ role: 'user', content: 'Hello' }] | |
| }); | |
| // In real usage, ai-services-unified would: | |
| // 1. Get the provider instance (works) | |
| // 2. Call provider.getClient() (works) | |
| // 3. Create a model (works) | |
| // 4. Try to generate (fails with clear error) | |
| expect(result.textStream).toBeDefined(); | |
| expect(streamText).toHaveBeenCalledWith({ | |
| model: expect.any(Object), | |
| messages: [{ role: 'user', content: 'Hello' }] | |
| }); | |
| }); | |
| it('should integrate with AI SDK streamText', () => { | |
| const provider = new ClaudeCodeProvider(); | |
| const client = provider.getClient(); | |
| // Mock successful streaming | |
| const mockStream = { | |
| textStream: (async function* () { | |
| yield 'Hello '; | |
| yield 'from '; | |
| yield 'Claude Code!'; | |
| })() | |
| }; | |
| streamText.mockReturnValueOnce(mockStream); | |
| const result = streamText({ | |
| model: client('sonnet'), | |
| messages: [{ role: 'user', content: 'Hello' }] | |
| }); | |
| expect(result.textStream).toBeDefined(); | |
| expect(streamText).toHaveBeenCalledWith({ | |
| model: expect.any(Object), | |
| messages: [{ role: 'user', content: 'Hello' }] | |
| }); | |
| }); |
🤖 Prompt for AI Agents
In tests/integration/claude-code-optional.test.js between lines 82 and 106, the
streamText mock returns an async generator which makes the test asynchronous. To
fix this, change the mock to return a synchronous iterable object instead of an
async generator, ensuring the test runs fully synchronously. Adjust the
mockStream.textStream to be a synchronous generator or iterable that yields the
same values.
| // Force an error by making createClaudeCode throw | ||
| const { createClaudeCode } = await import( | ||
| '../../../src/ai-providers/custom-sdk/claude-code/index.js' | ||
| 'ai-sdk-provider-claude-code' | ||
| ); | ||
| createClaudeCode.mockImplementationOnce(() => { | ||
| throw new Error('Mock initialization error'); | ||
| }); | ||
|
|
||
| // Create a new provider instance to use the mocked createClaudeCode | ||
| const errorProvider = new ClaudeCodeProvider(); | ||
| expect(() => errorProvider.getClient({})).toThrow( | ||
| 'Mock initialization error' | ||
| ); | ||
| expect(() => errorProvider.getClient({})).toThrow('Mock initialization error'); | ||
| }); |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Don’t assert exact error text in unit tests
Prefer regex/substring to avoid brittleness as messages evolve.
- expect(() => errorProvider.getClient({})).toThrow('Mock initialization error');
+ expect(() => errorProvider.getClient({})).toThrow(/initialization error/i);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Force an error by making createClaudeCode throw | |
| const { createClaudeCode } = await import( | |
| '../../../src/ai-providers/custom-sdk/claude-code/index.js' | |
| 'ai-sdk-provider-claude-code' | |
| ); | |
| createClaudeCode.mockImplementationOnce(() => { | |
| throw new Error('Mock initialization error'); | |
| }); | |
| // Create a new provider instance to use the mocked createClaudeCode | |
| const errorProvider = new ClaudeCodeProvider(); | |
| expect(() => errorProvider.getClient({})).toThrow( | |
| 'Mock initialization error' | |
| ); | |
| expect(() => errorProvider.getClient({})).toThrow('Mock initialization error'); | |
| }); | |
| // Force an error by making createClaudeCode throw | |
| const { createClaudeCode } = await import( | |
| 'ai-sdk-provider-claude-code' | |
| ); | |
| createClaudeCode.mockImplementationOnce(() => { | |
| throw new Error('Mock initialization error'); | |
| }); | |
| // Create a new provider instance to use the mocked createClaudeCode | |
| const errorProvider = new ClaudeCodeProvider(); | |
| expect(() => errorProvider.getClient({})).toThrow(/initialization error/i); | |
| }); |
🤖 Prompt for AI Agents
In tests/unit/ai-providers/claude-code.test.js around lines 112 to 123, the test
asserts the exact error message string which can cause brittleness if the
message changes. Modify the test to use a regex or substring match in the
expect().toThrow() assertion instead of the exact error text to make the test
more resilient to message changes.
Crunchyman-ralph
left a comment
There was a problem hiding this comment.
if you're replacing claude code might as well remove the directory: ./custom-sdk/claude-code since the ai sdk claude code package comes from this repository.
Shout out @ben-vargas the OG
|
Vercel AI SDK v5 is GA (use latest stable rather than beta), and breaking. Upgrading touches the base provider and all ai-sdk providers—not just Claude Code. I also spiked a branch that mostly works, but it’s large, so never submitted it given outstanding PRs and lack of time to really thoroughly review the AI code. I recommend a single, coordinated migration: update the base + all providers together; I do agree in moving to adopt ai-sdk-provider-claude-code (mirroring ai-sdk-provider-gemini-cli) and deleting the custom-sdk dir in our codebase, that has been on my PR "to-do" list. Tomorrow I'll probably update both claude-code and gemini-cli ai-sdk-providers to latest ai-sdk release and remove the beta tag. |
Yes, to completely migrate to ai sdk 5, we need more work not just Claude Code sdk. |
|
@tommy-ca I'm back on reviewing PRs, you taking this home, or should I jump on it ? |
540354b to
d0258e9
Compare
🦋 Changeset detectedLatest commit: 9f339cc The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/ai-providers/claude-code.js (1)
1-98: Export provider wrapper functions to meet module contractAdd thin wrapper exports that instantiate ClaudeCodeProvider and call generateText/streamText/generateObject. Append to src/ai-providers/claude-code.js:
// Wrapper exports per provider module guidelines export async function generateClaudeCodeText(params) { const provider = new ClaudeCodeProvider(); return provider.generateText(params); } export async function streamClaudeCodeText(params) { const provider = new ClaudeCodeProvider(); return provider.streamText(params); } export async function generateClaudeCodeObject(params) { const provider = new ClaudeCodeProvider(); return provider.generateObject(params); }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (4)
docs/claude-code-integration.md(1 hunks)package.json(1 hunks)scripts/test-claude-code-direct.js(1 hunks)src/ai-providers/claude-code.js(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
package.json
📄 CodeRabbit inference engine (.cursor/rules/test_workflow.mdc)
Add and update test scripts in package.json to include test, test:watch, test:coverage, test:unit, test:integration, test:e2e, and test:ci
Files:
package.json
**/*.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:
scripts/test-claude-code-direct.jssrc/ai-providers/claude-code.js
docs/**/*
📄 CodeRabbit inference engine (.cursor/rules/new_features.mdc)
Add feature documentation to '/docs' folder, include tagged system usage examples, update command reference documentation, and provide migration notes if relevant.
Files:
docs/claude-code-integration.md
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/claude-code.js
🧠 Learnings (21)
📚 Learning: 2025-08-07T13:00:22.966Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1090
File: apps/extension/package.json:241-243
Timestamp: 2025-08-07T13:00:22.966Z
Learning: In monorepos, local packages should use "*" as the version constraint in package.json dependencies, as recommended by npm. This ensures the local version from within the same workspace is always used, rather than attempting to resolve from external registries. This applies to packages like task-master-ai within the eyaltoledano/claude-task-master monorepo.
Applied to files:
package.json
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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:
package.jsonscripts/test-claude-code-direct.jssrc/ai-providers/claude-code.js
📚 Learning: 2025-07-18T17:12:57.903Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/new_features.mdc:0-0
Timestamp: 2025-07-18T17:12:57.903Z
Learning: Applies to scripts/modules/**/*.test.js : Test CLI and MCP interfaces with real task data, verify end-to-end workflows across tag contexts, and test error scenarios and recovery in integration tests.
Applied to files:
scripts/test-claude-code-direct.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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:
scripts/test-claude-code-direct.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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:
scripts/test-claude-code-direct.js
📚 Learning: 2025-07-18T17:12:57.903Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/new_features.mdc:0-0
Timestamp: 2025-07-18T17:12:57.903Z
Learning: Applies to scripts/modules/*.js : Use structured error objects with code and message properties, include clear error messages, and handle both function-specific and file system errors.
Applied to files:
scripts/test-claude-code-direct.js
📚 Learning: 2025-07-18T17:11:36.732Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/mcp.mdc:0-0
Timestamp: 2025-07-18T17:11:36.732Z
Learning: Applies to mcp-server/src/core/direct-functions/*.js : Wrap core function calls and AI calls in try/catch blocks in direct functions, log errors with appropriate severity and context, and return standardized error objects with code and message.
Applied to files:
scripts/test-claude-code-direct.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : Verify file operations use the correct paths in expect statements.
Applied to files:
scripts/test-claude-code-direct.js
📚 Learning: 2025-09-03T13:46:00.640Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1178
File: packages/tm-core/src/auth/oauth-service.ts:20-20
Timestamp: 2025-09-03T13:46:00.640Z
Learning: For Node.js v22 and later, JSON imports should use `with { type: 'json' }` syntax, not `assert { type: 'json' }`. The `assert` syntax was removed in Node.js v22 in favor of the `with` syntax for import attributes. This applies to the eyaltoledano/claude-task-master codebase which uses Node.js v24.
Applied to files:
scripts/test-claude-code-direct.js
📚 Learning: 2025-07-18T17:12:57.903Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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:
scripts/test-claude-code-direct.js
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/ai_providers.mdc:0-0
Timestamp: 2025-07-18T17:06:04.909Z
Learning: Applies to tests/unit/ai-providers/*.test.js : Create unit tests for the new provider in tests/unit/ai-providers/<provider-name>.test.js, mocking ai-sdk/<provider-name> and core ai module functions, and testing all exported functions for correct behavior and error handling.
Applied to files:
scripts/test-claude-code-direct.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : Mock API calls (e.g., Anthropic/Claude) by mocking the entire module and providing predictable responses.
Applied to files:
scripts/test-claude-code-direct.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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:
scripts/test-claude-code-direct.js
📚 Learning: 2025-08-11T12:30:23.843Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-11T12:30:23.843Z
Learning: Import Task Master's development workflow commands and guidelines; treat the contents of ./.taskmaster/CLAUDE.md as if included in the main CLAUDE.md
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-08-06T21:13:05.240Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1091
File: assets/claude/agents/task-orchestrator.md:69-78
Timestamp: 2025-08-06T21:13:05.240Z
Learning: For Claude agent instruction files in .claude/agents/ and assets/claude/agents/ directories, ignore markdownlint issues (like MD031 blanks-around-fences, MD040 fenced-code-language, MD041 missing top-level heading) as these files follow Claude's specific agent format requirements rather than standard markdown documentation conventions.
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-08-06T21:11:37.259Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1091
File: .claude/agents/task-orchestrator.md:0-0
Timestamp: 2025-08-06T21:11:37.259Z
Learning: For files in .claude/agents/ and assets/claude/agents/ directories, ignore markdownlint issues like MD041 (missing top-level heading) as these are Claude Code agent instruction files that follow a specific format with YAML frontmatter and don't need to conform to standard markdown documentation conventions.
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-07-18T17:10:12.881Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/dev_workflow.mdc:0-0
Timestamp: 2025-07-18T17:10:12.881Z
Learning: For CLI usage, install Taskmaster globally with `npm install -g task-master-ai` or use locally via `npx task-master-ai ...`.
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : Do not rely on environment variables for API keys in tests; set mock environment variables in test setup.
Applied to files:
src/ai-providers/claude-code.js
📚 Learning: 2025-07-18T17:12:57.903Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/new_features.mdc:0-0
Timestamp: 2025-07-18T17:12:57.903Z
Learning: Applies to scripts/modules/commands.js : Provide clear error messages for common failures, handle tagged system migration errors gracefully, include suggestions for resolution, and exit with appropriate codes for scripting in CLI commands.
Applied to files:
src/ai-providers/claude-code.js
📚 Learning: 2025-07-18T17:08:48.695Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/commands.mdc:0-0
Timestamp: 2025-07-18T17:08:48.695Z
Learning: Applies to scripts/modules/commands.js : Provide specific error handling for common issues, include troubleshooting hints for each error type, and use consistent error formatting across all commands.
Applied to files:
src/ai-providers/claude-code.js
📚 Learning: 2025-07-18T17:07:39.336Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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/claude-code.js
🧬 Code graph analysis (2)
scripts/test-claude-code-direct.js (1)
src/ai-providers/custom-sdk/claude-code/index.js (1)
createClaudeCode(20-65)
src/ai-providers/claude-code.js (3)
src/ai-providers/base-provider.js (1)
BaseAIProvider(16-352)scripts/modules/config-manager.js (3)
settings(377-377)settings(393-393)modelId(624-624)src/ai-providers/custom-sdk/claude-code/index.js (1)
createClaudeCode(20-65)
🪛 markdownlint-cli2 (0.18.1)
docs/claude-code-integration.md
16-16: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
22-22: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
76-76: Lists should be surrounded by blank lines
(MD032, blanks-around-lists)
111-111: Lists should be surrounded by blank lines
(MD032, blanks-around-lists)
120-120: Lists should be surrounded by blank lines
(MD032, blanks-around-lists)
129-129: Lists should be surrounded by blank lines
(MD032, blanks-around-lists)
136-136: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
142-142: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
148-148: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
165-165: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
219-219: Files should end with a single newline character
(MD047, single-trailing-newline)
🔇 Additional comments (13)
package.json (1)
20-27: Test scripts coverage LGTMAll required test scripts are present and correctly wired.
scripts/test-claude-code-direct.js (2)
54-66: Harden error handling for non-Error throws; surface cause; avoid hard exitGuard against non-Error values, log
causeif present, and prefer settingprocess.exitCodeinstead ofprocess.exit(1).} catch (error) { - console.error('\n❌ Test failed with error:'); - console.error('Error message:', error.message); + console.error('\n❌ Test failed with error:'); + const isObj = error && typeof error === 'object'; + const message = isObj && 'message' in error ? error.message : String(error); + console.error('Error message:', message); - if (error.message.includes('Claude Code CLI')) { + if (typeof message === 'string' && message.includes('Claude Code CLI')) { console.error('\n💡 Troubleshooting suggestions:'); console.error('1. Ensure Claude Code CLI is installed'); console.error('2. Run: claude setup-token'); console.error('3. Verify CLI works: claude --help'); } - console.error('\nStack trace:', error.stack); - process.exit(1); + if (isObj && 'cause' in error && error.cause) { + console.error('\nCaused by:', error.cause); + } + console.error('\nStack trace:', isObj ? error.stack : 'N/A'); + process.exitCode = 1; }
71-73: Make “run directly” check cross‑platformUse fileURLToPath + path.resolve instead of string-compare on import.meta.url.
+import { fileURLToPath } from 'node:url'; +import path from 'node:path'; + // Handle CLI usage -if (import.meta.url === `file://${process.argv[1]}`) { - testClaudeCodeIntegration().catch(console.error); -} +if (process.argv[1]) { + const thisFile = fileURLToPath(import.meta.url); + if (path.resolve(thisFile) === path.resolve(process.argv[1])) { + testClaudeCodeIntegration().catch(console.error); + } +}docs/claude-code-integration.md (2)
1-219: Fix markdownlint spacing and trailing newlineAdd blank lines around fenced code blocks and lists (MD031/MD032) and end with a single newline (MD047).
175-186: Add “Migration from AI SDK v4.x” notesBrief section on API diffs, streaming changes, error shapes, and any Task Master command updates.
src/ai-providers/claude-code.js (8)
29-30: Freeze supported models to prevent accidental mutationMake the list immutable.
- this.supportedModels = ['sonnet', 'opus']; + this.supportedModels = Object.freeze(['sonnet', 'opus']);Optional (outside this range): define a module‑level constant and assign it to improve reuse.
32-37: Align API key name with docs (optional) or state not requiredReturn the optional override env var to match messaging.
getRequiredApiKeyName() { - return 'CLAUDE_CODE_API_KEY'; + // Not required due to CLI OAuth; kept for messaging/telemetry + return 'CLAUDE_CODE_OAUTH_TOKEN'; }
47-52: Proactively detect CLI availability in validateAuthFast‑fail with actionable guidance if CLI is missing.
validateAuth(params) { - // Claude Code uses local CLI - no API key validation needed + // No API key validation; ensure CLI is present + try { + const { spawnSync } = await import('node:child_process'); + const res = spawnSync('claude', ['--version'], { stdio: 'ignore' }); + if (res.error || res.status !== 0) { + throw Object.assign(new Error('Claude Code CLI not available'), { code: 'ENOENT' }); + } + } catch (e) { + this.handleError('authentication/CLI check', e); + } }Note: If making this method async is undesirable, perform the check in getClient instead.
63-67: Ensure settings fallback is an objectAvoid passing undefined downstream.
- const settings = getClaudeCodeSettingsForCommand(params.commandName); + const settings = getClaudeCodeSettingsForCommand(params.commandName) || {}; return createClaudeCode({ defaultSettings: settings });
69-78: Brittle CLI-missing detection; handle codes and case-insensitive matchCheck
code === 'ENOENT'and use case-insensitive match; rethrow other errors unchanged.- // Provide more helpful error message - if (error.message.includes('Claude Code') || error.message.includes('claude')) { + // Provide more helpful error message + const msg = String(error?.message || ''); + const code = error?.code; + if (code === 'ENOENT' || /claude/i.test(msg)) { const enhancedError = new Error( `Claude Code CLI not available. Please install Claude Code CLI first. Original error: ${error.message}` ); enhancedError.cause = error; this.handleError('Claude Code CLI initialization', enhancedError); } else { this.handleError('client initialization', error); }
94-96: Normalize model IDs before lookupBe case‑insensitive and guard nullish input.
isModelSupported(modelId) { - return this.supportedModels.includes(modelId); + if (!modelId) return false; + return this.supportedModels.includes(String(modelId).toLowerCase()); }
4-10: Clarify auth docs: no manual env var; CLI OAuth is primaryReplace env-var centric wording with “uses local CLI OAuth; no manual env var required (optional override via CLAUDE_CODE_OAUTH_TOKEN)”.
* Authentication: - * - Uses CLAUDE_CODE_OAUTH_TOKEN managed by Claude Code CLI - * - Token is set up via: claude setup-token - * - No manual API key configuration required + * - Uses local Claude Code CLI OAuth (configured via: `claude setup-token`) + * - No manual API key required; optional override: CLAUDE_CODE_OAUTH_TOKEN
85-87: Return a copy to preserve immutability guaranteesAvoid exposing internal array reference.
getSupportedModels() { - return this.supportedModels; + return [...this.supportedModels]; }
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
src/ai-providers/gemini-cli.js (3)
43-45: Undefined reference: loadGeminiCliModule() will crash at runtimeThis function is not defined or imported. The first await in getClient will throw a ReferenceError, blocking any Gemini usage. Remove it (since you now import the provider directly) or implement a real dynamic loader.
Apply the minimal fix:
- // Load the Gemini CLI module dynamically - await loadGeminiCliModule();
642-649: Export required wrapper functions per provider module contractOur provider modules must export generateText/streamText/generateObject. This file only exports a class. Add thin wrappers to satisfy callers and tests.
export class GeminiCliProvider extends BaseAIProvider { ... } +// Singleton + required function exports +const _geminiCliProvider = new GeminiCliProvider(); + +export async function generateGeminiCliText(params) { + return _geminiCliProvider.generateText(params); +} + +export async function streamGeminiCliText(params) { + return _geminiCliProvider.streamText(params); +} + +export async function generateGeminiCliObject(params) { + return _geminiCliProvider.generateObject(params); +} + +export { _geminiCliProvider as geminiCliProvider };
49-66: Auth options confirmed; remove unsupported baseURL handlingVerified: createGeminiProvider expects authType 'oauth-personal' | 'api-key' (also accepts 'gemini-api-key') and uses apiKey as the option name — those usages are correct. There is no documented baseURL/baseUrl option, so setting authOptions.baseURL will be ignored and can silently misconfigure users. Action: remove the baseURL assignment (or wire it to a supported underlying option and document it). Location: src/ai-providers/gemini-cli.js lines 49–66.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (2)
package.json(2 hunks)src/ai-providers/gemini-cli.js(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
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/gemini-cli.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/gemini-cli.js
package.json
📄 CodeRabbit inference engine (.cursor/rules/test_workflow.mdc)
Add and update test scripts in package.json to include test, test:watch, test:coverage, test:unit, test:integration, test:e2e, and test:ci
Files:
package.json
🧠 Learnings (7)
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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/gemini-cli.jspackage.json
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/ai_providers.mdc:0-0
Timestamp: 2025-07-18T17:06:04.909Z
Learning: Applies to src/ai-providers/*.js : Create a new provider module file in src/ai-providers/ named <provider-name>.js when adding a new AI provider.
Applied to files:
src/ai-providers/gemini-cli.js
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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 export three functions: generate<ProviderName>Text, stream<ProviderName>Text, and generate<ProviderName>Object.
Applied to files:
src/ai-providers/gemini-cli.js
📚 Learning: 2025-07-18T17:07:39.336Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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/gemini-cli.js
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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/gemini-cli.js
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/ai_providers.mdc:0-0
Timestamp: 2025-07-18T17:06:04.909Z
Learning: Applies to tests/unit/ai-providers/*.test.js : Create unit tests for the new provider in tests/unit/ai-providers/<provider-name>.test.js, mocking ai-sdk/<provider-name> and core ai module functions, and testing all exported functions for correct behavior and error handling.
Applied to files:
src/ai-providers/gemini-cli.js
📚 Learning: 2025-08-07T13:00:22.966Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1090
File: apps/extension/package.json:241-243
Timestamp: 2025-08-07T13:00:22.966Z
Learning: In monorepos, local packages should use "*" as the version constraint in package.json dependencies, as recommended by npm. This ensures the local version from within the same workspace is always used, rather than attempting to resolve from external registries. This applies to packages like task-master-ai within the eyaltoledano/claude-task-master monorepo.
Applied to files:
package.json
🔇 Additional comments (2)
package.json (2)
68-71: GA upgrade looks good; resolves prior “avoid beta” feedbackDependencies now use ai@^5.0.48 and ai-sdk-provider-claude-code@^1.1.4 with gemini-cli@^1.1.1. This aligns with the recommended GA migration.
Run a quick scan to ensure no providers still rely on v4-era imports or deprecated paths:
#!/bin/bash set -euo pipefail echo "Scanning for legacy AI SDK imports..." rg -nP -C2 $'from\\s+[\'"]ai(?:\\/|\\-edge|\\-next)' --type=js --type=ts || true rg -nP -C2 $'@vercel/ai' --type=js --type=ts || true rg -nP -C2 $'import\\s+\\{\\s*OpenAI\\s*\\}\\s+from\\s+[\'"]ai' --type=js --type=ts || true
103-105: Optional: confirm optional dependency strategyKeeping @anthropic-ai/claude-code as optional is fine. If the CLI is truly optional at runtime, ensure code paths handle its absence gracefully (clear error with guidance), and docs reflect the optional install.
4deedfc to
2a44e61
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/ai-providers/gemini-cli.js (1)
42-44: Remove unused loadGeminiCliModule call.Line 44 calls
await loadGeminiCliModule();but this function no longer exists since switching to static imports. This will cause a runtime error.async getClient(params) { try { - // Load the Gemini CLI module dynamically - await loadGeminiCliModule(); // Primary use case: Use existing gemini CLI authentication
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (11)
docs/claude-code-integration.md(1 hunks)package.json(3 hunks)scripts/test-claude-code-direct.js(1 hunks)src/ai-providers/base-provider.js(2 hunks)src/ai-providers/claude-code.js(1 hunks)src/ai-providers/gemini-cli.js(4 hunks)src/ai-providers/ollama.js(1 hunks)src/ai-providers/test.ts(1 hunks)tests/integration/claude-code-optional.test.js(1 hunks)tests/unit/ai-providers/claude-code.test.js(3 hunks)tests/unit/ai-providers/openai.test.js(4 hunks)
🧰 Additional context used
📓 Path-based instructions (16)
docs/**/*
📄 CodeRabbit inference engine (.cursor/rules/new_features.mdc)
Add feature documentation to '/docs' folder, include tagged system usage examples, update command reference documentation, and provide migration notes if relevant.
Files:
docs/claude-code-integration.md
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/base-provider.jssrc/ai-providers/claude-code.jssrc/ai-providers/ollama.jssrc/ai-providers/gemini-cli.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/base-provider.jssrc/ai-providers/claude-code.jsscripts/test-claude-code-direct.jssrc/ai-providers/ollama.jstests/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.jssrc/ai-providers/gemini-cli.jstests/unit/ai-providers/openai.test.js
**/?(*.)+(spec|test).ts
📄 CodeRabbit inference engine (.cursor/rules/test_workflow.mdc)
In JavaScript/TypeScript projects using Jest, test files should match *.test.ts and *.spec.ts patterns
Files:
src/ai-providers/test.ts
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/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.jstests/unit/ai-providers/openai.test.js
tests/integration/*.js
📄 CodeRabbit inference engine (.cursor/rules/architecture.mdc)
Integration tests in tests/integration/ should test interactions between modules.
Files:
tests/integration/claude-code-optional.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/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.jstests/unit/ai-providers/openai.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/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.jstests/unit/ai-providers/openai.test.js
tests/integration/**/*.test.js
📄 CodeRabbit inference engine (.cursor/rules/tests.mdc)
Integration tests must be located in tests/integration/, test interactions between modules, and focus on component interfaces rather than implementation details.
Files:
tests/integration/claude-code-optional.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/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.jstests/unit/ai-providers/openai.test.js
tests/{integration,e2e}/**/*.test.js
📄 CodeRabbit inference engine (.cursor/rules/tests.mdc)
Properly mock session objects when required by functions, and reset environment variables between tests if modified.
Files:
tests/integration/claude-code-optional.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/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.jstests/unit/ai-providers/openai.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/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.jstests/unit/ai-providers/openai.test.js
package.json
📄 CodeRabbit inference engine (.cursor/rules/test_workflow.mdc)
Add and update test scripts in package.json to include test, test:watch, test:coverage, test:unit, test:integration, test:e2e, and test:ci
Files:
package.json
tests/unit/ai-providers/*.test.js
📄 CodeRabbit inference engine (.cursor/rules/ai_providers.mdc)
Create unit tests for the new provider in tests/unit/ai-providers/.test.js, mocking @ai-sdk/ and core ai module functions, and testing all exported functions for correct behavior and error handling.
Files:
tests/unit/ai-providers/claude-code.test.jstests/unit/ai-providers/openai.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/ai-providers/claude-code.test.jstests/unit/ai-providers/openai.test.js
🧠 Learnings (46)
📚 Learning: 2025-08-11T12:30:23.843Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-11T12:30:23.843Z
Learning: Import Task Master's development workflow commands and guidelines; treat the contents of ./.taskmaster/CLAUDE.md as if included in the main CLAUDE.md
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-07-18T17:10:53.657Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/glossary.mdc:0-0
Timestamp: 2025-07-18T17:10:53.657Z
Learning: Guidelines for integrating new features into the Task Master CLI with tagged system considerations (new_features.mdc).
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-08-06T21:13:05.240Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1091
File: assets/claude/agents/task-orchestrator.md:69-78
Timestamp: 2025-08-06T21:13:05.240Z
Learning: For Claude agent instruction files in .claude/agents/ and assets/claude/agents/ directories, ignore markdownlint issues (like MD031 blanks-around-fences, MD040 fenced-code-language, MD041 missing top-level heading) as these files follow Claude's specific agent format requirements rather than standard markdown documentation conventions.
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-08-06T21:11:37.259Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1091
File: .claude/agents/task-orchestrator.md:0-0
Timestamp: 2025-08-06T21:11:37.259Z
Learning: For files in .claude/agents/ and assets/claude/agents/ directories, ignore markdownlint issues like MD041 (missing top-level heading) as these are Claude Code agent instruction files that follow a specific format with YAML frontmatter and don't need to conform to standard markdown documentation conventions.
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-09-22T16:42:54.285Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: public/assets/AGENTS.md:0-0
Timestamp: 2025-09-22T16:42:54.285Z
Learning: Applies to public/assets/.claude/settings.json : Define Claude Code tool allowlist in .claude/settings.json including Bash(task-master *), git commands, npm scripts, and mcp__task_master_ai__*
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-07-18T17:10:12.881Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/dev_workflow.mdc:0-0
Timestamp: 2025-07-18T17:10:12.881Z
Learning: For CLI usage, install Taskmaster globally with `npm install -g task-master-ai` or use locally via `npx task-master-ai ...`.
Applied to files:
docs/claude-code-integration.md
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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/base-provider.jssrc/ai-providers/test.tstests/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.jssrc/ai-providers/gemini-cli.js
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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 export three functions: generate<ProviderName>Text, stream<ProviderName>Text, and generate<ProviderName>Object.
Applied to files:
src/ai-providers/base-provider.jssrc/ai-providers/test.tstests/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.jssrc/ai-providers/gemini-cli.js
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/ai_providers.mdc:0-0
Timestamp: 2025-07-18T17:06:04.909Z
Learning: Applies to tests/unit/ai-providers/*.test.js : Create unit tests for the new provider in tests/unit/ai-providers/<provider-name>.test.js, mocking ai-sdk/<provider-name> and core ai module functions, and testing all exported functions for correct behavior and error handling.
Applied to files:
src/ai-providers/test.tsscripts/test-claude-code-direct.jssrc/ai-providers/ollama.jstests/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.jssrc/ai-providers/gemini-cli.js
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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/test.tssrc/ai-providers/claude-code.jsscripts/test-claude-code-direct.jssrc/ai-providers/ollama.jstests/integration/claude-code-optional.test.jspackage.jsontests/unit/ai-providers/claude-code.test.jssrc/ai-providers/gemini-cli.js
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/ai_providers.mdc:0-0
Timestamp: 2025-07-18T17:06:04.909Z
Learning: Applies to src/ai-providers/*.js : Create a new provider module file in src/ai-providers/ named <provider-name>.js when adding a new AI provider.
Applied to files:
src/ai-providers/test.tssrc/ai-providers/ollama.jssrc/ai-providers/gemini-cli.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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/test.tsscripts/test-claude-code-direct.jstests/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : Do not rely on environment variables for API keys in tests; set mock environment variables in test setup.
Applied to files:
src/ai-providers/claude-code.js
📚 Learning: 2025-07-18T17:12:57.903Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/new_features.mdc:0-0
Timestamp: 2025-07-18T17:12:57.903Z
Learning: Applies to scripts/modules/commands.js : Provide clear error messages for common failures, handle tagged system migration errors gracefully, include suggestions for resolution, and exit with appropriate codes for scripting in CLI commands.
Applied to files:
src/ai-providers/claude-code.js
📚 Learning: 2025-07-18T17:08:48.695Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/commands.mdc:0-0
Timestamp: 2025-07-18T17:08:48.695Z
Learning: Applies to scripts/modules/commands.js : Provide specific error handling for common issues, include troubleshooting hints for each error type, and use consistent error formatting across all commands.
Applied to files:
src/ai-providers/claude-code.js
📚 Learning: 2025-07-18T17:07:39.336Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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/claude-code.jssrc/ai-providers/ollama.jstests/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.jssrc/ai-providers/gemini-cli.js
📚 Learning: 2025-07-18T17:12:57.903Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/new_features.mdc:0-0
Timestamp: 2025-07-18T17:12:57.903Z
Learning: Applies to scripts/modules/**/*.test.js : Test CLI and MCP interfaces with real task data, verify end-to-end workflows across tag contexts, and test error scenarios and recovery in integration tests.
Applied to files:
scripts/test-claude-code-direct.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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:
scripts/test-claude-code-direct.jstests/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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:
scripts/test-claude-code-direct.jstests/unit/ai-providers/claude-code.test.js
📚 Learning: 2025-07-18T17:12:57.903Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/new_features.mdc:0-0
Timestamp: 2025-07-18T17:12:57.903Z
Learning: Applies to scripts/modules/*.js : Use structured error objects with code and message properties, include clear error messages, and handle both function-specific and file system errors.
Applied to files:
scripts/test-claude-code-direct.js
📚 Learning: 2025-07-18T17:11:36.732Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/mcp.mdc:0-0
Timestamp: 2025-07-18T17:11:36.732Z
Learning: Applies to mcp-server/src/core/direct-functions/*.js : Wrap core function calls and AI calls in try/catch blocks in direct functions, log errors with appropriate severity and context, and return standardized error objects with code and message.
Applied to files:
scripts/test-claude-code-direct.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : Verify file operations use the correct paths in expect statements.
Applied to files:
scripts/test-claude-code-direct.jstests/unit/ai-providers/claude-code.test.js
📚 Learning: 2025-09-03T13:46:00.640Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1178
File: packages/tm-core/src/auth/oauth-service.ts:20-20
Timestamp: 2025-09-03T13:46:00.640Z
Learning: For Node.js v22 and later, JSON imports should use `with { type: 'json' }` syntax, not `assert { type: 'json' }`. The `assert` syntax was removed in Node.js v22 in favor of the `with` syntax for import attributes. This applies to the eyaltoledano/claude-task-master codebase which uses Node.js v24.
Applied to files:
scripts/test-claude-code-direct.js
📚 Learning: 2025-07-18T17:12:57.903Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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:
scripts/test-claude-code-direct.js
📚 Learning: 2025-08-03T12:13:33.875Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/test_workflow.mdc:0-0
Timestamp: 2025-08-03T12:13:33.875Z
Learning: Applies to {tests/integration/**/*.test.ts,src/**/*.integration.test.ts} : Use supertest for API endpoint testing in integration test files
Applied to files:
scripts/test-claude-code-direct.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : Mock API calls (e.g., Anthropic/Claude) by mocking the entire module and providing predictable responses.
Applied to files:
scripts/test-claude-code-direct.jstests/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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/integration/claude-code-optional.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to 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.
Applied to files:
tests/integration/claude-code-optional.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to tests/{unit,integration,e2e}/**/*.test.js : 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.
Applied to files:
tests/integration/claude-code-optional.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to tests/{unit,integration,e2e}/**/*.test.js : Mock chalk functions to return the input text to make testing easier while still verifying correct function calls.
Applied to files:
tests/integration/claude-code-optional.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to tests/{unit,integration,e2e}/**/*.test.js : Mock the action handlers for CLI commands and verify they're called with correct arguments.
Applied to files:
tests/integration/claude-code-optional.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : Never use asynchronous operations in tests. Make all mocks return synchronous values when possible.
Applied to files:
tests/integration/claude-code-optional.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : Clear mocks between tests with jest.clearAllMocks() in beforeEach.
Applied to files:
tests/integration/claude-code-optional.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : Isolate tests by properly mocking shared resources and resetting state in beforeEach and afterEach hooks.
Applied to files:
tests/integration/claude-code-optional.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : Be careful with how you mock or stub functions that depend on module state; use factory functions in mocks to ensure proper initialization order.
Applied to files:
tests/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : Always declare mocks before importing the modules being tested in Jest test files.
Applied to files:
tests/integration/claude-code-optional.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to tests/{unit,integration,e2e}/**/*.test.js : Mock console output and verify correct formatting in UI function tests. Use flexible assertions like toContain() or toMatch() for formatted output.
Applied to files:
tests/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.js
📚 Learning: 2025-07-18T17:07:39.336Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/architecture.mdc:0-0
Timestamp: 2025-07-18T17:07:39.336Z
Learning: Module dependencies should be mocked before importing the test module, following Jest's hoisting behavior.
Applied to files:
tests/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.js
📚 Learning: 2025-07-18T17:12:57.903Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/new_features.mdc:0-0
Timestamp: 2025-07-18T17:12:57.903Z
Learning: Applies to scripts/modules/**/*.test.js : Follow the mock-first-then-import pattern and use jest.spyOn() for testing in Jest, clearing mocks between tests.
Applied to files:
tests/integration/claude-code-optional.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : For ES modules, use jest.mock() before static imports and jest.unstable_mockModule() before dynamic imports to mock dependencies.
Applied to files:
tests/integration/claude-code-optional.test.jstests/unit/ai-providers/claude-code.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to **/*.test.js : Troubleshoot mock functions not being called by ensuring mocks are defined before imports, referencing the correct mock instance, and verifying import paths.
Applied to files:
tests/integration/claude-code-optional.test.js
📚 Learning: 2025-09-22T19:45:04.246Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1232
File: packages/tm-core/package.json:50-51
Timestamp: 2025-09-22T19:45:04.246Z
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.
Applied to files:
package.json
📚 Learning: 2025-08-07T13:00:22.966Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1090
File: apps/extension/package.json:241-243
Timestamp: 2025-08-07T13:00:22.966Z
Learning: In monorepos, local packages should use "*" as the version constraint in package.json dependencies, as recommended by npm. This ensures the local version from within the same workspace is always used, rather than attempting to resolve from external registries. This applies to packages like task-master-ai within the eyaltoledano/claude-task-master monorepo.
Applied to files:
package.json
📚 Learning: 2025-08-03T12:13:33.875Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/test_workflow.mdc:0-0
Timestamp: 2025-08-03T12:13:33.875Z
Learning: Applies to **/*.test.ts : Use descriptive names for test functions, such as should_return_error_for_invalid_input
Applied to files:
tests/unit/ai-providers/claude-code.test.js
📚 Learning: 2025-07-18T17:07:39.336Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/architecture.mdc:0-0
Timestamp: 2025-07-18T17:07:39.336Z
Learning: Mock external libraries (e.g., fs, commander, anthropic-ai/sdk) at the module level in tests.
Applied to files:
tests/unit/ai-providers/claude-code.test.js
🧬 Code graph analysis (3)
src/ai-providers/claude-code.js (3)
src/ai-providers/base-provider.js (1)
BaseAIProvider(16-352)scripts/modules/config-manager.js (3)
settings(378-378)settings(394-394)modelId(625-625)src/ai-providers/custom-sdk/claude-code/index.js (1)
createClaudeCode(20-65)
scripts/test-claude-code-direct.js (2)
src/ai-providers/custom-sdk/claude-code/index.js (1)
createClaudeCode(20-65)tests/integration/claude-code-optional.test.js (2)
generateText(5-5)streamText(6-6)
tests/integration/claude-code-optional.test.js (1)
src/ai-providers/claude-code.js (1)
ClaudeCodeProvider(25-100)
🪛 markdownlint-cli2 (0.18.1)
docs/claude-code-integration.md
16-16: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
22-22: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
136-136: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
142-142: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
148-148: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
165-165: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
219-219: Files should end with a single newline character
(MD047, single-trailing-newline)
🔇 Additional comments (24)
src/ai-providers/ollama.js (1)
3-3: Update provider package reference is consistent.The changes from
ollama-ai-providertoollama-ai-provider-v2are consistent with the package.json dependencies and maintain the same functionality.Also applies to: 6-6
src/ai-providers/base-provider.js (2)
156-156: LGTM: Token parameter standardization for AI SDK v5.The change from
maxTokenstomaxOutputTokensfor non-GPT-5 models aligns with AI SDK v5 conventions and is consistent across the codebase. GPT-5 models correctly still usemax_completion_tokens.
251-251: Direct parameter usage is correct for streamObject.Using
maxOutputTokens: params.maxTokensdirectly instreamObjectis appropriate since this method doesn't use theprepareTokenParamhelper.src/ai-providers/gemini-cli.js (2)
430-430: LGTM: Token parameter updates align with AI SDK v5.The changes from
maxTokenstomaxOutputTokensin the generateText, streamText, and generateObject methods are consistent with the broader AI SDK v5 migration and base provider updates.Also applies to: 534-534, 593-593
12-12: Static import contradicts coding guidelines.The coding guidelines recommend dynamic imports to avoid initialization order issues and make providers load only when needed.
package.json (2)
55-72: Verify upgraded dependencies are compatible.The major version bumps across multiple AI SDK packages (from v1-2 to v2-3) indicate significant changes. Ensure all providers are tested with these new versions.
Based on the search results, AI SDK v5 includes breaking changes that remove deprecated APIs and requires updating multiple packages to specific versions. The search confirms that:
- If you encounter TypeScript performance issues after upgrading, ensure you're using Zod 4.1.8 or later - This aligns with the package.json upgrade to zod ^4.1.11
- They've made the migration process easier with automated migration tools and codemods
- The providerMetadata input parameter has been renamed to providerOptions
The package versions look correct based on the migration guide references.
97-97: LGTM: Ollama and Zod version upgrades align with ecosystem.The ollama-ai-provider-v2 ^1.3.1 and zod ^4.1.11 upgrades are consistent with broader ecosystem updates and should provide better compatibility.
Also applies to: 100-100
tests/unit/ai-providers/openai.test.js (1)
58-61: Test expectations correctly updated for maxOutputTokens.The changes from
maxTokenstomaxOutputTokensin test expectations for non-GPT-5 models are consistent with the base provider changes and properly reflect the new AI SDK v5 token parameter naming conventions.Also applies to: 69-70, 80-81, 100-100
src/ai-providers/claude-code.js (5)
85-99: LGTM: New public API methods are well-implemented.The
getSupportedModels()andisModelSupported()methods provide clean access to model capabilities and support proper model validation.
8-10: Environment variable name inconsistency with documentation.The class returns
'CLAUDE_CODE_API_KEY'but the documentation mentionsCLAUDE_CODE_OAUTH_TOKEN. This mismatch could confuse users.Also applies to: 35-37
29-29: Consider freezing supportedModels array.The mutable array could be accidentally modified, affecting model validation.
63-63: Add null safety for settings parameter.Ensure the function returns an object even if undefined/null.
- const settings = getClaudeCodeSettingsForCommand(params.commandName); + const settings = getClaudeCodeSettingsForCommand(params.commandName) || {};
97-99: Add input validation to isModelSupported.The method should handle edge cases like null/undefined modelId values.
isModelSupported(modelId) { + if (!modelId || typeof modelId !== 'string') return false; return this.supportedModels.includes(modelId); }scripts/test-claude-code-direct.js (3)
13-57: LGTM: Comprehensive integration testing approach.The script provides excellent coverage by testing both
generateTextandstreamTextfunctionality with proper logging and usage tracking. The test structure is clear and provides good debugging information.
58-71: Error handling improvements needed.The error handling assumes
erroris always an Error object and the CLI detection check could be more robust.
75-77: Make ESM "run directly" check cross-platform.The current string comparison approach is fragile on Windows and with encoded paths.
docs/claude-code-integration.md (1)
1-219: Fix markdown formatting issues and add missing migration section.The documentation needs formatting fixes per static analysis and should include migration guidance for the v5 upgrade.
Apply these fixes for markdown compliance:
1. **Install Claude Code CLI** (if not already installed): + ```bash # Installation method depends on your system # Follow Claude Code documentation for installation ``` + 2. **Set up OAuth token** using Claude Code CLI: + ```bash claude setup-token ``` +Also add a migration section after line 175:
## Integration with AI SDK +## Migration from AI SDK v4.x + +When upgrading to AI SDK v5 with Claude Code: + +- **Token parameters**: Use `maxOutputTokens` instead of `maxTokens` for most models +- **Provider imports**: Update to use `ai-sdk-provider-claude-code` package +- **Error handling**: Enhanced error shapes and better CLI detection +- **TypeScript**: Improved type safety with stricter schema validation + Task Master's Claude Code integration uses the official `ai-sdk-provider-claude-code` package, providing:And add final newline to end the file properly.
tests/unit/ai-providers/claude-code.test.js (2)
96-108: Model support tests look goodGood coverage for getSupportedModels/isModelSupported.
110-123: Don’t assert exact error textUse regex/substring to reduce brittleness.
- expect(() => errorProvider.getClient({})).toThrow( - 'Mock initialization error' - ); + expect(() => errorProvider.getClient({})).toThrow(/initialization error/i);tests/integration/claude-code-optional.test.js (5)
8-17: beforeAll doesn’t need to be asyncNo awaits here; make it sync.
- beforeAll(async () => { + beforeAll(() => { // Mock AI SDK functions generateText = jest.fn(); streamText = jest.fn(); jest.unstable_mockModule('ai', () => ({ generateText, streamText })); });
23-37: Reset module registry before re-import when changing mocksEnsure new mock of ai-sdk-provider-claude-code takes effect.
const { ClaudeCodeProvider } = await import( '../../src/ai-providers/claude-code.js' ); + // Reset module cache so the above mock is applied to fresh imports + jest.resetModules(); + const { ClaudeCodeProvider: FreshClaudeCodeProvider } = await import( + '../../src/ai-providers/claude-code.js' + ); - const provider = new ClaudeCodeProvider(); + const provider = new FreshClaudeCodeProvider();Alternatively, call
jest.resetModules()before the first import:+ jest.resetModules(); const { ClaudeCodeProvider } = await import( '../../src/ai-providers/claude-code.js' );
40-54: Call jest.resetModules() before each different mock setupPrevents stale cached imports across scenarios.
beforeEach(async () => { + jest.resetModules(); // Mock successful provider creation const mockProvider = jest.fn((modelId) => ({ id: modelId, doGenerate: jest.fn(), doStream: jest.fn() }));
62-82: Make generateText test fully synchronousReturn sync values from mocks; remove async/await.
- it('should integrate with AI SDK generateText', async () => { + it('should integrate with AI SDK generateText', () => { const provider = new ClaudeCodeProvider(); const client = provider.getClient(); // Mock successful generation - generateText.mockResolvedValueOnce({ + generateText.mockReturnValueOnce({ text: 'Hello from Claude Code!', usage: { totalTokens: 10 } }); - const result = await generateText({ + const result = generateText({ model: client('sonnet'), messages: [{ role: 'user', content: 'Hello' }] });
84-108: Make streamText test fully synchronousAvoid async generator and resolved Promise. Use sync iterable and direct return.
- it('should integrate with AI SDK streamText', async () => { + it('should integrate with AI SDK streamText', () => { const provider = new ClaudeCodeProvider(); const client = provider.getClient(); // Mock successful streaming - const mockStream = { - textStream: (async function* () { - yield 'Hello '; - yield 'from '; - yield 'Claude Code!'; - })() - }; - streamText.mockResolvedValueOnce(mockStream); + const mockStream = { + textStream: (function* () { + yield 'Hello '; + yield 'from '; + yield 'Claude Code!'; + })() + }; + streamText.mockReturnValueOnce(mockStream); - const result = await streamText({ + const result = streamText({ model: client('sonnet'), messages: [{ role: 'user', content: 'Hello' }] });
| const result = await streamObject({ | ||
| model: openai('gpt-4o-mini'), | ||
| prompt: 'What is the capital of France?', | ||
| schema: z.object({ | ||
| capital: z.string() | ||
| }), | ||
| maxOutputTokens: 100, | ||
| }); |
There was a problem hiding this comment.
Handle the streaming result properly.
The current implementation doesn't properly consume the streaming result. The streamObject function returns a stream that needs to be consumed to get the actual data.
Apply this diff to properly handle the streaming result:
-const result = await streamObject({
- model: openai('gpt-4o-mini'),
- prompt: 'What is the capital of France?',
- schema: z.object({
- capital: z.string()
- }),
- maxOutputTokens: 100,
-});
-
-console.log(result);
+const { partialObjectStream } = await streamObject({
+ model: openai('gpt-4o-mini'),
+ prompt: 'What is the capital of France?',
+ schema: z.object({
+ capital: z.string()
+ }),
+ maxOutputTokens: 100,
+});
+
+for await (const partialObject of partialObjectStream) {
+ console.log(partialObject);
+}Or if you want the final result:
-const result = await streamObject({
+const { object } = await streamObject({
model: openai('gpt-4o-mini'),
prompt: 'What is the capital of France?',
schema: z.object({
capital: z.string()
}),
maxOutputTokens: 100,
});
-console.log(result);
+console.log(await object);🤖 Prompt for AI Agents
In src/ai-providers/test.ts around lines 5 to 12, the code assigns the result of
streamObject directly to `result` but streamObject returns a
stream/async-iterable that must be consumed; change the code to await and
iterate the stream (e.g., use a for-await loop or the library’s helper to
collect the stream into a final object), accumulate/parse the streamed chunks
into the schema-defined object, await completion before using the final data,
and add basic error handling so the stream is properly closed and exceptions are
handled.
| doGenerate: jest.fn(async () => ({ text: 'ok', usage: {} })), | ||
| doStream: jest.fn(async () => ({ stream: true })) | ||
| }); |
There was a problem hiding this comment.
🧹 Nitpick
Make mocked methods synchronous per test guidelines
Avoid async in unit test mocks. Return sync values.
- doGenerate: jest.fn(async () => ({ text: 'ok', usage: {} })),
- doStream: jest.fn(async () => ({ stream: true }))
+ doGenerate: jest.fn(() => ({ text: 'ok', usage: {} })),
+ doStream: jest.fn(() => ({ stream: true }))📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| doGenerate: jest.fn(async () => ({ text: 'ok', usage: {} })), | |
| doStream: jest.fn(async () => ({ stream: true })) | |
| }); | |
| doGenerate: jest.fn(() => ({ text: 'ok', usage: {} })), | |
| doStream: jest.fn(() => ({ stream: true })) | |
| }); |
🤖 Prompt for AI Agents
In tests/unit/ai-providers/claude-code.test.js around lines 10 to 12, the mocked
methods use async arrow functions which return Promises; update them to be
synchronous per test guidelines by removing the async keyword and returning the
plain objects directly (e.g., change jest.fn(async () => ({ ... })) to
jest.fn(() => ({ ... }))). Ensure both doGenerate and doStream return their
objects synchronously.
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
tests/unit/ai-providers/openai.test.js (1)
12-19: Mock external AI SDKs to keep unit tests isolatedEven if not exercised here, import-time side effects can leak. Mock @ai-sdk/openai and ai before importing the provider.
Apply this diff at the top (before imports):
+jest.mock('@ai-sdk/openai', () => ({ + createOpenAI: jest.fn(() => (modelId) => ({ modelId })) +})); +jest.mock('ai', () => ({ + generateText: jest.fn(), + streamText: jest.fn(), + generateObject: jest.fn() +}));src/ai-providers/base-provider.js (3)
133-144: Docs mismatch: update return description for token paramJSDoc still references “either maxTokens or max_completion_tokens”. It now always returns { maxOutputTokens }.
- * @returns {object} Object with either maxTokens or max_completion_tokens + * @returns {object} Object with maxOutputTokens
231-239: Inconsistent token handling in streamObject; use prepareTokenParamDirectly passing params.maxTokens skips validation/rounding and diverges from other methods.
- mode: params.mode || 'auto', - maxOutputTokens: params.maxTokens, + mode: params.mode || 'auto', + ...this.prepareTokenParam(params.modelId, params.maxTokens), temperature: params.temperature
93-101: Preserve original error via causeRe-throw with the original error as cause for better debuggability.
- throw new Error( - `${this.name} API error during ${operation}: ${errorMessage}` - ); + throw new Error(`${this.name} API error during ${operation}: ${errorMessage}`, { cause: error });
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (7)
.changeset/flat-cities-say.md(1 hunks)apps/docs/docs.json(1 hunks)apps/docs/getting-started/api-keys.mdx(1 hunks)package.json(3 hunks)src/ai-providers/base-provider.js(2 hunks)src/ai-providers/openai.js(0 hunks)tests/unit/ai-providers/openai.test.js(1 hunks)
💤 Files with no reviewable changes (1)
- src/ai-providers/openai.js
🧰 Additional context used
📓 Path-based instructions (13)
package.json
📄 CodeRabbit inference engine (.cursor/rules/test_workflow.mdc)
Add and update test scripts in package.json to include test, test:watch, test:coverage, test:unit, test:integration, test:e2e, and test:ci
Files:
package.json
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/base-provider.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/base-provider.jstests/unit/ai-providers/openai.test.js
.changeset/*.md
📄 CodeRabbit inference engine (.cursor/rules/changeset.mdc)
.changeset/*.md: When runningnpm run changesetornpx changeset add, provide a concise summary of the changes for theCHANGELOG.mdin imperative mood, typically a single line, and not a detailed Git commit message.
The changeset summary should be user-facing, describing what changed in the released version that is relevant to users or consumers of the package.
Do not use your detailed Git commit message body as the changeset summary.
Files:
.changeset/flat-cities-say.md
.changeset/*
📄 CodeRabbit inference engine (.cursor/rules/new_features.mdc)
Create appropriate changesets for new features, use semantic versioning, include tagged system information in release notes, and document breaking changes if any.
Files:
.changeset/flat-cities-say.md
tests/unit/ai-providers/*.test.js
📄 CodeRabbit inference engine (.cursor/rules/ai_providers.mdc)
Create unit tests for the new provider in tests/unit/ai-providers/.test.js, mocking @ai-sdk/ and core ai module functions, and testing all exported functions for correct behavior and error handling.
Files:
tests/unit/ai-providers/openai.test.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/ai-providers/openai.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/ai-providers/openai.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/ai-providers/openai.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/ai-providers/openai.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/ai-providers/openai.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/ai-providers/openai.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/ai-providers/openai.test.js
🧠 Learnings (19)
📚 Learning: 2025-09-22T19:45:04.246Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1232
File: packages/tm-core/package.json:50-51
Timestamp: 2025-09-22T19:45:04.246Z
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.
Applied to files:
package.json
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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:
package.json
📚 Learning: 2025-08-07T13:00:22.966Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1090
File: apps/extension/package.json:241-243
Timestamp: 2025-08-07T13:00:22.966Z
Learning: In monorepos, local packages should use "*" as the version constraint in package.json dependencies, as recommended by npm. This ensures the local version from within the same workspace is always used, rather than attempting to resolve from external registries. This applies to packages like task-master-ai within the eyaltoledano/claude-task-master monorepo.
Applied to files:
package.json
📚 Learning: 2025-07-18T17:06:57.833Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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/base-provider.js
📚 Learning: 2025-07-18T17:18:17.759Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/utilities.mdc:0-0
Timestamp: 2025-07-18T17:18:17.759Z
Learning: Applies to scripts/modules/task-manager/**/*.js : Do not call AI-specific getters (like `getMainModelId`, `getMainMaxTokens`) from core logic functions in `scripts/modules/task-manager/*`; instead, pass the `role` to the unified AI service.
Applied to files:
src/ai-providers/base-provider.js
📚 Learning: 2025-07-18T17:18:17.759Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/utilities.mdc:0-0
Timestamp: 2025-07-18T17:18:17.759Z
Learning: Applies to .taskmasterconfig : Do not store API keys in `.taskmasterconfig`.
Applied to files:
.changeset/flat-cities-say.mdapps/docs/getting-started/api-keys.mdx
📚 Learning: 2025-09-24T15:12:58.821Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: assets/AGENTS.md:0-0
Timestamp: 2025-09-24T15:12:58.821Z
Learning: Applies to assets/**/.mcp.json : Configure the Task Master MCP server in .mcp.json under mcpServers.task-master-ai using npx task-master-ai and provide required API key env vars
Applied to files:
.changeset/flat-cities-say.mdapps/docs/getting-started/api-keys.mdx
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/ai_providers.mdc:0-0
Timestamp: 2025-07-18T17:06:04.909Z
Learning: Applies to tests/unit/ai-providers/*.test.js : Create unit tests for the new provider in tests/unit/ai-providers/<provider-name>.test.js, mocking ai-sdk/<provider-name> and core ai module functions, and testing all exported functions for correct behavior and error handling.
Applied to files:
tests/unit/ai-providers/openai.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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:
tests/unit/ai-providers/openai.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#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:
tests/unit/ai-providers/openai.test.js
📚 Learning: 2025-07-18T17:16:13.793Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tests.mdc:0-0
Timestamp: 2025-07-18T17:16:13.793Z
Learning: Applies to tests/{unit,integration,e2e}/**/*.test.js : 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.
Applied to files:
tests/unit/ai-providers/openai.test.js
📚 Learning: 2025-07-31T22:08:16.039Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/taskmaster.mdc:0-0
Timestamp: 2025-07-31T22:08:16.039Z
Learning: Applies to {.env,.cursor/mcp.json} : Set API keys for AI providers (e.g., ANTHROPIC_API_KEY, OPENAI_API_KEY, etc.) in your .env file in the project root (for CLI use) or within the env section of your .cursor/mcp.json file (for MCP/Cursor integration).
Applied to files:
apps/docs/getting-started/api-keys.mdx
📚 Learning: 2025-09-24T15:12:58.821Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: assets/AGENTS.md:0-0
Timestamp: 2025-09-24T15:12:58.821Z
Learning: Applies to assets/**/.env : Store provider API keys in .env for CLI usage; ensure at least one provider key (e.g., ANTHROPIC_API_KEY, PERPLEXITY_API_KEY, OPENAI_API_KEY, etc.) is set; research mode requires PERPLEXITY_API_KEY
Applied to files:
apps/docs/getting-started/api-keys.mdx
📚 Learning: 2025-07-18T17:10:12.881Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/dev_workflow.mdc:0-0
Timestamp: 2025-07-18T17:10:12.881Z
Learning: Applies to .taskmaster/config.json : Store Taskmaster configuration settings (AI model selections, parameters, logging level, default subtasks/priority, project name, etc.) in the `.taskmaster/config.json` file located in the project root directory. Do not configure non-API key settings via environment variables.
Applied to files:
apps/docs/getting-started/api-keys.mdx
📚 Learning: 2025-07-18T17:10:02.683Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/dev_workflow.mdc:0-0
Timestamp: 2025-07-18T17:10:02.683Z
Learning: Applies to {.env,.cursor/mcp.json} : Store sensitive API keys and endpoint URLs for Taskmaster in a `.env` file (for CLI usage) or in the `env` section of `.cursor/mcp.json` (for MCP/Cursor integration). Do not store non-API key settings in these files.
Applied to files:
apps/docs/getting-started/api-keys.mdx
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/ai_providers.mdc:0-0
Timestamp: 2025-07-18T17:06:04.909Z
Learning: Applies to .cursor/mcp.json.example : Add the new PROVIDER_API_KEY with its placeholder to the env section for taskmaster-ai in .cursor/mcp.json.example.
Applied to files:
apps/docs/getting-started/api-keys.mdx
📚 Learning: 2025-07-18T17:06:57.833Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/ai_services.mdc:0-0
Timestamp: 2025-07-18T17:06:57.833Z
Learning: Ensure API keys are correctly configured in `.env` (for CLI) or `.cursor/mcp.json` (for MCP).
Applied to files:
apps/docs/getting-started/api-keys.mdx
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/ai_providers.mdc:0-0
Timestamp: 2025-07-18T17:06:04.909Z
Learning: If AI commands fail, verify the API key for the selected provider, check the model ID, provider status, and restart MCP if necessary.
Applied to files:
apps/docs/getting-started/api-keys.mdx
📚 Learning: 2025-07-18T17:06:04.909Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/ai_providers.mdc:0-0
Timestamp: 2025-07-18T17:06:04.909Z
Learning: API keys for providers must be set in the correct location: in the env section of .cursor/mcp.json for MCP/Cursor, or in a .env file in the project root for CLI.
Applied to files:
apps/docs/getting-started/api-keys.mdx
🪛 markdownlint-cli2 (0.18.1)
.changeset/flat-cities-say.md
5-5: First line in a file should be a top-level heading
(MD041, first-line-heading, first-line-h1)
🔇 Additional comments (6)
tests/unit/ai-providers/openai.test.js (2)
2-8: Test scope description update looks fineThe narrowed scope to generic maxTokens and client/model handling aligns with unified token handling.
88-92: Verify failure mode for missing API key is reliableDepending on OpenAIProvider.getClient implementation, the error may only surface on generate/stream calls, not on getClient(). If getClient() no-ops validation, assert on generateText with missing key instead.
Would you confirm getClient() throws without an apiKey? If not, adjust the test to invoke a generate method to assert the error.
src/ai-providers/base-provider.js (1)
143-143: Unified to maxOutputTokens — goodReturning { maxOutputTokens } aligns with AI SDK v5.
package.json (2)
54-101: GA AI SDK and provider deps look alignedai ^5.0.51 and ai-sdk-provider-claude-code ^1.1.4 resolve the earlier beta concerns.
100-101: Confirm Zod v4 compatibility with Vercel AI SDK v5 (zodSchema)Vercel AI SDK v5 supports Zod v4 schemas (including "mini" schemas) via zodSchema or passing Zod objects, but there are known ecosystem issues (notably zod-to-json-schema / transitive deps) that can cause build-time errors — pin/align the zod version in package.json (currently "zod": "^4.1.11" at lines 100–101), update the lockfile, and run CI/tests across providers; monitor SDK/GitHub fixes if failures occur.
apps/docs/docs.json (1)
35-36: Docs nav entry LGTM“getting-started/api-keys” is correctly placed under Getting Started.
| --- | ||
| "task-master-ai": minor | ||
| --- | ||
|
|
||
| Added api keys page on docs website: docs.task-master.dev/getting-started/api-keys#security-best-practices |
There was a problem hiding this comment.
🧹 Nitpick
Use imperative mood in changeset summary
Follow the project’s changeset style.
-Added api keys page on docs website: docs.task-master.dev/getting-started/api-keys#security-best-practices
+Add API keys page: docs.task-master.dev/getting-started/api-keys#security-best-practices📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| --- | |
| "task-master-ai": minor | |
| --- | |
| Added api keys page on docs website: docs.task-master.dev/getting-started/api-keys#security-best-practices | |
| --- | |
| "task-master-ai": minor | |
| --- | |
| Add API keys page: docs.task-master.dev/getting-started/api-keys#security-best-practices |
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
5-5: First line in a file should be a top-level heading
(MD041, first-line-heading, first-line-h1)
🤖 Prompt for AI Agents
In .changeset/flat-cities-say.md around lines 1–5, the changeset summary is
written in past tense ("Added api keys page..."); update it to use imperative
present tense and proper capitalization (e.g., "Add API Keys page on docs
website: docs.task-master.dev/getting-started/api-keys#security-best-practices")
so the summary follows the project’s changeset style.
| ### PERPLEXITY_API_KEY (Highly Recommended for Research) | ||
| - **Provider**: Perplexity AI (Research features) | ||
| - **Format**: `pplx-...` | ||
| - **Required**: ✅ **Yes** | ||
| - **Purpose**: Enables research-backed task expansions and updates | ||
| - **Models**: Perplexity Sonar models | ||
| - **Get Key**: [Perplexity API](https://www.perplexity.ai/settings/api) | ||
|
|
||
| ```bash | ||
| PERPLEXITY_API_KEY="pplx-your-key-here" | ||
| ``` | ||
|
|
||
| ### OPENAI_API_KEY | ||
| - **Provider**: OpenAI GPT models | ||
| - **Format**: `sk-proj-...` or `sk-...` | ||
| - **Required**: ✅ **Yes** | ||
| - **Models**: GPT-4, GPT-4 Turbo, GPT-3.5 Turbo, O1 models |
There was a problem hiding this comment.
🧹 Nitpick
Clarify “Required: Yes” labels to avoid confusion
Since only one provider key is strictly required overall, consider “Required to use this provider: Yes” to avoid misreading.
🤖 Prompt for AI Agents
In apps/docs/getting-started/api-keys.mdx around lines 20 to 36, the "Required:
✅ Yes" labels are ambiguous and may imply multiple keys are mandatory; update
the text to clarify that the requirement applies per-provider by changing the
label to "Required to use this provider: ✅ Yes" (or similar wording) for each
provider section and adjust any surrounding explanatory copy to state that only
one provider key is strictly required overall unless a user opts to use multiple
providers.
| ### CLAUDE_CODE_API_KEY | ||
| - **Provider**: Claude Code CLI | ||
| - **Required**: ❌ **No** (uses OAuth tokens) | ||
| - **Purpose**: Integration with local Claude Code CLI | ||
| - **Authentication**: Uses OAuth tokens, no API key needed | ||
|
|
||
| ```bash | ||
| # Not typically needed | ||
| CLAUDE_CODE_API_KEY="not-usually-required" | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Correct Claude Code auth variable; it uses OAuth token, not API key
The integration uses CLAUDE_CODE_OAUTH_TOKEN (with CLI fallback), not CLAUDE_CODE_API_KEY.
-### CLAUDE_CODE_API_KEY
-- **Provider**: Claude Code CLI
-- **Required**: ❌ **No** (uses OAuth tokens)
-- **Purpose**: Integration with local Claude Code CLI
-- **Authentication**: Uses OAuth tokens, no API key needed
-
-```bash
-# Not typically needed
-CLAUDE_CODE_API_KEY="not-usually-required"
-```
+### CLAUDE_CODE_OAUTH_TOKEN
+- **Provider**: Claude Code CLI
+- **Required**: ❌ **No** (OAuth via CLI is preferred)
+- **Purpose**: Integration with local Claude Code CLI
+- **Authentication**: Uses OAuth token; falls back to `claude setup-token` if unset
+
+```bash
+# Optional: set explicitly to bypass interactive CLI setup
+CLAUDE_CODE_OAUTH_TOKEN="your-oauth-token"
+```🤖 Prompt for AI Agents
In apps/docs/getting-started/api-keys.mdx around lines 113 to 123, the
documentation incorrectly references CLAUDE_CODE_API_KEY and implies an API key
is used; update this section to describe CLAUDE_CODE_OAUTH_TOKEN instead, change
the header to "CLAUDE_CODE_OAUTH_TOKEN", update
Provider/Required/Purpose/Authentication to state it uses an OAuth token with
CLI fallback (mention `claude setup-token`), and replace the bash example with
an explicit CLAUDE_CODE_OAUTH_TOKEN="your-oauth-token" line and a short note
that it is optional to bypass interactive CLI setup.
- Update AI SDK from v4.3.16 to v5.0.0-beta.34 - Add ai-sdk-provider-claude-code integration - Replace custom SDK with official ai-sdk-provider-claude-code package - Add OAuth token authentication via Claude Code CLI - Support for 'sonnet' and 'opus' models - Comprehensive integration tests and documentation - Direct integration test script for verification 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Updates @anthropic-ai/claude-code to latest version - Ensures compatibility with latest Claude Code CLI features - Maintains optional dependency status for graceful degradation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
613709d to
1fb10b2
Compare
02806aa
into
eyaltoledano:ralph/ai-sdk.v5.migration
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com>
Summary
This PR integrates Claude Code with AI SDK v5, providing seamless OAuth-based authentication and comprehensive Claude model support for Task Master.
✨ Key Features
🆙 AI SDK v5 Integration
ai-sdk-provider-claude-code@1.0.0-beta.1🔐 OAuth Authentication
claude setup-tokenfor authentication🤖 Model Support
sonnetopus📚 Comprehensive Documentation
claude setup-token🧪 Testing Verified
✅ Unit Tests (11/11 passing)
✅ Integration Tests
generateTextintegrationstreamTextintegration✅ Live Testing
📁 Files Changed
Enhanced
package.json- AI SDK v5 + ai-sdk-provider-claude-code dependenciessrc/ai-providers/claude-code.js- Complete rewrite using official providertests/unit/ai-providers/claude-code.test.js- Updated for new providertests/integration/claude-code-optional.test.js- AI SDK integration testsAdded
docs/claude-code-integration.md- Comprehensive integration guidescripts/test-claude-code-direct.js- Direct integration verification scriptUpdated Dependencies
ai:^4.3.10→^5.0.0-beta.34ai-sdk-provider-claude-code:^1.0.0-beta.1(new)@anthropic-ai/claude-code:^1.0.25→^1.0.72🔧 Technical Details
Provider Architecture
BaseAIProviderwith Claude Code-specific functionalitygetSupportedModels,isModelSupported)Authentication Flow
CLAUDE_CODE_OAUTH_TOKEN(optional)claude setup-token(recommended)AI SDK Integration
generateTextandstreamTextoperations🚀 Production Impact
Benefits
Breaking Changes
🔍 Verification Steps
Install Dependencies:
Setup Authentication (if needed):
Test Integration:
Run Tests:
npm test -- tests/unit/ai-providers/claude-code.test.js📖 Documentation
Complete integration guide available at
docs/claude-code-integration.mdincluding:This PR significantly enhances the Claude Code integration while maintaining complete compatibility and providing a seamless upgrade path.
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com
Summary by CodeRabbit