Simplified implementation
This commit is contained in:
committed by
Ralph Khreish
parent
ef23beac0d
commit
3f31c34f8d
@@ -22,8 +22,7 @@ import {
|
|||||||
truncate,
|
truncate,
|
||||||
ensureTagMetadata,
|
ensureTagMetadata,
|
||||||
performCompleteTagMigration,
|
performCompleteTagMigration,
|
||||||
markMigrationForNotice,
|
markMigrationForNotice
|
||||||
normalizeTaskIds
|
|
||||||
} from '../utils.js';
|
} from '../utils.js';
|
||||||
import { generateObjectService } from '../ai-services-unified.js';
|
import { generateObjectService } from '../ai-services-unified.js';
|
||||||
import { getDefaultPriority } from '../config-manager.js';
|
import { getDefaultPriority } from '../config-manager.js';
|
||||||
@@ -70,7 +69,6 @@ function getAllTasks(rawData) {
|
|||||||
rawData[tagName] &&
|
rawData[tagName] &&
|
||||||
Array.isArray(rawData[tagName].tasks)
|
Array.isArray(rawData[tagName].tasks)
|
||||||
) {
|
) {
|
||||||
normalizeTaskIds(rawData[tagName].tasks);
|
|
||||||
allTasks = allTasks.concat(rawData[tagName].tasks);
|
allTasks = allTasks.concat(rawData[tagName].tasks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -308,8 +306,6 @@ async function addTask(
|
|||||||
|
|
||||||
// Find the highest task ID *within the target tag* to determine the next ID
|
// Find the highest task ID *within the target tag* to determine the next ID
|
||||||
const tasksInTargetTag = rawData[targetTag].tasks;
|
const tasksInTargetTag = rawData[targetTag].tasks;
|
||||||
|
|
||||||
normalizeTaskIds(tasksInTargetTag);
|
|
||||||
const highestId =
|
const highestId =
|
||||||
tasksInTargetTag.length > 0
|
tasksInTargetTag.length > 0
|
||||||
? Math.max(...tasksInTargetTag.map((t) => t.id))
|
? Math.max(...tasksInTargetTag.map((t) => t.id))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { log, readJSON, writeJSON, setTasksForTag, normalizeTaskIds } from '../utils.js';
|
import { log, readJSON, writeJSON, setTasksForTag } from '../utils.js';
|
||||||
import { isTaskDependentOn } from '../task-manager.js';
|
import { isTaskDependentOn } from '../task-manager.js';
|
||||||
import generateTaskFiles from './generate-task-files.js';
|
import generateTaskFiles from './generate-task-files.js';
|
||||||
|
|
||||||
@@ -79,8 +79,6 @@ async function moveTask(
|
|||||||
|
|
||||||
// Get the tasks for the current tag
|
// Get the tasks for the current tag
|
||||||
const tasks = rawData[tag].tasks;
|
const tasks = rawData[tag].tasks;
|
||||||
|
|
||||||
normalizeTaskIds(tasks);
|
|
||||||
|
|
||||||
log(
|
log(
|
||||||
'info',
|
'info',
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import {
|
|||||||
readJSON,
|
readJSON,
|
||||||
writeJSON,
|
writeJSON,
|
||||||
findTaskById,
|
findTaskById,
|
||||||
ensureTagMetadata,
|
ensureTagMetadata
|
||||||
normalizeTaskIds
|
|
||||||
} from '../utils.js';
|
} from '../utils.js';
|
||||||
import { displayBanner } from '../ui.js';
|
import { displayBanner } from '../ui.js';
|
||||||
import { validateTaskDependencies } from '../dependency-manager.js';
|
import { validateTaskDependencies } from '../dependency-manager.js';
|
||||||
@@ -77,8 +76,6 @@ async function setTaskStatus(tasksPath, taskIdInput, newStatus, options = {}) {
|
|||||||
tag,
|
tag,
|
||||||
_rawTaggedData: rawData
|
_rawTaggedData: rawData
|
||||||
};
|
};
|
||||||
|
|
||||||
normalizeTaskIds(data.tasks);
|
|
||||||
|
|
||||||
if (!data || !data.tasks) {
|
if (!data || !data.tasks) {
|
||||||
throw new Error(`No valid tasks found in ${tasksPath}`);
|
throw new Error(`No valid tasks found in ${tasksPath}`);
|
||||||
|
|||||||
@@ -282,9 +282,16 @@ function normalizeTaskIds(tasks) {
|
|||||||
if (Array.isArray(task.subtasks)) {
|
if (Array.isArray(task.subtasks)) {
|
||||||
task.subtasks.forEach(subtask => {
|
task.subtasks.forEach(subtask => {
|
||||||
if (subtask.id !== undefined) {
|
if (subtask.id !== undefined) {
|
||||||
const parsedSubtaskId = parseInt(subtask.id, 10);
|
// Check for dot notation (which shouldn't exist in storage)
|
||||||
if (!isNaN(parsedSubtaskId) && parsedSubtaskId > 0) {
|
if (typeof subtask.id === 'string' && subtask.id.includes('.')) {
|
||||||
subtask.id = parsedSubtaskId;
|
// Extract the subtask part after the dot
|
||||||
|
const parts = subtask.id.split('.');
|
||||||
|
subtask.id = parseInt(parts[parts.length - 1], 10);
|
||||||
|
} else {
|
||||||
|
const parsedSubtaskId = parseInt(subtask.id, 10);
|
||||||
|
if (!isNaN(parsedSubtaskId) && parsedSubtaskId > 0) {
|
||||||
|
subtask.id = parsedSubtaskId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -432,6 +439,13 @@ function readJSON(filepath, projectRoot = null, tag = null) {
|
|||||||
|
|
||||||
// Store reference to the raw tagged data for functions that need it
|
// Store reference to the raw tagged data for functions that need it
|
||||||
const originalTaggedData = JSON.parse(JSON.stringify(data));
|
const originalTaggedData = JSON.parse(JSON.stringify(data));
|
||||||
|
|
||||||
|
// Normalize IDs in all tags before storing as originalTaggedData
|
||||||
|
for (const tagName in originalTaggedData) {
|
||||||
|
if (originalTaggedData[tagName] && Array.isArray(originalTaggedData[tagName].tasks)) {
|
||||||
|
normalizeTaskIds(originalTaggedData[tagName].tasks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check and auto-switch git tags if enabled (for existing tagged format)
|
// Check and auto-switch git tags if enabled (for existing tagged format)
|
||||||
// This needs to run synchronously BEFORE tag resolution
|
// This needs to run synchronously BEFORE tag resolution
|
||||||
|
|||||||
Reference in New Issue
Block a user