/** * Loop status helpers for the TUI run/monitor screens. */ /** * Find the implementation plan file, checking main project and git worktrees. * * Shared between loop-status.ts and monitor.ts to avoid duplicating the * worktree search logic. */ export declare function findImplementationPlan(projectRoot: string, specsRelPath: string, feature: string): string | null; export interface LoopStatus { running: boolean; phase: string; iteration: number; maxIterations: number; tokensInput: number; tokensOutput: number; cacheCreate: number; cacheRead: number; tokensUpdatedAt?: number; } export interface TaskCounts { tasksDone: number; tasksPending: number; e2eDone: number; e2ePending: number; planExists: boolean; } /** * Phase execution status and timing. * Shared between RunScreen and loop-status utilities. */ export interface PhaseInfo { /** Unique phase identifier (e.g., 'planning', 'implementation') */ id: string; /** Human-readable phase label */ label: string; /** Phase completion status */ status: 'success' | 'skipped' | 'failed' | 'started'; /** Duration in milliseconds, if available */ durationMs?: number; /** Number of iterations in this phase (e.g., for implementation) */ iterations?: number; } /** * Phase ID to human-readable label mapping. * Matches the phase IDs written by feature-loop.sh. */ export declare const PHASE_LABELS: Record; /** * Return the conventional log file path for a feature loop. */ export declare function getLoopLogPath(feature: string): string; /** * Detect current phase of the loop by checking for processes with prompt file patterns in their command line. * * Note: prompt-file checks (PROMPT_feature.md, etc.) are global — they match any * running process, not just the one for `feature`. This is acceptable because * concurrent loops are rare, but callers should be aware of the limitation. */ export declare function detectPhase(feature: string): string; /** * Read the current phase from the `.phases` file written by feature-loop.sh. * Returns the human-readable label of the active phase, or null if unavailable. * * The file format is: phase_id|status|start_timestamp|end_timestamp * A line with status "started" and no end timestamp indicates the active phase. */ export declare function readCurrentPhase(feature: string): string | null; /** * Read loop status from temp files written by feature-loop.sh. * * Reads `ralph-loop-.status` (or `.final`) for iteration progress * and `ralph-loop-.tokens` for token counts. Also runs `pgrep` to * check whether the loop process is still alive. * * @throws {Error} If `feature` contains invalid characters. */ export declare function readLoopStatus(feature: string): LoopStatus; /** * Parse the markdown implementation plan for a feature to extract task/E2E counts. * * Looks for `- [x]` (done) and `- [ ]` (pending) checklist items. * Items containing "E2E:" are counted separately as end-to-end tests. * * @returns Counts of done/pending tasks and E2E tests. */ export declare function parseImplementationPlan(projectRoot: string, feature: string, specsDirOverride?: string): Promise; /** * Get current git branch. */ export declare function getGitBranch(projectRoot: string): string; /** * Format number with K/M suffix. */ export declare function formatNumber(num: number): string; /** * Format epoch milliseconds as a relative time string (e.g., "30s ago", "2m ago", "1h ago"). */ export declare function formatRelativeTime(timestampMs: number): string; /** * A structured activity event derived from loop log or phase changes. */ export interface ActivityEvent { /** Epoch milliseconds when the event occurred */ timestamp: number; /** Human-readable description of the event */ message: string; /** Inferred status based on event content */ status: 'success' | 'error' | 'in-progress'; } /** * Incremental parse result for loop logs. * `nextCursor` is a character offset for the next poll. */ export interface LoopLogDelta { events: ActivityEvent[]; nextCursor: number; } /** * Returns true if a log line should be excluded from the activity feed. */ export declare function shouldSkipLine(line: string): boolean; /** * Parse the loop log file into structured activity events. * * Filters out noise lines (separators, markdown headers, interactive prompts, * config lines) and strips markdown formatting from remaining messages. * * @param logPath - Absolute path to the loop log file. * @param since - Optional epoch ms cutoff; only return events at or after this time. */ export declare function parseLoopLog(logPath: string, since?: number): ActivityEvent[]; /** * Incrementally parse only the new portion of a loop log. * * The cursor is a character offset in UTF-16 code units. If the file shrinks, * parsing restarts from the beginning. */ export declare function parseLoopLogDelta(logPath: string, cursor?: number): LoopLogDelta; /** * Detect phase changes by comparing current phases file to a known previous state, * and emit activity events for newly completed or started phases. * * @param feature - Feature name (used to locate the phases file). * @param lastKnownPhases - Phase array from the previous poll cycle. */ export declare function parsePhaseChanges(feature: string, lastKnownPhases?: PhaseInfo[]): { events: ActivityEvent[]; currentPhases?: PhaseInfo[]; }; /** * Parse phase information from the phases file written by feature-loop.sh. * * Format: phase_id|status|start_timestamp|end_timestamp * Accepts both 3-field lines (started: phase_id|started|timestamp) and * 4-field lines (completed: phase_id|status|start_ts|end_ts). * * The parser handles duplicate phase entries defensively (last status wins, * durations aggregate), though feature-loop.sh normally writes one final * line per phase. * * Used by build-run-summary.ts for completion summaries. */ export declare function parsePhases(phasesFilePath: string): PhaseInfo[];