Fix: MCP log errors (#648)
This commit is contained in:
@@ -28,8 +28,7 @@ export async function complexityReportDirect(args, log) {
|
||||
log.error('complexityReportDirect called without reportPath');
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'MISSING_ARGUMENT', message: 'reportPath is required' },
|
||||
fromCache: false
|
||||
error: { code: 'MISSING_ARGUMENT', message: 'reportPath is required' }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -111,8 +110,7 @@ export async function complexityReportDirect(args, log) {
|
||||
error: {
|
||||
code: 'UNEXPECTED_ERROR',
|
||||
message: error.message
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,8 @@ export async function expandAllTasksDirect(args, log, context = {}) {
|
||||
useResearch,
|
||||
additionalContext,
|
||||
forceFlag,
|
||||
{ session, mcpLog, projectRoot }
|
||||
{ session, mcpLog, projectRoot },
|
||||
'json'
|
||||
);
|
||||
|
||||
// Core function now returns a summary object including the *aggregated* telemetryData
|
||||
|
||||
@@ -29,7 +29,7 @@ import { createLogWrapper } from '../../tools/utils.js';
|
||||
* @param {Object} log - Logger object
|
||||
* @param {Object} context - Context object containing session
|
||||
* @param {Object} [context.session] - MCP Session object
|
||||
* @returns {Promise<Object>} - Task expansion result { success: boolean, data?: any, error?: { code: string, message: string }, fromCache: boolean }
|
||||
* @returns {Promise<Object>} - Task expansion result { success: boolean, data?: any, error?: { code: string, message: string } }
|
||||
*/
|
||||
export async function expandTaskDirect(args, log, context = {}) {
|
||||
const { session } = context; // Extract session
|
||||
@@ -54,8 +54,7 @@ export async function expandTaskDirect(args, log, context = {}) {
|
||||
error: {
|
||||
code: 'MISSING_ARGUMENT',
|
||||
message: 'tasksJsonPath is required'
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -73,8 +72,7 @@ export async function expandTaskDirect(args, log, context = {}) {
|
||||
error: {
|
||||
code: 'INPUT_VALIDATION_ERROR',
|
||||
message: 'Task ID is required'
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -105,8 +103,7 @@ export async function expandTaskDirect(args, log, context = {}) {
|
||||
error: {
|
||||
code: 'INVALID_TASKS_FILE',
|
||||
message: `No valid tasks found in ${tasksPath}. readJSON returned: ${JSON.stringify(data)}`
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -121,8 +118,7 @@ export async function expandTaskDirect(args, log, context = {}) {
|
||||
error: {
|
||||
code: 'TASK_NOT_FOUND',
|
||||
message: `Task with ID ${taskId} not found`
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -133,8 +129,7 @@ export async function expandTaskDirect(args, log, context = {}) {
|
||||
error: {
|
||||
code: 'TASK_COMPLETED',
|
||||
message: `Task ${taskId} is already marked as ${task.status} and cannot be expanded`
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -151,8 +146,7 @@ export async function expandTaskDirect(args, log, context = {}) {
|
||||
task,
|
||||
subtasksAdded: 0,
|
||||
hasExistingSubtasks
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -232,8 +226,7 @@ export async function expandTaskDirect(args, log, context = {}) {
|
||||
subtasksAdded,
|
||||
hasExistingSubtasks,
|
||||
telemetryData: coreResult.telemetryData
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
// Make sure to restore normal logging even if there's an error
|
||||
@@ -245,8 +238,7 @@ export async function expandTaskDirect(args, log, context = {}) {
|
||||
error: {
|
||||
code: 'CORE_FUNCTION_ERROR',
|
||||
message: error.message || 'Failed to expand task'
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -256,8 +248,7 @@ export async function expandTaskDirect(args, log, context = {}) {
|
||||
error: {
|
||||
code: 'CORE_FUNCTION_ERROR',
|
||||
message: error.message || 'Failed to expand task'
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,7 @@ export async function generateTaskFilesDirect(args, log) {
|
||||
log.error(errorMessage);
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'MISSING_ARGUMENT', message: errorMessage },
|
||||
fromCache: false
|
||||
error: { code: 'MISSING_ARGUMENT', message: errorMessage }
|
||||
};
|
||||
}
|
||||
if (!outputDir) {
|
||||
@@ -37,8 +36,7 @@ export async function generateTaskFilesDirect(args, log) {
|
||||
log.error(errorMessage);
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'MISSING_ARGUMENT', message: errorMessage },
|
||||
fromCache: false
|
||||
error: { code: 'MISSING_ARGUMENT', message: errorMessage }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -65,8 +63,7 @@ export async function generateTaskFilesDirect(args, log) {
|
||||
log.error(`Error in generateTaskFiles: ${genError.message}`);
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'GENERATE_FILES_ERROR', message: genError.message },
|
||||
fromCache: false
|
||||
error: { code: 'GENERATE_FILES_ERROR', message: genError.message }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -79,8 +76,7 @@ export async function generateTaskFilesDirect(args, log) {
|
||||
outputDir: resolvedOutputDir,
|
||||
taskFiles:
|
||||
'Individual task files have been generated in the output directory'
|
||||
},
|
||||
fromCache: false // This operation always modifies state and should never be cached
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
// Make sure to restore normal logging if an outer error occurs
|
||||
@@ -92,8 +88,7 @@ export async function generateTaskFilesDirect(args, log) {
|
||||
error: {
|
||||
code: 'GENERATE_TASKS_ERROR',
|
||||
message: error.message || 'Unknown error generating task files'
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,7 @@ export async function initializeProjectDirect(args, log, context = {}) {
|
||||
code: 'INVALID_TARGET_DIRECTORY',
|
||||
message: `Cannot initialize project: Invalid target directory '${targetDirectory}' received. Please ensure a valid workspace/folder is open or specified.`,
|
||||
details: `Received args.projectRoot: ${args.projectRoot}` // Show what was received
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -97,8 +96,8 @@ export async function initializeProjectDirect(args, log, context = {}) {
|
||||
}
|
||||
|
||||
if (success) {
|
||||
return { success: true, data: resultData, fromCache: false };
|
||||
return { success: true, data: resultData };
|
||||
} else {
|
||||
return { success: false, error: errorResult, fromCache: false };
|
||||
return { success: false, error: errorResult };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
*
|
||||
* @param {Object} args - Command arguments (now expecting tasksJsonPath explicitly).
|
||||
* @param {Object} log - Logger object.
|
||||
* @returns {Promise<Object>} - Task list result { success: boolean, data?: any, error?: { code: string, message: string }, fromCache: boolean }.
|
||||
* @returns {Promise<Object>} - Task list result { success: boolean, data?: any, error?: { code: string, message: string } }.
|
||||
*/
|
||||
export async function listTasksDirect(args, log) {
|
||||
// Destructure the explicit tasksJsonPath from args
|
||||
@@ -27,8 +27,7 @@ export async function listTasksDirect(args, log) {
|
||||
error: {
|
||||
code: 'MISSING_ARGUMENT',
|
||||
message: 'tasksJsonPath is required'
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
* @param {Object} args - Command arguments
|
||||
* @param {string} args.tasksJsonPath - Explicit path to the tasks.json file.
|
||||
* @param {Object} log - Logger object
|
||||
* @returns {Promise<Object>} - Next task result { success: boolean, data?: any, error?: { code: string, message: string }, fromCache: boolean }
|
||||
* @returns {Promise<Object>} - Next task result { success: boolean, data?: any, error?: { code: string, message: string } }
|
||||
*/
|
||||
export async function nextTaskDirect(args, log) {
|
||||
// Destructure expected args
|
||||
@@ -32,8 +32,7 @@ export async function nextTaskDirect(args, log) {
|
||||
error: {
|
||||
code: 'MISSING_ARGUMENT',
|
||||
message: 'tasksJsonPath is required'
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -121,7 +120,7 @@ export async function nextTaskDirect(args, log) {
|
||||
// Use the caching utility
|
||||
try {
|
||||
const result = await coreNextTaskAction();
|
||||
log.info(`nextTaskDirect completed.`);
|
||||
log.info('nextTaskDirect completed.');
|
||||
return result;
|
||||
} catch (error) {
|
||||
log.error(`Unexpected error during nextTask: ${error.message}`);
|
||||
@@ -130,8 +129,7 @@ export async function nextTaskDirect(args, log) {
|
||||
error: {
|
||||
code: 'UNEXPECTED_ERROR',
|
||||
message: error.message
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ export async function parsePRDDirect(args, log, context = {}) {
|
||||
? path.isAbsolute(outputArg)
|
||||
? outputArg
|
||||
: path.resolve(projectRoot, outputArg)
|
||||
: resolveProjectPath(TASKMASTER_TASKS_FILE, session) ||
|
||||
: resolveProjectPath(TASKMASTER_TASKS_FILE, args) ||
|
||||
path.resolve(projectRoot, TASKMASTER_TASKS_FILE);
|
||||
|
||||
// Check if input file exists
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
* @param {string} args.tasksJsonPath - Explicit path to the tasks.json file.
|
||||
* @param {string} args.id - The ID(s) of the task(s) or subtask(s) to remove (comma-separated for multiple).
|
||||
* @param {Object} log - Logger object
|
||||
* @returns {Promise<Object>} - Remove task result { success: boolean, data?: any, error?: { code: string, message: string }, fromCache: false }
|
||||
* @returns {Promise<Object>} - Remove task result { success: boolean, data?: any, error?: { code: string, message: string } }
|
||||
*/
|
||||
export async function removeTaskDirect(args, log) {
|
||||
// Destructure expected args
|
||||
@@ -35,8 +35,7 @@ export async function removeTaskDirect(args, log) {
|
||||
error: {
|
||||
code: 'MISSING_ARGUMENT',
|
||||
message: 'tasksJsonPath is required'
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -48,8 +47,7 @@ export async function removeTaskDirect(args, log) {
|
||||
error: {
|
||||
code: 'INPUT_VALIDATION_ERROR',
|
||||
message: 'Task ID is required'
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -68,8 +66,7 @@ export async function removeTaskDirect(args, log) {
|
||||
error: {
|
||||
code: 'INVALID_TASKS_FILE',
|
||||
message: `No valid tasks found in ${tasksJsonPath}`
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -83,8 +80,7 @@ export async function removeTaskDirect(args, log) {
|
||||
error: {
|
||||
code: 'INVALID_TASK_ID',
|
||||
message: `The following tasks were not found: ${invalidTasks.join(', ')}`
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -133,8 +129,7 @@ export async function removeTaskDirect(args, log) {
|
||||
details: failedRemovals
|
||||
.map((r) => `${r.taskId}: ${r.error}`)
|
||||
.join('; ')
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -147,8 +142,7 @@ export async function removeTaskDirect(args, log) {
|
||||
failed: failedRemovals.length,
|
||||
results: results,
|
||||
tasksPath: tasksJsonPath
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
// Ensure silent mode is disabled even if an outer error occurs
|
||||
@@ -161,8 +155,7 @@ export async function removeTaskDirect(args, log) {
|
||||
error: {
|
||||
code: 'UNEXPECTED_ERROR',
|
||||
message: error.message
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,7 @@ export async function setTaskStatusDirect(args, log) {
|
||||
log.error(errorMessage);
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'MISSING_ARGUMENT', message: errorMessage },
|
||||
fromCache: false
|
||||
error: { code: 'MISSING_ARGUMENT', message: errorMessage }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -41,8 +40,7 @@ export async function setTaskStatusDirect(args, log) {
|
||||
log.error(errorMessage);
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'MISSING_TASK_ID', message: errorMessage },
|
||||
fromCache: false
|
||||
error: { code: 'MISSING_TASK_ID', message: errorMessage }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -52,8 +50,7 @@ export async function setTaskStatusDirect(args, log) {
|
||||
log.error(errorMessage);
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'MISSING_STATUS', message: errorMessage },
|
||||
fromCache: false
|
||||
error: { code: 'MISSING_STATUS', message: errorMessage }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -82,8 +79,7 @@ export async function setTaskStatusDirect(args, log) {
|
||||
taskId,
|
||||
status: newStatus,
|
||||
tasksPath: tasksPath // Return the path used
|
||||
},
|
||||
fromCache: false // This operation always modifies state and should never be cached
|
||||
}
|
||||
};
|
||||
|
||||
// If the task was completed, attempt to fetch the next task
|
||||
@@ -126,8 +122,7 @@ export async function setTaskStatusDirect(args, log) {
|
||||
error: {
|
||||
code: 'SET_STATUS_ERROR',
|
||||
message: error.message || 'Unknown error setting task status'
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
} finally {
|
||||
// ALWAYS restore normal logging in finally block
|
||||
@@ -145,8 +140,7 @@ export async function setTaskStatusDirect(args, log) {
|
||||
error: {
|
||||
code: 'SET_STATUS_ERROR',
|
||||
message: error.message || 'Unknown error setting task status'
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,8 +42,7 @@ export async function updateSubtaskByIdDirect(args, log, context = {}) {
|
||||
logWrapper.error(errorMessage);
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'MISSING_ARGUMENT', message: errorMessage },
|
||||
fromCache: false
|
||||
error: { code: 'MISSING_ARGUMENT', message: errorMessage }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -54,8 +53,7 @@ export async function updateSubtaskByIdDirect(args, log, context = {}) {
|
||||
logWrapper.error(errorMessage);
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'INVALID_SUBTASK_ID', message: errorMessage },
|
||||
fromCache: false
|
||||
error: { code: 'INVALID_SUBTASK_ID', message: errorMessage }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -65,8 +63,7 @@ export async function updateSubtaskByIdDirect(args, log, context = {}) {
|
||||
logWrapper.error(errorMessage);
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'MISSING_PROMPT', message: errorMessage },
|
||||
fromCache: false
|
||||
error: { code: 'MISSING_PROMPT', message: errorMessage }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -77,8 +74,7 @@ export async function updateSubtaskByIdDirect(args, log, context = {}) {
|
||||
log.error(errorMessage);
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'INVALID_SUBTASK_ID_TYPE', message: errorMessage },
|
||||
fromCache: false
|
||||
error: { code: 'INVALID_SUBTASK_ID_TYPE', message: errorMessage }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -88,8 +84,7 @@ export async function updateSubtaskByIdDirect(args, log, context = {}) {
|
||||
log.error(errorMessage);
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'INVALID_SUBTASK_ID_FORMAT', message: errorMessage },
|
||||
fromCache: false
|
||||
error: { code: 'INVALID_SUBTASK_ID_FORMAT', message: errorMessage }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -128,8 +123,7 @@ export async function updateSubtaskByIdDirect(args, log, context = {}) {
|
||||
logWrapper.error(message);
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'SUBTASK_NOT_FOUND', message: message },
|
||||
fromCache: false
|
||||
error: { code: 'SUBTASK_NOT_FOUND', message: message }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -146,8 +140,7 @@ export async function updateSubtaskByIdDirect(args, log, context = {}) {
|
||||
tasksPath,
|
||||
useResearch,
|
||||
telemetryData: coreResult.telemetryData
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
logWrapper.error(`Error updating subtask by ID: ${error.message}`);
|
||||
@@ -156,8 +149,7 @@ export async function updateSubtaskByIdDirect(args, log, context = {}) {
|
||||
error: {
|
||||
code: 'UPDATE_SUBTASK_CORE_ERROR',
|
||||
message: error.message || 'Unknown error updating subtask'
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
} finally {
|
||||
if (!wasSilent && isSilentMode()) {
|
||||
@@ -174,8 +166,7 @@ export async function updateSubtaskByIdDirect(args, log, context = {}) {
|
||||
error: {
|
||||
code: 'DIRECT_FUNCTION_SETUP_ERROR',
|
||||
message: error.message || 'Unknown setup error'
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,8 +42,7 @@ export async function updateTaskByIdDirect(args, log, context = {}) {
|
||||
logWrapper.error(errorMessage);
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'MISSING_ARGUMENT', message: errorMessage },
|
||||
fromCache: false
|
||||
error: { code: 'MISSING_ARGUMENT', message: errorMessage }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -54,8 +53,7 @@ export async function updateTaskByIdDirect(args, log, context = {}) {
|
||||
logWrapper.error(errorMessage);
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'MISSING_TASK_ID', message: errorMessage },
|
||||
fromCache: false
|
||||
error: { code: 'MISSING_TASK_ID', message: errorMessage }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -65,8 +63,7 @@ export async function updateTaskByIdDirect(args, log, context = {}) {
|
||||
logWrapper.error(errorMessage);
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'MISSING_PROMPT', message: errorMessage },
|
||||
fromCache: false
|
||||
error: { code: 'MISSING_PROMPT', message: errorMessage }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -84,8 +81,7 @@ export async function updateTaskByIdDirect(args, log, context = {}) {
|
||||
logWrapper.error(errorMessage);
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'INVALID_TASK_ID', message: errorMessage },
|
||||
fromCache: false
|
||||
error: { code: 'INVALID_TASK_ID', message: errorMessage }
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -137,8 +133,7 @@ export async function updateTaskByIdDirect(args, log, context = {}) {
|
||||
taskId: taskId,
|
||||
updated: false,
|
||||
telemetryData: coreResult?.telemetryData
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -155,8 +150,7 @@ export async function updateTaskByIdDirect(args, log, context = {}) {
|
||||
updated: true,
|
||||
updatedTask: coreResult.updatedTask,
|
||||
telemetryData: coreResult.telemetryData
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
logWrapper.error(`Error updating task by ID: ${error.message}`);
|
||||
@@ -165,8 +159,7 @@ export async function updateTaskByIdDirect(args, log, context = {}) {
|
||||
error: {
|
||||
code: 'UPDATE_TASK_CORE_ERROR',
|
||||
message: error.message || 'Unknown error updating task'
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
} finally {
|
||||
if (!wasSilent && isSilentMode()) {
|
||||
@@ -181,8 +174,7 @@ export async function updateTaskByIdDirect(args, log, context = {}) {
|
||||
error: {
|
||||
code: 'DIRECT_FUNCTION_SETUP_ERROR',
|
||||
message: error.message || 'Unknown setup error'
|
||||
},
|
||||
fromCache: false
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import {
|
||||
findTasksPath as coreFindTasksPath,
|
||||
findPRDPath as coreFindPrdPath,
|
||||
@@ -13,22 +12,22 @@ import { PROJECT_MARKERS } from '../../../../src/constants/paths.js';
|
||||
* This module handles session-specific path resolution for the MCP server
|
||||
*/
|
||||
|
||||
/**
|
||||
* Silent logger for MCP context to prevent console output
|
||||
*/
|
||||
const silentLogger = {
|
||||
info: () => {},
|
||||
warn: () => {},
|
||||
error: () => {},
|
||||
debug: () => {},
|
||||
success: () => {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Cache for last found project root to improve performance
|
||||
*/
|
||||
export const lastFoundProjectRoot = null;
|
||||
|
||||
/**
|
||||
* Find tasks.json file with MCP support
|
||||
* @param {string} [explicitPath] - Explicit path to tasks.json (highest priority)
|
||||
* @param {Object} [args] - Arguments object for context
|
||||
* @param {Object} [log] - Logger object to prevent console logging
|
||||
* @returns {string|null} - Resolved path to tasks.json or null if not found
|
||||
*/
|
||||
export function findTasksPathCore(explicitPath, args = null, log = null) {
|
||||
return coreFindTasksPath(explicitPath, args, log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find PRD file with MCP support
|
||||
* @param {string} [explicitPath] - Explicit path to PRD file (highest priority)
|
||||
@@ -36,25 +35,10 @@ export function findTasksPathCore(explicitPath, args = null, log = null) {
|
||||
* @param {Object} [log] - Logger object to prevent console logging
|
||||
* @returns {string|null} - Resolved path to PRD file or null if not found
|
||||
*/
|
||||
export function findPrdPath(explicitPath, args = null, log = null) {
|
||||
export function findPrdPath(explicitPath, args = null, log = silentLogger) {
|
||||
return coreFindPrdPath(explicitPath, args, log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find complexity report file with MCP support
|
||||
* @param {string} [explicitPath] - Explicit path to complexity report (highest priority)
|
||||
* @param {Object} [args] - Arguments object for context
|
||||
* @param {Object} [log] - Logger object to prevent console logging
|
||||
* @returns {string|null} - Resolved path to complexity report or null if not found
|
||||
*/
|
||||
export function findComplexityReportPathCore(
|
||||
explicitPath,
|
||||
args = null,
|
||||
log = null
|
||||
) {
|
||||
return coreFindComplexityReportPath(explicitPath, args, log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve tasks.json path from arguments
|
||||
* Prioritizes explicit path parameter, then uses fallback logic
|
||||
@@ -62,7 +46,7 @@ export function findComplexityReportPathCore(
|
||||
* @param {Object} [log] - Logger object to prevent console logging
|
||||
* @returns {string|null} - Resolved path to tasks.json or null if not found
|
||||
*/
|
||||
export function resolveTasksPath(args, log = null) {
|
||||
export function resolveTasksPath(args, log = silentLogger) {
|
||||
// Get explicit path from args.file if provided
|
||||
const explicitPath = args?.file;
|
||||
const projectRoot = args?.projectRoot;
|
||||
@@ -92,7 +76,7 @@ export function resolveTasksPath(args, log = null) {
|
||||
* @param {Object} [log] - Logger object to prevent console logging
|
||||
* @returns {string|null} - Resolved path to PRD file or null if not found
|
||||
*/
|
||||
export function resolvePrdPath(args, log = null) {
|
||||
export function resolvePrdPath(args, log = silentLogger) {
|
||||
// Get explicit path from args.input if provided
|
||||
const explicitPath = args?.input;
|
||||
const projectRoot = args?.projectRoot;
|
||||
@@ -122,7 +106,7 @@ export function resolvePrdPath(args, log = null) {
|
||||
* @param {Object} [log] - Logger object to prevent console logging
|
||||
* @returns {string|null} - Resolved path to complexity report or null if not found
|
||||
*/
|
||||
export function resolveComplexityReportPath(args, log = null) {
|
||||
export function resolveComplexityReportPath(args, log = silentLogger) {
|
||||
// Get explicit path from args.complexityReport if provided
|
||||
const explicitPath = args?.complexityReport;
|
||||
const projectRoot = args?.projectRoot;
|
||||
@@ -184,7 +168,7 @@ export function findProjectRoot(startDir) {
|
||||
* @param {Object} [log] - Log function to prevent console logging
|
||||
* @returns {string|null} - Resolved path to tasks.json or null if not found
|
||||
*/
|
||||
export function findTasksPath(args, log = null) {
|
||||
export function findTasksPath(args, log = silentLogger) {
|
||||
return resolveTasksPath(args, log);
|
||||
}
|
||||
|
||||
@@ -194,7 +178,7 @@ export function findTasksPath(args, log = null) {
|
||||
* @param {Object} [log] - Log function to prevent console logging
|
||||
* @returns {string|null} - Resolved path to complexity report or null if not found
|
||||
*/
|
||||
export function findComplexityReportPath(args, log = null) {
|
||||
export function findComplexityReportPath(args, log = silentLogger) {
|
||||
return resolveComplexityReportPath(args, log);
|
||||
}
|
||||
|
||||
@@ -205,7 +189,7 @@ export function findComplexityReportPath(args, log = null) {
|
||||
* @param {Object} [log] - Logger object to prevent console logging
|
||||
* @returns {string|null} - Resolved path to PRD file or null if not found
|
||||
*/
|
||||
export function findPRDPath(explicitPath, args = null, log = null) {
|
||||
export function findPRDPath(explicitPath, args = null, log = silentLogger) {
|
||||
return findPrdPath(explicitPath, args, log);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user