Implement fix-dependencies MCP command for automatically fixing invalid dependencies

This commit is contained in:
Eyal Toledano
2025-03-31 14:01:49 -04:00
parent 535fb5be71
commit d06e45bf12
5 changed files with 97 additions and 2 deletions

View File

@@ -0,0 +1,55 @@
/**
* Direct function wrapper for fixDependenciesCommand
*/
import { fixDependenciesCommand } from '../../../../scripts/modules/dependency-manager.js';
import { findTasksJsonPath } from '../utils/path-utils.js';
import fs from 'fs';
/**
* Fix invalid dependencies in tasks.json automatically
* @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 fixDependenciesDirect(args, log) {
try {
log.info(`Fixing invalid 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 fixDependenciesCommand(tasksPath);
return {
success: true,
data: {
message: 'Dependencies fixed successfully',
tasksPath
}
};
} catch (error) {
log.error(`Error fixing dependencies: ${error.message}`);
return {
success: false,
error: {
code: 'FIX_DEPENDENCIES_ERROR',
message: error.message
}
};
}
}