feat(refactor): Finalize AI service migration and cleanup obsolete files

This commit completes the major refactoring initiative (Task 61) to migrate all AI-interacting task management functions to the unified service layer (`ai-services-unified.js`) and standardized configuration (`config-manager.js`).

Key Changes:

1.  **Refactor `update-task-by-id` & `update-subtask-by-id`:**

    *   Replaced direct AI client logic and config fetching with calls to `generateTextService`.

    *   Preserved original prompt logic while ensuring JSON output format is requested.

    *   Implemented robust manual JSON parsing and Zod validation for text-based AI responses.

    *   Corrected logger implementation (`logFn`/`isMCP`/`report` pattern) for both CLI and MCP contexts.

    *   Ensured correct passing of `session` context to the unified service.

    *   Refactored associated direct function wrappers (`updateTaskByIdDirect`, `updateSubtaskByIdDirect`) to remove AI client initialization and call core logic appropriately.

2.  **CLI Environment Loading:**

    *   Added `dotenv.config()` to `scripts/dev.js` to ensure consistent loading of the `.env` file for CLI operations.

3.  **Obsolete Code Removal:**

    *   Deleted unused helper files:

        *   `scripts/modules/task-manager/get-subtasks-from-ai.js`

        *   `scripts/modules/task-manager/generate-subtask-prompt.js`

        *   `scripts/modules/ai-services.js`

        *   `scripts/modules/ai-client-factory.js`

        *   `mcp-server/src/core/utils/ai-client-utils.js`

    *   Removed corresponding imports/exports from `scripts/modules/task-manager.js` and `mcp-server/src/core/task-master-core.js`.

4.  **Verification:**

    *   Successfully tested `update-task` and `update-subtask` via both CLI and MCP after refactoring.

5.  **Task Management:**

    *   Marked subtasks 61.38, 61.39, 61.40, 61.41, and 61.33 as 'done'.

    *   Includes other task content/status updates as reflected in the diff.

This completes the migration of core AI features to the new architecture, enhancing maintainability and flexibility.
This commit is contained in:
Eyal Toledano
2025-04-25 13:24:15 -04:00
parent 3721359782
commit afb47584bd
17 changed files with 496 additions and 6375 deletions

View File

@@ -1,6 +1,6 @@
# Task ID: 59
# Title: Remove Manual Package.json Modifications and Implement Automatic Dependency Management
# Status: pending
# Status: done
# Dependencies: None
# Priority: medium
# Description: Eliminate code that manually modifies users' package.json files and implement proper npm dependency management that automatically handles package requirements when users install task-master-ai.
@@ -30,37 +30,37 @@ This change will make the package more reliable, follow npm best practices, and
9. Create an integration test that simulates a real user workflow from installation through usage
# Subtasks:
## 1. Conduct Code Audit for Dependency Management [pending]
## 1. Conduct Code Audit for Dependency Management [done]
### Dependencies: None
### Description: Review the current codebase to identify all areas where dependencies are manually managed, modified, or referenced outside of npm best practices.
### Details:
Focus on scripts, configuration files, and any custom logic related to dependency installation or versioning.
## 2. Remove Manual Dependency Modifications [pending]
## 2. Remove Manual Dependency Modifications [done]
### Dependencies: 59.1
### Description: Eliminate any custom scripts or manual steps that alter dependencies outside of npm's standard workflow.
### Details:
Refactor or delete code that manually installs, updates, or modifies dependencies, ensuring all dependency management is handled via npm.
## 3. Update npm Dependencies [pending]
## 3. Update npm Dependencies [done]
### Dependencies: 59.2
### Description: Update all project dependencies using npm, ensuring versions are current and compatible, and resolve any conflicts.
### Details:
Run npm update, audit for vulnerabilities, and adjust package.json and package-lock.json as needed.
## 4. Update Initialization and Installation Commands [pending]
## 4. Update Initialization and Installation Commands [done]
### Dependencies: 59.3
### Description: Revise project setup scripts and documentation to reflect the new npm-based dependency management approach.
### Details:
Ensure that all initialization commands (e.g., npm install) are up-to-date and remove references to deprecated manual steps.
## 5. Update Documentation [pending]
## 5. Update Documentation [done]
### Dependencies: 59.4
### Description: Revise project documentation to describe the new dependency management process and provide clear setup instructions.
### Details:
Update README, onboarding guides, and any developer documentation to align with npm best practices.
## 6. Perform Regression Testing [pending]
## 6. Perform Regression Testing [done]
### Dependencies: 59.5
### Description: Run comprehensive tests to ensure that the refactor has not introduced any regressions or broken existing functionality.
### Details: