Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

Changelog fragments: conflict-free changelog entries (#1589)

Sebastian Müllerb5807b6f932a
diff --git a/.github/workflows/changelog-fragment.yml b/.github/workflows/changelog-fragment.yml
new file mode 100644
index 0000000000..5ae2967619
--- /dev/null
+++ b/.github/workflows/changelog-fragment.yml
@@ -0,0 +1,76 @@
+name: Changelog fragment
+
+on:
+ pull_request:
+ types: [opened, synchronize, reopened, labeled, unlabeled]
+ branches: [main]
+
+permissions:
+ pull-requests: read
+
+jobs:
+ changelog-fragment:
+ name: Check changelog fragment
+ runs-on: ubuntu-latest
+ if: github.event.pull_request.user.type != 'Bot'
+ steps:
+ - name: Require a changelog fragment for changed packages or an explicit opt-out
+ uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
+ with:
+ script: |
+ const pr = context.payload.pull_request;
+ if (pr.labels.some((label) => label.name === "no-changelog")) {
+ core.info("Label no-changelog is set; skipping changelog check.");
+ return;
+ }
+ // listFiles caps at 3000 files; beyond that the check cannot see every change.
+ if (pr.changed_files > 3000) {
+ core.setFailed("PR changes more than 3000 files; split it or apply the no-changelog label.");
+ return;
+ }
+ const files = await github.paginate(github.rest.pulls.listFiles, {
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ pull_number: pr.number,
+ per_page: 100,
+ });
+ const packages = ["agent", "ai", "coding-agent", "tui"];
+ const failing = [];
+ for (const pkg of packages) {
+ const srcPrefix = `packages/${pkg}/src/`;
+ const srcChanged = files.some(
+ (f) =>
+ f.filename.startsWith(srcPrefix) ||
+ (f.previous_filename !== undefined && f.previous_filename.startsWith(srcPrefix)),
+ );
+ if (!srcChanged) {
+ continue;
+ }
+ // Fragments must be direct children of .changes/ — release.mjs ignores nested paths.
+ const fragmentRe = new RegExp(`^packages/${pkg}/\\.changes/[^/]+\\.md$`);
+ const hasFragment = files.some(
+ (f) =>
+ f.status === "added" &&
+ f.additions > 0 &&
+ fragmentRe.test(f.filename) &&
+ !f.filename.endsWith("/README.md"),
+ );
+ if (!hasFragment) {
+ failing.push(pkg);
+ }
+ }
+ if (failing.length === 0) {
+ core.info("Changelog fragments present for all changed packages.");
+ return;
+ }
+ core.setFailed(
+ failing
+ .map(
+ (pkg) =>
+ `packages/${pkg}/src changed but no changelog entry found. ` +
+ `Add packages/${pkg}/.changes/<branch-slug>.md containing e.g. ` +
+ "`- Fixed the frobnicator dropping input on resize.`, " +
+ "or apply the no-changelog label.",
+ )
+ .join("\n"),
+ );
diff --git a/AGENTS.md b/AGENTS.md
index d8c18dd87e..85e64ff351 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -104,28 +104,23 @@ You, yourself, are often running into a tmux session, so be careful when killing
## Changelog
-Location: `packages/*/CHANGELOG.md` (each package has its own)
+Location: `packages/<pkg>/.changes/<slug>.md` (one fragment file per PR per touched package)
### Format
-A flat list of plain bullets under `## [Unreleased]`. No `### Added` / `### Changed` / `### Fixed` / `### Removed` subsections — just one bullet per change, written as a short sentence starting with a past-tense verb (Added, Changed, Fixed, Removed). Keep each bullet to one line; describe the user-visible change, not the implementation.
+Do NOT edit `packages/*/CHANGELOG.md` directly. Instead, add a fragment file `packages/<pkg>/.changes/<slug>.md` (slug = kebab-case, branch- or ticket-derived, e.g. `eng-1234-fix-resize.md`) containing exactly the bullet line(s) for the change. Bullets are plain `- ...` lines with no `### Added` / `### Changed` / `### Fixed` / `### Removed` subsections — one bullet per change, written as a short sentence starting with a past-tense verb (Added, Changed, Fixed, Removed). Keep each bullet to one line; describe the user-visible change, not the implementation. The release script folds fragments into the release section of CHANGELOG.md and deletes them.
-Example of a well-formed `[Unreleased]` section:
+Example fragment (`packages/coding-agent/.changes/eng-1234-effort-command.md`):
```markdown
-## [Unreleased]
-
- Added `/effort` to set the reasoning level, with autocomplete for the levels the current model supports.
-- Changed `prime-agent` to open a new chat by default instead of resuming the previous session.
-- Fixed onboarding showing no models after entering a provider key.
-- Removed the interactive `!` / `!!` bash shortcuts; use IPython instead.
```
### Rules
-- Read the full `[Unreleased]` section first so you don't duplicate an existing bullet
-- New entries ALWAYS go under `## [Unreleased]`
-- NEVER modify already-released version sections (e.g., `## [0.2.1]`) — each is immutable once released
+- One fragment file per PR per touched package; a fragment may contain multiple bullets
+- NEVER modify already-released version sections in CHANGELOG.md (e.g., `## [0.2.1]`) — each is immutable once released
+- Purely internal changes may opt out via the `no-changelog` PR label
### Attribution
@@ -183,7 +178,7 @@ Create provider file exporting:
### 7. Documentation
- `packages/ai/README.md`: Add to providers table, document options/auth, add env vars
-- `packages/ai/CHANGELOG.md`: Add entry under `## [Unreleased]`
+- `packages/ai/.changes/<slug>.md`: Add a changelog fragment (see Changelog above)
## Releasing
@@ -196,7 +191,7 @@ Create provider file exporting:
### Steps
-1. **Update CHANGELOGs**: Ensure all changes since last release are documented in the `[Unreleased]` section of each affected package's CHANGELOG.md
+1. **Check fragments**: Ensure all changes since last release have fragment files in `packages/<pkg>/.changes/`
2. **Run release script**:
```bash
@@ -204,7 +199,7 @@ Create provider file exporting:
npm run release:minor # API breaking changes
```
-The script handles: version bump, CHANGELOG finalization, commit, tag, publish, and adding new `[Unreleased]` sections.
+The script handles: version bump, folding `.changes/` fragments into the release section, commit, tag, and publish.
## **CRITICAL** Git Rules for Parallel Agents **CRITICAL**
@@ -239,7 +234,7 @@ git status
# 2. Add ONLY your specific files
git add packages/ai/src/providers/transform-messages.ts
-git add packages/ai/CHANGELOG.md
+git add packages/ai/.changes/eng-1234-fix-resize.md
# 3. Commit
git commit -m "fix(ai): description"
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index dc84807e67..cb693bd65b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -40,4 +40,13 @@ If a maintainer has invited a pull request:
Development setup and commands are documented in the [development guide](packages/coding-agent/docs/development.md).
+## Changelog entries
+
+Do not edit `packages/*/CHANGELOG.md` directly. Instead, add one fragment
+file per PR per touched package: `packages/<pkg>/.changes/<slug>.md`, where `<slug>` is a kebab-case name
+derived from your branch or ticket (e.g. `eng-1234-fix-resize.md`). The file contains exactly the bullet
+line(s) that describe the change, e.g. `- Fixed the frobnicator dropping input on resize.`. The release
+script aggregates fragments into the release section and deletes them. PRs that change `packages/<pkg>/src`
+without a fragment fail CI; apply the `no-changelog` label to opt out.
+
Maintainers may close a pull request that changes scope, cannot be validated safely, or no longer fits the project roadmap.
diff --git a/packages/agent/.changes/README.md b/packages/agent/.changes/README.md
new file mode 100644
index 0000000000..86744da404
--- /dev/null
+++ b/packages/agent/.changes/README.md
@@ -0,0 +1,5 @@
+# Changelog fragments
+
+One `<slug>.md` per PR containing the bullet line(s) (e.g. `- Fixed ...`) that describe the change
+for this package. `scripts/release.mjs` folds these into the release section of CHANGELOG.md and
+deletes them. See CONTRIBUTING.md.
diff --git a/packages/agent/CHANGELOG.md b/packages/agent/CHANGELOG.md
index bacb18e7f9..c1264f581f 100644
--- a/packages/agent/CHANGELOG.md
+++ b/packages/agent/CHANGELOG.md
@@ -1,7 +1,5 @@
# Changelog
-## [Unreleased]
-
## [0.7.4] - 2026-08-19
## [0.7.3] - 2026-08-17
diff --git a/packages/ai/.changes/0000-pending-from-unreleased.md b/packages/ai/.changes/0000-pending-from-unreleased.md
new file mode 100644
index 0000000000..6c80a8d2c7
--- /dev/null
+++ b/packages/ai/.changes/0000-pending-from-unreleased.md
@@ -0,0 +1 @@
+- Added endpoint binding to MCP OAuth credentials: tokens record the URL they were issued for, and refreshes carry the original binding forward without ever inferring one for unbound legacy credentials.
diff --git a/packages/ai/.changes/README.md b/packages/ai/.changes/README.md
new file mode 100644
index 0000000000..86744da404
--- /dev/null
+++ b/packages/ai/.changes/README.md
@@ -0,0 +1,5 @@
+# Changelog fragments
+
+One `<slug>.md` per PR containing the bullet line(s) (e.g. `- Fixed ...`) that describe the change
+for this package. `scripts/release.mjs` folds these into the release section of CHANGELOG.md and
+deletes them. See CONTRIBUTING.md.
diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md
index f12f99fbaa..7f716c0828 100644
--- a/packages/ai/CHANGELOG.md
+++ b/packages/ai/CHANGELOG.md
@@ -1,9 +1,5 @@
# Changelog
-## [Unreleased]
-
-- Added endpoint binding to MCP OAuth credentials: tokens record the URL they were issued for, and refreshes carry the original binding forward without ever inferring one for unbound legacy credentials.
-
## [0.7.4] - 2026-08-19
## [0.7.3] - 2026-08-17
diff --git a/packages/coding-agent/.changes/0000-pending-from-unreleased.md b/packages/coding-agent/.changes/0000-pending-from-unreleased.md
new file mode 100644
index 0000000000..99798ec819
--- /dev/null
+++ b/packages/coding-agent/.changes/0000-pending-from-unreleased.md
@@ -0,0 +1,15 @@
+- Fixed an OAuth login that finishes after its server was retargeted arming the old-endpoint token against the new URL: credentials are endpoint-bound at issuance, and the host and kernel only use a token bound to the configured endpoint. **Breaking**: generic MCP OAuth credentials stored before this release lack the binding and require one `/mcp login <server>`.
+- Fixed `mcp add` keeping a stored `mcp:<name>` credential when the entry was new: any add now drops the name's credential, so tokens for authored non-catalog skills (e.g. slack) cannot replay to a user-configured URL.
+- Fixed kernel MCP shutdown budgets exceeding the host's kill deadline; graceful close now finishes inside it, and a kernel that exits without a `shutdown_reply` no longer stalls shutdown for the full deadline.
+- Fixed a shutdown race that could leave an MCP server process running after its generation was dropped from the registry.
+- Fixed the kernel MCP regression test and the Python runtime tests not running in CI.
+- Fixed first IPython calls after an upgrade failing with a raw "Operation was not possible or timed out": kernel startup now tolerates cold venv boots (30s budget; crashes still fail fast via the exit handler), and zmq socket-teardown rejections surface as actionable retriable kernel errors.
+- Fixed headless completion reporting a clean finish when a post-compaction continuation failed to start: ACP and print-mode idle waiters now see the failure, while interactive idle behavior is unchanged.
+- Added a pre-imported generic MCP API and shell/TUI commands to manage persistent Streamable HTTP and stdio servers in user settings.
+- **Breaking**: removed the documented catalog-name override — an `mcpServers` entry named after a built-in integration (e.g. `linear`) no longer repoints the built-in at a custom `url`/`bearerTokenEnvVar`; it now disables the built-in skill and is not served by the generic runtime. Rename the entry (e.g. `linear-proxy`) to keep using a custom endpoint via the generic API. This closes a credential-replay surface where name-keyed tokens could be sent to an override URL.
+- Fixed agents overlooking enabled generic MCP connections by advertising their names and pre-imported `mcp` API usage in the system prompt.
+- Fixed `/mcp` management feedback disappearing during resource reload and limited server details in TUI output to names and transports.
+- Fixed credentials configured as env var names resolving to the literal variable name when the variable is set but empty; an empty env var now reports a missing credential ([#1468](https://github.com/PrimeIntellect-ai/prime-agent/discussions/1468)).
+- Fixed ACP rejecting an immediate follow-up prompt when injected work restarted the session; follow-ups now queue behind in-flight work, and cancellation drops queued follow-ups before they start.
+- Added correlated ACP terminal-quiescence metadata, resident session settlement, and fail-closed daemon input fencing; prevented recovery state from persisting runtime credentials or model configuration.
+- Fixed explicit RLM child deletion leaving hidden unsettled work after runtime teardown, including reporting cleanup failures and notifying the parent when deletion completes.
diff --git a/packages/coding-agent/.changes/README.md b/packages/coding-agent/.changes/README.md
new file mode 100644
index 0000000000..86744da404
--- /dev/null
+++ b/packages/coding-agent/.changes/README.md
@@ -0,0 +1,5 @@
+# Changelog fragments
+
+One `<slug>.md` per PR containing the bullet line(s) (e.g. `- Fixed ...`) that describe the change
+for this package. `scripts/release.mjs` folds these into the release section of CHANGELOG.md and
+deletes them. See CONTRIBUTING.md.
diff --git a/packages/coding-agent/.changes/eng-5408-changelog-fragments.md b/packages/coding-agent/.changes/eng-5408-changelog-fragments.md
new file mode 100644
index 0000000000..2ea44cd68e
--- /dev/null
+++ b/packages/coding-agent/.changes/eng-5408-changelog-fragments.md
@@ -0,0 +1 @@
+- Added changelog fragments (`packages/<pkg>/.changes/*.md`) with a CI check and release-time aggregation, eliminating `[Unreleased]` merge conflicts.
diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md
index b44534a79c..105b91eb9e 100644
--- a/packages/coding-agent/CHANGELOG.md
+++ b/packages/coding-agent/CHANGELOG.md
@@ -1,23 +1,5 @@
# Changelog
-## [Unreleased]
-
-- Fixed an OAuth login that finishes after its server was retargeted arming the old-endpoint token against the new URL: credentials are endpoint-bound at issuance, and the host and kernel only use a token bound to the configured endpoint. **Breaking**: generic MCP OAuth credentials stored before this release lack the binding and require one `/mcp login <server>`.
-- Fixed `mcp add` keeping a stored `mcp:<name>` credential when the entry was new: any add now drops the name's credential, so tokens for authored non-catalog skills (e.g. slack) cannot replay to a user-configured URL.
-- Fixed kernel MCP shutdown budgets exceeding the host's kill deadline; graceful close now finishes inside it, and a kernel that exits without a `shutdown_reply` no longer stalls shutdown for the full deadline.
-- Fixed a shutdown race that could leave an MCP server process running after its generation was dropped from the registry.
-- Fixed the kernel MCP regression test and the Python runtime tests not running in CI.
-- Fixed first IPython calls after an upgrade failing with a raw "Operation was not possible or timed out": kernel startup now tolerates cold venv boots (30s budget; crashes still fail fast via the exit handler), and zmq socket-teardown rejections surface as actionable retriable kernel errors.
-- Fixed headless completion reporting a clean finish when a post-compaction continuation failed to start: ACP and print-mode idle waiters now see the failure, while interactive idle behavior is unchanged.
-- Added a pre-imported generic MCP API and shell/TUI commands to manage persistent Streamable HTTP and stdio servers in user settings.
-- **Breaking**: removed the documented catalog-name override — an `mcpServers` entry named after a built-in integration (e.g. `linear`) no longer repoints the built-in at a custom `url`/`bearerTokenEnvVar`; it now disables the built-in skill and is not served by the generic runtime. Rename the entry (e.g. `linear-proxy`) to keep using a custom endpoint via the generic API. This closes a credential-replay surface where name-keyed tokens could be sent to an override URL.
-- Fixed agents overlooking enabled generic MCP connections by advertising their names and pre-imported `mcp` API usage in the system prompt.
-- Fixed `/mcp` management feedback disappearing during resource reload and limited server details in TUI output to names and transports.
-- Fixed credentials configured as env var names resolving to the literal variable name when the variable is set but empty; an empty env var now reports a missing credential ([#1468](https://github.com/PrimeIntellect-ai/prime-agent/discussions/1468)).
-- Fixed ACP rejecting an immediate follow-up prompt when injected work restarted the session; follow-ups now queue behind in-flight work, and cancellation drops queued follow-ups before they start.
-- Added correlated ACP terminal-quiescence metadata, resident session settlement, and fail-closed daemon input fencing; prevented recovery state from persisting runtime credentials or model configuration.
-- Fixed explicit RLM child deletion leaving hidden unsettled work after runtime teardown, including reporting cleanup failures and notifying the parent when deletion completes.
-
## [0.7.4] - 2026-08-19
- Fixed model searches ranking stronger matches ahead of weaker signed-in matches while preferring signed-in providers for equivalent results ([#539](https://github.com/PrimeIntellect-ai/prime-agent/pull/539) by [@eliebak](https://github.com/eliebak)).
diff --git a/packages/tui/.changes/README.md b/packages/tui/.changes/README.md
new file mode 100644
index 0000000000..86744da404
--- /dev/null
+++ b/packages/tui/.changes/README.md
@@ -0,0 +1,5 @@
+# Changelog fragments
+
+One `<slug>.md` per PR containing the bullet line(s) (e.g. `- Fixed ...`) that describe the change
+for this package. `scripts/release.mjs` folds these into the release section of CHANGELOG.md and
+deletes them. See CONTRIBUTING.md.
diff --git a/packages/tui/CHANGELOG.md b/packages/tui/CHANGELOG.md
index 06e565a692..fcdd1c6eed 100644
--- a/packages/tui/CHANGELOG.md
+++ b/packages/tui/CHANGELOG.md
@@ -1,7 +1,5 @@
# Changelog
-## [Unreleased]
-
## [0.7.4] - 2026-08-19
## [0.7.3] - 2026-08-17
diff --git a/scripts/lib/changelog-fragments.mjs b/scripts/lib/changelog-fragments.mjs
new file mode 100644
index 0000000000..619636ba87
--- /dev/null
+++ b/scripts/lib/changelog-fragments.mjs
@@ -0,0 +1,39 @@
+function normalizeFragment(text) {
+ const trimmed = text.trim();
+ return trimmed ? `${trimmed}\n` : "";
+}
+
+/**
+ * Build the `[version] - date` section from pre-sorted fragments. Entries in
+ * a stray [Unreleased] section (old-style PR merged post-cutover) are
+ * absorbed first instead of being stranded.
+ */
+export function buildReleaseSection(changelogContent, fragments, version, date) {
+ const unreleasedRe = /## \[Unreleased\]\n([\s\S]*?)(?=\n## \[|$)/;
+ const match = changelogContent.match(unreleasedRe);
+ if (!match && fragments.length === 0) {
+ return { content: changelogContent, changed: false };
+ }
+
+ const parts = [];
+ if (match && match[1].trim()) {
+ parts.push(`${match[1].trim()}\n`);
+ }
+ for (const fragment of fragments) {
+ const normalized = normalizeFragment(fragment.content);
+ if (normalized) {
+ parts.push(normalized);
+ }
+ }
+
+ const header = `## [${version}] - ${date}`;
+ const section = parts.length > 0 ? `${header}\n\n${parts.join("")}` : `${header}\n`;
+
+ if (match) {
+ return { content: changelogContent.replace(unreleasedRe, () => section), changed: true };
+ }
+
+ // No [Unreleased] header but fragments exist: insert the section after the title.
+ const content = changelogContent.replace(/^(# Changelog\n\n)/, (title) => `${title}${section}\n`);
+ return { content, changed: true };
+}
diff --git a/scripts/release.mjs b/scripts/release.mjs
index a369dcced6..4eb4c83cba 100755
--- a/scripts/release.mjs
+++ b/scripts/release.mjs
@@ -5,27 +5,29 @@
* Usage:
* node scripts/release.mjs <major|minor|patch>
* node scripts/release.mjs <x.y.z>
+ * node scripts/release.mjs <target> --dry-run (preview changelog updates only)
*
* Steps:
* 1. Check for uncommitted changes
* 2. Bump version via npm run version:xxx or set an explicit version
- * 3. Update CHANGELOG.md files: [Unreleased] -> [version] - date
+ * 3. Update CHANGELOG.md files: aggregate .changes/*.md fragments into a
+ * [version] - date section, git rm the consumed fragments
* 4. Commit and tag
* 5. Publish to npm
- * 6. Add new [Unreleased] section to changelogs
- * 7. Commit
*/
import { execSync } from "child_process";
import { readFileSync, writeFileSync, readdirSync, existsSync } from "fs";
-import { join } from "path";
+import { dirname, join } from "path";
+import { buildReleaseSection } from "./lib/changelog-fragments.mjs";
-const RELEASE_TARGET = process.argv[2];
+const DRY_RUN = process.argv.includes("--dry-run");
+const RELEASE_TARGET = process.argv.slice(2).find((arg) => !arg.startsWith("--"));
const BUMP_TYPES = new Set(["major", "minor", "patch"]);
const SEMVER_RE = /^\d+\.\d+\.\d+$/;
if (!RELEASE_TARGET || (!BUMP_TYPES.has(RELEASE_TARGET) && !SEMVER_RE.test(RELEASE_TARGET))) {
- console.error("Usage: node scripts/release.mjs <major|minor|patch|x.y.z>");
+ console.error("Usage: node scripts/release.mjs <major|minor|patch|x.y.z> [--dry-run]");
process.exit(1);
}
@@ -104,46 +106,92 @@ function getChangelogs() {
.filter((path) => existsSync(path));
}
+function listFragments(pkgDir) {
+ const changesDir = join(pkgDir, ".changes");
+ if (!existsSync(changesDir)) {
+ return [];
+ }
+
+ const files = readdirSync(changesDir)
+ .filter((name) => name.endsWith(".md") && name !== "README.md")
+ .map((name) => join(changesDir, name));
+ return files
+ .map((path) => ({ path, key: fragmentSortKey(path) }))
+ .sort((a, b) => a.key - b.key || (a.path < b.path ? -1 : 1))
+ .map(({ path }) => ({ name: path, content: readFileSync(path, "utf-8") }));
+}
+
+function fragmentSortKey(path) {
+ const output = run(`git log --diff-filter=A --format=%ct -1 -- ${shellQuote(path)}`, {
+ silent: true,
+ ignoreError: true,
+ });
+ const epoch = Number.parseInt((output || "").trim(), 10);
+ return Number.isFinite(epoch) ? epoch : Infinity;
+}
+
function updateChangelogsForRelease(version) {
const date = new Date().toISOString().split("T")[0];
const changelogs = getChangelogs();
+ const consumedFragments = [];
for (const changelog of changelogs) {
const content = readFileSync(changelog, "utf-8");
+ const allFragments = listFragments(dirname(changelog));
+ // Empty fragments are skipped, not consumed, so nothing is ever lost silently.
+ const empty = allFragments.filter((fragment) => !fragment.content.trim());
+ for (const fragment of empty) {
+ console.warn(` Warning: skipping empty fragment ${fragment.name}; delete it or add content.`);
+ }
+ const fragments = allFragments.filter((fragment) => fragment.content.trim());
+ const result = buildReleaseSection(content, fragments, version, date);
- if (!content.includes("## [Unreleased]")) {
- console.log(` Skipping ${changelog}: no [Unreleased] section`);
+ if (!result.changed) {
+ console.log(` Skipping ${changelog}: no fragments`);
continue;
}
- const updated = content.replace(
- "## [Unreleased]",
- `## [${version}] - ${date}`
- );
- writeFileSync(changelog, updated);
- console.log(` Updated ${changelog}`);
+ if (DRY_RUN) {
+ console.log(`\n--- ${changelog} (${fragments.length} fragments) ---`);
+ const escapedVersion = version.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
+ const sectionRe = new RegExp(`## \\[${escapedVersion}\\][\\s\\S]*?(?=\\n## \\[|$)`);
+ console.log((result.content.match(sectionRe) || ["(no release section)"])[0]);
+ } else {
+ writeFileSync(changelog, result.content);
+ console.log(` Updated ${changelog} (${fragments.length} fragments)`);
+ }
+ consumedFragments.push(...fragments.map((fragment) => fragment.name));
}
-}
-function addUnreleasedSection() {
- const changelogs = getChangelogs();
- const unreleasedSection = "## [Unreleased]\n\n";
-
- for (const changelog of changelogs) {
- const content = readFileSync(changelog, "utf-8");
+ if (consumedFragments.length > 0) {
+ if (DRY_RUN) {
+ console.log(`\nWould git rm: ${consumedFragments.join(", ")}`);
+ } else {
+ run(`git rm -q -- ${consumedFragments.map(shellQuote).join(" ")}`);
+ }
+ }
+}
- // Insert after "# Changelog\n\n"
- const updated = content.replace(
- /^(# Changelog\n\n)/,
- `$1${unreleasedSection}`
- );
- writeFileSync(changelog, updated);
- console.log(` Added [Unreleased] to ${changelog}`);
+function previewVersion(target) {
+ if (!BUMP_TYPES.has(target)) {
+ return target;
}
+ const [major, minor, patch] = getVersion().split(".").map(Number);
+ if (target === "major") return `${major + 1}.0.0`;
+ if (target === "minor") return `${major}.${minor + 1}.0`;
+ return `${major}.${minor}.${patch + 1}`;
}
console.log("\n=== Release Script ===\n");
+if (DRY_RUN) {
+ const version = previewVersion(RELEASE_TARGET);
+ console.log(`Dry run for v${version}: previewing changelog updates, no files are written.`);
+ updateChangelogsForRelease(version);
+ console.log("\n=== Dry run complete (no changes made) ===");
+ process.exit(0);
+}
+
console.log("Checking for uncommitted changes...");
const status = run("git status --porcelain", { silent: true });
if (status && status.trim()) {
@@ -170,15 +218,6 @@ console.log("Publishing to npm...");
run("npm run publish");
console.log();
-console.log("Adding [Unreleased] sections for next cycle...");
-addUnreleasedSection();
-console.log();
-
-console.log("Committing changelog updates...");
-stageChangedFiles();
-run(`git commit -m "Add [Unreleased] section for next cycle"`);
-console.log();
-
console.log("Pushing to remote...");
run("git push origin main");
run(`git push origin v${version}`);