You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
📝 Add docstrings to fix-ai-sdk-jsonschema-fallback
Docstrings generation was requested by @TheLazyIndianTechie.
* #1556 (comment)
The following files were modified:
* `scripts/modules/task-manager/parse-prd/parse-prd-helpers.js`
* `scripts/modules/task-manager/scope-adjustment.js`
Copy file name to clipboardExpand all lines: scripts/modules/task-manager/parse-prd/parse-prd-helpers.js
+58-8Lines changed: 58 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -120,19 +120,21 @@ export function validateFileOperations({
120
120
}
121
121
122
122
/**
123
-
* Process and transform tasks with ID remapping
124
-
* @param {Array} rawTasks - Raw tasks from AI
125
-
* @param {number} startId - Starting ID for new tasks
126
-
* @param {Array} existingTasks - Existing tasks for dependency validation
127
-
* @param {string} defaultPriority - Default priority for tasks
128
-
* @returns {Array} Processed tasks with remapped IDs
129
-
*/
123
+
* Transform raw PRD tasks into normalized tasks with reassigned sequential IDs.
124
+
* @param {Array} rawTasks - Tasks parsed from a PRD; each task must include an integer `id`.
125
+
* @param {number} startId - ID to assign to the first processed task.
126
+
* @param {Array} existingTasks - Existing tasks used to validate dependency references.
127
+
* @param {string} defaultPriority - Priority to apply when a task has no priority.
128
+
* @returns {Array} An array of tasks with reassigned sequential IDs, normalized fields (status, priority, title, description, details, testStrategy, subtasks), and dependencies remapped to the new IDs.
130
129
export function processTasks(
131
130
rawTasks,
132
131
startId,
133
132
existingTasks,
134
133
defaultPriority
135
134
) {
135
+
// Runtime guard: ensure PRD task IDs are unique and sequential (1..N).
136
+
validateSequentialTaskIds(rawTasks, startId);
137
+
136
138
let currentId = startId;
137
139
const taskMap = new Map();
138
140
@@ -172,6 +174,54 @@ export function processTasks(
172
174
return processedTasks;
173
175
}
174
176
177
+
/**
178
+
* Validate that an array of PRD tasks uses unique, positive integer IDs that form a contiguous sequence.
179
+
*
180
+
* Validates that each task has an integer `id` >= 1, that IDs are unique, and that the sorted IDs form
181
+
* a contiguous sequence starting at either `1` or the provided `expectedStartId`.
182
+
*
183
+
* @param {Array<{id: number}>} rawTasks - Array of task objects containing an `id` property. If not an array or empty, no validation is performed.
184
+
* @param {number} [expectedStartId=1] - Allowed alternative starting ID for the contiguous sequence.
185
+
* @throws {Error} If any `id` is not an integer >= 1: "PRD tasks must use sequential positive integer IDs starting at 1."
186
+
* @throws {Error} If IDs are not unique: "PRD task IDs must be unique and sequential starting at 1."
187
+
* @throws {Error} If the sequence does not start at `1` or `expectedStartId`: "PRD task IDs must start at 1 or {expectedStartId} and be sequential."
188
+
* @throws {Error} If IDs are not contiguous: "PRD task IDs must be a contiguous sequence starting at {startId}."
* @param {number|null} originalComplexity - Original complexity score for smarter adjustments
167
-
* @returns {Promise<Object>} Object with updated task and regeneration info
160
+
* Regenerates a task's pending subtasks to match a changed complexity while preserving subtasks with work already done.
161
+
*
162
+
* Generates new pending subtasks (via the configured AI service) to reach a target subtask count based on direction and strength, preserves subtasks whose status indicates work should be kept, and remaps IDs/dependencies so generated subtasks follow preserved ones.
163
+
*
164
+
* @param {Object} task - The task object to update; its subtasks array will be replaced with preserved and newly generated subtasks in the returned `updatedTask`.
165
+
* @param {string} tasksPath - Filesystem path to tasks.json (used for context; not modified by this function).
166
+
* @param {Object} context - Execution context containing { projectRoot, tag, session, ... } used for AI calls and logging.
167
+
* @param {string} direction - Scope change direction: 'up' to increase complexity or 'down' to decrease complexity.
0 commit comments