/** * @fileoverview Generation map — per-Definition summary used for * reverse queries: "which files came from refName User?", "which * files did gen-zod produce?". Per plan §4.3. * * Lives at `.skmtc//.maps/_map.ndjson`, **wholly rewritten** * per generation (no accumulation across runs; stale entries would * mislead the viewer). The CLI handles disk I/O — this module emits * the entries + an NDJSON helper. * * One entry per Definition (landmark), not per anchor. The landmark * appears in the generation map; the per-Snippet anchors stay inside * the sidecar itself. * * "Generation map" by analogy with source maps: each row pairs a * generated artifact with the schema location + generator + variant * it came from. Same pattern as a sourcemap, at Definition rather * than byte granularity. */ import * as v from 'valibot'; import type { Sidecar } from './sidecar.js'; /** * Single row in the generation map. Mirrors the documented shape in * `plan.md` §4.3: * * - `f` — file path (relative to basePath) * - `name` — Definition / landmark name * - `g` — generator id (e.g. `@skmtc/gen-typescript`) * - `s` — schema pointer or empty string * - `v` — variant name (default `'main'`) */ export declare const generationMapEntry: v.ObjectSchema<{ readonly f: v.StringSchema; readonly name: v.StringSchema; readonly g: v.StringSchema; readonly s: v.StringSchema; readonly v: v.StringSchema; }, undefined>; export type GenerationMapEntry = v.InferOutput; /** * Extract one generation-map entry per unique landmark in `sidecar`. * * For each landmark, picks the **outermost** anchor — the one whose * AST path is empty (meaning the span is the landmark node itself). * If no path-empty anchor exists for a landmark (rare; happens when * the Definition's full text was reshaped between render and * post-pass), falls back to the first anchor for that landmark in * document order. This keeps the map populated rather than silently * dropping a Definition that the user can see in the file. */ export declare const entriesForSidecar: (sidecar: Sidecar) => GenerationMapEntry[]; /** * Convert generation-map entries to NDJSON (newline-delimited JSON). * One row per line; trailing newline so concatenation between * generations is boundary-safe. * * Pure: takes entries, returns a string. No I/O. */ export declare const toNdjson: (entries: readonly GenerationMapEntry[]) => string; /** * Parse a generation-map NDJSON file (typically read off disk by the * viewer or by a `doctor` check). Invalid rows fail the valibot parse * — the map is wholly rewritten per generation so a row being * unparseable means the file is corrupt, not just stale. */ export declare const parseNdjson: (text: string) => GenerationMapEntry[];