import { readFile, writeFile } from "node:fs/promises"; import { createRequire } from "node:module"; import prettier from "prettier"; import type { RenderArtifactDetails, ValidationFinding } from "../types.ts"; const require = createRequire(import.meta.url); interface HtmlHintMessage { rule: { id: string }; line: number; col: number; message: string; type: "error" | "warning" | "info"; } interface HtmlHintLike { verify(html: string, ruleset?: Record): HtmlHintMessage[]; } const { HTMLHint } = require("htmlhint") as { HTMLHint: HtmlHintLike }; const SUPPORTED_COMPONENTS = new Set([ "pi-data-source", "pi-grid", "pi-card", "pi-metric", "pi-chart", "pi-table", ]); /** * html validation gate (Phase C, Pass 2). * * Mirrors the markdown gate: format -> lint -> capability-check. * - Prettier formats `index.html` in place (autofix; warn on parse failure). * - HTMLHint findings are warnings (structural correctness, not style). * - Runtime-capability checks warn when authored markup uses features that * are blocked by the strict CSP (inline