/** * Task hierarchy operations - parent/child tree traversal and validation. * Ported from lib/tasks/hierarchy.sh * * @epic T4454 * @task T4529 */ import type { Task } from '@cleocode/contracts'; /** * Get direct children of a task. */ export declare function getChildren(taskId: string, tasks: Task[]): Task[]; /** * Get direct child IDs. */ export declare function getChildIds(taskId: string, tasks: Task[]): string[]; /** * Get all descendants of a task (recursive). */ export declare function getDescendants(taskId: string, tasks: Task[]): Task[]; /** * Get all descendant IDs (flat list). */ export declare function getDescendantIds(taskId: string, tasks: Task[]): string[]; /** * Get the parent chain (ancestors) from a task up to the root. * Returns ordered from immediate parent to root. */ export declare function getParentChain(taskId: string, tasks: Task[]): Task[]; /** * Get the parent chain as IDs. */ export declare function getParentChainIds(taskId: string, tasks: Task[]): string[]; /** * Calculate depth of a task in the hierarchy (0-based). * Root tasks have depth 0, their children depth 1, etc. */ export declare function getDepth(taskId: string, tasks: Task[]): number; /** * Get the root ancestor of a task. */ export declare function getRootAncestor(taskId: string, tasks: Task[]): Task | null; /** * Check if a task is an ancestor of another. */ export declare function isAncestorOf(ancestorId: string, descendantId: string, tasks: Task[]): boolean; /** * Check if a task is a descendant of another. */ export declare function isDescendantOf(descendantId: string, ancestorId: string, tasks: Task[]): boolean; /** * Get sibling tasks (same parent). */ export declare function getSiblings(taskId: string, tasks: Task[]): Task[]; /** * Validate that adding a child to a parent would not violate constraints. */ export interface HierarchyValidation { valid: boolean; error?: { code: string; message: string; }; } export declare function validateHierarchy(parentId: string | null, tasks: Task[], policy?: { maxDepth?: number; maxSiblings?: number; }): HierarchyValidation; /** * Detect circular reference if parentId were set. */ export declare function wouldCreateCircle(taskId: string, newParentId: string, tasks: Task[]): boolean; /** * Build a tree structure from flat task list. */ export interface TaskTreeNode { task: Task; children: TaskTreeNode[]; } export declare function buildTree(tasks: Task[]): TaskTreeNode[]; /** * Flatten a tree back to a list (depth-first). */ export declare function flattenTree(nodes: TaskTreeNode[]): Task[]; //# sourceMappingURL=hierarchy.d.ts.map