@descent-vtt/spec-brief 0.1.0 → 0.2.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.
Files changed (128) hide show
  1. package/CHANGELOG.md +264 -0
  2. package/README.md +90 -20
  3. package/dist/archive.d.ts +52 -2
  4. package/dist/archive.js +205 -37
  5. package/dist/archive.js.map +1 -1
  6. package/dist/brief.d.ts +2 -0
  7. package/dist/brief.js +5 -1
  8. package/dist/brief.js.map +1 -1
  9. package/dist/cli.d.ts +1 -1
  10. package/dist/cli.js +48 -14
  11. package/dist/cli.js.map +1 -1
  12. package/dist/collisions.d.ts +43 -12
  13. package/dist/collisions.js +90 -58
  14. package/dist/collisions.js.map +1 -1
  15. package/dist/config.d.ts +11 -0
  16. package/dist/config.js +58 -10
  17. package/dist/config.js.map +1 -1
  18. package/dist/corpus.d.ts +21 -1
  19. package/dist/corpus.js +51 -2
  20. package/dist/corpus.js.map +1 -1
  21. package/dist/engine.d.ts +33 -3
  22. package/dist/engine.js +112 -9
  23. package/dist/engine.js.map +1 -1
  24. package/dist/frontmatter.d.ts +18 -61
  25. package/dist/frontmatter.js +31 -300
  26. package/dist/frontmatter.js.map +1 -1
  27. package/dist/glob.d.ts +77 -54
  28. package/dist/glob.js +104 -433
  29. package/dist/glob.js.map +1 -1
  30. package/dist/index.d.ts +10 -8
  31. package/dist/index.js +8 -6
  32. package/dist/index.js.map +1 -1
  33. package/dist/links.d.ts +1 -1
  34. package/dist/links.js +3 -4
  35. package/dist/links.js.map +1 -1
  36. package/dist/lint.d.ts +33 -2
  37. package/dist/lint.js +9 -2
  38. package/dist/lint.js.map +1 -1
  39. package/dist/markdown.d.ts +26 -23
  40. package/dist/markdown.js +60 -237
  41. package/dist/markdown.js.map +1 -1
  42. package/dist/plugins.d.ts +14 -0
  43. package/dist/plugins.js +142 -6
  44. package/dist/plugins.js.map +1 -1
  45. package/dist/report.d.ts +40 -3
  46. package/dist/report.js +227 -11
  47. package/dist/report.js.map +1 -1
  48. package/dist/rules.d.ts +22 -4
  49. package/dist/rules.js +175 -45
  50. package/dist/rules.js.map +1 -1
  51. package/dist/scaffold.d.ts +1 -1
  52. package/dist/scaffold.js +10 -9
  53. package/dist/scaffold.js.map +1 -1
  54. package/dist/schedule.d.ts +133 -0
  55. package/dist/schedule.js +265 -0
  56. package/dist/schedule.js.map +1 -0
  57. package/dist/scope.d.ts +52 -0
  58. package/dist/scope.js +56 -0
  59. package/dist/scope.js.map +1 -0
  60. package/dist/text.d.ts +13 -0
  61. package/dist/text.js +23 -0
  62. package/dist/text.js.map +1 -1
  63. package/dist/trigger.d.ts +17 -0
  64. package/dist/trigger.js +49 -0
  65. package/dist/trigger.js.map +1 -0
  66. package/dist/types.d.ts +14 -5
  67. package/dist/types.js.map +1 -1
  68. package/dist/vendor/spec-core/markdown/frontmatter.d.ts +103 -0
  69. package/dist/vendor/spec-core/markdown/frontmatter.js +459 -0
  70. package/dist/vendor/spec-core/markdown/frontmatter.js.map +1 -0
  71. package/dist/vendor/spec-core/markdown/headings.d.ts +45 -0
  72. package/dist/vendor/spec-core/markdown/headings.js +199 -0
  73. package/dist/vendor/spec-core/markdown/headings.js.map +1 -0
  74. package/dist/vendor/spec-core/markdown/index.d.ts +5 -0
  75. package/dist/vendor/spec-core/markdown/index.js +4 -0
  76. package/dist/vendor/spec-core/markdown/index.js.map +1 -0
  77. package/dist/vendor/spec-core/markdown/layout.d.ts +39 -0
  78. package/dist/vendor/spec-core/markdown/layout.js +28 -0
  79. package/dist/vendor/spec-core/markdown/layout.js.map +1 -0
  80. package/dist/vendor/spec-core/markdown/links.d.ts +22 -0
  81. package/dist/vendor/spec-core/markdown/links.js +364 -0
  82. package/dist/vendor/spec-core/markdown/links.js.map +1 -0
  83. package/dist/vendor/spec-core/markdown/lists.d.ts +22 -0
  84. package/dist/vendor/spec-core/markdown/lists.js +127 -0
  85. package/dist/vendor/spec-core/markdown/lists.js.map +1 -0
  86. package/dist/vendor/spec-core/markdown/scan.d.ts +36 -0
  87. package/dist/vendor/spec-core/markdown/scan.js +439 -0
  88. package/dist/vendor/spec-core/markdown/scan.js.map +1 -0
  89. package/dist/vendor/spec-core/markdown/syntax.d.ts +75 -0
  90. package/dist/vendor/spec-core/markdown/syntax.js +181 -0
  91. package/dist/vendor/spec-core/markdown/syntax.js.map +1 -0
  92. package/dist/vendor/spec-core/markdown/tables.d.ts +18 -0
  93. package/dist/vendor/spec-core/markdown/tables.js +86 -0
  94. package/dist/vendor/spec-core/markdown/tables.js.map +1 -0
  95. package/dist/vendor/spec-core/markdown/types.d.ts +287 -0
  96. package/dist/vendor/spec-core/markdown/types.js +9 -0
  97. package/dist/vendor/spec-core/markdown/types.js.map +1 -0
  98. package/dist/vendor/spec-core/path/index.d.ts +1 -0
  99. package/dist/vendor/spec-core/path/index.js +2 -0
  100. package/dist/vendor/spec-core/path/index.js.map +1 -0
  101. package/dist/vendor/spec-core/path/posix.d.ts +83 -0
  102. package/dist/vendor/spec-core/path/posix.js +150 -0
  103. package/dist/vendor/spec-core/path/posix.js.map +1 -0
  104. package/dist/vendor/spec-core/pattern/automaton.d.ts +129 -0
  105. package/dist/vendor/spec-core/pattern/automaton.js +340 -0
  106. package/dist/vendor/spec-core/pattern/automaton.js.map +1 -0
  107. package/dist/vendor/spec-core/pattern/charset.d.ts +58 -0
  108. package/dist/vendor/spec-core/pattern/charset.js +116 -0
  109. package/dist/vendor/spec-core/pattern/charset.js.map +1 -0
  110. package/dist/vendor/spec-core/pattern/glob.d.ts +121 -0
  111. package/dist/vendor/spec-core/pattern/glob.js +481 -0
  112. package/dist/vendor/spec-core/pattern/glob.js.map +1 -0
  113. package/dist/vendor/spec-core/pattern/index.d.ts +6 -0
  114. package/dist/vendor/spec-core/pattern/index.js +4 -0
  115. package/dist/vendor/spec-core/pattern/index.js.map +1 -0
  116. package/dist/vendor/spec-core/pattern/regex.d.ts +67 -0
  117. package/dist/vendor/spec-core/pattern/regex.js +813 -0
  118. package/dist/vendor/spec-core/pattern/regex.js.map +1 -0
  119. package/dist/vendor/spec-core/text/index.d.ts +2 -0
  120. package/dist/vendor/spec-core/text/index.js +2 -0
  121. package/dist/vendor/spec-core/text/index.js.map +1 -0
  122. package/dist/vendor/spec-core/text/lines.d.ts +72 -0
  123. package/dist/vendor/spec-core/text/lines.js +156 -0
  124. package/dist/vendor/spec-core/text/lines.js.map +1 -0
  125. package/package.json +3 -2
  126. package/schema.json +17 -0
  127. package/src/vendor/spec-core/LICENSE +21 -0
  128. package/src/vendor/spec-core/README.md +8 -0
package/dist/brief.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"brief.js","sourceRoot":"","sources":["../src/brief.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAoC,MAAM,kBAAkB,CAAC;AACjH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAA0C,MAAM,eAAe,CAAC;AAClG,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGjD,MAAM,CAAC,MAAM,WAAW,GAAG,4BAA4B,CAAC;AACxD,MAAM,CAAC,MAAM,YAAY,GAAG,6BAA6B,CAAC;AAE1D,+EAA+E;AAC/E,MAAM,CAAC,MAAM,eAAe,GAAsB;IAChD,IAAI;IACJ,OAAO;IACP,MAAM;IACN,QAAQ;IACR,MAAM;IACN,MAAM;IACN,WAAW;IACX,eAAe;IACf,gBAAgB;IAChB,WAAW;CACZ,CAAC;AA0CF,SAAS,SAAS,CAAC,KAAgB;IACjC,IAAI,KAAK,CAAC,IAAI,KAAK,aAAa;QAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;IACnE,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,EAAE,OAAO,EAAE,oCAAoC,EAAE,CAAC;IACpF,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC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e,CAAC;QACpC,cAAc,EAAE,IAAI,CAAC,gBAAgB,CAAC;QACtC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC;QAC7B,MAAM;QACN,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,WAAW,CAAC,KAAY,EAAE,KAAa;IACrD,OAAO,SAAS,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE,IAAI,IAAI,CAAC,CAAC;AACxD,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,MAAM,KAAK,GAAG,CAAC,GAAG,eAAe,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACrD,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAClE,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AACrC,CAAC","sourcesContent":["/**\n * One brief, read: its identity, its front matter, its sections and its task\n * items. A pure function of a file's path and text.\n */\n\nimport type { Config } from './config.js';\nimport { findEntry, isNull, keyName, readFrontMatter, type FrontMatter, type YamlValue } from './frontmatter.js';\nimport { scan, sectionsOf, titleOf, type Scan, type Section, type TaskItem } from './markdown.js';\nimport { splitLines, stripBom } from './text.js';\nimport type { Phase, Status } from './types.js';\n\nexport const BANNER_OPEN = '<!-- spec-brief:banner -->';\nexport const BANNER_CLOSE = '<!-- /spec-brief:banner -->';\n\n/** Front-matter keys spec-brief itself reads, in the spelling it documents. */\nexport const BUILT_IN_FIELDS: readonly string[] = [\n 'id',\n 'title',\n 'type',\n 'status',\n 'date',\n 'wave',\n 'dependsOn',\n 'affectedFiles',\n 'protectedFiles',\n 'integrity',\n];\n\nexport interface FieldProblem {\n readonly field: string;\n /** 0-based line. */\n readonly line: number;\n readonly message: string;\n}\n\nexport interface Brief {\n /** `null` when no id can be read, which a rule reports. */\n readonly id: string | null;\n /** Repository-relative path. */\n readonly file: string;\n /** The file name. */\n readonly name: string;\n readonly phase: Phase;\n /** The file exactly as read, byte-order mark and line endings included. */\n readonly source: string;\n /** The text parsed: the source without a byte-order mark. */\n readonly text: string;\n readonly lines: readonly string[];\n readonly frontMatter: FrontMatter | null;\n /** 0-based first line after the front matter. */\n readonly bodyStart: number;\n readonly scan: Scan;\n readonly sections: readonly Section[];\n readonly tasks: readonly TaskItem[];\n readonly title: string | null;\n readonly status: Status | null;\n readonly statusWord: string | null;\n readonly type: string | null;\n readonly wave: number | null;\n readonly dependsOn: readonly string[];\n readonly affectedFiles: readonly string[];\n readonly protectedFiles: readonly string[];\n readonly integrity: string | null;\n /** The frozen banner's lines, markers included, end exclusive. */\n readonly banner: { readonly start: number; readonly end: number } | null;\n readonly problems: readonly FieldProblem[];\n}\n\nfunction valueText(value: YamlValue): string | null | { readonly problem: string } {\n if (value.kind === 'unsupported') return { problem: value.reason };\n if (value.kind === 'list') return { problem: 'must be a single value, not a list' };\n return isNull(value.scalar) ? null : value.scalar.text;\n}\n\nfunction valueList(value: YamlValue): string[] | { readonly problem: string } {\n if (value.kind === 'unsupported') return { problem: value.reason };\n if (value.kind === 'scalar') return isNull(value.scalar) ? [] : [value.scalar.text];\n const empty = value.items.find((item) => isNull(item) || item.text.trim() === '');\n if (empty !== undefined) return { problem: 'must not contain an empty item' };\n return value.items.map((item) => item.text.trim());\n}\n\n/** The id a file name carries: everything before the separator, or the whole stem. */\nexport function idFromName(name: string, separator: string): string {\n const stem = name.replace(/\\.md$/i, '');\n const at = stem.indexOf(separator);\n return at > 0 ? stem.slice(0, at) : stem;\n}\n\nfunction statusFrom(word: string | null, config: Config, phase: Phase): Status | null {\n if (config.status.field === null) return phase === 'archived' ? 'archived' : 'active';\n if (word === null) return null;\n const lower = word.toLowerCase();\n if (lower === config.status.archived.toLowerCase()) return 'archived';\n if (lower === config.status.active.toLowerCase()) return 'active';\n if (config.status.draft !== null && lower === config.status.draft.toLowerCase()) return 'draft';\n return null;\n}\n\nexport function parseBrief(file: string, text: string, config: Config, phase: Phase): Brief {\n const content = stripBom(text);\n const lines = splitLines(content);\n const frontMatter = readFrontMatter(lines);\n const bodyStart = frontMatter === null || frontMatter.close < 0 ? 0 : frontMatter.close + 1;\n const scanned = scan(lines, bodyStart);\n const problems: FieldProblem[] = [];\n const name = file.slice(file.lastIndexOf('/') + 1);\n\n const text1 = (field: string): string | null => {\n const entry = findEntry(frontMatter, field);\n if (entry === undefined) return null;\n const value = valueText(entry.value);\n if (value !== null && typeof value === 'object') {\n problems.push({ field, line: entry.line, message: `\"${entry.key}\" ${value.problem}` });\n return null;\n }\n return value;\n };\n const list = (field: string): string[] => {\n const entry = findEntry(frontMatter, field);\n if (entry === undefined) return [];\n const value = valueList(entry.value);\n if (!Array.isArray(value)) {\n problems.push({ field, line: entry.line, message: `\"${entry.key}\" ${value.problem}` });\n return [];\n }\n return value;\n };\n\n const waveText = text1('wave');\n let wave: number | null = null;\n const waveEntry = findEntry(frontMatter, 'wave');\n if (waveText !== null && waveEntry !== undefined) {\n const quoted = waveEntry.value.kind === 'scalar' && waveEntry.value.scalar.quoted;\n if (!quoted && /^\\d{1,9}$/.test(waveText)) wave = Number(waveText);\n else problems.push({ field: 'wave', line: waveEntry.line, message: `\"wave\" must be a whole number, not \"${waveText}\"` });\n }\n\n const statusWord = config.status.field === null ? null : text1(config.status.field);\n const frontTitle = text1('title');\n const heading = titleOf(scanned);\n const id = config.id.source === 'filename' ? idFromName(name, config.id.separator) : text1('id');\n\n // A marker is a comment on a line of its own. Quoted in a code block it is\n // text: the prose mask keeps code and blanks comments, so a real marker is\n // a line whose prose is empty.\n const marker = (line: number, text: string): boolean =>\n (lines[line] as string).trim() === text && (scanned.prose[line] as string).trim() === '';\n let banner: Brief['banner'] = null;\n const open = lines.findIndex((_, i) => i >= bodyStart && marker(i, BANNER_OPEN));\n if (open >= 0) {\n const close = lines.findIndex((_, i) => i > open && marker(i, BANNER_CLOSE));\n if (close > open) banner = { start: open, end: close + 1 };\n }\n\n return {\n id: id === null || id.trim() === '' ? null : id.trim(),\n file,\n name,\n phase,\n source: text,\n text: content,\n lines,\n frontMatter,\n bodyStart,\n scan: scanned,\n sections: sectionsOf(scanned),\n tasks: scanned.tasks,\n title: frontTitle ?? (heading === undefined || heading.text === '' ? null : heading.text),\n status: statusFrom(statusWord, config, phase),\n statusWord,\n type: text1('type'),\n wave,\n dependsOn: list('dependsOn'),\n affectedFiles: list('affectedFiles'),\n protectedFiles: list('protectedFiles'),\n integrity: text1('integrity'),\n banner,\n problems,\n };\n}\n\n/** The 0-based line a front-matter key is declared on, or the first line when it is absent. */\nexport function lineOfField(brief: Brief, field: string): number {\n return findEntry(brief.frontMatter, field)?.line ?? 0;\n}\n\n/** Keys spec-brief knows, compared the way front matter compares them. */\nexport function knownFields(config: Config): Set<string> {\n const names = [...BUILT_IN_FIELDS, ...config.fields];\n if (config.status.field !== null) names.push(config.status.field);\n return new Set(names.map(keyName));\n}\n"]}
1
+ {"version":3,"file":"brief.js","sourceRoot":"","sources":["../src/brief.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAoC,MAAM,kBAAkB,CAAC;AACjH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAA0C,MAAM,eAAe,CAAC;AAClG,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGjD,MAAM,CAAC,MAAM,WAAW,GAAG,4BAA4B,CAAC;AACxD,MAAM,CAAC,MAAM,YAAY,GAAG,6BAA6B,CAAC;AAE1D,+EAA+E;AAC/E,MAAM,CAAC,MAAM,eAAe,GAAsB;IAChD,IAAI;IACJ,OAAO;IACP,MAAM;IACN,QAAQ;IACR,MAAM;IACN,MAAM;IACN,WAAW;IACX,eAAe;IACf,gBAAgB;IAChB,SAA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,EAAE,UAAU,CAAC,OAAO,CAAC;QAC7B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,KAAK,EAAE,UAAU,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;QACzF,MAAM,EAAE,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC;QAC7C,UAAU;QACV,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC;QACnB,IAAI;QACJ,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC;QAC5B,aAAa,EAAE,IAAI,CAAC,eAAe,CAAC;QACpC,cAAc,EAAE,IAAI,CAAC,gBAAgB,CAAC;QACtC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;QACzB,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC;QAC7B,MAAM;QACN,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,WAAW,CAAC,KAAY,EAAE,KAAa;IACrD,OAAO,SAAS,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE,IAAI,IAAI,CAAC,CAAC;AACxD,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,MAAM,KAAK,GAAG,CAAC,GAAG,eAAe,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACrD,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAClE,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AACrC,CAAC","sourcesContent":["/**\n * One brief, read: its identity, its front matter, its sections and its task\n * items. A pure function of a file's path and text.\n */\n\nimport type { Config } from './config.js';\nimport { findEntry, isNull, keyName, readFrontMatter, type FrontMatter, type YamlValue } from './frontmatter.js';\nimport { scan, sectionsOf, titleOf, type Scan, type Section, type TaskItem } from './markdown.js';\nimport { splitLines, stripBom } from './text.js';\nimport type { Phase, Status } from './types.js';\n\nexport const BANNER_OPEN = '<!-- spec-brief:banner -->';\nexport const BANNER_CLOSE = '<!-- /spec-brief:banner -->';\n\n/** Front-matter keys spec-brief itself reads, in the spelling it documents. */\nexport const BUILT_IN_FIELDS: readonly string[] = [\n 'id',\n 'title',\n 'type',\n 'status',\n 'date',\n 'wave',\n 'dependsOn',\n 'affectedFiles',\n 'protectedFiles',\n 'trigger',\n 'integrity',\n];\n\nexport interface FieldProblem {\n readonly field: string;\n /** 0-based line. */\n readonly line: number;\n readonly message: string;\n}\n\nexport interface Brief {\n /** `null` when no id can be read, which a rule reports. */\n readonly id: string | null;\n /** Repository-relative path. */\n readonly file: string;\n /** The file name. */\n readonly name: string;\n readonly phase: Phase;\n /** The file exactly as read, byte-order mark and line endings included. */\n readonly source: string;\n /** The text parsed: the source without a byte-order mark. */\n readonly text: string;\n readonly lines: readonly string[];\n readonly frontMatter: FrontMatter | null;\n /** 0-based first line after the front matter. */\n readonly bodyStart: number;\n readonly scan: Scan;\n readonly sections: readonly Section[];\n readonly tasks: readonly TaskItem[];\n readonly title: string | null;\n readonly status: Status | null;\n readonly statusWord: string | null;\n readonly type: string | null;\n readonly wave: number | null;\n readonly dependsOn: readonly string[];\n readonly affectedFiles: readonly string[];\n readonly protectedFiles: readonly string[];\n /** For deferred work: the observable event that brings it back. */\n readonly trigger: string | null;\n readonly integrity: string | null;\n /** The frozen banner's lines, markers included, end exclusive. */\n readonly banner: { readonly start: number; readonly end: number } | null;\n readonly problems: readonly FieldProblem[];\n}\n\nfunction valueText(value: YamlValue): string | null | { readonly problem: string } {\n if (value.kind === 'unsupported') return { problem: value.reason };\n if (value.kind === 'list') return { problem: 'must be a single value, not a list' };\n return isNull(value.scalar) ? null : value.scalar.text;\n}\n\nfunction valueList(value: YamlValue): string[] | { readonly problem: string } {\n if (value.kind === 'unsupported') return { problem: value.reason };\n if (value.kind === 'scalar') return isNull(value.scalar) ? [] : [value.scalar.text];\n const empty = value.items.find((item) => isNull(item) || item.text.trim() === '');\n if (empty !== undefined) return { problem: 'must not contain an empty item' };\n return value.items.map((item) => item.text.trim());\n}\n\n/** The id a file name carries: everything before the separator, or the whole stem. */\nexport function idFromName(name: string, separator: string): string {\n const stem = name.replace(/\\.md$/i, '');\n const at = stem.indexOf(separator);\n return at > 0 ? stem.slice(0, at) : stem;\n}\n\nfunction statusFrom(word: string | null, config: Config, phase: Phase): Status | null {\n if (config.status.field === null) return phase === 'archived' ? 'archived' : 'active';\n if (word === null) return null;\n const lower = word.toLowerCase();\n if (lower === config.status.archived.toLowerCase()) return 'archived';\n if (lower === config.status.active.toLowerCase()) return 'active';\n if (config.status.draft !== null && lower === config.status.draft.toLowerCase()) return 'draft';\n if (config.status.deferred !== null && lower === config.status.deferred.toLowerCase()) return 'deferred';\n return null;\n}\n\nexport function parseBrief(file: string, text: string, config: Config, phase: Phase): Brief {\n const content = stripBom(text);\n const lines = splitLines(content);\n const frontMatter = readFrontMatter(lines);\n const bodyStart = frontMatter === null || frontMatter.close < 0 ? 0 : frontMatter.close + 1;\n const scanned = scan(lines);\n const problems: FieldProblem[] = [];\n const name = file.slice(file.lastIndexOf('/') + 1);\n\n const text1 = (field: string): string | null => {\n const entry = findEntry(frontMatter, field);\n if (entry === undefined) return null;\n const value = valueText(entry.value);\n if (value !== null && typeof value === 'object') {\n problems.push({ field, line: entry.line, message: `\"${entry.key}\" ${value.problem}` });\n return null;\n }\n return value;\n };\n const list = (field: string): string[] => {\n const entry = findEntry(frontMatter, field);\n if (entry === undefined) return [];\n const value = valueList(entry.value);\n if (!Array.isArray(value)) {\n problems.push({ field, line: entry.line, message: `\"${entry.key}\" ${value.problem}` });\n return [];\n }\n return value;\n };\n\n const waveText = text1('wave');\n let wave: number | null = null;\n const waveEntry = findEntry(frontMatter, 'wave');\n if (waveText !== null && waveEntry !== undefined) {\n const quoted = waveEntry.value.kind === 'scalar' && waveEntry.value.scalar.quoted;\n if (!quoted && /^\\d{1,9}$/.test(waveText)) wave = Number(waveText);\n else problems.push({ field: 'wave', line: waveEntry.line, message: `\"wave\" must be a whole number, not \"${waveText}\"` });\n }\n\n const statusWord = config.status.field === null ? null : text1(config.status.field);\n const frontTitle = text1('title');\n const heading = titleOf(scanned);\n const id = config.id.source === 'filename' ? idFromName(name, config.id.separator) : text1('id');\n\n // A marker is a comment on a line of its own. Quoted in a code block it is\n // text: the prose mask keeps code and blanks comments, so a real marker is\n // a line whose prose is empty.\n const marker = (line: number, text: string): boolean =>\n (lines[line] as string).trim() === text && (scanned.prose[line] as string).trim() === '';\n let banner: Brief['banner'] = null;\n const open = lines.findIndex((_, i) => i >= bodyStart && marker(i, BANNER_OPEN));\n if (open >= 0) {\n const close = lines.findIndex((_, i) => i > open && marker(i, BANNER_CLOSE));\n if (close > open) banner = { start: open, end: close + 1 };\n }\n\n return {\n id: id === null || id.trim() === '' ? null : id.trim(),\n file,\n name,\n phase,\n source: text,\n text: content,\n lines,\n frontMatter,\n bodyStart,\n scan: scanned,\n sections: sectionsOf(scanned),\n tasks: scanned.tasks,\n title: frontTitle ?? (heading === undefined || heading.text === '' ? null : heading.text),\n status: statusFrom(statusWord, config, phase),\n statusWord,\n type: text1('type'),\n wave,\n dependsOn: list('dependsOn'),\n affectedFiles: list('affectedFiles'),\n protectedFiles: list('protectedFiles'),\n trigger: text1('trigger'),\n integrity: text1('integrity'),\n banner,\n problems,\n };\n}\n\n/** The 0-based line a front-matter key is declared on, or the first line when it is absent. */\nexport function lineOfField(brief: Brief, field: string): number {\n return findEntry(brief.frontMatter, field)?.line ?? 0;\n}\n\n/** Keys spec-brief knows, compared the way front matter compares them. */\nexport function knownFields(config: Config): Set<string> {\n const names = [...BUILT_IN_FIELDS, ...config.fields];\n if (config.status.field !== null) names.push(config.status.field);\n return new Set(names.map(keyName));\n}\n"]}
package/dist/cli.d.ts CHANGED
@@ -23,7 +23,7 @@ export interface CliIO {
23
23
  readonly cwd?: string;
24
24
  readonly env?: Readonly<Record<string, string | undefined>>;
25
25
  }
26
- export declare const HELP = "spec-brief - lint, schedule and archive task briefs\n\nUsage:\n spec-brief <command> [options]\n\nCommands:\n init write .spec-brief.json and the brief directories\n new <title> scaffold a brief with the next free id\n lint [brief...] check briefs against the configuration\n list briefs with their status, wave and readiness\n matrix scope collisions between briefs in the same wave\n archive <brief> close a round: check it, stamp it, freeze it, move it\n unarchive <brief> reopen an archived brief\n\nOptions for every command:\n --root <dir> run from this directory instead of the current one\n --config <file> use this configuration file\n --no-config use the defaults, ignoring any configuration file\n --format <format> pretty (default), json, sarif or github\n --strict treat warnings as errors\n --no-git leave git out; read the files on disk instead\n --color, --no-color force colour on or off\n -h, --help show this help\n -v, --version show the version\n\ninit:\n --briefs <dir> the directory of live briefs; default briefs\n --archive <dir> the directory of archived briefs; default <briefs>/archive\n\nnew:\n --id <id> use this id instead of the next free one\n --type <type> a brief type from the configuration\n --wave <n> the wave it runs in\n --depends-on <ids> comma-separated ids it runs after\n --date <YYYY-MM-DD> the date in its front matter; default today\n\nlist:\n --ready only live briefs whose dependencies are archived\n --archived include archived briefs\n\nmatrix:\n --all-waves compare every live brief, whatever its wave\n\narchive:\n --pr <number> the pull request the round merged in\n --commit <rev> the commit the round landed as\n --base <rev> the branch it started from; the diff runs from the merge base\n --summary <text> what the round did, for the banner\n --date <YYYY-MM-DD> the archival date; default today\n --allow-dirty archive although the tree has uncommitted work\n --dry-run print the plan and change nothing\n\nunarchive:\n --dry-run print the plan and change nothing\n\nExit codes: 0 clean, 1 findings or refused, 2 the run could not be trusted.\n";
26
+ export declare const HELP = "spec-brief - lint, schedule and archive task briefs\n\nUsage:\n spec-brief <command> [options]\n\nCommands:\n init write .spec-brief.json and the brief directories\n new <title> scaffold a brief with the next free id\n lint [brief...] check briefs against the configuration\n list briefs with their status, wave and readiness\n matrix scope collisions between briefs in the same wave\n schedule the waves the live briefs can run in, computed\n archive <brief> close a round: check it, stamp it, freeze it, move it\n unarchive <brief> reopen an archived brief\n\nOptions for every command:\n --root <dir> run from this directory instead of the current one\n --config <file> use this configuration file\n --no-config use the defaults, ignoring any configuration file\n --format <format> pretty (default), json, sarif, github or gitlab\n --strict treat warnings as errors\n --no-git leave git out; read the files on disk instead\n --color, --no-color force colour on or off\n -h, --help show this help\n -v, --version show the version\n\ninit:\n --briefs <dir> the directory of live briefs; default briefs\n --archive <dir> the directory of archived briefs; default <briefs>/archive\n\nnew:\n --id <id> use this id instead of the next free one\n --type <type> a brief type from the configuration\n --wave <n> the wave it runs in\n --depends-on <ids> comma-separated ids it runs after\n --date <YYYY-MM-DD> the date in its front matter; default today\n\nlist:\n --ready only briefs that can run now: dependencies archived, not drafts or deferred\n --archived include archived briefs\n\nmatrix:\n --all-waves compare every live brief, whatever its wave\n\nschedule:\n --write write each proposed wave into its brief's front matter\n\narchive:\n --pr <number> the pull request the round merged in\n --commit <rev> the commit the round landed as\n --base <rev> the branch it started from; the diff runs from the merge base\n --summary <text> what the round did, for the banner\n --date <YYYY-MM-DD> the archival date; default today\n --allow-dirty archive although the tree has uncommitted work\n --dry-run print the plan and change nothing\n\nunarchive:\n --dry-run print the plan and change nothing\n\nExit codes: 0 clean, 1 findings or refused, 2 the run could not be trusted.\n";
27
27
  type Values = Record<string, string | boolean | undefined>;
28
28
  interface Parsed {
29
29
  readonly command: string | undefined;
package/dist/cli.js CHANGED
@@ -14,7 +14,7 @@ import { BriefEngine, EngineError, today } from './engine.js';
14
14
  import { NodeFileSystem } from './fs.js';
15
15
  import { failing, sortFindings, summarise } from './lint.js';
16
16
  import { normalisePath } from './links.js';
17
- import { briefJson, findingJson, FORMATS, githubCommands, jsonDocument, planJson, prettyFindings, prettyList, prettyMatrix, prettyPlan, sarif, summaryLine, } from './report.js';
17
+ import { briefJson, findingJson, FORMATS, githubCommands, gitlabCodeQuality, jsonDocument, matrixJson, planJson, prettyFindings, prettyList, prettyMatrix, prettyPlan, prettySchedule, sarif, scheduleJson, sectionsJson, summaryLine, } from './report.js';
18
18
  export const EXIT_OK = 0;
19
19
  export const EXIT_FAILED = 1;
20
20
  export const EXIT_ERROR = 2;
@@ -35,6 +35,7 @@ Commands:
35
35
  lint [brief...] check briefs against the configuration
36
36
  list briefs with their status, wave and readiness
37
37
  matrix scope collisions between briefs in the same wave
38
+ schedule the waves the live briefs can run in, computed
38
39
  archive <brief> close a round: check it, stamp it, freeze it, move it
39
40
  unarchive <brief> reopen an archived brief
40
41
 
@@ -42,7 +43,7 @@ Options for every command:
42
43
  --root <dir> run from this directory instead of the current one
43
44
  --config <file> use this configuration file
44
45
  --no-config use the defaults, ignoring any configuration file
45
- --format <format> pretty (default), json, sarif or github
46
+ --format <format> pretty (default), json, sarif, github or gitlab
46
47
  --strict treat warnings as errors
47
48
  --no-git leave git out; read the files on disk instead
48
49
  --color, --no-color force colour on or off
@@ -61,12 +62,15 @@ new:
61
62
  --date <YYYY-MM-DD> the date in its front matter; default today
62
63
 
63
64
  list:
64
- --ready only live briefs whose dependencies are archived
65
+ --ready only briefs that can run now: dependencies archived, not drafts or deferred
65
66
  --archived include archived briefs
66
67
 
67
68
  matrix:
68
69
  --all-waves compare every live brief, whatever its wave
69
70
 
71
+ schedule:
72
+ --write write each proposed wave into its brief's front matter
73
+
70
74
  archive:
71
75
  --pr <number> the pull request the round merged in
72
76
  --commit <rev> the commit the round landed as
@@ -108,6 +112,7 @@ const COMMANDS = {
108
112
  lint: { options: {}, formats: FORMATS },
109
113
  list: { options: { ready: { type: 'boolean' }, archived: { type: 'boolean' } }, formats: ['pretty', 'json'] },
110
114
  matrix: { options: { 'all-waves': { type: 'boolean' } }, formats: FORMATS },
115
+ schedule: { options: { write: { type: 'boolean' } }, formats: FORMATS },
111
116
  archive: {
112
117
  options: {
113
118
  pr: { type: 'string' },
@@ -211,6 +216,9 @@ function emitFindings(run, command, findings, checked, extra = {}) {
211
216
  case 'github':
212
217
  run.out(githubCommands(findings));
213
218
  break;
219
+ case 'gitlab':
220
+ run.out(gitlabCodeQuality(findings));
221
+ break;
214
222
  case 'pretty':
215
223
  if (findings.length > 0)
216
224
  run.out(`${prettyFindings(findings, run.style)}\n\n`);
@@ -274,7 +282,7 @@ async function runLint(run) {
274
282
  engine.requireBriefs();
275
283
  const findings = await engine.lint(run.positionals);
276
284
  const checked = run.positionals.length === 0 ? engine.corpus.briefs.length : run.positionals.length;
277
- return emitFindings(run, 'lint', findings, checked);
285
+ return emitFindings(run, 'lint', findings, checked, { sections: sectionsJson(engine.config) });
278
286
  }
279
287
  async function runList(run) {
280
288
  const engine = await openEngine(run);
@@ -285,7 +293,11 @@ async function runList(run) {
285
293
  .map((brief) => ({ brief, ready: ready.has(brief), waitingOn: engine.waitingOn(brief) }))
286
294
  .filter((row) => !flag(run.values, 'ready') || row.ready);
287
295
  if (run.format === 'json') {
288
- run.out(jsonDocument('list', run.version, { ok: true, briefs: rows.map((r) => briefJson(r.brief, { ready: r.ready, waitingOn: r.waitingOn })) }));
296
+ run.out(jsonDocument('list', run.version, {
297
+ ok: true,
298
+ briefs: rows.map((r) => briefJson(r.brief, { ready: r.ready, waitingOn: r.waitingOn })),
299
+ sections: sectionsJson(engine.config),
300
+ }));
289
301
  }
290
302
  else {
291
303
  run.out(`${prettyList(rows, run.style)}\n`);
@@ -301,14 +313,34 @@ async function runMatrix(run) {
301
313
  run.out(`${prettyMatrix(report, run.style)}\n`);
302
314
  return failing(sorted, run.strict) ? EXIT_FAILED : EXIT_OK;
303
315
  }
304
- const waves = report.waves.map((w) => ({
305
- wave: w.wave,
306
- briefs: w.briefs.map((b) => b.id),
307
- collisions: w.collisions.map((c) => ({ a: c.a.id, b: c.b.id, patterns: c.patterns, witness: c.witness })),
308
- sharedDirectories: w.shared.map((s) => ({ a: s.a.id, b: s.b.id, directory: s.directory })),
309
- unscoped: w.unscoped.map((b) => b.id),
310
- }));
311
- return emitFindings(run, 'matrix', sorted, engine.corpus.live.length, { waves, unscheduled: report.unscheduled.map((b) => b.id) });
316
+ return emitFindings(run, 'matrix', sorted, engine.corpus.live.length, matrixJson(report));
317
+ }
318
+ /**
319
+ * The waves, computed. The view shows the moves, their reasons and the
320
+ * cycles; the other findings - briefs that run alone, pairs the search could
321
+ * not decide, a front matter that cannot take a wave - print beneath it.
322
+ */
323
+ async function runSchedule(run) {
324
+ const engine = await openEngine(run);
325
+ engine.requireBriefs();
326
+ const { schedule: computed, findings } = await engine.schedule();
327
+ let written = null;
328
+ let reported = findings;
329
+ if (flag(run.values, 'write')) {
330
+ const result = await engine.writeWaves(computed);
331
+ written = result.written;
332
+ // Written, the waves hold, and the findings that said they did not are answered.
333
+ reported = [...(written.length > 0 ? findings.filter((f) => f.rule !== 'wave-schedule') : findings), ...result.refused];
334
+ }
335
+ const sorted = sortFindings(reported);
336
+ if (run.format === 'pretty') {
337
+ run.out(`${prettySchedule(computed, written, run.style)}\n`);
338
+ const rest = sorted.filter((f) => f.rule !== 'wave-schedule' && f.rule !== 'dependency-cycle');
339
+ if (rest.length > 0)
340
+ run.out(`\n${prettyFindings(rest, run.style)}\n`);
341
+ return failing(sorted, run.strict) ? EXIT_FAILED : EXIT_OK;
342
+ }
343
+ return emitFindings(run, 'schedule', sorted, engine.corpus.live.length, { ...scheduleJson(computed), written });
312
344
  }
313
345
  async function runTransition(run, action) {
314
346
  const reference = run.positionals[0];
@@ -327,7 +359,7 @@ async function runTransition(run, action) {
327
359
  strict: run.strict,
328
360
  noGit: flag(run.values, 'no-git'),
329
361
  })
330
- : engine.planUnarchive(reference);
362
+ : engine.planUnarchive(reference, { strict: run.strict });
331
363
  const refused = plan.blocking.length > 0;
332
364
  if (!refused && !dryRun)
333
365
  await engine.apply(plan);
@@ -392,6 +424,8 @@ export async function main(argv = process.argv.slice(2), io = {}) {
392
424
  return await runList(run);
393
425
  case 'matrix':
394
426
  return await runMatrix(run);
427
+ case 'schedule':
428
+ return await runSchedule(run);
395
429
  case 'archive':
396
430
  return await runTransition(run, 'archive');
397
431
  default:
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAwB,MAAM,WAAW,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EACL,SAAS,EACT,WAAW,EACX,OAAO,EAEP,cAAc,EACd,YAAY,EAEZ,QAAQ,EACR,cAAc,EACd,UAAU,EACV,YAAY,EACZ,UAAU,EACV,KAAK,EAEL,WAAW,GACZ,MAAM,aAAa,CAAC;AAGrB,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC;AACzB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC;AAC7B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC;AAE5B,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AASD,MAAM,CAAC,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDnB,CAAC;A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":["/**\n * The command line: argument parsing, dispatch, output and exit codes.\n *\n * Exit 0: done, nothing found. Exit 1: findings, collisions, or an action\n * refused. Exit 2: the run could not be trusted - a bad flag, a configuration\n * that does not load, a brief that does not exist. A run that checked nothing\n * must never exit as though it found nothing.\n */\n\nimport { readFile } from 'node:fs/promises';\nimport { parseArgs, type ParseArgsConfig } from 'node:util';\n\nimport { TransactionError, ConflictError } from './apply.js';\nimport type { Plan } from './archive.js';\nimport { CONFIG_FILES, ConfigError, initialConfig } from './config.js';\nimport { BriefEngine, EngineError, today } from './engine.js';\nimport { NodeFileSystem } from './fs.js';\nimport { failing, sortFindings, summarise } from './lint.js';\nimport { normalisePath } from './links.js';\nimport {\n briefJson,\n findingJson,\n FORMATS,\n type Format,\n githubCommands,\n jsonDocument,\n type ListRow,\n planJson,\n prettyFindings,\n prettyList,\n prettyMatrix,\n prettyPlan,\n sarif,\n type Style,\n summaryLine,\n} from './report.js';\nimport type { Finding } from './types.js';\n\nexport const EXIT_OK = 0;\nexport const EXIT_FAILED = 1;\nexport const EXIT_ERROR = 2;\n\nexport class UsageError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'UsageError';\n }\n}\n\nexport interface CliIO {\n readonly stdout?: { write(text: string): unknown; readonly isTTY?: boolean };\n readonly stderr?: { write(text: string): unknown };\n readonly cwd?: string;\n readonly env?: Readonly<Record<string, string | undefined>>;\n}\n\nexport const HELP = `spec-brief - lint, schedule and archive task briefs\n\nUsage:\n spec-brief <command> [options]\n\nCommands:\n init write .spec-brief.json and the brief directories\n new <title> scaffold a brief with the next free id\n lint [brief...] check briefs against the configuration\n list briefs with their status, wave and readiness\n matrix scope collisions between briefs in the same wave\n archive <brief> close a round: check it, stamp it, freeze it, move it\n unarchive <brief> reopen an archived brief\n\nOptions for every command:\n --root <dir> run from this directory instead of the current one\n --config <file> use this configuration file\n --no-config use the defaults, ignoring any configuration file\n --format <format> pretty (default), json, sarif or github\n --strict treat warnings as errors\n --no-git leave git out; read the files on disk instead\n --color, --no-color force colour on or off\n -h, --help show this help\n -v, --version show the version\n\ninit:\n --briefs <dir> the directory of live briefs; default briefs\n --archive <dir> the directory of archived briefs; default <briefs>/archive\n\nnew:\n --id <id> use this id instead of the next free one\n --type <type> a brief type from the configuration\n --wave <n> the wave it runs in\n --depends-on <ids> comma-separated ids it runs after\n --date <YYYY-MM-DD> the date in its front matter; default today\n\nlist:\n --ready only live briefs whose dependencies are archived\n --archived include archived briefs\n\nmatrix:\n --all-waves compare every live brief, whatever its wave\n\narchive:\n --pr <number> the pull request the round merged in\n --commit <rev> the commit the round landed as\n --base <rev> the branch it started from; the diff runs from the merge base\n --summary <text> what the round did, for the banner\n --date <YYYY-MM-DD> the archival date; default today\n --allow-dirty archive although the tree has uncommitted work\n --dry-run print the plan and change nothing\n\nunarchive:\n --dry-run print the plan and change nothing\n\nExit codes: 0 clean, 1 findings or refused, 2 the run could not be trusted.\n`;\n\ntype Values = Record<string, string | boolean | undefined>;\n\nconst GLOBAL: NonNullable<ParseArgsConfig['options']> = {\n root: { type: 'string' },\n config: { type: 'string' },\n 'no-config': { type: 'boolean' },\n format: { type: 'string' },\n strict: { type: 'boolean' },\n 'no-git': { type: 'boolean' },\n color: { type: 'boolean' },\n 'no-color': { type: 'boolean' },\n help: { type: 'boolean', short: 'h' },\n version: { type: 'boolean', short: 'v' },\n};\n\nconst COMMANDS: Readonly<Record<string, { options: NonNullable<ParseArgsConfig['options']>; formats: readonly Format[] }>> = {\n init: { options: { briefs: { type: 'string' }, archive: { type: 'string' } }, formats: ['pretty', 'json'] },\n new: {\n options: {\n id: { type: 'string' },\n type: { type: 'string' },\n wave: { type: 'string' },\n 'depends-on': { type: 'string' },\n date: { type: 'string' },\n },\n formats: ['pretty', 'json'],\n },\n lint: { options: {}, formats: FORMATS },\n list: { options: { ready: { type: 'boolean' }, archived: { type: 'boolean' } }, formats: ['pretty', 'json'] },\n matrix: { options: { 'all-waves': { type: 'boolean' } }, formats: FORMATS },\n archive: {\n options: {\n pr: { type: 'string' },\n commit: { type: 'string' },\n base: { type: 'string' },\n summary: { type: 'string' },\n date: { type: 'string' },\n 'allow-dirty': { type: 'boolean' },\n 'dry-run': { type: 'boolean' },\n },\n formats: ['pretty', 'json'],\n },\n unarchive: { options: { 'dry-run': { type: 'boolean' } }, formats: ['pretty', 'json'] },\n};\n\ninterface Parsed {\n readonly command: string | undefined;\n readonly values: Values;\n readonly positionals: readonly string[];\n}\n\n/** Global options that take a value, so the value is not mistaken for the command. */\nconst VALUED = new Set(['--root', '--config', '--format']);\n\nfunction commandOf(argv: readonly string[]): string | undefined {\n for (let i = 0; i < argv.length; i += 1) {\n const arg = argv[i] as string;\n if (arg === '--') return argv[i + 1];\n if (VALUED.has(arg)) {\n i += 1;\n continue;\n }\n if (!arg.startsWith('-')) return arg;\n }\n return undefined;\n}\n\nexport function parse(argv: readonly string[]): Parsed {\n const command = commandOf(argv);\n const spec = command === undefined ? undefined : COMMANDS[command];\n if (command !== undefined && spec === undefined) {\n throw new UsageError(`\"${command}\" is not a command; run spec-brief --help`);\n }\n try {\n const { values, positionals } = parseArgs({\n args: [...argv],\n options: { ...GLOBAL, ...(spec?.options ?? {}) },\n allowPositionals: true,\n strict: true,\n });\n return { command, values: values as Values, positionals: positionals.slice(1) };\n } catch (error) {\n throw new UsageError((error as Error).message);\n }\n}\n\nfunction text(values: Values, key: string): string | undefined {\n const value = values[key];\n return typeof value === 'string' ? value : undefined;\n}\n\nfunction flag(values: Values, key: string): boolean {\n return values[key] === true;\n}\n\nfunction integer(values: Values, key: string, minimum: number): number | undefined {\n const raw = text(values, key);\n if (raw === undefined) return undefined;\n if (!/^\\d+$/.test(raw) || Number(raw) < minimum) throw new UsageError(`--${key} must be a whole number of at least ${minimum}, not \"${raw}\"`);\n return Number(raw);\n}\n\nasync function version(): Promise<string> {\n const pkg = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8')) as { version: string };\n return pkg.version;\n}\n\ninterface Run {\n /** Today, as the environment the run was given says. */\n readonly today: string;\n readonly out: (text: string) => void;\n readonly err: (text: string) => void;\n readonly style: Style;\n readonly format: Format;\n readonly strict: boolean;\n readonly version: string;\n readonly values: Values;\n readonly positionals: readonly string[];\n readonly cwd: string;\n}\n\nfunction useColor(values: Values, io: CliIO): boolean {\n if (flag(values, 'no-color')) return false;\n if (flag(values, 'color')) return true;\n const env = io.env ?? process.env;\n if ((env['NO_COLOR'] ?? '') !== '') return false;\n const force = env['FORCE_COLOR'];\n if (force !== undefined && force !== '') return force !== '0';\n return (io.stdout ?? process.stdout).isTTY === true;\n}\n\nasync function openEngine(run: Run): Promise<BriefEngine> {\n const root = text(run.values, 'root');\n const config = text(run.values, 'config');\n return BriefEngine.open({\n cwd: root === undefined ? run.cwd : root,\n ...(config === undefined ? {} : { config }),\n ...(flag(run.values, 'no-git') ? { git: null } : {}),\n noConfig: flag(run.values, 'no-config'),\n });\n}\n\nfunction emitFindings(run: Run, command: string, findings: readonly Finding[], checked: number, extra: Record<string, unknown> = {}): number {\n const failed = failing(findings, run.strict);\n switch (run.format) {\n case 'json':\n run.out(jsonDocument(command, run.version, { ok: !failed, checked, summary: summarise(findings), findings: findings.map(findingJson), ...extra }));\n break;\n case 'sarif':\n run.out(sarif(findings, run.version));\n break;\n case 'github':\n run.out(githubCommands(findings));\n break;\n case 'pretty':\n if (findings.length > 0) run.out(`${prettyFindings(findings, run.style)}\\n\\n`);\n run.out(`${findings.length === 0 ? `${checked} brief(s) checked, no findings` : `${summaryLine(findings)} in ${checked} brief(s)`}\\n`);\n break;\n }\n return failed ? EXIT_FAILED : EXIT_OK;\n}\n\nasync function runInit(run: Run): Promise<number> {\n const root = text(run.values, 'root') ?? run.cwd;\n const fs = new NodeFileSystem(root);\n for (const name of CONFIG_FILES) {\n if (await fs.exists(name)) throw new UsageError(`${name} already exists here; edit it instead`);\n }\n const briefs = normalisePath(text(run.values, 'briefs') ?? 'briefs');\n const archive = normalisePath(text(run.values, 'archive') ?? `${briefs}/archive`);\n if (briefs === '' || archive === '' || briefs === archive) throw new UsageError('--briefs and --archive must be two directories');\n const config = `${JSON.stringify(initialConfig(briefs, archive), null, 2)}\\n`;\n await fs.write('.spec-brief.json', config);\n const written = ['.spec-brief.json'];\n for (const dir of [briefs, archive]) {\n const keep = `${dir}/.gitkeep`;\n if ((await fs.list(dir)) === null) {\n await fs.write(keep, '');\n written.push(keep);\n }\n }\n if (run.format === 'json') run.out(jsonDocument('init', run.version, { ok: true, written }));\n else run.out(`${written.map((w) => `wrote ${w}`).join('\\n')}\\nnext: spec-brief new \"<title>\"\\n`);\n return EXIT_OK;\n}\n\nasync function runNew(run: Run): Promise<number> {\n const title = run.positionals.join(' ').trim();\n if (title === '') throw new UsageError('new needs a title: spec-brief new \"<title>\"');\n const engine = await openEngine(run);\n const dependsOn = text(run.values, 'depends-on')\n ?.split(',')\n .map((d) => d.trim())\n .filter((d) => d !== '');\n const created = await engine.create({\n title,\n id: text(run.values, 'id'),\n type: text(run.values, 'type'),\n wave: integer(run.values, 'wave', 0),\n dependsOn,\n date: text(run.values, 'date') ?? run.today,\n });\n if (run.format === 'json') run.out(jsonDocument('new', run.version, { ok: true, file: created.file }));\n else run.out(`wrote ${created.file}\\n`);\n return EXIT_OK;\n}\n\nasync function runLint(run: Run): Promise<number> {\n const engine = await openEngine(run);\n engine.requireBriefs();\n const findings = await engine.lint(run.positionals);\n const checked = run.positionals.length === 0 ? engine.corpus.briefs.length : run.positionals.length;\n return emitFindings(run, 'lint', findings, checked);\n}\n\nasync function runList(run: Run): Promise<number> {\n const engine = await openEngine(run);\n engine.requireBriefs();\n const briefs = flag(run.values, 'archived') ? engine.corpus.briefs : engine.corpus.live;\n const ready = new Set(engine.ready());\n const rows: ListRow[] = briefs\n .map((brief) => ({ brief, ready: ready.has(brief), waitingOn: engine.waitingOn(brief) }))\n .filter((row) => !flag(run.values, 'ready') || row.ready);\n if (run.format === 'json') {\n run.out(jsonDocument('list', run.version, { ok: true, briefs: rows.map((r) => briefJson(r.brief, { ready: r.ready, waitingOn: r.waitingOn })) }));\n } else {\n run.out(`${prettyList(rows, run.style)}\\n`);\n }\n return EXIT_OK;\n}\n\nasync function runMatrix(run: Run): Promise<number> {\n const engine = await openEngine(run);\n engine.requireBriefs();\n const { report, findings } = await engine.collisions({ all: flag(run.values, 'all-waves') });\n const sorted = sortFindings(findings);\n if (run.format === 'pretty') {\n run.out(`${prettyMatrix(report, run.style)}\\n`);\n return failing(sorted, run.strict) ? EXIT_FAILED : EXIT_OK;\n }\n const waves = report.waves.map((w) => ({\n wave: w.wave,\n briefs: w.briefs.map((b) => b.id),\n collisions: w.collisions.map((c) => ({ a: c.a.id, b: c.b.id, patterns: c.patterns, witness: c.witness })),\n sharedDirectories: w.shared.map((s) => ({ a: s.a.id, b: s.b.id, directory: s.directory })),\n unscoped: w.unscoped.map((b) => b.id),\n }));\n return emitFindings(run, 'matrix', sorted, engine.corpus.live.length, { waves, unscheduled: report.unscheduled.map((b) => b.id) });\n}\n\nasync function runTransition(run: Run, action: 'archive' | 'unarchive'): Promise<number> {\n const reference = run.positionals[0];\n if (reference === undefined || run.positionals.length > 1) throw new UsageError(`${action} takes one brief: spec-brief ${action} <brief>`);\n const engine = await openEngine(run);\n const dryRun = flag(run.values, 'dry-run');\n const plan: Plan =\n action === 'archive'\n ? await engine.planArchive(reference, {\n pr: integer(run.values, 'pr', 1),\n commit: text(run.values, 'commit'),\n base: text(run.values, 'base'),\n summary: text(run.values, 'summary'),\n date: text(run.values, 'date') ?? run.today,\n allowDirty: flag(run.values, 'allow-dirty'),\n strict: run.strict,\n noGit: flag(run.values, 'no-git'),\n })\n : engine.planUnarchive(reference);\n const refused = plan.blocking.length > 0;\n if (!refused && !dryRun) await engine.apply(plan);\n if (run.format === 'json') run.out(jsonDocument(action, run.version, { ok: !refused, dryRun, plan: planJson(plan) }));\n else run.out(`${prettyPlan(plan, dryRun, run.style)}\\n`);\n return refused ? EXIT_FAILED : EXIT_OK;\n}\n\nexport async function main(argv: readonly string[] = process.argv.slice(2), io: CliIO = {}): Promise<number> {\n const stdout = io.stdout ?? process.stdout;\n const stderr = io.stderr ?? process.stderr;\n const err = (message: string): void => {\n stderr.write(`spec-brief: ${message}\\n`);\n };\n let parsed: Parsed;\n try {\n parsed = parse(argv);\n } catch (error) {\n err((error as Error).message);\n return EXIT_ERROR;\n }\n const { command, values, positionals } = parsed;\n if (flag(values, 'version')) {\n stdout.write(`${await version()}\\n`);\n return EXIT_OK;\n }\n if (flag(values, 'help') || command === undefined) {\n stdout.write(HELP);\n return command === undefined && !flag(values, 'help') ? EXIT_ERROR : EXIT_OK;\n }\n const spec = COMMANDS[command] as (typeof COMMANDS)[string];\n const format = (text(values, 'format') ?? 'pretty') as Format;\n if (!spec.formats.includes(format)) {\n err(`--format for ${command} is one of ${spec.formats.join(', ')}, not \"${format}\"`);\n return EXIT_ERROR;\n }\n const run: Run = {\n today: today(io.env ?? process.env),\n out: (t) => {\n stdout.write(t);\n },\n err,\n style: { color: format === 'pretty' && useColor(values, io) },\n format,\n strict: flag(values, 'strict'),\n version: await version(),\n values,\n positionals,\n cwd: io.cwd ?? process.cwd(),\n };\n try {\n switch (command) {\n case 'init':\n return await runInit(run);\n case 'new':\n return await runNew(run);\n case 'lint':\n return await runLint(run);\n case 'list':\n return await runList(run);\n case 'matrix':\n return await runMatrix(run);\n case 'archive':\n return await runTransition(run, 'archive');\n default:\n return await runTransition(run, 'unarchive');\n }\n } catch (error) {\n const expected = [ConfigError, UsageError, EngineError, ConflictError, TransactionError];\n if (expected.some((kind) => error instanceof kind)) {\n err((error as Error).message);\n return EXIT_ERROR;\n }\n err(`unexpected error: ${error instanceof Error ? (error.stack ?? error.message) : String(error)}`);\n return EXIT_ERROR;\n }\n}\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAwB,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AK,MAAM;gBACT,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;YAC5B,KAAK,QAAQ;gBACX,OAAO,MAAM,SAAS,CAAC,GAAG,CAAC,CAAC;YAC9B,KAAK,UAAU;gBACb,OAAO,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;YAChC,KAAK,SAAS;gBACZ,OAAO,MAAM,aAAa,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YAC7C;gBACE,OAAO,MAAM,aAAa,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,QAAQ,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,CAAC,CAAC;QACzF,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,YAAY,IAAI,CAAC,EAAE,CAAC;YACnD,GAAG,CAAE,KAAe,CAAC,OAAO,CAAC,CAAC;YAC9B,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,GAAG,CAAC,qBAAqB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACpG,OAAO,UAAU,CAAC;IACpB,CAAC;AACH,CAAC","sourcesContent":["/**\n * The command line: argument parsing, dispatch, output and exit codes.\n *\n * Exit 0: done, nothing found. Exit 1: findings, collisions, or an action\n * refused. Exit 2: the run could not be trusted - a bad flag, a configuration\n * that does not load, a brief that does not exist. A run that checked nothing\n * must never exit as though it found nothing.\n */\n\nimport { readFile } from 'node:fs/promises';\nimport { parseArgs, type ParseArgsConfig } from 'node:util';\n\nimport { TransactionError, ConflictError } from './apply.js';\nimport type { Plan } from './archive.js';\nimport { CONFIG_FILES, ConfigError, initialConfig } from './config.js';\nimport { BriefEngine, EngineError, today } from './engine.js';\nimport { NodeFileSystem } from './fs.js';\nimport { failing, sortFindings, summarise } from './lint.js';\nimport { normalisePath } from './links.js';\nimport {\n briefJson,\n findingJson,\n FORMATS,\n type Format,\n githubCommands,\n gitlabCodeQuality,\n jsonDocument,\n type ListRow,\n matrixJson,\n planJson,\n prettyFindings,\n prettyList,\n prettyMatrix,\n prettyPlan,\n prettySchedule,\n sarif,\n scheduleJson,\n sectionsJson,\n type Style,\n summaryLine,\n} from './report.js';\nimport type { Finding } from './types.js';\n\nexport const EXIT_OK = 0;\nexport const EXIT_FAILED = 1;\nexport const EXIT_ERROR = 2;\n\nexport class UsageError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'UsageError';\n }\n}\n\nexport interface CliIO {\n readonly stdout?: { write(text: string): unknown; readonly isTTY?: boolean };\n readonly stderr?: { write(text: string): unknown };\n readonly cwd?: string;\n readonly env?: Readonly<Record<string, string | undefined>>;\n}\n\nexport const HELP = `spec-brief - lint, schedule and archive task briefs\n\nUsage:\n spec-brief <command> [options]\n\nCommands:\n init write .spec-brief.json and the brief directories\n new <title> scaffold a brief with the next free id\n lint [brief...] check briefs against the configuration\n list briefs with their status, wave and readiness\n matrix scope collisions between briefs in the same wave\n schedule the waves the live briefs can run in, computed\n archive <brief> close a round: check it, stamp it, freeze it, move it\n unarchive <brief> reopen an archived brief\n\nOptions for every command:\n --root <dir> run from this directory instead of the current one\n --config <file> use this configuration file\n --no-config use the defaults, ignoring any configuration file\n --format <format> pretty (default), json, sarif, github or gitlab\n --strict treat warnings as errors\n --no-git leave git out; read the files on disk instead\n --color, --no-color force colour on or off\n -h, --help show this help\n -v, --version show the version\n\ninit:\n --briefs <dir> the directory of live briefs; default briefs\n --archive <dir> the directory of archived briefs; default <briefs>/archive\n\nnew:\n --id <id> use this id instead of the next free one\n --type <type> a brief type from the configuration\n --wave <n> the wave it runs in\n --depends-on <ids> comma-separated ids it runs after\n --date <YYYY-MM-DD> the date in its front matter; default today\n\nlist:\n --ready only briefs that can run now: dependencies archived, not drafts or deferred\n --archived include archived briefs\n\nmatrix:\n --all-waves compare every live brief, whatever its wave\n\nschedule:\n --write write each proposed wave into its brief's front matter\n\narchive:\n --pr <number> the pull request the round merged in\n --commit <rev> the commit the round landed as\n --base <rev> the branch it started from; the diff runs from the merge base\n --summary <text> what the round did, for the banner\n --date <YYYY-MM-DD> the archival date; default today\n --allow-dirty archive although the tree has uncommitted work\n --dry-run print the plan and change nothing\n\nunarchive:\n --dry-run print the plan and change nothing\n\nExit codes: 0 clean, 1 findings or refused, 2 the run could not be trusted.\n`;\n\ntype Values = Record<string, string | boolean | undefined>;\n\nconst GLOBAL: NonNullable<ParseArgsConfig['options']> = {\n root: { type: 'string' },\n config: { type: 'string' },\n 'no-config': { type: 'boolean' },\n format: { type: 'string' },\n strict: { type: 'boolean' },\n 'no-git': { type: 'boolean' },\n color: { type: 'boolean' },\n 'no-color': { type: 'boolean' },\n help: { type: 'boolean', short: 'h' },\n version: { type: 'boolean', short: 'v' },\n};\n\nconst COMMANDS: Readonly<Record<string, { options: NonNullable<ParseArgsConfig['options']>; formats: readonly Format[] }>> = {\n init: { options: { briefs: { type: 'string' }, archive: { type: 'string' } }, formats: ['pretty', 'json'] },\n new: {\n options: {\n id: { type: 'string' },\n type: { type: 'string' },\n wave: { type: 'string' },\n 'depends-on': { type: 'string' },\n date: { type: 'string' },\n },\n formats: ['pretty', 'json'],\n },\n lint: { options: {}, formats: FORMATS },\n list: { options: { ready: { type: 'boolean' }, archived: { type: 'boolean' } }, formats: ['pretty', 'json'] },\n matrix: { options: { 'all-waves': { type: 'boolean' } }, formats: FORMATS },\n schedule: { options: { write: { type: 'boolean' } }, formats: FORMATS },\n archive: {\n options: {\n pr: { type: 'string' },\n commit: { type: 'string' },\n base: { type: 'string' },\n summary: { type: 'string' },\n date: { type: 'string' },\n 'allow-dirty': { type: 'boolean' },\n 'dry-run': { type: 'boolean' },\n },\n formats: ['pretty', 'json'],\n },\n unarchive: { options: { 'dry-run': { type: 'boolean' } }, formats: ['pretty', 'json'] },\n};\n\ninterface Parsed {\n readonly command: string | undefined;\n readonly values: Values;\n readonly positionals: readonly string[];\n}\n\n/** Global options that take a value, so the value is not mistaken for the command. */\nconst VALUED = new Set(['--root', '--config', '--format']);\n\nfunction commandOf(argv: readonly string[]): string | undefined {\n for (let i = 0; i < argv.length; i += 1) {\n const arg = argv[i] as string;\n if (arg === '--') return argv[i + 1];\n if (VALUED.has(arg)) {\n i += 1;\n continue;\n }\n if (!arg.startsWith('-')) return arg;\n }\n return undefined;\n}\n\nexport function parse(argv: readonly string[]): Parsed {\n const command = commandOf(argv);\n const spec = command === undefined ? undefined : COMMANDS[command];\n if (command !== undefined && spec === undefined) {\n throw new UsageError(`\"${command}\" is not a command; run spec-brief --help`);\n }\n try {\n const { values, positionals } = parseArgs({\n args: [...argv],\n options: { ...GLOBAL, ...(spec?.options ?? {}) },\n allowPositionals: true,\n strict: true,\n });\n return { command, values: values as Values, positionals: positionals.slice(1) };\n } catch (error) {\n throw new UsageError((error as Error).message);\n }\n}\n\nfunction text(values: Values, key: string): string | undefined {\n const value = values[key];\n return typeof value === 'string' ? value : undefined;\n}\n\nfunction flag(values: Values, key: string): boolean {\n return values[key] === true;\n}\n\nfunction integer(values: Values, key: string, minimum: number): number | undefined {\n const raw = text(values, key);\n if (raw === undefined) return undefined;\n if (!/^\\d+$/.test(raw) || Number(raw) < minimum) throw new UsageError(`--${key} must be a whole number of at least ${minimum}, not \"${raw}\"`);\n return Number(raw);\n}\n\nasync function version(): Promise<string> {\n const pkg = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8')) as { version: string };\n return pkg.version;\n}\n\ninterface Run {\n /** Today, as the environment the run was given says. */\n readonly today: string;\n readonly out: (text: string) => void;\n readonly err: (text: string) => void;\n readonly style: Style;\n readonly format: Format;\n readonly strict: boolean;\n readonly version: string;\n readonly values: Values;\n readonly positionals: readonly string[];\n readonly cwd: string;\n}\n\nfunction useColor(values: Values, io: CliIO): boolean {\n if (flag(values, 'no-color')) return false;\n if (flag(values, 'color')) return true;\n const env = io.env ?? process.env;\n if ((env['NO_COLOR'] ?? '') !== '') return false;\n const force = env['FORCE_COLOR'];\n if (force !== undefined && force !== '') return force !== '0';\n return (io.stdout ?? process.stdout).isTTY === true;\n}\n\nasync function openEngine(run: Run): Promise<BriefEngine> {\n const root = text(run.values, 'root');\n const config = text(run.values, 'config');\n return BriefEngine.open({\n cwd: root === undefined ? run.cwd : root,\n ...(config === undefined ? {} : { config }),\n ...(flag(run.values, 'no-git') ? { git: null } : {}),\n noConfig: flag(run.values, 'no-config'),\n });\n}\n\nfunction emitFindings(run: Run, command: string, findings: readonly Finding[], checked: number, extra: Record<string, unknown> = {}): number {\n const failed = failing(findings, run.strict);\n switch (run.format) {\n case 'json':\n run.out(jsonDocument(command, run.version, { ok: !failed, checked, summary: summarise(findings), findings: findings.map(findingJson), ...extra }));\n break;\n case 'sarif':\n run.out(sarif(findings, run.version));\n break;\n case 'github':\n run.out(githubCommands(findings));\n break;\n case 'gitlab':\n run.out(gitlabCodeQuality(findings));\n break;\n case 'pretty':\n if (findings.length > 0) run.out(`${prettyFindings(findings, run.style)}\\n\\n`);\n run.out(`${findings.length === 0 ? `${checked} brief(s) checked, no findings` : `${summaryLine(findings)} in ${checked} brief(s)`}\\n`);\n break;\n }\n return failed ? EXIT_FAILED : EXIT_OK;\n}\n\nasync function runInit(run: Run): Promise<number> {\n const root = text(run.values, 'root') ?? run.cwd;\n const fs = new NodeFileSystem(root);\n for (const name of CONFIG_FILES) {\n if (await fs.exists(name)) throw new UsageError(`${name} already exists here; edit it instead`);\n }\n const briefs = normalisePath(text(run.values, 'briefs') ?? 'briefs');\n const archive = normalisePath(text(run.values, 'archive') ?? `${briefs}/archive`);\n if (briefs === '' || archive === '' || briefs === archive) throw new UsageError('--briefs and --archive must be two directories');\n const config = `${JSON.stringify(initialConfig(briefs, archive), null, 2)}\\n`;\n await fs.write('.spec-brief.json', config);\n const written = ['.spec-brief.json'];\n for (const dir of [briefs, archive]) {\n const keep = `${dir}/.gitkeep`;\n if ((await fs.list(dir)) === null) {\n await fs.write(keep, '');\n written.push(keep);\n }\n }\n if (run.format === 'json') run.out(jsonDocument('init', run.version, { ok: true, written }));\n else run.out(`${written.map((w) => `wrote ${w}`).join('\\n')}\\nnext: spec-brief new \"<title>\"\\n`);\n return EXIT_OK;\n}\n\nasync function runNew(run: Run): Promise<number> {\n const title = run.positionals.join(' ').trim();\n if (title === '') throw new UsageError('new needs a title: spec-brief new \"<title>\"');\n const engine = await openEngine(run);\n const dependsOn = text(run.values, 'depends-on')\n ?.split(',')\n .map((d) => d.trim())\n .filter((d) => d !== '');\n const created = await engine.create({\n title,\n id: text(run.values, 'id'),\n type: text(run.values, 'type'),\n wave: integer(run.values, 'wave', 0),\n dependsOn,\n date: text(run.values, 'date') ?? run.today,\n });\n if (run.format === 'json') run.out(jsonDocument('new', run.version, { ok: true, file: created.file }));\n else run.out(`wrote ${created.file}\\n`);\n return EXIT_OK;\n}\n\nasync function runLint(run: Run): Promise<number> {\n const engine = await openEngine(run);\n engine.requireBriefs();\n const findings = await engine.lint(run.positionals);\n const checked = run.positionals.length === 0 ? engine.corpus.briefs.length : run.positionals.length;\n return emitFindings(run, 'lint', findings, checked, { sections: sectionsJson(engine.config) });\n}\n\nasync function runList(run: Run): Promise<number> {\n const engine = await openEngine(run);\n engine.requireBriefs();\n const briefs = flag(run.values, 'archived') ? engine.corpus.briefs : engine.corpus.live;\n const ready = new Set(engine.ready());\n const rows: ListRow[] = briefs\n .map((brief) => ({ brief, ready: ready.has(brief), waitingOn: engine.waitingOn(brief) }))\n .filter((row) => !flag(run.values, 'ready') || row.ready);\n if (run.format === 'json') {\n run.out(\n jsonDocument('list', run.version, {\n ok: true,\n briefs: rows.map((r) => briefJson(r.brief, { ready: r.ready, waitingOn: r.waitingOn })),\n sections: sectionsJson(engine.config),\n }),\n );\n } else {\n run.out(`${prettyList(rows, run.style)}\\n`);\n }\n return EXIT_OK;\n}\n\nasync function runMatrix(run: Run): Promise<number> {\n const engine = await openEngine(run);\n engine.requireBriefs();\n const { report, findings } = await engine.collisions({ all: flag(run.values, 'all-waves') });\n const sorted = sortFindings(findings);\n if (run.format === 'pretty') {\n run.out(`${prettyMatrix(report, run.style)}\\n`);\n return failing(sorted, run.strict) ? EXIT_FAILED : EXIT_OK;\n }\n return emitFindings(run, 'matrix', sorted, engine.corpus.live.length, matrixJson(report));\n}\n\n/**\n * The waves, computed. The view shows the moves, their reasons and the\n * cycles; the other findings - briefs that run alone, pairs the search could\n * not decide, a front matter that cannot take a wave - print beneath it.\n */\nasync function runSchedule(run: Run): Promise<number> {\n const engine = await openEngine(run);\n engine.requireBriefs();\n const { schedule: computed, findings } = await engine.schedule();\n let written: string[] | null = null;\n let reported: Finding[] = findings;\n if (flag(run.values, 'write')) {\n const result = await engine.writeWaves(computed);\n written = result.written;\n // Written, the waves hold, and the findings that said they did not are answered.\n reported = [...(written.length > 0 ? findings.filter((f) => f.rule !== 'wave-schedule') : findings), ...result.refused];\n }\n const sorted = sortFindings(reported);\n if (run.format === 'pretty') {\n run.out(`${prettySchedule(computed, written, run.style)}\\n`);\n const rest = sorted.filter((f) => f.rule !== 'wave-schedule' && f.rule !== 'dependency-cycle');\n if (rest.length > 0) run.out(`\\n${prettyFindings(rest, run.style)}\\n`);\n return failing(sorted, run.strict) ? EXIT_FAILED : EXIT_OK;\n }\n return emitFindings(run, 'schedule', sorted, engine.corpus.live.length, { ...scheduleJson(computed), written });\n}\n\nasync function runTransition(run: Run, action: 'archive' | 'unarchive'): Promise<number> {\n const reference = run.positionals[0];\n if (reference === undefined || run.positionals.length > 1) throw new UsageError(`${action} takes one brief: spec-brief ${action} <brief>`);\n const engine = await openEngine(run);\n const dryRun = flag(run.values, 'dry-run');\n const plan: Plan =\n action === 'archive'\n ? await engine.planArchive(reference, {\n pr: integer(run.values, 'pr', 1),\n commit: text(run.values, 'commit'),\n base: text(run.values, 'base'),\n summary: text(run.values, 'summary'),\n date: text(run.values, 'date') ?? run.today,\n allowDirty: flag(run.values, 'allow-dirty'),\n strict: run.strict,\n noGit: flag(run.values, 'no-git'),\n })\n : engine.planUnarchive(reference, { strict: run.strict });\n const refused = plan.blocking.length > 0;\n if (!refused && !dryRun) await engine.apply(plan);\n if (run.format === 'json') run.out(jsonDocument(action, run.version, { ok: !refused, dryRun, plan: planJson(plan) }));\n else run.out(`${prettyPlan(plan, dryRun, run.style)}\\n`);\n return refused ? EXIT_FAILED : EXIT_OK;\n}\n\nexport async function main(argv: readonly string[] = process.argv.slice(2), io: CliIO = {}): Promise<number> {\n const stdout = io.stdout ?? process.stdout;\n const stderr = io.stderr ?? process.stderr;\n const err = (message: string): void => {\n stderr.write(`spec-brief: ${message}\\n`);\n };\n let parsed: Parsed;\n try {\n parsed = parse(argv);\n } catch (error) {\n err((error as Error).message);\n return EXIT_ERROR;\n }\n const { command, values, positionals } = parsed;\n if (flag(values, 'version')) {\n stdout.write(`${await version()}\\n`);\n return EXIT_OK;\n }\n if (flag(values, 'help') || command === undefined) {\n stdout.write(HELP);\n return command === undefined && !flag(values, 'help') ? EXIT_ERROR : EXIT_OK;\n }\n const spec = COMMANDS[command] as (typeof COMMANDS)[string];\n const format = (text(values, 'format') ?? 'pretty') as Format;\n if (!spec.formats.includes(format)) {\n err(`--format for ${command} is one of ${spec.formats.join(', ')}, not \"${format}\"`);\n return EXIT_ERROR;\n }\n const run: Run = {\n today: today(io.env ?? process.env),\n out: (t) => {\n stdout.write(t);\n },\n err,\n style: { color: format === 'pretty' && useColor(values, io) },\n format,\n strict: flag(values, 'strict'),\n version: await version(),\n values,\n positionals,\n cwd: io.cwd ?? process.cwd(),\n };\n try {\n switch (command) {\n case 'init':\n return await runInit(run);\n case 'new':\n return await runNew(run);\n case 'lint':\n return await runLint(run);\n case 'list':\n return await runList(run);\n case 'matrix':\n return await runMatrix(run);\n case 'schedule':\n return await runSchedule(run);\n case 'archive':\n return await runTransition(run, 'archive');\n default:\n return await runTransition(run, 'unarchive');\n }\n } catch (error) {\n const expected = [ConfigError, UsageError, EngineError, ConflictError, TransactionError];\n if (expected.some((kind) => error instanceof kind)) {\n err((error as Error).message);\n return EXIT_ERROR;\n }\n err(`unexpected error: ${error instanceof Error ? (error.stack ?? error.message) : String(error)}`);\n return EXIT_ERROR;\n }\n}\n"]}
@@ -4,30 +4,47 @@
4
4
  *
5
5
  * Scopes are compared as globs, not as strings. `src/auth/**` and
6
6
  * `src/**\/session.ts` share no prefix a string comparison would see and both
7
- * cover `src/auth/session.ts`; the intersection finds that, and names the file.
8
- * A brief that declares no scope cannot be proven apart from anything, so it
9
- * is reported as unscoped rather than silently counted as safe.
7
+ * cover `src/auth/session.ts`; the witness search finds that, and names the
8
+ * file. What a brief protects it will not write, so a file either brief of a
9
+ * pair protects is no collision. A brief that declares no scope cannot be
10
+ * proven apart from anything, so it is reported as unscoped rather than
11
+ * silently counted as safe, and a pair the search could not decide is reported
12
+ * as undecided rather than as either.
13
+ *
14
+ * Two briefs that collide are one defect however many of their patterns
15
+ * meet: they are fixed together, by a wave, a dependency or a narrower scope.
16
+ * So a pair is one collision, carrying every pair of patterns that meets.
10
17
  */
11
18
  import type { Brief } from './brief.js';
12
- import type { Corpus } from './corpus.js';
13
- import type { Finding } from './types.js';
19
+ import { type Corpus, type Waiting } from './corpus.js';
20
+ import { type Overlap } from './scope.js';
21
+ import type { Finding, Severity } from './types.js';
22
+ export type { Overlap } from './scope.js';
14
23
  export interface Collision {
15
24
  readonly a: Brief;
16
25
  readonly b: Brief;
17
- readonly patterns: readonly [string, string];
18
- /** A path both scopes cover. */
19
- readonly witness: string;
26
+ /** Every pair of patterns that meets, `a`'s first; never empty. */
27
+ readonly overlaps: readonly Overlap[];
28
+ }
29
+ /** Two briefs no pair of whose patterns is known to meet, and some pair the search could not decide. */
30
+ export interface UndecidedPair {
31
+ readonly a: Brief;
32
+ readonly b: Brief;
33
+ /** The pairs of patterns, `a`'s first; never empty. */
34
+ readonly patterns: readonly (readonly [string, string])[];
20
35
  }
21
36
  export interface SharedDirectory {
22
37
  readonly a: Brief;
23
38
  readonly b: Brief;
24
- readonly directory: string;
39
+ /** The directories both write into, sorted; never empty. */
40
+ readonly directories: readonly string[];
25
41
  }
26
42
  export interface WaveMatrix {
27
43
  /** `null` when every live brief is compared regardless of wave. */
28
44
  readonly wave: number | null;
29
45
  readonly briefs: readonly Brief[];
30
46
  readonly collisions: readonly Collision[];
47
+ readonly undecided: readonly UndecidedPair[];
31
48
  readonly shared: readonly SharedDirectory[];
32
49
  readonly unscoped: readonly Brief[];
33
50
  }
@@ -35,16 +52,30 @@ export interface CollisionReport {
35
52
  readonly waves: readonly WaveMatrix[];
36
53
  /** Live briefs with no wave, which the matrix does not place. */
37
54
  readonly unscheduled: readonly Brief[];
55
+ /** Deferred briefs, which wait for their trigger and run in no wave. */
56
+ readonly deferred: readonly Brief[];
57
+ /**
58
+ * Briefs that depend on a deferred brief, or on one that waits on one. They
59
+ * cannot start before the deferred work, so they run in no wave either, and
60
+ * are compared with nothing - as `schedule` places them nowhere. By id.
61
+ */
62
+ readonly waiting: readonly Waiting[];
38
63
  }
39
64
  export interface CollisionOptions {
40
65
  /** Compare every live brief with every other, whatever its wave. */
41
66
  readonly all?: boolean;
42
- /** Tracked files, which tell a literal file path from a directory. */
67
+ /** The files the tree holds, which say whether a literal path is a file or a directory. */
43
68
  readonly repoFiles?: readonly string[] | null;
69
+ /** How many states one witness search may visit before it answers `undecided`. */
70
+ readonly budget?: number;
44
71
  }
45
72
  export declare function collisions(corpus: Corpus, options?: CollisionOptions): CollisionReport;
73
+ /** A pair whose collision the search could not decide, as one finding on the later brief. */
74
+ export declare function undecidedFinding(severity: Severity, a: Brief, b: Brief, patterns: readonly (readonly [string, string])[], wave: number | null): Finding;
46
75
  /**
47
- * The report as findings. One collision is one finding, placed on the later
48
- * brief of the pair, which is usually the one still being written.
76
+ * The report as findings. One pair of briefs is one finding, placed on the
77
+ * later brief of the pair, which is usually the one still being written.
49
78
  */
50
79
  export declare function collisionFindings(corpus: Corpus, report: CollisionReport): Finding[];
80
+ /** A brief with no scope, which nothing can be proved apart from. */
81
+ export declare function unscopedFinding(severity: Severity, brief: Brief, others: string): Finding;