@releasekit/notes 0.41.0 → 0.41.2
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/{aggregator-74VELOCJ.js → aggregator-NMUD72J2.js} +2 -2
- package/dist/{chunk-4YP4CODY.js → chunk-2PRVRNSI.js} +240 -71
- package/dist/{chunk-EWEPFCCT.js → chunk-FI3F2ND5.js} +13 -2
- package/dist/{chunk-WTOR47NP.js → chunk-YO6KWOCB.js} +1 -1
- package/dist/cli.js +2 -2
- package/dist/index.js +3 -3
- package/package.json +4 -4
|
@@ -5,13 +5,14 @@ import {
|
|
|
5
5
|
error,
|
|
6
6
|
formatVersion,
|
|
7
7
|
info,
|
|
8
|
+
isPathWithinRoot,
|
|
8
9
|
parseGitHubOwnerRepo,
|
|
9
10
|
setLogLevel,
|
|
10
11
|
setQuietMode,
|
|
11
12
|
success,
|
|
12
13
|
warn,
|
|
13
14
|
writeMarkdown
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-FI3F2ND5.js";
|
|
15
16
|
|
|
16
17
|
// ../config/dist/index.js
|
|
17
18
|
import * as fs from "fs";
|
|
@@ -578,7 +579,7 @@ var ReleaseKitConfigSchema = z.object({
|
|
|
578
579
|
release: ReleaseConfigSchema.optional().describe("Release pipeline automation configuration")
|
|
579
580
|
}).describe("Configuration schema for ReleaseKit - Automated versioning, changelog generation, and publishing");
|
|
580
581
|
var MAX_INPUT_LENGTH = 1e4;
|
|
581
|
-
function substituteVariables(value) {
|
|
582
|
+
function substituteVariables(value, rootDir = process.cwd()) {
|
|
582
583
|
if (value.length > MAX_INPUT_LENGTH) {
|
|
583
584
|
throw new Error(`Input too long: ${value.length} characters (max ${MAX_INPUT_LENGTH})`);
|
|
584
585
|
}
|
|
@@ -589,9 +590,14 @@ function substituteVariables(value) {
|
|
|
589
590
|
return process.env[varName] ?? "";
|
|
590
591
|
});
|
|
591
592
|
result = result.replace(filePattern, (_, filePath) => {
|
|
592
|
-
const
|
|
593
|
+
const resolved = path2.resolve(rootDir, filePath);
|
|
594
|
+
if (!isPathWithinRoot(rootDir, resolved)) {
|
|
595
|
+
throw new ConfigError(
|
|
596
|
+
`{file:${filePath}} resolves outside the config directory (${path2.resolve(rootDir)}); config file references are confined to the repository. Use {env:NAME} for secrets kept outside the repo.`
|
|
597
|
+
);
|
|
598
|
+
}
|
|
593
599
|
try {
|
|
594
|
-
return fs2.readFileSync(
|
|
600
|
+
return fs2.readFileSync(resolved, "utf-8").trim();
|
|
595
601
|
} catch {
|
|
596
602
|
return "";
|
|
597
603
|
}
|
|
@@ -599,21 +605,21 @@ function substituteVariables(value) {
|
|
|
599
605
|
return result;
|
|
600
606
|
}
|
|
601
607
|
var SOLE_REFERENCE_PATTERN = /^\{(?:env|file):[^}]+\}$/;
|
|
602
|
-
function substituteInObject(obj) {
|
|
608
|
+
function substituteInObject(obj, rootDir = process.cwd()) {
|
|
603
609
|
if (typeof obj === "string") {
|
|
604
|
-
const result = substituteVariables(obj);
|
|
610
|
+
const result = substituteVariables(obj, rootDir);
|
|
605
611
|
if (result === "" && SOLE_REFERENCE_PATTERN.test(obj)) {
|
|
606
612
|
return void 0;
|
|
607
613
|
}
|
|
608
614
|
return result;
|
|
609
615
|
}
|
|
610
616
|
if (Array.isArray(obj)) {
|
|
611
|
-
return obj.map((item) => substituteInObject(item));
|
|
617
|
+
return obj.map((item) => substituteInObject(item, rootDir));
|
|
612
618
|
}
|
|
613
619
|
if (obj && typeof obj === "object") {
|
|
614
620
|
const result = {};
|
|
615
621
|
for (const [key, value] of Object.entries(obj)) {
|
|
616
|
-
result[key] = substituteInObject(value);
|
|
622
|
+
result[key] = substituteInObject(value, rootDir);
|
|
617
623
|
}
|
|
618
624
|
return result;
|
|
619
625
|
}
|
|
@@ -702,7 +708,7 @@ function loadConfigFile(configPath) {
|
|
|
702
708
|
try {
|
|
703
709
|
const content = fs3.readFileSync(configPath, "utf-8");
|
|
704
710
|
const parsed = parseJsonc(content);
|
|
705
|
-
const substituted = substituteInObject(parsed);
|
|
711
|
+
const substituted = substituteInObject(parsed, path3.dirname(configPath));
|
|
706
712
|
assertNoRemovedReleaseNotesFields(substituted);
|
|
707
713
|
assertNoRemovedVersionFields(substituted);
|
|
708
714
|
assertNoRemovedTopLevelFields(substituted);
|
|
@@ -753,6 +759,17 @@ var LLMError = class extends NotesError {
|
|
|
753
759
|
"Check network connectivity",
|
|
754
760
|
"Try with --no-llm to skip LLM processing"
|
|
755
761
|
];
|
|
762
|
+
/**
|
|
763
|
+
* Whether the underlying failure is transient and worth retrying (timeout / 429 / 5xx / network).
|
|
764
|
+
* `false` marks a non-retryable failure (4xx auth/validation) so `withRetry` fails fast instead of
|
|
765
|
+
* burning the whole backoff budget. `undefined` means "unclassified" — callers retry by default.
|
|
766
|
+
*/
|
|
767
|
+
retryable;
|
|
768
|
+
constructor(message, options) {
|
|
769
|
+
super(message);
|
|
770
|
+
if (options?.cause !== void 0) this.cause = options.cause;
|
|
771
|
+
this.retryable = options?.retryable;
|
|
772
|
+
}
|
|
756
773
|
};
|
|
757
774
|
var GitHubError = class extends NotesError {
|
|
758
775
|
code = "GITHUB_ERROR";
|
|
@@ -895,13 +912,14 @@ function withContentHashCache(provider, identity, dir = defaultCacheDir()) {
|
|
|
895
912
|
name: provider.name,
|
|
896
913
|
capabilities: provider.capabilities,
|
|
897
914
|
async complete(messages, options) {
|
|
915
|
+
const temperature = provider.capabilities.honorsTemperature === false ? void 0 : options?.temperature;
|
|
898
916
|
const key = createHash("sha256").update(
|
|
899
917
|
stableStringify({
|
|
900
918
|
provider: provider.name,
|
|
901
919
|
model: identity.model,
|
|
902
920
|
baseURL: identity.baseURL,
|
|
903
921
|
messages,
|
|
904
|
-
temperature
|
|
922
|
+
temperature,
|
|
905
923
|
maxTokens: options?.maxTokens,
|
|
906
924
|
schema: options?.schema,
|
|
907
925
|
toolName: options?.toolName
|
|
@@ -932,6 +950,11 @@ function forgeErrorStatus(error2) {
|
|
|
932
950
|
}
|
|
933
951
|
return void 0;
|
|
934
952
|
}
|
|
953
|
+
function isBotComment(comment) {
|
|
954
|
+
const user = comment.user;
|
|
955
|
+
if (!user) return true;
|
|
956
|
+
return user.type === "Bot" || user.login !== void 0 && user.login.endsWith("[bot]");
|
|
957
|
+
}
|
|
935
958
|
var REPO_PERMISSIONS = ["admin", "maintain", "write", "triage", "read", "none"];
|
|
936
959
|
var MAX_RELEASE_PAGES = 3;
|
|
937
960
|
var MAX_OPEN_PR_PAGES = 5;
|
|
@@ -1072,12 +1095,20 @@ var GitHubForge = class {
|
|
|
1072
1095
|
issue_number: prNumber,
|
|
1073
1096
|
per_page: 100
|
|
1074
1097
|
});
|
|
1098
|
+
let humanMatch = null;
|
|
1075
1099
|
for await (const response of iterator) {
|
|
1076
1100
|
for (const comment of response.data) {
|
|
1077
|
-
if (comment.body?.startsWith(marker))
|
|
1101
|
+
if (!comment.body?.startsWith(marker)) continue;
|
|
1102
|
+
const found = {
|
|
1103
|
+
id: comment.id,
|
|
1104
|
+
body: comment.body,
|
|
1105
|
+
user: comment.user ? { login: comment.user.login, type: comment.user.type } : void 0
|
|
1106
|
+
};
|
|
1107
|
+
if (isBotComment(found)) return found;
|
|
1108
|
+
humanMatch ??= found;
|
|
1078
1109
|
}
|
|
1079
1110
|
}
|
|
1080
|
-
return
|
|
1111
|
+
return humanMatch;
|
|
1081
1112
|
}
|
|
1082
1113
|
async createComment(prNumber, body) {
|
|
1083
1114
|
await this.octokit.rest.issues.createComment({ ...this.base, issue_number: prNumber, body });
|
|
@@ -1087,7 +1118,7 @@ var GitHubForge = class {
|
|
|
1087
1118
|
}
|
|
1088
1119
|
async upsertMarkerComment(prNumber, marker, body) {
|
|
1089
1120
|
const existing = await this.findComment(prNumber, marker);
|
|
1090
|
-
if (existing) {
|
|
1121
|
+
if (existing && isBotComment(existing)) {
|
|
1091
1122
|
await this.updateComment(existing.id, body);
|
|
1092
1123
|
} else {
|
|
1093
1124
|
await this.createComment(prNumber, body);
|
|
@@ -1256,6 +1287,10 @@ var LLM_DEFAULTS = {
|
|
|
1256
1287
|
// 0.7 balances coherence (low temp) with natural-sounding variation (high temp).
|
|
1257
1288
|
temperature: 0.7,
|
|
1258
1289
|
concurrency: 5,
|
|
1290
|
+
// Max entries per enhance+categorize prompt. Large releases in a single prompt overflow the output
|
|
1291
|
+
// ceiling → entry-count validation fails → corrective retries resend a growing transcript. Bounded
|
|
1292
|
+
// chunks keep each call within budget and isolate a bad chunk's fallback to that chunk alone.
|
|
1293
|
+
enhanceCategorizeChunkSize: 30,
|
|
1259
1294
|
retry: {
|
|
1260
1295
|
maxAttempts: 3,
|
|
1261
1296
|
initialDelay: 1e3,
|
|
@@ -1569,13 +1604,45 @@ function debugLogMessages(providerName, messages) {
|
|
|
1569
1604
|
}
|
|
1570
1605
|
}
|
|
1571
1606
|
|
|
1607
|
+
// src/llm/retryable.ts
|
|
1608
|
+
var NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
1609
|
+
"ECONNRESET",
|
|
1610
|
+
"ECONNREFUSED",
|
|
1611
|
+
"ECONNABORTED",
|
|
1612
|
+
"ETIMEDOUT",
|
|
1613
|
+
"ENOTFOUND",
|
|
1614
|
+
"EAI_AGAIN",
|
|
1615
|
+
"EPIPE",
|
|
1616
|
+
"ENETUNREACH",
|
|
1617
|
+
"ENETDOWN"
|
|
1618
|
+
]);
|
|
1619
|
+
function isRetryableStatus(status) {
|
|
1620
|
+
if (status === 408 || status === 409 || status === 425 || status === 429) return true;
|
|
1621
|
+
if (status >= 500) return true;
|
|
1622
|
+
if (status >= 400) return false;
|
|
1623
|
+
return true;
|
|
1624
|
+
}
|
|
1625
|
+
function isRetryableProviderError(error2) {
|
|
1626
|
+
if (!error2 || typeof error2 !== "object") return true;
|
|
1627
|
+
const e = error2;
|
|
1628
|
+
if (typeof e.status === "number") return isRetryableStatus(e.status);
|
|
1629
|
+
if (typeof e.code === "string" && NETWORK_ERROR_CODES.has(e.code)) return true;
|
|
1630
|
+
return true;
|
|
1631
|
+
}
|
|
1632
|
+
function isRetryableLLMError(error2) {
|
|
1633
|
+
if (error2 instanceof LLMError) return error2.retryable ?? true;
|
|
1634
|
+
return true;
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1572
1637
|
// src/llm/anthropic.ts
|
|
1573
1638
|
var AnthropicProvider = class extends BaseLLMProvider {
|
|
1574
1639
|
name = "anthropic";
|
|
1575
1640
|
capabilities = {
|
|
1576
1641
|
systemRole: true,
|
|
1577
1642
|
structuredOutputs: true,
|
|
1578
|
-
toolUse: true
|
|
1643
|
+
toolUse: true,
|
|
1644
|
+
// temperature is deliberately not forwarded (see complete()), so it must not key the cache.
|
|
1645
|
+
honorsTemperature: false
|
|
1579
1646
|
};
|
|
1580
1647
|
client;
|
|
1581
1648
|
model;
|
|
@@ -1629,15 +1696,20 @@ var AnthropicProvider = class extends BaseLLMProvider {
|
|
|
1629
1696
|
},
|
|
1630
1697
|
{ signal }
|
|
1631
1698
|
);
|
|
1632
|
-
const
|
|
1633
|
-
if (
|
|
1634
|
-
throw new LLMError("
|
|
1699
|
+
const textBlock = response.content.find((b) => b.type === "text");
|
|
1700
|
+
if (textBlock?.type !== "text") {
|
|
1701
|
+
throw new LLMError("Expected a text block in Anthropic response");
|
|
1635
1702
|
}
|
|
1636
|
-
return { content:
|
|
1703
|
+
return { content: textBlock.text };
|
|
1637
1704
|
} catch (error2) {
|
|
1638
1705
|
if (error2 instanceof LLMError) throw error2;
|
|
1639
|
-
if (signal.aborted)
|
|
1640
|
-
|
|
1706
|
+
if (signal.aborted) {
|
|
1707
|
+
throw new LLMError(`Anthropic request timed out after ${this.getTimeout(options)}ms`, { retryable: true });
|
|
1708
|
+
}
|
|
1709
|
+
throw new LLMError(`Anthropic API error: ${error2 instanceof Error ? error2.message : String(error2)}`, {
|
|
1710
|
+
cause: error2,
|
|
1711
|
+
retryable: isRetryableProviderError(error2)
|
|
1712
|
+
});
|
|
1641
1713
|
}
|
|
1642
1714
|
}
|
|
1643
1715
|
};
|
|
@@ -1648,7 +1720,8 @@ var OllamaProvider = class extends BaseLLMProvider {
|
|
|
1648
1720
|
capabilities = {
|
|
1649
1721
|
systemRole: true,
|
|
1650
1722
|
structuredOutputs: true,
|
|
1651
|
-
toolUse: false
|
|
1723
|
+
toolUse: false,
|
|
1724
|
+
honorsTemperature: true
|
|
1652
1725
|
};
|
|
1653
1726
|
baseURL;
|
|
1654
1727
|
model;
|
|
@@ -1693,11 +1766,14 @@ var OllamaProvider = class extends BaseLLMProvider {
|
|
|
1693
1766
|
const text2 = await response.text();
|
|
1694
1767
|
const keyHint = this.apiKey ? "OLLAMA_API_KEY is set but may be invalid or rejected by the server." : "OLLAMA_API_KEY is not set. Set the environment variable or use --no-llm to skip LLM processing.";
|
|
1695
1768
|
throw new LLMError(
|
|
1696
|
-
`Ollama request failed: ${response.status} ${response.statusText}${text2 ? ` - ${text2}` : ""}. ${keyHint}
|
|
1769
|
+
`Ollama request failed: ${response.status} ${response.statusText}${text2 ? ` - ${text2}` : ""}. ${keyHint}`,
|
|
1770
|
+
{ retryable: false }
|
|
1697
1771
|
);
|
|
1698
1772
|
}
|
|
1699
1773
|
const text = await response.text();
|
|
1700
|
-
throw new LLMError(`Ollama request failed: ${response.status} ${text}
|
|
1774
|
+
throw new LLMError(`Ollama request failed: ${response.status} ${text}`, {
|
|
1775
|
+
retryable: isRetryableStatus(response.status)
|
|
1776
|
+
});
|
|
1701
1777
|
}
|
|
1702
1778
|
const data = await response.json();
|
|
1703
1779
|
if (!data.message?.content) {
|
|
@@ -1716,8 +1792,13 @@ var OllamaProvider = class extends BaseLLMProvider {
|
|
|
1716
1792
|
return { content };
|
|
1717
1793
|
} catch (error2) {
|
|
1718
1794
|
if (error2 instanceof LLMError) throw error2;
|
|
1719
|
-
if (signal.aborted)
|
|
1720
|
-
|
|
1795
|
+
if (signal.aborted) {
|
|
1796
|
+
throw new LLMError(`Ollama request timed out after ${this.getTimeout(options)}ms`, { retryable: true });
|
|
1797
|
+
}
|
|
1798
|
+
throw new LLMError(`Ollama error: ${error2 instanceof Error ? error2.message : String(error2)}`, {
|
|
1799
|
+
cause: error2,
|
|
1800
|
+
retryable: isRetryableProviderError(error2)
|
|
1801
|
+
});
|
|
1721
1802
|
}
|
|
1722
1803
|
}
|
|
1723
1804
|
};
|
|
@@ -1729,7 +1810,8 @@ var OpenAIProvider = class extends BaseLLMProvider {
|
|
|
1729
1810
|
capabilities = {
|
|
1730
1811
|
systemRole: true,
|
|
1731
1812
|
structuredOutputs: true,
|
|
1732
|
-
toolUse: false
|
|
1813
|
+
toolUse: false,
|
|
1814
|
+
honorsTemperature: true
|
|
1733
1815
|
};
|
|
1734
1816
|
client;
|
|
1735
1817
|
model;
|
|
@@ -1761,7 +1843,6 @@ var OpenAIProvider = class extends BaseLLMProvider {
|
|
|
1761
1843
|
type: "json_schema",
|
|
1762
1844
|
json_schema: {
|
|
1763
1845
|
name: options.toolName ?? "release_notes",
|
|
1764
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1765
1846
|
schema: options.schema,
|
|
1766
1847
|
strict: true
|
|
1767
1848
|
}
|
|
@@ -1785,8 +1866,13 @@ var OpenAIProvider = class extends BaseLLMProvider {
|
|
|
1785
1866
|
return { content };
|
|
1786
1867
|
} catch (error2) {
|
|
1787
1868
|
if (error2 instanceof LLMError) throw error2;
|
|
1788
|
-
if (signal.aborted)
|
|
1789
|
-
|
|
1869
|
+
if (signal.aborted) {
|
|
1870
|
+
throw new LLMError(`OpenAI request timed out after ${this.getTimeout(options)}ms`, { retryable: true });
|
|
1871
|
+
}
|
|
1872
|
+
throw new LLMError(`OpenAI API error: ${error2 instanceof Error ? error2.message : String(error2)}`, {
|
|
1873
|
+
cause: error2,
|
|
1874
|
+
retryable: isRetryableProviderError(error2)
|
|
1875
|
+
});
|
|
1790
1876
|
}
|
|
1791
1877
|
}
|
|
1792
1878
|
};
|
|
@@ -1798,7 +1884,8 @@ var OpenAICompatibleProvider = class extends BaseLLMProvider {
|
|
|
1798
1884
|
capabilities = {
|
|
1799
1885
|
systemRole: true,
|
|
1800
1886
|
structuredOutputs: false,
|
|
1801
|
-
toolUse: false
|
|
1887
|
+
toolUse: false,
|
|
1888
|
+
honorsTemperature: true
|
|
1802
1889
|
};
|
|
1803
1890
|
client;
|
|
1804
1891
|
model;
|
|
@@ -1831,8 +1918,13 @@ var OpenAICompatibleProvider = class extends BaseLLMProvider {
|
|
|
1831
1918
|
return { content };
|
|
1832
1919
|
} catch (error2) {
|
|
1833
1920
|
if (error2 instanceof LLMError) throw error2;
|
|
1834
|
-
if (signal.aborted)
|
|
1835
|
-
|
|
1921
|
+
if (signal.aborted) {
|
|
1922
|
+
throw new LLMError(`${this.name} request timed out after ${this.getTimeout(options)}ms`, { retryable: true });
|
|
1923
|
+
}
|
|
1924
|
+
throw new LLMError(`LLM API error: ${error2 instanceof Error ? error2.message : String(error2)}`, {
|
|
1925
|
+
cause: error2,
|
|
1926
|
+
retryable: isRetryableProviderError(error2)
|
|
1927
|
+
});
|
|
1836
1928
|
}
|
|
1837
1929
|
}
|
|
1838
1930
|
};
|
|
@@ -2110,6 +2202,7 @@ async function enhanceEntry(provider, entry, context) {
|
|
|
2110
2202
|
}
|
|
2111
2203
|
async function enhanceEntries(provider, entries, context, concurrency = LLM_DEFAULTS.concurrency) {
|
|
2112
2204
|
const results = [];
|
|
2205
|
+
let failures = 0;
|
|
2113
2206
|
for (let i = 0; i < entries.length; i += concurrency) {
|
|
2114
2207
|
const batch = entries.slice(i, i + concurrency);
|
|
2115
2208
|
const batchResults = await Promise.all(
|
|
@@ -2118,12 +2211,16 @@ async function enhanceEntries(provider, entries, context, concurrency = LLM_DEFA
|
|
|
2118
2211
|
const newDescription = await enhanceEntry(provider, entry, context);
|
|
2119
2212
|
return { ...entry, description: newDescription };
|
|
2120
2213
|
} catch {
|
|
2214
|
+
failures++;
|
|
2121
2215
|
return entry;
|
|
2122
2216
|
}
|
|
2123
2217
|
})
|
|
2124
2218
|
);
|
|
2125
2219
|
results.push(...batchResults);
|
|
2126
2220
|
}
|
|
2221
|
+
if (failures > 0) {
|
|
2222
|
+
warn(`LLM enhancement failed for ${failures} of ${entries.length} entries; keeping their original text.`);
|
|
2223
|
+
}
|
|
2127
2224
|
return results;
|
|
2128
2225
|
}
|
|
2129
2226
|
|
|
@@ -2211,20 +2308,17 @@ function createEnhanceAndCategorizeValidator(entries, context) {
|
|
|
2211
2308
|
};
|
|
2212
2309
|
};
|
|
2213
2310
|
}
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2311
|
+
function mergeCategories(target, incoming) {
|
|
2312
|
+
for (const cat of incoming) {
|
|
2313
|
+
const existing = target.find((c) => c.category === cat.category);
|
|
2314
|
+
if (existing) existing.entries.push(...cat.entries);
|
|
2315
|
+
else target.push({ category: cat.category, entries: [...cat.entries] });
|
|
2217
2316
|
}
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
const systemPrompt = resolveSystemPrompt(
|
|
2221
|
-
"enhanceAndCategorize",
|
|
2222
|
-
examplesBlock ? `${basePrompt}${examplesBlock}` : basePrompt,
|
|
2223
|
-
context.prompts
|
|
2224
|
-
);
|
|
2317
|
+
}
|
|
2318
|
+
async function enhanceAndCategorizeChunk(provider, chunk, context, systemPrompt) {
|
|
2225
2319
|
const initialMessages = [
|
|
2226
2320
|
{ role: "system", content: systemPrompt },
|
|
2227
|
-
{ role: "user", content: buildUserPrompt3(
|
|
2321
|
+
{ role: "user", content: buildUserPrompt3(chunk) }
|
|
2228
2322
|
];
|
|
2229
2323
|
try {
|
|
2230
2324
|
return await runCorrectiveTask({
|
|
@@ -2232,17 +2326,39 @@ async function enhanceAndCategorize(provider, entries, context) {
|
|
|
2232
2326
|
initialMessages,
|
|
2233
2327
|
schema: buildEnhanceAndCategorizeSchema(context.categories ?? []),
|
|
2234
2328
|
toolName: "emit_release_notes",
|
|
2235
|
-
validate: createEnhanceAndCategorizeValidator(
|
|
2329
|
+
validate: createEnhanceAndCategorizeValidator(chunk, context)
|
|
2236
2330
|
});
|
|
2237
2331
|
} catch (error2) {
|
|
2238
2332
|
if (error2 instanceof LLMError) {
|
|
2239
|
-
warn(`enhanceAndCategorize failed
|
|
2240
|
-
const stripped =
|
|
2333
|
+
warn(`enhanceAndCategorize failed for a ${chunk.length}-entry chunk: ${error2.message}. Returning it ungrouped.`);
|
|
2334
|
+
const stripped = chunk.map((e) => ({ ...e, scope: void 0, leadIn: void 0 }));
|
|
2241
2335
|
return { enhancedEntries: stripped, categories: [{ category: "General", entries: stripped }] };
|
|
2242
2336
|
}
|
|
2243
2337
|
throw error2;
|
|
2244
2338
|
}
|
|
2245
2339
|
}
|
|
2340
|
+
async function enhanceAndCategorize(provider, entries, context) {
|
|
2341
|
+
if (entries.length === 0) {
|
|
2342
|
+
return { enhancedEntries: [], categories: [] };
|
|
2343
|
+
}
|
|
2344
|
+
const basePrompt = buildSystemPrompt3(context.categories, context.style);
|
|
2345
|
+
const examplesBlock = renderExamplesBlock(context.examples ?? []);
|
|
2346
|
+
const systemPrompt = resolveSystemPrompt(
|
|
2347
|
+
"enhanceAndCategorize",
|
|
2348
|
+
examplesBlock ? `${basePrompt}${examplesBlock}` : basePrompt,
|
|
2349
|
+
context.prompts
|
|
2350
|
+
);
|
|
2351
|
+
const chunkSize = LLM_DEFAULTS.enhanceCategorizeChunkSize;
|
|
2352
|
+
const enhancedEntries = [];
|
|
2353
|
+
const categories = [];
|
|
2354
|
+
for (let i = 0; i < entries.length; i += chunkSize) {
|
|
2355
|
+
const chunk = entries.slice(i, i + chunkSize);
|
|
2356
|
+
const result = await enhanceAndCategorizeChunk(provider, chunk, context, systemPrompt);
|
|
2357
|
+
enhancedEntries.push(...result.enhancedEntries);
|
|
2358
|
+
mergeCategories(categories, result.categories);
|
|
2359
|
+
}
|
|
2360
|
+
return { enhancedEntries, categories };
|
|
2361
|
+
}
|
|
2246
2362
|
|
|
2247
2363
|
// src/llm/tasks/release-notes.ts
|
|
2248
2364
|
var DEFAULT_SYSTEM_PROMPT = `You are writing release notes for a software project.
|
|
@@ -2630,9 +2746,32 @@ function renderTemplate(templatePath, context, engine) {
|
|
|
2630
2746
|
return renderComposable(templatePath, context, engine);
|
|
2631
2747
|
}
|
|
2632
2748
|
|
|
2749
|
+
// src/utils/concurrency.ts
|
|
2750
|
+
async function mapWithConcurrency(items, limit, fn) {
|
|
2751
|
+
const bound = Math.max(1, Math.floor(limit) || 1);
|
|
2752
|
+
const results = new Array(items.length);
|
|
2753
|
+
let next = 0;
|
|
2754
|
+
let failed = false;
|
|
2755
|
+
async function worker() {
|
|
2756
|
+
while (!failed) {
|
|
2757
|
+
const i = next++;
|
|
2758
|
+
if (i >= items.length) return;
|
|
2759
|
+
try {
|
|
2760
|
+
results[i] = await fn(items[i], i);
|
|
2761
|
+
} catch (err) {
|
|
2762
|
+
failed = true;
|
|
2763
|
+
throw err;
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
const workers = Array.from({ length: Math.min(bound, items.length) }, () => worker());
|
|
2768
|
+
await Promise.all(workers);
|
|
2769
|
+
return results;
|
|
2770
|
+
}
|
|
2771
|
+
|
|
2633
2772
|
// src/utils/retry.ts
|
|
2634
2773
|
function sleep(ms) {
|
|
2635
|
-
return new Promise((
|
|
2774
|
+
return new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
2636
2775
|
}
|
|
2637
2776
|
async function withRetry(fn, options = {}) {
|
|
2638
2777
|
const maxAttempts = options.maxAttempts ?? 3;
|
|
@@ -2645,6 +2784,7 @@ async function withRetry(fn, options = {}) {
|
|
|
2645
2784
|
return await fn();
|
|
2646
2785
|
} catch (error2) {
|
|
2647
2786
|
lastError = error2;
|
|
2787
|
+
if (options.shouldRetry && !options.shouldRetry(error2)) break;
|
|
2648
2788
|
if (attempt < maxAttempts - 1) {
|
|
2649
2789
|
const base = Math.min(initialDelay * backoffFactor ** attempt, maxDelay);
|
|
2650
2790
|
const jitter = base * 0.2 * (Math.random() * 2 - 1);
|
|
@@ -2772,6 +2912,7 @@ async function processWithLLM(context, llmConfig, examples, packageNames) {
|
|
|
2772
2912
|
const enhanced = {
|
|
2773
2913
|
entries: context.entries
|
|
2774
2914
|
};
|
|
2915
|
+
let provider;
|
|
2775
2916
|
try {
|
|
2776
2917
|
info(`Using LLM provider: ${llmConfig.provider}${llmConfig.model ? ` (${llmConfig.model})` : ""}`);
|
|
2777
2918
|
if (llmConfig.baseURL) {
|
|
@@ -2781,33 +2922,58 @@ async function processWithLLM(context, llmConfig, examples, packageNames) {
|
|
|
2781
2922
|
const baseProvider = llmConfig.cache ? withContentHashCache(rawProvider, { model: llmConfig.model, baseURL: llmConfig.baseURL }) : rawProvider;
|
|
2782
2923
|
const retryOpts = llmConfig.retry ?? LLM_DEFAULTS.retry;
|
|
2783
2924
|
const configOptions = llmConfig.options;
|
|
2784
|
-
|
|
2925
|
+
provider = {
|
|
2785
2926
|
name: baseProvider.name,
|
|
2786
2927
|
capabilities: baseProvider.capabilities,
|
|
2787
|
-
|
|
2928
|
+
// Fail fast on non-transient errors (4xx auth/validation); only retry timeout/429/5xx/network.
|
|
2929
|
+
complete: (messages, opts) => withRetry(() => baseProvider.complete(messages, { ...configOptions, ...opts }), {
|
|
2930
|
+
...retryOpts,
|
|
2931
|
+
shouldRetry: isRetryableLLMError
|
|
2932
|
+
})
|
|
2788
2933
|
};
|
|
2789
2934
|
const activeTasks = Object.entries(tasks).filter(([, enabled]) => enabled).map(([name]) => name);
|
|
2790
2935
|
info(`Running LLM tasks: ${activeTasks.join(", ")}`);
|
|
2791
|
-
|
|
2936
|
+
} catch (error2) {
|
|
2937
|
+
warn(`LLM setup failed: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
2938
|
+
warn("Falling back to non-LLM changelog rendering. Check your LLM config or set RELEASEKIT_DEBUG=1 for details.");
|
|
2939
|
+
return context;
|
|
2940
|
+
}
|
|
2941
|
+
const taskFailed = (task, error2) => {
|
|
2942
|
+
warn(`LLM ${task} failed: ${error2 instanceof Error ? error2.message : String(error2)}. Keeping results so far.`);
|
|
2943
|
+
};
|
|
2944
|
+
if (tasks.enhance && tasks.categorize) {
|
|
2945
|
+
try {
|
|
2792
2946
|
info("Enhancing and categorizing entries with LLM...");
|
|
2793
2947
|
const result = await enhanceAndCategorize(provider, context.entries, llmContext);
|
|
2794
2948
|
enhanced.entries = result.enhancedEntries;
|
|
2795
2949
|
enhanced.categories = buildOrderedCategories(result.categories, llmContext.categories);
|
|
2796
2950
|
info(`Enhanced ${enhanced.entries.length} entries into ${result.categories.length} categories`);
|
|
2797
|
-
}
|
|
2798
|
-
|
|
2951
|
+
} catch (error2) {
|
|
2952
|
+
taskFailed("enhance+categorize", error2);
|
|
2953
|
+
}
|
|
2954
|
+
} else {
|
|
2955
|
+
if (tasks.enhance) {
|
|
2956
|
+
try {
|
|
2799
2957
|
info("Enhancing entries with LLM...");
|
|
2800
2958
|
enhanced.entries = await enhanceEntries(provider, context.entries, llmContext, llmConfig.concurrency);
|
|
2801
2959
|
info(`Enhanced ${enhanced.entries.length} entries`);
|
|
2960
|
+
} catch (error2) {
|
|
2961
|
+
taskFailed("enhance", error2);
|
|
2802
2962
|
}
|
|
2803
|
-
|
|
2963
|
+
}
|
|
2964
|
+
if (tasks.categorize) {
|
|
2965
|
+
try {
|
|
2804
2966
|
info("Categorizing entries with LLM...");
|
|
2805
2967
|
const categorized = await categorizeEntries(provider, enhanced.entries, llmContext);
|
|
2806
2968
|
enhanced.categories = buildOrderedCategories(categorized, llmContext.categories);
|
|
2807
2969
|
info(`Created ${categorized.length} categories`);
|
|
2970
|
+
} catch (error2) {
|
|
2971
|
+
taskFailed("categorize", error2);
|
|
2808
2972
|
}
|
|
2809
2973
|
}
|
|
2810
|
-
|
|
2974
|
+
}
|
|
2975
|
+
if (tasks.summarize) {
|
|
2976
|
+
try {
|
|
2811
2977
|
info("Summarizing entries with LLM...");
|
|
2812
2978
|
enhanced.summary = await summarizeEntries(provider, enhanced.entries, llmContext);
|
|
2813
2979
|
if (enhanced.summary) {
|
|
@@ -2816,8 +2982,12 @@ async function processWithLLM(context, llmConfig, examples, packageNames) {
|
|
|
2816
2982
|
} else {
|
|
2817
2983
|
warn("Summary generation returned empty result");
|
|
2818
2984
|
}
|
|
2985
|
+
} catch (error2) {
|
|
2986
|
+
taskFailed("summarize", error2);
|
|
2819
2987
|
}
|
|
2820
|
-
|
|
2988
|
+
}
|
|
2989
|
+
if (tasks.releaseNotes) {
|
|
2990
|
+
try {
|
|
2821
2991
|
info("Generating release notes with LLM...");
|
|
2822
2992
|
enhanced.releaseNotes = await generateReleaseNotes(provider, enhanced.entries, llmContext);
|
|
2823
2993
|
if (enhanced.releaseNotes) {
|
|
@@ -2825,16 +2995,14 @@ async function processWithLLM(context, llmConfig, examples, packageNames) {
|
|
|
2825
2995
|
} else {
|
|
2826
2996
|
warn("Release notes generation returned empty result");
|
|
2827
2997
|
}
|
|
2998
|
+
} catch (error2) {
|
|
2999
|
+
taskFailed("releaseNotes", error2);
|
|
2828
3000
|
}
|
|
2829
|
-
return {
|
|
2830
|
-
...context,
|
|
2831
|
-
enhanced
|
|
2832
|
-
};
|
|
2833
|
-
} catch (error2) {
|
|
2834
|
-
warn(`LLM processing failed: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
2835
|
-
warn("Falling back to non-LLM changelog rendering. Check your LLM config or set RELEASEKIT_DEBUG=1 for details.");
|
|
2836
|
-
return context;
|
|
2837
3001
|
}
|
|
3002
|
+
return {
|
|
3003
|
+
...context,
|
|
3004
|
+
enhanced
|
|
3005
|
+
};
|
|
2838
3006
|
}
|
|
2839
3007
|
function getBuiltinTemplatePath(style) {
|
|
2840
3008
|
let packageRoot;
|
|
@@ -2929,10 +3097,11 @@ async function runPipeline(input, config, dryRun, pipelineOptions) {
|
|
|
2929
3097
|
}));
|
|
2930
3098
|
}
|
|
2931
3099
|
const allPackageNames = contexts.map((c) => c.packageName);
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
3100
|
+
const concurrency = llmConfig.concurrency ?? LLM_DEFAULTS.concurrency;
|
|
3101
|
+
contexts = await mapWithConcurrency(
|
|
3102
|
+
contexts,
|
|
3103
|
+
concurrency,
|
|
3104
|
+
(ctx) => processWithLLM(ctx, llmConfig, examplesByPackage.get(ctx.packageName) ?? [], allPackageNames)
|
|
2936
3105
|
);
|
|
2937
3106
|
}
|
|
2938
3107
|
const files = [];
|
|
@@ -2980,7 +3149,7 @@ async function runPipeline(input, config, dryRun, pipelineOptions) {
|
|
|
2980
3149
|
const dir = releaseNotesConfig.file.dir;
|
|
2981
3150
|
info(`Generating release notes \u2192 ${dir}`);
|
|
2982
3151
|
try {
|
|
2983
|
-
const { detectMonorepo } = await import("./aggregator-
|
|
3152
|
+
const { detectMonorepo } = await import("./aggregator-NMUD72J2.js");
|
|
2984
3153
|
const nested = detectMonorepo(process.cwd()).isMonorepo || contexts.length > 1;
|
|
2985
3154
|
const renderContent = (ctx) => {
|
|
2986
3155
|
if (releaseNotesConfig.templates?.path) {
|
|
@@ -3042,7 +3211,7 @@ async function processInput(inputJson, config, dryRun, pipelineOptions) {
|
|
|
3042
3211
|
return runPipeline(input, config, dryRun, pipelineOptions);
|
|
3043
3212
|
}
|
|
3044
3213
|
async function writeMonorepoFiles(contexts, config, dryRun, fileName, refs) {
|
|
3045
|
-
const { detectMonorepo, writeMonorepoChangelogs } = await import("./aggregator-
|
|
3214
|
+
const { detectMonorepo, writeMonorepoChangelogs } = await import("./aggregator-NMUD72J2.js");
|
|
3046
3215
|
const cwd = process.cwd();
|
|
3047
3216
|
const detected = detectMonorepo(cwd);
|
|
3048
3217
|
if (!detected.isMonorepo) return [];
|
|
@@ -3240,10 +3409,10 @@ async function readStdin() {
|
|
|
3240
3409
|
}
|
|
3241
3410
|
function promptSecret(prompt) {
|
|
3242
3411
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
3243
|
-
return new Promise((
|
|
3412
|
+
return new Promise((resolve3) => {
|
|
3244
3413
|
rl.question(prompt, (answer) => {
|
|
3245
3414
|
rl.close();
|
|
3246
|
-
|
|
3415
|
+
resolve3(answer);
|
|
3247
3416
|
});
|
|
3248
3417
|
});
|
|
3249
3418
|
}
|
|
@@ -6,6 +6,7 @@ import * as path2 from "path";
|
|
|
6
6
|
import { fileURLToPath } from "url";
|
|
7
7
|
import chalk from "chalk";
|
|
8
8
|
import { minimatch } from "minimatch";
|
|
9
|
+
import * as path3 from "path";
|
|
9
10
|
function parseGitHubOwnerRepo(repoUrl) {
|
|
10
11
|
const scpMatch = repoUrl.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/);
|
|
11
12
|
if (scpMatch) return { owner: scpMatch[1], repo: scpMatch[2] };
|
|
@@ -160,10 +161,19 @@ var EXIT_CODES = {
|
|
|
160
161
|
VERSION_ERROR: 8,
|
|
161
162
|
PUBLISH_ERROR: 9
|
|
162
163
|
};
|
|
164
|
+
function isPathWithinRoot(root, target) {
|
|
165
|
+
const resolvedRoot = path3.resolve(root);
|
|
166
|
+
const resolvedTarget = path3.resolve(target);
|
|
167
|
+
if (resolvedTarget === resolvedRoot) {
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
const relative2 = path3.relative(resolvedRoot, resolvedTarget);
|
|
171
|
+
return relative2 !== ".." && !relative2.startsWith(`..${path3.sep}`) && !path3.isAbsolute(relative2);
|
|
172
|
+
}
|
|
163
173
|
|
|
164
174
|
// src/output/markdown.ts
|
|
165
175
|
import * as fs3 from "fs";
|
|
166
|
-
import * as
|
|
176
|
+
import * as path4 from "path";
|
|
167
177
|
var DEFAULT_FIRST_RELEASE_TEXT = "_First release of ${packageName}._";
|
|
168
178
|
function firstReleaseLine(context, config) {
|
|
169
179
|
if (!context.isFirstRelease || config === false) return void 0;
|
|
@@ -441,7 +451,7 @@ function writeMarkdown(outputPath, contexts, config, dryRun, options) {
|
|
|
441
451
|
info(content);
|
|
442
452
|
return;
|
|
443
453
|
}
|
|
444
|
-
const dir =
|
|
454
|
+
const dir = path4.dirname(outputPath);
|
|
445
455
|
if (!fs3.existsSync(dir)) {
|
|
446
456
|
fs3.mkdirSync(dir, { recursive: true });
|
|
447
457
|
}
|
|
@@ -473,6 +483,7 @@ export {
|
|
|
473
483
|
debug,
|
|
474
484
|
ReleaseKitError,
|
|
475
485
|
EXIT_CODES,
|
|
486
|
+
isPathWithinRoot,
|
|
476
487
|
formatVersion,
|
|
477
488
|
renderMarkdown,
|
|
478
489
|
prependVersion,
|
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
createNotesCommand
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-2PRVRNSI.js";
|
|
5
5
|
import {
|
|
6
6
|
readPackageVersion
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-FI3F2ND5.js";
|
|
8
8
|
|
|
9
9
|
// src/cli.ts
|
|
10
10
|
import * as fs from "fs";
|
package/dist/index.js
CHANGED
|
@@ -18,12 +18,12 @@ import {
|
|
|
18
18
|
runPipeline,
|
|
19
19
|
saveAuth,
|
|
20
20
|
versionOutputToChangelogInput
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-2PRVRNSI.js";
|
|
22
22
|
import {
|
|
23
23
|
aggregateToRoot,
|
|
24
24
|
detectMonorepo,
|
|
25
25
|
writeMonorepoChangelogs
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-YO6KWOCB.js";
|
|
27
27
|
import {
|
|
28
28
|
debug,
|
|
29
29
|
formatVersion,
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
renderMarkdown,
|
|
32
32
|
success,
|
|
33
33
|
writeMarkdown
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-FI3F2ND5.js";
|
|
35
35
|
|
|
36
36
|
// src/output/json.ts
|
|
37
37
|
import * as fs from "fs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@releasekit/notes",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.2",
|
|
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.112.
|
|
50
|
+
"@anthropic-ai/sdk": "^0.112.4",
|
|
51
51
|
"@octokit/rest": "^22.0.1",
|
|
52
52
|
"chalk": "^5.6.2",
|
|
53
53
|
"commander": "^14.0.3",
|
|
@@ -69,10 +69,10 @@
|
|
|
69
69
|
"tsup": "^8.5.1",
|
|
70
70
|
"typescript": "^5.9.3",
|
|
71
71
|
"vitest": "^4.1.10",
|
|
72
|
+
"@releasekit/config": "0.0.0",
|
|
72
73
|
"@releasekit/forge": "0.0.0",
|
|
73
|
-
"@releasekit/git": "0.0.0",
|
|
74
74
|
"@releasekit/core": "0.0.0",
|
|
75
|
-
"@releasekit/
|
|
75
|
+
"@releasekit/git": "0.0.0"
|
|
76
76
|
},
|
|
77
77
|
"engines": {
|
|
78
78
|
"node": ">=22"
|