Implement validate-dependencies MCP command for checking dependency validity

This commit is contained in:
Eyal Toledano
2025-03-31 13:55:07 -04:00
parent fba6131db7
commit 535fb5be71
7 changed files with 127 additions and 24 deletions

View File

@@ -0,0 +1,55 @@
/**
* Direct function wrapper for validateDependenciesCommand
*/
import { validateDependenciesCommand } from '../../../../scripts/modules/dependency-manager.js';
import { findTasksJsonPath } from '../utils/path-utils.js';
import fs from 'fs';
/**
* Validate dependencies in tasks.json
* @param {Object} args - Function arguments
* @param {string} [args.file] - Path to the tasks file
* @param {string} [args.projectRoot] - Project root directory
* @param {Object} log - Logger object
* @returns {Promise<{success: boolean, data?: Object, error?: {code: string, message: string}}>}
*/
export async function validateDependenciesDirect(args, log) {
try {
log.info(`Validating dependencies in tasks...`);
// Determine the tasks file path
const tasksPath = args.file || await findTasksJsonPath(args.projectRoot);
// Verify the file exists
if (!fs.existsSync(tasksPath)) {
return {
success: false,
error: {
code: 'FILE_NOT_FOUND',
message: `Tasks file not found at ${tasksPath}`
}
};
}
// Call the original command function
await validateDependenciesCommand(tasksPath);
return {
success: true,
data: {
message: 'Dependencies validated successfully',
tasksPath
}
};
} catch (error) {
log.error(`Error validating dependencies: ${error.message}`);
return {
success: false,
error: {
code: 'VALIDATION_ERROR',
message: error.message
}
};
}
}

View File

@@ -23,6 +23,7 @@ import { analyzeTaskComplexityDirect } from './direct-functions/analyze-task-com
import { clearSubtasksDirect } from './direct-functions/clear-subtasks.js';
import { expandAllTasksDirect } from './direct-functions/expand-all-tasks.js';
import { removeDependencyDirect } from './direct-functions/remove-dependency.js';
import { validateDependenciesDirect } from './direct-functions/validate-dependencies.js';
// Re-export utility functions
export { findTasksJsonPath } from './utils/path-utils.js';
@@ -46,7 +47,8 @@ export const directFunctions = new Map([
['analyzeTaskComplexityDirect', analyzeTaskComplexityDirect],
['clearSubtasksDirect', clearSubtasksDirect],
['expandAllTasksDirect', expandAllTasksDirect],
['removeDependencyDirect', removeDependencyDirect]
['removeDependencyDirect', removeDependencyDirect],
['validateDependenciesDirect', validateDependenciesDirect]
]);
// Re-export all direct function implementations
@@ -68,5 +70,6 @@ export {
analyzeTaskComplexityDirect,
clearSubtasksDirect,
expandAllTasksDirect,
removeDependencyDirect
removeDependencyDirect,
validateDependenciesDirect
};