chore(release): add a script for accruing an Unreleased changelog note - #1523
Merged
Merged
Conversation
The release owns package.json's version and every `## [X.Y.Z]` heading, and #1515 wrote that rule down in the bump-coana skill. A rule is all it was: every caller still had to hand-build the `## [Unreleased]` block, and the one that got it wrong — Coana's release automation, which opens the bump PRs — kept costing us. v1.1.161 shipped with commit-derived notes because a hand-written heading had consumed the block the release meant to promote, and every bump PR since has needed a human fixup commit. Give callers something to call instead. `addUnreleasedEntry` finds or creates the block and the section, and rewrites a matching bullet in place so a bump that reruns updates its own line rather than stacking one per run. It reuses `unreleasedRange` and the same parsed-not-matched structure rule as `promoteChangelog`, so the writer and the reader cannot drift: markdown inside a fence stays content, and the block this writes is by construction one the release can see. It also repairs a decorated `## [Unreleased] - 2026-08-27` heading. That form is invisible to `unreleasedRange`, which matches for equality — a human wrote one on #1516 while fixing up a bump PR, and the entry under it was stranded. `scripts/release/add-unreleased.mts` exposes it to non-JS callers; the skill now runs that rather than describing the shape in prose.
Oskar Haarklou Veileborg (BarrensZeppelin)
approved these changes
Sep 1, 2026
Review: the v1.1.161 story belongs in the PR, not in three doc comments. Apply @BarrensZeppelin's suggestions verbatim.
Martin Torp (mtorp)
deleted the
martin/add-unreleased-changelog-helper
branch
September 1, 2026 07:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#1515 wrote down the rule that the release owns
package.json'sversionand every## [X.Y.Z]heading. A rule was all it was — every caller still hand-built the## [Unreleased]block from prose, and the caller that got it wrong is the one nobody here reviews: Coana's release automation, which opens theupgrading coana to version …PRs.The cost so far:
## [1.1.161]heading consumed the[Unreleased]block, sopromoteChangelogfound nothing to promote and fell back to commit-derived notes. The actual user-facing change — the Coana 15.10.25 bump — was stranded below the release heading.Nothing in CI catches it on a PR, so it fails silently each time.
Changes
addUnreleasedEntry()inchangelog.mts— the counterpart topromoteChangelog. It finds or creates the## [Unreleased]block and the### Changedsection (inSECTION_ORDERposition), and with--replacerewrites a matching bullet in place, so a bump that reruns on every upstream release updates its own line instead of stacking one per run.It reuses
unreleasedRange()and the same parsed-not-matched structure rule aspromoteChangelog, so the writer and the reader can't drift: markdown inside a fence stays content, and the block this writes is by construction one the release can see. There's a test asserting exactly that round trip.It also repairs a decorated
## [Unreleased] - 2026-08-27heading. That form is invisible tounreleasedRange(), which matches for equality — a human wrote one on #1516 while fixing up a bump PR, and the entry under it was stranded until a later bump happened to overwrite the line.scripts/release/add-unreleased.mtsexposes it to non-JS callers, in the houseisMainModule+runMain(main, SCRIPT_META)shape so it inherits--describe/--helpand the bare---refusal:/bump-coananow runs that instead of describing the shape in prose, and coana-tech/coana-package-manager#2378 switches the bot to the same call — so the human path and the bot path become one implementation, tested here.Why here and not in the caller
That Coana PR originally carried a ~60-line changelog editor embedded in a YAML
run:heredoc. Oskar Haarklou Veileborg (@BarrensZeppelin)'s review asked for this instead, and he's right: the convention belongs to this repo, the parse half is already installed here, and a helper can be unit-tested where a heredoc can't. Keeping it there also meant re-implementingh2detection with regex and losing the code-fence correctness this repo explicitly tests for.Verification
pnpm exec vitest run test/release-add-unreleased.test.mts test/release-version.test.mts test/release-bump.test.mts— 53 pass (19 new, 34 existing unaffected by theh2LineIndexes→headingLineIndexesrefactor).SECTION_ORDERplacement, in-place replace, replace scoped to its own section, decorated heading repaired, lower-cased heading, heading lookalike inside a fence, released blocks left byte-for-byte, idempotent rerun, and theaddUnreleasedEntry→promoteChangeloground trip. PlusparseArgsflags and refusals.CHANGELOG.mdonv1.x: creates the block, updates in place on a version bump, no-ops on a rerun.node scripts/check.mtspasses;tsc --noEmitclean.Note
Medium Risk
Changes release changelog write path used by automation; mistakes could still strand notes, but the change replaces error-prone hand edits with tested logic aligned to
promoteChangelog.Overview
Adds
addUnreleasedEntryinchangelog.mtsand aadd-unreleased.mtsCLI so Coana bumps and other automation writeCHANGELOG.mdunder## [Unreleased]instead of hand-editing. The writer mirrorspromoteChangelog(same parsing rules, fenced-code safety) and only touches the unreleased block—notpackage.jsonversion or## [X.Y.Z]headings.Behavior includes recreating
[Unreleased]after a release consumes it, inserting### Changed(and other sections) inSECTION_ORDER, optional--replaceto update a matching bullet in place (for repeated Coana bumps), and normalizing decorated## [Unreleased] - dateheadings so releases can still promote the block.The
/bump-coanaskill now runs the CLI instead of prose instructions for manual changelog edits.test/release-add-unreleased.test.mtscovers edge cases and anaddUnreleasedEntry→promoteChangeloground trip.Reviewed by Cursor Bugbot for commit 15fd47a. Configure here.