/** * The shaping cuts: runs of lines the agent has already seen, and windows of the lines Spotlight ranks highest within * a character budget. A window says why it showed or hid each line ({@link SpotlightReason}) and what it spent, for the result's * trace. */ import { type SpotlightReason } from "@oh-my-pi/pi-tui/chat/spotlight"; import type { Seen } from "./state.js"; /** Lines inside runs of already-seen lines ({@link witnessedRuns}), and the first line of each run. */ export interface Witnessed { mask: boolean[]; /** Back to back runs are two passages of the context: each collapses to a marker of its own. */ starts: boolean[]; } /** * Runs of ≥ `run` already-seen lines in the order the context holds them: each line came right after the one before * it in one text there (short lines inside a run count only so), and a run starts and ends on a seen line. A line * dropped, moved or changed between two passages splits them. A line `keep` marks never counts as seen and ends any * run it is in. */ export declare function witnessedRuns(lines: readonly string[], seen: Seen, run: number, keep?: readonly boolean[]): Witnessed; /** Knobs of the valve window ({@link frameLines}). */ export interface WindowKnobs { budget: number; /** Lines shown on each side of a chosen line. */ ctx: number; /** First and last lines always shown. */ head: number; tail: number; /** Lines that may be chosen on their score (default: every open line); the frame and neighbours still show. */ pick?: readonly boolean[]; } /** * Which lines a window shows and why: `s` head, tail and markers, `a` chosen on its score, `c` a neighbour of a * chosen line or a lone gap filled, `b` hidden by the budget (`r`: already seen, never chosen). `used` is the * characters the window counted against its budget, `last` its last line chosen on score and what that cost. */ export interface Window { why: SpotlightReason[]; used: number; last?: { item: number; chars: number; }; } /** The part of {@link densityScores} and the highest score a line can reach. */ export declare const DENSITY_PARTS: string[]; export declare const DENSITY_MAX = 1; /** The valve's ranking: each line's Spotlight rank over the fourth root of its length (short lines of equal rank win). */ export declare function densityScores(lines: readonly string[], spot: readonly number[]): number[]; /** * The valve's frame within `budget`. `width[i]` is line i's shown size; lines with `skip` set (already seen) are never * chosen. The first and last open lines first, then best-first by `scores` with neighbours. */ export declare function frameLines(width: readonly number[], lines: readonly string[], skip: readonly boolean[], scores: readonly number[], k: WindowKnobs): Window; /** * Shows each hidden run of one line, or of two lines with at most two markers' worth of text, between shown lines * (`c`): such a run costs about what its marker does. A gap and an already-seen fragment are runs of their own; runs * again after later steps (commit headers) split runs into fragments. */ export declare function fillSmallGaps(width: readonly number[], why: (SpotlightReason | undefined)[]): void; /** * Shows the headings every shown line sits under, as structure (`s`): `grep` and `glob` group their lines under * `# dir/` and `## file` headings, and a Markdown result its paragraphs under sections, so a line shown without them * names nothing. Blank lines pull no heading. Only lines hidden by rank or budget (`b`) are shown; `undefined` counts * as shown. */ export declare function keepHeadings(lines: readonly string[], why: (SpotlightReason | undefined)[]): void; /** A `git log` commit's first line, the header lines under it, and its `--stat` total. */ export declare const COMMIT: RegExp; /** * Shows, as structure (`s`), the record of the commit every shown line of `git log` output sits under: its header * (`commit`, `Merge:`, `Author:`, `Date:` lines), subject, and `--stat` total. A stat line, message or lone `Date:` * shown without them names no commit. Lines hidden by rank or budget (`b`) and as already seen (`r`) are shown: a * header an earlier result showed is far from the lines it names here. Output without commit lines is left as it is. */ export declare function keepCommitHeaders(lines: readonly string[], why: (SpotlightReason | undefined)[]): void; /** A line with its numbers blanked: lines of one shape say the same thing with other counts. */ export declare function lineShape(line: string): string; /** * Output that repeats one to {@link UNIFORM_SHAPES} line shapes (`sync batch N: wrote N rows … ok`; table rows * whose status is `ok`, `shipped` or `packed`): the shapes, most common first; which open lines inside the run (from * the first line of a shape to the last) have none of them; and which open lines lie outside it (a table's header, a * closing summary). Undefined unless at least {@link UNIFORM_LINES} non-blank open lines exist and the shapes cover * {@link UNIFORM_SHARE} of them; blank lines and markers neither count nor differ. */ export declare function uniformShape(lines: readonly string[], skip: readonly boolean[]): { shapes: string[]; differs: boolean[]; edges: boolean[]; } | undefined; /** Unified diff text (`git diff`, a `.patch` read back): a hunk header and a file header. */ export declare function isDiff(lines: readonly string[]): boolean; /** * A picture or matrix: at least 10 non-blank lines, 60% of them of one length (±1, at least 8), drawn from at most * 16 distinct non-space characters. Any line subset of one is meaningless. */ export declare function isGrid(lines: readonly string[]): boolean;