feat(analyze): add task ID filtering to analyze-complexity command
Enhance analyze-complexity to support analyzing specific tasks by ID or range: - Add --id option for comma-separated task IDs - Add --from/--to options for analyzing tasks within a range - Implement intelligent merging with existing reports - Update CLI, MCP tools, and direct functions for consistent support - Add changeset documenting the feature
This commit is contained in:
@@ -3,79 +3,91 @@
|
||||
# Status: pending
|
||||
# Dependencies: None
|
||||
# Priority: medium
|
||||
# Description: Modify the analyze-complexity feature (CLI and MCP) to allow analyzing only specified task IDs and append/update results in the report.
|
||||
# Description: Modify the analyze-complexity feature (CLI and MCP) to allow analyzing only specified task IDs or ranges, and append/update results in the report.
|
||||
# Details:
|
||||
|
||||
Implementation Plan:
|
||||
|
||||
1. **Core Logic (`scripts/modules/task-manager/analyze-task-complexity.js`):**
|
||||
* Modify the function signature to accept an optional `options.ids` parameter (string, comma-separated IDs).
|
||||
* If `options.ids` is present:
|
||||
* Parse the `ids` string into an array of target IDs.
|
||||
* Filter `tasksData.tasks` to *only* include tasks matching the target IDs. Use this filtered list for analysis.
|
||||
* Handle cases where provided IDs don't exist in `tasks.json`.
|
||||
* If `options.ids` is *not* present: Continue with existing logic (filtering by active status).
|
||||
* **Report Handling:**
|
||||
* Before generating the analysis, check if the `outputPath` report file exists.
|
||||
* If it exists, read the existing `complexityAnalysis` array.
|
||||
* Generate the new analysis *only* for the target tasks (filtered by ID or status).
|
||||
* Merge the results: Remove any entries from the *existing* array that match the IDs analyzed in the *current run*. Then, append the *new* analysis results to the array.
|
||||
* Update the `meta` section (`generatedAt`, `tasksAnalyzed` should reflect *this run*).
|
||||
* Write the *merged* `complexityAnalysis` array and updated `meta` back to the report file.
|
||||
* If the report file doesn't exist, create it as usual.
|
||||
* **Prompt Generation:** Ensure `generateInternalComplexityAnalysisPrompt` receives the correctly filtered list of tasks.
|
||||
1. **Core Logic (`scripts/modules/task-manager/analyze-task-complexity.js`)**
|
||||
* Modify function signature to accept optional parameters: `options.ids` (string, comma-separated IDs) and range parameters `options.from` and `options.to`.
|
||||
* If `options.ids` is present:
|
||||
* Parse the `ids` string into an array of target IDs.
|
||||
* Filter `tasksData.tasks` to include only tasks matching the target IDs.
|
||||
* Handle cases where provided IDs don't exist in `tasks.json`.
|
||||
* If range parameters (`options.from` and `options.to`) are present:
|
||||
* Parse these values into integers.
|
||||
* Filter tasks within the specified ID range (inclusive).
|
||||
* If neither `options.ids` nor range parameters are present: Continue with existing logic (filtering by active status).
|
||||
* Maintain existing logic for skipping completed tasks.
|
||||
* **Report Handling:**
|
||||
* Before generating analysis, check if the `outputPath` report file exists.
|
||||
* If it exists:
|
||||
* Read the existing `complexityAnalysis` array.
|
||||
* Generate new analysis only for target tasks (filtered by ID or range).
|
||||
* Merge results: Remove entries from the existing array that match IDs analyzed in the current run, then append new analysis results to the array.
|
||||
* Update the `meta` section (`generatedAt`, `tasksAnalyzed`).
|
||||
* Write merged `complexityAnalysis` and updated `meta` back to report file.
|
||||
* If the report file doesn't exist: Create it as usual.
|
||||
* **Prompt Generation:** Ensure `generateInternalComplexityAnalysisPrompt` receives correctly filtered list of tasks.
|
||||
|
||||
2. **CLI (`scripts/modules/commands.js`):**
|
||||
* Add a new option `--id <ids>` to the `analyze-complexity` command definition. Description: "Comma-separated list of specific task IDs to analyze".
|
||||
* In the `.action` handler:
|
||||
* Check if `options.id` is provided.
|
||||
* If yes, pass `options.id` (as the comma-separated string) to the `analyzeTaskComplexity` core function via the `options` object.
|
||||
* Update user feedback messages to indicate specific task analysis.
|
||||
2. **CLI (`scripts/modules/commands.js`)**
|
||||
* Add new options to the `analyze-complexity` command:
|
||||
* `--id/-i <ids>`: "Comma-separated list of specific task IDs to analyze"
|
||||
* `--from/-f <startId>`: "Start ID for range analysis (inclusive)"
|
||||
* `--to/-t <endId>`: "End ID for range analysis (inclusive)"
|
||||
* In the `.action` handler:
|
||||
* Check if `options.id`, `options.from`, or `options.to` are provided.
|
||||
* If yes, pass appropriate values to the `analyzeTaskComplexity` core function via the `options` object.
|
||||
* Update user feedback messages to indicate specific task analysis.
|
||||
|
||||
3. **MCP Tool (`mcp-server/src/tools/analyze.js`):**
|
||||
* Add a new optional parameter `ids: z.string().optional().describe("Comma-separated list of task IDs to analyze specifically")` to the Zod schema for the `analyze_project_complexity` tool.
|
||||
* In the `execute` method, pass `args.ids` to the `analyzeTaskComplexityDirect` function within its `args` object.
|
||||
3. **MCP Tool (`mcp-server/src/tools/analyze.js`)**
|
||||
* Add new optional parameters to Zod schema for `analyze_project_complexity` tool:
|
||||
* `ids: z.string().optional().describe("Comma-separated list of task IDs to analyze specifically")`
|
||||
* `from: z.number().optional().describe("Start ID for range analysis (inclusive)")`
|
||||
* `to: z.number().optional().describe("End ID for range analysis (inclusive)")`
|
||||
* In the `execute` method, pass `args.ids`, `args.from`, and `args.to` to the `analyzeTaskComplexityDirect` function within its `args` object.
|
||||
|
||||
4. **Direct Function (`mcp-server/src/core/direct-functions/analyze-task-complexity.js`):**
|
||||
* Update the function to receive the `ids` string within the `args` object.
|
||||
* Pass the `ids` string along to the core `analyzeTaskComplexity` function within its `options` object.
|
||||
|
||||
5. **Documentation:** Update relevant rule files (`commands.mdc`, `taskmaster.mdc`) to reflect the new `--id` option/parameter.
|
||||
4. **Direct Function (`mcp-server/src/core/direct-functions/analyze-task-complexity.js`)**
|
||||
* Update function to receive `ids`, `from`, and `to` values within the `args` object.
|
||||
* Pass these values along to the core `analyzeTaskComplexity` function within its `options` object.
|
||||
|
||||
5. **Documentation:** Update relevant rule files (`commands.mdc`, `taskmaster.mdc`) to reflect new `--id/-i`, `--from/-f`, and `--to/-t` options/parameters.
|
||||
|
||||
# Test Strategy:
|
||||
|
||||
1. **CLI:**
|
||||
* Run `task-master analyze-complexity --id=<id1>` (where report doesn't exist). Verify report created with only task id1.
|
||||
* Run `task-master analyze-complexity --id=<id2>` (where report exists). Verify report updated, containing analysis for both id1 and id2 (id2 replaces any previous id2 analysis).
|
||||
* Run `task-master analyze-complexity --id=<id1>,<id3>`. Verify report updated, containing id1, id2, id3.
|
||||
* Run `task-master analyze-complexity` (no id). Verify it analyzes *all* active tasks and updates the report accordingly, merging with previous specific analyses.
|
||||
* Test with invalid/non-existent IDs.
|
||||
2. **MCP:**
|
||||
* Call `analyze_project_complexity` tool with `ids: "<id1>"`. Verify report creation/update.
|
||||
* Call `analyze_project_complexity` tool with `ids: "<id1>,<id2>"`. Verify report merging.
|
||||
* Call `analyze_project_complexity` tool without `ids`. Verify full analysis and merging.
|
||||
3. Verify report `meta` section is updated correctly on each run.
|
||||
|
||||
1. **CLI:**
|
||||
* Run `task-master analyze-complexity -i=<id1>` (where report doesn't exist). Verify report created with only task id1.
|
||||
* Run `task-master analyze-complexity -i=<id2>` (where report exists). Verify report updated, containing analysis for both id1 and id2 (id2 replaces any previous id2 analysis).
|
||||
* Run `task-master analyze-complexity -i=<id1>,<id3>`. Verify report updated, containing id1, id2, id3.
|
||||
* Run `task-master analyze-complexity -f=50 -t=60`. Verify report created/updated with tasks in the range 50-60.
|
||||
* Run `task-master analyze-complexity` (no flags). Verify it analyzes all active tasks and updates the report accordingly, merging with previous specific analyses.
|
||||
* Test with invalid/non-existent IDs or ranges.
|
||||
* Verify that completed tasks are still skipped in all scenarios, maintaining existing behavior.
|
||||
2. **MCP:**
|
||||
* Call `analyze_project_complexity` tool with `ids: "<id1>"`. Verify report creation/update.
|
||||
* Call `analyze_project_complexity` tool with `ids: "<id1>,<id2>,<id3>"`. Verify report created/updated with multiple specific tasks.
|
||||
* Call `analyze_project_complexity` tool with `from: 50, to: 60`. Verify report created/updated for tasks in range.
|
||||
* Call `analyze_project_complexity` tool without parameters. Verify full analysis and merging.
|
||||
3. Verify report `meta` section is updated correctly on each run.
|
||||
|
||||
# Subtasks:
|
||||
## 1. Modify core complexity analysis logic [pending]
|
||||
### Dependencies: None
|
||||
### Description: Update the core complexity analysis function to accept specific task IDs as input parameters
|
||||
### Description: Update the core complexity analysis function to accept specific task IDs or ranges as input parameters
|
||||
### Details:
|
||||
Refactor the existing complexity analysis module to allow filtering by task IDs. This involves modifying the data processing pipeline to filter tasks before analysis, ensuring the complexity metrics are calculated only for the specified tasks while maintaining context awareness.
|
||||
Refactor the existing complexity analysis module to allow filtering by task IDs or ranges. This involves modifying the data processing pipeline to filter tasks before analysis, ensuring the complexity metrics are calculated only for the specified tasks while maintaining context awareness.
|
||||
|
||||
## 2. Update CLI interface for task-specific complexity analysis [pending]
|
||||
### Dependencies: 69.1
|
||||
### Description: Extend the CLI to accept task IDs as parameters for the complexity analysis command
|
||||
### Description: Extend the CLI to accept task IDs or ranges as parameters for the complexity analysis command
|
||||
### Details:
|
||||
Add a new flag or parameter to the CLI that allows users to specify task IDs for targeted complexity analysis. Update the command parser, help documentation, and ensure proper validation of the provided task IDs.
|
||||
Add new flags `--id/-i`, `--from/-f`, and `--to/-t` to the CLI that allow users to specify task IDs or ranges for targeted complexity analysis. Update the command parser, help documentation, and ensure proper validation of the provided values.
|
||||
|
||||
## 3. Integrate task-specific analysis with MCP tool [pending]
|
||||
### Dependencies: 69.1
|
||||
### Description: Update the MCP tool interface to support analyzing complexity for specific tasks
|
||||
### Description: Update the MCP tool interface to support analyzing complexity for specific tasks or ranges
|
||||
### Details:
|
||||
Modify the MCP tool's API endpoints and UI components to allow users to select specific tasks for complexity analysis. Ensure the UI provides clear feedback about which tasks are being analyzed and update the visualization components to properly display partial analysis results.
|
||||
Modify the MCP tool's API endpoints and UI components to allow users to select specific tasks or ranges for complexity analysis. Ensure the UI provides clear feedback about which tasks are being analyzed and update the visualization components to properly display partial analysis results.
|
||||
|
||||
## 4. Create comprehensive tests for task-specific complexity analysis [pending]
|
||||
### Dependencies: 69.1, 69.2, 69.3
|
||||
|
||||
@@ -4544,39 +4544,39 @@
|
||||
{
|
||||
"id": 69,
|
||||
"title": "Enhance Analyze Complexity for Specific Task IDs",
|
||||
"description": "Modify the analyze-complexity feature (CLI and MCP) to allow analyzing only specified task IDs and append/update results in the report.",
|
||||
"details": "\nImplementation Plan:\n\n1. **Core Logic (`scripts/modules/task-manager/analyze-task-complexity.js`):**\n * Modify the function signature to accept an optional `options.ids` parameter (string, comma-separated IDs).\n * If `options.ids` is present:\n * Parse the `ids` string into an array of target IDs.\n * Filter `tasksData.tasks` to *only* include tasks matching the target IDs. Use this filtered list for analysis.\n * Handle cases where provided IDs don't exist in `tasks.json`.\n * If `options.ids` is *not* present: Continue with existing logic (filtering by active status).\n * **Report Handling:**\n * Before generating the analysis, check if the `outputPath` report file exists.\n * If it exists, read the existing `complexityAnalysis` array.\n * Generate the new analysis *only* for the target tasks (filtered by ID or status).\n * Merge the results: Remove any entries from the *existing* array that match the IDs analyzed in the *current run*. Then, append the *new* analysis results to the array.\n * Update the `meta` section (`generatedAt`, `tasksAnalyzed` should reflect *this run*).\n * Write the *merged* `complexityAnalysis` array and updated `meta` back to the report file.\n * If the report file doesn't exist, create it as usual.\n * **Prompt Generation:** Ensure `generateInternalComplexityAnalysisPrompt` receives the correctly filtered list of tasks.\n\n2. **CLI (`scripts/modules/commands.js`):**\n * Add a new option `--id <ids>` to the `analyze-complexity` command definition. Description: \"Comma-separated list of specific task IDs to analyze\".\n * In the `.action` handler:\n * Check if `options.id` is provided.\n * If yes, pass `options.id` (as the comma-separated string) to the `analyzeTaskComplexity` core function via the `options` object.\n * Update user feedback messages to indicate specific task analysis.\n\n3. **MCP Tool (`mcp-server/src/tools/analyze.js`):**\n * Add a new optional parameter `ids: z.string().optional().describe(\"Comma-separated list of task IDs to analyze specifically\")` to the Zod schema for the `analyze_project_complexity` tool.\n * In the `execute` method, pass `args.ids` to the `analyzeTaskComplexityDirect` function within its `args` object.\n\n4. **Direct Function (`mcp-server/src/core/direct-functions/analyze-task-complexity.js`):**\n * Update the function to receive the `ids` string within the `args` object.\n * Pass the `ids` string along to the core `analyzeTaskComplexity` function within its `options` object.\n\n5. **Documentation:** Update relevant rule files (`commands.mdc`, `taskmaster.mdc`) to reflect the new `--id` option/parameter.\n",
|
||||
"testStrategy": "\n1. **CLI:**\n * Run `task-master analyze-complexity --id=<id1>` (where report doesn't exist). Verify report created with only task id1.\n * Run `task-master analyze-complexity --id=<id2>` (where report exists). Verify report updated, containing analysis for both id1 and id2 (id2 replaces any previous id2 analysis).\n * Run `task-master analyze-complexity --id=<id1>,<id3>`. Verify report updated, containing id1, id2, id3.\n * Run `task-master analyze-complexity` (no id). Verify it analyzes *all* active tasks and updates the report accordingly, merging with previous specific analyses.\n * Test with invalid/non-existent IDs.\n2. **MCP:**\n * Call `analyze_project_complexity` tool with `ids: \"<id1>\"`. Verify report creation/update.\n * Call `analyze_project_complexity` tool with `ids: \"<id1>,<id2>\"`. Verify report merging.\n * Call `analyze_project_complexity` tool without `ids`. Verify full analysis and merging.\n3. Verify report `meta` section is updated correctly on each run.\n",
|
||||
"description": "Modify the analyze-complexity feature (CLI and MCP) to allow analyzing only specified task IDs or ranges, and append/update results in the report.",
|
||||
"status": "pending",
|
||||
"dependencies": [],
|
||||
"priority": "medium",
|
||||
"details": "\nImplementation Plan:\n\n1. **Core Logic (`scripts/modules/task-manager/analyze-task-complexity.js`)**\n * Modify function signature to accept optional parameters: `options.ids` (string, comma-separated IDs) and range parameters `options.from` and `options.to`.\n * If `options.ids` is present:\n * Parse the `ids` string into an array of target IDs.\n * Filter `tasksData.tasks` to include only tasks matching the target IDs.\n * Handle cases where provided IDs don't exist in `tasks.json`.\n * If range parameters (`options.from` and `options.to`) are present:\n * Parse these values into integers.\n * Filter tasks within the specified ID range (inclusive).\n * If neither `options.ids` nor range parameters are present: Continue with existing logic (filtering by active status).\n * Maintain existing logic for skipping completed tasks.\n * **Report Handling:**\n * Before generating analysis, check if the `outputPath` report file exists.\n * If it exists:\n * Read the existing `complexityAnalysis` array.\n * Generate new analysis only for target tasks (filtered by ID or range).\n * Merge results: Remove entries from the existing array that match IDs analyzed in the current run, then append new analysis results to the array.\n * Update the `meta` section (`generatedAt`, `tasksAnalyzed`).\n * Write merged `complexityAnalysis` and updated `meta` back to report file.\n * If the report file doesn't exist: Create it as usual.\n * **Prompt Generation:** Ensure `generateInternalComplexityAnalysisPrompt` receives correctly filtered list of tasks.\n\n2. **CLI (`scripts/modules/commands.js`)**\n * Add new options to the `analyze-complexity` command:\n * `--id/-i <ids>`: \"Comma-separated list of specific task IDs to analyze\"\n * `--from/-f <startId>`: \"Start ID for range analysis (inclusive)\"\n * `--to/-t <endId>`: \"End ID for range analysis (inclusive)\"\n * In the `.action` handler:\n * Check if `options.id`, `options.from`, or `options.to` are provided.\n * If yes, pass appropriate values to the `analyzeTaskComplexity` core function via the `options` object.\n * Update user feedback messages to indicate specific task analysis.\n\n3. **MCP Tool (`mcp-server/src/tools/analyze.js`)**\n * Add new optional parameters to Zod schema for `analyze_project_complexity` tool:\n * `ids: z.string().optional().describe(\"Comma-separated list of task IDs to analyze specifically\")`\n * `from: z.number().optional().describe(\"Start ID for range analysis (inclusive)\")`\n * `to: z.number().optional().describe(\"End ID for range analysis (inclusive)\")`\n * In the `execute` method, pass `args.ids`, `args.from`, and `args.to` to the `analyzeTaskComplexityDirect` function within its `args` object.\n\n4. **Direct Function (`mcp-server/src/core/direct-functions/analyze-task-complexity.js`)**\n * Update function to receive `ids`, `from`, and `to` values within the `args` object.\n * Pass these values along to the core `analyzeTaskComplexity` function within its `options` object.\n\n5. **Documentation:** Update relevant rule files (`commands.mdc`, `taskmaster.mdc`) to reflect new `--id/-i`, `--from/-f`, and `--to/-t` options/parameters.",
|
||||
"testStrategy": "\n1. **CLI:**\n * Run `task-master analyze-complexity -i=<id1>` (where report doesn't exist). Verify report created with only task id1.\n * Run `task-master analyze-complexity -i=<id2>` (where report exists). Verify report updated, containing analysis for both id1 and id2 (id2 replaces any previous id2 analysis).\n * Run `task-master analyze-complexity -i=<id1>,<id3>`. Verify report updated, containing id1, id2, id3.\n * Run `task-master analyze-complexity -f=50 -t=60`. Verify report created/updated with tasks in the range 50-60.\n * Run `task-master analyze-complexity` (no flags). Verify it analyzes all active tasks and updates the report accordingly, merging with previous specific analyses.\n * Test with invalid/non-existent IDs or ranges.\n * Verify that completed tasks are still skipped in all scenarios, maintaining existing behavior.\n2. **MCP:**\n * Call `analyze_project_complexity` tool with `ids: \"<id1>\"`. Verify report creation/update.\n * Call `analyze_project_complexity` tool with `ids: \"<id1>,<id2>,<id3>\"`. Verify report created/updated with multiple specific tasks.\n * Call `analyze_project_complexity` tool with `from: 50, to: 60`. Verify report created/updated for tasks in range.\n * Call `analyze_project_complexity` tool without parameters. Verify full analysis and merging.\n3. Verify report `meta` section is updated correctly on each run.",
|
||||
"subtasks": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Modify core complexity analysis logic",
|
||||
"description": "Update the core complexity analysis function to accept specific task IDs as input parameters",
|
||||
"description": "Update the core complexity analysis function to accept specific task IDs or ranges as input parameters",
|
||||
"dependencies": [],
|
||||
"details": "Refactor the existing complexity analysis module to allow filtering by task IDs. This involves modifying the data processing pipeline to filter tasks before analysis, ensuring the complexity metrics are calculated only for the specified tasks while maintaining context awareness.",
|
||||
"details": "Refactor the existing complexity analysis module to allow filtering by task IDs or ranges. This involves modifying the data processing pipeline to filter tasks before analysis, ensuring the complexity metrics are calculated only for the specified tasks while maintaining context awareness.",
|
||||
"status": "pending"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "Update CLI interface for task-specific complexity analysis",
|
||||
"description": "Extend the CLI to accept task IDs as parameters for the complexity analysis command",
|
||||
"description": "Extend the CLI to accept task IDs or ranges as parameters for the complexity analysis command",
|
||||
"dependencies": [
|
||||
1
|
||||
],
|
||||
"details": "Add a new flag or parameter to the CLI that allows users to specify task IDs for targeted complexity analysis. Update the command parser, help documentation, and ensure proper validation of the provided task IDs.",
|
||||
"details": "Add new flags `--id/-i`, `--from/-f`, and `--to/-t` to the CLI that allow users to specify task IDs or ranges for targeted complexity analysis. Update the command parser, help documentation, and ensure proper validation of the provided values.",
|
||||
"status": "pending"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "Integrate task-specific analysis with MCP tool",
|
||||
"description": "Update the MCP tool interface to support analyzing complexity for specific tasks",
|
||||
"description": "Update the MCP tool interface to support analyzing complexity for specific tasks or ranges",
|
||||
"dependencies": [
|
||||
1
|
||||
],
|
||||
"details": "Modify the MCP tool's API endpoints and UI components to allow users to select specific tasks for complexity analysis. Ensure the UI provides clear feedback about which tasks are being analyzed and update the visualization components to properly display partial analysis results.",
|
||||
"details": "Modify the MCP tool's API endpoints and UI components to allow users to select specific tasks or ranges for complexity analysis. Ensure the UI provides clear feedback about which tasks are being analyzed and update the visualization components to properly display partial analysis results.",
|
||||
"status": "pending"
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user