fix: expand_all now uses complexity analysis recommendations (#1287)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Ralph Khreish
2025-10-11 11:54:31 +02:00
committed by GitHub
parent 25a00dca67
commit 90e6bdcf1c
5 changed files with 116 additions and 7 deletions

View File

@@ -8,6 +8,7 @@ import {
disableSilentMode
} from '../../../../scripts/modules/utils.js';
import { createLogWrapper } from '../../tools/utils.js';
import { resolveComplexityReportOutputPath } from '../../../../src/utils/path-utils.js';
/**
* Expand all pending tasks with subtasks (Direct Function Wrapper)
@@ -25,13 +26,30 @@ import { createLogWrapper } from '../../tools/utils.js';
*/
export async function expandAllTasksDirect(args, log, context = {}) {
const { session } = context; // Extract session
// Destructure expected args, including projectRoot
const { tasksJsonPath, num, research, prompt, force, projectRoot, tag } =
args;
// Destructure expected args, including projectRoot and complexityReportPath
const {
tasksJsonPath,
num,
research,
prompt,
force,
projectRoot,
tag,
complexityReportPath: providedComplexityReportPath
} = args;
// Create logger wrapper using the utility
const mcpLog = createLogWrapper(log);
// Use provided complexity report path or compute it
const complexityReportPath =
providedComplexityReportPath ||
resolveComplexityReportOutputPath(null, { projectRoot, tag }, log);
log.info(
`Expand all tasks will use complexity report at: ${complexityReportPath}`
);
if (!tasksJsonPath) {
log.error('expandAllTasksDirect called without tasksJsonPath');
return {
@@ -55,14 +73,14 @@ export async function expandAllTasksDirect(args, log, context = {}) {
const additionalContext = prompt || '';
const forceFlag = force === true;
// Call the core function, passing options and the context object { session, mcpLog, projectRoot }
// Call the core function, passing options and the context object { session, mcpLog, projectRoot, tag, complexityReportPath }
const result = await expandAllTasks(
tasksJsonPath,
numSubtasks,
useResearch,
additionalContext,
forceFlag,
{ session, mcpLog, projectRoot, tag },
{ session, mcpLog, projectRoot, tag, complexityReportPath },
'json'
);

View File

@@ -3,6 +3,7 @@ import {
findTasksPath as coreFindTasksPath,
findPRDPath as coreFindPrdPath,
findComplexityReportPath as coreFindComplexityReportPath,
resolveComplexityReportOutputPath as coreResolveComplexityReportOutputPath,
findProjectRoot as coreFindProjectRoot,
normalizeProjectRoot
} from '../../../../src/utils/path-utils.js';
@@ -224,6 +225,21 @@ export function findComplexityReportPath(args, log = silentLogger) {
return resolveComplexityReportPath(args, log);
}
/**
* Resolve complexity report output path (create if needed) - primary MCP function
* @param {string|null} [explicitPath] - Explicit path to complexity report
* @param {Object} args - Arguments object containing projectRoot and tag
* @param {Object} [log] - Log function to prevent console logging
* @returns {string} - Resolved output path for complexity report
*/
export function resolveComplexityReportOutputPath(
explicitPath,
args,
log = silentLogger
) {
return coreResolveComplexityReportOutputPath(explicitPath, args, log);
}
/**
* Find PRD path - primary MCP function
* @param {string} [explicitPath] - Explicit path to PRD file

View File

@@ -10,7 +10,10 @@ import {
withNormalizedProjectRoot
} from './utils.js';
import { expandAllTasksDirect } from '../core/task-master-core.js';
import { findTasksPath } from '../core/utils/path-utils.js';
import {
findTasksPath,
resolveComplexityReportOutputPath
} from '../core/utils/path-utils.js';
import { resolveTag } from '../../../scripts/modules/utils.js';
/**
@@ -85,6 +88,14 @@ export function registerExpandAllTool(server) {
);
}
// Resolve complexity report path to use recommendations from analyze-complexity
const complexityReportPath = resolveComplexityReportOutputPath(
null,
{ projectRoot: args.projectRoot, tag: resolvedTag },
log
);
log.info(`Using complexity report path: ${complexityReportPath}`);
const result = await expandAllTasksDirect(
{
tasksJsonPath: tasksJsonPath,
@@ -93,7 +104,8 @@ export function registerExpandAllTool(server) {
prompt: args.prompt,
force: args.force,
projectRoot: args.projectRoot,
tag: resolvedTag
tag: resolvedTag,
complexityReportPath
},
log,
{ session }