fix(update): pass projectRoot through update command flow

Modified ai-services-unified.js, update.js tool, and update-tasks.js direct function to correctly pass projectRoot. This enables the .env file API key fallback mechanism for the update command when running via MCP, ensuring consistent key resolution with the CLI context.
This commit is contained in:
Eyal Toledano
2025-05-01 13:45:11 -04:00
parent 37ee3af7a5
commit 8f49b0198a
4 changed files with 48 additions and 25 deletions

View File

@@ -20,7 +20,7 @@ import { createLogWrapper } from '../../tools/utils.js';
*/
export async function updateTasksDirect(args, log, context = {}) {
const { session } = context; // Extract session
const { tasksJsonPath, from, prompt, research } = args;
const { tasksJsonPath, from, prompt, research, projectRoot } = args;
// Create the standard logger wrapper
const logWrapper = {
@@ -85,21 +85,23 @@ export async function updateTasksDirect(args, log, context = {}) {
const useResearch = research === true;
// --- End Input Validation ---
log.info(`Updating tasks from ID ${fromId}. Research: ${useResearch}`);
log.info(
`Updating tasks from ID ${fromId}. Research: ${useResearch}. Project Root: ${projectRoot}`
);
enableSilentMode(); // Enable silent mode
try {
// Create logger wrapper using the utility
const mcpLog = createLogWrapper(log);
// Execute core updateTasks function, passing session context
// Execute core updateTasks function, passing session context AND projectRoot
await updateTasks(
tasksJsonPath,
fromId,
prompt,
useResearch,
// Pass context with logger wrapper and session
{ mcpLog, session },
// Pass context with logger wrapper, session, AND projectRoot
{ mcpLog, session, projectRoot },
'json' // Explicitly request JSON format for MCP
);

View File

@@ -70,7 +70,8 @@ export function registerUpdateTool(server) {
tasksJsonPath: tasksJsonPath,
from: args.from,
prompt: args.prompt,
research: args.research
research: args.research,
projectRoot: rootFolder
},
log,
{ session }