/** * GoalPlanner - converts a goal into phases using a real LLM call, * producing a large task list with todos under each phase. * * Similar to SDD's spec-to-task flow, but different: the output is directly * `PhaseTemplate[]`; each phase carries `taskTemplates`, so * `PhaseGraphBuilder` produces a populated `PhaseGraph` and `PhaseOrchestrator` * runs each task through a real agent execution. * * The planner is not tied to a specific LLM: callers provide a `runOnce(prompt)` function * (a subagent run in the CLI, or a deterministic stub in tests). */ import type { PhaseTemplate } from './types.js'; export interface GoalPlannerOptions { /** * One-shot LLM call: receives a prompt and returns the model text output. * In the CLI this wraps subagent.run; in tests it can be a deterministic stub. */ runOnce: (prompt: string) => Promise; /** Goal or project title. */ goal: string; /** Optional project context such as package.json or directory structure. */ projectContext?: string | undefined; /** Requested minimum phase count. Defaults to 3. */ minPhases?: number | undefined; /** Requested maximum phase count. Defaults to 8. */ maxPhases?: number | undefined; /** Target todo count per phase. Defaults to 6. */ todosPerPhase?: number | undefined; /** * Maximum total tasks across all phases. When set, plans exceeding * this limit will have `budgetExceeded: true` and `warnings` will * describe the overage. Defaults to 0 (no limit). */ maxTotalTasks?: number | undefined; } export interface GoalPlanResult { /** Phase templates passed to PhaseGraphBuilder. */ phases: PhaseTemplate[]; /** Raw model output for debugging and logs. */ raw: string; /** True when JSON could not be parsed; `phases` is empty in that case. */ parseFailed: boolean; /** Validation warnings collected during coercion (e.g. invalid priority defaults). */ warnings: string[]; /** * Rough cost estimate (in tokens) for executing this plan. * Based on estimated task count × average per-task LLM round-trip. */ estimatedCostTokens?: number | undefined; /** True when the plan exceeds `maxTotalTasks` budget. */ budgetExceeded?: boolean | undefined; } /** * GoalPlanner drives the model through `plan()` and produces `PhaseTemplate[]`. */ export declare class GoalPlanner { private readonly opts; constructor(opts: GoalPlannerOptions); /** Convert the goal into a phase-and-todo plan. */ plan(): Promise; /** Instruction prompt for the plan the model should produce. */ buildPrompt(): string; /** Extract JSON from raw output, validate it, and convert it to PhaseTemplate[]. * Returns `{ phases, warnings }` where warnings describe coerced defaults. */ parse(raw: string): { phases: PhaseTemplate[]; warnings: string[]; }; private coercePhase; private coerceTask; } /** * Extract the first JSON array from text. Tries, in order: * 1. The first [ ... ] inside a ```json ... ``` or bare ``` code block * 2. The first balanced [ ... ] block in the text, aware of strings and escapes */ export declare function extractJSONArray(text: string): string | null; //# sourceMappingURL=goal-planner.d.ts.map