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 40df57f969
commit 2a07d366be
4 changed files with 48 additions and 25 deletions

View File

@@ -21,6 +21,7 @@ import {
import { getDebugFlag } from '../config-manager.js';
import generateTaskFiles from './generate-task-files.js';
import { generateTextService } from '../ai-services-unified.js';
import { getModelConfiguration } from './models.js';
// Zod schema for validating the structure of tasks AFTER parsing
const updatedTaskSchema = z
@@ -173,7 +174,7 @@ async function updateTasks(
context = {},
outputFormat = 'text' // Default to text for CLI
) {
const { session, mcpLog } = context;
const { session, mcpLog, projectRoot } = context;
// Use mcpLog if available, otherwise use the imported consoleLog function
const logFn = mcpLog || consoleLog;
// Flag to easily check which logger type we have
@@ -312,7 +313,8 @@ The changes described in the prompt should be applied to ALL tasks in the list.`
prompt: userPrompt,
systemPrompt: systemPrompt,
role,
session
session,
projectRoot
});
if (isMCP) logFn.info('Successfully received text response');
else