pantheon-opencode 2.0.0-beta.4 → 2.0.0-beta.6

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.
@@ -0,0 +1,345 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * changelog-format.mjs — canonical CHANGELOG/release-body format validator
4
+ *
5
+ * The canonical section format (docs/RELEASING.md) is the hybrid: curated
6
+ * `### 🆕 What's New` highlights on top, Keep a Changelog `### ` subsections
7
+ * in fixed order, `### ⚠️ Known Issues` / `### ✅ Closed Issues` last.
8
+ * Every GitHub release body is the verbatim extraction of its CHANGELOG
9
+ * section, so validating the section validates the release.
10
+ *
11
+ * Exports:
12
+ * CANONICAL_SECTIONS — the approved heading order (frozen).
13
+ * splitSections(text) — all `## [name]` sections in file order.
14
+ * validateSection(body, {label, allowLeadingComment}) — violation strings.
15
+ *
16
+ * Consumers: scripts/release-gates.mjs (gate e fails the release),
17
+ * scripts/docs-check-changelog.mjs (CI shift-left on maintained sections).
18
+ *
19
+ * Exit code / stdout behavior exists only for direct-run diagnostics
20
+ * (`node scripts/changelog-format.mjs <version>`); the workflow consumes the
21
+ * exported functions, not the CLI.
22
+ */
23
+
24
+ import { readFileSync } from 'node:fs'
25
+ import { dirname, join } from 'node:path'
26
+ import { fileURLToPath, pathToFileURL } from 'node:url'
27
+
28
+ const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..')
29
+
30
+ /** Approved subsection order — What's New first, Known/Closed Issues last. */
31
+ export const CANONICAL_SECTIONS = Object.freeze([
32
+ "🆕 What's New",
33
+ 'Added',
34
+ 'Changed',
35
+ 'Deprecated',
36
+ 'Removed',
37
+ 'Fixed',
38
+ 'Security',
39
+ '⚠️ Known Issues',
40
+ '✅ Closed Issues',
41
+ ])
42
+
43
+ const SECTION_INDEX = new Map(CANONICAL_SECTIONS.map((name, index) => [name, index]))
44
+
45
+ /** What's New is the TUI window contract: at most 6 bullets of ≤140 chars. */
46
+ export const MAX_WHATS_NEW_BULLETS = 6
47
+ export const MAX_WHATS_NEW_BULLET = 140
48
+ /** KaC sections allow long-wrapped bullets, but not unbounded ones. */
49
+ export const MAX_BULLET = 200
50
+
51
+ /** Added/Changed/Fixed are scope-driven: every bullet names its scope. */
52
+ const STRICT_SHAPE_SECTIONS = new Set(['Added', 'Changed', 'Fixed'])
53
+
54
+ const PLACEHOLDER_RE = /\b(?:TODO|TBD|FIXME|XXX)\b/
55
+ const HEADING_RE = /^(#{1,6}) (.+?)\s*$/
56
+ const SECTION_HEADING_RE = /^## \[([^\]]+)\]/
57
+ const BULLET_RE = /^- /
58
+ /** Strict shape: `- **scope** — text` (scoped) or `- **subject**` (unscoped),
59
+ * with the optional 💥 breaking prefix. */
60
+ const STRICT_BULLET_RE = /^- (?:💥 )?\*\*[^*]+\*\*(?: — \S|$)/
61
+ /** What's New shape: any bold lead (`- **summary**` + `:` or ` — ` detail). */
62
+ const WHATS_NEW_BULLET_RE = /^- \*\*[^*]+\*\*/
63
+ const CLOSED_ISSUE_BULLET_RE = /^- #\d+(?: - |$)/
64
+
65
+ /** Emoji-safe character count (What's New bullets contain emoji-adjacent text). */
66
+ function charCount(text) {
67
+ return [...text].length
68
+ }
69
+
70
+ /**
71
+ * Split changelog text into its `## [name]` sections, in file order.
72
+ *
73
+ * Names keep the heading spelling minus a leading `v` ("1.7.0",
74
+ * "0.1.0-beta.2", "Unreleased"). Each body is everything after the heading
75
+ * line up to the next `## [` heading, trimmed. Content outside any section
76
+ * (the file preamble) is ignored.
77
+ *
78
+ * @param {string} changelogText - full CHANGELOG.md content
79
+ * @returns {Array<{name: string, body: string}>}
80
+ */
81
+ export function splitSections(changelogText) {
82
+ const sections = []
83
+ const lines = String(changelogText).split(/\r?\n/)
84
+ let current = null // { name, lines: string[] }
85
+
86
+ const close = () => {
87
+ if (current) sections.push({ name: current.name, body: current.lines.join('\n').trim() })
88
+ current = null
89
+ }
90
+
91
+ for (const line of lines) {
92
+ const match = SECTION_HEADING_RE.exec(line)
93
+ if (match) {
94
+ close()
95
+ current = { name: match[1].replace(/^v/, ''), lines: [] }
96
+ continue
97
+ }
98
+ if (current) current.lines.push(line)
99
+ }
100
+ close()
101
+ return sections
102
+ }
103
+
104
+ // ---------------------------------------------------------------------------
105
+ // validateSection
106
+ // ---------------------------------------------------------------------------
107
+
108
+ /**
109
+ * One parsed content line inside a subsection.
110
+ * @typedef {{kind: 'bullet'|'continuation'|'prose', text: string}} Line
111
+ */
112
+
113
+ /**
114
+ * Validate one section body against the canonical format. Returns every
115
+ * violation found, each prefixed with `label`. An empty violations array
116
+ * means the body is canonical.
117
+ *
118
+ * Rules (docs/RELEASING.md "The canonical section format"):
119
+ * - only `### ` subsections from CANONICAL_SECTIONS, in order, no dupes;
120
+ * - no H1/H2/H4+ headings inside the section;
121
+ * - no content before the first `###` (leading HTML comment tolerated with
122
+ * `allowLeadingComment` — the [Unreleased] template);
123
+ * - no empty subsections;
124
+ * - What's New: ≤6 bullets, each ≤140 chars, bold summary lead;
125
+ * - Added/Changed/Fixed bullets: `- **scope** — text` (💥 prefix allowed);
126
+ * - Closed Issues bullets: `- #N - subject`;
127
+ * - no bullet over 200 chars (continuations included);
128
+ * - no TODO/TBD/FIXME/XXX placeholders.
129
+ *
130
+ * @param {string} body - section body (no `## [` heading line)
131
+ * @param {{label?: string, allowLeadingComment?: boolean}} [options]
132
+ * @returns {string[]}
133
+ */
134
+ export function validateSection(body, options = {}) {
135
+ const { label = 'section', allowLeadingComment = false } = options
136
+ const violations = []
137
+ const fail = (message) => violations.push(`${label}: ${message}`)
138
+
139
+ if (!String(body).trim()) {
140
+ fail('section is empty')
141
+ return violations
142
+ }
143
+
144
+ const lines = String(body).split(/\r?\n/)
145
+
146
+ // Leading HTML comment (the [Unreleased] template) is skipped when allowed.
147
+ let index = 0
148
+ if (allowLeadingComment) {
149
+ while (index < lines.length && lines[index].trim() === '') index += 1
150
+ if (index < lines.length && lines[index].includes('<!--')) {
151
+ while (index < lines.length && !lines[index].includes('-->')) index += 1
152
+ if (index < lines.length) index += 1
153
+ }
154
+ }
155
+
156
+ // Heading-level tracking across the whole body.
157
+ let sawFirstH3 = false
158
+ const seen = new Map() // name -> count
159
+ let lastIndex = -1
160
+
161
+ // Subsection aggregation.
162
+ let current = null // { name, strict, closed, bullets: string[][], prose: string, raw: string, placeholderReported }
163
+ let bullet = null // string[] parts (first part keeps the "- " marker)
164
+
165
+ const flushBullet = () => {
166
+ if (current && bullet) current.bullets.push(bullet)
167
+ bullet = null
168
+ }
169
+
170
+ const closeSection = () => {
171
+ flushBullet()
172
+ if (!current) return
173
+ if (current.bullets.length === 0 && current.prose.trim() === '') {
174
+ fail(`"${current.name}" subsection is empty`)
175
+ }
176
+ // Placeholders are checked on the raw content: strict-section prose is
177
+ // already a shape violation, but naming the placeholder is the useful half.
178
+ if (PLACEHOLDER_RE.test(current.raw) && !current.placeholderReported) {
179
+ current.placeholderReported = true
180
+ fail(`placeholder marker (TODO/TBD/FIXME/XXX) in "${current.name}"`)
181
+ }
182
+ if (current.name === "🆕 What's New") {
183
+ if (current.bullets.length > MAX_WHATS_NEW_BULLETS) {
184
+ fail(`What's New has ${current.bullets.length} bullets (max ${MAX_WHATS_NEW_BULLETS})`)
185
+ }
186
+ for (const parts of current.bullets) {
187
+ const text = parts.join(' ').replace(/^- /, '')
188
+ if (!WHATS_NEW_BULLET_RE.test(parts[0])) {
189
+ fail("What's New bullet must open with a bold summary (**...**)")
190
+ }
191
+ if (charCount(text) > MAX_WHATS_NEW_BULLET) {
192
+ fail(`What's New bullet is ${charCount(text)} chars (max ${MAX_WHATS_NEW_BULLET})`)
193
+ }
194
+ }
195
+ } else if (current.strict) {
196
+ for (const parts of current.bullets) {
197
+ if (!STRICT_BULLET_RE.test(parts[0])) {
198
+ fail(
199
+ `"${current.name}" bullet must open with a bold scope (- **scope** — text / - **subject**): ${parts[0].slice(0, 60)}`,
200
+ )
201
+ }
202
+ }
203
+ } else if (current.closed) {
204
+ for (const parts of current.bullets) {
205
+ const text = parts.join(' ')
206
+ if (!CLOSED_ISSUE_BULLET_RE.test(text.trimEnd())) {
207
+ fail(`"${current.name}" bullet must match the - #N - subject shape: ${text.slice(0, 60)}`)
208
+ }
209
+ }
210
+ }
211
+ for (const parts of current.bullets) {
212
+ const text = parts.join(' ').replace(/^- /, '')
213
+ if (charCount(text) > MAX_BULLET) {
214
+ fail(`bullet is ${charCount(text)} chars (max ${MAX_BULLET}): ${text.slice(0, 60)}…`)
215
+ }
216
+ }
217
+ current = null
218
+ }
219
+
220
+ const openSection = (name) => {
221
+ closeSection()
222
+ seen.set(name, (seen.get(name) ?? 0) + 1)
223
+ if (!SECTION_INDEX.has(name)) {
224
+ fail(`H3 "${name}" is not in the canonical set (${CANONICAL_SECTIONS.join(', ')})`)
225
+ } else {
226
+ const index = SECTION_INDEX.get(name)
227
+ if (seen.get(name) > 1) {
228
+ fail(`H3 "${name}" is duplicated`)
229
+ } else if (lastIndex !== -1 && index <= lastIndex) {
230
+ fail(
231
+ `H3 "${name}" is out of canonical order (must follow "${CANONICAL_SECTIONS[lastIndex]}")`,
232
+ )
233
+ }
234
+ lastIndex = index
235
+ }
236
+ sawFirstH3 = true
237
+ current = {
238
+ name,
239
+ strict: STRICT_SHAPE_SECTIONS.has(name),
240
+ closed: name === '✅ Closed Issues',
241
+ bullets: [],
242
+ prose: '',
243
+ raw: '',
244
+ placeholderReported: false,
245
+ }
246
+ }
247
+
248
+ for (; index < lines.length; index += 1) {
249
+ const line = lines[index]
250
+ const trimmed = line.trim()
251
+
252
+ if (trimmed === '') {
253
+ flushBullet()
254
+ continue
255
+ }
256
+
257
+ const heading = HEADING_RE.exec(line)
258
+ if (heading) {
259
+ const level = heading[1].length
260
+ if (level === 3) {
261
+ openSection(heading[2].trim())
262
+ } else {
263
+ fail(`H${level} inside the section (only ### subsections are allowed): ${trimmed}`)
264
+ }
265
+ continue
266
+ }
267
+
268
+ if (!sawFirstH3) {
269
+ fail(`content before the first ### heading: ${trimmed.slice(0, 60)}`)
270
+ // Report once, then keep scanning for headings without spamming.
271
+ while (index + 1 < lines.length && !HEADING_RE.test(lines[index + 1])) index += 1
272
+ continue
273
+ }
274
+
275
+ if (!current) continue // heading already reported; nothing to attach content to
276
+
277
+ if (BULLET_RE.test(trimmed)) {
278
+ flushBullet()
279
+ bullet = [trimmed]
280
+ current.raw += ` ${trimmed}`
281
+ continue
282
+ }
283
+ if (bullet) {
284
+ bullet.push(trimmed)
285
+ current.raw += ` ${trimmed}`
286
+ continue
287
+ }
288
+ // Prose paragraph in a strict section is a shape violation; loose
289
+ // sections (Deprecated/Removed/Security/Known Issues) tolerate it.
290
+ if (current.strict) {
291
+ fail(
292
+ `"${current.name}" content must be bullets (- **scope** — text): ${trimmed.slice(0, 60)}`,
293
+ )
294
+ current.raw += ` ${trimmed}`
295
+ } else {
296
+ current.prose += ` ${trimmed}`
297
+ current.raw += ` ${trimmed}`
298
+ }
299
+ }
300
+ closeSection()
301
+
302
+ return violations
303
+ }
304
+
305
+ // ---------------------------------------------------------------------------
306
+ // CLI (diagnostics only — consumers import the functions above)
307
+ // ---------------------------------------------------------------------------
308
+
309
+ const isDirectRun = process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href
310
+
311
+ if (isDirectRun) {
312
+ const version = process.argv[2]
313
+ const changelogPath =
314
+ process.argv[4] && process.argv[3] === '--changelog'
315
+ ? process.argv[4]
316
+ : join(ROOT, 'CHANGELOG.md')
317
+ if (!version) {
318
+ console.error('Usage: node scripts/changelog-format.mjs <version> [--changelog <path>]')
319
+ process.exitCode = 2
320
+ } else {
321
+ let text
322
+ try {
323
+ text = readFileSync(changelogPath, 'utf-8')
324
+ } catch {
325
+ console.error(`changelog-format: cannot read ${changelogPath}`)
326
+ process.exitCode = 1
327
+ }
328
+ if (text !== undefined) {
329
+ const section = splitSections(text).find((s) => s.name === version.replace(/^v/, ''))
330
+ if (!section) {
331
+ console.error(`changelog-format: section [${version}] not found in ${changelogPath}`)
332
+ process.exitCode = 1
333
+ } else {
334
+ const violations = validateSection(section.body, { label: `v${section.name}` })
335
+ if (violations.length === 0) {
336
+ console.log(`changelog-format: [${section.name}] is canonical.`)
337
+ } else {
338
+ for (const violation of violations) console.error(violation)
339
+ console.error(`changelog-format: ${violations.length} violation(s) in [${section.name}].`)
340
+ process.exitCode = 1
341
+ }
342
+ }
343
+ }
344
+ }
345
+ }
@@ -7,16 +7,11 @@
7
7
 
8
8
  const UNRELEASED_TEMPLATE = `
9
9
 
10
- <!-- Add new changes here. Running \`node scripts/versioning.mjs apply\` will
11
- move this section to a versioned entry and reset the template below. -->
12
-
13
- ## 🆕 What's New
14
-
15
- ## 🐞 Fixed
16
-
17
- ## ⚠️ Known Issues
18
-
19
- ## ✅ Closed Issues
10
+ <!-- Add new changes here.
11
+ Canonical sections (docs/RELEASING.md): ### 🆕 What's New (curated highlights, ≤6 bullets ≤140 chars) →
12
+ ### Added / Changed / Deprecated / Removed / Fixed / Security → ### ⚠️ Known Issues / ### ✅ Closed Issues.
13
+ \`node scripts/versioning.mjs apply --notes\` pre-fills the generated sections from conventional commits.
14
+ Running apply will move this section to a versioned entry and reset the template below. -->
20
15
  `
21
16
 
22
17
  const TEMPLATE_COMMENT = /<!-- Add new changes here\.[\s\S]*?reset the template below\. -->/g
@@ -4,28 +4,27 @@
4
4
  *
5
5
  * Fails on:
6
6
  * - a version heading with the wrong shape;
7
- * - an H3 outside {Added, Changed, Deprecated, Removed, Fixed, Security}
8
- * inside the maintained sections ([Unreleased] and the newest stable
9
- * version section);
10
- * - a bullet over 200 characters (including continuation lines) in those
11
- * sections;
12
- * - an empty subsection under [Unreleased];
13
7
  * - any emoji H2 except the generated `🆕 What's New` and `🐞 Fixed` headings;
14
- * - a missing Deprecated or Removed block in the newest stable version.
8
+ * - a MAINTAINED section ([Unreleased] or the newest stable version) that
9
+ * violates the canonical section format — allowed H3 set and order, the
10
+ * What's New window contract (≤6 bullets, ≤140 chars, bold lead),
11
+ * bullet shapes, empty subsections, and placeholders. The rules live in
12
+ * scripts/changelog-format.mjs, shared with the release gate, so CI
13
+ * catches at PR time exactly what the release would fail on.
15
14
  *
16
15
  * Historical sections are archived records: only their version-heading shape
17
- * and the emoji-H2 rule are enforced. The 200-character and H3 rules apply to
18
- * the maintained sections, where the new record is authored.
16
+ * and the emoji-H2 rule are enforced.
19
17
  */
20
18
 
21
19
  import { readFileSync } from 'node:fs'
22
20
  import { dirname, join } from 'node:path'
23
21
  import { fileURLToPath } from 'node:url'
24
22
 
23
+ import { extractSection } from './changelog-extract.mjs'
24
+ import { splitSections, validateSection } from './changelog-format.mjs'
25
+
25
26
  const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..')
26
27
  const CHANGELOG = process.argv[2] ? process.argv[2] : join(ROOT, 'CHANGELOG.md')
27
- const MAX_BULLET = 200
28
- const ALLOWED_H3 = new Set(['Added', 'Changed', 'Deprecated', 'Removed', 'Fixed', 'Security'])
29
28
  const EMOJI_H2 =
30
29
  /^##\s+(?:\p{Extended_Pictographic}|\p{Regional_Indicator}{2}|[#*0-9]\uFE0F?\u20E3)/u
31
30
  const ALLOWED_GENERATED_H2 = /^##\s+(?:🆕 What's New|🐞 Fixed)\s*$/
@@ -37,10 +36,6 @@ const HISTORICAL_VERSION_HEADING =
37
36
  const UNRELEASED_HEADING = /^## \[Unreleased\]$/
38
37
  const LOOKS_LIKE_VERSION = /^##\s+(?:\[?v?\d+\.\d+)/
39
38
 
40
- function charCount(text) {
41
- return [...text].length
42
- }
43
-
44
39
  function newestStableVersion(lines) {
45
40
  for (const line of lines) {
46
41
  const match = STABLE_VERSION_HEADING.exec(line)
@@ -50,9 +45,9 @@ function newestStableVersion(lines) {
50
45
  }
51
46
 
52
47
  function main() {
53
- const lines = readFileSync(CHANGELOG, 'utf8').split(/\r?\n/)
48
+ const text = readFileSync(CHANGELOG, 'utf8')
49
+ const lines = text.split(/\r?\n/)
54
50
  const findings = []
55
- const maintainedH3 = new Map() // section name -> Map<h3, empty>
56
51
  const newest = newestStableVersion(lines)
57
52
 
58
53
  if (newest === null) {
@@ -61,136 +56,40 @@ function main() {
61
56
  return
62
57
  }
63
58
 
64
- let section = null // { name, maintained }
65
- let currentH3 = null
66
- let currentH3Empty = false
67
- let currentBullet = null // { lineNo, parts: string[] }
68
- let inComment = false
69
-
70
- const headingsFor = (name) => {
71
- if (!maintainedH3.has(name)) maintainedH3.set(name, new Map())
72
- return maintainedH3.get(name)
73
- }
74
-
75
- const flushBullet = () => {
76
- if (currentBullet === null) return
77
- if (section?.maintained) {
78
- const text = currentBullet.parts.join(' ')
79
- if (charCount(text) > MAX_BULLET) {
80
- findings.push(
81
- `${currentBullet.lineNo}: bullet is ${charCount(text)} chars (max ${MAX_BULLET}): ${text.slice(0, 60)}…`,
82
- )
83
- }
84
- }
85
- currentBullet = null
86
- }
87
-
88
- const commitH3 = () => {
89
- if (section?.maintained && currentH3 !== null) {
90
- headingsFor(section.name).set(currentH3, currentH3Empty)
91
- }
92
- currentH3 = null
93
- currentH3Empty = false
94
- }
95
-
96
- const closeSection = () => {
97
- flushBullet()
98
- commitH3()
99
- section = null
100
- }
101
-
59
+ // File-level pass: heading shapes and the emoji-H2 rule (all sections).
102
60
  for (let i = 0; i < lines.length; i += 1) {
103
61
  const line = lines[i]
104
62
  const lineNo = i + 1
63
+ if (!line.startsWith('## ')) continue
105
64
 
106
- if (line.startsWith('## ')) {
107
- closeSection()
108
-
109
- if (EMOJI_H2.test(line) && !ALLOWED_GENERATED_H2.test(line)) {
110
- findings.push(`${lineNo}: emoji H2 is not allowed (${line.trim()})`)
111
- continue
112
- }
113
- if (UNRELEASED_HEADING.test(line)) {
114
- section = { name: 'Unreleased', maintained: true }
115
- headingsFor('Unreleased')
116
- continue
117
- }
118
- const stable = STABLE_VERSION_HEADING.exec(line)
119
- if (stable) {
120
- const name = stable[1]
121
- section = { name, maintained: name === newest }
122
- if (section.maintained) headingsFor(name)
123
- continue
124
- }
125
- if (HISTORICAL_VERSION_HEADING.test(line)) {
126
- const name = line.slice(4, line.indexOf(']')).replace(/^v/, '')
127
- section = { name, maintained: false }
128
- continue
129
- }
130
- if (line.startsWith('## [') || LOOKS_LIKE_VERSION.test(line)) {
131
- findings.push(`${lineNo}: version heading has the wrong shape (${line.trim()})`)
132
- }
133
- // A plain legacy H2 (historical sections) or the wrong-shape heading.
65
+ if (EMOJI_H2.test(line) && !ALLOWED_GENERATED_H2.test(line)) {
66
+ findings.push(`${lineNo}: emoji H2 is not allowed (${line.trim()})`)
134
67
  continue
135
68
  }
136
-
137
- if (line.startsWith('### ')) {
138
- if (section?.maintained) {
139
- flushBullet()
140
- commitH3()
141
- const name = line.slice(4).trim()
142
- currentH3 = name
143
- currentH3Empty = true
144
- if (!ALLOWED_H3.has(name)) {
145
- findings.push(`${lineNo}: H3 "${name}" is not in the allowed set`)
146
- }
147
- }
148
- continue
69
+ if (UNRELEASED_HEADING.test(line)) continue
70
+ if (STABLE_VERSION_HEADING.test(line)) continue
71
+ if (HISTORICAL_VERSION_HEADING.test(line)) continue
72
+ if (line.startsWith('## [') || LOOKS_LIKE_VERSION.test(line)) {
73
+ findings.push(`${lineNo}: version heading has the wrong shape (${line.trim()})`)
149
74
  }
150
-
151
- if (!section?.maintained) continue
152
-
153
- if (inComment) {
154
- if (line.includes('-->')) inComment = false
155
- continue
156
- }
157
- if (line.includes('<!--')) {
158
- if (!line.includes('-->')) inComment = true
159
- continue
160
- }
161
-
162
- if (line.trim() === '') {
163
- flushBullet()
164
- continue
165
- }
166
-
167
- if (line.startsWith('- ')) {
168
- flushBullet()
169
- currentBullet = { lineNo, parts: [line] }
170
- if (currentH3 !== null) currentH3Empty = false
171
- continue
172
- }
173
-
174
- if (currentBullet !== null) {
175
- currentBullet.parts.push(line.trim())
176
- if (currentH3 !== null) currentH3Empty = false
177
- continue
178
- }
179
-
180
- if (currentH3 !== null) currentH3Empty = false
181
75
  }
182
- closeSection()
183
76
 
184
- for (const [heading, empty] of headingsFor('Unreleased')) {
185
- if (empty) findings.push(`[Unreleased] has an empty "${heading}" subsection`)
186
- }
187
-
188
- const newestHeadings = headingsFor(newest)
189
- if (!newestHeadings.has('Deprecated')) {
190
- findings.push(`[v${newest}] is missing the Deprecated block`)
77
+ // Maintained sections: the canonical format (shared with the release gate).
78
+ // An empty [Unreleased] is legitimate — nothing is pending yet.
79
+ const unreleased = splitSections(text).find((section) => section.name === 'Unreleased')
80
+ if (unreleased?.body.trim()) {
81
+ for (const violation of validateSection(unreleased.body, {
82
+ label: '[Unreleased]',
83
+ allowLeadingComment: true,
84
+ })) {
85
+ findings.push(violation)
86
+ }
191
87
  }
192
- if (!newestHeadings.has('Removed')) {
193
- findings.push(`[v${newest}] is missing the Removed block`)
88
+ const newestBody = extractSection(text, newest)
89
+ if (newestBody?.found && newestBody.body) {
90
+ for (const violation of validateSection(newestBody.body, { label: `[v${newest}]` })) {
91
+ findings.push(violation)
92
+ }
194
93
  }
195
94
 
196
95
  if (findings.length === 0) {