fix: include tagInfo in AI service responses for MCP tools
- Update all core functions that call AI services to extract and return tagInfo - Update all direct functions to include tagInfo in MCP response data - Fixes issue where add_task, expand_task, and other AI commands were not including current tag and available tags information - tagInfo includes currentTag from state.json and availableTags list - Ensures tagged task lists system information is properly propagated through the full chain: AI service -> core function -> direct function -> MCP client
This commit is contained in:
@@ -95,6 +95,7 @@ export async function addTaskDirect(args, log, context = {}) {
|
||||
let manualTaskData = null;
|
||||
let newTaskId;
|
||||
let telemetryData;
|
||||
let tagInfo;
|
||||
|
||||
if (isManualCreation) {
|
||||
// Create manual task data object
|
||||
@@ -129,6 +130,7 @@ export async function addTaskDirect(args, log, context = {}) {
|
||||
);
|
||||
newTaskId = result.newTaskId;
|
||||
telemetryData = result.telemetryData;
|
||||
tagInfo = result.tagInfo;
|
||||
} else {
|
||||
// AI-driven task creation
|
||||
log.info(
|
||||
@@ -154,6 +156,7 @@ export async function addTaskDirect(args, log, context = {}) {
|
||||
);
|
||||
newTaskId = result.newTaskId;
|
||||
telemetryData = result.telemetryData;
|
||||
tagInfo = result.tagInfo;
|
||||
}
|
||||
|
||||
// Restore normal logging
|
||||
@@ -164,7 +167,8 @@ export async function addTaskDirect(args, log, context = {}) {
|
||||
data: {
|
||||
taskId: newTaskId,
|
||||
message: `Successfully added new task #${newTaskId}`,
|
||||
telemetryData: telemetryData
|
||||
telemetryData: telemetryData,
|
||||
tagInfo: tagInfo
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
|
||||
@@ -196,7 +196,8 @@ export async function analyzeTaskComplexityDirect(args, log, context = {}) {
|
||||
lowComplexityTasks
|
||||
},
|
||||
fullReport: coreResult.report,
|
||||
telemetryData: coreResult.telemetryData
|
||||
telemetryData: coreResult.telemetryData,
|
||||
tagInfo: coreResult.tagInfo
|
||||
}
|
||||
};
|
||||
} catch (parseError) {
|
||||
|
||||
@@ -225,7 +225,8 @@ export async function expandTaskDirect(args, log, context = {}) {
|
||||
task: coreResult.task,
|
||||
subtasksAdded,
|
||||
hasExistingSubtasks,
|
||||
telemetryData: coreResult.telemetryData
|
||||
telemetryData: coreResult.telemetryData,
|
||||
tagInfo: coreResult.tagInfo
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
|
||||
@@ -170,7 +170,8 @@ export async function parsePRDDirect(args, log, context = {}) {
|
||||
data: {
|
||||
message: successMsg,
|
||||
outputPath: result.tasksPath,
|
||||
telemetryData: result.telemetryData
|
||||
telemetryData: result.telemetryData,
|
||||
tagInfo: result.tagInfo
|
||||
}
|
||||
};
|
||||
} else {
|
||||
|
||||
@@ -140,7 +140,8 @@ export async function researchDirect(args, log, context = {}) {
|
||||
userPromptTokens: result.userPromptTokens,
|
||||
totalInputTokens: result.totalInputTokens,
|
||||
detailLevel: result.detailLevel,
|
||||
telemetryData: result.telemetryData
|
||||
telemetryData: result.telemetryData,
|
||||
tagInfo: result.tagInfo
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
|
||||
@@ -139,7 +139,8 @@ export async function updateSubtaskByIdDirect(args, log, context = {}) {
|
||||
subtask: coreResult.updatedSubtask,
|
||||
tasksPath,
|
||||
useResearch,
|
||||
telemetryData: coreResult.telemetryData
|
||||
telemetryData: coreResult.telemetryData,
|
||||
tagInfo: coreResult.tagInfo
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
|
||||
@@ -76,7 +76,7 @@ export async function updateTaskByIdDirect(args, log, context = {}) {
|
||||
} else {
|
||||
// Parse as integer for main task IDs
|
||||
taskId = parseInt(id, 10);
|
||||
if (isNaN(taskId)) {
|
||||
if (Number.isNaN(taskId)) {
|
||||
const errorMessage = `Invalid task ID: ${id}. Task ID must be a positive integer or subtask ID (e.g., "5.2").`;
|
||||
logWrapper.error(errorMessage);
|
||||
return {
|
||||
@@ -132,7 +132,8 @@ export async function updateTaskByIdDirect(args, log, context = {}) {
|
||||
message: message,
|
||||
taskId: taskId,
|
||||
updated: false,
|
||||
telemetryData: coreResult?.telemetryData
|
||||
telemetryData: coreResult?.telemetryData,
|
||||
tagInfo: coreResult?.tagInfo
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -149,7 +150,8 @@ export async function updateTaskByIdDirect(args, log, context = {}) {
|
||||
useResearch: useResearch,
|
||||
updated: true,
|
||||
updatedTask: coreResult.updatedTask,
|
||||
telemetryData: coreResult.telemetryData
|
||||
telemetryData: coreResult.telemetryData,
|
||||
tagInfo: coreResult.tagInfo
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
|
||||
@@ -90,7 +90,8 @@ export async function updateTasksDirect(args, log, context = {}) {
|
||||
message: `Successfully updated ${result.updatedTasks.length} tasks.`,
|
||||
tasksPath: tasksJsonPath,
|
||||
updatedCount: result.updatedTasks.length,
|
||||
telemetryData: result.telemetryData
|
||||
telemetryData: result.telemetryData,
|
||||
tagInfo: result.tagInfo
|
||||
}
|
||||
};
|
||||
} else {
|
||||
|
||||
@@ -624,7 +624,8 @@ async function addTask(
|
||||
);
|
||||
return {
|
||||
newTaskId: newTaskId,
|
||||
telemetryData: aiServiceResponse ? aiServiceResponse.telemetryData : null
|
||||
telemetryData: aiServiceResponse ? aiServiceResponse.telemetryData : null,
|
||||
tagInfo: aiServiceResponse ? aiServiceResponse.tagInfo : null
|
||||
};
|
||||
} catch (error) {
|
||||
// Stop any loading indicator on error
|
||||
|
||||
@@ -644,7 +644,8 @@ async function analyzeTaskComplexity(options, context = {}) {
|
||||
|
||||
return {
|
||||
report: report,
|
||||
telemetryData: aiServiceResponse?.telemetryData
|
||||
telemetryData: aiServiceResponse?.telemetryData,
|
||||
tagInfo: aiServiceResponse?.tagInfo
|
||||
};
|
||||
} catch (aiError) {
|
||||
if (loadingIndicator) stopLoadingIndicator(loadingIndicator);
|
||||
|
||||
@@ -686,7 +686,8 @@ async function expandTask(
|
||||
// Return the updated task object AND telemetry data
|
||||
return {
|
||||
task,
|
||||
telemetryData: aiServiceResponse?.telemetryData
|
||||
telemetryData: aiServiceResponse?.telemetryData,
|
||||
tagInfo: aiServiceResponse?.tagInfo
|
||||
};
|
||||
} catch (error) {
|
||||
// Catches errors from file reading, parsing, AI call etc.
|
||||
|
||||
@@ -359,7 +359,8 @@ Guidelines:
|
||||
return {
|
||||
success: true,
|
||||
tasksPath,
|
||||
telemetryData: aiServiceResponse?.telemetryData
|
||||
telemetryData: aiServiceResponse?.telemetryData,
|
||||
tagInfo: aiServiceResponse?.tagInfo
|
||||
};
|
||||
} catch (error) {
|
||||
report(`Error parsing PRD: ${error.message}`, 'error');
|
||||
|
||||
@@ -244,6 +244,7 @@ async function performResearch(
|
||||
|
||||
const researchResult = aiResult.mainResult;
|
||||
const telemetryData = aiResult.telemetryData;
|
||||
const tagInfo = aiResult.tagInfo;
|
||||
|
||||
// Format and display results
|
||||
if (outputFormat === 'text') {
|
||||
@@ -285,7 +286,8 @@ async function performResearch(
|
||||
userPromptTokens,
|
||||
totalInputTokens,
|
||||
detailLevel,
|
||||
telemetryData
|
||||
telemetryData,
|
||||
tagInfo
|
||||
};
|
||||
} catch (error) {
|
||||
logFn.error(`Research query failed: ${error.message}`);
|
||||
|
||||
@@ -366,7 +366,8 @@ Output Requirements:
|
||||
|
||||
return {
|
||||
updatedSubtask: updatedSubtask,
|
||||
telemetryData: aiServiceResponse.telemetryData
|
||||
telemetryData: aiServiceResponse.telemetryData,
|
||||
tagInfo: aiServiceResponse.tagInfo
|
||||
};
|
||||
} catch (error) {
|
||||
if (outputFormat === 'text' && loadingIndicator) {
|
||||
|
||||
@@ -535,7 +535,8 @@ The changes described in the prompt should be thoughtfully applied to make the t
|
||||
// --- Return Success with Telemetry ---
|
||||
return {
|
||||
updatedTask: updatedTask, // Return the updated task object
|
||||
telemetryData: aiServiceResponse.telemetryData // <<< ADD telemetryData
|
||||
telemetryData: aiServiceResponse.telemetryData, // <<< ADD telemetryData
|
||||
tagInfo: aiServiceResponse.tagInfo
|
||||
};
|
||||
} catch (error) {
|
||||
// Catch errors from generateTextService
|
||||
|
||||
@@ -486,7 +486,8 @@ The changes described in the prompt should be applied to ALL tasks in the list.`
|
||||
return {
|
||||
success: true,
|
||||
updatedTasks: parsedUpdatedTasks,
|
||||
telemetryData: aiServiceResponse.telemetryData
|
||||
telemetryData: aiServiceResponse.telemetryData,
|
||||
tagInfo: aiServiceResponse.tagInfo
|
||||
};
|
||||
} catch (error) {
|
||||
if (loadingIndicator) stopLoadingIndicator(loadingIndicator);
|
||||
|
||||
Reference in New Issue
Block a user