decompose

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 6 Imported by: 0

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

func DecomposePrompt(task *pm.Task, depth int) string

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:

  1. Parent is marked skipped with annotation 'Decomposed into sub-tasks'.
  2. Sub-tasks are assigned IDs as maxID+1, maxID+2, ... and wired sequentially.
  3. Sub-tasks are appended after the parent task in the plan slice.

Returns the assigned sub-tasks.

func ParseSubTasks

func ParseSubTasks(response string, parent *pm.Task) ([]*pm.Task, error)

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

type DecomposeResult struct {
	Parent   *pm.Task
	SubTasks []*pm.Task
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL