@releasekit/notes 0.20.0 → 0.22.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.
package/README.md CHANGED
@@ -19,9 +19,15 @@ Generates CHANGELOG.md and release notes from `@releasekit/version` output, with
19
19
 
20
20
  ## Installation
21
21
 
22
+ **npm:**
23
+
22
24
  ```bash
23
25
  npm install -g @releasekit/notes
24
- # or
26
+ ```
27
+
28
+ **pnpm:**
29
+
30
+ ```bash
25
31
  pnpm add -g @releasekit/notes
26
32
  ```
27
33
 
@@ -76,6 +76,23 @@ var VersionCargoConfigSchema = z.object({
76
76
  });
77
77
  var VersionConfigSchema = z.object({
78
78
  tagTemplate: z.string().default("v{version}"),
79
+ /**
80
+ * Optional secondary tag template for an internal "baseline" marker that records the
81
+ * release commit on the source branch. Use this when `tagTemplate` resolves to a tag that
82
+ * gets force-moved off the source branch by a downstream step (for example, a GitHub
83
+ * Action distributing built artifacts at the version tag) — the baseline tag stays on the
84
+ * release commit so version-bump and changelog calculations can still find the previous
85
+ * release in the working branch's history.
86
+ *
87
+ * Supports `${packageName}`, `${prefix}`, `${version}` substitutions. Leave unset for
88
+ * single-tag workflows (the default).
89
+ */
90
+ baselineTagTemplate: z.string().refine((tpl) => tpl.includes("${version}"), {
91
+ message: (
92
+ // biome-ignore lint/suspicious/noTemplateCurlyInString: documenting the expected placeholder syntax to the user
93
+ 'baselineTagTemplate must contain a ${version} placeholder so the prefix can be derived (e.g. "release/${prefix}${version}").'
94
+ )
95
+ }).optional(),
79
96
  packageSpecificTags: z.boolean().default(false),
80
97
  preset: z.string().default("conventional"),
81
98
  sync: z.boolean().default(true),
@@ -241,7 +258,9 @@ var LLMCategorySchema = z.object({
241
258
  });
242
259
  var ScopeRulesSchema = z.object({
243
260
  allowed: z.array(z.string()).optional(),
244
- caseSensitive: z.boolean().default(false)
261
+ caseSensitive: z.boolean().default(false),
262
+ invalidScopeAction: z.enum(["remove", "keep", "fallback"]).default("remove"),
263
+ fallbackScope: z.string().optional()
245
264
  });
246
265
  var ScopeConfigSchema = z.object({
247
266
  mode: z.enum(["restricted", "packages", "none", "unrestricted"]).default("unrestricted"),
@@ -305,9 +324,11 @@ var NotesConfigSchema = z.object({
305
324
  updateStrategy: z.enum(["prepend", "regenerate"]).optional()
306
325
  });
307
326
  var CILabelsConfigSchema = z.object({
308
- stable: z.string().default("release:stable"),
309
- prerelease: z.string().default("release:prerelease"),
327
+ stable: z.string().default("channel:stable"),
328
+ prerelease: z.string().default("channel:prerelease"),
310
329
  skip: z.string().default("release:skip"),
330
+ /** Bypass the standing PR for one merge — triggers a direct release. Standing-pr mode only. */
331
+ immediate: z.string().default("release:immediate"),
311
332
  major: z.string().default("bump:major"),
312
333
  minor: z.string().default("bump:minor"),
313
334
  patch: z.string().default("bump:patch")
@@ -322,8 +343,6 @@ var StandingPrConfigSchema = z.object({
322
343
  labels: z.array(z.string()).default(["release"]),
323
344
  /** Whether to auto-delete the release branch after PR merge. Default: true */
324
345
  deleteBranchOnMerge: z.boolean().default(true),
325
- /** Allow teams to edit the release notes section in the PR body before publishing. Default: false */
326
- editableNotes: z.boolean().default(false),
327
346
  /** Merge method to use when merging the standing release PR. Default: 'merge' */
328
347
  mergeMethod: z.enum(["merge", "squash", "rebase"]).default("merge"),
329
348
  /** Minimum age of the standing PR before it can be merged. Duration string (e.g. '6h', '30m', '1d'). Gate enforced via the releasekit/standing-pr status check. */
@@ -332,7 +351,7 @@ var StandingPrConfigSchema = z.object({
332
351
  minPackages: z.number().int().positive().optional()
333
352
  });
334
353
  var CIConfigSchema = z.object({
335
- releaseStrategy: z.enum(["manual", "direct", "standing-pr", "scheduled"]).default("direct"),
354
+ releaseStrategy: z.enum(["manual", "direct", "standing-pr"]).default("direct"),
336
355
  releaseTrigger: z.enum(["commit", "label"]).default("label"),
337
356
  prPreview: z.boolean().default(true),
338
357
  autoRelease: z.boolean().default(false),
@@ -345,9 +364,10 @@ var CIConfigSchema = z.object({
345
364
  skipPatterns: z.array(z.string()).default(["chore: release "]),
346
365
  minChanges: z.number().int().positive().default(1),
347
366
  labels: CILabelsConfigSchema.default({
348
- stable: "release:stable",
349
- prerelease: "release:prerelease",
367
+ stable: "channel:stable",
368
+ prerelease: "channel:prerelease",
350
369
  skip: "release:skip",
370
+ immediate: "release:immediate",
351
371
  major: "bump:major",
352
372
  minor: "bump:minor",
353
373
  patch: "bump:patch"
@@ -690,8 +710,14 @@ async function fetchPullRequestContext(owner, repo, issueNumbers, token, cache)
690
710
  const body = truncateBody(sanitiseBody(raw));
691
711
  cache.set(number, { number, title: data.title, body });
692
712
  } catch (error2) {
693
- if (error2 instanceof RequestError && (error2.status === 401 || error2.status === 403)) {
694
- warn(`GitHub API auth error fetching PR #${number} (${error2.status}): check GITHUB_TOKEN permissions`);
713
+ if (error2 instanceof RequestError) {
714
+ if (error2.status === 401 || error2.status === 403) {
715
+ warn(`GitHub API auth error fetching PR #${number} (${error2.status}): check GITHUB_TOKEN permissions`);
716
+ } else if (error2.status === 404) {
717
+ cache.set(number, null);
718
+ } else {
719
+ debug(`Failed to fetch PR #${number}: ${error2.message}`);
720
+ }
695
721
  } else {
696
722
  debug(`Failed to fetch PR #${number}: ${error2 instanceof Error ? error2.message : String(error2)}`);
697
723
  }
@@ -701,7 +727,7 @@ async function fetchPullRequestContext(owner, repo, issueNumbers, token, cache)
701
727
  }
702
728
  }
703
729
  function parseIssueNumbers(issueIds) {
704
- return issueIds.map((id) => parseInt(id.replace(/^#/, ""), 10)).filter((n) => !isNaN(n) && n > 0);
730
+ return issueIds.map((id) => parseInt(id.replace(/^#/, ""), 10)).filter((n) => !Number.isNaN(n) && n > 0);
705
731
  }
706
732
  function resolveGitHubToken() {
707
733
  return process.env.GITHUB_TOKEN || process.env.GH_TOKEN || void 0;
@@ -1308,7 +1334,14 @@ function validateEntryScopes(entries, scopeConfig, categories) {
1308
1334
  const allowedScopes = resolveAllowedScopes(scopeConfig, categories);
1309
1335
  if (allowedScopes === null) return { valid: true, entries, errors: [] };
1310
1336
  const caseSensitive = scopeConfig?.rules?.caseSensitive ?? false;
1337
+ const action = scopeConfig?.rules?.invalidScopeAction ?? "remove";
1338
+ const fallback = scopeConfig?.rules?.fallbackScope;
1311
1339
  const errors = [];
1340
+ if (action === "fallback" && fallback !== void 0 && validateScope(fallback, allowedScopes, caseSensitive) === void 0) {
1341
+ warn(
1342
+ `scopes.rules.fallbackScope "${fallback}" is not in the allowed scope list (${allowedScopes.length ? allowedScopes.join(", ") : "<empty>"}); substituted scopes will violate the allow-list. Add "${fallback}" to the allow list or change invalidScopeAction.`
1343
+ );
1344
+ }
1312
1345
  const validatedEntries = entries.map((entry, index) => {
1313
1346
  const cleaned = validateScope(entry.scope, allowedScopes, caseSensitive);
1314
1347
  if (entry.scope && cleaned === void 0) {
@@ -1317,11 +1350,12 @@ function validateEntryScopes(entries, scopeConfig, categories) {
1317
1350
  providedScope: entry.scope,
1318
1351
  allowedScopes
1319
1352
  });
1320
- return { ...entry, scope: void 0 };
1353
+ const replacement = action === "keep" ? entry.scope : action === "fallback" ? fallback : void 0;
1354
+ return { ...entry, scope: replacement };
1321
1355
  }
1322
1356
  return entry.scope !== cleaned ? { ...entry, scope: cleaned } : entry;
1323
1357
  });
1324
- return { valid: errors.length === 0, entries: validatedEntries, errors };
1358
+ return { valid: true, entries: validatedEntries, errors };
1325
1359
  }
1326
1360
 
1327
1361
  // src/llm/tasks/shared.ts
@@ -1434,11 +1468,11 @@ function makeValidator(entries, context) {
1434
1468
  return scope ? { ...entry, scope } : entry;
1435
1469
  });
1436
1470
  const scopeResult = validateEntryScopes(withScopes, context.scopes, context.categories);
1437
- if (!scopeResult.valid) {
1438
- const msg = scopeResult.errors.map(
1439
- (e) => `entry ${e.entryIndex} scope "${e.providedScope}" (${e.allowedScopes.length ? `valid: ${e.allowedScopes.join(", ")}` : "no scopes permitted"})`
1440
- ).join("; ");
1441
- return { valid: false, error: `Invalid scopes: ${msg}` };
1471
+ if (scopeResult.errors.length > 0) {
1472
+ const offenders = [...new Set(scopeResult.errors.map((e) => e.providedScope))];
1473
+ warn(
1474
+ `LLM returned ${scopeResult.errors.length} entries with disallowed scopes (${offenders.join(", ")}); resolved per invalidScopeAction.`
1475
+ );
1442
1476
  }
1443
1477
  return { valid: true, value: groupByCategory(zodResult.data.entries, scopeResult.entries) };
1444
1478
  };
@@ -1594,12 +1628,17 @@ function makeValidator2(entries, context) {
1594
1628
  if (!zodResult.success) {
1595
1629
  return { valid: false, error: `Schema error: ${zodResult.error.message}` };
1596
1630
  }
1597
- if (zodResult.data.entries.length !== entries.length) {
1631
+ const receivedCount = zodResult.data.entries.length;
1632
+ if (receivedCount < entries.length) {
1598
1633
  return {
1599
1634
  valid: false,
1600
- error: `Expected ${entries.length} entries, got ${zodResult.data.entries.length}`
1635
+ error: `Expected ${entries.length} entries, got ${receivedCount} (entries missing \u2014 cannot proceed)`
1601
1636
  };
1602
1637
  }
1638
+ if (receivedCount > entries.length) {
1639
+ warn(`LLM returned ${receivedCount} entries for ${entries.length} inputs; truncating to expected count.`);
1640
+ zodResult.data.entries.length = entries.length;
1641
+ }
1603
1642
  const categoryNames = context.categories?.map((c) => c.name);
1604
1643
  if (categoryNames?.length) {
1605
1644
  const invalid = zodResult.data.entries.filter((e) => !categoryNames.includes(e.category)).map((e) => e.category);
@@ -1623,11 +1662,11 @@ function makeValidator2(entries, context) {
1623
1662
  };
1624
1663
  });
1625
1664
  const scopeResult = validateEntryScopes(enhancedEntries, context.scopes, context.categories);
1626
- if (!scopeResult.valid) {
1627
- const msg = scopeResult.errors.map(
1628
- (e) => `entry ${e.entryIndex} scope "${e.providedScope}" (${e.allowedScopes.length ? `valid: ${e.allowedScopes.join(", ")}` : "no scopes permitted"})`
1629
- ).join("; ");
1630
- return { valid: false, error: `Invalid scopes: ${msg}` };
1665
+ if (scopeResult.errors.length > 0) {
1666
+ const offenders = [...new Set(scopeResult.errors.map((e) => e.providedScope))];
1667
+ warn(
1668
+ `LLM returned ${scopeResult.errors.length} entries with disallowed scopes (${offenders.join(", ")}); resolved per invalidScopeAction.`
1669
+ );
1631
1670
  }
1632
1671
  const categories = groupByCategory(zodResult.data.entries, scopeResult.entries);
1633
1672
  return {
@@ -2278,13 +2317,13 @@ async function generateWithTemplate(contexts, templatesConfig, outputPath, repoU
2278
2317
  const label = /changelog/i.test(outputPath) ? "Changelog" : "Release notes";
2279
2318
  success(`${label} written to ${outputPath} (using ${result.engine} template)`);
2280
2319
  }
2281
- async function runPipeline(input, config, dryRun) {
2320
+ async function runPipeline(input, config, dryRun, pipelineOptions) {
2282
2321
  debug(`Processing ${input.packages.length} package(s)`);
2283
2322
  let contexts = input.packages.map(createTemplateContext);
2284
2323
  const changelogConfig = config.changelog === false ? false : { mode: "root", ...config.changelog ?? {} };
2285
2324
  const releaseNotesConfig = config.releaseNotes === false || config.releaseNotes === void 0 ? void 0 : config.releaseNotes.mode !== void 0 || config.releaseNotes.file !== void 0 ? { mode: "root", ...config.releaseNotes } : config.releaseNotes;
2286
2325
  const llmConfig = releaseNotesConfig?.llm;
2287
- if (llmConfig && !process.env.CHANGELOG_NO_LLM) {
2326
+ if (llmConfig && !process.env.CHANGELOG_NO_LLM && !pipelineOptions?.skipReleaseNotes) {
2288
2327
  info("Processing with LLM enhancement");
2289
2328
  const examplesCount = llmConfig.examples ?? 3;
2290
2329
  const repoUrl = contexts[0]?.repoUrl ?? input.metadata?.repoUrl;
@@ -2343,7 +2382,7 @@ async function runPipeline(input, config, dryRun) {
2343
2382
  categoryOrder: llmConfig?.categoryOrder,
2344
2383
  links: releaseNotesConfig?.links
2345
2384
  };
2346
- if (changelogConfig !== false && changelogConfig.mode) {
2385
+ if (!pipelineOptions?.skipChangelogs && changelogConfig !== false && changelogConfig.mode) {
2347
2386
  const fileName = changelogConfig.file ?? "CHANGELOG.md";
2348
2387
  const mode = changelogConfig.mode;
2349
2388
  info(`Generating changelog \u2192 ${fileName}`);
@@ -2370,7 +2409,7 @@ async function runPipeline(input, config, dryRun) {
2370
2409
  warn(`Failed to write changelog: ${error2 instanceof Error ? error2.message : String(error2)}`);
2371
2410
  }
2372
2411
  }
2373
- if (releaseNotesConfig?.mode) {
2412
+ if (!pipelineOptions?.skipReleaseNotes && releaseNotesConfig?.mode) {
2374
2413
  const fileName = releaseNotesConfig.file ?? "RELEASE_NOTES.md";
2375
2414
  const mode = releaseNotesConfig.mode;
2376
2415
  info(`Generating release notes \u2192 ${fileName}`);
@@ -2406,6 +2445,9 @@ async function runPipeline(input, config, dryRun) {
2406
2445
  const releaseNotesResult = {};
2407
2446
  for (const ctx of contexts) {
2408
2447
  packageNotes[ctx.packageName] = formatVersion(ctx);
2448
+ if (pipelineOptions?.skipReleaseNotes) {
2449
+ continue;
2450
+ }
2409
2451
  if (ctx.enhanced?.releaseNotes) {
2410
2452
  releaseNotesResult[ctx.packageName] = ctx.enhanced.releaseNotes;
2411
2453
  } else if (releaseNotesConfig) {
@@ -2439,9 +2481,9 @@ async function runPipeline(input, config, dryRun) {
2439
2481
  releaseNotes: Object.keys(releaseNotesResult).length > 0 ? releaseNotesResult : void 0
2440
2482
  };
2441
2483
  }
2442
- async function processInput(inputJson, config, dryRun) {
2484
+ async function processInput(inputJson, config, dryRun, pipelineOptions) {
2443
2485
  const input = parseVersionOutput(inputJson);
2444
- return runPipeline(input, config, dryRun);
2486
+ return runPipeline(input, config, dryRun, pipelineOptions);
2445
2487
  }
2446
2488
  async function writeMonorepoFiles(contexts, config, dryRun, fileName) {
2447
2489
  const { detectMonorepo, writeMonorepoChangelogs } = await import("./aggregator-GXJXPM7O.js");
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createNotesCommand
4
- } from "./chunk-UWUSIQSW.js";
4
+ } from "./chunk-U7DE6XZR.js";
5
5
  import {
6
6
  readPackageVersion
7
7
  } from "./chunk-QCJ545PJ.js";
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { createNotesCommand } from './command.ts';
2
2
  export { getDefaultConfig, loadAuth, loadConfig, saveAuth } from './core/config.ts';
3
- export { PipelineResult, createTemplateContext, processInput, runPipeline } from './core/pipeline.ts';
3
+ export { PipelineOptions, PipelineResult, createTemplateContext, processInput, runPipeline } from './core/pipeline.ts';
4
4
  export * from './core/types.ts';
5
5
  export * from './errors/index.ts';
6
6
  export { parseVersionOutput, parseVersionOutputFile, parseVersionOutputStdin, versionOutputToChangelogInput } from './input/version-output.ts';
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  runPipeline,
19
19
  saveAuth,
20
20
  versionOutputToChangelogInput
21
- } from "./chunk-UWUSIQSW.js";
21
+ } from "./chunk-U7DE6XZR.js";
22
22
  import {
23
23
  aggregateToRoot,
24
24
  detectMonorepo,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@releasekit/notes",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "description": "Release notes and changelog generation with LLM-powered enhancement and flexible templating",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -47,7 +47,7 @@
47
47
  "access": "public"
48
48
  },
49
49
  "dependencies": {
50
- "@anthropic-ai/sdk": "^0.86.0",
50
+ "@anthropic-ai/sdk": "^0.93.0",
51
51
  "@octokit/request-error": "^7.1.0",
52
52
  "@octokit/rest": "^22.0.1",
53
53
  "chalk": "^5.6.2",
@@ -56,18 +56,18 @@
56
56
  "handlebars": "^4.7.9",
57
57
  "liquidjs": "^10.25.7",
58
58
  "minimatch": "^10.0.0",
59
- "openai": "^6.33.0",
59
+ "openai": "^6.36.0",
60
60
  "smol-toml": "^1.6.1",
61
- "zod": "^4.3.6"
61
+ "zod": "^4.4.3"
62
62
  },
63
63
  "devDependencies": {
64
- "@biomejs/biome": "^2.4.10",
64
+ "@biomejs/biome": "^2.4.14",
65
65
  "@types/ejs": "^3.1.5",
66
66
  "@types/node": "^22.19.17",
67
- "@vitest/coverage-v8": "^4.1.3",
67
+ "@vitest/coverage-v8": "^4.1.5",
68
68
  "tsup": "^8.5.1",
69
69
  "typescript": "^5.9.3",
70
- "vitest": "^4.1.3",
70
+ "vitest": "^4.1.5",
71
71
  "@releasekit/config": "0.0.0",
72
72
  "@releasekit/core": "0.0.0"
73
73
  },