fix(ui): Display subtask details in 'show' command output
Ensures that the 'details' field, which can be updated via 'update-subtask', is correctly rendered when viewing a specific subtask. fix(test): Remove empty describe block causing Jest error Removes a redundant block in that contained a hook but no tests. chore: Add npm script
This commit is contained in:
@@ -226,12 +226,69 @@ Testing approach:
|
||||
### Dependencies: 23.13
|
||||
### Description: Refactor the MCP server implementation to use direct Task Master function imports instead of the current CLI-based execution using child_process.spawnSync. This will improve performance, reliability, and enable better error handling.
|
||||
### Details:
|
||||
1. Create a new module to import and expose Task Master core functions directly
|
||||
2. Modify tools/utils.js to remove executeTaskMasterCommand and replace with direct function calls
|
||||
3. Update each tool implementation (listTasks.js, showTask.js, etc.) to use the direct function imports
|
||||
4. Implement proper error handling with try/catch blocks and FastMCP's MCPError
|
||||
5. Add unit tests to verify the function imports work correctly
|
||||
6. Test performance improvements by comparing response times between CLI and function import approaches
|
||||
|
||||
|
||||
<info added on 2025-03-30T00:14:10.040Z>
|
||||
```
|
||||
# Refactoring Strategy for Direct Function Imports
|
||||
|
||||
## Core Approach
|
||||
1. Create a clear separation between data retrieval/processing and presentation logic
|
||||
2. Modify function signatures to accept `outputFormat` parameter ('cli'|'json', default: 'cli')
|
||||
3. Implement early returns for JSON format to bypass CLI-specific code
|
||||
|
||||
## Implementation Details for `listTasks`
|
||||
```javascript
|
||||
function listTasks(tasksPath, statusFilter, withSubtasks = false, outputFormat = 'cli') {
|
||||
try {
|
||||
// Existing data retrieval logic
|
||||
const filteredTasks = /* ... */;
|
||||
|
||||
// Early return for JSON format
|
||||
if (outputFormat === 'json') return filteredTasks;
|
||||
|
||||
// Existing CLI output logic
|
||||
} catch (error) {
|
||||
if (outputFormat === 'json') {
|
||||
throw {
|
||||
code: 'TASK_LIST_ERROR',
|
||||
message: error.message,
|
||||
details: error.stack
|
||||
};
|
||||
} else {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Testing Strategy
|
||||
- Create integration tests in `tests/integration/mcp-server/`
|
||||
- Use FastMCP InMemoryTransport for direct client-server testing
|
||||
- Test both JSON and CLI output formats
|
||||
- Verify structure consistency with schema validation
|
||||
|
||||
## Additional Considerations
|
||||
- Update JSDoc comments to document new parameters and return types
|
||||
- Ensure backward compatibility with default CLI behavior
|
||||
- Add JSON schema validation for consistent output structure
|
||||
- Apply similar pattern to other core functions (expandTask, updateTaskById, etc.)
|
||||
|
||||
## Error Handling Improvements
|
||||
- Standardize error format for JSON returns:
|
||||
```javascript
|
||||
{
|
||||
code: 'ERROR_CODE',
|
||||
message: 'Human-readable message',
|
||||
details: {}, // Additional context when available
|
||||
stack: process.env.NODE_ENV === 'development' ? error.stack : undefined
|
||||
}
|
||||
```
|
||||
- Enrich JSON errors with error codes and debug info
|
||||
- Ensure validation failures return proper objects in JSON mode
|
||||
```
|
||||
</info added on 2025-03-30T00:14:10.040Z>
|
||||
|
||||
## 9. Implement Context Management and Caching Mechanisms [deferred]
|
||||
### Dependencies: 23.1
|
||||
|
||||
@@ -1399,7 +1399,7 @@
|
||||
"dependencies": [
|
||||
"23.13"
|
||||
],
|
||||
"details": "1. Create a new module to import and expose Task Master core functions directly\n2. Modify tools/utils.js to remove executeTaskMasterCommand and replace with direct function calls\n3. Update each tool implementation (listTasks.js, showTask.js, etc.) to use the direct function imports\n4. Implement proper error handling with try/catch blocks and FastMCP's MCPError\n5. Add unit tests to verify the function imports work correctly\n6. Test performance improvements by comparing response times between CLI and function import approaches",
|
||||
"details": "\n\n<info added on 2025-03-30T00:14:10.040Z>\n```\n# Refactoring Strategy for Direct Function Imports\n\n## Core Approach\n1. Create a clear separation between data retrieval/processing and presentation logic\n2. Modify function signatures to accept `outputFormat` parameter ('cli'|'json', default: 'cli')\n3. Implement early returns for JSON format to bypass CLI-specific code\n\n## Implementation Details for `listTasks`\n```javascript\nfunction listTasks(tasksPath, statusFilter, withSubtasks = false, outputFormat = 'cli') {\n try {\n // Existing data retrieval logic\n const filteredTasks = /* ... */;\n \n // Early return for JSON format\n if (outputFormat === 'json') return filteredTasks;\n \n // Existing CLI output logic\n } catch (error) {\n if (outputFormat === 'json') {\n throw {\n code: 'TASK_LIST_ERROR',\n message: error.message,\n details: error.stack\n };\n } else {\n console.error(error);\n process.exit(1);\n }\n }\n}\n```\n\n## Testing Strategy\n- Create integration tests in `tests/integration/mcp-server/`\n- Use FastMCP InMemoryTransport for direct client-server testing\n- Test both JSON and CLI output formats\n- Verify structure consistency with schema validation\n\n## Additional Considerations\n- Update JSDoc comments to document new parameters and return types\n- Ensure backward compatibility with default CLI behavior\n- Add JSON schema validation for consistent output structure\n- Apply similar pattern to other core functions (expandTask, updateTaskById, etc.)\n\n## Error Handling Improvements\n- Standardize error format for JSON returns:\n```javascript\n{\n code: 'ERROR_CODE',\n message: 'Human-readable message',\n details: {}, // Additional context when available\n stack: process.env.NODE_ENV === 'development' ? error.stack : undefined\n}\n```\n- Enrich JSON errors with error codes and debug info\n- Ensure validation failures return proper objects in JSON mode\n```\n</info added on 2025-03-30T00:14:10.040Z>",
|
||||
"status": "in-progress",
|
||||
"parentTaskId": 23
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user