Files
claude-task-master/mcp-server/src/tools/scope-up.js
Eyal Toledano 1080162a09 feat(task-104): Complete task 104 - Implement scope-up and scope-down CLI Commands
- Added new CLI commands 'scope-up' and 'scope-down' with comma-separated ID support
- Implemented strength levels (light/regular/heavy) and custom prompt functionality
- Created core complexity adjustment logic with AI integration
- Added MCP tool equivalents for integrated environments
- Comprehensive error handling and task validation
- Full test coverage with TDD approach
- Updated task manager core and UI components

Task 104: Implement 'scope-up' and 'scope-down' CLI Commands for Dynamic Task Complexity Adjustment - Complete implementation with CLI, MCP integration, and testing
2025-08-02 18:57:19 +03:00

105 lines
2.6 KiB
JavaScript

/**
* tools/scope-up.js
* Tool to scope up task complexity
*/
import { z } from 'zod';
import {
createErrorResponse,
handleApiResult,
withNormalizedProjectRoot
} from './utils.js';
import { scopeUpDirect } from '../core/task-master-core.js';
import { findTasksPath } from '../core/utils/path-utils.js';
import { resolveTag } from '../../../scripts/modules/utils.js';
/**
* Register the scopeUp tool with the MCP server
* @param {Object} server - FastMCP server instance
*/
export function registerScopeUpTool(server) {
server.addTool({
name: 'scope_up_task',
description: 'Increase the complexity of one or more tasks using AI',
parameters: z.object({
id: z
.string()
.describe(
'Comma-separated list of task IDs to scope up (e.g., "1,3,5")'
),
strength: z
.string()
.optional()
.describe(
'Strength level: light, regular, or heavy (default: regular)'
),
prompt: z
.string()
.optional()
.describe('Custom prompt for specific scoping adjustments'),
file: z
.string()
.optional()
.describe('Path to the tasks file (default: tasks/tasks.json)'),
projectRoot: z
.string()
.describe('The directory of the project. Must be an absolute path.'),
tag: z.string().optional().describe('Tag context to operate on'),
research: z
.boolean()
.optional()
.describe('Whether to use research capabilities for scoping')
}),
execute: withNormalizedProjectRoot(async (args, { log, session }) => {
try {
log.info(`Starting scope-up with args: ${JSON.stringify(args)}`);
const resolvedTag = resolveTag({
projectRoot: args.projectRoot,
tag: args.tag
});
// Use args.projectRoot directly (guaranteed by withNormalizedProjectRoot)
let tasksJsonPath;
try {
tasksJsonPath = findTasksPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);
} catch (error) {
log.error(`Error finding tasks.json: ${error.message}`);
return createErrorResponse(
`Failed to find tasks.json: ${error.message}`
);
}
// Call the direct function
const result = await scopeUpDirect(
{
tasksJsonPath: tasksJsonPath,
id: args.id,
strength: args.strength,
prompt: args.prompt,
research: args.research,
projectRoot: args.projectRoot,
tag: resolvedTag
},
log,
{ session }
);
return handleApiResult(
result,
log,
'Error scoping up task',
undefined,
args.projectRoot
);
} catch (error) {
log.error(`Error in scope-up tool: ${error.message}`);
return createErrorResponse(error.message);
}
})
});
}