/** * * Promoted from `src/services/slice/slice-pick-service.ts` (which is * the only prior caller). Encapsulates the canonical fzf integration * pattern: format items as one-line text, spawn `fzf --multi`, parse * the multi-selection, write a `-picked.json` artifact. * * Two distinct things live in `src/services/fuzzy-matching/`: * - `fuzzy-match-service.ts` — in-process fzf *npm package* (the * Fzf class). Used by `memory search` / `retrospective search`. * - `fzf-pick-service.ts` — spawns the fzf *binary* for * interactive TTY multi-select. Used by `peaks slice pick`, * `peaks memory list --pick`, `peaks retrospective index --pick`. * * The two are independent (one is a library, the other spawns a CLI); * do not merge them. fzf-for-js returns positions; the binary returns * raw lines. Different output shapes → different consumers. * * Source-of-truth: the binary is the *consumer* of the formatter * output, not an input. Each caller injects its own `formatLine` and * `parseLine` so a future swap to skim/peco is a one-line change per * caller, not a refactor of this service. */ export interface FzfPickOptions { readonly items: readonly T[]; /** Render a single item as one line of fzf input. Must round-trip with parseLine. */ readonly formatLine: (item: T) => string; /** Reconstruct an item from a fzf output line. Return null to drop the line. */ readonly parseLine: (line: string) => T | null; /** Absolute path for the output artifact. Caller decides the directory layout. */ readonly outputPath: string; /** Metadata to embed in the picked artifact (rid, parentId, etc). */ readonly meta: Record; /** Run `fzf --preview 'cat'` (recommended; needs fzf >= 0.38). */ readonly preview?: boolean; /** Override fzf binary path (default: 'fzf'). Useful for tests. */ readonly fzfBin?: string; /** Override stdin content for tests; bypasses the actual spawning. */ readonly overrideStdin?: string; /** Working directory for the fzf spawn. */ readonly projectRoot: string; /** fzf --multi toggle (default true; pass false for single-select). */ readonly multi?: boolean; /** Custom fzf prompt string (default "pick> "). */ readonly prompt?: string; } export interface FzfPickResult { readonly picked: readonly T[]; readonly outputPath: string; readonly fzfVersion: string; } export declare const MIN_FZF_VERSION = "0.38"; /** * Pick a subset of `items` interactively via fzf. The full flow: * 1. Check fzf presence + version. * 2. Format items as one-line text (caller's formatLine). * 3. Spawn `fzf --multi` (or test override). * 4. Parse the multi-selection back into T[] (caller's parseLine). * 5. Write `` with the picked + meta + fzfVersion. * * Failure modes: * - fzf missing → throws with `brew install fzf | apt-get install fzf` hint. * - fzf version too old → throws. * - fzf exits 130 (Esc) → returns `{ picked: [], outputPath, fzfVersion }` (NOT thrown). * - parseLine returns null for a line → silently dropped (line ignored). */ export declare function pickFromList(options: FzfPickOptions): Promise>;