Documentation
¶
Overview ¶
Package decompose implements recursive AI sub-task expansion for a single task.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecomposePrompt ¶
DecomposePrompt builds a prompt asking the AI to break a complex task into 3-7 sub-tasks. depth indicates how many more levels of recursion are intended (for informational framing only).
func InjectSubTasks ¶
func InjectSubTasks(plan *pm.Plan, res *DecomposeResult) []*pm.Task
InjectSubTasks applies a DecomposeResult to the plan:
- Parent is marked skipped with annotation 'Decomposed into sub-tasks'.
- Sub-tasks are assigned IDs as maxID+1, maxID+2, ... and wired sequentially.
- Sub-tasks are appended after the parent task in the plan slice.
Returns the assigned sub-tasks.
func ParseSubTasks ¶
ParseSubTasks parses the AI's JSON response into sub-tasks. The returned tasks have no IDs set (caller assigns IDs). Tags and Assignee from the parent are inherited by all sub-tasks. The first sub-task's DependsOn is set to []int{parentID}. Subsequent sub-tasks depend on the previous sub-task sequentially.
Types ¶
type DecomposeResult ¶
DecomposeResult holds the output of a single decompose call.
func Decompose ¶
func Decompose(ctx context.Context, p provider.Provider, opts provider.Options, plan *pm.Plan, taskID int) (*DecomposeResult, error)
Decompose calls the AI to break a single task into sub-tasks and returns the result without modifying the plan. Callers must assign IDs and inject into the plan themselves (see InjectSubTasks).
The proposed sub-tasks are deliberately NOT semantically deduplicated against the plan: sub-tasks are a refinement of the parent and by construction cover the same work, so dedup against a plan that contains the parent classifies them all as duplicates and silently discards them. Since applying a decomposition marks the parent skipped, any dropped sub-task would be silently lost work. Both consumers (UI modal, CLI preview) have a human review step instead.
A degenerate first answer (unparseable, or fewer than 2 sub-tasks) gets one retry with a firmer instruction; provider transport errors are returned immediately.