@descent-vtt/spec-graph 0.2.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +275 -0
- package/README.md +169 -3
- package/dist/baseline.d.ts +18 -4
- package/dist/baseline.js +14 -2
- package/dist/baseline.js.map +1 -1
- package/dist/cli.d.ts +13 -4
- package/dist/cli.js +126 -27
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +14 -2
- package/dist/config.js +28 -1
- package/dist/config.js.map +1 -1
- package/dist/extract.d.ts +39 -2
- package/dist/extract.js +137 -8
- package/dist/extract.js.map +1 -1
- package/dist/identity.d.ts +10 -0
- package/dist/identity.js +51 -5
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/markdown.d.ts +16 -2
- package/dist/markdown.js +89 -22
- package/dist/markdown.js.map +1 -1
- package/dist/project-rules.d.ts +92 -0
- package/dist/project-rules.js +201 -0
- package/dist/project-rules.js.map +1 -0
- package/dist/report.d.ts +33 -8
- package/dist/report.js +181 -7
- package/dist/report.js.map +1 -1
- package/dist/resolve.d.ts +9 -1
- package/dist/resolve.js +181 -26
- package/dist/resolve.js.map +1 -1
- package/dist/rules.d.ts +8 -5
- package/dist/rules.js +96 -5
- package/dist/rules.js.map +1 -1
- package/dist/runner.d.ts +5 -2
- package/dist/runner.js +1 -0
- package/dist/runner.js.map +1 -1
- package/dist/select.d.ts +11 -0
- package/dist/select.js +31 -0
- package/dist/select.js.map +1 -1
- package/dist/types.d.ts +59 -4
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/markdown.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,eA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,GAAG,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IAC/B,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AAClC,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACnF,CAAC;AAED,8EAA8E;AAC9E,SAAS,UAAU,CAAC,GAAW;IAC7B,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC9B,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACzD,CAAC","sourcesContent":["/**\n * A structural Markdown scanner.\n *\n * This is deliberately **not** a CommonMark implementation. spec-graph needs six\n * things from a document - front matter, headings, list items with their\n * continuations, HTML comments, links, and a reliable map of what is code - and\n * a full parser would cost a dependency tree, an AST walk, and a position\n * mapping layer to get back the offsets we want in the first place.\n *\n * What the scanner does guarantee is the part that makes regex-based spec\n * linters lie:\n *\n * - **Code never counts.** Fenced blocks, indented blocks and inline spans are\n * masked before a single link is extracted, so an example in a code sample\n * never becomes a graph edge.\n * - **Items are blocks, not lines.** A list item owns its wrapped continuation\n * lines and its nested content, so a resolution written on the second line of\n * a bullet is found instead of missed.\n * - **Everything carries absolute offsets.** No re-scanning, no drift between\n * the text a rule matched and the position it reports.\n */\n\nimport { createLineIndex, type LineIndex } from './source.js';\n\n/* -------------------------------------------------------------------------- */\n/* Shapes */\n/* -------------------------------------------------------------------------- */\n\nexport interface Range {\n readonly start: number;\n readonly end: number;\n}\n\nexport interface FrontMatter {\n /** The body between the delimiters, exclusive. */\n readonly raw: string;\n /** Offset of the first character of `raw`. */\n readonly start: number;\n readonly end: number;\n /** Offset just past the closing delimiter line. */\n readonly bodyStart: number;\n}\n\nexport interface ScannedLine {\n /** 1-based. */\n readonly line: number;\n /** Offset of the raw line start. */\n readonly start: number;\n /** Offset just past the line, excluding its terminator. */\n readonly end: number;\n /** Offset of the first character after any block-quote markers. */\n readonly contentStart: number;\n /** Line text after block-quote markers, indentation intact. */\n readonly content: string;\n /** Indentation of `content`, tabs counted as four columns. */\n readonly indent: number;\n readonly blank: boolean;\n readonly quoteDepth: number;\n /** Inside a fenced or indented code block, fence delimiters included. */\n readonly code: boolean;\n}\n\nexport interface Heading {\n readonly level: number;\n readonly text: string;\n /** GitHub-compatible anchor slug. */\n readonly slug: string;\n readonly start: number;\n readonly end: number;\n readonly line: number;\n}\n\nexport interface ListItem {\n /** The whole block: marker line plus continuations and nested content. */\n readonly start: number;\n readonly end: number;\n /** Offset of the list marker itself. */\n readonly markerStart: number;\n readonly marker: string;\n /** Offset where the item text begins, after marker and any checkbox. */\n readonly textStart: number;\n /** The character inside `[ ]`, or `null` when the item has no checkbox. */\n readonly checkbox: string | null;\n readonly checkboxStart: number | null;\n /** First line of item text, trimmed. */\n readonly firstLine: string;\n /** Full item text including continuations and nested content. */\n readonly body: string;\n /**\n * `body` with code and comments blanked out, same length and offsets.\n *\n * Anything that searches item text for meaning - resolution markers above\n * all - must read this rather than `body`, or a fenced example nested under\n * the item will close it.\n */\n readonly maskedBody: string;\n readonly line: number;\n /** How many list items enclose this one. Top-level items are `0`. */\n readonly depth: number;\n readonly indent: number;\n}\n\nexport interface HtmlComment {\n readonly start: number;\n readonly end: number;\n /** Text between `<!--` and `-->`. */\n readonly inner: string;\n readonly innerStart: number;\n readonly line: number;\n}\n\nexport type LinkForm = 'inline' | 'reference' | 'shortcut' | 'autolink' | 'wiki' | 'definition';\n\nexport interface Link {\n /** Visible label. Empty for autolinks and definitions. */\n readonly text: string;\n /** Destination as written: a path, a URL, or a reference label. */\n readonly target: string;\n /** Offset of the whole construct. */\n readonly start: number;\n readonly end: number;\n /** Offset of `target` inside the source, for precise diagnostics. */\n readonly targetStart: number;\n readonly form: LinkForm;\n readonly line: number;\n}\n\nexport interface TableCell {\n /** Cell text as written, trimmed. */\n readonly text: string;\n /** Offset of the trimmed text, so a finding can point at the cell itself. */\n readonly start: number;\n readonly end: number;\n}\n\nexport interface TableRow {\n readonly cells: readonly TableCell[];\n readonly start: number;\n readonly end: number;\n readonly line: number;\n}\n\nexport interface Table {\n readonly start: number;\n readonly end: number;\n /** Header cells, trimmed. A table without a header row is not a table. */\n readonly headers: readonly TableCell[];\n readonly rows: readonly TableRow[];\n}\n\nexport interface ScannedDocument {\n readonly text: string;\n readonly index: LineIndex;\n readonly frontMatter: FrontMatter | null;\n /** Offset where the body starts, after any front matter. */\n readonly bodyStart: number;\n readonly lines: readonly ScannedLine[];\n readonly headings: readonly Heading[];\n readonly listItems: readonly ListItem[];\n readonly comments: readonly HtmlComment[];\n readonly links: readonly Link[];\n readonly tables: readonly Table[];\n /** Code and comments blanked out, offsets and line breaks preserved. */\n readonly masked: string;\n /** True when the offset falls inside code, a comment, or front matter. */\n isMasked(offset: number): boolean;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Entry point */\n/* -------------------------------------------------------------------------- */\n\nexport function scanMarkdown(source: string): ScannedDocument {\n const text = source.charCodeAt(0) === 0xfeff ? source.slice(1) : source;\n const index = createLineIndex(text);\n const frontMatter = readFrontMatter(text, index);\n const bodyStart = frontMatter ? frontMatter.bodyStart : 0;\n\n const lines = scanLines(text, index, bodyStart);\n const codeRanges = collectCodeRanges(lines, bodyStart);\n const comments = scanComments(text, index, bodyStart, codeRanges);\n\n const inlineCode = scanInlineCode(text, bodyStart, codeRanges, comments);\n const maskRanges = [\n ...(frontMatter ? [{ start: 0, end: frontMatter.bodyStart }] : []),\n ...codeRanges,\n ...inlineCode,\n ...comments.map((c) => ({ start: c.start, end: c.end })),\n ];\n const masked = applyMask(text, maskRanges);\n const sortedMask = mergeRanges(maskRanges);\n\n const headings = scanHeadings(lines);\n const listItems = scanListItems(lines, text, masked);\n const links = scanLinks(masked, text, index);\n const tables = scanTables(lines, text, masked);\n\n return {\n text,\n index,\n frontMatter,\n bodyStart,\n lines,\n headings,\n listItems,\n comments,\n links,\n tables,\n masked,\n isMasked: (offset) => containsOffset(sortedMask, offset),\n };\n}\n\n/* -------------------------------------------------------------------------- */\n/* Front matter */\n/* -------------------------------------------------------------------------- */\n\nconst FENCE_FM = /^(-{3,}|\\+{3,})[ \\t]*$/;\n\nfunction readFrontMatter(text: string, index: LineIndex): FrontMatter | null {\n if (index.lineCount === 0) return null;\n const first = index.lineText(1);\n const open = FENCE_FM.exec(first);\n if (!open) return null;\n const closer = (open[1] as string).startsWith('-') ? /^(-{3,}|\\.{3,})[ \\t]*$/ : /^\\+{3,}[ \\t]*$/;\n\n for (let line = 2; line <= index.lineCount; line += 1) {\n if (closer.test(index.lineText(line))) {\n const start = index.lineStart(2);\n const end = index.lineStart(line);\n const bodyStart = line < index.lineCount ? index.lineStart(line + 1) : text.length;\n return { raw: text.slice(start, end), start, end, bodyStart };\n }\n }\n // An unterminated opener is a horizontal rule, not front matter.\n return null;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Line classification */\n/* -------------------------------------------------------------------------- */\n\nconst LIST_MARKER = /^([ \\t]*)([-*+]|\\d{1,9}[.)])([ \\t]+|$)/;\nconst ATX_HEADING = /^ {0,3}(#{1,6})(?:[ \\t]+(.*?))?[ \\t]*(?:#+[ \\t]*)?$/;\nconst SETEXT_UNDERLINE = /^ {0,3}(=+|-+)[ \\t]*$/;\nconst THEMATIC_BREAK = /^ {0,3}(?:(?:\\*[ \\t]*){3,}|(?:-[ \\t]*){3,}|(?:_[ \\t]*){3,})$/;\nconst FENCE_OPEN = /^([ \\t]*)(`{3,}|~{3,})(.*)$/;\n\n/** Counts indentation in columns, expanding tabs to the next multiple of four. */\nfunction measureIndent(line: string): number {\n let width = 0;\n for (const ch of line) {\n if (ch === ' ') width += 1;\n else if (ch === '\\t') width += 4 - (width % 4);\n else break;\n }\n return width;\n}\n\n/** Strips `>` block-quote markers, returning the offset and text of the content. */\nfunction stripQuotes(raw: string, lineStart: number): { contentStart: number; content: string; depth: number } {\n let i = 0;\n let depth = 0;\n for (;;) {\n let j = i;\n let spaces = 0;\n while (j < raw.length && (raw[j] === ' ' || raw[j] === '\\t') && spaces < 3) {\n spaces += 1;\n j += 1;\n }\n if (raw[j] !== '>') break;\n j += 1;\n if (raw[j] === ' ') j += 1;\n depth += 1;\n i = j;\n }\n return { contentStart: lineStart + i, content: raw.slice(i), depth };\n}\n\nfunction scanLines(text: string, index: LineIndex, bodyStart: number): ScannedLine[] {\n const out: ScannedLine[] = [];\n const firstLine = index.positionAt(bodyStart).line;\n\n let fence: { char: string; length: number; indent: number } | null = null;\n let inList = false;\n let listIndent = 0;\n let previousBlank = true;\n let indentedCode = false;\n\n for (let line = firstLine; line <= index.lineCount; line += 1) {\n const start = index.lineStart(line);\n const end = index.lineEnd(line);\n if (end < bodyStart) continue;\n const raw = text.slice(start, end);\n const { contentStart, content, depth } = stripQuotes(raw, start);\n const indent = measureIndent(content);\n const blank = content.trim().length === 0;\n\n let code = false;\n\n if (fence) {\n code = true;\n const close = FENCE_OPEN.exec(content);\n if (\n close &&\n (close[2] as string)[0] === fence.char &&\n (close[2] as string).length >= fence.length &&\n (close[3] as string).trim().length === 0 &&\n measureIndent(close[1] as string) <= fence.indent + 3\n ) {\n fence = null;\n }\n } else {\n const open = FENCE_OPEN.exec(content);\n if (open && (open[3] as string).indexOf('`') === -1) {\n fence = {\n char: (open[2] as string)[0] as string,\n length: (open[2] as string).length,\n indent: measureIndent(open[1] as string),\n };\n code = true;\n indentedCode = false;\n } else if (blank) {\n code = indentedCode;\n } else {\n // Indented code is only recognised outside list containers. Inside a\n // list, four-space indentation is ordinary continuation far more often\n // than it is a code block, and masking a continuation would silently\n // drop the links and resolutions written there.\n if (!inList && indent >= 4 && (previousBlank || indentedCode)) {\n code = true;\n indentedCode = true;\n } else {\n indentedCode = false;\n }\n }\n }\n\n if (!code && !blank) {\n const marker = LIST_MARKER.exec(content);\n if (marker) {\n inList = true;\n listIndent = indent;\n } else if (inList && indent === 0 && previousBlank) {\n inList = false;\n listIndent = 0;\n } else if (inList && indent <= listIndent && previousBlank && ATX_HEADING.test(content)) {\n inList = false;\n listIndent = 0;\n }\n if (ATX_HEADING.test(content) && indent < 4) {\n inList = false;\n listIndent = 0;\n }\n }\n\n out.push({ line, start, end, contentStart, content, indent, blank, quoteDepth: depth, code });\n previousBlank = blank;\n }\n\n return out;\n}\n\nfunction collectCodeRanges(lines: readonly ScannedLine[], bodyStart: number): Range[] {\n const ranges: Range[] = [];\n let open: { start: number; end: number } | null = null;\n for (const line of lines) {\n if (line.code) {\n const start = Math.max(line.start, bodyStart);\n if (open && open.end >= line.start - 2) open.end = line.end;\n else {\n if (open) ranges.push(open);\n open = { start, end: line.end };\n }\n } else if (open) {\n ranges.push(open);\n open = null;\n }\n }\n if (open) ranges.push(open);\n return ranges;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Headings */\n/* -------------------------------------------------------------------------- */\n\nexport function slugify(text: string): string {\n return text\n .trim()\n .toLowerCase()\n .replace(/[`*_~[\\]()<>#!|]/g, '')\n .replace(/[^\\p{L}\\p{N}\\s-]/gu, '')\n .trim()\n // GitHub hyphenates every whitespace character, so a run of two spaces left\n // behind by stripped punctuation becomes two hyphens, not one.\n .replace(/\\s/g, '-');\n}\n\nfunction scanHeadings(lines: readonly ScannedLine[]): Heading[] {\n const out: Heading[] = [];\n for (let i = 0; i < lines.length; i += 1) {\n const line = lines[i] as ScannedLine;\n if (line.code || line.blank) continue;\n\n const atx = ATX_HEADING.exec(line.content);\n if (atx && line.indent < 4) {\n const body = (atx[2] ?? '').trim();\n out.push({\n level: (atx[1] as string).length,\n text: body,\n slug: slugify(body),\n start: line.contentStart,\n end: line.end,\n line: line.line,\n });\n continue;\n }\n\n // Setext: an underline of `=` or `-` directly below a paragraph line. The\n // preceding line must not itself be a heading, a list item or a fence.\n const next = lines[i + 1];\n if (!next || next.code || next.blank) continue;\n const under = SETEXT_UNDERLINE.exec(next.content);\n if (!under) continue;\n if (LIST_MARKER.test(line.content) || THEMATIC_BREAK.test(line.content)) continue;\n if (line.indent >= 4) continue;\n const body = line.content.trim();\n if (body.length === 0) continue;\n out.push({\n level: (under[1] as string)[0] === '=' ? 1 : 2,\n text: body,\n slug: slugify(body),\n start: line.contentStart,\n end: next.end,\n line: line.line,\n });\n }\n return out;\n}\n\n/* -------------------------------------------------------------------------- */\n/* List items */\n/* -------------------------------------------------------------------------- */\n\nconst CHECKBOX = /^\\[([ xX~\\-?!*/+])\\](?=[ \\t]|$)/;\n\nfunction scanListItems(lines: readonly ScannedLine[], text: string, masked: string): ListItem[] {\n const out: ListItem[] = [];\n // Indents of the list items currently enclosing the cursor, outermost first.\n const stack: number[] = [];\n\n for (let i = 0; i < lines.length; i += 1) {\n const line = lines[i] as ScannedLine;\n if (line.code || line.blank) continue;\n const marker = LIST_MARKER.exec(line.content);\n if (!marker) continue;\n\n const indent = measureIndent(marker[1] as string);\n while (stack.length > 0 && indent <= (stack[stack.length - 1] as number)) stack.pop();\n const depth = stack.length;\n stack.push(indent);\n\n const markerStart = line.contentStart + (marker[1] as string).length;\n let textStart = markerStart + (marker[2] as string).length + (marker[3] as string).length;\n\n const rest = text.slice(textStart, line.end);\n const box = CHECKBOX.exec(rest);\n let checkbox: string | null = null;\n let checkboxStart: number | null = null;\n if (box) {\n checkbox = box[1] as string;\n checkboxStart = textStart;\n textStart += (box[0] as string).length;\n while (text[textStart] === ' ' || text[textStart] === '\\t') textStart += 1;\n }\n\n const end = findItemEnd(lines, i, indent);\n const firstLine = text.slice(textStart, line.end).trim();\n const body = text.slice(textStart, end);\n\n out.push({\n start: line.contentStart,\n end,\n markerStart,\n marker: marker[2] as string,\n textStart,\n checkbox,\n checkboxStart,\n firstLine,\n body,\n maskedBody: masked.slice(textStart, end),\n line: line.line,\n depth,\n indent,\n });\n }\n\n return out;\n}\n\n/**\n * Finds where a list item block ends.\n *\n * The item owns its wrapped continuation lines and everything nested under it.\n * It gives up ownership at the next sibling or shallower marker, at any\n * heading, and at the first non-indented line after a blank one.\n */\nfunction findItemEnd(lines: readonly ScannedLine[], startIndex: number, indent: number): number {\n let end = (lines[startIndex] as ScannedLine).end;\n let sawBlank = false;\n\n for (let i = startIndex + 1; i < lines.length; i += 1) {\n const line = lines[i] as ScannedLine;\n if (line.blank) {\n sawBlank = true;\n continue;\n }\n if (!line.code) {\n if (line.indent < 4 && ATX_HEADING.test(line.content)) break;\n if (line.indent <= indent) {\n if (sawBlank) break;\n if (LIST_MARKER.test(line.content)) break;\n if (THEMATIC_BREAK.test(line.content)) break;\n }\n }\n if (line.indent <= indent && sawBlank) break;\n end = line.end;\n sawBlank = false;\n }\n\n return end;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Tables */\n/* -------------------------------------------------------------------------- */\n\n/** `| :--- | ---: | :-: |` - the row that makes the line above it a header. */\nconst TABLE_DELIMITER = /^\\|?(?:\\s*:?-+:?\\s*\\|)+\\s*:?-*:?\\s*\\|?$/;\n\n/**\n * Finds pipe tables, with an offset for every cell.\n *\n * Cell offsets are the point: a register kept as a table needs findings that\n * name the cell declaring the relation, not the row and not the file.\n *\n * Splitting happens on the masked copy so a pipe inside inline code cannot\n * invent a column, while the text comes from the original.\n */\nfunction scanTables(lines: readonly ScannedLine[], text: string, masked: string): Table[] {\n const out: Table[] = [];\n\n for (let i = 0; i < lines.length - 1; i += 1) {\n const header = lines[i] as ScannedLine;\n const delimiter = lines[i + 1] as ScannedLine;\n if (header.code || header.blank || delimiter.code) continue;\n if (!header.content.includes('|')) continue;\n if (!TABLE_DELIMITER.test(delimiter.content.trim())) continue;\n\n const headers = splitRow(header, text, masked);\n if (headers.length === 0) continue;\n\n const rows: TableRow[] = [];\n let end = delimiter.end;\n for (let j = i + 2; j < lines.length; j += 1) {\n const line = lines[j] as ScannedLine;\n if (line.blank || line.code || !line.content.includes('|')) break;\n const cells = splitRow(line, text, masked);\n if (cells.length === 0) break;\n rows.push({ cells, start: line.contentStart, end: line.end, line: line.line });\n end = line.end;\n }\n\n out.push({ start: header.contentStart, end, headers, rows });\n i += rows.length + 1;\n }\n\n return out;\n}\n\n/** Splits one row into cells, keeping each cell's offset in the source. */\nfunction splitRow(line: ScannedLine, text: string, masked: string): TableCell[] {\n const from = line.contentStart;\n const to = line.end;\n const bounds: number[] = [];\n for (let i = from; i < to; i += 1) {\n if (masked[i] !== '|') continue;\n // A pipe escaped with a backslash is content, not a column edge.\n if (i > from && text[i - 1] === '\\\\') continue;\n bounds.push(i);\n }\n if (bounds.length === 0) return [];\n\n const cells: TableCell[] = [];\n // A leading pipe opens the first cell; without one the row starts at `from`.\n let cursor = (bounds[0] as number) === from ? from + 1 : from;\n for (const bound of bounds) {\n if (bound < cursor) continue;\n cells.push(makeCell(text, cursor, bound));\n cursor = bound + 1;\n }\n // Trailing content after the last pipe is a final cell unless the row ended\n // with a border pipe.\n if (cursor < to && text.slice(cursor, to).trim().length > 0) cells.push(makeCell(text, cursor, to));\n\n return cells;\n}\n\nfunction makeCell(text: string, start: number, end: number): TableCell {\n const raw = text.slice(start, end);\n const leading = raw.length - raw.trimStart().length;\n const trimmed = raw.trim();\n return { text: trimmed, start: start + leading, end: start + leading + trimmed.length };\n}\n\n/* -------------------------------------------------------------------------- */\n/* HTML comments */\n/* -------------------------------------------------------------------------- */\n\nfunction scanComments(text: string, index: LineIndex, bodyStart: number, code: readonly Range[]): HtmlComment[] {\n const out: HtmlComment[] = [];\n const merged = mergeRanges(code);\n let from = bodyStart;\n for (;;) {\n const open = text.indexOf('<!--', from);\n if (open === -1) break;\n if (containsOffset(merged, open)) {\n from = open + 4;\n continue;\n }\n const close = text.indexOf('-->', open + 4);\n if (close === -1) break;\n out.push({\n start: open,\n end: close + 3,\n inner: text.slice(open + 4, close),\n innerStart: open + 4,\n line: index.positionAt(open).line,\n });\n from = close + 3;\n }\n return out;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Inline code */\n/* -------------------------------------------------------------------------- */\n\nfunction scanInlineCode(\n text: string,\n bodyStart: number,\n code: readonly Range[],\n comments: readonly HtmlComment[],\n): Range[] {\n const blocked = mergeRanges([...code, ...comments.map((c) => ({ start: c.start, end: c.end }))]);\n const out: Range[] = [];\n let i = bodyStart;\n\n while (i < text.length) {\n if (text[i] !== '`') {\n i += 1;\n continue;\n }\n if (containsOffset(blocked, i)) {\n i += 1;\n continue;\n }\n let runStart = i;\n while (text[i] === '`') i += 1;\n const runLength = i - runStart;\n // An escaped backtick does not open a span.\n if (runStart > 0 && text[runStart - 1] === '\\\\') continue;\n\n let j = i;\n let closed = -1;\n while (j < text.length) {\n if (text[j] !== '`') {\n j += 1;\n continue;\n }\n const closeStart = j;\n while (text[j] === '`') j += 1;\n if (j - closeStart === runLength && !containsOffset(blocked, closeStart)) {\n closed = j;\n break;\n }\n }\n if (closed === -1) continue;\n out.push({ start: runStart, end: closed });\n i = closed;\n }\n\n return out;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Masking */\n/* -------------------------------------------------------------------------- */\n\nfunction mergeRanges(ranges: readonly Range[]): Range[] {\n if (ranges.length === 0) return [];\n const sorted = [...ranges].sort((a, b) => a.start - b.start || a.end - b.end);\n const out: Range[] = [{ ...(sorted[0] as Range) }];\n for (let i = 1; i < sorted.length; i += 1) {\n const next = sorted[i] as Range;\n const last = out[out.length - 1] as { start: number; end: number };\n if (next.start <= last.end) last.end = Math.max(last.end, next.end);\n else out.push({ ...next });\n }\n return out;\n}\n\nfunction containsOffset(sorted: readonly Range[], offset: number): boolean {\n let lo = 0;\n let hi = sorted.length - 1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n const range = sorted[mid] as Range;\n if (offset < range.start) hi = mid - 1;\n else if (offset >= range.end) lo = mid + 1;\n else return true;\n }\n return false;\n}\n\n/**\n * Blanks out the given ranges.\n *\n * Line terminators survive so every offset, line and column in the masked copy\n * still matches the original. Callers slice the original text for content and\n * search the masked copy for structure.\n */\nfunction applyMask(text: string, ranges: readonly Range[]): string {\n const merged = mergeRanges(ranges);\n if (merged.length === 0) return text;\n\n // Built from slices rather than a per-character array. Masking runs over every\n // byte of every document, and a `split('')`/`join('')` round trip allocates an\n // array entry per character - on a large corpus that was the single most\n // expensive thing the scanner did.\n let out = '';\n let cursor = 0;\n for (const range of merged) {\n const start = Math.max(range.start, cursor);\n const end = Math.min(range.end, text.length);\n if (end <= start) continue;\n out += text.slice(cursor, start);\n // The character class is deliberately not Unicode-aware: a surrogate pair\n // must become two spaces so that every later offset still lines up.\n out += text.slice(start, end).replace(NON_TERMINATOR, ' ');\n cursor = end;\n }\n return out + text.slice(cursor);\n}\n\nconst NON_TERMINATOR = /[^\\n\\r]/g;\n\n/* -------------------------------------------------------------------------- */\n/* Links */\n/* -------------------------------------------------------------------------- */\n\nconst DEFINITION = /^ {0,3}\\[([^\\]\\n]+)\\]:[ \\t]*(<[^>\\n]*>|\\S+)/;\nconst AUTOLINK = /<((?:https?|ftp|mailto):[^>\\s]+)>/g;\n\n/** How far a bracket construct may run before we call it unbalanced prose. */\nconst MAX_LINK_SPAN = 4096;\n\nfunction scanLinks(masked: string, text: string, index: LineIndex): Link[] {\n const out: Link[] = [];\n const definitions = new Set<string>();\n const definitionRanges: Range[] = [];\n\n // Pass 1: reference definitions, which also make shortcut links resolvable.\n for (let line = 1; line <= index.lineCount; line += 1) {\n const start = index.lineStart(line);\n const content = masked.slice(start, index.lineEnd(line));\n const match = DEFINITION.exec(content);\n if (!match) continue;\n const label = (match[1] as string).trim().toLowerCase();\n definitions.add(label);\n const rawTarget = match[2] as string;\n const targetStart = start + content.indexOf(rawTarget, (match[1] as string).length);\n definitionRanges.push({ start, end: start + (match[0] as string).length });\n out.push({\n text: (match[1] as string).trim(),\n target: unwrapAngle(rawTarget),\n start,\n end: start + (match[0] as string).length,\n targetStart,\n form: 'definition',\n line,\n });\n }\n\n // Pass 2: autolinks.\n AUTOLINK.lastIndex = 0;\n for (let m = AUTOLINK.exec(masked); m !== null; m = AUTOLINK.exec(masked)) {\n const start = m.index;\n out.push({\n text: '',\n target: m[1] as string,\n start,\n end: start + (m[0] as string).length,\n targetStart: start + 1,\n form: 'autolink',\n line: index.positionAt(start).line,\n });\n }\n\n // Pass 3: bracket constructs, left to right.\n const definedAt = mergeRanges(definitionRanges);\n let i = 0;\n while (i < masked.length) {\n const ch = masked[i];\n if (ch !== '[') {\n i += 1;\n continue;\n }\n // The label of a definition is not itself a shortcut link to anything.\n if (containsOffset(definedAt, i)) {\n i += 1;\n continue;\n }\n const isImage = i > 0 && masked[i - 1] === '!';\n\n if (masked[i + 1] === '[') {\n const close = masked.indexOf(']]', i + 2);\n if (close !== -1 && close - i <= MAX_LINK_SPAN && masked.slice(i + 2, close).indexOf('\\n') === -1) {\n const target = text.slice(i + 2, close).trim();\n if (target.length > 0) {\n out.push({\n text: target,\n target: wikiTarget(target),\n start: i,\n end: close + 2,\n targetStart: i + 2,\n form: 'wiki',\n line: index.positionAt(i).line,\n });\n i = close + 2;\n continue;\n }\n }\n }\n\n const labelEnd = matchBracket(masked, i);\n if (labelEnd === -1) {\n i += 1;\n continue;\n }\n const label = text.slice(i + 1, labelEnd);\n const after = masked[labelEnd + 1];\n\n if (after === '(') {\n const dest = readDestination(masked, labelEnd + 2);\n if (dest) {\n if (!isImage) {\n out.push({\n text: label.trim(),\n target: unwrapAngle(text.slice(dest.start, dest.end).trim()),\n start: isImage ? i - 1 : i,\n end: dest.close + 1,\n targetStart: dest.start,\n form: 'inline',\n line: index.positionAt(i).line,\n });\n }\n i = dest.close + 1;\n continue;\n }\n } else if (after === '[') {\n const refEnd = matchBracket(masked, labelEnd + 1);\n if (refEnd !== -1) {\n const ref = text.slice(labelEnd + 2, refEnd).trim();\n const resolved = ref.length > 0 ? ref : label.trim();\n if (!isImage) {\n out.push({\n text: label.trim(),\n target: resolved,\n start: isImage ? i - 1 : i,\n end: refEnd + 1,\n targetStart: ref.length > 0 ? labelEnd + 2 : i + 1,\n form: 'reference',\n line: index.positionAt(i).line,\n });\n }\n i = refEnd + 1;\n continue;\n }\n } else if (!isImage && definitions.has(label.trim().toLowerCase())) {\n out.push({\n text: label.trim(),\n target: label.trim(),\n start: i,\n end: labelEnd + 1,\n targetStart: i + 1,\n form: 'shortcut',\n line: index.positionAt(i).line,\n });\n i = labelEnd + 1;\n continue;\n }\n\n i = labelEnd + 1;\n }\n\n out.sort((a, b) => a.start - b.start);\n return out;\n}\n\n/** Finds the `]` matching the `[` at `open`, honouring nesting and escapes. */\nfunction matchBracket(text: string, open: number): number {\n let depth = 0;\n const limit = Math.min(text.length, open + MAX_LINK_SPAN);\n for (let i = open; i < limit; i += 1) {\n const ch = text[i];\n if (ch === '\\\\') {\n i += 1;\n continue;\n }\n if (ch === '\\n' && text[i + 1] === '\\n') return -1;\n if (ch === '[') depth += 1;\n else if (ch === ']') {\n depth -= 1;\n if (depth === 0) return i;\n }\n }\n return -1;\n}\n\n/** Reads a link destination starting just after `(`. */\nfunction readDestination(text: string, from: number): { start: number; end: number; close: number } | null {\n let i = from;\n const limit = Math.min(text.length, from + MAX_LINK_SPAN);\n while (i < limit && (text[i] === ' ' || text[i] === '\\t' || text[i] === '\\n')) i += 1;\n\n const start = i;\n if (text[i] === '<') {\n const close = text.indexOf('>', i + 1);\n if (close === -1 || close > limit) return null;\n const paren = text.indexOf(')', close);\n if (paren === -1 || paren > limit) return null;\n return { start, end: close + 1, close: paren };\n }\n\n let depth = 0;\n while (i < limit) {\n const ch = text[i];\n if (ch === '\\\\') {\n i += 2;\n continue;\n }\n if (ch === '(') depth += 1;\n else if (ch === ')') {\n if (depth === 0) break;\n depth -= 1;\n } else if (ch === ' ' || ch === '\\t' || ch === '\\n') break;\n i += 1;\n }\n const end = i;\n // Skip an optional title, then require the closing paren.\n let j = i;\n while (j < limit && text[j] !== ')') {\n if (text[j] === '\\n' && text[j + 1] === '\\n') return null;\n j += 1;\n }\n if (j >= limit || text[j] !== ')') return null;\n if (end === start) return null;\n return { start, end, close: j };\n}\n\nfunction unwrapAngle(value: string): string {\n return value.startsWith('<') && value.endsWith('>') ? value.slice(1, -1) : value;\n}\n\n/** `[[0007-thing|Display]]` and `[[0007-thing]]` both target `0007-thing`. */\nfunction wikiTarget(raw: string): string {\n const pipe = raw.indexOf('|');\n return (pipe === -1 ? raw : raw.slice(0, pipe)).trim();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,eAAe,EAAkB,MAAM,aAAa,CAAC;AAgK9D,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACxE,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,WAAW,GAAG,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACjD,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAE1D,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IAChD,4EAA4E;IAC5E,8EAA8E;IAC9E,yEAAyE;IACzE,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,GAAG,iBAAiB,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,kBAAkB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAA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AAC9E,SAAS,UAAU,CAAC,GAAW;IAC7B,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC9B,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACzD,CAAC","sourcesContent":["/**\n * A structural Markdown scanner.\n *\n * This is deliberately **not** a CommonMark implementation. spec-graph needs six\n * things from a document - front matter, headings, list items with their\n * continuations, HTML comments, links, and a reliable map of what is code - and\n * a full parser would cost a dependency tree, an AST walk, and a position\n * mapping layer to get back the offsets we want in the first place.\n *\n * What the scanner does guarantee is the part that makes regex-based spec\n * linters lie:\n *\n * - **Code never counts.** Fenced blocks, indented blocks and inline spans are\n * masked before a single link is extracted, so an example in a code sample\n * never becomes a graph edge.\n * - **Items are blocks, not lines.** A list item owns its wrapped continuation\n * lines and its nested content, so a resolution written on the second line of\n * a bullet is found instead of missed.\n * - **Everything carries absolute offsets.** No re-scanning, no drift between\n * the text a rule matched and the position it reports.\n */\n\nimport { createLineIndex, type LineIndex } from './source.js';\n\n/* -------------------------------------------------------------------------- */\n/* Shapes */\n/* -------------------------------------------------------------------------- */\n\nexport interface Range {\n readonly start: number;\n readonly end: number;\n}\n\nexport interface FrontMatter {\n /** The body between the delimiters, exclusive. */\n readonly raw: string;\n /** Offset of the first character of `raw`. */\n readonly start: number;\n readonly end: number;\n /** Offset just past the closing delimiter line. */\n readonly bodyStart: number;\n}\n\nexport interface ScannedLine {\n /** 1-based. */\n readonly line: number;\n /** Offset of the raw line start. */\n readonly start: number;\n /** Offset just past the line, excluding its terminator. */\n readonly end: number;\n /** Offset of the first character after any block-quote markers. */\n readonly contentStart: number;\n /** Line text after block-quote markers, indentation intact. */\n readonly content: string;\n /** Indentation of `content`, tabs counted as four columns. */\n readonly indent: number;\n readonly blank: boolean;\n readonly quoteDepth: number;\n /** Inside a fenced or indented code block, fence delimiters included. */\n readonly code: boolean;\n}\n\nexport interface Heading {\n readonly level: number;\n readonly text: string;\n /** GitHub-compatible anchor slug. */\n readonly slug: string;\n readonly start: number;\n readonly end: number;\n readonly line: number;\n}\n\nexport interface ListItem {\n /** The whole block: marker line plus continuations and nested content. */\n readonly start: number;\n readonly end: number;\n /** Offset of the list marker itself. */\n readonly markerStart: number;\n readonly marker: string;\n /** Offset where the item text begins, after marker and any checkbox. */\n readonly textStart: number;\n /** The character inside `[ ]`, or `null` when the item has no checkbox. */\n readonly checkbox: string | null;\n readonly checkboxStart: number | null;\n /** First line of item text, trimmed. */\n readonly firstLine: string;\n /** Full item text including continuations and nested content. */\n readonly body: string;\n /**\n * `body` with code and comments blanked out, same length and offsets.\n *\n * Anything that searches item text for meaning - resolution markers above\n * all - must read this rather than `body`, or a fenced example nested under\n * the item will close it.\n */\n readonly maskedBody: string;\n readonly line: number;\n /** How many list items enclose this one. Top-level items are `0`. */\n readonly depth: number;\n readonly indent: number;\n}\n\nexport interface HtmlComment {\n readonly start: number;\n readonly end: number;\n /** Text between `<!--` and `-->`. */\n readonly inner: string;\n readonly innerStart: number;\n readonly line: number;\n}\n\nexport type LinkForm = 'inline' | 'reference' | 'shortcut' | 'autolink' | 'wiki' | 'definition';\n\nexport interface Link {\n /** Visible label. Empty for autolinks and definitions. */\n readonly text: string;\n /** Destination as written: a path or a URL. */\n readonly target: string;\n /** Offset of the whole construct. */\n readonly start: number;\n readonly end: number;\n /**\n * Offset of `target` inside the source, for precise diagnostics.\n *\n * For a reference link this is inside the definition, not inside the use:\n * `[design][one]` has no destination of its own, and the line a human edits\n * to fix it is the one that says what `one` points at.\n */\n readonly targetStart: number;\n /**\n * The reference label, for the two forms written with one.\n *\n * `null` everywhere else. Kept because `target` is the destination the label\n * stands for, and a report quoting `[design][docs/gone.md]` would be quoting\n * something the author never wrote.\n */\n readonly label: string | null;\n readonly form: LinkForm;\n readonly line: number;\n}\n\nexport interface TableCell {\n /** Cell text as written, trimmed. */\n readonly text: string;\n /** Offset of the trimmed text, so a finding can point at the cell itself. */\n readonly start: number;\n readonly end: number;\n}\n\nexport interface TableRow {\n readonly cells: readonly TableCell[];\n readonly start: number;\n readonly end: number;\n readonly line: number;\n}\n\nexport interface Table {\n readonly start: number;\n readonly end: number;\n /** Header cells, trimmed. A table without a header row is not a table. */\n readonly headers: readonly TableCell[];\n readonly rows: readonly TableRow[];\n}\n\nexport interface ScannedDocument {\n readonly text: string;\n readonly index: LineIndex;\n readonly frontMatter: FrontMatter | null;\n /** Offset where the body starts, after any front matter. */\n readonly bodyStart: number;\n readonly lines: readonly ScannedLine[];\n readonly headings: readonly Heading[];\n readonly listItems: readonly ListItem[];\n readonly comments: readonly HtmlComment[];\n readonly links: readonly Link[];\n readonly tables: readonly Table[];\n /** Code and comments blanked out, offsets and line breaks preserved. */\n readonly masked: string;\n /** True when the offset falls inside code, a comment, or front matter. */\n isMasked(offset: number): boolean;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Entry point */\n/* -------------------------------------------------------------------------- */\n\nexport function scanMarkdown(source: string): ScannedDocument {\n const text = source.charCodeAt(0) === 0xfeff ? source.slice(1) : source;\n const index = createLineIndex(text);\n const frontMatter = readFrontMatter(text, index);\n const bodyStart = frontMatter ? frontMatter.bodyStart : 0;\n\n const lines = scanLines(text, index, bodyStart);\n // Raw-text HTML joins the code ranges rather than sitting beside them: what\n // both have in common is that their content is not Markdown, and every reader\n // downstream - comments, links, tables - already asks that one question.\n const codeRanges = mergeRanges([...collectCodeRanges(lines, bodyStart), ...collectRawTextHtml(lines, bodyStart)]);\n const comments = scanComments(text, index, bodyStart, codeRanges);\n\n const inlineCode = scanInlineCode(text, bodyStart, codeRanges, comments);\n const maskRanges = [\n ...(frontMatter ? [{ start: 0, end: frontMatter.bodyStart }] : []),\n ...codeRanges,\n ...inlineCode,\n ...comments.map((c) => ({ start: c.start, end: c.end })),\n ];\n const masked = applyMask(text, maskRanges);\n const sortedMask = mergeRanges(maskRanges);\n\n const headings = scanHeadings(lines);\n const listItems = scanListItems(lines, text, masked);\n const links = scanLinks(masked, text, index);\n const tables = scanTables(lines, text, masked);\n\n return {\n text,\n index,\n frontMatter,\n bodyStart,\n lines,\n headings,\n listItems,\n comments,\n links,\n tables,\n masked,\n isMasked: (offset) => containsOffset(sortedMask, offset),\n };\n}\n\n/* -------------------------------------------------------------------------- */\n/* Front matter */\n/* -------------------------------------------------------------------------- */\n\nconst FENCE_FM = /^(-{3,}|\\+{3,})[ \\t]*$/;\n\nfunction readFrontMatter(text: string, index: LineIndex): FrontMatter | null {\n if (index.lineCount === 0) return null;\n const first = index.lineText(1);\n const open = FENCE_FM.exec(first);\n if (!open) return null;\n const closer = (open[1] as string).startsWith('-') ? /^(-{3,}|\\.{3,})[ \\t]*$/ : /^\\+{3,}[ \\t]*$/;\n\n for (let line = 2; line <= index.lineCount; line += 1) {\n if (closer.test(index.lineText(line))) {\n const start = index.lineStart(2);\n const end = index.lineStart(line);\n const bodyStart = line < index.lineCount ? index.lineStart(line + 1) : text.length;\n return { raw: text.slice(start, end), start, end, bodyStart };\n }\n }\n // An unterminated opener is a horizontal rule, not front matter.\n return null;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Line classification */\n/* -------------------------------------------------------------------------- */\n\nconst LIST_MARKER = /^([ \\t]*)([-*+]|\\d{1,9}[.)])([ \\t]+|$)/;\nconst ATX_HEADING = /^ {0,3}(#{1,6})(?:[ \\t]+(.*?))?[ \\t]*(?:#+[ \\t]*)?$/;\nconst SETEXT_UNDERLINE = /^ {0,3}(=+|-+)[ \\t]*$/;\nconst THEMATIC_BREAK = /^ {0,3}(?:(?:\\*[ \\t]*){3,}|(?:-[ \\t]*){3,}|(?:_[ \\t]*){3,})$/;\nconst FENCE_OPEN = /^([ \\t]*)(`{3,}|~{3,})(.*)$/;\n\n/** Counts indentation in columns, expanding tabs to the next multiple of four. */\nfunction measureIndent(line: string): number {\n let width = 0;\n for (const ch of line) {\n if (ch === ' ') width += 1;\n else if (ch === '\\t') width += 4 - (width % 4);\n else break;\n }\n return width;\n}\n\n/** Strips `>` block-quote markers, returning the offset and text of the content. */\nfunction stripQuotes(raw: string, lineStart: number): { contentStart: number; content: string; depth: number } {\n let i = 0;\n let depth = 0;\n for (;;) {\n let j = i;\n let spaces = 0;\n while (j < raw.length && (raw[j] === ' ' || raw[j] === '\\t') && spaces < 3) {\n spaces += 1;\n j += 1;\n }\n if (raw[j] !== '>') break;\n j += 1;\n if (raw[j] === ' ') j += 1;\n depth += 1;\n i = j;\n }\n return { contentStart: lineStart + i, content: raw.slice(i), depth };\n}\n\nfunction scanLines(text: string, index: LineIndex, bodyStart: number): ScannedLine[] {\n const out: ScannedLine[] = [];\n const firstLine = index.positionAt(bodyStart).line;\n\n let fence: { char: string; length: number; indent: number } | null = null;\n let inList = false;\n let listIndent = 0;\n let previousBlank = true;\n let indentedCode = false;\n\n for (let line = firstLine; line <= index.lineCount; line += 1) {\n const start = index.lineStart(line);\n const end = index.lineEnd(line);\n if (end < bodyStart) continue;\n const raw = text.slice(start, end);\n const { contentStart, content, depth } = stripQuotes(raw, start);\n const indent = measureIndent(content);\n const blank = content.trim().length === 0;\n\n let code = false;\n\n if (fence) {\n code = true;\n const close = FENCE_OPEN.exec(content);\n if (\n close &&\n (close[2] as string)[0] === fence.char &&\n (close[2] as string).length >= fence.length &&\n (close[3] as string).trim().length === 0 &&\n measureIndent(close[1] as string) <= fence.indent + 3\n ) {\n fence = null;\n }\n } else {\n const open = FENCE_OPEN.exec(content);\n if (open && (open[3] as string).indexOf('`') === -1) {\n fence = {\n char: (open[2] as string)[0] as string,\n length: (open[2] as string).length,\n indent: measureIndent(open[1] as string),\n };\n code = true;\n indentedCode = false;\n } else if (blank) {\n code = indentedCode;\n } else {\n // Indented code is only recognised outside list containers. Inside a\n // list, four-space indentation is ordinary continuation far more often\n // than it is a code block, and masking a continuation would silently\n // drop the links and resolutions written there.\n if (!inList && indent >= 4 && (previousBlank || indentedCode)) {\n code = true;\n indentedCode = true;\n } else {\n indentedCode = false;\n }\n }\n }\n\n if (!code && !blank) {\n const marker = LIST_MARKER.exec(content);\n if (marker) {\n inList = true;\n listIndent = indent;\n } else if (inList && indent === 0 && previousBlank) {\n inList = false;\n listIndent = 0;\n } else if (inList && indent <= listIndent && previousBlank && ATX_HEADING.test(content)) {\n inList = false;\n listIndent = 0;\n }\n if (ATX_HEADING.test(content) && indent < 4) {\n inList = false;\n listIndent = 0;\n }\n }\n\n out.push({ line, start, end, contentStart, content, indent, blank, quoteDepth: depth, code });\n previousBlank = blank;\n }\n\n return out;\n}\n\n/**\n * `<script>`, `<style>`, `<pre>` and `<textarea>` blocks.\n *\n * These four are the only HTML elements whose content is not Markdown - the\n * CommonMark spec calls them out by name for exactly that reason - and the\n * distinction is load-bearing here rather than pedantic. A page explaining how\n * to annotate a document puts `<!-- @spec-node id=\"...\" -->` inside a script\n * sample or a `<pre>` block, and reading that as a directive lets a worked\n * example rename the document it appears in.\n *\n * `<div>` and `<details>` are deliberately not on the list. Their content *is*\n * Markdown, and a decision written inside a collapsed `<details>` section is\n * still a decision.\n */\nconst RAW_TEXT_OPEN = /^<(script|pre|style|textarea)(?:[\\s>]|$)/i;\nconst RAW_TEXT_CLOSE = /<\\/(?:script|pre|style|textarea)>/i;\n\nfunction collectRawTextHtml(lines: readonly ScannedLine[], bodyStart: number): Range[] {\n const ranges: Range[] = [];\n let open: { start: number; end: number } | null = null;\n for (const line of lines) {\n if (line.code) continue;\n if (open === null) {\n if (!RAW_TEXT_OPEN.test(line.content.trimStart())) continue;\n open = { start: Math.max(line.start, bodyStart), end: line.end };\n } else {\n open.end = line.end;\n }\n // The close tag ends the block on the line that carries it, whichever of\n // the four it names. An unclosed block runs to the end of the document,\n // which is what a browser does with it too.\n if (RAW_TEXT_CLOSE.test(line.content)) {\n ranges.push(open);\n open = null;\n }\n }\n if (open) ranges.push(open);\n return ranges;\n}\n\nfunction collectCodeRanges(lines: readonly ScannedLine[], bodyStart: number): Range[] {\n const ranges: Range[] = [];\n let open: { start: number; end: number } | null = null;\n for (const line of lines) {\n if (line.code) {\n const start = Math.max(line.start, bodyStart);\n if (open && open.end >= line.start - 2) open.end = line.end;\n else {\n if (open) ranges.push(open);\n open = { start, end: line.end };\n }\n } else if (open) {\n ranges.push(open);\n open = null;\n }\n }\n if (open) ranges.push(open);\n return ranges;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Headings */\n/* -------------------------------------------------------------------------- */\n\nexport function slugify(text: string): string {\n return text\n .trim()\n .toLowerCase()\n .replace(/[`*_~[\\]()<>#!|]/g, '')\n .replace(/[^\\p{L}\\p{N}\\s-]/gu, '')\n .trim()\n // GitHub hyphenates every whitespace character, so a run of two spaces left\n // behind by stripped punctuation becomes two hyphens, not one.\n .replace(/\\s/g, '-');\n}\n\nfunction scanHeadings(lines: readonly ScannedLine[]): Heading[] {\n const out: Heading[] = [];\n for (let i = 0; i < lines.length; i += 1) {\n const line = lines[i] as ScannedLine;\n if (line.code || line.blank) continue;\n\n const atx = ATX_HEADING.exec(line.content);\n if (atx && line.indent < 4) {\n const body = (atx[2] ?? '').trim();\n out.push({\n level: (atx[1] as string).length,\n text: body,\n slug: slugify(body),\n start: line.contentStart,\n end: line.end,\n line: line.line,\n });\n continue;\n }\n\n // Setext: an underline of `=` or `-` directly below a paragraph line. The\n // preceding line must not itself be a heading, a list item or a fence.\n const next = lines[i + 1];\n if (!next || next.code || next.blank) continue;\n const under = SETEXT_UNDERLINE.exec(next.content);\n if (!under) continue;\n if (LIST_MARKER.test(line.content) || THEMATIC_BREAK.test(line.content)) continue;\n if (line.indent >= 4) continue;\n const body = line.content.trim();\n if (body.length === 0) continue;\n out.push({\n level: (under[1] as string)[0] === '=' ? 1 : 2,\n text: body,\n slug: slugify(body),\n start: line.contentStart,\n end: next.end,\n line: line.line,\n });\n }\n return out;\n}\n\n/* -------------------------------------------------------------------------- */\n/* List items */\n/* -------------------------------------------------------------------------- */\n\nconst CHECKBOX = /^\\[([ xX~\\-?!*/+])\\](?=[ \\t]|$)/;\n\nfunction scanListItems(lines: readonly ScannedLine[], text: string, masked: string): ListItem[] {\n const out: ListItem[] = [];\n // Indents of the list items currently enclosing the cursor, outermost first.\n const stack: number[] = [];\n\n for (let i = 0; i < lines.length; i += 1) {\n const line = lines[i] as ScannedLine;\n if (line.code || line.blank) continue;\n const marker = LIST_MARKER.exec(line.content);\n if (!marker) continue;\n\n const indent = measureIndent(marker[1] as string);\n while (stack.length > 0 && indent <= (stack[stack.length - 1] as number)) stack.pop();\n const depth = stack.length;\n stack.push(indent);\n\n const markerStart = line.contentStart + (marker[1] as string).length;\n let textStart = markerStart + (marker[2] as string).length + (marker[3] as string).length;\n\n const rest = text.slice(textStart, line.end);\n const box = CHECKBOX.exec(rest);\n let checkbox: string | null = null;\n let checkboxStart: number | null = null;\n if (box) {\n checkbox = box[1] as string;\n checkboxStart = textStart;\n textStart += (box[0] as string).length;\n while (text[textStart] === ' ' || text[textStart] === '\\t') textStart += 1;\n }\n\n const end = findItemEnd(lines, i, indent);\n const firstLine = text.slice(textStart, line.end).trim();\n const body = text.slice(textStart, end);\n\n out.push({\n start: line.contentStart,\n end,\n markerStart,\n marker: marker[2] as string,\n textStart,\n checkbox,\n checkboxStart,\n firstLine,\n body,\n maskedBody: masked.slice(textStart, end),\n line: line.line,\n depth,\n indent,\n });\n }\n\n return out;\n}\n\n/**\n * Finds where a list item block ends.\n *\n * The item owns its wrapped continuation lines and everything nested under it.\n * It gives up ownership at the next sibling or shallower marker, at any\n * heading, and at the first non-indented line after a blank one.\n */\nfunction findItemEnd(lines: readonly ScannedLine[], startIndex: number, indent: number): number {\n let end = (lines[startIndex] as ScannedLine).end;\n let sawBlank = false;\n\n for (let i = startIndex + 1; i < lines.length; i += 1) {\n const line = lines[i] as ScannedLine;\n if (line.blank) {\n sawBlank = true;\n continue;\n }\n if (!line.code) {\n if (line.indent < 4 && ATX_HEADING.test(line.content)) break;\n if (line.indent <= indent) {\n if (sawBlank) break;\n if (LIST_MARKER.test(line.content)) break;\n if (THEMATIC_BREAK.test(line.content)) break;\n }\n }\n if (line.indent <= indent && sawBlank) break;\n end = line.end;\n sawBlank = false;\n }\n\n return end;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Tables */\n/* -------------------------------------------------------------------------- */\n\n/** `| :--- | ---: | :-: |` - the row that makes the line above it a header. */\nconst TABLE_DELIMITER = /^\\|?(?:\\s*:?-+:?\\s*\\|)+\\s*:?-*:?\\s*\\|?$/;\n\n/**\n * Finds pipe tables, with an offset for every cell.\n *\n * Cell offsets are the point: a register kept as a table needs findings that\n * name the cell declaring the relation, not the row and not the file.\n *\n * Splitting happens on the masked copy so a pipe inside inline code cannot\n * invent a column, while the text comes from the original.\n */\nfunction scanTables(lines: readonly ScannedLine[], text: string, masked: string): Table[] {\n const out: Table[] = [];\n\n for (let i = 0; i < lines.length - 1; i += 1) {\n const header = lines[i] as ScannedLine;\n const delimiter = lines[i + 1] as ScannedLine;\n if (header.code || header.blank || delimiter.code) continue;\n if (!header.content.includes('|')) continue;\n if (!TABLE_DELIMITER.test(delimiter.content.trim())) continue;\n\n const headers = splitRow(header, text, masked);\n if (headers.length === 0) continue;\n\n const rows: TableRow[] = [];\n let end = delimiter.end;\n for (let j = i + 2; j < lines.length; j += 1) {\n const line = lines[j] as ScannedLine;\n if (line.blank || line.code || !line.content.includes('|')) break;\n const cells = splitRow(line, text, masked);\n if (cells.length === 0) break;\n rows.push({ cells, start: line.contentStart, end: line.end, line: line.line });\n end = line.end;\n }\n\n out.push({ start: header.contentStart, end, headers, rows });\n i += rows.length + 1;\n }\n\n return out;\n}\n\n/** Splits one row into cells, keeping each cell's offset in the source. */\nfunction splitRow(line: ScannedLine, text: string, masked: string): TableCell[] {\n const from = line.contentStart;\n const to = line.end;\n const bounds: number[] = [];\n for (let i = from; i < to; i += 1) {\n if (masked[i] !== '|') continue;\n // A pipe escaped with a backslash is content, not a column edge.\n if (i > from && text[i - 1] === '\\\\') continue;\n bounds.push(i);\n }\n if (bounds.length === 0) return [];\n\n const cells: TableCell[] = [];\n // A leading pipe opens the first cell; without one the row starts at `from`.\n let cursor = (bounds[0] as number) === from ? from + 1 : from;\n for (const bound of bounds) {\n if (bound < cursor) continue;\n cells.push(makeCell(text, cursor, bound));\n cursor = bound + 1;\n }\n // Trailing content after the last pipe is a final cell unless the row ended\n // with a border pipe.\n if (cursor < to && text.slice(cursor, to).trim().length > 0) cells.push(makeCell(text, cursor, to));\n\n return cells;\n}\n\nfunction makeCell(text: string, start: number, end: number): TableCell {\n const raw = text.slice(start, end);\n const leading = raw.length - raw.trimStart().length;\n const trimmed = raw.trim();\n return { text: trimmed, start: start + leading, end: start + leading + trimmed.length };\n}\n\n/* -------------------------------------------------------------------------- */\n/* HTML comments */\n/* -------------------------------------------------------------------------- */\n\nfunction scanComments(text: string, index: LineIndex, bodyStart: number, code: readonly Range[]): HtmlComment[] {\n const out: HtmlComment[] = [];\n const merged = mergeRanges(code);\n let from = bodyStart;\n for (;;) {\n const open = text.indexOf('<!--', from);\n if (open === -1) break;\n if (containsOffset(merged, open)) {\n from = open + 4;\n continue;\n }\n const close = text.indexOf('-->', open + 4);\n if (close === -1) break;\n out.push({\n start: open,\n end: close + 3,\n inner: text.slice(open + 4, close),\n innerStart: open + 4,\n line: index.positionAt(open).line,\n });\n from = close + 3;\n }\n return out;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Inline code */\n/* -------------------------------------------------------------------------- */\n\nfunction scanInlineCode(\n text: string,\n bodyStart: number,\n code: readonly Range[],\n comments: readonly HtmlComment[],\n): Range[] {\n const blocked = mergeRanges([...code, ...comments.map((c) => ({ start: c.start, end: c.end }))]);\n const out: Range[] = [];\n let i = bodyStart;\n\n while (i < text.length) {\n if (text[i] !== '`') {\n i += 1;\n continue;\n }\n if (containsOffset(blocked, i)) {\n i += 1;\n continue;\n }\n let runStart = i;\n while (text[i] === '`') i += 1;\n const runLength = i - runStart;\n // An escaped backtick does not open a span.\n if (runStart > 0 && text[runStart - 1] === '\\\\') continue;\n\n let j = i;\n let closed = -1;\n while (j < text.length) {\n if (text[j] !== '`') {\n j += 1;\n continue;\n }\n const closeStart = j;\n while (text[j] === '`') j += 1;\n if (j - closeStart === runLength && !containsOffset(blocked, closeStart)) {\n closed = j;\n break;\n }\n }\n if (closed === -1) continue;\n out.push({ start: runStart, end: closed });\n i = closed;\n }\n\n return out;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Masking */\n/* -------------------------------------------------------------------------- */\n\nfunction mergeRanges(ranges: readonly Range[]): Range[] {\n if (ranges.length === 0) return [];\n const sorted = [...ranges].sort((a, b) => a.start - b.start || a.end - b.end);\n const out: Range[] = [{ ...(sorted[0] as Range) }];\n for (let i = 1; i < sorted.length; i += 1) {\n const next = sorted[i] as Range;\n const last = out[out.length - 1] as { start: number; end: number };\n if (next.start <= last.end) last.end = Math.max(last.end, next.end);\n else out.push({ ...next });\n }\n return out;\n}\n\nfunction containsOffset(sorted: readonly Range[], offset: number): boolean {\n let lo = 0;\n let hi = sorted.length - 1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n const range = sorted[mid] as Range;\n if (offset < range.start) hi = mid - 1;\n else if (offset >= range.end) lo = mid + 1;\n else return true;\n }\n return false;\n}\n\n/**\n * Blanks out the given ranges.\n *\n * Line terminators survive so every offset, line and column in the masked copy\n * still matches the original. Callers slice the original text for content and\n * search the masked copy for structure.\n */\nfunction applyMask(text: string, ranges: readonly Range[]): string {\n const merged = mergeRanges(ranges);\n if (merged.length === 0) return text;\n\n // Built from slices rather than a per-character array. Masking runs over every\n // byte of every document, and a `split('')`/`join('')` round trip allocates an\n // array entry per character - on a large corpus that was the single most\n // expensive thing the scanner did.\n let out = '';\n let cursor = 0;\n for (const range of merged) {\n const start = Math.max(range.start, cursor);\n const end = Math.min(range.end, text.length);\n if (end <= start) continue;\n out += text.slice(cursor, start);\n // The character class is deliberately not Unicode-aware: a surrogate pair\n // must become two spaces so that every later offset still lines up.\n out += text.slice(start, end).replace(NON_TERMINATOR, ' ');\n cursor = end;\n }\n return out + text.slice(cursor);\n}\n\nconst NON_TERMINATOR = /[^\\n\\r]/g;\n\n/* -------------------------------------------------------------------------- */\n/* Links */\n/* -------------------------------------------------------------------------- */\n\nconst DEFINITION = /^ {0,3}\\[([^\\]\\n]+)\\]:[ \\t]*(<[^>\\n]*>|\\S+)/;\nconst AUTOLINK = /<((?:https?|ftp|mailto):[^>\\s]+)>/g;\n\n/** How far a bracket construct may run before we call it unbalanced prose. */\nconst MAX_LINK_SPAN = 4096;\n\nfunction scanLinks(masked: string, text: string, index: LineIndex): Link[] {\n const out: Link[] = [];\n const definitions = new Map<string, { target: string; targetStart: number }>();\n const definitionRanges: Range[] = [];\n\n // Pass 1: reference definitions. These are the destination table the other\n // two written-with-a-label forms are read through, which is why the whole\n // document is swept for them before a single use is looked at: a definition\n // is conventionally written at the foot of the file, long after the links\n // that use it.\n for (let line = 1; line <= index.lineCount; line += 1) {\n const start = index.lineStart(line);\n const content = masked.slice(start, index.lineEnd(line));\n const match = DEFINITION.exec(content);\n if (!match) continue;\n const label = (match[1] as string).trim().toLowerCase();\n const rawTarget = match[2] as string;\n const targetStart = start + content.indexOf(rawTarget, (match[1] as string).length);\n const target = unwrapAngle(rawTarget);\n // First definition wins, as in CommonMark.\n if (!definitions.has(label)) definitions.set(label, { target, targetStart });\n definitionRanges.push({ start, end: start + (match[0] as string).length });\n out.push({\n text: (match[1] as string).trim(),\n target,\n start,\n end: start + (match[0] as string).length,\n targetStart,\n label: (match[1] as string).trim(),\n form: 'definition',\n line,\n });\n }\n\n // Pass 2: autolinks.\n AUTOLINK.lastIndex = 0;\n for (let m = AUTOLINK.exec(masked); m !== null; m = AUTOLINK.exec(masked)) {\n const start = m.index;\n out.push({\n text: '',\n target: m[1] as string,\n start,\n end: start + (m[0] as string).length,\n targetStart: start + 1,\n label: null,\n form: 'autolink',\n line: index.positionAt(start).line,\n });\n }\n\n // Pass 3: bracket constructs, left to right.\n const definedAt = mergeRanges(definitionRanges);\n let i = 0;\n while (i < masked.length) {\n const ch = masked[i];\n if (ch !== '[') {\n i += 1;\n continue;\n }\n // The label of a definition is not itself a shortcut link to anything.\n if (containsOffset(definedAt, i)) {\n i += 1;\n continue;\n }\n const isImage = i > 0 && masked[i - 1] === '!';\n\n if (masked[i + 1] === '[') {\n const close = masked.indexOf(']]', i + 2);\n if (close !== -1 && close - i <= MAX_LINK_SPAN && masked.slice(i + 2, close).indexOf('\\n') === -1) {\n const target = text.slice(i + 2, close).trim();\n if (target.length > 0) {\n out.push({\n text: target,\n target: wikiTarget(target),\n start: i,\n end: close + 2,\n targetStart: i + 2,\n label: null,\n form: 'wiki',\n line: index.positionAt(i).line,\n });\n i = close + 2;\n continue;\n }\n }\n }\n\n const labelEnd = matchBracket(masked, i);\n if (labelEnd === -1) {\n i += 1;\n continue;\n }\n const label = text.slice(i + 1, labelEnd);\n const after = masked[labelEnd + 1];\n\n if (after === '(') {\n const dest = readDestination(masked, labelEnd + 2);\n if (dest) {\n if (!isImage) {\n out.push({\n text: label.trim(),\n target: unwrapAngle(text.slice(dest.start, dest.end).trim()),\n start: isImage ? i - 1 : i,\n end: dest.close + 1,\n targetStart: dest.start,\n label: null,\n form: 'inline',\n line: index.positionAt(i).line,\n });\n }\n i = dest.close + 1;\n continue;\n }\n } else if (after === '[') {\n const refEnd = matchBracket(masked, labelEnd + 1);\n if (refEnd !== -1) {\n const ref = text.slice(labelEnd + 2, refEnd).trim();\n const written = ref.length > 0 ? ref : label.trim();\n const defined = definitions.get(written.toLowerCase());\n // A label with no definition is not a link. Every renderer prints\n // `[design][one]` verbatim when nothing says what `one` is, so reading\n // it as a citation invents a reference the author never made - and\n // then reports it as broken.\n if (!isImage && defined) {\n out.push({\n text: label.trim(),\n target: defined.target,\n start: i,\n end: refEnd + 1,\n targetStart: defined.targetStart,\n label: written,\n form: 'reference',\n line: index.positionAt(i).line,\n });\n }\n i = refEnd + 1;\n continue;\n }\n } else if (!isImage) {\n const written = label.trim();\n const defined = definitions.get(written.toLowerCase());\n if (defined) {\n out.push({\n text: written,\n target: defined.target,\n start: i,\n end: labelEnd + 1,\n targetStart: defined.targetStart,\n label: written,\n form: 'shortcut',\n line: index.positionAt(i).line,\n });\n i = labelEnd + 1;\n continue;\n }\n }\n\n i = labelEnd + 1;\n }\n\n out.sort((a, b) => a.start - b.start);\n return out;\n}\n\n/** Finds the `]` matching the `[` at `open`, honouring nesting and escapes. */\nfunction matchBracket(text: string, open: number): number {\n let depth = 0;\n const limit = Math.min(text.length, open + MAX_LINK_SPAN);\n for (let i = open; i < limit; i += 1) {\n const ch = text[i];\n if (ch === '\\\\') {\n i += 1;\n continue;\n }\n if (ch === '\\n' && text[i + 1] === '\\n') return -1;\n if (ch === '[') depth += 1;\n else if (ch === ']') {\n depth -= 1;\n if (depth === 0) return i;\n }\n }\n return -1;\n}\n\n/** Reads a link destination starting just after `(`. */\nfunction readDestination(text: string, from: number): { start: number; end: number; close: number } | null {\n let i = from;\n const limit = Math.min(text.length, from + MAX_LINK_SPAN);\n while (i < limit && (text[i] === ' ' || text[i] === '\\t' || text[i] === '\\n')) i += 1;\n\n const start = i;\n if (text[i] === '<') {\n const close = text.indexOf('>', i + 1);\n if (close === -1 || close > limit) return null;\n const paren = text.indexOf(')', close);\n if (paren === -1 || paren > limit) return null;\n return { start, end: close + 1, close: paren };\n }\n\n let depth = 0;\n while (i < limit) {\n const ch = text[i];\n if (ch === '\\\\') {\n i += 2;\n continue;\n }\n if (ch === '(') depth += 1;\n else if (ch === ')') {\n if (depth === 0) break;\n depth -= 1;\n } else if (ch === ' ' || ch === '\\t' || ch === '\\n') break;\n i += 1;\n }\n const end = i;\n // Skip an optional title, then require the closing paren.\n let j = i;\n while (j < limit && text[j] !== ')') {\n if (text[j] === '\\n' && text[j + 1] === '\\n') return null;\n j += 1;\n }\n if (j >= limit || text[j] !== ')') return null;\n if (end === start) return null;\n return { start, end, close: j };\n}\n\nfunction unwrapAngle(value: string): string {\n return value.startsWith('<') && value.endsWith('>') ? value.slice(1, -1) : value;\n}\n\n/** `[[0007-thing|Display]]` and `[[0007-thing]]` both target `0007-thing`. */\nfunction wikiTarget(raw: string): string {\n const pipe = raw.indexOf('|');\n return (pipe === -1 ? raw : raw.slice(0, pipe)).trim();\n}\n"]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rules a repository writes for itself.
|
|
3
|
+
*
|
|
4
|
+
* [ADR-0005](../docs/adr/0005-rules-are-queries.md) claimed the selector
|
|
5
|
+
* language was expressive enough that a team could express a convention
|
|
6
|
+
* spec-graph never anticipated. For three releases that claim was only true at a
|
|
7
|
+
* command prompt: `spec-graph query` could find the thing, and nothing could
|
|
8
|
+
* make finding it fail a build. Three ADRs recorded the same gap and the same
|
|
9
|
+
* reason - a query needs a severity and a sentence before it is a rule.
|
|
10
|
+
*
|
|
11
|
+
* This is the sentence. A project rule is a selector, a message, a hint and a
|
|
12
|
+
* severity, written in `.spec-graph.json` and run beside the built-ins:
|
|
13
|
+
*
|
|
14
|
+
* ```json
|
|
15
|
+
* "rules": {
|
|
16
|
+
* "no-draft-dependency": {
|
|
17
|
+
* "query": "document[phase=active] -depends-on-> document[phase=draft]",
|
|
18
|
+
* "message": "{0} depends on {1}, which is still a draft",
|
|
19
|
+
* "hint": "wait for {1} to be accepted, or drop the dependency"
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Everything here is a pure function of the parsed configuration. Reading the
|
|
25
|
+
* file stays in `config.ts`, for the same reason extraction never touches a
|
|
26
|
+
* disk.
|
|
27
|
+
*/
|
|
28
|
+
import { type Match, type QuerySpec } from './select.js';
|
|
29
|
+
import type { SpecGraph } from './graph.js';
|
|
30
|
+
import type { ProjectRuleId, Severity } from './types.js';
|
|
31
|
+
/** A project rule, compiled and known to be runnable. */
|
|
32
|
+
export interface ProjectRule {
|
|
33
|
+
/** Namespaced, so it can never collide with a built-in. */
|
|
34
|
+
readonly id: ProjectRuleId;
|
|
35
|
+
/** The name as the repository wrote it, for error messages. */
|
|
36
|
+
readonly name: string;
|
|
37
|
+
/**
|
|
38
|
+
* The selectors, in the order they were written.
|
|
39
|
+
*
|
|
40
|
+
* More than one because a convention is often a union - "no live document may
|
|
41
|
+
* depend on a draft *or* on a record" - and a union of queries is clearer than
|
|
42
|
+
* a disjunction inside the grammar. See ADR-0005.
|
|
43
|
+
*/
|
|
44
|
+
readonly queries: readonly QuerySpec[];
|
|
45
|
+
/**
|
|
46
|
+
* The selectors as written, kept beside the compiled form.
|
|
47
|
+
*
|
|
48
|
+
* A report has to describe the rule, and the only honest description of a
|
|
49
|
+
* project rule is the query behind it. Echoing the text back is exact and
|
|
50
|
+
* free; rendering a `QuerySpec` would be a second grammar to keep correct.
|
|
51
|
+
*/
|
|
52
|
+
readonly sources: readonly string[];
|
|
53
|
+
readonly message: string;
|
|
54
|
+
readonly hint: string;
|
|
55
|
+
/**
|
|
56
|
+
* What the repository declared, before `--rule` and `--strict` have their say.
|
|
57
|
+
*
|
|
58
|
+
* Defaults to `warn` rather than to `error`. A rule a team has just written
|
|
59
|
+
* has not yet earned the right to stop their build, and the first run of a new
|
|
60
|
+
* convention is exactly when it is most likely to be wrong.
|
|
61
|
+
*/
|
|
62
|
+
readonly severity: Severity;
|
|
63
|
+
}
|
|
64
|
+
export interface CompiledProjectRules {
|
|
65
|
+
readonly rules: readonly ProjectRule[];
|
|
66
|
+
readonly problems: readonly string[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Turns the `rules` section of a configuration into runnable rules.
|
|
70
|
+
*
|
|
71
|
+
* Every failure is collected rather than thrown. A repository whose eighth
|
|
72
|
+
* custom rule has a typo in it should still get the findings from the other
|
|
73
|
+
* seven, and should be told exactly which one stopped working - a configuration
|
|
74
|
+
* that silently does less than it says is the failure mode this whole file
|
|
75
|
+
* exists to avoid.
|
|
76
|
+
*/
|
|
77
|
+
export declare function compileProjectRules(raw: unknown, source: string): CompiledProjectRules;
|
|
78
|
+
/**
|
|
79
|
+
* Fills a validated template in from one path through the graph.
|
|
80
|
+
*
|
|
81
|
+
* Sharing one global regex between this and {@link placeholderProblems} is safe
|
|
82
|
+
* and not an oversight: `matchAll` works on a clone, and `replace` resets
|
|
83
|
+
* `lastIndex` on entry and on exit. The hazard `CLAUDE.md` warns about is a
|
|
84
|
+
* `/g` regex whose cursor survives a call, and neither of these keeps one.
|
|
85
|
+
*
|
|
86
|
+
* The index cannot be out of range when `execute` produced the match - a path is
|
|
87
|
+
* always one node longer than the query has steps, which is what validation
|
|
88
|
+
* checks against. The guard is for the exported case: this takes any `Match`,
|
|
89
|
+
* and a caller assembling one by hand gets the placeholder back rather than a
|
|
90
|
+
* crash.
|
|
91
|
+
*/
|
|
92
|
+
export declare function renderTemplate(template: string, match: Match, graph: SpecGraph): string;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rules a repository writes for itself.
|
|
3
|
+
*
|
|
4
|
+
* [ADR-0005](../docs/adr/0005-rules-are-queries.md) claimed the selector
|
|
5
|
+
* language was expressive enough that a team could express a convention
|
|
6
|
+
* spec-graph never anticipated. For three releases that claim was only true at a
|
|
7
|
+
* command prompt: `spec-graph query` could find the thing, and nothing could
|
|
8
|
+
* make finding it fail a build. Three ADRs recorded the same gap and the same
|
|
9
|
+
* reason - a query needs a severity and a sentence before it is a rule.
|
|
10
|
+
*
|
|
11
|
+
* This is the sentence. A project rule is a selector, a message, a hint and a
|
|
12
|
+
* severity, written in `.spec-graph.json` and run beside the built-ins:
|
|
13
|
+
*
|
|
14
|
+
* ```json
|
|
15
|
+
* "rules": {
|
|
16
|
+
* "no-draft-dependency": {
|
|
17
|
+
* "query": "document[phase=active] -depends-on-> document[phase=draft]",
|
|
18
|
+
* "message": "{0} depends on {1}, which is still a draft",
|
|
19
|
+
* "hint": "wait for {1} to be accepted, or drop the dependency"
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Everything here is a pure function of the parsed configuration. Reading the
|
|
25
|
+
* file stays in `config.ts`, for the same reason extraction never touches a
|
|
26
|
+
* disk.
|
|
27
|
+
*/
|
|
28
|
+
import { attributesOf, parseQuery, QueryError, SELECTOR_KEYS } from './select.js';
|
|
29
|
+
import { PROJECT_RULE_PREFIX } from './types.js';
|
|
30
|
+
/* -------------------------------------------------------------------------- */
|
|
31
|
+
/* Compilation */
|
|
32
|
+
/* -------------------------------------------------------------------------- */
|
|
33
|
+
/**
|
|
34
|
+
* What a name may contain.
|
|
35
|
+
*
|
|
36
|
+
* No colon, because the namespace separator has to stay unambiguous. No
|
|
37
|
+
* whitespace, because the id is printed in a column of a report. And no tab in
|
|
38
|
+
* particular: a baseline key is three fields joined by one, and a rule id that
|
|
39
|
+
* could contain a tab would be a rule whose accepted debt could be forged by
|
|
40
|
+
* typing carefully. See ADR-0012.
|
|
41
|
+
*/
|
|
42
|
+
const NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
43
|
+
const MAX_NAME_LENGTH = 64;
|
|
44
|
+
/**
|
|
45
|
+
* `{0}`, `{1.phase}`, `{2.fm.owner}`.
|
|
46
|
+
*
|
|
47
|
+
* Positional because a path is positional: step zero is where the finding
|
|
48
|
+
* starts and the last step is where it ends. Naming them would mean inventing a
|
|
49
|
+
* second vocabulary for something the selector already numbers.
|
|
50
|
+
*/
|
|
51
|
+
const PLACEHOLDER = /\{(\d+)(?:\.([A-Za-z][A-Za-z0-9_.:-]*))?\}/g;
|
|
52
|
+
/**
|
|
53
|
+
* Turns the `rules` section of a configuration into runnable rules.
|
|
54
|
+
*
|
|
55
|
+
* Every failure is collected rather than thrown. A repository whose eighth
|
|
56
|
+
* custom rule has a typo in it should still get the findings from the other
|
|
57
|
+
* seven, and should be told exactly which one stopped working - a configuration
|
|
58
|
+
* that silently does less than it says is the failure mode this whole file
|
|
59
|
+
* exists to avoid.
|
|
60
|
+
*/
|
|
61
|
+
export function compileProjectRules(raw, source) {
|
|
62
|
+
const problems = [];
|
|
63
|
+
if (!isRecord(raw)) {
|
|
64
|
+
return { rules: [], problems: [`${source}: "rules" must be an object of name to rule`] };
|
|
65
|
+
}
|
|
66
|
+
const rules = [];
|
|
67
|
+
for (const [name, body] of Object.entries(raw)) {
|
|
68
|
+
const rule = compileOne(name, body, source, problems);
|
|
69
|
+
if (rule !== null)
|
|
70
|
+
rules.push(rule);
|
|
71
|
+
}
|
|
72
|
+
// Sorted by id, so two runs of one configuration produce findings in the same
|
|
73
|
+
// order however the JSON was keyed. Two ids are never equal - they are object
|
|
74
|
+
// keys - so there is no third case to write, and `<` against `<=` here is a
|
|
75
|
+
// genuinely equivalent mutant with no test behind it for that reason.
|
|
76
|
+
return { rules: rules.sort((a, b) => (a.id < b.id ? -1 : 1)), problems };
|
|
77
|
+
}
|
|
78
|
+
function compileOne(name, body, source, problems) {
|
|
79
|
+
const where = `${source}: rules.${name}`;
|
|
80
|
+
if (!NAME.test(name) || name.length > MAX_NAME_LENGTH) {
|
|
81
|
+
problems.push(`${where}: a rule name must be letters, digits, "." "_" or "-", at most ${MAX_NAME_LENGTH} characters`);
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
if (!isRecord(body)) {
|
|
85
|
+
problems.push(`${where} must be an object with "query" and "message"`);
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
for (const key of Object.keys(body)) {
|
|
89
|
+
if (!RULE_KEYS.has(key))
|
|
90
|
+
problems.push(`${where}: unknown key "${key}"`);
|
|
91
|
+
}
|
|
92
|
+
const written = body['query'];
|
|
93
|
+
const listed = typeof written === 'string' ? [written] : Array.isArray(written) ? written : [];
|
|
94
|
+
if (listed.length === 0 || listed.some((entry) => typeof entry !== 'string')) {
|
|
95
|
+
problems.push(`${where}: "query" must be a selector, or an array of them`);
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const sources = listed;
|
|
99
|
+
const queries = [];
|
|
100
|
+
for (const selector of sources) {
|
|
101
|
+
try {
|
|
102
|
+
queries.push(parseQuery(selector));
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
const detail = error instanceof QueryError ? `${error.message} (at character ${error.offset + 1})` : String(error);
|
|
106
|
+
problems.push(`${where}: ${detail}`);
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const message = body['message'];
|
|
111
|
+
if (typeof message !== 'string' || message.trim().length === 0) {
|
|
112
|
+
problems.push(`${where}: "message" must be the one-line headline of the finding`);
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
// A finding has to name a next action, so the fallback names the only thing
|
|
116
|
+
// this file can be certain of: where the rule was written down.
|
|
117
|
+
const hint = body['hint'] ?? `check this against rules.${name} in ${source}`;
|
|
118
|
+
if (typeof hint !== 'string' || hint.trim().length === 0) {
|
|
119
|
+
problems.push(`${where}: "hint" must be a concrete next action`);
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
const declared = body['severity'] ?? 'warn';
|
|
123
|
+
if (declared !== 'error' && declared !== 'warn' && declared !== 'info' && declared !== 'off') {
|
|
124
|
+
problems.push(`${where}: "severity" must be error, warn, info or off`);
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
// The shortest path a rule can produce, because a placeholder has to be
|
|
128
|
+
// resolvable by *every* query behind the rule and not merely by the longest.
|
|
129
|
+
const arity = Math.min(...queries.map((query) => query.steps.length + 1));
|
|
130
|
+
let usable = true;
|
|
131
|
+
for (const text of [message, hint]) {
|
|
132
|
+
for (const problem of placeholderProblems(text, arity, where)) {
|
|
133
|
+
problems.push(problem);
|
|
134
|
+
usable = false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (!usable)
|
|
138
|
+
return null;
|
|
139
|
+
return {
|
|
140
|
+
id: `${PROJECT_RULE_PREFIX}${name}`,
|
|
141
|
+
name,
|
|
142
|
+
queries,
|
|
143
|
+
sources,
|
|
144
|
+
message: message.trim(),
|
|
145
|
+
hint: hint.trim(),
|
|
146
|
+
severity: declared,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const RULE_KEYS = new Set(['query', 'message', 'hint', 'severity']);
|
|
150
|
+
/**
|
|
151
|
+
* Why a template would not render.
|
|
152
|
+
*
|
|
153
|
+
* Checked here rather than tolerated at render time, because both failures are
|
|
154
|
+
* silent where it matters: an out-of-range index leaves `{3}` sitting in a
|
|
155
|
+
* sentence a human has to act on, and a misspelled attribute renders as nothing
|
|
156
|
+
* at all, which reads as a finding about an unnamed document.
|
|
157
|
+
*/
|
|
158
|
+
function placeholderProblems(template, arity, where) {
|
|
159
|
+
const out = [];
|
|
160
|
+
for (const match of template.matchAll(PLACEHOLDER)) {
|
|
161
|
+
const index = Number(match[1]);
|
|
162
|
+
if (index >= arity) {
|
|
163
|
+
out.push(`${where}: "${match[0]}" names step ${index}, and the query has ${arity} ${arity === 1 ? 'step' : 'steps'} (0 to ${arity - 1})`);
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const key = match[2];
|
|
167
|
+
if (key === undefined)
|
|
168
|
+
continue;
|
|
169
|
+
const folded = key.toLowerCase();
|
|
170
|
+
if (folded.startsWith('fm.') || SELECTOR_KEYS.includes(folded))
|
|
171
|
+
continue;
|
|
172
|
+
out.push(`${where}: "${match[0]}" asks for an attribute nothing has - known: ${SELECTOR_KEYS.join(', ')}, fm.*`);
|
|
173
|
+
}
|
|
174
|
+
return out;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Fills a validated template in from one path through the graph.
|
|
178
|
+
*
|
|
179
|
+
* Sharing one global regex between this and {@link placeholderProblems} is safe
|
|
180
|
+
* and not an oversight: `matchAll` works on a clone, and `replace` resets
|
|
181
|
+
* `lastIndex` on entry and on exit. The hazard `CLAUDE.md` warns about is a
|
|
182
|
+
* `/g` regex whose cursor survives a call, and neither of these keeps one.
|
|
183
|
+
*
|
|
184
|
+
* The index cannot be out of range when `execute` produced the match - a path is
|
|
185
|
+
* always one node longer than the query has steps, which is what validation
|
|
186
|
+
* checks against. The guard is for the exported case: this takes any `Match`,
|
|
187
|
+
* and a caller assembling one by hand gets the placeholder back rather than a
|
|
188
|
+
* crash.
|
|
189
|
+
*/
|
|
190
|
+
export function renderTemplate(template, match, graph) {
|
|
191
|
+
return template.replace(PLACEHOLDER, (whole, index, key) => {
|
|
192
|
+
const node = match.nodes[Number(index)];
|
|
193
|
+
if (node === undefined)
|
|
194
|
+
return whole;
|
|
195
|
+
return attributesOf(node, (key ?? 'id').toLowerCase(), graph)[0] ?? whole;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
function isRecord(value) {
|
|
199
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=project-rules.js.map
|