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 533f5cdc25
commit 678262df22
51 changed files with 9476 additions and 8918 deletions

View File

@@ -4,7 +4,6 @@
*/
import { addTask } from '../../../../scripts/modules/task-manager.js';
import { findTasksJsonPath } from '../utils/path-utils.js';
import {
enableSilentMode,
disableSilentMode
@@ -38,12 +37,27 @@ import {
* @returns {Promise<Object>} - Result object { success: boolean, data?: any, error?: { code: string, message: string } }
*/
export async function addTaskDirect(args, log, context = {}) {
// Destructure expected args
const { tasksJsonPath, prompt, dependencies, priority, research } = args;
try {
// Enable silent mode to prevent console logs from interfering with JSON response
enableSilentMode();
// Find the tasks.json path
const tasksPath = findTasksJsonPath(args, log);
// Check if tasksJsonPath was provided
if (!tasksJsonPath) {
log.error('addTaskDirect called without tasksJsonPath');
disableSilentMode(); // Disable before returning
return {
success: false,
error: {
code: 'MISSING_ARGUMENT',
message: 'tasksJsonPath is required'
}
};
}
// Use provided path
const tasksPath = tasksJsonPath;
// Check if this is manual task creation or AI-driven task creation
const isManualCreation = args.title && args.description;
@@ -65,15 +79,15 @@ export async function addTaskDirect(args, log, context = {}) {
}
// Extract and prepare parameters
const prompt = args.prompt;
const dependencies = Array.isArray(args.dependencies)
? args.dependencies
: args.dependencies
? String(args.dependencies)
const taskPrompt = prompt;
const taskDependencies = Array.isArray(dependencies)
? dependencies
: dependencies
? String(dependencies)
.split(',')
.map((id) => parseInt(id.trim(), 10))
: [];
const priority = args.priority || 'medium';
const taskPriority = priority || 'medium';
// Extract context parameters for advanced functionality
const { session } = context;
@@ -90,14 +104,14 @@ export async function addTaskDirect(args, log, context = {}) {
};
log.info(
`Adding new task manually with title: "${args.title}", dependencies: [${dependencies.join(', ')}], priority: ${priority}`
`Adding new task manually with title: "${args.title}", dependencies: [${taskDependencies.join(', ')}], priority: ${priority}`
);
// Call the addTask function with manual task data
const newTaskId = await addTask(
tasksPath,
null, // No prompt needed for manual creation
dependencies,
taskDependencies,
priority,
{
mcpLog: log,
@@ -121,7 +135,7 @@ export async function addTaskDirect(args, log, context = {}) {
} else {
// AI-driven task creation
log.info(
`Adding new task with prompt: "${prompt}", dependencies: [${dependencies.join(', ')}], priority: ${priority}`
`Adding new task with prompt: "${prompt}", dependencies: [${taskDependencies.join(', ')}], priority: ${priority}`
);
// Initialize AI client with session environment
@@ -207,7 +221,7 @@ export async function addTaskDirect(args, log, context = {}) {
const newTaskId = await addTask(
tasksPath,
prompt,
dependencies,
taskDependencies,
priority,
{
mcpLog: log,