fix(analyze-complexity): pass projectRoot through analyze-complexity flow

Modified analyze-task-complexity.js core function, direct function, and analyze.js tool to correctly pass projectRoot. Fixed import error in tools/index.js. Added debug logging to _resolveApiKey in ai-services-unified.js. This enables the .env API key fallback for analyze_project_complexity.
This commit is contained in:
Eyal Toledano
2025-05-01 14:18:44 -04:00
parent 2a07d366be
commit c7158d4910
5 changed files with 401 additions and 344 deletions

View File

@@ -46,6 +46,7 @@ Do not include any explanatory text, markdown formatting, or code block markers
* @param {string} options.output - Path to report output file
* @param {string|number} [options.threshold] - Complexity threshold
* @param {boolean} [options.research] - Use research role
* @param {string} [options.projectRoot] - Project root path (for MCP/env fallback).
* @param {Object} [options._filteredTasksData] - Pre-filtered task data (internal use)
* @param {number} [options._originalTaskCount] - Original task count (internal use)
* @param {Object} context - Context object, potentially containing session and mcpLog
@@ -59,6 +60,7 @@ async function analyzeTaskComplexity(options, context = {}) {
const outputPath = options.output || 'scripts/task-complexity-report.json';
const thresholdScore = parseFloat(options.threshold || '5');
const useResearch = options.research || false;
const projectRoot = options.projectRoot;
const outputFormat = mcpLog ? 'json' : 'text';
@@ -209,15 +211,13 @@ async function analyzeTaskComplexity(options, context = {}) {
const role = useResearch ? 'research' : 'main';
reportLog(`Using AI service with role: ${role}`, 'info');
// *** CHANGED: Use generateTextService ***
fullResponse = await generateTextService({
prompt,
systemPrompt,
role,
session
// No schema or objectName needed
session,
projectRoot
});
// *** End Service Call Change ***
reportLog(
'Successfully received text response via AI service',