v017 polish (#778)

* fix(research, tasks): Make research command and task updates tag-aware

* refactor(tasks): Prevent automatic task file generation across other locations

This commit refactors several core task management functions to prevent them from automatically regenerating individual task files after modifying the main `tasks.json`.

Previously, operations like `add-task`, `clear-subtasks`, `expand-task`, and `update-task-by-id` would immediately trigger `generateTaskFiles`. This could be slow and was often unnecessary.

The calls to `generateTaskFiles` have been removed or commented out from the core task functions. Users should now run `task-master generate` explicitly to update their individual task files.

Additionally, this commit includes fixes to the `move` command to make it fully tag-aware.

* fix: move and clear subtasks mcp commands

* chore: fix format

* chore: fix unit tests

---------

Co-authored-by: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com>
This commit is contained in:
Eyal Toledano
2025-06-14 20:37:25 -04:00
committed by Ralph Khreish
parent 44eba3f7d1
commit 5119cd2d8e
24 changed files with 1076 additions and 312 deletions

View File

@@ -12,7 +12,8 @@ import {
truncate,
isSilentMode,
flattenTasksWithSubtasks,
findProjectRoot
findProjectRoot,
getCurrentTag
} from '../utils.js';
import {
@@ -23,11 +24,7 @@ import {
} from '../ui.js';
import { generateTextService } from '../ai-services-unified.js';
import {
getDebugFlag,
isApiKeySet // Keep this check
} from '../config-manager.js';
import generateTaskFiles from './generate-task-files.js';
import { getDebugFlag, isApiKeySet } from '../config-manager.js';
import { ContextGatherer } from '../utils/contextGatherer.js';
import { FuzzyTaskSearch } from '../utils/fuzzyTaskSearch.js';
@@ -223,7 +220,7 @@ async function updateTaskById(
outputFormat = 'text',
appendMode = false
) {
const { session, mcpLog, projectRoot: providedProjectRoot } = context;
const { session, mcpLog, projectRoot: providedProjectRoot, tag } = context;
const logFn = mcpLog || consoleLog;
const isMCP = !!mcpLog;
@@ -268,8 +265,11 @@ async function updateTaskById(
throw new Error('Could not determine project root directory');
}
// Determine the tag to use
const currentTag = tag || getCurrentTag(projectRoot) || 'master';
// --- Task Loading and Status Check (Keep existing) ---
const data = readJSON(tasksPath, projectRoot);
const data = readJSON(tasksPath, projectRoot, currentTag);
if (!data || !data.tasks)
throw new Error(`No valid tasks found in ${tasksPath}.`);
const taskIndex = data.tasks.findIndex((task) => task.id === taskId);
@@ -510,7 +510,7 @@ The changes described in the prompt should be thoughtfully applied to make the t
// Write the updated task back to file
data.tasks[taskIndex] = taskToUpdate;
writeJSON(tasksPath, data);
writeJSON(tasksPath, data, projectRoot, currentTag);
report('success', `Successfully appended to task ${taskId}`);
// Display success message for CLI
@@ -624,7 +624,7 @@ The changes described in the prompt should be thoughtfully applied to make the t
// --- End Update Task Data ---
// --- Write File and Generate (Unchanged) ---
writeJSON(tasksPath, data);
writeJSON(tasksPath, data, projectRoot, currentTag);
report('success', `Successfully updated task ${taskId}`);
// await generateTaskFiles(tasksPath, path.dirname(tasksPath));
// --- End Write File ---