@releasekit/notes 0.32.1 → 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.
- package/dist/{chunk-DDZPVGJJ.js → chunk-7ASJIYE2.js} +119 -132
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -2
|
@@ -860,6 +860,9 @@ var GitHubForge = class {
|
|
|
860
860
|
this.owner = owner;
|
|
861
861
|
this.repo = repo;
|
|
862
862
|
}
|
|
863
|
+
octokit;
|
|
864
|
+
owner;
|
|
865
|
+
repo;
|
|
863
866
|
get base() {
|
|
864
867
|
return { owner: this.owner, repo: this.repo };
|
|
865
868
|
}
|
|
@@ -1562,27 +1565,6 @@ var OpenAICompatibleProvider = class extends BaseLLMProvider {
|
|
|
1562
1565
|
}
|
|
1563
1566
|
};
|
|
1564
1567
|
|
|
1565
|
-
// src/llm/correctiveRetry.ts
|
|
1566
|
-
async function withCorrectiveRetry(call, validate, buildCorrectionMessages3, initialMessages, maxCorrectiveAttempts = 2) {
|
|
1567
|
-
let messages = initialMessages;
|
|
1568
|
-
let lastError = "";
|
|
1569
|
-
for (let attempt = 0; attempt <= maxCorrectiveAttempts; attempt++) {
|
|
1570
|
-
const result = await call(messages, attempt === 0);
|
|
1571
|
-
const validation = validate(result);
|
|
1572
|
-
if (validation.valid) return validation.value;
|
|
1573
|
-
lastError = validation.error;
|
|
1574
|
-
if (attempt < maxCorrectiveAttempts) {
|
|
1575
|
-
const badContent = typeof result.structured !== "undefined" ? JSON.stringify(result.structured) : result.content;
|
|
1576
|
-
messages = [
|
|
1577
|
-
...messages,
|
|
1578
|
-
{ role: "assistant", content: badContent },
|
|
1579
|
-
...buildCorrectionMessages3(badContent, validation.error)
|
|
1580
|
-
];
|
|
1581
|
-
}
|
|
1582
|
-
}
|
|
1583
|
-
throw new LLMError(`Structured output validation failed after ${maxCorrectiveAttempts + 1} attempts: ${lastError}`);
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
1568
|
// src/llm/prompts.ts
|
|
1587
1569
|
function resolveSystemPrompt(taskName, defaultSystemPrompt, promptsConfig) {
|
|
1588
1570
|
const instructions = promptsConfig?.instructions?.[taskName];
|
|
@@ -1732,6 +1714,27 @@ function validateEntryScopes(entries, scopeConfig, categories) {
|
|
|
1732
1714
|
return { valid: true, entries: validatedEntries, errors };
|
|
1733
1715
|
}
|
|
1734
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
|
+
|
|
1735
1738
|
// src/llm/tasks/shared.ts
|
|
1736
1739
|
function escAttr(s) {
|
|
1737
1740
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);
|
|
@@ -1762,27 +1765,68 @@ function groupByCategory(llmEntries, entries) {
|
|
|
1762
1765
|
}
|
|
1763
1766
|
return result;
|
|
1764
1767
|
}
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
const categorySection = categories && categories.length > 0 ? `Categories (use ONLY these exact names):
|
|
1769
|
-
${categories.map((c) => {
|
|
1768
|
+
function buildCategorySection(categories, fallback) {
|
|
1769
|
+
if (!categories || categories.length === 0) return fallback;
|
|
1770
|
+
const lines = categories.map((c) => {
|
|
1770
1771
|
const scopeInfo = c.scopes?.length ? ` Allowed scopes: ${c.scopes.join(", ")}.` : "";
|
|
1771
1772
|
return `- "${c.name}": ${c.description}${scopeInfo}`;
|
|
1772
|
-
})
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
}
|
|
1781
|
-
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 `
|
|
1782
1781
|
${parts.join("\n")}
|
|
1783
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.`
|
|
1784
1791
|
}
|
|
1785
|
-
|
|
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, "");
|
|
1786
1830
|
return `You are categorizing changelog entries for a software release.
|
|
1787
1831
|
|
|
1788
1832
|
${categorySection}${scopeInstruction}
|
|
@@ -1796,26 +1840,12 @@ function buildUserPrompt(entries) {
|
|
|
1796
1840
|
return `Entries:
|
|
1797
1841
|
${text}`;
|
|
1798
1842
|
}
|
|
1799
|
-
function
|
|
1800
|
-
return [
|
|
1801
|
-
{
|
|
1802
|
-
role: "user",
|
|
1803
|
-
content: `Your previous response had an error: ${error2}
|
|
1804
|
-
|
|
1805
|
-
Please fix the issue and output only valid JSON matching the required schema.`
|
|
1806
|
-
}
|
|
1807
|
-
];
|
|
1808
|
-
}
|
|
1809
|
-
function makeValidator(entries, context) {
|
|
1843
|
+
function createCategorizeValidator(entries, context) {
|
|
1810
1844
|
const cleanEntries = entries.map((e) => ({ ...e, scope: void 0 }));
|
|
1811
1845
|
return (result) => {
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
} catch (e) {
|
|
1816
|
-
return { valid: false, error: `Invalid JSON: ${e instanceof Error ? e.message : String(e)}` };
|
|
1817
|
-
}
|
|
1818
|
-
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);
|
|
1819
1849
|
if (!zodResult.success) {
|
|
1820
1850
|
return { valid: false, error: `Schema error: ${zodResult.error.message}` };
|
|
1821
1851
|
}
|
|
@@ -1825,17 +1855,11 @@ function makeValidator(entries, context) {
|
|
|
1825
1855
|
error: `Expected ${entries.length} entries, got ${zodResult.data.entries.length}`
|
|
1826
1856
|
};
|
|
1827
1857
|
}
|
|
1828
|
-
const
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
return {
|
|
1834
|
-
valid: false,
|
|
1835
|
-
error: `Unknown categories: ${unique.join(", ")}. Valid categories: ${categoryNames.join(", ")}`
|
|
1836
|
-
};
|
|
1837
|
-
}
|
|
1838
|
-
}
|
|
1858
|
+
const categoryError = checkCategoryNames(
|
|
1859
|
+
zodResult.data.entries,
|
|
1860
|
+
context.categories?.map((c) => c.name)
|
|
1861
|
+
);
|
|
1862
|
+
if (categoryError) return { valid: false, error: categoryError };
|
|
1839
1863
|
const withScopes = cleanEntries.map((entry, i) => {
|
|
1840
1864
|
const llmEntry = zodResult.data.entries[i];
|
|
1841
1865
|
const scope = llmEntry?.scope ?? void 0;
|
|
@@ -1860,18 +1884,14 @@ async function categorizeEntries(provider, entries, context) {
|
|
|
1860
1884
|
{ role: "system", content: systemPrompt },
|
|
1861
1885
|
{ role: "user", content: buildUserPrompt(entries) }
|
|
1862
1886
|
];
|
|
1863
|
-
const schema = buildCategorizeSchema(context.categories ?? []);
|
|
1864
|
-
const validate = makeValidator(entries, context);
|
|
1865
1887
|
try {
|
|
1866
|
-
return await
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
validate,
|
|
1872
|
-
|
|
1873
|
-
initialMessages
|
|
1874
|
-
);
|
|
1888
|
+
return await runCorrectiveTask({
|
|
1889
|
+
provider,
|
|
1890
|
+
initialMessages,
|
|
1891
|
+
schema: buildCategorizeSchema(context.categories ?? []),
|
|
1892
|
+
toolName: "categorize_entries",
|
|
1893
|
+
validate: createCategorizeValidator(entries, context)
|
|
1894
|
+
});
|
|
1875
1895
|
} catch (error2) {
|
|
1876
1896
|
if (error2 instanceof LLMError) {
|
|
1877
1897
|
warn(`categorizeEntries failed after all attempts: ${error2.message}. Returning entries under General.`);
|
|
@@ -1935,21 +1955,12 @@ async function enhanceEntries(provider, entries, context, concurrency = LLM_DEFA
|
|
|
1935
1955
|
// src/llm/tasks/enhance-and-categorize.ts
|
|
1936
1956
|
function buildSystemPrompt3(categories, style) {
|
|
1937
1957
|
const styleText = style || 'Use past tense ("Added feature" not "Add feature"). Be concise.';
|
|
1938
|
-
const categorySection =
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
if (categories && categories.length > 0) {
|
|
1945
|
-
const withScopes = categories.filter((c) => c.scopes?.length);
|
|
1946
|
-
if (withScopes.length > 0) {
|
|
1947
|
-
const parts = withScopes.map((c) => `For "${c.name}" entries, use a scope from: ${c.scopes?.join(", ")}.`);
|
|
1948
|
-
scopeInstruction = `
|
|
1949
|
-
${parts.join("\n")}
|
|
1950
|
-
Only use scopes from these predefined lists. Set scope to null if no scope applies.`;
|
|
1951
|
-
}
|
|
1952
|
-
}
|
|
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");
|
|
1953
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.
|
|
1954
1965
|
|
|
1955
1966
|
Style guidelines:
|
|
@@ -1980,25 +1991,11 @@ ${prBlocks}` : header;
|
|
|
1980
1991
|
return `Entries:
|
|
1981
1992
|
${entriesText}`;
|
|
1982
1993
|
}
|
|
1983
|
-
function
|
|
1984
|
-
return [
|
|
1985
|
-
{
|
|
1986
|
-
role: "user",
|
|
1987
|
-
content: `Your previous response had an error: ${error2}
|
|
1988
|
-
|
|
1989
|
-
Please fix the issue and output only valid JSON matching the required schema.`
|
|
1990
|
-
}
|
|
1991
|
-
];
|
|
1992
|
-
}
|
|
1993
|
-
function makeValidator2(entries, context) {
|
|
1994
|
+
function createEnhanceAndCategorizeValidator(entries, context) {
|
|
1994
1995
|
return (result) => {
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
} catch (e) {
|
|
1999
|
-
return { valid: false, error: `Invalid JSON: ${e instanceof Error ? e.message : String(e)}` };
|
|
2000
|
-
}
|
|
2001
|
-
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);
|
|
2002
1999
|
if (!zodResult.success) {
|
|
2003
2000
|
return { valid: false, error: `Schema error: ${zodResult.error.message}` };
|
|
2004
2001
|
}
|
|
@@ -2013,17 +2010,11 @@ function makeValidator2(entries, context) {
|
|
|
2013
2010
|
warn(`LLM returned ${receivedCount} entries for ${entries.length} inputs; truncating to expected count.`);
|
|
2014
2011
|
zodResult.data.entries.length = entries.length;
|
|
2015
2012
|
}
|
|
2016
|
-
const
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
return {
|
|
2022
|
-
valid: false,
|
|
2023
|
-
error: `Unknown categories: ${unique.join(", ")}. Valid categories: ${categoryNames.join(", ")}`
|
|
2024
|
-
};
|
|
2025
|
-
}
|
|
2026
|
-
}
|
|
2013
|
+
const categoryError = checkCategoryNames(
|
|
2014
|
+
zodResult.data.entries,
|
|
2015
|
+
context.categories?.map((c) => c.name)
|
|
2016
|
+
);
|
|
2017
|
+
if (categoryError) return { valid: false, error: categoryError };
|
|
2027
2018
|
const enhancedEntries = entries.map((original, i) => {
|
|
2028
2019
|
const llmEntry = zodResult.data.entries[i];
|
|
2029
2020
|
if (!llmEntry) return original;
|
|
@@ -2064,18 +2055,14 @@ async function enhanceAndCategorize(provider, entries, context) {
|
|
|
2064
2055
|
{ role: "system", content: systemPrompt },
|
|
2065
2056
|
{ role: "user", content: buildUserPrompt3(entries) }
|
|
2066
2057
|
];
|
|
2067
|
-
const schema = buildEnhanceAndCategorizeSchema(context.categories ?? []);
|
|
2068
|
-
const validate = makeValidator2(entries, context);
|
|
2069
2058
|
try {
|
|
2070
|
-
return await
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
validate,
|
|
2076
|
-
|
|
2077
|
-
initialMessages
|
|
2078
|
-
);
|
|
2059
|
+
return await runCorrectiveTask({
|
|
2060
|
+
provider,
|
|
2061
|
+
initialMessages,
|
|
2062
|
+
schema: buildEnhanceAndCategorizeSchema(context.categories ?? []),
|
|
2063
|
+
toolName: "emit_release_notes",
|
|
2064
|
+
validate: createEnhanceAndCategorizeValidator(entries, context)
|
|
2065
|
+
});
|
|
2079
2066
|
} catch (error2) {
|
|
2080
2067
|
if (error2 instanceof LLMError) {
|
|
2081
2068
|
warn(`enhanceAndCategorize failed after all attempts: ${error2.message}. Returning entries ungrouped.`);
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@releasekit/notes",
|
|
3
|
-
"version": "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/
|
|
75
|
+
"@releasekit/git": "0.0.0"
|
|
75
76
|
},
|
|
76
77
|
"engines": {
|
|
77
78
|
"node": ">=22"
|