/** * Goal Loop — simplified Ralph-style autonomous execution. * * State lives in prd.json. Each iteration: pick next !passes story, spawn an * execution sub-pi, spawn a verification sub-pi, flip passes:true if verified, * write prd.json back to disk. Loop until all stories pass or maxIterations hit. * * No DB, no state machine, no global lock. Per-goal worktree gives physical * isolation; prd.json being the source of truth gives free pause/resume * (ctrl+C, re-run /goal --from prd.json — loop picks up where it left off). */ import { type PiTokens } from "@shog-lab/pi-utils"; import { PRD } from "./schema.js"; /** * Read prd.json and schema-validate. Returns null on any failure (missing, * malformed JSON, wrong shape) — caller surfaces a useful error. */ export declare function loadPRD(prdPath: string): PRD | { error: string; }; /** * Materialize a per-goal git worktree at `/.ralph-worktrees//` on * the given branch, return its path. Returns null if cwd is not in a git repo * (caller falls back to operating in cwd directly). * * Worktree isolation gives ralph a clean physical sandbox per goal — the * user's main checkout is never touched, multiple goals can coexist on * different branches, and `.pi-mind/` + `.pi-goals/` still resolve to the * main repo root via `git rev-parse --git-common-dir` (pi-utils paths.ts). * * Idempotent: if a worktree is already registered at the path, reuse it * (resume path). */ export declare function ensureWorktree(cwd: string, key: string, branchName: string): string | null; export interface LoopOptions { prdPath: string; cwd: string; branchName?: string; maxIterations?: number; /** Per-sub-agent timeout in ms (default: 5 min) */ subAgentTimeoutMs?: number; } export interface LoopResult { completed: boolean; iterationsRun: number; totalTokens: PiTokens; reason?: string; } /** * Run the goal loop on the PRD at prdPath. Loops until every story passes or * maxIterations is hit. Writes prd.json back after each iteration so re-runs * pick up where they left off (this IS the pause/resume mechanism). * * Returns aggregate tokens used and whether the goal completed. */ export declare function runGoalLoop(opts: LoopOptions): Promise; //# sourceMappingURL=loop.d.ts.map