/** * Body-schema validation for canonical doc kinds (T10160). * * Scans a Markdown body for H2 (`## ...`) section headers and checks them * against the {@link DocKindMetadata.requiredSections} list declared in the * canonical doc-kind taxonomy. Comparison is: * * - case-insensitive (`## decision` matches `Decision`) * - tolerant of hyphen vs space (`## Next Steps` matches `Next-Steps`) * - tolerant of trailing punctuation in the header (`## Decision:` matches) * * Unknown kinds (not in the registry) and kinds with no `requiredSections` * or an empty array always pass — this keeps the validator additive: a * project that never opts a kind into a schema sees no behaviour change. * * The function is pure and synchronous — no filesystem, no DB. The CLI * wires it into `cleo docs add` / `cleo docs publish` in advisory mode by * default; `--strict` makes a body-schema mismatch fatal with * `E_DOC_BODY_INVALID`. * * @task T10160 (E12.C3 · absorbs T10154) * @epic T10157 * @saga T9855 */ import { type DocKindRegistry } from '@cleocode/contracts'; /** * Result of {@link validateDocBody}. */ export interface ValidateDocBodyResult { /** True when every required H2 section is present (or the kind has none). */ readonly ok: boolean; /** Missing required-section titles, in declaration order. Empty when ok. */ readonly missing: ReadonlyArray; } /** * Validate a Markdown body against the required-sections schema for `kind`. * * Behaviour: * - Unknown kind → `{ ok: true, missing: [] }` (advisory — no schema rules). * - Kind declared with no `requiredSections` (or `[]`) → always ok. * - Otherwise → reports any required H2 section title not found in `body`. * * Matching ignores case and treats hyphens as spaces — `## next-steps` * satisfies a requirement of `Next Steps` and vice versa. * * Built-ins-only fast path: the function pulls metadata from * {@link BUILTIN_DOC_KINDS} so callers with no project root in scope * (e.g. dispatch handlers operating on a worktree-routed file) can still * validate. Extension-only kinds are reached through the optional * {@link DocKindRegistry} parameter. * * @param kind - Canonical doc kind id (e.g. `'adr'`, `'spec'`). * @param body - Markdown body to scan. Frontmatter is irrelevant — we * only look at `## ...` headers. * @param registry - Optional registry (built-ins + project extensions). * When omitted, only built-in kinds are considered. */ export declare function validateDocBody(kind: string, body: string, registry?: DocKindRegistry): ValidateDocBodyResult; //# sourceMappingURL=validate-body.d.ts.map