/** * peaks-loop v2.13.3 — Envelope parsers (split from `envelopes.ts`). * * `envelopes.ts` exceeded the 300-raw-line file-size cap, so the * finding-free parser mass — the `AnyEnvelope` discriminated-union * projection, the security / perf / karpathy markdown parsers, the * `AnyEnvelope → AggregatorInput` adapter, and the two markdown * section / bullet readers — moved here verbatim. The finding-carrying * helpers (`parseAuditMarkdown`, `parseKarpathyViolations`, `matchEnum`, * `parseFindingBullet`) stay in `envelopes.ts`, which re-exports every * name below so `./envelopes.js` stays the public import path. * * Cycle note: `envelopes.ts` and this file import each other. That is * safe under `module: NodeNext` + `"type": "module"` because every * cross-boundary reference is a hoisted function declaration (resolved * at call time) or an erased `type` — neither module reads a value from * the other at evaluation time. */ import { type PerfAuditEnvelope, type SecurityAuditEnvelope } from '../audit-independent/index.js'; import { type KarpathyEnvelope, type MutEnvelope, type QaEnvelope, type AggregatorInput } from './verdict-aggregator.js'; /** * `kind` is the discriminator. The on-disk file format is unchanged; * this field exists only in the TS type projection. The aggregator * accepts both the legacy `{security, perf, ...}` shape and the new * union via a thin adapter (`aggregateFromEnvelopes`). */ export type AnyEnvelope = { kind: 'security'; envelope: SecurityAuditEnvelope; } | { kind: 'perf'; envelope: PerfAuditEnvelope; } | { kind: 'karpathy'; envelope: KarpathyEnvelope; } | { kind: 'mut'; envelope: MutEnvelope; } | { kind: 'qa'; envelope: QaEnvelope; }; /** * * 1. Try JSON.parse first (back-compat with prior unit tests + any * consumer that passes a JSON string explicitly). * 2. Fall back to markdown parse: extract `verdict:` from YAML * frontmatter, parse `## Findings` bullets in the body, return * a SecurityAuditEnvelope. * 3. Return null when neither path yields a valid envelope. */ export declare function parseSecurityEnvelope(md: string): SecurityAuditEnvelope | null; export declare function parsePerfEnvelope(md: string): PerfAuditEnvelope | null; /** * Karpathy review is stored as markdown (`.peaks/_runtime//rd/karpathy-review.md`). * We parse the 3 state lines that drive the aggregator: * - `gateAction: pass | warn | block` * - `verdict: pass | warn | block` (alias for gateAction) * - `passed: true | false` * Plus the violations list under a `## Violations` heading, where each * bullet begins with `[SEVERITY] file:line — hint` and declares a * guideline tag like `(simplicity-first)`. */ export declare function parseKarpathyEnvelope(md: string): KarpathyEnvelope | null; /** * Convert a partial list of `AnyEnvelope` values to the legacy * `AggregatorInput` shape. `null` envelopes are skipped (a missing * envelope is treated as "audit not run" — same semantics as * `AggregatorInput` without that key). */ export declare function envelopesToAggregatorInput(list: ReadonlyArray): AggregatorInput; /** Extract the body of a `## Heading` section (text up to the next * `## ` heading or EOF). Returns null when the heading is absent. */ export declare function extractSection(body: string, heading: string): string | null; /** Parse `## Findings` bullets. Accepts the 3 real v2.12.0 shapes. */ export declare function parseFindingBullets(body: string): Array<{ dimension: string; severity: 'CRITICAL' | 'HIGH' | 'MED' | 'LOW'; file: string; line: number; hint: string; }>;