/** * Context builder for intelligent prompt trimming across loop iterations. * * Reduces input tokens by progressively narrowing the context sent to the agent: * - Iteration 1: Full spec + skills + full implementation plan * - Iterations 2-3: Abbreviated spec + current task only + compressed feedback * - Iterations 4+: Current task only + error summary */ import type { PlanTask, TaskCount } from './task-counter.js'; export interface ContextBuildOptions { /** The full task/spec content (original prompt) */ fullTask: string; /** Task with skills appended */ taskWithSkills: string; /** Current task from IMPLEMENTATION_PLAN.md */ currentTask: PlanTask | null; /** Task count info */ taskInfo: TaskCount; /** Current iteration number (1-based) */ iteration: number; /** Max iterations for this loop */ maxIterations: number; /** Validation feedback from previous iteration */ validationFeedback?: string; /** Maximum input tokens budget (0 = unlimited) */ maxInputTokens?: number; /** Abbreviated spec summary for later iterations (avoids agent re-reading specs/) */ specSummary?: string; /** Skip IMPLEMENTATION_PLAN.md instructions in preamble (used by fix --design) */ skipPlanInstructions?: boolean; /** Iteration log content from .ralph/iteration-log.md (previous iteration summaries) */ iterationLog?: string; /** Source integration type (github, linear, figma, notion, file) for source-specific prompts */ sourceType?: string; /** Whether Figma images were downloaded to public/images/ */ figmaImagesDownloaded?: boolean; /** Font substitutions applied (original → Google Fonts alternative) */ figmaFontSubstitutions?: Array<{ original: string; substitute: string; }>; /** Path to design reference image (relative to cwd) — becomes the PRIMARY visual source of truth */ designImagePath?: string; } export interface BuiltContext { /** The assembled prompt to send to the agent */ prompt: string; /** Estimated token count */ estimatedTokens: number; /** Whether the context was trimmed */ wasTrimmed: boolean; /** Debug info about what was included/excluded */ debugInfo: string; } /** * Compress validation feedback to reduce token usage. * Keeps only the failing command names and truncated error output. */ export declare function compressValidationFeedback(feedback: string, maxChars?: number): string; /** * Build an abbreviated spec summary from the specs/ directory. * Gives later iterations a quick design reference without requiring * the agent to re-read spec files via tool calls. */ export declare function buildSpecSummary(cwd: string, maxChars?: number): string | undefined; /** * Build a trimmed implementation plan context showing only the current task * with a summary of completed and pending tasks. */ export declare function buildTrimmedPlanContext(currentTask: PlanTask, taskInfo: TaskCount): string; /** * Build the iteration context with intelligent trimming. */ export declare function buildIterationContext(opts: ContextBuildOptions): BuiltContext; //# sourceMappingURL=context-builder.d.ts.map