Recovers lost files and commits work from the past 5-6 days. Holy shit that was a close call.

This commit is contained in:
Eyal Toledano
2025-04-07 19:55:03 -04:00
parent b3e7ebefd9
commit b7580e038d
42 changed files with 5180 additions and 1988 deletions

View File

@@ -10,6 +10,8 @@ import {
getProjectRootFromSession
} from "./utils.js";
import { expandTaskDirect } from "../core/task-master-core.js";
import fs from "fs";
import path from "path";
/**
* Register the expand-task tool with the MCP server
@@ -21,10 +23,9 @@ export function registerExpandTaskTool(server) {
description: "Expand a task into subtasks for detailed implementation",
parameters: z.object({
id: z.string().describe("ID of task to expand"),
num: z.union([z.number(), z.string()]).optional().describe("Number of subtasks to generate"),
num: z.union([z.string(), z.number()]).optional().describe("Number of subtasks to generate"),
research: z.boolean().optional().describe("Use Perplexity AI for research-backed generation"),
prompt: z.string().optional().describe("Additional context for subtask generation"),
force: z.boolean().optional().describe("Force regeneration even for tasks that already have subtasks"),
file: z.string().optional().describe("Path to the tasks file"),
projectRoot: z
.string()
@@ -33,11 +34,11 @@ export function registerExpandTaskTool(server) {
"Root directory of the project (default: current working directory)"
),
}),
execute: async (args, { log, session, reportProgress }) => {
execute: async (args, { log, reportProgress, session }) => {
try {
log.info(`Expanding task with args: ${JSON.stringify(args)}`);
// await reportProgress({ progress: 0 });
log.info(`Starting expand-task with args: ${JSON.stringify(args)}`);
// Get project root from session
let rootFolder = getProjectRootFromSession(session, log);
if (!rootFolder && args.projectRoot) {
@@ -45,19 +46,27 @@ export function registerExpandTaskTool(server) {
log.info(`Using project root from args as fallback: ${rootFolder}`);
}
const result = await expandTaskDirect({
projectRoot: rootFolder,
...args
}, log/*, { reportProgress, mcpLog: log, session}*/);
log.info(`Project root resolved to: ${rootFolder}`);
// await reportProgress({ progress: 100 });
// Check for tasks.json in the standard locations
const tasksJsonPath = path.join(rootFolder, 'tasks', 'tasks.json');
if (result.success) {
log.info(`Successfully expanded task with ID ${args.id}`);
if (fs.existsSync(tasksJsonPath)) {
log.info(`Found tasks.json at ${tasksJsonPath}`);
// Add the file parameter directly to args
args.file = tasksJsonPath;
} else {
log.error(`Failed to expand task: ${result.error?.message || 'Unknown error'}`);
log.warn(`Could not find tasks.json at ${tasksJsonPath}`);
}
// Call direct function with only session in the context, not reportProgress
// Use the pattern recommended in the MCP guidelines
const result = await expandTaskDirect({
...args,
projectRoot: rootFolder
}, log, { session }); // Only pass session, NOT reportProgress
// Return the result
return handleApiResult(result, log, 'Error expanding task');
} catch (error) {
log.error(`Error in expand task tool: ${error.message}`);