fix: replace tool parameter inputs with root directory paths (#147)

* wip: replace tool parameter inputs with root directory paths

* fix: moved path resolving responsibility to tools

- made path in parameters to optional for AI
- internalised path resolving using session roots

* chore: update package-lock.json

* chore: fix regressions and fix CI

* fix: make projectRoot required

* fix: add-task tool

* fix: updateTask tool

* fix: remove reportProgress

* chore: cleanup

* fix: expand-task tool

* chore: remove usless logs

* fix: dependency manager logging in mcp server
This commit is contained in:
Ralph Khreish
2025-04-11 18:57:43 +02:00
committed by GitHub
parent 30e6d47577
commit d3d9dc6ebe
51 changed files with 9476 additions and 8918 deletions

View File

@@ -4,7 +4,6 @@
*/
import { addDependency } from '../../../../scripts/modules/dependency-manager.js';
import { findTasksJsonPath } from '../utils/path-utils.js';
import {
enableSilentMode,
disableSilentMode
@@ -14,19 +13,32 @@ import {
* Direct function wrapper for addDependency with error handling.
*
* @param {Object} args - Command arguments
* @param {string} args.tasksJsonPath - Explicit path to the tasks.json file.
* @param {string|number} args.id - Task ID to add dependency to
* @param {string|number} args.dependsOn - Task ID that will become a dependency
* @param {string} [args.file] - Path to the tasks file
* @param {string} [args.projectRoot] - Project root directory
* @param {Object} log - Logger object
* @returns {Promise<Object>} - Result object with success status and data/error information
*/
export async function addDependencyDirect(args, log) {
// Destructure expected args
const { tasksJsonPath, id, dependsOn } = args;
try {
log.info(`Adding dependency with args: ${JSON.stringify(args)}`);
// Check if tasksJsonPath was provided
if (!tasksJsonPath) {
log.error('addDependencyDirect called without tasksJsonPath');
return {
success: false,
error: {
code: 'MISSING_ARGUMENT',
message: 'tasksJsonPath is required'
}
};
}
// Validate required parameters
if (!args.id) {
if (!id) {
return {
success: false,
error: {
@@ -36,7 +48,7 @@ export async function addDependencyDirect(args, log) {
};
}
if (!args.dependsOn) {
if (!dependsOn) {
return {
success: false,
error: {
@@ -46,18 +58,16 @@ export async function addDependencyDirect(args, log) {
};
}
// Find the tasks.json path
const tasksPath = findTasksJsonPath(args, log);
// Use provided path
const tasksPath = tasksJsonPath;
// Format IDs for the core function
const taskId =
args.id.includes && args.id.includes('.')
? args.id
: parseInt(args.id, 10);
id && id.includes && id.includes('.') ? id : parseInt(id, 10);
const dependencyId =
args.dependsOn.includes && args.dependsOn.includes('.')
? args.dependsOn
: parseInt(args.dependsOn, 10);
dependsOn && dependsOn.includes && dependsOn.includes('.')
? dependsOn
: parseInt(dependsOn, 10);
log.info(
`Adding dependency: task ${taskId} will depend on ${dependencyId}`
@@ -66,7 +76,7 @@ export async function addDependencyDirect(args, log) {
// Enable silent mode to prevent console logs from interfering with JSON response
enableSilentMode();
// Call the core function
// Call the core function using the provided path
await addDependency(tasksPath, taskId, dependencyId);
// Restore normal logging