pantheon-opencode 1.6.0-beta.8 → 1.6.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 (141) hide show
  1. package/AGENTS.global.md +118 -0
  2. package/AGENTS.md +18 -168
  3. package/CHANGELOG.md +126 -346
  4. package/README.md +83 -608
  5. package/README.pt-BR.md +120 -345
  6. package/bin/pantheon-init.mjs +366 -132
  7. package/commands/pantheon-audit.md +7 -1
  8. package/commands/pantheon-consolidate.md +1 -1
  9. package/commands/pantheon-deepwork.md +14 -3
  10. package/commands/pantheon-focus.md +17 -0
  11. package/commands/pantheon-vision.md +61 -12
  12. package/package.json +19 -11
  13. package/plugin.json +1 -1
  14. package/pyproject.toml +6 -2
  15. package/scripts/_pantheon_paths.py +24 -0
  16. package/scripts/build-agents-md.mjs +368 -69
  17. package/scripts/changelog-merge.mjs +161 -0
  18. package/scripts/check-plugin-v2-coverage.mjs +11 -8
  19. package/scripts/docs-check-changelog.mjs +204 -0
  20. package/scripts/docs-link-check.mjs +314 -0
  21. package/scripts/docs-media.mjs +157 -0
  22. package/scripts/doctor.mjs +828 -40
  23. package/scripts/install/agents-md.mjs +2 -2
  24. package/scripts/install/backup.mjs +648 -0
  25. package/scripts/install/cli-ui.mjs +303 -72
  26. package/scripts/install/component-selection.mjs +61 -0
  27. package/scripts/install/config-migration.mjs +583 -27
  28. package/scripts/install/exit-codes.mjs +26 -0
  29. package/scripts/install/file-inventory.mjs +555 -0
  30. package/scripts/install/health-check.mjs +31 -25
  31. package/scripts/install/interactive.mjs +78 -383
  32. package/scripts/install/migrate.mjs +49 -25
  33. package/scripts/install/model-picker.mjs +218 -250
  34. package/scripts/install/opencode-version.mjs +83 -21
  35. package/scripts/install/opencode.mjs +1465 -180
  36. package/scripts/install/plan-artifact.mjs +517 -0
  37. package/scripts/install/plan.mjs +475 -0
  38. package/scripts/install/plugin.mjs +251 -30
  39. package/scripts/install/prompt-result.mjs +2 -0
  40. package/scripts/install/shared.mjs +256 -99
  41. package/scripts/install/state.mjs +63 -8
  42. package/scripts/install/strings.mjs +60 -4
  43. package/scripts/install/venv.mjs +90 -47
  44. package/scripts/install/verify.mjs +128 -0
  45. package/scripts/install/vision-prompt.mjs +173 -0
  46. package/scripts/install-mcp.mjs +2 -2
  47. package/scripts/manifest-inventory.mjs +49 -3
  48. package/scripts/mcp_persistence.py +1535 -1050
  49. package/scripts/memory_mcp.py +12 -843
  50. package/scripts/node-engine-policy.mjs +85 -0
  51. package/scripts/package-evidence.mjs +10 -2
  52. package/scripts/postinstall.mjs +26 -26
  53. package/scripts/probe-pantheon-cost.mjs +118 -19
  54. package/scripts/prune.mjs +9 -3
  55. package/scripts/reconcile.mjs +325 -0
  56. package/scripts/release-gates.mjs +682 -0
  57. package/scripts/restore.mjs +222 -0
  58. package/scripts/run-node-tests.mjs +24 -8
  59. package/scripts/sync-artifacts.mjs +20 -7
  60. package/scripts/sync-tui.mjs +29 -4
  61. package/scripts/test-opencode-v2-sandbox.sh +36 -123
  62. package/scripts/uninstall.mjs +369 -34
  63. package/scripts/update.mjs +164 -0
  64. package/scripts/validate-node-engine-policy.mjs +13 -0
  65. package/scripts/version-check.mjs +34 -1
  66. package/scripts/versioning.mjs +23 -3
  67. package/scripts/vision-status.mjs +682 -0
  68. package/skills-lock.json +8 -8
  69. package/src/agents/aphrodite.md +13 -10
  70. package/src/agents/apollo.md +4 -5
  71. package/src/agents/athena.md +74 -46
  72. package/src/agents/demeter.md +10 -7
  73. package/src/agents/gaia.md +0 -1
  74. package/src/agents/hephaestus.md +4 -3
  75. package/src/agents/hermes.md +10 -9
  76. package/src/agents/iris.md +6 -1
  77. package/src/agents/mnemosyne.md +14 -15
  78. package/src/agents/nyx.md +4 -4
  79. package/src/agents/prometheus.md +12 -11
  80. package/src/agents/talos.md +6 -0
  81. package/src/agents/zeus.md +84 -56
  82. package/src/instructions/agent-return-format.instructions.md +12 -41
  83. package/src/instructions/memory-protocol.instructions.md +5 -11
  84. package/src/instructions/test-economy.instructions.md +12 -0
  85. package/src/instructions/yagni.instructions.md +6 -15
  86. package/src/instructions/zeus-anti-stall.instructions.md +6 -6
  87. package/src/instructions/zeus-communication-rules.instructions.md +6 -6
  88. package/src/instructions/zeus-council-synthesis.instructions.md +11 -12
  89. package/src/instructions/zeus-memory-operations.instructions.md +13 -7
  90. package/src/instructions/zeus-timeout-retry.instructions.md +36 -10
  91. package/src/mcp/_pantheon_paths.py +24 -0
  92. package/src/mcp/mcp_codemap_module.py +86 -18
  93. package/src/mcp/mcp_persistence.py +1535 -1050
  94. package/src/mcp/memory_mcp.py +444 -94
  95. package/src/mcp/pantheon_vision.py +285 -41
  96. package/src/mcp/requirements-mcp.txt +5 -0
  97. package/src/pantheon/context-pruner.ts +541 -0
  98. package/src/pantheon/cost-command.ts +814 -60
  99. package/src/pantheon/goal-loop.ts +11 -8
  100. package/src/pantheon/memory-context.ts +1017 -0
  101. package/src/pantheon/model-agents.ts +19 -0
  102. package/src/pantheon/model-command.ts +218 -56
  103. package/src/pantheon/model-pricing.ts +536 -0
  104. package/src/pantheon/presets.mjs +2 -0
  105. package/src/pantheon/task-result-guard.ts +50 -14
  106. package/src/pantheon/v2-bounded-read.ts +640 -0
  107. package/src/pantheon/v2-delegation-enforce.ts +133 -6
  108. package/src/pantheon/v2-execute-after.ts +135 -24
  109. package/src/pantheon/v2-model-overrides.ts +275 -0
  110. package/src/pantheon/v2-tools.ts +89 -35
  111. package/src/pantheon/v2-unsupported.mjs +2 -3
  112. package/src/pantheon/v2-vision.ts +622 -0
  113. package/src/pantheon/vision-local.ts +531 -0
  114. package/src/pantheon/vision.ts +1160 -115
  115. package/src/plugin-v2.ts +654 -162
  116. package/src/plugin.ts +15 -11
  117. package/src/plugins/tui/dist/tui-v2.d.ts +1036 -0
  118. package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -0
  119. package/src/plugins/tui/dist/tui-v2.js +3808 -0
  120. package/src/plugins/tui/dist/tui-v2.js.map +1 -0
  121. package/src/plugins/tui/dist/tui.js +4 -4
  122. package/src/plugins/tui/index-v2.ts +6 -0
  123. package/src/plugins/tui/package-lock.json +5416 -1297
  124. package/src/plugins/tui/package.json +14 -10
  125. package/src/plugins/tui/src/index-v2.tsx +4372 -0
  126. package/src/plugins/tui/src/index.tsx +3 -3
  127. package/src/plugins/tui/src/opencode-v2.d.ts +13 -0
  128. package/src/plugins/tui/tsconfig.typecheck.json +5 -0
  129. package/src/plugins/tui/tsdown.config.ts +2 -2
  130. package/src/plugins/tui/tui-v2.ts +2 -0
  131. package/src/plugins/tui/tui.ts +3 -0
  132. package/src/routing.yml +50 -5
  133. package/src/skills/agent-coordination/SKILL.md +7 -2
  134. package/src/skills/artifact-management/SKILL.md +5 -1
  135. package/src/skills/auto-continue/SKILL.md +14 -6
  136. package/src/skills/codemap/SKILL.md +1 -1
  137. package/src/skills/memory-bank/SKILL.md +21 -13
  138. package/src/skills/session-goal/SKILL.md +14 -15
  139. package/src/skills/spec-driven-development/SKILL.md +3 -1
  140. package/src/skills/worktrees/SKILL.md +30 -11
  141. package/scripts/probe-context-rehydrate.mjs +0 -263
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Merge pending [Unreleased] notes into an already-promoted version section.
3
+ * This supports release candidates whose versioned changelog section exists
4
+ * before the final beta changes are ready, without creating a duplicate entry
5
+ * or advancing the package version.
6
+ */
7
+
8
+ const UNRELEASED_TEMPLATE = `
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
20
+ `
21
+
22
+ const TEMPLATE_COMMENT = /<!-- Add new changes here\.[\s\S]*?reset the template below\. -->/g
23
+ const ESCAPED_TEMPLATE_COMMENT =
24
+ /&lt;!-- Add new changes here\.[\s\S]*?reset the template below\. --&gt;/g
25
+
26
+ function escapeRegExp(value) {
27
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
28
+ }
29
+
30
+ function findSection(lines, heading) {
31
+ const matches = []
32
+ for (let index = 0; index < lines.length; index += 1) {
33
+ if (lines[index] === heading) matches.push(index)
34
+ }
35
+ if (matches.length > 1) throw new Error(`CHANGELOG.md has duplicate section: ${heading}`)
36
+ if (matches.length === 0) return null
37
+ const start = matches[0]
38
+ let end = start + 1
39
+ while (end < lines.length && !/^## \[/.test(lines[end])) end += 1
40
+ return { start, end }
41
+ }
42
+
43
+ function parseBody(body) {
44
+ const withoutComments = body.replace(TEMPLATE_COMMENT, '').replace(ESCAPED_TEMPLATE_COMMENT, '')
45
+ const lines = withoutComments.split('\n')
46
+ const preamble = []
47
+ const sections = new Map()
48
+ let current = null
49
+
50
+ for (const line of lines) {
51
+ const heading = /^## (.+)$/.exec(line)
52
+ if (heading) {
53
+ current = heading[1]
54
+ if (!sections.has(current)) sections.set(current, [])
55
+ continue
56
+ }
57
+ if (current === null) preamble.push(line)
58
+ else sections.get(current).push(line)
59
+ }
60
+
61
+ const meaningful = (items) => items.join('\n').trim().length > 0
62
+ for (const [heading, content] of sections) {
63
+ if (!meaningful(content)) sections.delete(heading)
64
+ else {
65
+ sections.set(
66
+ heading,
67
+ content
68
+ .join('\n')
69
+ .replace(/\n{3,}/g, '\n\n')
70
+ .trim()
71
+ .split('\n'),
72
+ )
73
+ }
74
+ }
75
+ return {
76
+ preamble: preamble.join('\n').trim(),
77
+ sections,
78
+ }
79
+ }
80
+
81
+ function mergeBodies(existingBody, pendingBody) {
82
+ const existing = parseBody(existingBody)
83
+ const pending = parseBody(pendingBody)
84
+ const preamble = [existing.preamble, pending.preamble].filter(Boolean).join('\n\n')
85
+ const sections = new Map(existing.sections)
86
+
87
+ for (const [heading, content] of pending.sections) {
88
+ if (!sections.has(heading)) {
89
+ sections.set(heading, content)
90
+ continue
91
+ }
92
+ const previous = sections.get(heading)
93
+ const previousText = previous.join('\n').trim()
94
+ const pendingText = content.join('\n').trim()
95
+ sections.set(heading, [`${previousText}\n\n${pendingText}`])
96
+ }
97
+
98
+ const rendered = []
99
+ if (preamble) rendered.push(preamble)
100
+ for (const [heading, content] of sections) {
101
+ if (rendered.length > 0) rendered.push('')
102
+ rendered.push(`## ${heading}`, '', content.join('\n').trim())
103
+ }
104
+ return rendered.join('\n').trim()
105
+ }
106
+
107
+ /**
108
+ * Merge [Unreleased] into an existing exact version heading, preserving its
109
+ * date and existing notes. Returns null when the version section does not yet
110
+ * exist so the caller can use the normal promotion path.
111
+ *
112
+ * @param {string} changelogText complete changelog
113
+ * @param {string} version semantic version, with or without a leading v
114
+ * @returns {{changed: boolean, content: string}|null}
115
+ */
116
+ export function mergeUnreleasedIntoVersion(changelogText, version) {
117
+ const normalized = String(version).trim().replace(/^v/i, '')
118
+ if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(normalized)) {
119
+ throw new Error(`invalid changelog version: ${version}`)
120
+ }
121
+
122
+ const lines = changelogText.split('\n')
123
+ const unreleased = findSection(lines, '## [Unreleased]')
124
+ if (!unreleased) throw new Error('CHANGELOG.md is missing the [Unreleased] section')
125
+
126
+ const escaped = escapeRegExp(normalized)
127
+ const targetPattern = new RegExp(`^## \\[v?${escaped}\\](?: - \\d{4}-\\d{2}-\\d{2})?$`)
128
+ const targetMatches = []
129
+ for (let index = 0; index < lines.length; index += 1) {
130
+ if (targetPattern.test(lines[index])) targetMatches.push(index)
131
+ }
132
+ if (targetMatches.length > 1) {
133
+ throw new Error(`CHANGELOG.md has duplicate version sections: ${normalized}`)
134
+ }
135
+ if (targetMatches.length === 0) return null
136
+
137
+ const target = findSection(lines, lines[targetMatches[0]])
138
+ if (!target) throw new Error(`CHANGELOG.md is missing version section: ${normalized}`)
139
+
140
+ const pendingBody = lines.slice(unreleased.start + 1, unreleased.end).join('\n')
141
+ const existingBody = lines.slice(target.start + 1, target.end).join('\n')
142
+ const mergedBody = mergeBodies(existingBody, pendingBody)
143
+ const afterTarget = [lines[target.start], '', mergedBody].join('\n').trimEnd()
144
+ const updatedLines = [
145
+ ...lines.slice(0, target.start),
146
+ afterTarget,
147
+ ...(target.end < lines.length ? [''] : []),
148
+ ...lines.slice(target.end),
149
+ ]
150
+ .join('\n')
151
+ .split('\n')
152
+ const updatedUnreleased = findSection(updatedLines, '## [Unreleased]')
153
+ if (!updatedUnreleased) throw new Error('merged CHANGELOG.md lost the [Unreleased] section')
154
+ const content = [
155
+ ...updatedLines.slice(0, updatedUnreleased.start),
156
+ `## [Unreleased]${UNRELEASED_TEMPLATE}`,
157
+ ...updatedLines.slice(updatedUnreleased.end),
158
+ ].join('\n')
159
+
160
+ return { changed: content !== changelogText, content }
161
+ }
@@ -3,8 +3,8 @@ import { mkdtempSync, readdirSync, readFileSync, rmSync } from 'node:fs'
3
3
  import { tmpdir } from 'node:os'
4
4
  import { dirname, join, resolve } from 'node:path'
5
5
  import { fileURLToPath, pathToFileURL } from 'node:url'
6
+ import { isSupportedNodeVersion, MIN_SUPPORTED_NODE_VERSION } from './node-engine-policy.mjs'
6
7
 
7
- export const REQUIRED_NODE_VERSION = 'v24.15.0'
8
8
  export const LINE_THRESHOLD_NUMERATOR = 4
9
9
  export const LINE_THRESHOLD_DENOMINATOR = 5
10
10
 
@@ -103,13 +103,13 @@ export function parseTargetLcov(report, repoRoot, targetPath) {
103
103
  const found = integerField(exactlyOneField(lines, 'LF'), 'LF', 1)
104
104
  const hit = integerField(exactlyOneField(lines, 'LH'), 'LH', 0)
105
105
  if (hit > found) throw new Error(`LH ${hit} exceeds LF ${found}`)
106
- if (found !== lineRecords.size) {
107
- throw new Error(`LF ${found} does not equal ${lineRecords.size} unique DA entries`)
106
+ if (lineRecords.size > found) {
107
+ throw new Error(`LF ${found} is less than ${lineRecords.size} unique DA entries`)
108
108
  }
109
109
 
110
110
  const coveredRecords = [...lineRecords.values()].filter((count) => count > 0).length
111
- if (hit !== coveredRecords) {
112
- throw new Error(`LH ${hit} does not equal ${coveredRecords} covered DA entries`)
111
+ if (hit < coveredRecords) {
112
+ throw new Error(`LH ${hit} is less than ${coveredRecords} covered DA entries`)
113
113
  }
114
114
 
115
115
  return {
@@ -135,16 +135,19 @@ function formatMetric(metric) {
135
135
 
136
136
  function listTypeScriptTests(repoRoot) {
137
137
  const directory = join(repoRoot, 'tests', 'pantheon')
138
+ // This is the only TypeScript test file that imports src/plugin-v2.ts. Its
139
+ // isolated measured coverage matches the full-suite baseline; `test:ts`
140
+ // remains the separate full TypeScript suite.
138
141
  return readdirSync(directory)
139
- .filter((file) => file.endsWith('.test.ts'))
142
+ .filter((file) => file === 'plugin-v2-contract.test.ts')
140
143
  .sort()
141
144
  .map((file) => join(directory, file))
142
145
  }
143
146
 
144
147
  function runCoverage() {
145
- if (process.version !== REQUIRED_NODE_VERSION) {
148
+ if (!isSupportedNodeVersion(process.versions.node)) {
146
149
  throw new Error(
147
- `plugin-v2 coverage requires Node ${REQUIRED_NODE_VERSION}; got ${process.version}`,
150
+ `plugin-v2 coverage requires Node.js >= ${MIN_SUPPORTED_NODE_VERSION}; got ${process.version}`,
148
151
  )
149
152
  }
150
153
 
@@ -0,0 +1,204 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Keep a Changelog structural check for CHANGELOG.md.
4
+ *
5
+ * Fails on:
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
+ * - any `## 🆕|🐞|⚠️|✅` H2 anywhere;
14
+ * - a missing Deprecated or Removed block in the newest stable version.
15
+ *
16
+ * 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.
19
+ */
20
+
21
+ import { readFileSync } from 'node:fs'
22
+ import { dirname, join } from 'node:path'
23
+ import { fileURLToPath } from 'node:url'
24
+
25
+ const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..')
26
+ 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
+ const EMOJI_H2 = /^##\s+(?:🆕|🐞|⚠️|✅)/
30
+ const STABLE_VERSION_HEADING = /^## \[v?(\d+\.\d+\.\d+)\] - \d{4}-\d{2}-\d{2}$/
31
+ // Historical headings may carry a pre-release suffix, a month-only date, or a
32
+ // "(candidate)" marker.
33
+ const HISTORICAL_VERSION_HEADING =
34
+ /^## \[v?\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?\](?: - \d{4}-\d{2}(?:-\d{2})?)?(?: \(candidate\))?$/
35
+ const UNRELEASED_HEADING = /^## \[Unreleased\]$/
36
+ const LOOKS_LIKE_VERSION = /^##\s+(?:\[?v?\d+\.\d+)/
37
+
38
+ function charCount(text) {
39
+ return [...text].length
40
+ }
41
+
42
+ function newestStableVersion(lines) {
43
+ for (const line of lines) {
44
+ const match = STABLE_VERSION_HEADING.exec(line)
45
+ if (match) return match[1]
46
+ }
47
+ return null
48
+ }
49
+
50
+ function main() {
51
+ const lines = readFileSync(CHANGELOG, 'utf8').split(/\r?\n/)
52
+ const findings = []
53
+ const maintainedH3 = new Map() // section name -> Map<h3, empty>
54
+ const newest = newestStableVersion(lines)
55
+
56
+ if (newest === null) {
57
+ console.error('CHANGELOG.md: no stable version heading found')
58
+ process.exitCode = 1
59
+ return
60
+ }
61
+
62
+ let section = null // { name, maintained }
63
+ let currentH3 = null
64
+ let currentH3Empty = false
65
+ let currentBullet = null // { lineNo, parts: string[] }
66
+ let inComment = false
67
+
68
+ const headingsFor = (name) => {
69
+ if (!maintainedH3.has(name)) maintainedH3.set(name, new Map())
70
+ return maintainedH3.get(name)
71
+ }
72
+
73
+ const flushBullet = () => {
74
+ if (currentBullet === null) return
75
+ if (section?.maintained) {
76
+ const text = currentBullet.parts.join(' ')
77
+ if (charCount(text) > MAX_BULLET) {
78
+ findings.push(
79
+ `${currentBullet.lineNo}: bullet is ${charCount(text)} chars (max ${MAX_BULLET}): ${text.slice(0, 60)}…`,
80
+ )
81
+ }
82
+ }
83
+ currentBullet = null
84
+ }
85
+
86
+ const commitH3 = () => {
87
+ if (section?.maintained && currentH3 !== null) {
88
+ headingsFor(section.name).set(currentH3, currentH3Empty)
89
+ }
90
+ currentH3 = null
91
+ currentH3Empty = false
92
+ }
93
+
94
+ const closeSection = () => {
95
+ flushBullet()
96
+ commitH3()
97
+ section = null
98
+ }
99
+
100
+ for (let i = 0; i < lines.length; i += 1) {
101
+ const line = lines[i]
102
+ const lineNo = i + 1
103
+
104
+ if (line.startsWith('## ')) {
105
+ closeSection()
106
+
107
+ if (EMOJI_H2.test(line)) {
108
+ findings.push(`${lineNo}: emoji H2 is not allowed (${line.trim()})`)
109
+ continue
110
+ }
111
+ if (UNRELEASED_HEADING.test(line)) {
112
+ section = { name: 'Unreleased', maintained: true }
113
+ headingsFor('Unreleased')
114
+ continue
115
+ }
116
+ const stable = STABLE_VERSION_HEADING.exec(line)
117
+ if (stable) {
118
+ const name = stable[1]
119
+ section = { name, maintained: name === newest }
120
+ if (section.maintained) headingsFor(name)
121
+ continue
122
+ }
123
+ if (HISTORICAL_VERSION_HEADING.test(line)) {
124
+ const name = line.slice(4, line.indexOf(']')).replace(/^v/, '')
125
+ section = { name, maintained: false }
126
+ continue
127
+ }
128
+ if (line.startsWith('## [') || LOOKS_LIKE_VERSION.test(line)) {
129
+ findings.push(`${lineNo}: version heading has the wrong shape (${line.trim()})`)
130
+ }
131
+ // A plain legacy H2 (historical sections) or the wrong-shape heading.
132
+ continue
133
+ }
134
+
135
+ if (line.startsWith('### ')) {
136
+ if (section?.maintained) {
137
+ flushBullet()
138
+ commitH3()
139
+ const name = line.slice(4).trim()
140
+ currentH3 = name
141
+ currentH3Empty = true
142
+ if (!ALLOWED_H3.has(name)) {
143
+ findings.push(`${lineNo}: H3 "${name}" is not in the allowed set`)
144
+ }
145
+ }
146
+ continue
147
+ }
148
+
149
+ if (!section?.maintained) continue
150
+
151
+ if (inComment) {
152
+ if (line.includes('-->')) inComment = false
153
+ continue
154
+ }
155
+ if (line.includes('<!--')) {
156
+ if (!line.includes('-->')) inComment = true
157
+ continue
158
+ }
159
+
160
+ if (line.trim() === '') {
161
+ flushBullet()
162
+ continue
163
+ }
164
+
165
+ if (line.startsWith('- ')) {
166
+ flushBullet()
167
+ currentBullet = { lineNo, parts: [line] }
168
+ if (currentH3 !== null) currentH3Empty = false
169
+ continue
170
+ }
171
+
172
+ if (currentBullet !== null) {
173
+ currentBullet.parts.push(line.trim())
174
+ if (currentH3 !== null) currentH3Empty = false
175
+ continue
176
+ }
177
+
178
+ if (currentH3 !== null) currentH3Empty = false
179
+ }
180
+ closeSection()
181
+
182
+ for (const [heading, empty] of headingsFor('Unreleased')) {
183
+ if (empty) findings.push(`[Unreleased] has an empty "${heading}" subsection`)
184
+ }
185
+
186
+ const newestHeadings = headingsFor(newest)
187
+ if (!newestHeadings.has('Deprecated')) {
188
+ findings.push(`[v${newest}] is missing the Deprecated block`)
189
+ }
190
+ if (!newestHeadings.has('Removed')) {
191
+ findings.push(`[v${newest}] is missing the Removed block`)
192
+ }
193
+
194
+ if (findings.length === 0) {
195
+ console.log(`docs:check-changelog OK — ${lines.length} lines, no findings.`)
196
+ return
197
+ }
198
+
199
+ for (const finding of findings) console.error(`CHANGELOG.md:${finding}`)
200
+ console.error(`\ndocs:check-changelog failed — ${findings.length} finding(s).`)
201
+ process.exitCode = 1
202
+ }
203
+
204
+ main()