/** * Karpathy scan service (Slice 5/6 — karpathy-enforcement). * * Surface-level structural scan for the 4 Karpathy-guidelines * sections. Detects simple textual signals in `rd/karpathy-review.md` * (or a manually-supplied karpathy review blob) and reports * violation counts per guideline. This is a STRUCTURAL scanner, not * a semantic reviewer; the semantic review happens in the * `karpathy-reviewer` sub-agent (5-way fanout). Pattern follows * `orphan-service.ts` and `api-surface-service.ts`. * * karpathy §2: minimum code, no abstractions, no speculative * features. */ export type KarpathyViolationKind = 'think-before-coding' | 'simplicity-first' | 'surgical-changes' | 'goal-driven-execution'; export type KarpathyScanOptions = { projectRoot: string; /** Limit walk to the supplied review file path (default: rd/karpathy-review.md). */ reviewFile?: string; /** Scope: working-tree (default) | all. working-tree emits a warning if the file is missing. */ scope?: 'working-tree' | 'all'; }; export type KarpathyViolation = { kind: KarpathyViolationKind; line: number; snippet: string; hint: string; }; export type KarpathyScanReport = { projectRoot: string; reviewFile: string; scannedAt: string; present: boolean; counts: Record; totalViolations: number; violations: KarpathyViolation[]; /** Section coverage: which of the 4 guidelines has its dedicated heading in the file. */ sectionCoverage: Record; /** Gate action: pass when totalViolations === 0; warn when > 0; block when file missing under 'all' scope. */ gateAction: 'pass' | 'warn' | 'block'; warnings: string[]; }; export declare function scanKarpathy(options: KarpathyScanOptions): Promise; /** * Escape user-controlled strings before they are interpolated into the * markdown report. Slice 2.6.1.C mitigation: prevents L1 LOW markdown * injection when `projectRoot`, `reviewFile`, `v.snippet`, etc. contain * characters that would alter rendered structure (backslashes, inline * code fences, link/image syntax). * * The escape keeps the value readable but neutralises the four most * common markdown structural chars. We deliberately do NOT escape every * punctuation mark — the goal is structural safety, not full sanitisation. * Note: a link `[text](url)` is fully neutralised by escaping just `[]`; * the parens alone have no markdown meaning. */ export declare function escapeMarkdown(value: string): string; export declare function formatKarpathyMarkdown(report: KarpathyScanReport, opts?: { title?: string; }): string;