@releasekit/notes 0.44.1 → 0.46.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.
@@ -1,20 +1,31 @@
1
1
  import {
2
+ BREAKING_SECTION,
2
3
  EXIT_CODES,
3
4
  ReleaseKitError,
4
5
  debug,
6
+ detectMonorepo,
5
7
  error,
6
8
  formatVersion,
9
+ groupChangelogSections,
7
10
  info,
8
11
  isPathWithinRoot,
9
12
  parseGitHubOwnerRepo,
10
13
  removeDescriptionRefs,
14
+ renderBundledBlocks,
15
+ renderChangelogEntryLine,
16
+ renderMarkdown,
17
+ resolveBundled,
11
18
  setLogLevel,
12
19
  setQuietMode,
20
+ sharedPackageBlock,
21
+ sharedPackageEntriesOf,
13
22
  success,
23
+ unlistedEntries,
14
24
  unwrapEnvelope,
25
+ versionSections,
15
26
  warn,
16
- writeMarkdown
17
- } from "./chunk-VD3TYCTF.js";
27
+ writeChangelog
28
+ } from "./chunk-EI7LLVJN.js";
18
29
 
19
30
  // ../config/dist/index.js
20
31
  import * as fs from "fs";
@@ -63,7 +74,6 @@ function parseJsonc(content) {
63
74
  }
64
75
  return result;
65
76
  }
66
- var DEFAULT_DEMOTE_SCOPES = ["deps", "deps-dev"];
67
77
  var GitConfigSchema = z.strictObject({
68
78
  remote: z.string().default("origin").describe("Git remote name"),
69
79
  branch: z.string().optional().describe(
@@ -144,10 +154,13 @@ var VersionConfigBaseSchema = z.strictObject({
144
154
  ),
145
155
  packages: z.array(z.string()).default([]).describe("Packages to include in versioning. Empty includes every discovered package."),
146
156
  sharedPackages: z.array(z.string()).optional().describe(
147
- 'Foundational packages whose changes belong in every package\u2019s changelog. A commit touching only a shared package (exact name or glob) is classified as repo-level and surfaced under "Project-wide changes" rather than attributed to that one package. Default: none \u2014 no package is treated as shared unless declared.'
157
+ 'Foundational packages whose changes belong in every package\u2019s notes, as exact names or globs. In async mode (`sync: false`, no `groups`, more than one package in the run), commits touching a shared package and no non-shared package are listed under "Project-wide changes" in each released package\u2019s changelog, release notes and release body, covering those since that package\u2019s previous release. A root changelog lists them once per run in such releases, alongside commits that touch no package. Default: none.'
158
+ ),
159
+ primaryPackages: z.array(z.string()).default([]).describe(
160
+ "Packages users install, as exact names or globs. Each anchors a release unit with its group-mates and the internal dependencies it releases with. Used by the standing-PR selection list. In async mode or grouped releases with per-package tags, each primary's release notes also list its group-mates' and internal dependencies' releases since its previous release."
148
161
  ),
149
162
  sharedChangelogFloor: z.enum(["union", "sinceLastRelease"]).default("union").describe(
150
- `How the "Project-wide changes" block is bounded in package-specific-tag mode. "union" (default): repo-level commits accrue from the union of the releasing packages' ranges, floored by the OLDEST unreleased baseline \u2014 so a genuinely-global commit recurs in every release until the oldest-baselined package is released past it. "sinceLastRelease": floor the block by the single nearest tag reachable across the repo, so global commits already shown by the most recent release don't recur (recommended for per-package-tag monorepos). No effect in sync mode, where one shared tag already consumes repo-level commits on each release.`
163
+ `How project-wide entries in the standing PR and the root changelog are bounded in async mode (see sharedPackages); each package's own notes list the shared-package entries since its previous release. "union" (default): repo-level commits accrue from the union of the releasing packages' ranges, floored by the OLDEST unreleased baseline \u2014 so a genuinely-global commit recurs in every release until the oldest-baselined package is released past it. "sinceLastRelease": floor the block by the single nearest tag reachable across the repo, so global commits already shown by the most recent release don't recur (recommended for per-package-tag monorepos).`
151
164
  ),
152
165
  mainPackage: z.string().optional().describe(
153
166
  "The package a single-mode release versions. In sync mode, the release bumps from this package's version and tag and, without packageSpecificTags, carries its name. The changelog still lists every commit in the release."
@@ -168,7 +181,9 @@ var VersionConfigBaseSchema = z.strictObject({
168
181
  allowFirstBump: z.boolean().default(false).describe(
169
182
  'Acknowledge applying a bump on a first release with an already-stable manifest. On a first release (no prior tag), `--stable --bump <type>` applies the bump (e.g. 1.0.0 \u2192 2.0.0) rather than graduating, which can silently overshoot the staged first version. By default this is flagged per `mismatchStrategy` (warn, or abort under "error"); set true (or pass --allow-first-bump) to apply the bump silently \u2014 legitimate when importing a package with prior external version history.'
170
183
  ),
171
- strictReachable: z.boolean().default(false).describe("Fail the run when the previous release tag isn't reachable from HEAD, instead of falling back."),
184
+ strictReachable: z.boolean().default(false).describe(
185
+ "Fail the run when a release tag exists but none is reachable from HEAD (typically a shallow clone), instead of falling back to the manifest version."
186
+ ),
172
187
  zeroMajor: z.enum(["spec", "strict"]).default("spec").describe(
173
188
  "Pre-1.0 handling of commit-inferred breaking changes. 'spec' (default): bump the 0.x minor (0.24.0 \u2192 0.25.0), per semver \xA74. 'strict': bump the next major (\u2192 1.0.0). Inferred path only \u2014 explicit overrides (--bump major, bump:major) always graduate to 1.0.0."
174
189
  ),
@@ -366,10 +381,7 @@ var ChangelogConfigSchema = z.strictObject({
366
381
  file: z.string().optional().describe("Changelog file name override (default: CHANGELOG.md)"),
367
382
  templates: TemplateConfigSchema.optional().describe("Template configuration for changelog"),
368
383
  refs: z.enum(["strip", "escape", "link"]).default("link").describe(
369
- "How `#NNN` issue/PR refs in the changelog are rendered. Applies to the whole entry \u2014 both the appended label and any bare `#N` carried over from the commit subject into the description (a description ref that also appears in the appended label is de-duplicated away). 'link' (default): the PR and the issues it closed are labelled as `(PR #503 \xB7 closes #500)`, where the PR links to its canonical /pull/ URL with `PR #503` as the visible text \u2014 this keeps the GitHub hovercard but stops the bare-token rich inline card that duplicated the entry; closed issues link to /issues/. An entry with no identifiable PR (a non-squash commit, or a non-GitHub repo) falls back to a plain ref list. 'escape': plain text \\#NNN (no link, no hovercard, no PR/closes labelling). 'strip': refs are removed entirely. Scoped-package / @user mentions in entry text are always neutralised regardless of this setting."
370
- ),
371
- demoteScopes: z.array(z.string()).default([...DEFAULT_DEMOTE_SCOPES]).describe(
372
- 'Conventional-commit scopes whose changelog entries move to a trailing "Dependencies & version bumps" subsection instead of mixing with Added / Changed / Fixed. A breaking change still comes first, under Breaking. Applies to the release preview comment and the standing-PR changelogs (each releasable row and the "Show all changes" footer). Entries are moved, not dropped, so the de-duplicated change count is unchanged. Default: ["deps", "deps-dev"], the scopes Dependabot uses. Set to [] to render every scope inline.'
384
+ "How `#NNN` issue/PR refs in changelog entries are rendered, wherever the entries appear. Applies to the whole entry \u2014 both the appended label and any bare `#N` carried over from the commit subject into the description (a description ref that also appears in the appended label is de-duplicated away). 'link' (default): the PR and the issues it closed are labelled as `(PR #503 \xB7 closes #500)`, where the PR links to its canonical /pull/ URL with `PR #503` as the visible text \u2014 this keeps the GitHub hovercard but stops the bare-token rich inline card that duplicated the entry; closed issues link to /issues/. An entry with no identifiable PR (a non-squash commit, or a non-GitHub repo) falls back to a plain ref list. 'escape': plain text \\#NNN (no link, no hovercard, no PR/closes labelling). 'strip': refs are removed entirely. Scoped-package / @user mentions in entry text are always neutralised regardless of this setting."
373
385
  )
374
386
  }).describe("Changelog file configuration");
375
387
  var LLMOptionsSchema = z.strictObject({
@@ -511,9 +523,6 @@ var NotesConfigSchema = z.strictObject({
511
523
  changelog: z.union([z.literal(false).describe("Set to false to disable changelog generation"), ChangelogConfigSchema]).optional().describe("Changelog generation, on by default. Set to false to disable."),
512
524
  releaseNotes: z.union([z.literal(false).describe("Set to false to disable release notes"), ReleaseNotesConfigSchema]).optional().describe(
513
525
  "Release notes for the GitHub Release body and optional per-version files. Off unless set. {} turns them on using each version's changelog section; set llm or templates to change the content."
514
- ),
515
- updateStrategy: z.enum(["prepend", "regenerate"]).optional().describe(
516
- "How to update existing changelog files. 'prepend' (the default) adds the new entries at the top; 'regenerate' overwrites the file with this run's output."
517
526
  )
518
527
  });
519
528
  var CILabelsConfigSchema = z.strictObject({
@@ -580,11 +589,8 @@ var StandingPrConfigSchema = z.strictObject({
580
589
  }).optional().describe(
581
590
  "Restrict who can steer the standing PR \u2014 its selection checkboxes, per-row channel toggles, release labels, and merge. Omit to allow anyone with the GitHub permission GitHub itself requires for each action."
582
591
  ),
583
- primaryPackages: z.array(z.string()).default([]).describe(
584
- "Packages that drive releases \u2014 rendered as parent rows in the standing-PR selection list, with their coupled group-mates and changed prerequisites nested beneath, so one parent toggle holds back the whole release unit. Glob patterns or exact names. Empty (default) \u2192 flat per-package list (current behavior)."
585
- ),
586
592
  selection: z.enum(["streamlined", "granular"]).default("streamlined").describe(
587
- "How the selection list renders when primaryPackages is set. streamlined: one checkbox per primary, coupled members shown read-only in a collapsed pane, and a held-back primary cascades to its unit. granular: every package keeps its own checkbox, nested under its primary, with no cascade. No effect when primaryPackages is empty."
593
+ "How the selection list renders when version.primaryPackages is set. streamlined: one checkbox per primary, coupled members shown read-only in a collapsed pane, and a held-back primary cascades to its unit. granular: every package keeps its own checkbox, nested under its primary, with no cascade. No effect when version.primaryPackages is empty."
588
594
  ),
589
595
  combinedChangelogFooter: z.boolean().default(true).describe(
590
596
  "Append the de-duplicated combined-changelog footer to the standing PR: every change listed once, flat across packages and grouped by change type (Added/Changed/Fixed), breaking changes first. Set false to rely on the per-row changelogs; project-wide (shared) changes still show in their own block. Sync releases, which have no per-row changelogs, always show the footer."
@@ -759,8 +765,10 @@ var REMOVED_KEYS = /* @__PURE__ */ new Map([
759
765
  "renamed to markStaleAfterRelease, which marks open PRs' previews stale after a release instead of recomputing them"
760
766
  ],
761
767
  ["ci.labels.stable", "renamed to ci.labels.graduate"],
768
+ ["ci.standingPr.primaryPackages", "moved to version.primaryPackages"],
762
769
  ["monorepo.mainPackage", "moved to version.mainPackage"],
763
- ["monorepo.mode", "removed - changelog aggregation is set by notes.changelog.mode"]
770
+ ["monorepo.mode", "removed - changelog aggregation is set by notes.changelog.mode"],
771
+ ["notes.updateStrategy", "removed - changelogs always prepend the new versions"]
764
772
  ]);
765
773
  var unsetEnvByOwner = /* @__PURE__ */ new WeakMap();
766
774
  function configValidationError(issues) {
@@ -874,6 +882,9 @@ function loadConfig(options) {
874
882
  const configPath = options?.configPath ?? resolveConfigPath(cwd);
875
883
  return loadConfigFile(configPath);
876
884
  }
885
+ function configuredRefsMode(notes) {
886
+ return (notes?.changelog || void 0)?.refs ?? "link";
887
+ }
877
888
 
878
889
  // src/errors/index.ts
879
890
  var NotesError = class extends ReleaseKitError {
@@ -962,7 +973,8 @@ var VersionChangelogEntrySchema = z3.looseObject({
962
973
  prNumber: z3.string().optional(),
963
974
  scope: z3.string().optional(),
964
975
  originalType: z3.string().optional(),
965
- breaking: z3.boolean().optional()
976
+ breaking: z3.boolean().optional(),
977
+ sharedPackage: z3.boolean().optional()
966
978
  });
967
979
  var VersionPackageChangelogSchema = z3.looseObject({
968
980
  packageName: z3.string(),
@@ -971,7 +983,9 @@ var VersionPackageChangelogSchema = z3.looseObject({
971
983
  revisionRange: z3.string(),
972
984
  repoUrl: z3.string().nullable(),
973
985
  entries: z3.array(VersionChangelogEntrySchema),
974
- tag: z3.string().optional()
986
+ tag: z3.string().optional(),
987
+ sharedPackageEntries: z3.array(VersionChangelogEntrySchema).optional(),
988
+ bundled: z3.array(z3.looseObject({ packageName: z3.string(), versions: z3.array(z3.string()) })).optional()
975
989
  });
976
990
  var VersionPackageUpdateSchema = z3.looseObject({
977
991
  packageName: z3.string(),
@@ -984,6 +998,10 @@ var VersionOutputSchema = z3.looseObject({
984
998
  dryRun: z3.boolean(),
985
999
  updates: z3.array(VersionPackageUpdateSchema),
986
1000
  changelogs: z3.array(VersionPackageChangelogSchema),
1001
+ sharedEntries: z3.array(VersionChangelogEntrySchema).optional(),
1002
+ bundledReleases: z3.array(
1003
+ z3.looseObject({ packageName: z3.string(), version: z3.string(), entries: z3.array(VersionChangelogEntrySchema) })
1004
+ ).optional(),
987
1005
  commitMessage: z3.string().optional(),
988
1006
  tags: z3.array(z3.string()),
989
1007
  baselineTags: z3.array(z3.string()).optional(),
@@ -991,7 +1009,13 @@ var VersionOutputSchema = z3.looseObject({
991
1009
  });
992
1010
 
993
1011
  // src/input/version-output.ts
994
- var NotesVersionOutputSchema = VersionOutputSchema.pick({ changelogs: true, updates: true, tags: true }).partial({
1012
+ var NotesVersionOutputSchema = VersionOutputSchema.pick({
1013
+ changelogs: true,
1014
+ updates: true,
1015
+ tags: true,
1016
+ sharedEntries: true,
1017
+ bundledReleases: true
1018
+ }).partial({
995
1019
  updates: true,
996
1020
  tags: true
997
1021
  });
@@ -1012,6 +1036,18 @@ function normalizeEntryType(type) {
1012
1036
  };
1013
1037
  return typeMap[type.toLowerCase()] ?? "changed";
1014
1038
  }
1039
+ function toChangelogEntry(entry) {
1040
+ return {
1041
+ type: normalizeEntryType(entry.type),
1042
+ description: entry.description,
1043
+ issueIds: entry.issueIds,
1044
+ prNumber: entry.prNumber,
1045
+ scope: entry.scope,
1046
+ originalType: entry.originalType,
1047
+ breaking: entry.breaking ?? entry.originalType?.includes("!") ?? false,
1048
+ ...entry.sharedPackage ? { sharedPackage: true } : {}
1049
+ };
1050
+ }
1015
1051
  function versionOutputToChangelogInput(data) {
1016
1052
  if (!data.changelogs || !Array.isArray(data.changelogs)) {
1017
1053
  throw new InputParseError('Input must contain a "changelogs" array');
@@ -1025,20 +1061,16 @@ function versionOutputToChangelogInput(data) {
1025
1061
  revisionRange: changelog.revisionRange,
1026
1062
  repoUrl: changelog.repoUrl,
1027
1063
  date: (/* @__PURE__ */ new Date()).toISOString().split("T")[0] ?? "",
1028
- entries: changelog.entries.map((entry) => ({
1029
- type: normalizeEntryType(entry.type),
1030
- description: entry.description,
1031
- issueIds: entry.issueIds,
1032
- prNumber: entry.prNumber,
1033
- scope: entry.scope,
1034
- originalType: entry.originalType,
1035
- breaking: entry.breaking ?? entry.originalType?.includes("!") ?? false
1036
- }))
1064
+ entries: changelog.entries.map(toChangelogEntry),
1065
+ sharedPackageEntries: changelog.sharedPackageEntries?.map(toChangelogEntry),
1066
+ bundled: changelog.bundled
1037
1067
  }));
1038
1068
  const repoUrl = packages[0]?.repoUrl ?? null;
1039
1069
  return {
1040
1070
  source: "version",
1041
1071
  packages,
1072
+ sharedEntries: data.sharedEntries?.map(toChangelogEntry),
1073
+ bundledReleases: data.bundledReleases?.map((r) => ({ ...r, entries: r.entries.map(toChangelogEntry) })),
1042
1074
  metadata: {
1043
1075
  repoUrl: repoUrl ?? void 0
1044
1076
  }
@@ -1091,17 +1123,40 @@ function getDefaultConfig() {
1091
1123
  return {};
1092
1124
  }
1093
1125
 
1126
+ // src/output/versioned.ts
1127
+ import * as fs6 from "fs";
1128
+ import * as path6 from "path";
1129
+ function nestsReleaseNotes(packageCount) {
1130
+ return detectMonorepo(process.cwd()).isMonorepo || packageCount > 1;
1131
+ }
1132
+ function writeVersionedNotes(contexts, directory, dryRun, nested, renderContent) {
1133
+ const written = [];
1134
+ for (const ctx of contexts) {
1135
+ const outputPath = nested ? path6.join(directory, ctx.packageName, `${ctx.version}.md`) : path6.join(directory, `${ctx.version}.md`);
1136
+ const content = renderContent(ctx);
1137
+ if (dryRun) {
1138
+ info(`[DRY RUN] Release notes (would write to ${outputPath}):`);
1139
+ info(content);
1140
+ continue;
1141
+ }
1142
+ fs6.mkdirSync(path6.dirname(outputPath), { recursive: true });
1143
+ fs6.writeFileSync(outputPath, content, "utf-8");
1144
+ success(`Release notes written to ${outputPath}`);
1145
+ written.push(outputPath);
1146
+ }
1147
+ return written;
1148
+ }
1149
+
1094
1150
  // src/core/pipeline.ts
1095
- import * as fs13 from "fs";
1096
1151
  import * as path12 from "path";
1097
1152
 
1098
1153
  // src/llm/cache.ts
1099
1154
  import { createHash } from "crypto";
1100
- import * as fs6 from "fs/promises";
1155
+ import * as fs7 from "fs/promises";
1101
1156
  import * as os2 from "os";
1102
- import * as path6 from "path";
1157
+ import * as path7 from "path";
1103
1158
  function defaultCacheDir() {
1104
- return path6.join(os2.tmpdir(), "releasekit", "llm-cache");
1159
+ return path7.join(os2.tmpdir(), "releasekit", "llm-cache");
1105
1160
  }
1106
1161
  function stableStringify(value) {
1107
1162
  return JSON.stringify(
@@ -1127,17 +1182,17 @@ function withContentHashCache(provider, identity, dir = defaultCacheDir(), { ref
1127
1182
  toolName: options?.toolName
1128
1183
  })
1129
1184
  ).digest("hex");
1130
- const file = path6.join(dir, `${key}.json`);
1185
+ const file = path7.join(dir, `${key}.json`);
1131
1186
  if (!refresh) {
1132
1187
  try {
1133
- return JSON.parse(await fs6.readFile(file, "utf-8"));
1188
+ return JSON.parse(await fs7.readFile(file, "utf-8"));
1134
1189
  } catch {
1135
1190
  }
1136
1191
  }
1137
1192
  const result = await provider.complete(messages, options);
1138
1193
  try {
1139
- await fs6.mkdir(dir, { recursive: true });
1140
- await fs6.writeFile(file, JSON.stringify(result));
1194
+ await fs7.mkdir(dir, { recursive: true });
1195
+ await fs7.writeFile(file, JSON.stringify(result));
1141
1196
  } catch {
1142
1197
  }
1143
1198
  return result;
@@ -1547,9 +1602,9 @@ var LLM_DEFAULTS = {
1547
1602
 
1548
1603
  // src/llm/examples/fetcher.ts
1549
1604
  import { createHash as createHash2 } from "crypto";
1550
- import * as fs7 from "fs";
1605
+ import * as fs8 from "fs";
1551
1606
  import * as os3 from "os";
1552
- import * as path7 from "path";
1607
+ import * as path8 from "path";
1553
1608
 
1554
1609
  // src/utils/json.ts
1555
1610
  function extractJsonFromResponse(response) {
@@ -1721,7 +1776,7 @@ function parseReleaseBodyToExample(markdown, version) {
1721
1776
  }
1722
1777
  const heading = /^#{2,4} (.+)/.exec(line)?.[1];
1723
1778
  if (heading) {
1724
- currentCategory = heading.trim();
1779
+ currentCategory = heading.trim().replace(/:$/, "");
1725
1780
  continue;
1726
1781
  }
1727
1782
  if (line.startsWith("#")) {
@@ -1737,7 +1792,7 @@ function parseReleaseBodyToExample(markdown, version) {
1737
1792
  if (leadInMatch) {
1738
1793
  entry.leadIn = leadInMatch[1];
1739
1794
  }
1740
- if (/\*\*BREAKING\*\*/i.test(text)) {
1795
+ if (currentCategory === BREAKING_SECTION || /\*\*BREAKING\*\*/i.test(text)) {
1741
1796
  entry.breaking = true;
1742
1797
  }
1743
1798
  entries.push(entry);
@@ -1771,16 +1826,16 @@ ${blocks.join("\n")}
1771
1826
 
1772
1827
  // src/llm/examples/fetcher.ts
1773
1828
  function cacheDir() {
1774
- return path7.join(os3.tmpdir(), "releasekit", "examples");
1829
+ return path8.join(os3.tmpdir(), "releasekit", "examples");
1775
1830
  }
1776
1831
  function cacheKey(owner, repo, packageName) {
1777
1832
  const safe = packageName.replace(/[^a-zA-Z0-9-]/g, "_");
1778
1833
  const hash = createHash2("sha256").update(packageName).digest("hex").slice(0, 8);
1779
- return path7.join(cacheDir(), owner, repo, `${safe}_${hash}.json`);
1834
+ return path8.join(cacheDir(), owner, repo, `${safe}_${hash}.json`);
1780
1835
  }
1781
1836
  function readCache(key, latestTag, count) {
1782
1837
  try {
1783
- const raw = fs7.readFileSync(key, "utf-8");
1838
+ const raw = fs8.readFileSync(key, "utf-8");
1784
1839
  const entry = JSON.parse(raw);
1785
1840
  if (entry.latestTag !== latestTag || entry.count < count) {
1786
1841
  return null;
@@ -1792,8 +1847,8 @@ function readCache(key, latestTag, count) {
1792
1847
  }
1793
1848
  function writeCache(key, latestTag, count, examples) {
1794
1849
  try {
1795
- fs7.mkdirSync(path7.dirname(key), { recursive: true });
1796
- fs7.writeFileSync(key, JSON.stringify({ latestTag, count, examples }), "utf-8");
1850
+ fs8.mkdirSync(path8.dirname(key), { recursive: true });
1851
+ fs8.writeFileSync(key, JSON.stringify({ latestTag, count, examples }), "utf-8");
1797
1852
  } catch {
1798
1853
  }
1799
1854
  }
@@ -2854,27 +2909,6 @@ async function summarizeEntries(provider, entries, context) {
2854
2909
  return result.content.trim();
2855
2910
  }
2856
2911
 
2857
- // src/output/versioned.ts
2858
- import * as fs8 from "fs";
2859
- import * as path8 from "path";
2860
- function writeVersionedNotes(contexts, directory, dryRun, nested, renderContent) {
2861
- const written = [];
2862
- for (const ctx of contexts) {
2863
- const outputPath = nested ? path8.join(directory, ctx.packageName, `${ctx.version}.md`) : path8.join(directory, `${ctx.version}.md`);
2864
- const content = renderContent(ctx);
2865
- if (dryRun) {
2866
- info(`[DRY RUN] Release notes (would write to ${outputPath}):`);
2867
- info(content);
2868
- continue;
2869
- }
2870
- fs8.mkdirSync(path8.dirname(outputPath), { recursive: true });
2871
- fs8.writeFileSync(outputPath, content, "utf-8");
2872
- success(`Release notes written to ${outputPath}`);
2873
- written.push(outputPath);
2874
- }
2875
- return written;
2876
- }
2877
-
2878
2912
  // src/templates/loader.ts
2879
2913
  import * as fs12 from "fs";
2880
2914
  import * as path11 from "path";
@@ -3278,7 +3312,33 @@ function createTemplateContext(pkg) {
3278
3312
  isFirstRelease: pkg.previousVersion === null
3279
3313
  };
3280
3314
  }
3281
- function createDocumentContext(contexts, repoUrl) {
3315
+ function toTemplateVersion(ctx, options) {
3316
+ const refs = options.refs ?? "link";
3317
+ const withLine = (entry) => ({
3318
+ ...entry,
3319
+ line: renderChangelogEntryLine(entry, refs, ctx.repoUrl)
3320
+ });
3321
+ const toTemplateSection = (s) => ({
3322
+ label: s.label,
3323
+ entries: s.items.map(withLine)
3324
+ });
3325
+ const { enhanced, sharedEntries, bundled, ...rest } = ctx;
3326
+ const { categories: _, ...prose } = enhanced ?? {};
3327
+ return {
3328
+ ...rest,
3329
+ entries: ctx.entries.map(withLine),
3330
+ sections: versionSections(ctx, options.categoryOrder).map(toTemplateSection),
3331
+ shared: groupChangelogSections(sharedEntries ?? [], (e) => e).map(toTemplateSection),
3332
+ bundled: (bundled ?? []).map(({ entries, ...pkg }) => ({
3333
+ ...pkg,
3334
+ sections: groupChangelogSections(entries, (e) => e).map(toTemplateSection)
3335
+ })),
3336
+ // Set even when absent: EJS throws on a bare `enhanced` that isn't a key.
3337
+ enhanced: prose.summary || prose.releaseNotes ? prose : void 0
3338
+ };
3339
+ }
3340
+ function createDocumentContext(contexts, repoUrl, options, sharedEntries = []) {
3341
+ const refs = options.refs ?? "link";
3282
3342
  const compareUrls = {};
3283
3343
  for (const ctx of contexts) {
3284
3344
  if (ctx.compareUrl) {
@@ -3290,8 +3350,15 @@ function createDocumentContext(contexts, repoUrl) {
3290
3350
  name: contexts[0]?.packageName ?? "project",
3291
3351
  repoUrl
3292
3352
  },
3293
- versions: contexts,
3294
- compareUrls: Object.keys(compareUrls).length > 0 ? compareUrls : void 0
3353
+ versions: contexts.map((ctx) => toTemplateVersion(ctx, options)),
3354
+ compareUrls: Object.keys(compareUrls).length > 0 ? compareUrls : void 0,
3355
+ shared: groupChangelogSections(sharedEntries, (e) => e).map((s) => ({
3356
+ label: s.label,
3357
+ entries: s.items.map((entry) => ({
3358
+ ...entry,
3359
+ line: renderChangelogEntryLine(entry, refs, repoUrl ?? null)
3360
+ }))
3361
+ }))
3295
3362
  };
3296
3363
  }
3297
3364
  async function processWithLLM(context, llmConfig, examples, packageNames) {
@@ -3308,9 +3375,8 @@ async function processWithLLM(context, llmConfig, examples, packageNames) {
3308
3375
  examples,
3309
3376
  packageNames
3310
3377
  };
3311
- const enhanced = {
3312
- entries: context.entries
3313
- };
3378
+ let entries = context.entries;
3379
+ const enhanced = {};
3314
3380
  let provider;
3315
3381
  try {
3316
3382
  info(`Using LLM provider: ${llmConfig.provider}${llmConfig.model ? ` (${llmConfig.model})` : ""}`);
@@ -3333,7 +3399,7 @@ async function processWithLLM(context, llmConfig, examples, packageNames) {
3333
3399
  info(`Running LLM tasks: ${activeTasks.join(", ")}`);
3334
3400
  } catch (error2) {
3335
3401
  warn(`LLM setup failed: ${error2 instanceof Error ? error2.message : String(error2)}`);
3336
- warn("Falling back to non-LLM changelog rendering. Check your LLM config or set RELEASEKIT_DEBUG=1 for details.");
3402
+ warn("Falling back to non-LLM release notes. Check your LLM config or set RELEASEKIT_DEBUG=1 for details.");
3337
3403
  return context;
3338
3404
  }
3339
3405
  const taskFailed = (task, error2) => {
@@ -3342,10 +3408,10 @@ async function processWithLLM(context, llmConfig, examples, packageNames) {
3342
3408
  if (tasks.enhance && tasks.categorize) {
3343
3409
  try {
3344
3410
  info("Enhancing and categorizing entries with LLM...");
3345
- const result = await enhanceAndCategorize(provider, context.entries, llmContext);
3346
- enhanced.entries = result.enhancedEntries;
3411
+ const result = await enhanceAndCategorize(provider, entries, llmContext);
3412
+ entries = result.enhancedEntries;
3347
3413
  enhanced.categories = buildOrderedCategories(result.categories, llmContext.categories);
3348
- info(`Enhanced ${enhanced.entries.length} entries into ${result.categories.length} categories`);
3414
+ info(`Enhanced ${entries.length} entries into ${result.categories.length} categories`);
3349
3415
  } catch (error2) {
3350
3416
  taskFailed("enhance+categorize", error2);
3351
3417
  }
@@ -3353,8 +3419,8 @@ async function processWithLLM(context, llmConfig, examples, packageNames) {
3353
3419
  if (tasks.enhance) {
3354
3420
  try {
3355
3421
  info("Enhancing entries with LLM...");
3356
- enhanced.entries = await enhanceEntries(provider, context.entries, llmContext, llmConfig.concurrency);
3357
- info(`Enhanced ${enhanced.entries.length} entries`);
3422
+ entries = await enhanceEntries(provider, entries, llmContext, llmConfig.concurrency);
3423
+ info(`Enhanced ${entries.length} entries`);
3358
3424
  } catch (error2) {
3359
3425
  taskFailed("enhance", error2);
3360
3426
  }
@@ -3362,7 +3428,7 @@ async function processWithLLM(context, llmConfig, examples, packageNames) {
3362
3428
  if (tasks.categorize) {
3363
3429
  try {
3364
3430
  info("Categorizing entries with LLM...");
3365
- const categorized = await categorizeEntries(provider, enhanced.entries, llmContext);
3431
+ const categorized = await categorizeEntries(provider, entries, llmContext);
3366
3432
  enhanced.categories = buildOrderedCategories(categorized, llmContext.categories);
3367
3433
  info(`Created ${categorized.length} categories`);
3368
3434
  } catch (error2) {
@@ -3373,7 +3439,7 @@ async function processWithLLM(context, llmConfig, examples, packageNames) {
3373
3439
  if (tasks.summarize) {
3374
3440
  try {
3375
3441
  info("Summarizing entries with LLM...");
3376
- enhanced.summary = await summarizeEntries(provider, enhanced.entries, llmContext);
3442
+ enhanced.summary = await summarizeEntries(provider, entries, llmContext);
3377
3443
  if (enhanced.summary) {
3378
3444
  info("Summary generated successfully");
3379
3445
  debug(`Summary: ${enhanced.summary.substring(0, 100)}...`);
@@ -3387,7 +3453,7 @@ async function processWithLLM(context, llmConfig, examples, packageNames) {
3387
3453
  if (tasks.releaseNotes) {
3388
3454
  try {
3389
3455
  info("Generating release notes with LLM...");
3390
- enhanced.releaseNotes = await generateReleaseNotes(provider, enhanced.entries, llmContext);
3456
+ enhanced.releaseNotes = await generateReleaseNotes(provider, entries, llmContext);
3391
3457
  if (enhanced.releaseNotes) {
3392
3458
  info("Release notes generated successfully");
3393
3459
  } else {
@@ -3399,49 +3465,34 @@ async function processWithLLM(context, llmConfig, examples, packageNames) {
3399
3465
  }
3400
3466
  return {
3401
3467
  ...context,
3468
+ entries,
3402
3469
  enhanced
3403
3470
  };
3404
3471
  }
3405
- function getBuiltinTemplatePath(style) {
3406
- let packageRoot;
3407
- try {
3408
- const currentUrl = import.meta.url;
3409
- packageRoot = path12.dirname(new URL(currentUrl).pathname);
3410
- packageRoot = path12.join(packageRoot, "..", "..");
3411
- } catch {
3412
- packageRoot = __dirname;
3413
- }
3414
- return path12.join(packageRoot, "templates", style);
3415
- }
3416
- async function generateWithTemplate(contexts, templatesConfig, outputPath, repoUrl, dryRun) {
3417
- let templatePath;
3418
- if (templatesConfig?.path) {
3419
- templatePath = path12.resolve(templatesConfig.path);
3420
- } else {
3421
- templatePath = getBuiltinTemplatePath("keep-a-changelog");
3422
- }
3423
- const documentContext = createDocumentContext(contexts, templatesConfig?.path ? void 0 : repoUrl);
3424
- const result = renderTemplate(templatePath, documentContext, templatesConfig?.engine);
3425
- if (dryRun) {
3426
- info(`[DRY RUN] Changelog preview (would write to ${outputPath}):`);
3427
- info(result.content);
3428
- return;
3429
- }
3430
- if (outputPath === "-") {
3431
- process.stdout.write(result.content);
3432
- return;
3433
- }
3434
- const dir = path12.dirname(outputPath);
3435
- if (!fs13.existsSync(dir)) {
3436
- fs13.mkdirSync(dir, { recursive: true });
3472
+ function renderReleaseNotes(ctx, output, releaseNotesConfig, fmtOpts) {
3473
+ if (releaseNotesConfig.templates?.path) {
3474
+ const templatePath = path12.resolve(releaseNotesConfig.templates.path);
3475
+ const docCtx = {
3476
+ ...createDocumentContext([ctx], ctx.repoUrl ?? void 0, fmtOpts),
3477
+ perPackage: true,
3478
+ output
3479
+ };
3480
+ return renderTemplate(templatePath, docCtx, releaseNotesConfig.templates.engine).content;
3437
3481
  }
3438
- fs13.writeFileSync(outputPath, result.content, "utf-8");
3439
- const label = /changelog/i.test(outputPath) ? "Changelog" : "Release notes";
3440
- success(`${label} written to ${outputPath} (using ${result.engine} template)`);
3482
+ const refs = fmtOpts.refs ?? "link";
3483
+ const prose = ctx.enhanced?.releaseNotes;
3484
+ const own = prose ? [prose.trimEnd(), sharedPackageBlock(ctx, refs)] : [formatVersion(ctx, fmtOpts).trimEnd()];
3485
+ const blocks = [...own, ...renderBundledBlocks(ctx.bundled ?? [], 3, refs, ctx.repoUrl)].filter(
3486
+ (block) => !!block
3487
+ );
3488
+ return prose && blocks.length === 1 ? prose : `${blocks.join("\n\n")}
3489
+ `;
3441
3490
  }
3442
3491
  async function runPipeline(input, config, dryRun, pipelineOptions) {
3443
3492
  debug(`Processing ${input.packages.length} package(s)`);
3444
- let contexts = input.packages.map(createTemplateContext);
3493
+ const changelogContexts = input.packages.map(createTemplateContext);
3494
+ const releaseNotesFor = pipelineOptions?.releaseNotesFor;
3495
+ let releaseNotesContexts = releaseNotesFor ? changelogContexts.filter((ctx) => releaseNotesFor.includes(ctx.packageName)) : changelogContexts;
3445
3496
  const changelogConfig = config.changelog === false ? false : { mode: "root", ...config.changelog ?? {} };
3446
3497
  const releaseNotesConfig = config.releaseNotes === false || config.releaseNotes === void 0 ? void 0 : config.releaseNotes;
3447
3498
  const llmConfig = releaseNotesConfig?.llm;
@@ -3449,18 +3500,18 @@ async function runPipeline(input, config, dryRun, pipelineOptions) {
3449
3500
  assertLlmModel(llmConfig);
3450
3501
  info("Processing with LLM enhancement");
3451
3502
  const examplesCount = llmConfig.examples ?? 3;
3452
- const repoUrl = contexts[0]?.repoUrl ?? input.metadata?.repoUrl;
3503
+ const repoUrl = releaseNotesContexts[0]?.repoUrl ?? input.metadata?.repoUrl;
3453
3504
  const ownerRepo = repoUrl ? parseGitHubOwnerRepo(repoUrl) : null;
3454
3505
  const examplesByPackage = /* @__PURE__ */ new Map();
3455
3506
  if (examplesCount > 0 && ownerRepo) {
3456
3507
  await Promise.all(
3457
- contexts.map(async (ctx) => {
3508
+ releaseNotesContexts.map(async (ctx) => {
3458
3509
  const examples = await fetchExamples({
3459
3510
  owner: ownerRepo.owner,
3460
3511
  repo: ownerRepo.repo,
3461
3512
  packageName: ctx.packageName,
3462
3513
  count: examplesCount,
3463
- isMonorepo: contexts.length > 1
3514
+ isMonorepo: input.packages.length > 1
3464
3515
  });
3465
3516
  examplesByPackage.set(ctx.packageName, examples);
3466
3517
  if (examples.length > 0) {
@@ -3473,7 +3524,9 @@ async function runPipeline(input, config, dryRun, pipelineOptions) {
3473
3524
  const pullRequestsEnabled = llmConfig.context?.pullRequests !== false;
3474
3525
  if (pullRequestsEnabled && ownerRepo) {
3475
3526
  const allIssueNumbers = [
3476
- ...new Set(contexts.flatMap((ctx) => ctx.entries.flatMap((e) => parseIssueNumbers(e.issueIds ?? []))))
3527
+ ...new Set(
3528
+ releaseNotesContexts.flatMap((ctx) => ctx.entries.flatMap((e) => parseIssueNumbers(e.issueIds ?? [])))
3529
+ )
3477
3530
  ];
3478
3531
  if (allIssueNumbers.length > 0) {
3479
3532
  const token = resolveGitHubToken();
@@ -3487,7 +3540,7 @@ async function runPipeline(input, config, dryRun, pipelineOptions) {
3487
3540
  }
3488
3541
  }
3489
3542
  if (prCache.size > 0) {
3490
- contexts = contexts.map((ctx) => ({
3543
+ releaseNotesContexts = releaseNotesContexts.map((ctx) => ({
3491
3544
  ...ctx,
3492
3545
  entries: ctx.entries.map((entry) => {
3493
3546
  const prs = parseIssueNumbers(entry.issueIds ?? []).map((n) => prCache.get(n)).filter((pr) => pr != null);
@@ -3495,50 +3548,69 @@ async function runPipeline(input, config, dryRun, pipelineOptions) {
3495
3548
  })
3496
3549
  }));
3497
3550
  }
3498
- const allPackageNames = contexts.map((c) => c.packageName);
3551
+ const allPackageNames = input.packages.map((p) => p.packageName);
3499
3552
  const concurrency = llmConfig.concurrency ?? LLM_DEFAULTS.concurrency;
3500
- contexts = await mapWithConcurrency(
3501
- contexts,
3553
+ releaseNotesContexts = await mapWithConcurrency(
3554
+ releaseNotesContexts,
3502
3555
  concurrency,
3503
3556
  (ctx) => processWithLLM(ctx, llmConfig, examplesByPackage.get(ctx.packageName) ?? [], allPackageNames)
3504
3557
  );
3505
3558
  }
3559
+ const sharedEntries = input.sharedEntries ?? [];
3560
+ const packages = new Map(input.packages.map((pkg) => [pkg.packageName, pkg]));
3561
+ const withShared = (ctx) => {
3562
+ const pkg = packages.get(ctx.packageName);
3563
+ const shared = pkg ? sharedPackageEntriesOf(pkg, sharedEntries) : [];
3564
+ return shared.length > 0 ? { ...ctx, sharedEntries: shared } : ctx;
3565
+ };
3566
+ const releases = [...input.bundledReleases ?? [], ...input.packages];
3567
+ const withBundled = (ctx) => {
3568
+ const bundled = resolveBundled(packages.get(ctx.packageName)?.bundled, releases);
3569
+ if (bundled.length === 0) {
3570
+ return ctx;
3571
+ }
3572
+ const entries = ctx.entries.filter((e) => e.description !== `Update version to ${ctx.version}`);
3573
+ return { ...ctx, entries, bundled };
3574
+ };
3575
+ releaseNotesContexts = releaseNotesContexts.map(withShared).map(withBundled);
3506
3576
  const files = [];
3507
3577
  const fmtOpts = {
3508
- includePackageName: contexts.length > 1 || contexts.some((c) => c.packageName.includes("/")),
3578
+ includePackageName: input.packages.length > 1 || changelogContexts.some((c) => c.packageName.includes("/")),
3509
3579
  categoryOrder: llmConfig?.categoryOrder,
3510
3580
  links: releaseNotesConfig?.links,
3511
3581
  firstRelease: releaseNotesConfig?.firstRelease,
3512
- refs: (changelogConfig !== false ? changelogConfig.refs : void 0) ?? "link"
3582
+ refs: configuredRefsMode(config)
3513
3583
  };
3514
- if (!pipelineOptions?.skipChangelogs && changelogConfig !== false && changelogConfig.mode) {
3584
+ if (!pipelineOptions?.skipChangelogs && !releaseNotesFor && changelogConfig !== false && changelogConfig.mode) {
3515
3585
  const fileName = changelogConfig.file ?? "CHANGELOG.md";
3516
3586
  const mode = changelogConfig.mode;
3587
+ const templates = changelogConfig.templates;
3588
+ const renderChangelog = (ctxs, options, runSharedEntries) => templates?.path ? renderTemplate(
3589
+ path12.resolve(templates.path),
3590
+ createDocumentContext(ctxs, ctxs[0]?.repoUrl ?? void 0, options, runSharedEntries),
3591
+ templates.engine
3592
+ ).content : renderMarkdown(ctxs, options, runSharedEntries);
3517
3593
  info(`Generating changelog \u2192 ${fileName}`);
3518
3594
  try {
3519
3595
  if (mode === "root" || mode === "both") {
3520
- if (changelogConfig.templates?.path) {
3521
- await generateWithTemplate(
3522
- contexts,
3523
- changelogConfig.templates,
3524
- fileName,
3525
- contexts[0]?.repoUrl ?? void 0,
3526
- dryRun
3527
- );
3528
- } else {
3529
- writeMarkdown(fileName, contexts, config, dryRun, fmtOpts);
3530
- }
3596
+ const runEntries = changelogContexts.flatMap((ctx) => ctx.entries);
3597
+ writeChangelog(
3598
+ fileName,
3599
+ renderChangelog(changelogContexts, fmtOpts, unlistedEntries(sharedEntries, runEntries)),
3600
+ dryRun
3601
+ );
3531
3602
  if (!dryRun) {
3532
3603
  files.push(fileName);
3533
3604
  }
3534
3605
  }
3535
3606
  if (mode === "packages" || mode === "both") {
3607
+ const refs = fmtOpts.refs;
3536
3608
  const monoFiles = await writeMonorepoFiles(
3537
- contexts,
3609
+ changelogContexts.map(withShared),
3538
3610
  config,
3539
3611
  dryRun,
3540
- changelogConfig.file ?? "CHANGELOG.md",
3541
- fmtOpts.refs ?? "link"
3612
+ fileName,
3613
+ (ctxs) => renderChangelog(ctxs, { refs })
3542
3614
  );
3543
3615
  files.push(...monoFiles);
3544
3616
  }
@@ -3550,57 +3622,37 @@ async function runPipeline(input, config, dryRun, pipelineOptions) {
3550
3622
  const dir = releaseNotesConfig.file.dir;
3551
3623
  info(`Generating release notes \u2192 ${dir}`);
3552
3624
  try {
3553
- const { detectMonorepo } = await import("./aggregator-JHRFNT67.js");
3554
- const nested = detectMonorepo(process.cwd()).isMonorepo || contexts.length > 1;
3555
- const renderContent = (ctx) => {
3556
- if (releaseNotesConfig.templates?.path) {
3557
- const templatePath = path12.resolve(releaseNotesConfig.templates.path);
3558
- const docCtx = { ...createDocumentContext([ctx], void 0), perPackage: true, output: "file" };
3559
- return renderTemplate(templatePath, docCtx, releaseNotesConfig.templates.engine).content;
3560
- }
3561
- if (ctx.enhanced?.releaseNotes) {
3562
- return ctx.enhanced.releaseNotes;
3563
- }
3564
- return formatVersion(ctx, fmtOpts);
3565
- };
3566
- const versionedFiles = writeVersionedNotes(contexts, dir, dryRun, nested, renderContent);
3625
+ const nested = nestsReleaseNotes(input.packages.length);
3626
+ const versionedFiles = writeVersionedNotes(
3627
+ releaseNotesContexts,
3628
+ dir,
3629
+ dryRun,
3630
+ nested,
3631
+ (ctx) => renderReleaseNotes(ctx, "file", releaseNotesConfig, fmtOpts)
3632
+ );
3567
3633
  files.push(...versionedFiles);
3568
3634
  } catch (error2) {
3569
3635
  warn(`Failed to write release notes: ${error2 instanceof Error ? error2.message : String(error2)}`);
3570
3636
  }
3571
3637
  }
3572
- const packageNotes = {};
3638
+ const packageNotes = Object.fromEntries(
3639
+ changelogContexts.map((ctx) => [
3640
+ ctx.packageName,
3641
+ formatVersion(withShared(ctx), { firstRelease: releaseNotesConfig?.firstRelease })
3642
+ ])
3643
+ );
3573
3644
  const releaseNotesResult = {};
3574
- for (const ctx of contexts) {
3575
- packageNotes[ctx.packageName] = formatVersion(ctx, { firstRelease: releaseNotesConfig?.firstRelease });
3576
- if (pipelineOptions?.skipReleaseNotes) {
3645
+ for (const ctx of releaseNotesContexts) {
3646
+ if (pipelineOptions?.skipReleaseNotes || !releaseNotesConfig) {
3577
3647
  continue;
3578
3648
  }
3579
- if (ctx.enhanced?.releaseNotes) {
3580
- releaseNotesResult[ctx.packageName] = ctx.enhanced.releaseNotes;
3581
- } else if (releaseNotesConfig) {
3582
- if (releaseNotesConfig.templates?.path) {
3583
- try {
3584
- const templatePath = path12.resolve(releaseNotesConfig.templates.path);
3585
- const docCtx = { ...createDocumentContext([ctx], void 0), perPackage: true, output: "release" };
3586
- const rendered = renderTemplate(
3587
- templatePath,
3588
- docCtx,
3589
- releaseNotesConfig.templates.engine
3590
- );
3591
- releaseNotesResult[ctx.packageName] = rendered.content;
3592
- } catch (err) {
3593
- warn(
3594
- `Failed to render release notes template for ${ctx.packageName}: ${err instanceof Error ? err.message : String(err)}`
3595
- );
3596
- warn(`Release notes preview will not be available for ${ctx.packageName} in the workflow summary`);
3597
- }
3598
- } else {
3599
- info(
3600
- `No LLM release notes or template output for ${ctx.packageName}, using formatted changelog as release notes preview`
3601
- );
3602
- releaseNotesResult[ctx.packageName] = formatVersion(ctx, { firstRelease: releaseNotesConfig?.firstRelease });
3603
- }
3649
+ try {
3650
+ releaseNotesResult[ctx.packageName] = renderReleaseNotes(ctx, "release", releaseNotesConfig, fmtOpts);
3651
+ } catch (err) {
3652
+ warn(
3653
+ `Failed to render release notes for ${ctx.packageName}: ${err instanceof Error ? err.message : String(err)}`
3654
+ );
3655
+ warn(`${ctx.packageName}'s GitHub release body uses the githubRelease.body fallback instead`);
3604
3656
  }
3605
3657
  }
3606
3658
  return {
@@ -3613,37 +3665,34 @@ async function processInput(inputJson, config, dryRun, pipelineOptions) {
3613
3665
  const input = parseVersionOutput(inputJson);
3614
3666
  return runPipeline(input, config, dryRun, pipelineOptions);
3615
3667
  }
3616
- async function writeMonorepoFiles(contexts, config, dryRun, fileName, refs) {
3617
- const { detectMonorepo, writeMonorepoChangelogs } = await import("./aggregator-JHRFNT67.js");
3668
+ async function writeMonorepoFiles(contexts, config, dryRun, fileName, render) {
3669
+ const { detectMonorepo: detectMonorepo2, writeMonorepoChangelogs } = await import("./aggregator-XM2XIYDF.js");
3618
3670
  const cwd = process.cwd();
3619
- const detected = detectMonorepo(cwd);
3671
+ const detected = detectMonorepo2(cwd);
3620
3672
  if (!detected.isMonorepo) {
3621
3673
  return [];
3622
3674
  }
3623
- const monoFiles = writeMonorepoChangelogs(
3675
+ return writeMonorepoChangelogs(
3624
3676
  contexts,
3625
3677
  {
3626
3678
  rootPath: config.monorepo?.rootPath ?? cwd,
3627
3679
  packagesPath: config.monorepo?.packagesPath ?? detected.packagesPath,
3628
- mode: "packages",
3629
3680
  fileName
3630
3681
  },
3631
- config,
3632
- dryRun,
3633
- refs
3682
+ render,
3683
+ dryRun
3634
3684
  );
3635
- return monoFiles;
3636
3685
  }
3637
3686
 
3638
3687
  // src/command.ts
3639
- import * as fs14 from "fs";
3688
+ import * as fs13 from "fs";
3640
3689
  import * as readline from "readline";
3641
3690
  import { Command } from "commander";
3642
3691
  function createNotesCommand() {
3643
3692
  const cmd = new Command("notes").description(
3644
- "Generate changelogs with LLM-powered enhancement and flexible templating"
3693
+ "Generate changelogs and release notes, with LLM-enhanced release notes and flexible templating"
3645
3694
  );
3646
- cmd.command("generate", { isDefault: true }).description("Generate changelog from input data").option("-i, --input <file>", "Input file (default: stdin)").option("--no-changelog", "Disable changelog generation").option("--changelog-mode <mode>", "Changelog location mode (root|packages|both)").option("--changelog-file <name>", "Changelog file name override").option("--release-notes-dir <dir>", "Write per-version release-notes files to this directory").option("--no-release-notes", "Disable release notes generation").option("-t, --template <path>", "Template file or directory").option("-e, --engine <engine>", "Template engine (handlebars|liquid|ejs)").option("--monorepo <mode>", "Monorepo mode (root|packages|both)").option("--llm-provider <provider>", "LLM provider").option("--llm-model <model>", "LLM model").option("--llm-base-url <url>", "LLM base URL (for openai-compatible provider)").option("--llm-tasks <tasks>", "Comma-separated LLM tasks").option("--no-llm", "Disable LLM processing").option("--target <package>", "Filter to a specific package name").option("--config <path>", "Config file path").option("--regenerate", "Regenerate entire changelog instead of prepending new entries").option("--dry-run", "Preview without writing").option("-v, --verbose", "Increase verbosity", increaseVerbosity, 0).option("-q, --quiet", "Suppress non-error output").action(async (options) => {
3695
+ cmd.command("generate", { isDefault: true }).description("Generate changelog from input data").option("-i, --input <file>", "Input file (default: stdin)").option("--no-changelog", "Disable changelog generation").option("--changelog-mode <mode>", "Changelog location mode (root|packages|both)").option("--changelog-file <name>", "Changelog file name override").option("--release-notes-dir <dir>", "Write per-version release-notes files to this directory").option("--no-release-notes", "Disable release notes generation").option("-t, --template <path>", "Template file or directory").option("-e, --engine <engine>", "Template engine (handlebars|liquid|ejs)").option("--monorepo <mode>", "Monorepo mode (root|packages|both)").option("--llm-provider <provider>", "LLM provider").option("--llm-model <model>", "LLM model").option("--llm-base-url <url>", "LLM base URL (for openai-compatible provider)").option("--llm-tasks <tasks>", "Comma-separated LLM tasks").option("--no-llm", "Disable LLM processing").option("--target <package>", "Filter to a specific package name").option("--config <path>", "Config file path").option("--dry-run", "Preview without writing").option("-v, --verbose", "Increase verbosity", increaseVerbosity, 0).option("-q, --quiet", "Suppress non-error output").action(async (options) => {
3647
3696
  setVerbosity(options.verbose);
3648
3697
  if (options.quiet) {
3649
3698
  setQuietMode(true);
@@ -3692,9 +3741,6 @@ function createNotesCommand() {
3692
3741
  templates: { ...existing.templates, engine: options.engine }
3693
3742
  };
3694
3743
  }
3695
- if (options.regenerate) {
3696
- config.updateStrategy = "regenerate";
3697
- }
3698
3744
  if (options.llm === false) {
3699
3745
  if (config.releaseNotes && typeof config.releaseNotes !== "boolean" && config.releaseNotes.llm) {
3700
3746
  info("LLM processing disabled via --no-llm flag");
@@ -3754,9 +3800,19 @@ function createNotesCommand() {
3754
3800
  }
3755
3801
  }
3756
3802
  }
3803
+ const releaseNotes = config.releaseNotes;
3804
+ if (releaseNotes && runsLlmTasks(releaseNotes.llm) && !releaseNotes.file?.dir) {
3805
+ const message = "Skipping the LLM: its tasks shape release notes, and this run writes none. Pass --release-notes-dir or set notes.releaseNotes.file.dir to write them.";
3806
+ if (options.llmProvider || options.llmModel || options.llmBaseUrl || options.llmTasks) {
3807
+ warn(message);
3808
+ } else {
3809
+ info(message);
3810
+ }
3811
+ config.releaseNotes = { ...releaseNotes, llm: void 0 };
3812
+ }
3757
3813
  let inputJson;
3758
3814
  if (options.input) {
3759
- inputJson = fs14.readFileSync(options.input, "utf-8");
3815
+ inputJson = fs13.readFileSync(options.input, "utf-8");
3760
3816
  } else {
3761
3817
  inputJson = await readStdin();
3762
3818
  }
@@ -3858,6 +3914,8 @@ export {
3858
3914
  parseVersionOutputStdin,
3859
3915
  loadConfig2 as loadConfig,
3860
3916
  getDefaultConfig,
3917
+ nestsReleaseNotes,
3918
+ writeVersionedNotes,
3861
3919
  createTemplateContext,
3862
3920
  runPipeline,
3863
3921
  processInput,