@releasekit/notes 0.32.0 → 0.33.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.
@@ -117,6 +117,9 @@ var VersionConfigSchema = z.object({
117
117
  sharedPackages: z.array(z.string()).optional().describe(
118
118
  '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.'
119
119
  ),
120
+ sharedChangelogFloor: z.enum(["union", "sinceLastRelease"]).default("union").describe(
121
+ `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.`
122
+ ),
120
123
  mainPackage: z.string().optional().describe("Package to use for version determination"),
121
124
  updateInternalDependencies: z.enum(["major", "minor", "patch", "no-internal-update"]).default("minor").describe("How to bump internal dependencies"),
122
125
  skip: z.array(z.string()).optional().describe("Packages to exclude from versioning"),
@@ -127,6 +130,9 @@ var VersionConfigSchema = z.object({
127
130
  mismatchStrategy: z.enum(["error", "warn", "ignore", "prefer-package", "prefer-git"]).default("warn").describe("How to handle version mismatches"),
128
131
  versionPrefix: z.string().default("").describe("Prefix for version tags"),
129
132
  prereleaseIdentifier: z.string().optional().describe("Identifier for prerelease versions (e.g., 'alpha', 'beta')"),
133
+ allowFirstBump: z.boolean().default(false).describe(
134
+ '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.'
135
+ ),
130
136
  strictReachable: z.boolean().default(false).describe("Only use reachable tags"),
131
137
  zeroMajor: z.enum(["spec", "strict"]).default("spec").describe(
132
138
  "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."
@@ -854,6 +860,9 @@ var GitHubForge = class {
854
860
  this.owner = owner;
855
861
  this.repo = repo;
856
862
  }
863
+ octokit;
864
+ owner;
865
+ repo;
857
866
  get base() {
858
867
  return { owner: this.owner, repo: this.repo };
859
868
  }
@@ -1556,27 +1565,6 @@ var OpenAICompatibleProvider = class extends BaseLLMProvider {
1556
1565
  }
1557
1566
  };
1558
1567
 
1559
- // src/llm/correctiveRetry.ts
1560
- async function withCorrectiveRetry(call, validate, buildCorrectionMessages3, initialMessages, maxCorrectiveAttempts = 2) {
1561
- let messages = initialMessages;
1562
- let lastError = "";
1563
- for (let attempt = 0; attempt <= maxCorrectiveAttempts; attempt++) {
1564
- const result = await call(messages, attempt === 0);
1565
- const validation = validate(result);
1566
- if (validation.valid) return validation.value;
1567
- lastError = validation.error;
1568
- if (attempt < maxCorrectiveAttempts) {
1569
- const badContent = typeof result.structured !== "undefined" ? JSON.stringify(result.structured) : result.content;
1570
- messages = [
1571
- ...messages,
1572
- { role: "assistant", content: badContent },
1573
- ...buildCorrectionMessages3(badContent, validation.error)
1574
- ];
1575
- }
1576
- }
1577
- throw new LLMError(`Structured output validation failed after ${maxCorrectiveAttempts + 1} attempts: ${lastError}`);
1578
- }
1579
-
1580
1568
  // src/llm/prompts.ts
1581
1569
  function resolveSystemPrompt(taskName, defaultSystemPrompt, promptsConfig) {
1582
1570
  const instructions = promptsConfig?.instructions?.[taskName];
@@ -1726,6 +1714,27 @@ function validateEntryScopes(entries, scopeConfig, categories) {
1726
1714
  return { valid: true, entries: validatedEntries, errors };
1727
1715
  }
1728
1716
 
1717
+ // src/llm/correctiveRetry.ts
1718
+ async function withCorrectiveRetry(call, validate, buildCorrectionMessages2, initialMessages, maxCorrectiveAttempts = 2) {
1719
+ let messages = initialMessages;
1720
+ let lastError = "";
1721
+ for (let attempt = 0; attempt <= maxCorrectiveAttempts; attempt++) {
1722
+ const result = await call(messages, attempt === 0);
1723
+ const validation = validate(result);
1724
+ if (validation.valid) return validation.value;
1725
+ lastError = validation.error;
1726
+ if (attempt < maxCorrectiveAttempts) {
1727
+ const badContent = typeof result.structured !== "undefined" ? JSON.stringify(result.structured) : result.content;
1728
+ messages = [
1729
+ ...messages,
1730
+ { role: "assistant", content: badContent },
1731
+ ...buildCorrectionMessages2(badContent, validation.error)
1732
+ ];
1733
+ }
1734
+ }
1735
+ throw new LLMError(`Structured output validation failed after ${maxCorrectiveAttempts + 1} attempts: ${lastError}`);
1736
+ }
1737
+
1729
1738
  // src/llm/tasks/shared.ts
1730
1739
  function escAttr(s) {
1731
1740
  return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
@@ -1756,27 +1765,68 @@ function groupByCategory(llmEntries, entries) {
1756
1765
  }
1757
1766
  return result;
1758
1767
  }
1759
-
1760
- // src/llm/tasks/categorize.ts
1761
- function buildSystemPrompt(categories) {
1762
- const categorySection = categories && categories.length > 0 ? `Categories (use ONLY these exact names):
1763
- ${categories.map((c) => {
1768
+ function buildCategorySection(categories, fallback) {
1769
+ if (!categories || categories.length === 0) return fallback;
1770
+ const lines = categories.map((c) => {
1764
1771
  const scopeInfo = c.scopes?.length ? ` Allowed scopes: ${c.scopes.join(", ")}.` : "";
1765
1772
  return `- "${c.name}": ${c.description}${scopeInfo}`;
1766
- }).join("\n")}` : `Categories: Group into meaningful categories (e.g., "Core", "UI", "API", "Performance", "Bug Fixes", "Documentation").`;
1767
- let scopeInstruction = "";
1768
- if (categories && categories.length > 0) {
1769
- const scopeMap = getAllowedScopesFromCategories(categories);
1770
- if (scopeMap.size > 0) {
1771
- const parts = [];
1772
- for (const [catName, scopes] of scopeMap) {
1773
- parts.push(`For "${catName}", use a scope from: ${scopes.join(", ")}.`);
1774
- }
1775
- scopeInstruction = `
1773
+ });
1774
+ return `Categories (use ONLY these exact names):
1775
+ ${lines.join("\n")}`;
1776
+ }
1777
+ function renderScopeInstruction(pairs, entrySuffix) {
1778
+ if (pairs.length === 0) return "";
1779
+ const parts = pairs.map((p) => `For "${p.name}"${entrySuffix}, use a scope from: ${p.scopes.join(", ")}.`);
1780
+ return `
1776
1781
  ${parts.join("\n")}
1777
1782
  Only use scopes from these predefined lists. Set scope to null if no scope applies.`;
1783
+ }
1784
+ function buildCorrectionMessages(_badContent, error2) {
1785
+ return [
1786
+ {
1787
+ role: "user",
1788
+ content: `Your previous response had an error: ${error2}
1789
+
1790
+ Please fix the issue and output only valid JSON matching the required schema.`
1778
1791
  }
1779
- }
1792
+ ];
1793
+ }
1794
+ function parseLLMResult(result) {
1795
+ try {
1796
+ const data = typeof result.structured !== "undefined" ? result.structured : JSON.parse(extractJsonFromResponse(result.content));
1797
+ return { ok: true, data };
1798
+ } catch (e) {
1799
+ return { ok: false, error: `Invalid JSON: ${e instanceof Error ? e.message : String(e)}` };
1800
+ }
1801
+ }
1802
+ function checkCategoryNames(llmEntries, categoryNames) {
1803
+ if (!categoryNames?.length) return null;
1804
+ const invalid = llmEntries.filter((e) => !categoryNames.includes(e.category)).map((e) => e.category);
1805
+ if (invalid.length === 0) return null;
1806
+ const unique = [...new Set(invalid)];
1807
+ return `Unknown categories: ${unique.join(", ")}. Valid categories: ${categoryNames.join(", ")}`;
1808
+ }
1809
+ async function runCorrectiveTask(opts) {
1810
+ const { provider, initialMessages, schema, toolName, validate } = opts;
1811
+ return withCorrectiveRetry(
1812
+ (messages, isFirstAttempt) => provider.complete(
1813
+ messages,
1814
+ isFirstAttempt && provider.capabilities.structuredOutputs ? { schema, toolName } : void 0
1815
+ ),
1816
+ validate,
1817
+ buildCorrectionMessages,
1818
+ initialMessages
1819
+ );
1820
+ }
1821
+
1822
+ // src/llm/tasks/categorize.ts
1823
+ function buildSystemPrompt(categories) {
1824
+ const categorySection = buildCategorySection(
1825
+ categories,
1826
+ `Categories: Group into meaningful categories (e.g., "Core", "UI", "API", "Performance", "Bug Fixes", "Documentation").`
1827
+ );
1828
+ const pairs = categories && categories.length > 0 ? [...getAllowedScopesFromCategories(categories)].map(([name, scopes]) => ({ name, scopes })) : [];
1829
+ const scopeInstruction = renderScopeInstruction(pairs, "");
1780
1830
  return `You are categorizing changelog entries for a software release.
1781
1831
 
1782
1832
  ${categorySection}${scopeInstruction}
@@ -1790,26 +1840,12 @@ function buildUserPrompt(entries) {
1790
1840
  return `Entries:
1791
1841
  ${text}`;
1792
1842
  }
1793
- function buildCorrectionMessages(_badContent, error2) {
1794
- return [
1795
- {
1796
- role: "user",
1797
- content: `Your previous response had an error: ${error2}
1798
-
1799
- Please fix the issue and output only valid JSON matching the required schema.`
1800
- }
1801
- ];
1802
- }
1803
- function makeValidator(entries, context) {
1843
+ function createCategorizeValidator(entries, context) {
1804
1844
  const cleanEntries = entries.map((e) => ({ ...e, scope: void 0 }));
1805
1845
  return (result) => {
1806
- let parsed;
1807
- try {
1808
- parsed = typeof result.structured !== "undefined" ? result.structured : JSON.parse(extractJsonFromResponse(result.content));
1809
- } catch (e) {
1810
- return { valid: false, error: `Invalid JSON: ${e instanceof Error ? e.message : String(e)}` };
1811
- }
1812
- const zodResult = CategorizeOutputSchema.safeParse(parsed);
1846
+ const parsed = parseLLMResult(result);
1847
+ if (!parsed.ok) return { valid: false, error: parsed.error };
1848
+ const zodResult = CategorizeOutputSchema.safeParse(parsed.data);
1813
1849
  if (!zodResult.success) {
1814
1850
  return { valid: false, error: `Schema error: ${zodResult.error.message}` };
1815
1851
  }
@@ -1819,17 +1855,11 @@ function makeValidator(entries, context) {
1819
1855
  error: `Expected ${entries.length} entries, got ${zodResult.data.entries.length}`
1820
1856
  };
1821
1857
  }
1822
- const categoryNames = context.categories?.map((c) => c.name);
1823
- if (categoryNames?.length) {
1824
- const invalid = zodResult.data.entries.filter((e) => !categoryNames.includes(e.category)).map((e) => e.category);
1825
- if (invalid.length > 0) {
1826
- const unique = [...new Set(invalid)];
1827
- return {
1828
- valid: false,
1829
- error: `Unknown categories: ${unique.join(", ")}. Valid categories: ${categoryNames.join(", ")}`
1830
- };
1831
- }
1832
- }
1858
+ const categoryError = checkCategoryNames(
1859
+ zodResult.data.entries,
1860
+ context.categories?.map((c) => c.name)
1861
+ );
1862
+ if (categoryError) return { valid: false, error: categoryError };
1833
1863
  const withScopes = cleanEntries.map((entry, i) => {
1834
1864
  const llmEntry = zodResult.data.entries[i];
1835
1865
  const scope = llmEntry?.scope ?? void 0;
@@ -1854,18 +1884,14 @@ async function categorizeEntries(provider, entries, context) {
1854
1884
  { role: "system", content: systemPrompt },
1855
1885
  { role: "user", content: buildUserPrompt(entries) }
1856
1886
  ];
1857
- const schema = buildCategorizeSchema(context.categories ?? []);
1858
- const validate = makeValidator(entries, context);
1859
1887
  try {
1860
- return await withCorrectiveRetry(
1861
- (messages, isFirstAttempt) => provider.complete(
1862
- messages,
1863
- isFirstAttempt && provider.capabilities.structuredOutputs ? { schema, toolName: "categorize_entries" } : void 0
1864
- ),
1865
- validate,
1866
- buildCorrectionMessages,
1867
- initialMessages
1868
- );
1888
+ return await runCorrectiveTask({
1889
+ provider,
1890
+ initialMessages,
1891
+ schema: buildCategorizeSchema(context.categories ?? []),
1892
+ toolName: "categorize_entries",
1893
+ validate: createCategorizeValidator(entries, context)
1894
+ });
1869
1895
  } catch (error2) {
1870
1896
  if (error2 instanceof LLMError) {
1871
1897
  warn(`categorizeEntries failed after all attempts: ${error2.message}. Returning entries under General.`);
@@ -1929,21 +1955,12 @@ async function enhanceEntries(provider, entries, context, concurrency = LLM_DEFA
1929
1955
  // src/llm/tasks/enhance-and-categorize.ts
1930
1956
  function buildSystemPrompt3(categories, style) {
1931
1957
  const styleText = style || 'Use past tense ("Added feature" not "Add feature"). Be concise.';
1932
- const categorySection = categories && categories.length > 0 ? `Categories (use ONLY these exact names):
1933
- ${categories.map((c) => {
1934
- const scopeInfo = c.scopes?.length ? ` Allowed scopes: ${c.scopes.join(", ")}.` : "";
1935
- return `- "${c.name}": ${c.description}${scopeInfo}`;
1936
- }).join("\n")}` : `Categories: Group into meaningful categories (e.g., "New", "Fixed", "Changed", "Removed").`;
1937
- let scopeInstruction = "";
1938
- if (categories && categories.length > 0) {
1939
- const withScopes = categories.filter((c) => c.scopes?.length);
1940
- if (withScopes.length > 0) {
1941
- const parts = withScopes.map((c) => `For "${c.name}" entries, use a scope from: ${c.scopes?.join(", ")}.`);
1942
- scopeInstruction = `
1943
- ${parts.join("\n")}
1944
- Only use scopes from these predefined lists. Set scope to null if no scope applies.`;
1945
- }
1946
- }
1958
+ const categorySection = buildCategorySection(
1959
+ categories,
1960
+ `Categories: Group into meaningful categories (e.g., "New", "Fixed", "Changed", "Removed").`
1961
+ );
1962
+ const pairs = categories && categories.length > 0 ? categories.filter((c) => c.scopes?.length).map((c) => ({ name: c.name, scopes: c.scopes })) : [];
1963
+ const scopeInstruction = renderScopeInstruction(pairs, " entries");
1947
1964
  return `You are generating release notes for a software project. Given changelog entries, rewrite each as a clear user-friendly description and categorize it.
1948
1965
 
1949
1966
  Style guidelines:
@@ -1974,25 +1991,11 @@ ${prBlocks}` : header;
1974
1991
  return `Entries:
1975
1992
  ${entriesText}`;
1976
1993
  }
1977
- function buildCorrectionMessages2(_badContent, error2) {
1978
- return [
1979
- {
1980
- role: "user",
1981
- content: `Your previous response had an error: ${error2}
1982
-
1983
- Please fix the issue and output only valid JSON matching the required schema.`
1984
- }
1985
- ];
1986
- }
1987
- function makeValidator2(entries, context) {
1994
+ function createEnhanceAndCategorizeValidator(entries, context) {
1988
1995
  return (result) => {
1989
- let parsed;
1990
- try {
1991
- parsed = typeof result.structured !== "undefined" ? result.structured : JSON.parse(extractJsonFromResponse(result.content));
1992
- } catch (e) {
1993
- return { valid: false, error: `Invalid JSON: ${e instanceof Error ? e.message : String(e)}` };
1994
- }
1995
- const zodResult = EnhanceAndCategorizeOutputSchema.safeParse(parsed);
1996
+ const parsed = parseLLMResult(result);
1997
+ if (!parsed.ok) return { valid: false, error: parsed.error };
1998
+ const zodResult = EnhanceAndCategorizeOutputSchema.safeParse(parsed.data);
1996
1999
  if (!zodResult.success) {
1997
2000
  return { valid: false, error: `Schema error: ${zodResult.error.message}` };
1998
2001
  }
@@ -2007,17 +2010,11 @@ function makeValidator2(entries, context) {
2007
2010
  warn(`LLM returned ${receivedCount} entries for ${entries.length} inputs; truncating to expected count.`);
2008
2011
  zodResult.data.entries.length = entries.length;
2009
2012
  }
2010
- const categoryNames = context.categories?.map((c) => c.name);
2011
- if (categoryNames?.length) {
2012
- const invalid = zodResult.data.entries.filter((e) => !categoryNames.includes(e.category)).map((e) => e.category);
2013
- if (invalid.length > 0) {
2014
- const unique = [...new Set(invalid)];
2015
- return {
2016
- valid: false,
2017
- error: `Unknown categories: ${unique.join(", ")}. Valid categories: ${categoryNames.join(", ")}`
2018
- };
2019
- }
2020
- }
2013
+ const categoryError = checkCategoryNames(
2014
+ zodResult.data.entries,
2015
+ context.categories?.map((c) => c.name)
2016
+ );
2017
+ if (categoryError) return { valid: false, error: categoryError };
2021
2018
  const enhancedEntries = entries.map((original, i) => {
2022
2019
  const llmEntry = zodResult.data.entries[i];
2023
2020
  if (!llmEntry) return original;
@@ -2058,18 +2055,14 @@ async function enhanceAndCategorize(provider, entries, context) {
2058
2055
  { role: "system", content: systemPrompt },
2059
2056
  { role: "user", content: buildUserPrompt3(entries) }
2060
2057
  ];
2061
- const schema = buildEnhanceAndCategorizeSchema(context.categories ?? []);
2062
- const validate = makeValidator2(entries, context);
2063
2058
  try {
2064
- return await withCorrectiveRetry(
2065
- (messages, isFirstAttempt) => provider.complete(
2066
- messages,
2067
- isFirstAttempt && provider.capabilities.structuredOutputs ? { schema, toolName: "emit_release_notes" } : void 0
2068
- ),
2069
- validate,
2070
- buildCorrectionMessages2,
2071
- initialMessages
2072
- );
2059
+ return await runCorrectiveTask({
2060
+ provider,
2061
+ initialMessages,
2062
+ schema: buildEnhanceAndCategorizeSchema(context.categories ?? []),
2063
+ toolName: "emit_release_notes",
2064
+ validate: createEnhanceAndCategorizeValidator(entries, context)
2065
+ });
2073
2066
  } catch (error2) {
2074
2067
  if (error2 instanceof LLMError) {
2075
2068
  warn(`enhanceAndCategorize failed after all attempts: ${error2.message}. Returning entries ungrouped.`);
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createNotesCommand
4
- } from "./chunk-4ZP32TPZ.js";
4
+ } from "./chunk-7ASJIYE2.js";
5
5
  import {
6
6
  readPackageVersion
7
7
  } from "./chunk-IC4SXXRM.js";
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  runPipeline,
19
19
  saveAuth,
20
20
  versionOutputToChangelogInput
21
- } from "./chunk-4ZP32TPZ.js";
21
+ } from "./chunk-7ASJIYE2.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.32.0",
3
+ "version": "0.33.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",
@@ -70,8 +70,9 @@
70
70
  "typescript": "^5.9.3",
71
71
  "vitest": "^4.1.9",
72
72
  "@releasekit/config": "0.0.0",
73
+ "@releasekit/core": "0.0.0",
73
74
  "@releasekit/forge": "0.0.0",
74
- "@releasekit/core": "0.0.0"
75
+ "@releasekit/git": "0.0.0"
75
76
  },
76
77
  "engines": {
77
78
  "node": ">=22"