9 Commits

Author SHA1 Message Date
Eyal Toledano
b47f189cc2 chore: Remove unused imports across modules
Removes unused import statements identified after the major refactoring of the AI service layer and other components. This cleanup improves code clarity and removes unnecessary dependencies.

Unused imports removed from:

- **`mcp-server/src/core/direct-functions/analyze-task-complexity.js`:**

    - Removed `path`

- **`mcp-server/src/core/direct-functions/complexity-report.js`:**

    - Removed `path`

- **`mcp-server/src/core/direct-functions/expand-all-tasks.js`:**

    - Removed `path`, `fs`

- **`mcp-server/src/core/direct-functions/generate-task-files.js`:**

    - Removed `path`

- **`mcp-server/src/core/direct-functions/parse-prd.js`:**

    - Removed `os`, `findTasksJsonPath`

- **`mcp-server/src/core/direct-functions/update-tasks.js`:**

    - Removed `isSilentMode`

- **`mcp-server/src/tools/add-task.js`:**

    - Removed `createContentResponse`, `executeTaskMasterCommand`

- **`mcp-server/src/tools/analyze.js`:**

    - Removed `getProjectRootFromSession` (as `projectRoot` is now required in args)

- **`mcp-server/src/tools/expand-task.js`:**

    - Removed `path`

- **`mcp-server/src/tools/initialize-project.js`:**

    - Removed `createContentResponse`

- **`mcp-server/src/tools/parse-prd.js`:**

    - Removed `findPRDDocumentPath`, `resolveTasksOutputPath` (logic moved or handled by `resolveProjectPaths`)

- **`mcp-server/src/tools/update.js`:**

    - Removed `getProjectRootFromSession` (as `projectRoot` is now required in args)

- **`scripts/modules/commands.js`:**

    - Removed `exec`, `readline`

    - Removed AI config getters (`getMainModelId`, etc.)

    - Removed MCP helpers (`getMcpApiKeyStatus`)

- **`scripts/modules/config-manager.js`:**

    - Removed `ZodError`, `readJSON`, `writeJSON`

- **`scripts/modules/task-manager/analyze-task-complexity.js`:**

    - Removed AI config getters (`getMainModelId`, etc.)

- **`scripts/modules/task-manager/expand-all-tasks.js`:**

    - Removed `fs`, `path`, `writeJSON`

- **`scripts/modules/task-manager/models.js`:**

    - Removed `VALID_PROVIDERS`

- **`scripts/modules/task-manager/update-subtask-by-id.js`:**

    - Removed AI config getters (`getMainModelId`, etc.)

- **`scripts/modules/task-manager/update-tasks.js`:**

    - Removed AI config getters (`getMainModelId`, etc.)

- **`scripts/modules/ui.js`:**

    - Removed `getDebugFlag`

- **`scripts/modules/utils.js`:**

    - Removed `ZodError`
2025-04-25 15:11:55 -04:00
Eyal Toledano
36d559db26 docs: Update documentation for new AI/config architecture and finalize cleanup
This commit updates all relevant documentation (READMEs, docs/*, .cursor/rules) to accurately reflect the finalized unified AI service architecture and the new configuration system (.taskmasterconfig + .env/mcp.json). It also includes the final code cleanup steps related to the refactoring.

Key Changes:

1.  **Documentation Updates:**

    *   Revised `README.md`, `README-task-master.md`, `assets/scripts_README.md`, `docs/configuration.md`, and `docs/tutorial.md` to explain the new configuration split (.taskmasterconfig vs .env/mcp.json).

    *   Updated MCP configuration examples in READMEs and tutorials to only include API keys in the `env` block.

    *   Added/updated examples for using the `--research` flag in `docs/command-reference.md`, `docs/examples.md`, and `docs/tutorial.md`.

    *   Updated `.cursor/rules/ai_services.mdc`, `.cursor/rules/architecture.mdc`, `.cursor/rules/dev_workflow.mdc`, `.cursor/rules/mcp.mdc`, `.cursor/rules/taskmaster.mdc`, `.cursor/rules/utilities.mdc`, and `.cursor/rules/new_features.mdc` to align with the new architecture, removing references to old patterns/files.

    *   Removed internal rule links from user-facing rules (`taskmaster.mdc`, `dev_workflow.mdc`, `self_improve.mdc`).

    *   Deleted outdated example file `docs/ai-client-utils-example.md`.

2.  **Final Code Refactor & Cleanup:**

    *   Corrected `update-task-by-id.js` by removing the last import from the old `ai-services.js`.

    *   Refactored `update-subtask-by-id.js` to correctly use the unified service and logger patterns.

    *   Removed the obsolete export block from `mcp-server/src/core/task-master-core.js`.

    *   Corrected logger implementation in `update-tasks.js` for CLI context.

    *   Updated API key mapping in `config-manager.js` and `ai-services-unified.js`.

3.  **Configuration Files:**

    *   Updated API keys in `.cursor/mcp.json`, replacing `GROK_API_KEY` with `XAI_API_KEY`.

    *   Updated `.env.example` with current API key names.

    *   Added `azureOpenaiBaseUrl` to `.taskmasterconfig` example.

4.  **Task Management:**

    *   Marked documentation subtask 61.10 as 'done'.

    *   Includes various other task content/status updates from the diff summary.

5.  **Changeset:**

    *   Added `.changeset/cuddly-zebras-matter.md` for user-facing `expand`/`expand-all` improvements.

This commit concludes the major architectural refactoring (Task 61) and ensures the documentation accurately reflects the current system.
2025-04-25 14:43:12 -04:00
Eyal Toledano
205a11e82c fix(config): Improve config-manager.js for MCP server integration
- Fixed MCP server initialization warnings by refactoring config-manager.js to handle missing project roots silently during startup

- Added project root tracking (loadedConfigRoot) to improve config caching and prevent unnecessary reloads

- Modified _loadAndValidateConfig to return defaults without warnings when no explicitRoot provided

- Improved getConfig to only update cache when loading config with a specific project root

- Ensured warning messages still appear when explicitly specified roots have missing/invalid configs

- Prevented console output during MCP startup that was causing JSON parsing errors

- Verified parse_prd and other MCP tools still work correctly with the new config loading approach.

- Replaces test perplexity api key in mcp.json and rolls it. It's invalid now.
2025-04-24 13:34:51 -04:00
Eyal Toledano
78a5376796 fix(mcp): prevents the mcp from failing due to the newly introduced ConfigurationError object thrown if .taskmasterconfig is not present. I'll need to implement MCP tools for model to manage models from MCP and be able to create it. 2025-04-22 16:09:33 -04:00
Eyal Toledano
b3b424be93 refactor(ai): Implement unified AI service layer and fix subtask update
- Unified Service: Introduced 'scripts/modules/ai-services-unified.js' to centralize AI interactions using provider modules ('src/ai-providers/') and the Vercel AI SDK.

- Provider Modules: Implemented 'anthropic.js' and 'perplexity.js' wrappers for Vercel SDK.

- 'updateSubtaskById' Fix: Refactored the AI call within 'updateSubtaskById' to use 'generateTextService' from the unified layer, resolving runtime errors related to parameter passing and streaming. This serves as the pattern for refactoring other AI calls in 'scripts/modules/task-manager/'.

- Task Status: Marked Subtask 61.19 as 'done'.

- Rules: Added new 'ai-services.mdc' rule.

This centralizes AI logic, replacing previous direct SDK calls and custom implementations. API keys are resolved via 'resolveEnvVariable' within the service layer. The refactoring of 'updateSubtaskById' establishes the standard approach for migrating other AI-dependent functions in the task manager module to use the unified service.

Relates to Task 61.
2025-04-22 02:42:04 -04:00
Eyal Toledano
515dcae965 refactor(config)!: Enforce .taskmasterconfig and remove env var overrides
BREAKING CHANGE: Taskmaster now requires a `.taskmasterconfig` file for model/parameter settings. Environment variables (except API keys) are no longer used for overrides.

- Throws an error if `.taskmasterconfig` is missing, guiding user to run `task-master models --setup`." -m "- Removed env var checks from config getters in `config-manager.js`." -m "- Updated `env.example` to remove obsolete variables." -m "- Refined missing config file error message in `commands.js`.
2025-04-21 22:25:04 -04:00
Eyal Toledano
538b874582 feat(config): Implement new config system and resolve refactoring errors Introduced config-manager.js and new utilities (resolveEnvVariable, findProjectRoot). Removed old global CONFIG object from utils.js. Updated .taskmasterconfig, mcp.json, and .env.example. Added generateComplexityAnalysisPrompt to ui.js. Removed unused updateSubtaskById from task-manager.js. Resolved SyntaxError and ReferenceError issues across commands.js, ui.js, task-manager.js, and ai-services.js by replacing CONFIG references with config-manager getters (getDebugFlag, getProjectName, getDefaultSubtasks, isApiKeySet). Refactored 'models' command to use getConfig/writeConfig. Simplified version checking. This stabilizes the codebase after initial Task 61 refactoring, fixing CLI errors and enabling subsequent work on Subtasks 61.34 and 61.35. 2025-04-20 01:09:30 -04:00
Eyal Toledano
1ab836f191 feat(config): Add Fallback Model and Expanded Provider Support
Introduces a configurable fallback model and adds support for additional AI provider API keys in the environment setup.

- **Add Fallback Model Configuration (.taskmasterconfig):**
  - Implemented a new  section in .
  - Configured  as the default fallback model, enhancing resilience if the primary model fails.

- **Update Default Model Configuration (.taskmasterconfig):**
  - Changed the default  model to .
  - Changed the default  model to .

- **Add API Key Examples (assets/env.example):**
  - Added example environment variables for:
    -  (for OpenAI/OpenRouter)
    -  (for Google Gemini)
    -  (for XAI Grok)
  - Included format comments for clarity.
2025-04-16 00:45:02 -04:00
Eyal Toledano
d84c2486e4 fix(config): Improve config manager flexibility & test mocks
Refactored `config-manager.js` to handle different execution contexts (CLI vs. MCP) and fixed related Jest tests.

- Modified `readConfig` and `writeConfig` to accept an optional `explicitRoot` parameter, allowing explicit path specification (e.g., from MCP) while retaining automatic project root finding for CLI usage.

- Updated getter/setter functions (`getMainProvider`, `setMainModel`, etc.) to accept and propagate the `explicitRoot`.

- Resolved Jest testing issues for dynamic imports by using `jest.unstable_mockModule` for `fs` and `chalk` dependencies *before* the dynamic `import()`.

- Corrected console error assertions in tests to match exact logged messages.

- Updated `.cursor/rules/tests.mdc` with guidelines for `jest.unstable_mockModule` and precise console assertions.
2025-04-16 00:45:02 -04:00