@descent-vtt/spec-graph 0.9.10 → 0.10.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 +68 -2
- package/README.md +522 -319
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +112 -67
- package/dist/cli.js.map +1 -1
- package/dist/extract.d.ts +14 -1
- package/dist/extract.js +114 -10
- package/dist/extract.js.map +1 -1
- package/dist/glob.d.ts +11 -0
- package/dist/glob.js +17 -1
- package/dist/glob.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lifecycle.d.ts +11 -1
- package/dist/lifecycle.js +187 -28
- package/dist/lifecycle.js.map +1 -1
- package/dist/report.d.ts +22 -0
- package/dist/report.js +50 -3
- package/dist/report.js.map +1 -1
- package/dist/sections.d.ts +7 -1
- package/dist/sections.js +10 -2
- package/dist/sections.js.map +1 -1
- package/dist/state.js +19 -3
- package/dist/state.js.map +1 -1
- package/dist/vendor/spec-core/markdown/frontmatter.d.ts +11 -1
- package/dist/vendor/spec-core/markdown/frontmatter.js +20 -3
- package/dist/vendor/spec-core/markdown/frontmatter.js.map +1 -1
- package/dist/vendor/spec-core/pattern/glob.d.ts +85 -0
- package/dist/vendor/spec-core/pattern/glob.js +207 -17
- package/dist/vendor/spec-core/pattern/glob.js.map +1 -1
- package/dist/vendor/spec-core/pattern/index.d.ts +2 -2
- package/dist/vendor/spec-core/pattern/index.js +1 -1
- package/dist/vendor/spec-core/pattern/index.js.map +1 -1
- package/dist/vendor/spec-core/text/index.d.ts +1 -0
- package/dist/vendor/spec-core/text/index.js +1 -0
- package/dist/vendor/spec-core/text/index.js.map +1 -1
- package/dist/vendor/spec-core/text/width.d.ts +30 -0
- package/dist/vendor/spec-core/text/width.js +113 -0
- package/dist/vendor/spec-core/text/width.js.map +1 -0
- package/dist/yaml.js +6 -2
- package/dist/yaml.js.map +1 -1
- package/package.json +1 -1
package/dist/lifecycle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,GAAqD;IACnE;QACE,SAAS;QACT;YACE,YAAY;YACZ,sEAAsE;YACtE,yCAAyC;YACzC,YAAY;YACZ,eAAe;YACf,UAAU;YACV,YAAY;YACZ,UAAU;YACV,WAAW;YACX,SAAS;YACT,UAAU;YACV,UAAU;YACV,WAAW;YACX,WAAW;YACX,WAAW;YACX,UAAU;YACV,SAAS;YACT,SAAS;YACT,UAAU;YACV,OAAO;YACP,YAAY;YACZ,SAAS;YACT,UAAU;YACV,MAAM;YACN,MAAM;YACN,QAAQ;YACR,WAAW;YACX,UAAU;YACV,aAAa;YACb,SAAS;SACV;KACF;IACD;QACE,4EAA4E;QAC5E,4EAA4E;QAC5E,yEAAyE;QACzE,wEAAwE;QACxE,wEAAwE;QACxE,qDAAqD;QACrD,QAAQ;QACR,CAAC,UAAU,EAAE,SAAS,CAAC;KACxB;IACD;QACE,QAAQ;QACR,CAAC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC;KACpH;IACD,yEAAyE;IACzE,sEAAsE;IACtE,CAAC,OAAO,EAAE,CAAC,wBAAwB,CAAC,CAAC;IACrC;QACE,QAAQ;QACR;YACE,UAAU;YACV,QAAQ;YACR,UAAU;YACV,SAAS;YACT,QAAQ;YACR,eAAe;YACf,aAAa;YACb,cAAc;YACd,SAAS;YACT,WAAW;YACX,WAAW;YACX,UAAU;YACV,QAAQ;YACR,QAAQ;YACR,UAAU;YACV,SAAS;YACT,MAAM;YACN,MAAM;YACN,UAAU;YACV,WAAW;YACX,YAAY;YACZ,WAAW;SACZ;KACF;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,EAAE,CAAC;QACV,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG;YAAE,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Status vocabulary normalisation.\n *\n * Every specification ecosystem invented its own status words, and no two agree.\n * MADR says `accepted`; Kubernetes KEPs say `implementable`; Rust RFCs say\n * `merged`; a hundred internal wikis say `Live`, `Signed off`, or `DONE ✅`.\n *\n * spec-graph refuses to care. What it needs from a status is one bit - *can this\n * document still absorb an obligation?* - and that bit is recoverable from all\n * of those vocabularies at once. The tables below are the only place in the\n * codebase that knows any ecosystem-specific word, which is what keeps the\n * engine domain-agnostic: supporting a new convention is a table entry, never a\n * rule change.\n */\n\nimport type { Phase, Receptivity } from './types.js';\n\n/**\n * Recognised status words, most terminal first.\n *\n * Order matters. A status of \"accepted, superseded by ADR-0009\" is retired, not\n * active: retirement is terminal, so a retirement word anywhere in the string\n * wins over anything else in it.\n *\n * A hyphenated term is found anywhere in the status, so a row needs no term\n * another in it already finds: `replaced` reads \"replaced by\", `review` reads\n * \"in review\" and \"under review\", and `in-progress` reads \"work in progress\".\n */\nconst VOCABULARY: readonly (readonly [Phase, readonly string[]])[] = [\n [\n 'retired',\n [\n 'superseded',\n // Misspelled in the wild often enough that omitting it would silently\n // mis-classify real documents as active.\n 'superceded',\n 'supersedes-by',\n 'replaced',\n 'deprecated',\n 'obsolete',\n 'obsoleted',\n 'retired',\n 'rejected',\n 'declined',\n 'withdrawn',\n 'abandoned',\n 'cancelled',\n 'canceled',\n 'dropped',\n 'revoked',\n 'reverted',\n 'moved',\n 'historical',\n 'defunct',\n 'inactive',\n 'dead',\n 'void',\n 'closed',\n 'postponed',\n 'deferred',\n 'not-planned',\n 'wontfix',\n ],\n ],\n [\n // A finished round of work kept as it was left: spec-brief archives a brief\n // by writing this word and moving the file. Every spec-* tool reads it as a\n // record rather than as a retired decision - depending on one is normal,\n // its unticked boxes were never going to be ticked, and its links still\n // have to go somewhere (ADR-0011). After retirement, so a brief written\n // `archived, superseded by B-0007` is still retired.\n 'record',\n ['archived', 'archive'],\n ],\n [\n 'frozen',\n ['final', 'finalised', 'finalized', 'frozen', 'locked', 'ratified', 'immutable', 'sealed', 'standard', 'published'],\n ],\n // Ahead of `active`, whose `accepted` it contains: read after it, as the\n // rest of the draft row is, `provisionally accepted` would be active.\n ['draft', ['provisionally-accepted']],\n [\n 'active',\n [\n 'accepted',\n 'active',\n 'approved',\n 'adopted',\n 'agreed',\n 'implementable',\n 'implemented',\n 'implementing',\n 'current',\n 'effective',\n 'in-effect',\n 'enforced',\n 'stable',\n 'merged',\n 'released',\n 'shipped',\n 'live',\n 'done',\n 'complete',\n 'completed',\n 'signed-off',\n 'committed',\n ],\n ],\n [\n 'draft',\n [\n 'draft',\n 'drafting',\n 'proposed',\n 'proposal',\n 'provisional',\n 'prospective',\n 'wip',\n 'in-progress',\n 'review',\n 'reviewing',\n 'discussion',\n 'discussing',\n 'pending',\n 'idea',\n 'exploratory',\n 'candidate',\n 'open',\n 'new',\n 'unreviewed',\n 'rfc',\n 'experimental',\n 'alpha',\n 'beta',\n 'incubating',\n ],\n ],\n];\n\n/** Path segments that retire every document beneath them. */\nconst RETIRING_DIRECTORIES: ReadonlySet<string> = new Set([\n 'archive',\n 'archived',\n 'attic',\n 'deprecated',\n 'graveyard',\n 'historical',\n 'obsolete',\n 'rejected',\n 'retired',\n 'superseded',\n 'superceded',\n 'withdrawn',\n]);\n\n/** Front-matter keys that may carry a status, in order of preference. */\nexport const STATUS_KEYS: readonly string[] = ['status', 'state', 'stage', 'lifecycle', 'phase', 'adr-status'];\n\n/** Heading names whose body declares the document status. */\nconst STATUS_HEADINGS: ReadonlySet<string> = new Set(['status', 'state', 'stage', 'lifecycle', 'current status']);\n\n/**\n * Reduces a status string to lookup form.\n *\n * Strips Markdown emphasis, badge syntax, emoji and dates, so `**Accepted**`,\n * `` `accepted` ``, `Accepted ✅` and `Accepted (2026-03-01)` all land on the\n * same token.\n */\nexport function normaliseStatus(raw: string): string {\n // An underscore between two letters joins two words - `not_planned`,\n // `in_progress` - where one at either end of a word is emphasis. Stripped\n // with the emphasis, it ran the two words into one that is neither.\n return raw\n .replace(/<[^>]*>/g, ' ')\n .replace(/(?<=[\\p{L}\\p{N}])_(?=[\\p{L}\\p{N}])/gu, ' ')\n .replace(/[`*_~\"'#]/g, '')\n .replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1')\n .replace(/\\p{Extended_Pictographic}/gu, ' ')\n .replace(/\\d{4}-\\d{2}-\\d{2}/g, ' ')\n .toLowerCase()\n .replace(/[^\\p{L}\\p{N}]+/gu, ' ')\n .trim();\n}\n\n/**\n * Maps a raw status string onto a lifecycle phase.\n *\n * Returns `unknown` rather than guessing when nothing matches: a document with\n * an unrecognised status is not evidence of anything, and inventing a phase for\n * it would produce exactly the confident-but-wrong findings this tool exists to\n * eliminate.\n */\nexport function phaseOf(raw: string | null | undefined): Phase {\n if (raw === null || raw === undefined) return 'unknown';\n const text = normaliseStatus(raw);\n const words = new Set(text.split(' '));\n const hyphenated = text.replace(/ /g, '-');\n\n for (const [phase, terms] of VOCABULARY) {\n for (const term of terms) {\n if (term.includes('-')) {\n if (hyphenated.includes(term)) return phase;\n } else if (words.has(term)) {\n return phase;\n }\n }\n }\n return 'unknown';\n}\n\n/** Whether a document in this phase can take on a new open obligation. */\nexport function receptivityOf(phase: Phase): Receptivity {\n switch (phase) {\n case 'draft':\n case 'active':\n return 'receptive';\n case 'frozen':\n case 'retired':\n // A record was never asking for an obligation, so it cannot take one on.\n // Sealed for the same reason a retired document is, by a different route.\n case 'record':\n return 'sealed';\n case 'unknown':\n return 'unknown';\n }\n}\n\n/** True when the phase means the document no longer binds anybody. */\nexport function isRetired(phase: Phase): boolean {\n return phase === 'retired';\n}\n\n/** True when the heading names a section that declares the document status. */\nexport function isStatusHeading(text: string): boolean {\n return STATUS_HEADINGS.has(text.toLowerCase().replace(/[:*_`]/g, '').trim());\n}\n\n/**\n * Infers retirement from where a file lives.\n *\n * Moving an ADR into `docs/adr/archive/` is the most common way a team retires a\n * decision without touching its front matter, and a graph that misses it will\n * happily let obligations be delegated into the archive.\n */\nexport function phaseFromPath(posixPath: string): Phase {\n const segments = posixPath.toLowerCase().split('/');\n // The file name itself is not a directory; a document called `archive`, with\n // or without an extension, is not retired.\n for (let i = 0; i < segments.length - 1; i += 1) {\n if (RETIRING_DIRECTORIES.has(segments[i] as string)) return 'retired';\n }\n return 'unknown';\n}\n\n/**\n * Pulls a supersession target out of a status string.\n *\n * `Superseded by ADR-0009` is the single most common way a supersession is ever\n * recorded, and it is written in the status field rather than as a link. Reading\n * it here means the relation reaches the graph even in repositories that never\n * adopted an explicit field for it.\n */\nexport function supersessionTargetsIn(raw: string): string[] {\n const out: string[] = [];\n // The tail runs to the end of the line, not of the string: a status that\n // wraps onto a second line still names its successor on the first.\n const pattern = /(?:super[sc]eded|replaced|obsoleted)\\s*(?:by|with|through)?\\s*[:\\-–—]?\\s*(.+)/i;\n const match = pattern.exec(raw.replace(/[`*_]/g, ''));\n if (!match) return out;\n const tail = match[1] as string;\n for (const token of tail.split(/[,;]|\\band\\b/)) {\n const cleaned = token\n .replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1')\n .replace(/[()<>\"']/g, ' ')\n .trim();\n if (cleaned.length > 0 && cleaned.length < 200) out.push(cleaned);\n }\n return out;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,GAAqD;IACnE;QACE,SAAS;QACT;YACE,qEAAqE;YACrE,sEAAsE;YACtE,KAAK;YACL,KAAK;YACL,IAAI;YACJ,IAAI;YACJ,IAAI;YACJ,IAAI;YACJ,KAAK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IAAI,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,EAAE,CAAC;YACtD,MAAM,OAAO,GAAG,KAAK;iBAClB,OAAO,CAAC,wBAAwB,EAAE,IAAI,CAAC;iBACvC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;iBAC3B,IAAI,EAAE,CAAC;YACV,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG;gBAAE,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Status vocabulary normalisation.\n *\n * Every specification ecosystem invented its own status words, and no two agree.\n * MADR says `accepted`; Kubernetes KEPs say `implementable`; Rust RFCs say\n * `merged`; a hundred internal wikis say `Live`, `Signed off`, or `DONE ✅`.\n *\n * spec-graph refuses to care. What it needs from a status is one bit - *can this\n * document still absorb an obligation?* - and that bit is recoverable from all\n * of those vocabularies at once. The tables below are the only place in the\n * codebase that knows any ecosystem-specific word, which is what keeps the\n * engine domain-agnostic: supporting a new convention is a table entry, never a\n * rule change.\n */\n\nimport type { Phase, Receptivity } from './types.js';\n\n/**\n * Recognised status words, most terminal first.\n *\n * Order matters. A status of \"accepted, superseded by ADR-0009\" is retired, not\n * active: retirement is terminal, so a retirement word anywhere in the string\n * wins over anything else in it.\n *\n * A hyphenated term is found anywhere in the status, so a row needs no term\n * another in it already finds: `replaced` reads \"replaced by\", `review` reads\n * \"in review\" and \"under review\", and `in-progress` reads \"work in progress\".\n *\n * A Chinese term is the English word it translates, in Traditional and in\n * Simplified characters, and sits in that word's row. Chinese writes no space\n * between words, so a term in Han characters is found anywhere in the status,\n * as a hyphenated one is, and the same economy applies: `棄用` reads `已棄用`,\n * and `待審` reads `待審核`. The superseded forms are rules of their own, in\n * {@link supersededInChinese}.\n */\nconst VOCABULARY: readonly (readonly [Phase, readonly string[]])[] = [\n [\n 'retired',\n [\n // Read as itself, though it starts with a negation. The active row's\n // `採納` inside it is not read, because that negation stands before it.\n '不採納',\n '不采纳',\n '棄用',\n '弃用',\n '廢棄',\n '废弃',\n '已停用',\n '已過時',\n '已过时',\n '否決',\n '否决',\n '已拒絕',\n '已拒绝',\n '撤回',\n '作廢',\n '作废',\n '延後',\n '延后',\n '暫緩',\n '暂缓',\n '擱置',\n '搁置',\n 'superseded',\n // Misspelled in the wild often enough that omitting it would silently\n // mis-classify real documents as active.\n 'superceded',\n 'supersedes-by',\n 'replaced',\n 'deprecated',\n 'obsolete',\n 'obsoleted',\n 'retired',\n 'rejected',\n 'declined',\n 'withdrawn',\n 'abandoned',\n 'cancelled',\n 'canceled',\n 'dropped',\n 'revoked',\n 'reverted',\n 'moved',\n 'historical',\n 'defunct',\n 'inactive',\n 'dead',\n 'void',\n 'closed',\n 'postponed',\n 'deferred',\n 'not-planned',\n 'wontfix',\n ],\n ],\n [\n // A finished round of work kept as it was left: spec-brief archives a brief\n // by writing this word and moving the file. Every spec-* tool reads it as a\n // record rather than as a retired decision - depending on one is normal,\n // its unticked boxes were never going to be ticked, and its links still\n // have to go somewhere (ADR-0011). After retirement, so a brief written\n // `archived, superseded by B-0007` is still retired.\n 'record',\n ['archived', 'archive', '封存', '歸檔', '归档'],\n ],\n [\n 'frozen',\n [\n 'final',\n 'finalised',\n 'finalized',\n 'frozen',\n 'locked',\n 'ratified',\n 'immutable',\n 'sealed',\n 'standard',\n 'published',\n '定案',\n '已凍結',\n '已冻结',\n ],\n ],\n // Ahead of `active`, whose `accepted` it contains: read after it, as the\n // rest of the draft row is, `provisionally accepted` would be active. `暫定`\n // is the same word, and `暫定接受` holds the active row's `接受`.\n ['draft', ['provisionally-accepted', '暫定', '暂定']],\n [\n 'active',\n [\n '接受',\n '採納',\n '采纳',\n '核准',\n '批准',\n '生效',\n '已實施',\n '已实施',\n '已完成',\n 'accepted',\n 'active',\n 'approved',\n 'adopted',\n 'agreed',\n 'implementable',\n 'implemented',\n 'implementing',\n 'current',\n 'effective',\n 'in-effect',\n 'enforced',\n 'stable',\n 'merged',\n 'released',\n 'shipped',\n 'live',\n 'done',\n 'complete',\n 'completed',\n 'signed-off',\n 'committed',\n ],\n ],\n [\n 'draft',\n [\n '草稿',\n '草案',\n '提議',\n '提议',\n '提案',\n '審查中',\n '审查中',\n '審核中',\n '审核中',\n '討論中',\n '讨论中',\n '待審',\n '待审',\n 'draft',\n 'drafting',\n 'proposed',\n 'proposal',\n 'provisional',\n 'prospective',\n 'wip',\n 'in-progress',\n 'review',\n 'reviewing',\n 'discussion',\n 'discussing',\n 'pending',\n 'idea',\n 'exploratory',\n 'candidate',\n 'open',\n 'new',\n 'unreviewed',\n 'rfc',\n 'experimental',\n 'alpha',\n 'beta',\n 'incubating',\n ],\n ],\n];\n\n/** Path segments that retire every document beneath them. */\nconst RETIRING_DIRECTORIES: ReadonlySet<string> = new Set([\n 'archive',\n 'archived',\n 'attic',\n 'deprecated',\n 'graveyard',\n 'historical',\n 'obsolete',\n 'rejected',\n 'retired',\n 'superseded',\n 'superceded',\n 'withdrawn',\n]);\n\n/**\n * Front-matter keys that may carry a status, in order of preference. The\n * Chinese key is the English one it translates, so it ranks beside it.\n */\nexport const STATUS_KEYS: readonly string[] = ['status', '狀態', '状态', 'state', 'stage', 'lifecycle', 'phase', 'adr-status'];\n\n/** Heading names whose body declares the document status. */\nconst STATUS_HEADINGS: ReadonlySet<string> = new Set([\n 'status',\n 'state',\n 'stage',\n 'lifecycle',\n 'current status',\n '狀態',\n '状态',\n]);\n\n/** A term written in Han characters, which is found anywhere in a status rather than as a word. */\nconst HAN = /\\p{Script=Han}/u;\n\n/**\n * What cancels a Han term written directly after it: `未接受`, `尚未核准` and\n * `不再生效` are not accepted, approved or in effect, and `未移交給 ADR-0002`\n * hands nothing on. One list for status words and relation phrases alike, so\n * the two cannot come to disagree about what a negation is. `尚未` ends in\n * `未`, so it needs no entry of its own.\n */\nconst HAN_NEGATIONS: readonly string[] = ['不', '未', '非', '沒', '没', '無', '无', '勿', '不再'];\n\n/**\n * `被 ADR-0003 取代`, and `被取代` with nothing between: superseded, in the\n * passive, with the successor between `被` and the verb. Thirty characters\n * leave room for a name or two and not for a clause, and the gap never runs\n * past the end of a sentence: `被團隊接受。取代 ADR-0002 的方案另議` is no\n * supersession of this document.\n */\nconst PASSIVE_SUPERSESSION = /被([^。;!?]{0,30}?)所?(?:取而代之|取代|替代)/gu;\n\n/**\n * `已取代` said alone. Followed by a name - `已取代 ADR-0002`, `已取代舊方案`,\n * after spaces or a colon - it usually says what *this* document replaced, and\n * reading it either way would be a guess.\n */\nconst SUPERSEDED_ALONE = /已取代(?![\\s::]*[\\p{L}\\p{N}])/gu;\n\n/**\n * Strips what decorates a status and keeps its punctuation: HTML, emphasis,\n * link syntax, emoji and dates. Lower-cased, since every term is.\n */\nfunction undecorated(raw: string): string {\n // An underscore between two letters joins two words - `not_planned`,\n // `in_progress` - where one at either end of a word is emphasis. Stripped\n // with the emphasis, it ran the two words into one that is neither.\n return raw\n .replace(/<[^>]*>/g, ' ')\n .replace(/(?<=[\\p{L}\\p{N}])_(?=[\\p{L}\\p{N}])/gu, ' ')\n .replace(/[`*_~\"'#]/g, '')\n .replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1')\n .replace(/\\p{Extended_Pictographic}/gu, ' ')\n .replace(/\\d{4}-\\d{2}-\\d{2}/g, ' ')\n .toLowerCase();\n}\n\n/**\n * Reduces a status string to lookup form.\n *\n * Strips Markdown emphasis, badge syntax, emoji and dates, so `**Accepted**`,\n * `` `accepted` ``, `Accepted ✅` and `Accepted (2026-03-01)` all land on the\n * same token.\n */\nexport function normaliseStatus(raw: string): string {\n return undecorated(raw)\n .replace(/[^\\p{L}\\p{N}]+/gu, ' ')\n .trim();\n}\n\n/** Whether a Chinese negation stands directly before the offset. */\nexport function negatedAt(text: string, offset: number): boolean {\n const before = text.slice(0, offset);\n return HAN_NEGATIONS.some((negation) => before.endsWith(negation));\n}\n\n/** Whether a Han term occurs in the text with no negation directly before it. */\nfunction hanTermIn(text: string, term: string): boolean {\n for (let at = text.indexOf(term); at !== -1; at = text.indexOf(term, at + 1)) {\n if (!negatedAt(text, at)) return true;\n }\n return false;\n}\n\n/** The text between `被` and the verb of every passive supersession not negated. */\nfunction passiveSupersessions(text: string): string[] {\n const out: string[] = [];\n for (const match of text.matchAll(PASSIVE_SUPERSESSION)) {\n if (!negatedAt(text, match.index)) out.push(match[1] as string);\n }\n return out;\n}\n\n/** Whether a status says it was superseded, in Chinese. */\nfunction supersededInChinese(text: string): boolean {\n if (passiveSupersessions(text).length > 0) return true;\n for (const match of text.matchAll(SUPERSEDED_ALONE)) {\n if (!negatedAt(text, match.index)) return true;\n }\n return false;\n}\n\n/**\n * Maps a raw status string onto a lifecycle phase.\n *\n * Returns `unknown` rather than guessing when nothing matches: a document with\n * an unrecognised status is not evidence of anything, and inventing a phase for\n * it would produce exactly the confident-but-wrong findings this tool exists to\n * eliminate.\n */\nexport function phaseOf(raw: string | null | undefined): Phase {\n if (raw === null || raw === undefined) return 'unknown';\n const plain = undecorated(raw);\n // Retirement wins wherever it is written, so the superseded forms need no\n // place in the table's order.\n if (supersededInChinese(plain)) return 'retired';\n const text = plain.replace(/[^\\p{L}\\p{N}]+/gu, ' ').trim();\n const words = new Set(text.split(' '));\n const hyphenated = text.replace(/ /g, '-');\n\n for (const [phase, terms] of VOCABULARY) {\n for (const term of terms) {\n if (HAN.test(term)) {\n if (hanTermIn(plain, term)) return phase;\n } else if (term.includes('-')) {\n if (hyphenated.includes(term)) return phase;\n } else if (words.has(term)) {\n return phase;\n }\n }\n }\n return 'unknown';\n}\n\n/** Whether a document in this phase can take on a new open obligation. */\nexport function receptivityOf(phase: Phase): Receptivity {\n switch (phase) {\n case 'draft':\n case 'active':\n return 'receptive';\n case 'frozen':\n case 'retired':\n // A record was never asking for an obligation, so it cannot take one on.\n // Sealed for the same reason a retired document is, by a different route.\n case 'record':\n return 'sealed';\n case 'unknown':\n return 'unknown';\n }\n}\n\n/** True when the phase means the document no longer binds anybody. */\nexport function isRetired(phase: Phase): boolean {\n return phase === 'retired';\n}\n\n/** True when the heading names a section that declares the document status. */\nexport function isStatusHeading(text: string): boolean {\n return STATUS_HEADINGS.has(text.toLowerCase().replace(/[::*_`]/g, '').trim());\n}\n\n/**\n * Infers retirement from where a file lives.\n *\n * Moving an ADR into `docs/adr/archive/` is the most common way a team retires a\n * decision without touching its front matter, and a graph that misses it will\n * happily let obligations be delegated into the archive.\n */\nexport function phaseFromPath(posixPath: string): Phase {\n const segments = posixPath.toLowerCase().split('/');\n // The file name itself is not a directory; a document called `archive`, with\n // or without an extension, is not retired.\n for (let i = 0; i < segments.length - 1; i += 1) {\n if (RETIRING_DIRECTORIES.has(segments[i] as string)) return 'retired';\n }\n return 'unknown';\n}\n\n/**\n * Pulls a supersession target out of a status string.\n *\n * `Superseded by ADR-0009` is the single most common way a supersession is ever\n * recorded, and it is written in the status field rather than as a link. Reading\n * it here means the relation reaches the graph even in repositories that never\n * adopted an explicit field for it.\n *\n * In Chinese the successor stands between `被` and the verb: `已被 ADR-0003\n * 取代`. Left unread, a document that said so and one that said it supersedes\n * this one disagreed, and `unreciprocated-supersession` asked for a\n * `superseded-by` key the status had already given.\n */\nexport function supersessionTargetsIn(raw: string): string[] {\n const out: string[] = [];\n const plain = raw.replace(/[`*_]/g, '');\n // The tail runs to the end of the line, not of the string: a status that\n // wraps onto a second line still names its successor on the first.\n const pattern = /(?:super[sc]eded|replaced|obsoleted)\\s*(?:by|with|through)?\\s*[:\\-–—]?\\s*(.+)/i;\n const match = pattern.exec(plain);\n // A link inside the passive is read by its label, as a status is: its path\n // would run the name past the thirty characters the form allows.\n const tails = match ? [match[1] as string] : passiveSupersessions(plain.replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1'));\n for (const tail of tails) {\n for (const token of tail.split(/[,;、,;和及與与]|\\band\\b/)) {\n const cleaned = token\n .replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1')\n .replace(/[()<>\"'()]/g, ' ')\n .trim();\n if (cleaned.length > 0 && cleaned.length < 200) out.push(cleaned);\n }\n }\n return out;\n}\n"]}
|
package/dist/report.d.ts
CHANGED
|
@@ -47,6 +47,14 @@ export interface ReporterOptions {
|
|
|
47
47
|
readonly ratchet?: boolean | undefined;
|
|
48
48
|
readonly entries?: readonly StaleEntry[] | undefined;
|
|
49
49
|
} | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* The baseline's path as it is typed where the run was started, for the
|
|
52
|
+
* command that re-records it; `baseline.source` when unset. The source reads
|
|
53
|
+
* from the root, and typed in a directory below it, it names another file.
|
|
54
|
+
* Beside the baseline rather than in it, because the JSON report writes the
|
|
55
|
+
* baseline whole.
|
|
56
|
+
*/
|
|
57
|
+
readonly recordAs?: string | undefined;
|
|
50
58
|
}
|
|
51
59
|
export interface ColorEnvironment {
|
|
52
60
|
readonly isTTY?: boolean | undefined;
|
|
@@ -142,6 +150,20 @@ export declare function formatSarif(result: AnalysisResult, graph: SpecGraph, op
|
|
|
142
150
|
export declare function formatGitlab(result: AnalysisResult, options?: {
|
|
143
151
|
escalated?: ReadonlySet<AnyRuleId> | undefined;
|
|
144
152
|
}): string;
|
|
153
|
+
/**
|
|
154
|
+
* Findings as GitHub Actions workflow commands, one line each, which a job's
|
|
155
|
+
* log turns into annotations on the pull request's diff with no upload step -
|
|
156
|
+
* what SARIF does through code scanning, for a repository that has none.
|
|
157
|
+
*
|
|
158
|
+
* An error is `error`, a warning `warning` and a note `notice`, as spec-guard
|
|
159
|
+
* writes them. The rule is the title, marked `(strict)` where only `--strict`
|
|
160
|
+
* made it an error, as the Markdown report marks it; the message carries the
|
|
161
|
+
* hint, since a finding without its next action is the half a reader cannot
|
|
162
|
+
* act on. Nothing at all for a clean run.
|
|
163
|
+
*/
|
|
164
|
+
export declare function formatGithub(result: AnalysisResult, options?: {
|
|
165
|
+
escalated?: ReadonlySet<AnyRuleId> | undefined;
|
|
166
|
+
}): string;
|
|
145
167
|
export declare function formatJson(result: AnalysisResult, options?: {
|
|
146
168
|
escalated?: ReadonlySet<AnyRuleId>;
|
|
147
169
|
baseline?: ReporterOptions['baseline'];
|
package/dist/report.js
CHANGED
|
@@ -14,6 +14,7 @@ import { createHash } from 'node:crypto';
|
|
|
14
14
|
import { fingerprintOf } from './baseline.js';
|
|
15
15
|
import { formatRef } from './source.js';
|
|
16
16
|
import { DEFAULT_SEVERITIES, RULE_DESCRIPTIONS, RULE_IDS } from './rules.js';
|
|
17
|
+
import { displayWidth } from './vendor/spec-core/text/index.js';
|
|
17
18
|
/** Honours `NO_COLOR`, `FORCE_COLOR` and `TERM=dumb` before falling back to TTY. */
|
|
18
19
|
export function shouldUseColor(environment = {}) {
|
|
19
20
|
const env = environment.env ?? process.env;
|
|
@@ -139,7 +140,7 @@ export function formatReport(result, options = {}) {
|
|
|
139
140
|
// anything that is not one counts the same zero.
|
|
140
141
|
const gone = (baseline.entries ?? []).filter((entry) => entry.reason === 'gone').length;
|
|
141
142
|
const because = gone === 0
|
|
142
|
-
? `tighten it: spec-graph check --record-baseline ${baseline.source}`
|
|
143
|
+
? `tighten it: spec-graph check --record-baseline ${options.recordAs ?? baseline.source}`
|
|
143
144
|
: `${gone} of them ${gone === 1 ? 'names a document' : 'name documents'} this run did not see - check the include patterns before re-recording`;
|
|
144
145
|
const text = `${baseline.stale} baseline ${plural(baseline.stale, 'entry', 'entries')} no longer ${baseline.stale === 1 ? 'occurs' : 'occur'} - ${because}`;
|
|
145
146
|
lines.push(ratcheted ? `${paint.error(marks.error)} ${text}` : paint.dim(text));
|
|
@@ -164,10 +165,14 @@ function formatDiagnostic(diagnostic, paint, marks, escalated) {
|
|
|
164
165
|
`${mark} ${paint.location(formatRef(diagnostic.at))} ${paint.dim(label)}`,
|
|
165
166
|
` ${diagnostic.message}`,
|
|
166
167
|
];
|
|
167
|
-
|
|
168
|
+
// Padded to the columns a terminal draws, not to UTF-16 units: `docs/決策.md`
|
|
169
|
+
// is ten units and twelve columns, so `.padEnd` left the notes beside it two
|
|
170
|
+
// columns out of line.
|
|
171
|
+
const width = Math.max(0, ...diagnostic.related.map((entry) => displayWidth(formatRef(entry.at))));
|
|
168
172
|
for (const entry of diagnostic.related) {
|
|
169
173
|
const reference = formatRef(entry.at);
|
|
170
|
-
|
|
174
|
+
const padded = `${reference}${' '.repeat(width - displayWidth(reference))}`;
|
|
175
|
+
lines.push(` ${paint.dim(marks.related)} ${paint.dim(padded)} ${paint.dim(entry.note)}`);
|
|
171
176
|
}
|
|
172
177
|
lines.push(` ${paint.hint(marks.hint)} ${paint.hint(diagnostic.hint)}`);
|
|
173
178
|
return lines;
|
|
@@ -525,6 +530,48 @@ function gitlabSeverity(severity, escalated) {
|
|
|
525
530
|
return 'info';
|
|
526
531
|
}
|
|
527
532
|
}
|
|
533
|
+
/* -------------------------------------------------------------------------- */
|
|
534
|
+
/* GitHub workflow commands */
|
|
535
|
+
/* -------------------------------------------------------------------------- */
|
|
536
|
+
/** A workflow command's message: `%`, and the line breaks that would end the command. */
|
|
537
|
+
function escapeData(text) {
|
|
538
|
+
return text.replace(/%/g, '%25').replace(/\r/g, '%0D').replace(/\n/g, '%0A');
|
|
539
|
+
}
|
|
540
|
+
/** A workflow command's property: as a message, and the `:` and `,` that would end the property. */
|
|
541
|
+
function escapeProperty(text) {
|
|
542
|
+
return escapeData(text).replace(/:/g, '%3A').replace(/,/g, '%2C');
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Findings as GitHub Actions workflow commands, one line each, which a job's
|
|
546
|
+
* log turns into annotations on the pull request's diff with no upload step -
|
|
547
|
+
* what SARIF does through code scanning, for a repository that has none.
|
|
548
|
+
*
|
|
549
|
+
* An error is `error`, a warning `warning` and a note `notice`, as spec-guard
|
|
550
|
+
* writes them. The rule is the title, marked `(strict)` where only `--strict`
|
|
551
|
+
* made it an error, as the Markdown report marks it; the message carries the
|
|
552
|
+
* hint, since a finding without its next action is the half a reader cannot
|
|
553
|
+
* act on. Nothing at all for a clean run.
|
|
554
|
+
*/
|
|
555
|
+
export function formatGithub(result, options = {}) {
|
|
556
|
+
const escalated = options.escalated ?? EMPTY_RULES;
|
|
557
|
+
return result.diagnostics
|
|
558
|
+
.map((diagnostic) => {
|
|
559
|
+
const title = escalated.has(diagnostic.rule) ? `${diagnostic.rule} (strict)` : diagnostic.rule;
|
|
560
|
+
const place = `file=${escapeProperty(diagnostic.at.file)},line=${diagnostic.at.span.start.line}`;
|
|
561
|
+
return `::${githubLevel(diagnostic.severity)} ${place},title=${escapeProperty(title)}::${escapeData(`${diagnostic.message}. ${diagnostic.hint}`)}\n`;
|
|
562
|
+
})
|
|
563
|
+
.join('');
|
|
564
|
+
}
|
|
565
|
+
function githubLevel(severity) {
|
|
566
|
+
switch (severity) {
|
|
567
|
+
case 'error':
|
|
568
|
+
return 'error';
|
|
569
|
+
case 'warn':
|
|
570
|
+
return 'warning';
|
|
571
|
+
default:
|
|
572
|
+
return 'notice';
|
|
573
|
+
}
|
|
574
|
+
}
|
|
528
575
|
export function formatJson(result, options = {}) {
|
|
529
576
|
const escalated = options.escalated ?? EMPTY_RULES;
|
|
530
577
|
return `${JSON.stringify({
|
package/dist/report.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.js","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAmB,MAAM,eAAe,CAAC;AAG/D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAmE7E,oFAAoF;AACpF,MAAM,UAAU,cAAc,CAAC,WAAW,GAAqB,EAAE;IAC/D,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IAC3C,IA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MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AACjE,CAAC","sourcesContent":["/**\n * Output formatting.\n *\n * Two audiences, one set of facts. In a terminal the report leads with the file\n * and line so an editor can jump there, indents the supporting evidence, and\n * ends with a concrete next action - because a finding a reader cannot act on\n * is a finding they will learn to scroll past. In CI it emits JSON with every\n * position intact, so a bot can annotate a diff.\n *\n * Colour is opt-out and auto-detected, and the glyphs degrade to ASCII when the\n * terminal cannot render them.\n */\n\nimport { createHash } from 'node:crypto';\n\nimport { fingerprintOf, type StaleEntry } from './baseline.js';\nimport type { SpecGraph } from './graph.js';\nimport type { ProjectRule } from './project-rules.js';\nimport { formatRef } from './source.js';\nimport { DEFAULT_SEVERITIES, RULE_DESCRIPTIONS, RULE_IDS } from './rules.js';\nimport type { AnalysisResult } from './runner.js';\nimport type {\n AnyRuleId,\n Diagnostic,\n Edge,\n RuleId,\n Severity,\n SourceRef,\n SpecNode,\n SuppressedRef,\n} from './types.js';\n\nexport interface ReporterOptions {\n readonly color?: boolean | undefined;\n readonly ascii?: boolean | undefined;\n readonly verbose?: boolean | undefined;\n /** Stop after this many findings. `0` means no limit. */\n readonly max?: number | undefined;\n /**\n * Rules whose severity `--strict` raised.\n *\n * A finding that only became an error because of a flag has to say so, or the\n * reader cannot tell what would happen without it.\n */\n readonly escalated?: ReadonlySet<AnyRuleId> | undefined;\n /**\n * What a baseline accounted for on this run.\n *\n * Reported as counts rather than as a list: the point of accepted debt is\n * that nobody has to read it every time. `stale` is the ratchet - debt the\n * run did not spend and which can be struck from the file - and `ratchet`\n * says whether this run was asked to fail over it.\n *\n * `entries` carries the stale ones themselves, for the structured formats. A\n * number is enough to know the file has slack and never enough to strike it,\n * and a bot that wants to open the pull request needs the rows.\n */\n readonly baseline?:\n | {\n readonly source: string;\n readonly suppressed: number;\n readonly stale: number;\n readonly ratchet?: boolean | undefined;\n readonly entries?: readonly StaleEntry[] | undefined;\n }\n | undefined;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Environment detection */\n/* -------------------------------------------------------------------------- */\n\nexport interface ColorEnvironment {\n readonly isTTY?: boolean | undefined;\n readonly env?: Readonly<Record<string, string | undefined>> | undefined;\n /**\n * Host platform, defaulting to the real one.\n *\n * Injected for the same reason `env` is: without it half of\n * {@link shouldUseAscii} is unreachable from a test, and a rule about\n * Windows consoles that only Windows can exercise is a rule that breaks on\n * Windows and nowhere else.\n */\n readonly platform?: NodeJS.Platform | undefined;\n}\n\n/** Honours `NO_COLOR`, `FORCE_COLOR` and `TERM=dumb` before falling back to TTY. */\nexport function shouldUseColor(environment: ColorEnvironment = {}): boolean {\n const env = environment.env ?? process.env;\n if (env['NO_COLOR'] !== undefined && env['NO_COLOR'] !== '') return false;\n // `FORCE_COLOR=0` is the conventional way to turn colour off, so it has to\n // win over an attached TTY rather than merely failing to force it on.\n if (env['FORCE_COLOR'] === '0') return false;\n if (env['FORCE_COLOR'] !== undefined && env['FORCE_COLOR'] !== '') return true;\n if (env['TERM'] === 'dumb') return false;\n if (env['CI'] !== undefined && env['CI'] !== '') return false;\n return environment.isTTY === true;\n}\n\n/** True when the terminal is unlikely to render box-drawing and arrows. */\nexport function shouldUseAscii(environment: ColorEnvironment = {}): boolean {\n const env = environment.env ?? process.env;\n if (env['SPEC_GRAPH_ASCII'] !== undefined && env['SPEC_GRAPH_ASCII'] !== '') return true;\n if ((environment.platform ?? process.platform) !== 'win32') return false;\n // Windows Terminal and modern shells set these; the legacy console does not.\n return env['WT_SESSION'] === undefined && env['TERM_PROGRAM'] === undefined;\n}\n\nconst EMPTY_RULES: ReadonlySet<RuleId> = new Set<RuleId>();\n\ntype Paint = (text: string) => string;\n\nexport interface Painter {\n readonly error: Paint;\n readonly warn: Paint;\n readonly info: Paint;\n readonly dim: Paint;\n readonly bold: Paint;\n readonly hint: Paint;\n readonly location: Paint;\n}\n\nexport function createPainter(color: boolean): Painter {\n const wrap = (open: string): Paint => (text) => (color ? `\\u001b[${open}m${text}\\u001b[0m` : text);\n return {\n error: wrap('31'),\n warn: wrap('33'),\n info: wrap('36'),\n dim: wrap('2'),\n bold: wrap('1'),\n hint: wrap('32'),\n location: wrap('4'),\n };\n}\n\ninterface Glyphs {\n readonly error: string;\n readonly warn: string;\n readonly info: string;\n readonly related: string;\n readonly hint: string;\n readonly separator: string;\n}\n\nfunction glyphs(ascii: boolean): Glyphs {\n return ascii\n ? { error: 'x', warn: '!', info: 'i', related: '|', hint: '>', separator: '-' }\n : { error: '\\u2716', warn: '\\u26a0', info: '\\u2139', related: '\\u21b3', hint: '\\u2192', separator: '\\u00b7' };\n}\n\n/* -------------------------------------------------------------------------- */\n/* Human report */\n/* -------------------------------------------------------------------------- */\n\n/** Renders the full terminal report. */\nexport function formatReport(result: AnalysisResult, options: ReporterOptions = {}): string {\n const paint = createPainter(options.color ?? false);\n const marks = glyphs(options.ascii ?? false);\n const lines: string[] = [];\n const { summary } = result;\n\n lines.push(\n `${paint.bold('spec-graph')} ${paint.dim(\n [\n `${summary.documents} ${plural(summary.documents, 'document')}`,\n `${summary.items} ${plural(summary.items, 'item')}`,\n `${summary.edges} ${plural(summary.edges, 'relation')}`,\n `${summary.openObligations} open`,\n ].join(` ${marks.separator} `),\n )}`,\n );\n lines.push('');\n\n // Zero is falsy and never reaches the comparison, so `> 0` and `>= 0` are\n // the same test here.\n const limit = options.max && options.max > 0 ? options.max : result.diagnostics.length;\n const shown = result.diagnostics.slice(0, limit);\n\n const escalated = options.escalated ?? EMPTY_RULES;\n for (const diagnostic of shown) {\n lines.push(...formatDiagnostic(diagnostic, paint, marks, escalated));\n lines.push('');\n }\n\n if (result.diagnostics.length > shown.length) {\n lines.push(paint.dim(` ... and ${result.diagnostics.length - shown.length} more`));\n lines.push('');\n }\n\n if (options.verbose && result.problems.length > 0) {\n for (const problem of result.problems) {\n lines.push(`${paint.warn(marks.warn)} ${paint.location(formatRef(problem.at))} ${problem.message}`);\n }\n lines.push('');\n }\n\n const unread = options.verbose ? 0 : unreadFrontMatter(result);\n if (unread > 0) {\n lines.push(`${paint.warn(marks.warn)} ${unreadNotice(unread)}`, '');\n }\n\n // What the repository told spec-graph to stop looking at. Only under\n // --verbose, and never as a finding: these are not defects, they are the one\n // place a configuration can make the check quieter, and a single over-broad\n // glob looks exactly like a clean repository from the outside. See ADR-0008.\n if (options.verbose && result.corpus.suppressed.length > 0) {\n for (const [target, entry] of groupSuppressed(result.corpus.suppressed)) {\n const where = entry.by === 'family' ? 'ignored family' : 'ignored reference';\n const times = entry.count === 1 ? '' : ` (${entry.count} times)`;\n lines.push(`${paint.dim(marks.info)} ${paint.location(formatRef(entry.at))} ${paint.dim(`${where}: ${target}${times}`)}`);\n }\n lines.push('');\n }\n\n const tally: string[] = [];\n if (summary.errors > 0) tally.push(paint.error(`${summary.errors} ${plural(summary.errors, 'error')}`));\n if (summary.warnings > 0) tally.push(paint.warn(`${summary.warnings} ${plural(summary.warnings, 'warning')}`));\n if (summary.infos > 0) tally.push(paint.info(`${summary.infos} ${plural(summary.infos, 'note')}`));\n tally.push(paint.dim(`${summary.durationMs}ms`));\n const raised = result.diagnostics.filter((diagnostic) => escalated.has(diagnostic.rule)).length;\n if (raised > 0) {\n tally.push(paint.warn(`${raised} raised by --strict`));\n }\n const baseline = options.baseline;\n if (baseline !== undefined && baseline.suppressed > 0) {\n tally.push(paint.dim(`${baseline.suppressed} accepted by ${baseline.source}`));\n }\n lines.push(tally.join(` ${marks.separator} `));\n\n // Under `--ratchet` a paid entry is a failure rather than a note, so it is\n // painted and worded as one.\n const ratcheted = ratchetFailed(baseline);\n if (baseline !== undefined && baseline.stale > 0) {\n // A \"gone\" entry is not the ratchet working, and saying so matters more\n // than the count does: the usual way to produce one is to narrow an include\n // pattern, which loses sight of a defect rather than fixing it.\n //\n // The fallback is only ever filtered for gone entries, so filling it with\n // anything that is not one counts the same zero.\n const gone = (baseline.entries ?? []).filter((entry) => entry.reason === 'gone').length;\n const because =\n gone === 0\n ? `tighten it: spec-graph check --record-baseline ${baseline.source}`\n : `${gone} of them ${gone === 1 ? 'names a document' : 'name documents'} this run did not see - check the include patterns before re-recording`;\n const text = `${baseline.stale} baseline ${plural(baseline.stale, 'entry', 'entries')} no longer ${\n baseline.stale === 1 ? 'occurs' : 'occur'\n } - ${because}`;\n lines.push(ratcheted ? `${paint.error(marks.error)} ${text}` : paint.dim(text));\n }\n\n // `ok` means no errors, so where it is true the sum below is the warnings\n // alone and `-` in place of `+` asks the same question.\n lines.push(\n ratcheted\n ? `${paint.error(marks.error)} ${\n result.ok ? 'the baseline is looser than the repository' : 'the specification graph is inconsistent'\n }`\n : result.ok\n ? `${paint.hint(marks.hint === '>' ? 'ok' : '\\u2714')} ${\n summary.errors + summary.warnings === 0\n ? 'the specification graph is consistent'\n : 'no errors - the specification graph holds'\n }`\n : `${paint.error(marks.error)} the specification graph is inconsistent`,\n );\n\n return lines.join('\\n');\n}\n\nfunction formatDiagnostic(\n diagnostic: Diagnostic,\n paint: Painter,\n marks: Glyphs,\n escalated: ReadonlySet<AnyRuleId>,\n): string[] {\n const mark = severityMark(diagnostic.severity, paint, marks);\n const label = escalated.has(diagnostic.rule)\n ? `${diagnostic.rule} ${paint.warn('(strict: warn -> error)')}`\n : diagnostic.rule;\n const lines: string[] = [\n `${mark} ${paint.location(formatRef(diagnostic.at))} ${paint.dim(label)}`,\n ` ${diagnostic.message}`,\n ];\n\n const width = Math.max(0, ...diagnostic.related.map((entry) => formatRef(entry.at).length));\n for (const entry of diagnostic.related) {\n const reference = formatRef(entry.at);\n lines.push(` ${paint.dim(marks.related)} ${paint.dim(reference.padEnd(width))} ${paint.dim(entry.note)}`);\n }\n\n lines.push(` ${paint.hint(marks.hint)} ${paint.hint(diagnostic.hint)}`);\n return lines;\n}\n\nfunction severityMark(severity: Exclude<Severity, 'off'>, paint: Painter, marks: Glyphs): string {\n switch (severity) {\n case 'error':\n return paint.error(marks.error);\n case 'warn':\n return paint.warn(marks.warn);\n case 'info':\n return paint.info(marks.info);\n }\n}\n\nfunction plural(count: number, word: string, plural?: string): string {\n if (count === 1) return word;\n return plural ?? `${word}s`;\n}\n\n/**\n * How many front-matter values the graph is built from went unread.\n *\n * Parse problems are listed only under `--verbose`, and most of them can wait\n * there. These cannot: `status: Superseded by ADR-3: see notes` is not read,\n * the document reads as unknown, and a failing check reports that the graph is\n * consistent. So a default run says how many there are, and where to look.\n */\nfunction unreadFrontMatter(result: AnalysisResult): number {\n return result.problems.filter((problem) => problem.unread === true).length;\n}\n\nfunction unreadNotice(count: number): string {\n return `${count} front-matter ${plural(count, 'value')} not read - see --verbose`;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Markdown */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The same report as GitHub-flavoured Markdown.\n *\n * SARIF puts a finding on the line that caused it, which is where somebody\n * fixing one wants it. It says nothing to the person deciding whether to merge,\n * because a code-scanning alert is a list of lines and not a verdict. This is\n * the verdict: one table, the counts above it, and the baseline's slack\n * underneath, sized to be read without scrolling.\n *\n * Written for `$GITHUB_STEP_SUMMARY` and for a pull-request comment, but it is\n * named for what it is rather than for where it goes - the same text is what a\n * review tool, a chat message or a generated page wants.\n *\n * It carries no duration, which the JSON report does, so two runs over one\n * corpus produce identical bytes. That is what lets a test compare a run from\n * a subdirectory against a run from the root and assert they are the same\n * report rather than the same shape. See ADR-0015 and ADR-0018.\n */\nexport function formatMarkdown(result: AnalysisResult, options: ReporterOptions = {}): string {\n const { summary } = result;\n const escalated = options.escalated ?? EMPTY_RULES;\n const ratcheted = ratchetFailed(options.baseline);\n const lines: string[] = ['### spec-graph', ''];\n\n // `ok` means no errors, as in the terminal's verdict, so `-` in place of `+`\n // below asks the same question.\n const verdict =\n ratcheted && result.ok\n ? 'The baseline is looser than the repository.'\n : result.ok\n ? summary.errors + summary.warnings === 0\n ? 'The specification graph is consistent.'\n : 'No errors - the specification graph holds.'\n : 'The specification graph is inconsistent.';\n lines.push(verdict, '');\n\n lines.push('| | |', '| --- | ---: |');\n lines.push(`| Documents | ${summary.documents} |`);\n lines.push(`| Items | ${summary.items} |`);\n lines.push(`| Relations | ${summary.edges} |`);\n lines.push(`| Open obligations | ${summary.openObligations} |`);\n lines.push(`| Errors | ${summary.errors} |`);\n lines.push(`| Warnings | ${summary.warnings} |`);\n lines.push(`| Notes | ${summary.infos} |`);\n lines.push('');\n\n // Zero never reaches the comparison, as in the terminal report.\n const limit = options.max && options.max > 0 ? options.max : result.diagnostics.length;\n const shown = result.diagnostics.slice(0, limit);\n\n if (shown.length > 0) {\n lines.push('| | Rule | Where | Finding |', '| --- | --- | --- | --- |');\n for (const diagnostic of shown) {\n const rule = escalated.has(diagnostic.rule) ? `${diagnostic.rule} (strict)` : diagnostic.rule;\n // The hint in the same cell, under the message. A finding without its\n // next action is the half a reader cannot act on, and a fifth column\n // would push the message off the side of the page.\n const what = `${cell(diagnostic.message)}<br>${cell(diagnostic.hint)}`;\n lines.push(`| ${diagnostic.severity} | \\`${cell(rule)}\\` | \\`${cell(formatRef(diagnostic.at))}\\` | ${what} |`);\n }\n if (result.diagnostics.length > shown.length) {\n lines.push(`| | | | ... and ${result.diagnostics.length - shown.length} more |`);\n }\n lines.push('');\n }\n\n const baseline = options.baseline;\n if (baseline !== undefined) {\n const accepted = `${baseline.suppressed} ${plural(baseline.suppressed, 'finding')} accepted by \\`${cell(baseline.source)}\\``;\n if (baseline.stale === 0) {\n lines.push(accepted, '');\n } else {\n // The fallback is only filtered for gone entries, as in the terminal report.\n const gone = (baseline.entries ?? []).filter((entry) => entry.reason === 'gone').length;\n lines.push(\n `${accepted}, and ${baseline.stale} ${plural(baseline.stale, 'entry', 'entries')} no longer ${\n baseline.stale === 1 ? 'occurs' : 'occur'\n }${\n gone === 0\n ? ''\n : ` - ${gone} of them ${gone === 1 ? 'names a document' : 'name documents'} this run did not see`\n }.`,\n '',\n );\n // Listed rather than counted, because the point of a summary on a pull\n // request is that somebody can act on it without opening a terminal.\n lines.push('| Entry | Rule | Document | Why |', '| --- | --- | --- | --- |');\n for (const entry of baseline.entries ?? []) {\n const why = entry.reason === 'gone' ? 'not in this corpus - check the include patterns' : 'fixed';\n lines.push(`| ${entry.reason} | \\`${cell(entry.rule)}\\` | \\`${cell(entry.document)}\\` | ${why} |`);\n }\n lines.push('');\n }\n }\n\n const unread = options.verbose ? 0 : unreadFrontMatter(result);\n if (unread > 0) lines.push(`${unreadNotice(unread)}.`, '');\n\n if (options.verbose && result.problems.length > 0) {\n lines.push('<details><summary>Problems with the input</summary>', '');\n for (const problem of result.problems) {\n lines.push(`- \\`${cell(formatRef(problem.at))}\\` ${cell(problem.message)}`);\n }\n lines.push('', '</details>', '');\n }\n\n if (options.verbose && result.corpus.suppressed.length > 0) {\n lines.push('<details><summary>References this configuration silenced</summary>', '');\n for (const [target, entry] of groupSuppressed(result.corpus.suppressed)) {\n const where = entry.by === 'family' ? 'ignored family' : 'ignored reference';\n const times = entry.count === 1 ? '' : ` (${entry.count} times)`;\n lines.push(`- \\`${cell(target)}\\` - ${where}${times}, first at \\`${cell(formatRef(entry.at))}\\``);\n }\n lines.push('', '</details>', '');\n }\n\n // Every block above ends in exactly one blank line, so there is only ever one\n // trailing newline for this to strip, and `\\n$` would strip the same.\n return `${lines.join('\\n').replace(/\\n+$/, '')}\\n`;\n}\n\n/**\n * Makes one value safe to put in a table cell.\n *\n * A pipe would end the cell and a newline would end the row, and a diagnostic\n * message is written by whoever wrote the rule - including a project rule,\n * whose message is a template a repository controls.\n */\nfunction cell(value: string): string {\n return value.replace(/[|]/g, '|').replace(/\\s+/g, ' ').trim();\n}\n\n/* -------------------------------------------------------------------------- */\n/* JSON */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The machine-readable report.\n *\n * Deliberately flat and versioned: this is the contract a CI annotator or a\n * dashboard builds against, and it must be safe to add fields to it later.\n */\n/**\n * One row per silenced target, with the first place it was written.\n *\n * Grouped because a concept tag used forty times is one decision, and forty\n * lines of it would bury the one entry somebody needs to see. Insertion order\n * is document order, which is already deterministic.\n */\nfunction groupSuppressed(\n suppressed: readonly SuppressedRef[],\n): Map<string, { at: SourceRef; by: SuppressedRef['by']; count: number }> {\n const out = new Map<string, { at: SourceRef; by: SuppressedRef['by']; count: number }>();\n for (const entry of suppressed) {\n const seen = out.get(entry.target);\n if (seen === undefined) out.set(entry.target, { at: entry.at, by: entry.by, count: 1 });\n else seen.count += 1;\n }\n return out;\n}\n\n/**\n * True when a baseline was asked to ratchet and has slack left in it.\n *\n * Both reporters ask, because both have to agree with the exit code: a report\n * that prints \"ok\" above a failing build is worse than no report.\n */\nfunction ratchetFailed(baseline: ReporterOptions['baseline']): boolean {\n return baseline !== undefined && baseline.ratchet === true && baseline.stale > 0;\n}\n\n/* -------------------------------------------------------------------------- */\n/* SARIF */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The static-analysis interchange format, for the tools that already read it.\n *\n * The reason to emit it is not the format, it is what consumes the format:\n * GitHub code scanning turns a SARIF upload into annotations on the diff, and\n * an editor turns it into the problems pane, neither of which needs a line of\n * spec-graph-specific integration.\n *\n * One field earns the whole exercise. `partialFingerprints` is how a consumer\n * tracks a finding across commits without keying on a line number, and\n * spec-graph already has exactly that identifier for exactly that reason - the\n * `rule/document/subject` triple a baseline is keyed on (ADR-0012). The two\n * problems turned out to be the same problem, so the answer is the same answer.\n *\n * Deterministic and timestamp-free, like every other output here. Nothing about\n * a run that has the same findings should produce a different file.\n */\nexport function formatSarif(\n result: AnalysisResult,\n graph: SpecGraph,\n options: {\n version?: string | undefined;\n escalated?: ReadonlySet<AnyRuleId> | undefined;\n projectRules?: readonly ProjectRule[] | undefined;\n } = {},\n): string {\n const escalated = options.escalated ?? EMPTY_RULES;\n // A project rule describes itself by the selector it is, because that is the\n // only honest answer: its message is a template, and a template with `{0}` in\n // it is not a description of anything. See ADR-0016.\n const known: [AnyRuleId, string, Severity][] = [\n ...RULE_IDS.map((id): [AnyRuleId, string, Severity] => [id, RULE_DESCRIPTIONS[id], DEFAULT_SEVERITIES[id]]),\n ...(options.projectRules ?? []).map((rule): [AnyRuleId, string, Severity] => [\n rule.id,\n rule.sources.join(' | '),\n rule.severity,\n ]),\n ];\n const fired = known.filter(([id]) => result.diagnostics.some((diagnostic) => diagnostic.rule === id));\n return `${JSON.stringify(\n {\n $schema: 'https://json.schemastore.org/sarif-2.1.0.json',\n version: '2.1.0',\n runs: [\n {\n tool: {\n driver: {\n name: 'spec-graph',\n informationUri: 'https://github.com/DescentVTT/spec-graph',\n // JSON.stringify drops a key whose value is undefined, so always\n // spreading the pair writes the same file; the test is for the reader.\n ...(options.version === undefined ? {} : { version: options.version, semanticVersion: options.version }),\n // Only the rules that fired. A driver listing all of them\n // describes the tool; this file describes the run.\n rules: fired.map(([id, description, level]) => ({\n id,\n shortDescription: { text: description },\n defaultConfiguration: { level: sarifLevel(level) },\n })),\n },\n },\n results: result.diagnostics.map((diagnostic) => {\n const print = fingerprintOf(graph, diagnostic);\n return {\n ruleId: diagnostic.rule,\n level: sarifLevel(diagnostic.severity),\n message: { text: `${diagnostic.message}. ${diagnostic.hint}` },\n locations: [sarifLocation(diagnostic.at)],\n ...(diagnostic.related.length === 0\n ? {}\n : {\n relatedLocations: diagnostic.related.map((entry) => ({\n ...sarifLocation(entry.at),\n message: { text: entry.note },\n })),\n }),\n partialFingerprints: {\n specGraphIdentity: `${diagnostic.rule}/${print.document}/${print.subject}`,\n },\n properties: {\n nodes: diagnostic.nodes,\n target: diagnostic.target,\n // A finding that is only an error because of a flag says so\n // here too, so a reviewer reading an annotation is not misled.\n escalated: escalated.has(diagnostic.rule),\n },\n };\n }),\n },\n ],\n },\n null,\n 2,\n )}\\n`;\n}\n\nfunction sarifLevel(severity: Severity): string {\n switch (severity) {\n case 'error':\n return 'error';\n case 'warn':\n return 'warning';\n case 'info':\n return 'note';\n default:\n return 'none';\n }\n}\n\nfunction sarifLocation(at: SourceRef): {\n physicalLocation: {\n artifactLocation: { uri: string };\n region: { startLine: number; startColumn: number; endLine: number; endColumn: number };\n };\n} {\n return {\n physicalLocation: {\n // Already repository-relative and POSIX, which is what SARIF asks for.\n artifactLocation: { uri: at.file },\n region: {\n startLine: at.span.start.line,\n startColumn: at.span.start.column,\n endLine: at.span.end.line,\n endColumn: at.span.end.column,\n },\n },\n };\n}\n\n/* -------------------------------------------------------------------------- */\n/* GitLab Code Quality */\n/* -------------------------------------------------------------------------- */\n\ntype GitlabSeverity = 'critical' | 'major' | 'minor' | 'info';\n\n/**\n * GitLab's Code Quality report, which a merge request reads to show the\n * findings a change introduced and the ones it resolved - what SARIF is to\n * GitHub, so the family is not GitHub's alone.\n *\n * The format is GitLab's and carries no version of its own: a JSON array with\n * the five fields GitLab reads and nothing else.\n *\n * `fingerprint` is how GitLab matches a finding in the merge request to the\n * same finding on the target branch, so it holds what the finding is about and\n * nothing that moves when something else changes: the rule, the specification\n * and what within it, hashed - the identity a baseline counts by. Not the line,\n * so a paragraph moved above a finding does not make it new. Not the message,\n * which carries counts: ticking one of three boxes turned \"holds 3 open\n * obligations\" into \"holds 2\", and GitLab showed one finding resolved and one\n * introduced. Two findings that agree on all three - one broken link written\n * twice in a document - are told apart by their order, the second hashed with a\n * `2`: GitLab tells issues apart by fingerprint, and two that shared one would\n * be read as one.\n */\nexport function formatGitlab(\n result: AnalysisResult,\n options: { escalated?: ReadonlySet<AnyRuleId> | undefined } = {},\n): string {\n const escalated = options.escalated ?? EMPTY_RULES;\n const occurrences = new Map<string, number>();\n const issues = result.diagnostics.map((diagnostic) => {\n const { document, subject } = fingerprintOf(result.graph, diagnostic);\n const identity = [diagnostic.rule, document, subject];\n const key = JSON.stringify(identity);\n const occurrence = (occurrences.get(key) ?? 0) + 1;\n occurrences.set(key, occurrence);\n return {\n description: `${diagnostic.message}. ${diagnostic.hint}`,\n check_name: diagnostic.rule,\n fingerprint: createHash('sha256')\n .update(occurrence === 1 ? key : JSON.stringify([...identity, occurrence]))\n .digest('hex'),\n severity: gitlabSeverity(diagnostic.severity, escalated.has(diagnostic.rule)),\n location: { path: diagnostic.at.file, lines: { begin: diagnostic.at.span.start.line } },\n };\n });\n return `${JSON.stringify(issues, null, 2)}\\n`;\n}\n\n/**\n * spec-graph's three severities on GitLab's five. An error is critical: it\n * fails the build. One that is only an error because `--strict` raised it is\n * major, which is the one place the report can say so. A warning is minor,\n * and a note is information. `blocker` is left to tools that know more about\n * what cannot ship than a documentation linter does.\n */\nfunction gitlabSeverity(severity: Severity, escalated: boolean): GitlabSeverity {\n switch (severity) {\n case 'error':\n return escalated ? 'major' : 'critical';\n case 'warn':\n return 'minor';\n default:\n return 'info';\n }\n}\n\nexport function formatJson(\n result: AnalysisResult,\n options: { escalated?: ReadonlySet<AnyRuleId>; baseline?: ReporterOptions['baseline'] } = {},\n): string {\n const escalated = options.escalated ?? EMPTY_RULES;\n return `${JSON.stringify(\n {\n version: 1,\n ok: result.ok && !ratchetFailed(options.baseline),\n strict: escalated.size > 0,\n // Always spreading would write `baseline: undefined`, which JSON.stringify\n // drops, so the test changes nothing but what the line says.\n ...(options.baseline === undefined ? {} : { baseline: options.baseline }),\n summary: result.summary,\n files: result.files,\n // The audit trail for what configuration silenced. Always present, unlike\n // the human report's --verbose gate: a machine reader that has to ask for\n // it twice will not ask. See ADR-0008.\n suppressed: result.corpus.suppressed.map((entry) => ({\n target: entry.target,\n from: entry.from,\n by: entry.by,\n file: entry.at.file,\n line: entry.at.span.start.line,\n })),\n diagnostics: result.diagnostics.map((diagnostic) => ({\n rule: diagnostic.rule,\n severity: diagnostic.severity,\n // True when this finding is only an error because of --strict.\n escalated: escalated.has(diagnostic.rule),\n message: diagnostic.message,\n hint: diagnostic.hint,\n nodes: diagnostic.nodes,\n target: diagnostic.target,\n file: diagnostic.at.file,\n line: diagnostic.at.span.start.line,\n column: diagnostic.at.span.start.column,\n endLine: diagnostic.at.span.end.line,\n endColumn: diagnostic.at.span.end.column,\n related: diagnostic.related.map((entry) => ({\n file: entry.at.file,\n line: entry.at.span.start.line,\n column: entry.at.span.start.column,\n note: entry.note,\n })),\n })),\n problems: result.problems.map((problem) => ({\n message: problem.message,\n file: problem.at.file,\n line: problem.at.span.start.line,\n })),\n },\n null,\n 2,\n )}\\n`;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Graph export */\n/* -------------------------------------------------------------------------- */\n\nexport type GraphFormat = 'dot' | 'mermaid' | 'json';\n\nexport interface GraphExportOptions {\n /** Leave out `contains` edges and item nodes. */\n readonly documentsOnly?: boolean | undefined;\n /**\n * What made the export, for the JSON form. Passed in rather than looked up,\n * because reading the package's own version is I/O and this module has none.\n * Two exports from different versions differ wherever extraction changed, and\n * `diff` warns about that only if it can see it (ADR-0020).\n */\n readonly generator?: { readonly name: string; readonly version: string } | undefined;\n}\n\n/** Serialises the graph for Graphviz, Mermaid, or a downstream tool. */\nexport function formatGraph(graph: SpecGraph, format: GraphFormat, options: GraphExportOptions = {}): string {\n const skipItems = options.documentsOnly ?? false;\n const nodes = [...graph.nodes.values()].filter((node) => !skipItems || node.kind === 'document');\n const visible = new Set(nodes.map((node) => node.id));\n\n // Hiding items must not hide what they say. An obligation delegated from an\n // item to a document is lifted onto the item's owner, so the document-level\n // view still shows the handover rather than silently losing it.\n const lifted = skipItems\n ? dedupeEdges(\n graph.edges\n // Containment of an *item* is what hiding items makes redundant.\n // Containment of a specification by the register that holds it is\n // structure between documents, and is what this view exists to show.\n //\n // An item is contained by its own document, so its containment would\n // lift onto that document and fall to the reflexive filter below\n // anyway: dropping this filter changes no export, and it stays to\n // say which containment the view keeps.\n .filter((edge) => edge.kind !== 'contains' || visible.has(edge.to))\n .map((edge) => {\n const from = graph.owningDocument(edge.from)?.id ?? edge.from;\n const to = graph.owningDocument(edge.to)?.id ?? edge.to;\n // An edge that did not move, rebuilt, is the same edge: its own\n // `reflexive` already says whether `from` is `to`.\n return from === edge.from && to === edge.to ? edge : { ...edge, from, to, reflexive: from === to };\n })\n .filter((edge) => !edge.reflexive),\n )\n : graph.edges;\n\n const edges = lifted.filter((edge) => visible.has(edge.from) && visible.has(edge.to));\n\n switch (format) {\n case 'dot':\n return toDot(nodes, edges);\n case 'mermaid':\n return toMermaid(nodes, edges);\n case 'json':\n return `${JSON.stringify(\n {\n version: 1,\n // `generator: undefined` is dropped by JSON.stringify, so the test\n // decides nothing the file shows.\n ...(options.generator !== undefined && { generator: options.generator }),\n nodes: nodes.map(serialiseNode),\n edges: edges.map((edge) => ({\n kind: edge.kind,\n from: edge.from,\n to: edge.to,\n origin: edge.origin,\n declaredIn: edge.declaredIn,\n file: edge.declaredAt.file,\n line: edge.declaredAt.span.start.line,\n })),\n },\n null,\n 2,\n )}\\n`;\n }\n}\n\n/** Collapses duplicate relations produced by lifting item edges onto documents. */\nfunction dedupeEdges(edges: readonly Edge[]): Edge[] {\n const seen = new Set<string>();\n // Anything here that is not an edge between drawn nodes is dropped by the\n // filter formatGraph applies next, so seeding this array changes no export.\n const out: Edge[] = [];\n for (const edge of edges) {\n const key = `${edge.kind} ${edge.from} ${edge.to}`;\n if (seen.has(key)) continue;\n seen.add(key);\n out.push(edge);\n }\n return out;\n}\n\nfunction serialiseNode(node: SpecNode): Record<string, unknown> {\n const base = {\n id: node.id,\n kind: node.kind,\n title: node.title,\n file: node.at.file,\n line: node.at.span.start.line,\n };\n return node.kind === 'document'\n ? { ...base, path: node.path, phase: node.phase, status: node.rawStatus, aliases: node.aliases }\n : {\n ...base,\n declared: node.declared,\n document: node.document,\n section: node.section,\n disposition: node.disposition,\n openness: node.openness,\n };\n}\n\n/** Phase colours, chosen to stay legible in both light and dark renderings. */\nconst PHASE_FILL: Readonly<Record<string, string>> = {\n draft: '#e8f0fe',\n active: '#e6f4ea',\n frozen: '#e8eaed',\n retired: '#fce8e6',\n record: '#f3e8fd',\n unknown: '#ffffff',\n};\n\nfunction toDot(nodes: readonly SpecNode[], edges: readonly Edge[]): string {\n const lines = ['digraph spec {', ' rankdir=LR;', ' node [shape=box, style=\"rounded,filled\", fontname=\"sans\"];'];\n for (const node of nodes) {\n // Every phase has a fill, `unknown` included, so the fallback is for a\n // phase added to the lattice before it is given a colour, and no graph\n // today reaches it.\n const fill = node.kind === 'document' ? (PHASE_FILL[node.phase] ?? '#ffffff') : '#fffbe6';\n const label = node.kind === 'document' ? `${node.id}\\\\n${escapeDot(node.title)}` : escapeDot(node.text);\n const shape = node.kind === 'document' ? 'box' : 'note';\n lines.push(` \"${escapeDot(node.id)}\" [label=\"${label}\", fillcolor=\"${fill}\", shape=${shape}];`);\n }\n for (const edge of edges) {\n const style = edge.kind === 'contains' ? ', style=dotted' : '';\n lines.push(` \"${escapeDot(edge.from)}\" -> \"${escapeDot(edge.to)}\" [label=\"${edge.kind}\"${style}];`);\n }\n lines.push('}');\n return `${lines.join('\\n')}\\n`;\n}\n\nfunction toMermaid(nodes: readonly SpecNode[], edges: readonly Edge[]): string {\n const lines = ['graph LR'];\n const alias = new Map<string, string>();\n nodes.forEach((node, position) => alias.set(node.id, `n${position}`));\n\n for (const node of nodes) {\n const key = alias.get(node.id) as string;\n const label = escapeMermaid(node.kind === 'document' ? node.id : node.text);\n lines.push(node.kind === 'document' ? ` ${key}[\"${label}\"]` : ` ${key}([\"${label}\"])`);\n if (node.kind === 'document' && node.phase !== 'unknown') lines.push(` class ${key} ${node.phase};`);\n }\n // formatGraph hands over only edges between the nodes being drawn, and every\n // one of those has an alias.\n for (const edge of edges) {\n lines.push(` ${alias.get(edge.from) as string} -->|${edge.kind}| ${alias.get(edge.to) as string}`);\n }\n for (const [phase, fill] of Object.entries(PHASE_FILL)) {\n if (phase === 'unknown') continue;\n lines.push(` classDef ${phase} fill:${fill},stroke:#5f6368;`);\n }\n return `${lines.join('\\n')}\\n`;\n}\n\nfunction escapeDot(value: string): string {\n return value.replace(/[\"\\\\]/g, '\\\\$&').replace(/\\n/g, '\\\\n');\n}\n\nfunction escapeMermaid(value: string): string {\n return value.replace(/[\"#]/g, ' ').replace(/\\s+/g, ' ').trim();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAmB,MAAM,eAAe,CAAC;AAG/D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AA2EhE,oFAAoF;AACpF,MAAM,UAAU,cAAc,CAAC,WAAW,GAAqB,EAAE;IAC/D,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IAC3C,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,SAAS,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IAC1E,2EAA2E;IAC3E,sEAAsE;IACtE,IAAI,GAAG,CAAC,aAAa,CAAC,KAAK,GAAG;QAAE,OAAO,KAAK,CAAC;IAC7C,IAAI,GAAG,CAAC,aAAa,CAAC,KAAK,SAAS,IAAI,GAAG,CAAC,aAAa,CAAC,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAC/E,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IACzC,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IAC9D,OAAO,WAAW,CAAC,KAAK,KAAK,IAAI,CAAC;AACpC,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,cAAc,CAAC,WAAW,GAAqB,EAAE;IAC/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al the report leads with the file\n * and line so an editor can jump there, indents the supporting evidence, and\n * ends with a concrete next action - because a finding a reader cannot act on\n * is a finding they will learn to scroll past. In CI it emits JSON with every\n * position intact, so a bot can annotate a diff.\n *\n * Colour is opt-out and auto-detected, and the glyphs degrade to ASCII when the\n * terminal cannot render them.\n */\n\nimport { createHash } from 'node:crypto';\n\nimport { fingerprintOf, type StaleEntry } from './baseline.js';\nimport type { SpecGraph } from './graph.js';\nimport type { ProjectRule } from './project-rules.js';\nimport { formatRef } from './source.js';\nimport { DEFAULT_SEVERITIES, RULE_DESCRIPTIONS, RULE_IDS } from './rules.js';\nimport { displayWidth } from './vendor/spec-core/text/index.js';\nimport type { AnalysisResult } from './runner.js';\nimport type {\n AnyRuleId,\n Diagnostic,\n Edge,\n RuleId,\n Severity,\n SourceRef,\n SpecNode,\n SuppressedRef,\n} from './types.js';\n\nexport interface ReporterOptions {\n readonly color?: boolean | undefined;\n readonly ascii?: boolean | undefined;\n readonly verbose?: boolean | undefined;\n /** Stop after this many findings. `0` means no limit. */\n readonly max?: number | undefined;\n /**\n * Rules whose severity `--strict` raised.\n *\n * A finding that only became an error because of a flag has to say so, or the\n * reader cannot tell what would happen without it.\n */\n readonly escalated?: ReadonlySet<AnyRuleId> | undefined;\n /**\n * What a baseline accounted for on this run.\n *\n * Reported as counts rather than as a list: the point of accepted debt is\n * that nobody has to read it every time. `stale` is the ratchet - debt the\n * run did not spend and which can be struck from the file - and `ratchet`\n * says whether this run was asked to fail over it.\n *\n * `entries` carries the stale ones themselves, for the structured formats. A\n * number is enough to know the file has slack and never enough to strike it,\n * and a bot that wants to open the pull request needs the rows.\n */\n readonly baseline?:\n | {\n readonly source: string;\n readonly suppressed: number;\n readonly stale: number;\n readonly ratchet?: boolean | undefined;\n readonly entries?: readonly StaleEntry[] | undefined;\n }\n | undefined;\n /**\n * The baseline's path as it is typed where the run was started, for the\n * command that re-records it; `baseline.source` when unset. The source reads\n * from the root, and typed in a directory below it, it names another file.\n * Beside the baseline rather than in it, because the JSON report writes the\n * baseline whole.\n */\n readonly recordAs?: string | undefined;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Environment detection */\n/* -------------------------------------------------------------------------- */\n\nexport interface ColorEnvironment {\n readonly isTTY?: boolean | undefined;\n readonly env?: Readonly<Record<string, string | undefined>> | undefined;\n /**\n * Host platform, defaulting to the real one.\n *\n * Injected for the same reason `env` is: without it half of\n * {@link shouldUseAscii} is unreachable from a test, and a rule about\n * Windows consoles that only Windows can exercise is a rule that breaks on\n * Windows and nowhere else.\n */\n readonly platform?: NodeJS.Platform | undefined;\n}\n\n/** Honours `NO_COLOR`, `FORCE_COLOR` and `TERM=dumb` before falling back to TTY. */\nexport function shouldUseColor(environment: ColorEnvironment = {}): boolean {\n const env = environment.env ?? process.env;\n if (env['NO_COLOR'] !== undefined && env['NO_COLOR'] !== '') return false;\n // `FORCE_COLOR=0` is the conventional way to turn colour off, so it has to\n // win over an attached TTY rather than merely failing to force it on.\n if (env['FORCE_COLOR'] === '0') return false;\n if (env['FORCE_COLOR'] !== undefined && env['FORCE_COLOR'] !== '') return true;\n if (env['TERM'] === 'dumb') return false;\n if (env['CI'] !== undefined && env['CI'] !== '') return false;\n return environment.isTTY === true;\n}\n\n/** True when the terminal is unlikely to render box-drawing and arrows. */\nexport function shouldUseAscii(environment: ColorEnvironment = {}): boolean {\n const env = environment.env ?? process.env;\n if (env['SPEC_GRAPH_ASCII'] !== undefined && env['SPEC_GRAPH_ASCII'] !== '') return true;\n if ((environment.platform ?? process.platform) !== 'win32') return false;\n // Windows Terminal and modern shells set these; the legacy console does not.\n return env['WT_SESSION'] === undefined && env['TERM_PROGRAM'] === undefined;\n}\n\nconst EMPTY_RULES: ReadonlySet<RuleId> = new Set<RuleId>();\n\ntype Paint = (text: string) => string;\n\nexport interface Painter {\n readonly error: Paint;\n readonly warn: Paint;\n readonly info: Paint;\n readonly dim: Paint;\n readonly bold: Paint;\n readonly hint: Paint;\n readonly location: Paint;\n}\n\nexport function createPainter(color: boolean): Painter {\n const wrap = (open: string): Paint => (text) => (color ? `\\u001b[${open}m${text}\\u001b[0m` : text);\n return {\n error: wrap('31'),\n warn: wrap('33'),\n info: wrap('36'),\n dim: wrap('2'),\n bold: wrap('1'),\n hint: wrap('32'),\n location: wrap('4'),\n };\n}\n\ninterface Glyphs {\n readonly error: string;\n readonly warn: string;\n readonly info: string;\n readonly related: string;\n readonly hint: string;\n readonly separator: string;\n}\n\nfunction glyphs(ascii: boolean): Glyphs {\n return ascii\n ? { error: 'x', warn: '!', info: 'i', related: '|', hint: '>', separator: '-' }\n : { error: '\\u2716', warn: '\\u26a0', info: '\\u2139', related: '\\u21b3', hint: '\\u2192', separator: '\\u00b7' };\n}\n\n/* -------------------------------------------------------------------------- */\n/* Human report */\n/* -------------------------------------------------------------------------- */\n\n/** Renders the full terminal report. */\nexport function formatReport(result: AnalysisResult, options: ReporterOptions = {}): string {\n const paint = createPainter(options.color ?? false);\n const marks = glyphs(options.ascii ?? false);\n const lines: string[] = [];\n const { summary } = result;\n\n lines.push(\n `${paint.bold('spec-graph')} ${paint.dim(\n [\n `${summary.documents} ${plural(summary.documents, 'document')}`,\n `${summary.items} ${plural(summary.items, 'item')}`,\n `${summary.edges} ${plural(summary.edges, 'relation')}`,\n `${summary.openObligations} open`,\n ].join(` ${marks.separator} `),\n )}`,\n );\n lines.push('');\n\n // Zero is falsy and never reaches the comparison, so `> 0` and `>= 0` are\n // the same test here.\n const limit = options.max && options.max > 0 ? options.max : result.diagnostics.length;\n const shown = result.diagnostics.slice(0, limit);\n\n const escalated = options.escalated ?? EMPTY_RULES;\n for (const diagnostic of shown) {\n lines.push(...formatDiagnostic(diagnostic, paint, marks, escalated));\n lines.push('');\n }\n\n if (result.diagnostics.length > shown.length) {\n lines.push(paint.dim(` ... and ${result.diagnostics.length - shown.length} more`));\n lines.push('');\n }\n\n if (options.verbose && result.problems.length > 0) {\n for (const problem of result.problems) {\n lines.push(`${paint.warn(marks.warn)} ${paint.location(formatRef(problem.at))} ${problem.message}`);\n }\n lines.push('');\n }\n\n const unread = options.verbose ? 0 : unreadFrontMatter(result);\n if (unread > 0) {\n lines.push(`${paint.warn(marks.warn)} ${unreadNotice(unread)}`, '');\n }\n\n // What the repository told spec-graph to stop looking at. Only under\n // --verbose, and never as a finding: these are not defects, they are the one\n // place a configuration can make the check quieter, and a single over-broad\n // glob looks exactly like a clean repository from the outside. See ADR-0008.\n if (options.verbose && result.corpus.suppressed.length > 0) {\n for (const [target, entry] of groupSuppressed(result.corpus.suppressed)) {\n const where = entry.by === 'family' ? 'ignored family' : 'ignored reference';\n const times = entry.count === 1 ? '' : ` (${entry.count} times)`;\n lines.push(`${paint.dim(marks.info)} ${paint.location(formatRef(entry.at))} ${paint.dim(`${where}: ${target}${times}`)}`);\n }\n lines.push('');\n }\n\n const tally: string[] = [];\n if (summary.errors > 0) tally.push(paint.error(`${summary.errors} ${plural(summary.errors, 'error')}`));\n if (summary.warnings > 0) tally.push(paint.warn(`${summary.warnings} ${plural(summary.warnings, 'warning')}`));\n if (summary.infos > 0) tally.push(paint.info(`${summary.infos} ${plural(summary.infos, 'note')}`));\n tally.push(paint.dim(`${summary.durationMs}ms`));\n const raised = result.diagnostics.filter((diagnostic) => escalated.has(diagnostic.rule)).length;\n if (raised > 0) {\n tally.push(paint.warn(`${raised} raised by --strict`));\n }\n const baseline = options.baseline;\n if (baseline !== undefined && baseline.suppressed > 0) {\n tally.push(paint.dim(`${baseline.suppressed} accepted by ${baseline.source}`));\n }\n lines.push(tally.join(` ${marks.separator} `));\n\n // Under `--ratchet` a paid entry is a failure rather than a note, so it is\n // painted and worded as one.\n const ratcheted = ratchetFailed(baseline);\n if (baseline !== undefined && baseline.stale > 0) {\n // A \"gone\" entry is not the ratchet working, and saying so matters more\n // than the count does: the usual way to produce one is to narrow an include\n // pattern, which loses sight of a defect rather than fixing it.\n //\n // The fallback is only ever filtered for gone entries, so filling it with\n // anything that is not one counts the same zero.\n const gone = (baseline.entries ?? []).filter((entry) => entry.reason === 'gone').length;\n const because =\n gone === 0\n ? `tighten it: spec-graph check --record-baseline ${options.recordAs ?? baseline.source}`\n : `${gone} of them ${gone === 1 ? 'names a document' : 'name documents'} this run did not see - check the include patterns before re-recording`;\n const text = `${baseline.stale} baseline ${plural(baseline.stale, 'entry', 'entries')} no longer ${\n baseline.stale === 1 ? 'occurs' : 'occur'\n } - ${because}`;\n lines.push(ratcheted ? `${paint.error(marks.error)} ${text}` : paint.dim(text));\n }\n\n // `ok` means no errors, so where it is true the sum below is the warnings\n // alone and `-` in place of `+` asks the same question.\n lines.push(\n ratcheted\n ? `${paint.error(marks.error)} ${\n result.ok ? 'the baseline is looser than the repository' : 'the specification graph is inconsistent'\n }`\n : result.ok\n ? `${paint.hint(marks.hint === '>' ? 'ok' : '\\u2714')} ${\n summary.errors + summary.warnings === 0\n ? 'the specification graph is consistent'\n : 'no errors - the specification graph holds'\n }`\n : `${paint.error(marks.error)} the specification graph is inconsistent`,\n );\n\n return lines.join('\\n');\n}\n\nfunction formatDiagnostic(\n diagnostic: Diagnostic,\n paint: Painter,\n marks: Glyphs,\n escalated: ReadonlySet<AnyRuleId>,\n): string[] {\n const mark = severityMark(diagnostic.severity, paint, marks);\n const label = escalated.has(diagnostic.rule)\n ? `${diagnostic.rule} ${paint.warn('(strict: warn -> error)')}`\n : diagnostic.rule;\n const lines: string[] = [\n `${mark} ${paint.location(formatRef(diagnostic.at))} ${paint.dim(label)}`,\n ` ${diagnostic.message}`,\n ];\n\n // Padded to the columns a terminal draws, not to UTF-16 units: `docs/決策.md`\n // is ten units and twelve columns, so `.padEnd` left the notes beside it two\n // columns out of line.\n const width = Math.max(0, ...diagnostic.related.map((entry) => displayWidth(formatRef(entry.at))));\n for (const entry of diagnostic.related) {\n const reference = formatRef(entry.at);\n const padded = `${reference}${' '.repeat(width - displayWidth(reference))}`;\n lines.push(` ${paint.dim(marks.related)} ${paint.dim(padded)} ${paint.dim(entry.note)}`);\n }\n\n lines.push(` ${paint.hint(marks.hint)} ${paint.hint(diagnostic.hint)}`);\n return lines;\n}\n\nfunction severityMark(severity: Exclude<Severity, 'off'>, paint: Painter, marks: Glyphs): string {\n switch (severity) {\n case 'error':\n return paint.error(marks.error);\n case 'warn':\n return paint.warn(marks.warn);\n case 'info':\n return paint.info(marks.info);\n }\n}\n\nfunction plural(count: number, word: string, plural?: string): string {\n if (count === 1) return word;\n return plural ?? `${word}s`;\n}\n\n/**\n * How many front-matter values the graph is built from went unread.\n *\n * Parse problems are listed only under `--verbose`, and most of them can wait\n * there. These cannot: `status: Superseded by ADR-3: see notes` is not read,\n * the document reads as unknown, and a failing check reports that the graph is\n * consistent. So a default run says how many there are, and where to look.\n */\nfunction unreadFrontMatter(result: AnalysisResult): number {\n return result.problems.filter((problem) => problem.unread === true).length;\n}\n\nfunction unreadNotice(count: number): string {\n return `${count} front-matter ${plural(count, 'value')} not read - see --verbose`;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Markdown */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The same report as GitHub-flavoured Markdown.\n *\n * SARIF puts a finding on the line that caused it, which is where somebody\n * fixing one wants it. It says nothing to the person deciding whether to merge,\n * because a code-scanning alert is a list of lines and not a verdict. This is\n * the verdict: one table, the counts above it, and the baseline's slack\n * underneath, sized to be read without scrolling.\n *\n * Written for `$GITHUB_STEP_SUMMARY` and for a pull-request comment, but it is\n * named for what it is rather than for where it goes - the same text is what a\n * review tool, a chat message or a generated page wants.\n *\n * It carries no duration, which the JSON report does, so two runs over one\n * corpus produce identical bytes. That is what lets a test compare a run from\n * a subdirectory against a run from the root and assert they are the same\n * report rather than the same shape. See ADR-0015 and ADR-0018.\n */\nexport function formatMarkdown(result: AnalysisResult, options: ReporterOptions = {}): string {\n const { summary } = result;\n const escalated = options.escalated ?? EMPTY_RULES;\n const ratcheted = ratchetFailed(options.baseline);\n const lines: string[] = ['### spec-graph', ''];\n\n // `ok` means no errors, as in the terminal's verdict, so `-` in place of `+`\n // below asks the same question.\n const verdict =\n ratcheted && result.ok\n ? 'The baseline is looser than the repository.'\n : result.ok\n ? summary.errors + summary.warnings === 0\n ? 'The specification graph is consistent.'\n : 'No errors - the specification graph holds.'\n : 'The specification graph is inconsistent.';\n lines.push(verdict, '');\n\n lines.push('| | |', '| --- | ---: |');\n lines.push(`| Documents | ${summary.documents} |`);\n lines.push(`| Items | ${summary.items} |`);\n lines.push(`| Relations | ${summary.edges} |`);\n lines.push(`| Open obligations | ${summary.openObligations} |`);\n lines.push(`| Errors | ${summary.errors} |`);\n lines.push(`| Warnings | ${summary.warnings} |`);\n lines.push(`| Notes | ${summary.infos} |`);\n lines.push('');\n\n // Zero never reaches the comparison, as in the terminal report.\n const limit = options.max && options.max > 0 ? options.max : result.diagnostics.length;\n const shown = result.diagnostics.slice(0, limit);\n\n if (shown.length > 0) {\n lines.push('| | Rule | Where | Finding |', '| --- | --- | --- | --- |');\n for (const diagnostic of shown) {\n const rule = escalated.has(diagnostic.rule) ? `${diagnostic.rule} (strict)` : diagnostic.rule;\n // The hint in the same cell, under the message. A finding without its\n // next action is the half a reader cannot act on, and a fifth column\n // would push the message off the side of the page.\n const what = `${cell(diagnostic.message)}<br>${cell(diagnostic.hint)}`;\n lines.push(`| ${diagnostic.severity} | \\`${cell(rule)}\\` | \\`${cell(formatRef(diagnostic.at))}\\` | ${what} |`);\n }\n if (result.diagnostics.length > shown.length) {\n lines.push(`| | | | ... and ${result.diagnostics.length - shown.length} more |`);\n }\n lines.push('');\n }\n\n const baseline = options.baseline;\n if (baseline !== undefined) {\n const accepted = `${baseline.suppressed} ${plural(baseline.suppressed, 'finding')} accepted by \\`${cell(baseline.source)}\\``;\n if (baseline.stale === 0) {\n lines.push(accepted, '');\n } else {\n // The fallback is only filtered for gone entries, as in the terminal report.\n const gone = (baseline.entries ?? []).filter((entry) => entry.reason === 'gone').length;\n lines.push(\n `${accepted}, and ${baseline.stale} ${plural(baseline.stale, 'entry', 'entries')} no longer ${\n baseline.stale === 1 ? 'occurs' : 'occur'\n }${\n gone === 0\n ? ''\n : ` - ${gone} of them ${gone === 1 ? 'names a document' : 'name documents'} this run did not see`\n }.`,\n '',\n );\n // Listed rather than counted, because the point of a summary on a pull\n // request is that somebody can act on it without opening a terminal.\n lines.push('| Entry | Rule | Document | Why |', '| --- | --- | --- | --- |');\n for (const entry of baseline.entries ?? []) {\n const why = entry.reason === 'gone' ? 'not in this corpus - check the include patterns' : 'fixed';\n lines.push(`| ${entry.reason} | \\`${cell(entry.rule)}\\` | \\`${cell(entry.document)}\\` | ${why} |`);\n }\n lines.push('');\n }\n }\n\n const unread = options.verbose ? 0 : unreadFrontMatter(result);\n if (unread > 0) lines.push(`${unreadNotice(unread)}.`, '');\n\n if (options.verbose && result.problems.length > 0) {\n lines.push('<details><summary>Problems with the input</summary>', '');\n for (const problem of result.problems) {\n lines.push(`- \\`${cell(formatRef(problem.at))}\\` ${cell(problem.message)}`);\n }\n lines.push('', '</details>', '');\n }\n\n if (options.verbose && result.corpus.suppressed.length > 0) {\n lines.push('<details><summary>References this configuration silenced</summary>', '');\n for (const [target, entry] of groupSuppressed(result.corpus.suppressed)) {\n const where = entry.by === 'family' ? 'ignored family' : 'ignored reference';\n const times = entry.count === 1 ? '' : ` (${entry.count} times)`;\n lines.push(`- \\`${cell(target)}\\` - ${where}${times}, first at \\`${cell(formatRef(entry.at))}\\``);\n }\n lines.push('', '</details>', '');\n }\n\n // Every block above ends in exactly one blank line, so there is only ever one\n // trailing newline for this to strip, and `\\n$` would strip the same.\n return `${lines.join('\\n').replace(/\\n+$/, '')}\\n`;\n}\n\n/**\n * Makes one value safe to put in a table cell.\n *\n * A pipe would end the cell and a newline would end the row, and a diagnostic\n * message is written by whoever wrote the rule - including a project rule,\n * whose message is a template a repository controls.\n */\nfunction cell(value: string): string {\n return value.replace(/[|]/g, '|').replace(/\\s+/g, ' ').trim();\n}\n\n/* -------------------------------------------------------------------------- */\n/* JSON */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The machine-readable report.\n *\n * Deliberately flat and versioned: this is the contract a CI annotator or a\n * dashboard builds against, and it must be safe to add fields to it later.\n */\n/**\n * One row per silenced target, with the first place it was written.\n *\n * Grouped because a concept tag used forty times is one decision, and forty\n * lines of it would bury the one entry somebody needs to see. Insertion order\n * is document order, which is already deterministic.\n */\nfunction groupSuppressed(\n suppressed: readonly SuppressedRef[],\n): Map<string, { at: SourceRef; by: SuppressedRef['by']; count: number }> {\n const out = new Map<string, { at: SourceRef; by: SuppressedRef['by']; count: number }>();\n for (const entry of suppressed) {\n const seen = out.get(entry.target);\n if (seen === undefined) out.set(entry.target, { at: entry.at, by: entry.by, count: 1 });\n else seen.count += 1;\n }\n return out;\n}\n\n/**\n * True when a baseline was asked to ratchet and has slack left in it.\n *\n * Both reporters ask, because both have to agree with the exit code: a report\n * that prints \"ok\" above a failing build is worse than no report.\n */\nfunction ratchetFailed(baseline: ReporterOptions['baseline']): boolean {\n return baseline !== undefined && baseline.ratchet === true && baseline.stale > 0;\n}\n\n/* -------------------------------------------------------------------------- */\n/* SARIF */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The static-analysis interchange format, for the tools that already read it.\n *\n * The reason to emit it is not the format, it is what consumes the format:\n * GitHub code scanning turns a SARIF upload into annotations on the diff, and\n * an editor turns it into the problems pane, neither of which needs a line of\n * spec-graph-specific integration.\n *\n * One field earns the whole exercise. `partialFingerprints` is how a consumer\n * tracks a finding across commits without keying on a line number, and\n * spec-graph already has exactly that identifier for exactly that reason - the\n * `rule/document/subject` triple a baseline is keyed on (ADR-0012). The two\n * problems turned out to be the same problem, so the answer is the same answer.\n *\n * Deterministic and timestamp-free, like every other output here. Nothing about\n * a run that has the same findings should produce a different file.\n */\nexport function formatSarif(\n result: AnalysisResult,\n graph: SpecGraph,\n options: {\n version?: string | undefined;\n escalated?: ReadonlySet<AnyRuleId> | undefined;\n projectRules?: readonly ProjectRule[] | undefined;\n } = {},\n): string {\n const escalated = options.escalated ?? EMPTY_RULES;\n // A project rule describes itself by the selector it is, because that is the\n // only honest answer: its message is a template, and a template with `{0}` in\n // it is not a description of anything. See ADR-0016.\n const known: [AnyRuleId, string, Severity][] = [\n ...RULE_IDS.map((id): [AnyRuleId, string, Severity] => [id, RULE_DESCRIPTIONS[id], DEFAULT_SEVERITIES[id]]),\n ...(options.projectRules ?? []).map((rule): [AnyRuleId, string, Severity] => [\n rule.id,\n rule.sources.join(' | '),\n rule.severity,\n ]),\n ];\n const fired = known.filter(([id]) => result.diagnostics.some((diagnostic) => diagnostic.rule === id));\n return `${JSON.stringify(\n {\n $schema: 'https://json.schemastore.org/sarif-2.1.0.json',\n version: '2.1.0',\n runs: [\n {\n tool: {\n driver: {\n name: 'spec-graph',\n informationUri: 'https://github.com/DescentVTT/spec-graph',\n // JSON.stringify drops a key whose value is undefined, so always\n // spreading the pair writes the same file; the test is for the reader.\n ...(options.version === undefined ? {} : { version: options.version, semanticVersion: options.version }),\n // Only the rules that fired. A driver listing all of them\n // describes the tool; this file describes the run.\n rules: fired.map(([id, description, level]) => ({\n id,\n shortDescription: { text: description },\n defaultConfiguration: { level: sarifLevel(level) },\n })),\n },\n },\n results: result.diagnostics.map((diagnostic) => {\n const print = fingerprintOf(graph, diagnostic);\n return {\n ruleId: diagnostic.rule,\n level: sarifLevel(diagnostic.severity),\n message: { text: `${diagnostic.message}. ${diagnostic.hint}` },\n locations: [sarifLocation(diagnostic.at)],\n ...(diagnostic.related.length === 0\n ? {}\n : {\n relatedLocations: diagnostic.related.map((entry) => ({\n ...sarifLocation(entry.at),\n message: { text: entry.note },\n })),\n }),\n partialFingerprints: {\n specGraphIdentity: `${diagnostic.rule}/${print.document}/${print.subject}`,\n },\n properties: {\n nodes: diagnostic.nodes,\n target: diagnostic.target,\n // A finding that is only an error because of a flag says so\n // here too, so a reviewer reading an annotation is not misled.\n escalated: escalated.has(diagnostic.rule),\n },\n };\n }),\n },\n ],\n },\n null,\n 2,\n )}\\n`;\n}\n\nfunction sarifLevel(severity: Severity): string {\n switch (severity) {\n case 'error':\n return 'error';\n case 'warn':\n return 'warning';\n case 'info':\n return 'note';\n default:\n return 'none';\n }\n}\n\nfunction sarifLocation(at: SourceRef): {\n physicalLocation: {\n artifactLocation: { uri: string };\n region: { startLine: number; startColumn: number; endLine: number; endColumn: number };\n };\n} {\n return {\n physicalLocation: {\n // Already repository-relative and POSIX, which is what SARIF asks for.\n artifactLocation: { uri: at.file },\n region: {\n startLine: at.span.start.line,\n startColumn: at.span.start.column,\n endLine: at.span.end.line,\n endColumn: at.span.end.column,\n },\n },\n };\n}\n\n/* -------------------------------------------------------------------------- */\n/* GitLab Code Quality */\n/* -------------------------------------------------------------------------- */\n\ntype GitlabSeverity = 'critical' | 'major' | 'minor' | 'info';\n\n/**\n * GitLab's Code Quality report, which a merge request reads to show the\n * findings a change introduced and the ones it resolved - what SARIF is to\n * GitHub, so the family is not GitHub's alone.\n *\n * The format is GitLab's and carries no version of its own: a JSON array with\n * the five fields GitLab reads and nothing else.\n *\n * `fingerprint` is how GitLab matches a finding in the merge request to the\n * same finding on the target branch, so it holds what the finding is about and\n * nothing that moves when something else changes: the rule, the specification\n * and what within it, hashed - the identity a baseline counts by. Not the line,\n * so a paragraph moved above a finding does not make it new. Not the message,\n * which carries counts: ticking one of three boxes turned \"holds 3 open\n * obligations\" into \"holds 2\", and GitLab showed one finding resolved and one\n * introduced. Two findings that agree on all three - one broken link written\n * twice in a document - are told apart by their order, the second hashed with a\n * `2`: GitLab tells issues apart by fingerprint, and two that shared one would\n * be read as one.\n */\nexport function formatGitlab(\n result: AnalysisResult,\n options: { escalated?: ReadonlySet<AnyRuleId> | undefined } = {},\n): string {\n const escalated = options.escalated ?? EMPTY_RULES;\n const occurrences = new Map<string, number>();\n const issues = result.diagnostics.map((diagnostic) => {\n const { document, subject } = fingerprintOf(result.graph, diagnostic);\n const identity = [diagnostic.rule, document, subject];\n const key = JSON.stringify(identity);\n const occurrence = (occurrences.get(key) ?? 0) + 1;\n occurrences.set(key, occurrence);\n return {\n description: `${diagnostic.message}. ${diagnostic.hint}`,\n check_name: diagnostic.rule,\n fingerprint: createHash('sha256')\n .update(occurrence === 1 ? key : JSON.stringify([...identity, occurrence]))\n .digest('hex'),\n severity: gitlabSeverity(diagnostic.severity, escalated.has(diagnostic.rule)),\n location: { path: diagnostic.at.file, lines: { begin: diagnostic.at.span.start.line } },\n };\n });\n return `${JSON.stringify(issues, null, 2)}\\n`;\n}\n\n/**\n * spec-graph's three severities on GitLab's five. An error is critical: it\n * fails the build. One that is only an error because `--strict` raised it is\n * major, which is the one place the report can say so. A warning is minor,\n * and a note is information. `blocker` is left to tools that know more about\n * what cannot ship than a documentation linter does.\n */\nfunction gitlabSeverity(severity: Severity, escalated: boolean): GitlabSeverity {\n switch (severity) {\n case 'error':\n return escalated ? 'major' : 'critical';\n case 'warn':\n return 'minor';\n default:\n return 'info';\n }\n}\n\n/* -------------------------------------------------------------------------- */\n/* GitHub workflow commands */\n/* -------------------------------------------------------------------------- */\n\n/** A workflow command's message: `%`, and the line breaks that would end the command. */\nfunction escapeData(text: string): string {\n return text.replace(/%/g, '%25').replace(/\\r/g, '%0D').replace(/\\n/g, '%0A');\n}\n\n/** A workflow command's property: as a message, and the `:` and `,` that would end the property. */\nfunction escapeProperty(text: string): string {\n return escapeData(text).replace(/:/g, '%3A').replace(/,/g, '%2C');\n}\n\n/**\n * Findings as GitHub Actions workflow commands, one line each, which a job's\n * log turns into annotations on the pull request's diff with no upload step -\n * what SARIF does through code scanning, for a repository that has none.\n *\n * An error is `error`, a warning `warning` and a note `notice`, as spec-guard\n * writes them. The rule is the title, marked `(strict)` where only `--strict`\n * made it an error, as the Markdown report marks it; the message carries the\n * hint, since a finding without its next action is the half a reader cannot\n * act on. Nothing at all for a clean run.\n */\nexport function formatGithub(\n result: AnalysisResult,\n options: { escalated?: ReadonlySet<AnyRuleId> | undefined } = {},\n): string {\n const escalated = options.escalated ?? EMPTY_RULES;\n return result.diagnostics\n .map((diagnostic) => {\n const title = escalated.has(diagnostic.rule) ? `${diagnostic.rule} (strict)` : diagnostic.rule;\n const place = `file=${escapeProperty(diagnostic.at.file)},line=${diagnostic.at.span.start.line}`;\n return `::${githubLevel(diagnostic.severity)} ${place},title=${escapeProperty(title)}::${escapeData(\n `${diagnostic.message}. ${diagnostic.hint}`,\n )}\\n`;\n })\n .join('');\n}\n\nfunction githubLevel(severity: Severity): 'error' | 'warning' | 'notice' {\n switch (severity) {\n case 'error':\n return 'error';\n case 'warn':\n return 'warning';\n default:\n return 'notice';\n }\n}\n\nexport function formatJson(\n result: AnalysisResult,\n options: { escalated?: ReadonlySet<AnyRuleId>; baseline?: ReporterOptions['baseline'] } = {},\n): string {\n const escalated = options.escalated ?? EMPTY_RULES;\n return `${JSON.stringify(\n {\n version: 1,\n ok: result.ok && !ratchetFailed(options.baseline),\n strict: escalated.size > 0,\n // Always spreading would write `baseline: undefined`, which JSON.stringify\n // drops, so the test changes nothing but what the line says.\n ...(options.baseline === undefined ? {} : { baseline: options.baseline }),\n summary: result.summary,\n files: result.files,\n // The audit trail for what configuration silenced. Always present, unlike\n // the human report's --verbose gate: a machine reader that has to ask for\n // it twice will not ask. See ADR-0008.\n suppressed: result.corpus.suppressed.map((entry) => ({\n target: entry.target,\n from: entry.from,\n by: entry.by,\n file: entry.at.file,\n line: entry.at.span.start.line,\n })),\n diagnostics: result.diagnostics.map((diagnostic) => ({\n rule: diagnostic.rule,\n severity: diagnostic.severity,\n // True when this finding is only an error because of --strict.\n escalated: escalated.has(diagnostic.rule),\n message: diagnostic.message,\n hint: diagnostic.hint,\n nodes: diagnostic.nodes,\n target: diagnostic.target,\n file: diagnostic.at.file,\n line: diagnostic.at.span.start.line,\n column: diagnostic.at.span.start.column,\n endLine: diagnostic.at.span.end.line,\n endColumn: diagnostic.at.span.end.column,\n related: diagnostic.related.map((entry) => ({\n file: entry.at.file,\n line: entry.at.span.start.line,\n column: entry.at.span.start.column,\n note: entry.note,\n })),\n })),\n problems: result.problems.map((problem) => ({\n message: problem.message,\n file: problem.at.file,\n line: problem.at.span.start.line,\n })),\n },\n null,\n 2,\n )}\\n`;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Graph export */\n/* -------------------------------------------------------------------------- */\n\nexport type GraphFormat = 'dot' | 'mermaid' | 'json';\n\nexport interface GraphExportOptions {\n /** Leave out `contains` edges and item nodes. */\n readonly documentsOnly?: boolean | undefined;\n /**\n * What made the export, for the JSON form. Passed in rather than looked up,\n * because reading the package's own version is I/O and this module has none.\n * Two exports from different versions differ wherever extraction changed, and\n * `diff` warns about that only if it can see it (ADR-0020).\n */\n readonly generator?: { readonly name: string; readonly version: string } | undefined;\n}\n\n/** Serialises the graph for Graphviz, Mermaid, or a downstream tool. */\nexport function formatGraph(graph: SpecGraph, format: GraphFormat, options: GraphExportOptions = {}): string {\n const skipItems = options.documentsOnly ?? false;\n const nodes = [...graph.nodes.values()].filter((node) => !skipItems || node.kind === 'document');\n const visible = new Set(nodes.map((node) => node.id));\n\n // Hiding items must not hide what they say. An obligation delegated from an\n // item to a document is lifted onto the item's owner, so the document-level\n // view still shows the handover rather than silently losing it.\n const lifted = skipItems\n ? dedupeEdges(\n graph.edges\n // Containment of an *item* is what hiding items makes redundant.\n // Containment of a specification by the register that holds it is\n // structure between documents, and is what this view exists to show.\n //\n // An item is contained by its own document, so its containment would\n // lift onto that document and fall to the reflexive filter below\n // anyway: dropping this filter changes no export, and it stays to\n // say which containment the view keeps.\n .filter((edge) => edge.kind !== 'contains' || visible.has(edge.to))\n .map((edge) => {\n const from = graph.owningDocument(edge.from)?.id ?? edge.from;\n const to = graph.owningDocument(edge.to)?.id ?? edge.to;\n // An edge that did not move, rebuilt, is the same edge: its own\n // `reflexive` already says whether `from` is `to`.\n return from === edge.from && to === edge.to ? edge : { ...edge, from, to, reflexive: from === to };\n })\n .filter((edge) => !edge.reflexive),\n )\n : graph.edges;\n\n const edges = lifted.filter((edge) => visible.has(edge.from) && visible.has(edge.to));\n\n switch (format) {\n case 'dot':\n return toDot(nodes, edges);\n case 'mermaid':\n return toMermaid(nodes, edges);\n case 'json':\n return `${JSON.stringify(\n {\n version: 1,\n // `generator: undefined` is dropped by JSON.stringify, so the test\n // decides nothing the file shows.\n ...(options.generator !== undefined && { generator: options.generator }),\n nodes: nodes.map(serialiseNode),\n edges: edges.map((edge) => ({\n kind: edge.kind,\n from: edge.from,\n to: edge.to,\n origin: edge.origin,\n declaredIn: edge.declaredIn,\n file: edge.declaredAt.file,\n line: edge.declaredAt.span.start.line,\n })),\n },\n null,\n 2,\n )}\\n`;\n }\n}\n\n/** Collapses duplicate relations produced by lifting item edges onto documents. */\nfunction dedupeEdges(edges: readonly Edge[]): Edge[] {\n const seen = new Set<string>();\n // Anything here that is not an edge between drawn nodes is dropped by the\n // filter formatGraph applies next, so seeding this array changes no export.\n const out: Edge[] = [];\n for (const edge of edges) {\n const key = `${edge.kind} ${edge.from} ${edge.to}`;\n if (seen.has(key)) continue;\n seen.add(key);\n out.push(edge);\n }\n return out;\n}\n\nfunction serialiseNode(node: SpecNode): Record<string, unknown> {\n const base = {\n id: node.id,\n kind: node.kind,\n title: node.title,\n file: node.at.file,\n line: node.at.span.start.line,\n };\n return node.kind === 'document'\n ? { ...base, path: node.path, phase: node.phase, status: node.rawStatus, aliases: node.aliases }\n : {\n ...base,\n declared: node.declared,\n document: node.document,\n section: node.section,\n disposition: node.disposition,\n openness: node.openness,\n };\n}\n\n/** Phase colours, chosen to stay legible in both light and dark renderings. */\nconst PHASE_FILL: Readonly<Record<string, string>> = {\n draft: '#e8f0fe',\n active: '#e6f4ea',\n frozen: '#e8eaed',\n retired: '#fce8e6',\n record: '#f3e8fd',\n unknown: '#ffffff',\n};\n\nfunction toDot(nodes: readonly SpecNode[], edges: readonly Edge[]): string {\n const lines = ['digraph spec {', ' rankdir=LR;', ' node [shape=box, style=\"rounded,filled\", fontname=\"sans\"];'];\n for (const node of nodes) {\n // Every phase has a fill, `unknown` included, so the fallback is for a\n // phase added to the lattice before it is given a colour, and no graph\n // today reaches it.\n const fill = node.kind === 'document' ? (PHASE_FILL[node.phase] ?? '#ffffff') : '#fffbe6';\n const label = node.kind === 'document' ? `${node.id}\\\\n${escapeDot(node.title)}` : escapeDot(node.text);\n const shape = node.kind === 'document' ? 'box' : 'note';\n lines.push(` \"${escapeDot(node.id)}\" [label=\"${label}\", fillcolor=\"${fill}\", shape=${shape}];`);\n }\n for (const edge of edges) {\n const style = edge.kind === 'contains' ? ', style=dotted' : '';\n lines.push(` \"${escapeDot(edge.from)}\" -> \"${escapeDot(edge.to)}\" [label=\"${edge.kind}\"${style}];`);\n }\n lines.push('}');\n return `${lines.join('\\n')}\\n`;\n}\n\nfunction toMermaid(nodes: readonly SpecNode[], edges: readonly Edge[]): string {\n const lines = ['graph LR'];\n const alias = new Map<string, string>();\n nodes.forEach((node, position) => alias.set(node.id, `n${position}`));\n\n for (const node of nodes) {\n const key = alias.get(node.id) as string;\n const label = escapeMermaid(node.kind === 'document' ? node.id : node.text);\n lines.push(node.kind === 'document' ? ` ${key}[\"${label}\"]` : ` ${key}([\"${label}\"])`);\n if (node.kind === 'document' && node.phase !== 'unknown') lines.push(` class ${key} ${node.phase};`);\n }\n // formatGraph hands over only edges between the nodes being drawn, and every\n // one of those has an alias.\n for (const edge of edges) {\n lines.push(` ${alias.get(edge.from) as string} -->|${edge.kind}| ${alias.get(edge.to) as string}`);\n }\n for (const [phase, fill] of Object.entries(PHASE_FILL)) {\n if (phase === 'unknown') continue;\n lines.push(` classDef ${phase} fill:${fill},stroke:#5f6368;`);\n }\n return `${lines.join('\\n')}\\n`;\n}\n\nfunction escapeDot(value: string): string {\n return value.replace(/[\"\\\\]/g, '\\\\$&').replace(/\\n/g, '\\\\n');\n}\n\nfunction escapeMermaid(value: string): string {\n return value.replace(/[\"#]/g, ' ').replace(/\\s+/g, ' ').trim();\n}\n"]}
|
package/dist/sections.d.ts
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* neither declares a status.
|
|
22
22
|
*/
|
|
23
23
|
import { type Directive } from './directives.js';
|
|
24
|
-
import { type Heading, type Range, type ScannedDocument, type TableRow } from './markdown.js';
|
|
24
|
+
import { type Heading, type Range, type ScannedDocument, type Table, type TableRow } from './markdown.js';
|
|
25
25
|
import type { EdgeKind } from './types.js';
|
|
26
26
|
/** A status as written, and where it was written. */
|
|
27
27
|
export interface RegionStatus {
|
|
@@ -82,6 +82,12 @@ fileId: string): SpecificationRegion[];
|
|
|
82
82
|
* every row of it to a specification would invent a register nobody wrote.
|
|
83
83
|
*/
|
|
84
84
|
export declare function findTableRegions(scanned: ScannedDocument): SpecificationRegion[];
|
|
85
|
+
/**
|
|
86
|
+
* Whether spec-graph reads a table as a register: an identifier column, and a
|
|
87
|
+
* status column or a relation column beside it. Such a table's status column
|
|
88
|
+
* describes its rows, never the document holding it.
|
|
89
|
+
*/
|
|
90
|
+
export declare function isRegisterTable(table: Table): boolean;
|
|
85
91
|
/**
|
|
86
92
|
* Reads a status declared inside a region.
|
|
87
93
|
*
|
package/dist/sections.js
CHANGED
|
@@ -65,8 +65,8 @@ const MARKDOWN_LINK = /!?\[([^\]]*)\]\(([^)]*)\)/g;
|
|
|
65
65
|
const EMPTY_CELL = /^(?:-+|—|–|n\/?a|none|nil|tbd|\.|_+)$/i;
|
|
66
66
|
/** `## ADR-0007: Sharding` - an identifier at the very start of a heading. */
|
|
67
67
|
const HEADING_ID = /^\s*([A-Za-z]{1,15}[\s._-]?\d{1,6})\b/;
|
|
68
|
-
/** `**Status:** Accepted`, `Status: Accepted`, `*Status* : Accepted
|
|
69
|
-
const INLINE_STATUS = /^[ \t>]*[*_]{0,2}\s*status\s*[*_]{0,2}\s*[::]\s*(.+?)\s*$/im;
|
|
68
|
+
/** `**Status:** Accepted`, `Status: Accepted`, `*Status* : Accepted`, `**狀態:** 已接受`. */
|
|
69
|
+
const INLINE_STATUS = /^[ \t>]*[*_]{0,2}\s*(?:status|狀態|状态)\s*[*_]{0,2}\s*[::]\s*(.+?)\s*$/im;
|
|
70
70
|
/**
|
|
71
71
|
* Finds every specification in a file.
|
|
72
72
|
*
|
|
@@ -216,6 +216,14 @@ export function findTableRegions(scanned) {
|
|
|
216
216
|
}
|
|
217
217
|
return out;
|
|
218
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Whether spec-graph reads a table as a register: an identifier column, and a
|
|
221
|
+
* status column or a relation column beside it. Such a table's status column
|
|
222
|
+
* describes its rows, never the document holding it.
|
|
223
|
+
*/
|
|
224
|
+
export function isRegisterTable(table) {
|
|
225
|
+
return readSchema(table) !== null;
|
|
226
|
+
}
|
|
219
227
|
function readSchema(table) {
|
|
220
228
|
let id = null;
|
|
221
229
|
let status = null;
|