/** * `slowcook chef-drift` — α.9 L1 drift-fixer (cli α.9). * * Sibling to the existing `slowcook chef --pr ` (PR-CI-failure * handler). This module is the SURGICAL EDITOR variant: triggered by * mock-isolation / recon / brew halt / navigator halt-class. Reads the * failure + history-index + PR state, calls the chef LLM to get a * ChefVerdict, applies edits surgically, validates, commits, posts an * audit comment. * * Frozen surface (HARD): tests/integration/, tests/schema/, * tests/acceptance/ (spec-contract assertions) + .brewing/auto-gen/, * .brewing/code-map.*, .brewing/recon-result.json, .brewing/history- * index.json (slowcook-managed artifacts). If a fix requires an * ASSERTION change → escalates to PM via pm_comment (option B = * testgen --regenerate). * * NOT frozen (α.54 — chef owns test infrastructure): * tests/helpers/, vitest.config.*, playwright.config.*, package.json * (devDeps), tsconfig.json, setup files. Chef can fix the runner * machinery freehand. * * Ledger at .brewing/chef/.json tracks moves + cost. Cycle * detection + budget cap enforce convergence. * * Run from consumer repo root: * ANTHROPIC_API_KEY=... slowcook chef-drift \ * --story 018 \ * --trigger mock_isolation_check_failed \ * --trigger-detail "Relative import resolves to a non-existent file..." */ import { type ChefVerdict } from "@slowcook-ai/llm-anthropic"; export declare function isFrozenPath(path: string): boolean; /** * Parse a vitest-style test runner output to extract the failing test * files. Brew agent halts include the runner's stdout/stderr; chef * needs to know exactly which test files are red so it can grep their * imports + propose surgical edits to the source files under test. * * Recognises: * - `FAIL src/foo/bar.test.ts > description > it works` * - `× src/foo/bar.test.ts > description > it works` * - ` ❯ src/foo/bar.test.ts (...)` with a 'Tests fail' summary nearby * - `Test Files X failed | Y passed` summary lines (signal only) * * Returns { failingFiles: string[]; failingTestNames: string[] }. * Pure — does no IO. Exported for unit tests. */ export declare function parseBrewHaltOutput(text: string): { failingFiles: string[]; failingTestNames: string[]; }; /** * Extract the set of source files (non-test) imported by each failing * test file. Pure: takes a {testFile → contents} map and returns a * {testFile → importedSourceFiles[]} map. * * Captures relative imports (./ ../) AND tsconfig-path-style aliases * (`@/...`, `~/...`). Skips bare package imports. The chef-drift * resolver maps `@/X` → `src/X` and `~/X` → `src/X` per the Next.js * + most-Vite-template default; consumers using a different alias * mapping can override via tsconfig.json compilerOptions.paths (TODO). */ export declare function collectImportedSourceFiles(testContents: Record): Record; /** * Resolve an import path string (./X, ../X, @/X, ~/X) to a candidate * absolute file path under the repo, trying each known extension. * Returns null if no file resolves. Pure logic with single-call * existsSync at each candidate (caller can mock by injecting a * different `exists` predicate). */ export declare function resolveImportToFile(importPath: string, testFile: string, repoRoot: string, exists: (p: string) => boolean): string | null; export declare function chefDrift(argv: string[], cliVersion: string): Promise; /** * α.53 — extract whatever signal we can from a malformed chef JSON. * * The model often returns valid prose (`"rationale": "long sentence about * what's wrong"`) but the JSON envelope breaks if the rationale runs past * Anthropic's max-tokens midstring or contains an unescaped quote. * * Strategy: * 1. Look for ```json fence — strip it. * 2. Try a quick "auto-close unterminated string" repair: count * unescaped quotes; if odd, append a closing quote + `}` and retry * JSON.parse. * 3. If still broken, regex-extract the `"rationale"` field value up * to wherever it terminates (literal quote or end of buffer). * 4. Build a pm_question verdict with the recovered rationale plus a * bookkeeping note about the parse failure. Empty edits, no * next-dispatch — the PM is the next step. */ export declare function recoverChefVerdictFromMalformedJson(rawText: string, parseError: string, storyId: string, issueNumber: number): ChefVerdict; //# sourceMappingURL=drift-fix.d.ts.map