feat(cli): implement loop command (#1571)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ralph Khreish
2026-01-11 01:47:52 +01:00
committed by GitHub
parent 1befc6a341
commit c2d6c18a96
42 changed files with 8645 additions and 613 deletions

View File

@@ -154,6 +154,40 @@ export class TasksDomain {
return this.taskService.getNextTask(tag);
}
/**
* Get count of tasks and their subtasks matching a status
* Useful for determining work remaining, progress tracking, or setting loop iterations
*
* @param status - Task status to count (e.g., 'pending', 'done', 'in-progress')
* @param tag - Optional tag to filter tasks
* @returns Total count of matching tasks + matching subtasks
*/
async getCount(status: TaskStatus, tag?: string): Promise<number> {
// Fetch ALL tasks to ensure we count subtasks across all parent tasks
// (a parent task may have different status than its subtasks)
const result = await this.list({ tag });
let count = 0;
for (const task of result.tasks) {
// Count the task if it matches the status
if (task.status === status) {
count++;
}
// Count subtasks with matching status
if (task.subtasks && task.subtasks.length > 0) {
for (const subtask of task.subtasks) {
// For pending, also count subtasks without status (default to pending)
if (subtask.status === status || (status === 'pending' && !subtask.status)) {
count++;
}
}
}
}
return count;
}
// ========== Task Status Management ==========
/**