fix(tasks): ensure list tasks triggers silent migration if necessary.

This commit is contained in:
Eyal Toledano
2025-06-12 18:27:49 -04:00
parent 9efbd38f10
commit b28479a09d
7 changed files with 130 additions and 18 deletions

View File

@@ -27,6 +27,7 @@ import {
* @param {boolean} withSubtasks - Whether to show subtasks
* @param {string} outputFormat - Output format (text or json)
* @param {string} tag - Optional tag to override current tag resolution
* @param {Object} context - Optional context object containing projectRoot and other options
* @returns {Object} - Task list result for json format
*/
function listTasks(
@@ -35,10 +36,13 @@ function listTasks(
reportPath = null,
withSubtasks = false,
outputFormat = 'text',
tag = null
tag = null,
context = {}
) {
try {
const data = readJSON(tasksPath, null, tag); // Pass tag to readJSON
// Extract projectRoot from context if provided
const projectRoot = context.projectRoot || null;
const data = readJSON(tasksPath, projectRoot, tag); // Pass projectRoot to readJSON
if (!data || !data.tasks) {
throw new Error(`No valid tasks found in ${tasksPath}`);
}