@releasekit/notes 0.41.0 → 0.41.1
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-EWEPFCCT.js → chunk-FI3F2ND5.js} +13 -2
- package/dist/{chunk-WTOR47NP.js → chunk-YO6KWOCB.js} +1 -1
- package/dist/{chunk-4YP4CODY.js → chunk-ZGFPTVWY.js} +240 -70
- package/dist/cli.js +2 -2
- package/dist/index.js +3 -3
- package/package.json +4 -4
|
@@ -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,
|
|
@@ -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;
|
|
@@ -1785,8 +1867,13 @@ var OpenAIProvider = class extends BaseLLMProvider {
|
|
|
1785
1867
|
return { content };
|
|
1786
1868
|
} catch (error2) {
|
|
1787
1869
|
if (error2 instanceof LLMError) throw error2;
|
|
1788
|
-
if (signal.aborted)
|
|
1789
|
-
|
|
1870
|
+
if (signal.aborted) {
|
|
1871
|
+
throw new LLMError(`OpenAI request timed out after ${this.getTimeout(options)}ms`, { retryable: true });
|
|
1872
|
+
}
|
|
1873
|
+
throw new LLMError(`OpenAI API error: ${error2 instanceof Error ? error2.message : String(error2)}`, {
|
|
1874
|
+
cause: error2,
|
|
1875
|
+
retryable: isRetryableProviderError(error2)
|
|
1876
|
+
});
|
|
1790
1877
|
}
|
|
1791
1878
|
}
|
|
1792
1879
|
};
|
|
@@ -1798,7 +1885,8 @@ var OpenAICompatibleProvider = class extends BaseLLMProvider {
|
|
|
1798
1885
|
capabilities = {
|
|
1799
1886
|
systemRole: true,
|
|
1800
1887
|
structuredOutputs: false,
|
|
1801
|
-
toolUse: false
|
|
1888
|
+
toolUse: false,
|
|
1889
|
+
honorsTemperature: true
|
|
1802
1890
|
};
|
|
1803
1891
|
client;
|
|
1804
1892
|
model;
|
|
@@ -1831,8 +1919,13 @@ var OpenAICompatibleProvider = class extends BaseLLMProvider {
|
|
|
1831
1919
|
return { content };
|
|
1832
1920
|
} catch (error2) {
|
|
1833
1921
|
if (error2 instanceof LLMError) throw error2;
|
|
1834
|
-
if (signal.aborted)
|
|
1835
|
-
|
|
1922
|
+
if (signal.aborted) {
|
|
1923
|
+
throw new LLMError(`${this.name} request timed out after ${this.getTimeout(options)}ms`, { retryable: true });
|
|
1924
|
+
}
|
|
1925
|
+
throw new LLMError(`LLM API error: ${error2 instanceof Error ? error2.message : String(error2)}`, {
|
|
1926
|
+
cause: error2,
|
|
1927
|
+
retryable: isRetryableProviderError(error2)
|
|
1928
|
+
});
|
|
1836
1929
|
}
|
|
1837
1930
|
}
|
|
1838
1931
|
};
|
|
@@ -2110,6 +2203,7 @@ async function enhanceEntry(provider, entry, context) {
|
|
|
2110
2203
|
}
|
|
2111
2204
|
async function enhanceEntries(provider, entries, context, concurrency = LLM_DEFAULTS.concurrency) {
|
|
2112
2205
|
const results = [];
|
|
2206
|
+
let failures = 0;
|
|
2113
2207
|
for (let i = 0; i < entries.length; i += concurrency) {
|
|
2114
2208
|
const batch = entries.slice(i, i + concurrency);
|
|
2115
2209
|
const batchResults = await Promise.all(
|
|
@@ -2118,12 +2212,16 @@ async function enhanceEntries(provider, entries, context, concurrency = LLM_DEFA
|
|
|
2118
2212
|
const newDescription = await enhanceEntry(provider, entry, context);
|
|
2119
2213
|
return { ...entry, description: newDescription };
|
|
2120
2214
|
} catch {
|
|
2215
|
+
failures++;
|
|
2121
2216
|
return entry;
|
|
2122
2217
|
}
|
|
2123
2218
|
})
|
|
2124
2219
|
);
|
|
2125
2220
|
results.push(...batchResults);
|
|
2126
2221
|
}
|
|
2222
|
+
if (failures > 0) {
|
|
2223
|
+
warn(`LLM enhancement failed for ${failures} of ${entries.length} entries; keeping their original text.`);
|
|
2224
|
+
}
|
|
2127
2225
|
return results;
|
|
2128
2226
|
}
|
|
2129
2227
|
|
|
@@ -2211,20 +2309,17 @@ function createEnhanceAndCategorizeValidator(entries, context) {
|
|
|
2211
2309
|
};
|
|
2212
2310
|
};
|
|
2213
2311
|
}
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2312
|
+
function mergeCategories(target, incoming) {
|
|
2313
|
+
for (const cat of incoming) {
|
|
2314
|
+
const existing = target.find((c) => c.category === cat.category);
|
|
2315
|
+
if (existing) existing.entries.push(...cat.entries);
|
|
2316
|
+
else target.push({ category: cat.category, entries: [...cat.entries] });
|
|
2217
2317
|
}
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
const systemPrompt = resolveSystemPrompt(
|
|
2221
|
-
"enhanceAndCategorize",
|
|
2222
|
-
examplesBlock ? `${basePrompt}${examplesBlock}` : basePrompt,
|
|
2223
|
-
context.prompts
|
|
2224
|
-
);
|
|
2318
|
+
}
|
|
2319
|
+
async function enhanceAndCategorizeChunk(provider, chunk, context, systemPrompt) {
|
|
2225
2320
|
const initialMessages = [
|
|
2226
2321
|
{ role: "system", content: systemPrompt },
|
|
2227
|
-
{ role: "user", content: buildUserPrompt3(
|
|
2322
|
+
{ role: "user", content: buildUserPrompt3(chunk) }
|
|
2228
2323
|
];
|
|
2229
2324
|
try {
|
|
2230
2325
|
return await runCorrectiveTask({
|
|
@@ -2232,17 +2327,39 @@ async function enhanceAndCategorize(provider, entries, context) {
|
|
|
2232
2327
|
initialMessages,
|
|
2233
2328
|
schema: buildEnhanceAndCategorizeSchema(context.categories ?? []),
|
|
2234
2329
|
toolName: "emit_release_notes",
|
|
2235
|
-
validate: createEnhanceAndCategorizeValidator(
|
|
2330
|
+
validate: createEnhanceAndCategorizeValidator(chunk, context)
|
|
2236
2331
|
});
|
|
2237
2332
|
} catch (error2) {
|
|
2238
2333
|
if (error2 instanceof LLMError) {
|
|
2239
|
-
warn(`enhanceAndCategorize failed
|
|
2240
|
-
const stripped =
|
|
2334
|
+
warn(`enhanceAndCategorize failed for a ${chunk.length}-entry chunk: ${error2.message}. Returning it ungrouped.`);
|
|
2335
|
+
const stripped = chunk.map((e) => ({ ...e, scope: void 0, leadIn: void 0 }));
|
|
2241
2336
|
return { enhancedEntries: stripped, categories: [{ category: "General", entries: stripped }] };
|
|
2242
2337
|
}
|
|
2243
2338
|
throw error2;
|
|
2244
2339
|
}
|
|
2245
2340
|
}
|
|
2341
|
+
async function enhanceAndCategorize(provider, entries, context) {
|
|
2342
|
+
if (entries.length === 0) {
|
|
2343
|
+
return { enhancedEntries: [], categories: [] };
|
|
2344
|
+
}
|
|
2345
|
+
const basePrompt = buildSystemPrompt3(context.categories, context.style);
|
|
2346
|
+
const examplesBlock = renderExamplesBlock(context.examples ?? []);
|
|
2347
|
+
const systemPrompt = resolveSystemPrompt(
|
|
2348
|
+
"enhanceAndCategorize",
|
|
2349
|
+
examplesBlock ? `${basePrompt}${examplesBlock}` : basePrompt,
|
|
2350
|
+
context.prompts
|
|
2351
|
+
);
|
|
2352
|
+
const chunkSize = LLM_DEFAULTS.enhanceCategorizeChunkSize;
|
|
2353
|
+
const enhancedEntries = [];
|
|
2354
|
+
const categories = [];
|
|
2355
|
+
for (let i = 0; i < entries.length; i += chunkSize) {
|
|
2356
|
+
const chunk = entries.slice(i, i + chunkSize);
|
|
2357
|
+
const result = await enhanceAndCategorizeChunk(provider, chunk, context, systemPrompt);
|
|
2358
|
+
enhancedEntries.push(...result.enhancedEntries);
|
|
2359
|
+
mergeCategories(categories, result.categories);
|
|
2360
|
+
}
|
|
2361
|
+
return { enhancedEntries, categories };
|
|
2362
|
+
}
|
|
2246
2363
|
|
|
2247
2364
|
// src/llm/tasks/release-notes.ts
|
|
2248
2365
|
var DEFAULT_SYSTEM_PROMPT = `You are writing release notes for a software project.
|
|
@@ -2630,9 +2747,32 @@ function renderTemplate(templatePath, context, engine) {
|
|
|
2630
2747
|
return renderComposable(templatePath, context, engine);
|
|
2631
2748
|
}
|
|
2632
2749
|
|
|
2750
|
+
// src/utils/concurrency.ts
|
|
2751
|
+
async function mapWithConcurrency(items, limit, fn) {
|
|
2752
|
+
const bound = Math.max(1, Math.floor(limit) || 1);
|
|
2753
|
+
const results = new Array(items.length);
|
|
2754
|
+
let next = 0;
|
|
2755
|
+
let failed = false;
|
|
2756
|
+
async function worker() {
|
|
2757
|
+
while (!failed) {
|
|
2758
|
+
const i = next++;
|
|
2759
|
+
if (i >= items.length) return;
|
|
2760
|
+
try {
|
|
2761
|
+
results[i] = await fn(items[i], i);
|
|
2762
|
+
} catch (err) {
|
|
2763
|
+
failed = true;
|
|
2764
|
+
throw err;
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
const workers = Array.from({ length: Math.min(bound, items.length) }, () => worker());
|
|
2769
|
+
await Promise.all(workers);
|
|
2770
|
+
return results;
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2633
2773
|
// src/utils/retry.ts
|
|
2634
2774
|
function sleep(ms) {
|
|
2635
|
-
return new Promise((
|
|
2775
|
+
return new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
2636
2776
|
}
|
|
2637
2777
|
async function withRetry(fn, options = {}) {
|
|
2638
2778
|
const maxAttempts = options.maxAttempts ?? 3;
|
|
@@ -2645,6 +2785,7 @@ async function withRetry(fn, options = {}) {
|
|
|
2645
2785
|
return await fn();
|
|
2646
2786
|
} catch (error2) {
|
|
2647
2787
|
lastError = error2;
|
|
2788
|
+
if (options.shouldRetry && !options.shouldRetry(error2)) break;
|
|
2648
2789
|
if (attempt < maxAttempts - 1) {
|
|
2649
2790
|
const base = Math.min(initialDelay * backoffFactor ** attempt, maxDelay);
|
|
2650
2791
|
const jitter = base * 0.2 * (Math.random() * 2 - 1);
|
|
@@ -2772,6 +2913,7 @@ async function processWithLLM(context, llmConfig, examples, packageNames) {
|
|
|
2772
2913
|
const enhanced = {
|
|
2773
2914
|
entries: context.entries
|
|
2774
2915
|
};
|
|
2916
|
+
let provider;
|
|
2775
2917
|
try {
|
|
2776
2918
|
info(`Using LLM provider: ${llmConfig.provider}${llmConfig.model ? ` (${llmConfig.model})` : ""}`);
|
|
2777
2919
|
if (llmConfig.baseURL) {
|
|
@@ -2781,33 +2923,58 @@ async function processWithLLM(context, llmConfig, examples, packageNames) {
|
|
|
2781
2923
|
const baseProvider = llmConfig.cache ? withContentHashCache(rawProvider, { model: llmConfig.model, baseURL: llmConfig.baseURL }) : rawProvider;
|
|
2782
2924
|
const retryOpts = llmConfig.retry ?? LLM_DEFAULTS.retry;
|
|
2783
2925
|
const configOptions = llmConfig.options;
|
|
2784
|
-
|
|
2926
|
+
provider = {
|
|
2785
2927
|
name: baseProvider.name,
|
|
2786
2928
|
capabilities: baseProvider.capabilities,
|
|
2787
|
-
|
|
2929
|
+
// Fail fast on non-transient errors (4xx auth/validation); only retry timeout/429/5xx/network.
|
|
2930
|
+
complete: (messages, opts) => withRetry(() => baseProvider.complete(messages, { ...configOptions, ...opts }), {
|
|
2931
|
+
...retryOpts,
|
|
2932
|
+
shouldRetry: isRetryableLLMError
|
|
2933
|
+
})
|
|
2788
2934
|
};
|
|
2789
2935
|
const activeTasks = Object.entries(tasks).filter(([, enabled]) => enabled).map(([name]) => name);
|
|
2790
2936
|
info(`Running LLM tasks: ${activeTasks.join(", ")}`);
|
|
2791
|
-
|
|
2937
|
+
} catch (error2) {
|
|
2938
|
+
warn(`LLM setup failed: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
2939
|
+
warn("Falling back to non-LLM changelog rendering. Check your LLM config or set RELEASEKIT_DEBUG=1 for details.");
|
|
2940
|
+
return context;
|
|
2941
|
+
}
|
|
2942
|
+
const taskFailed = (task, error2) => {
|
|
2943
|
+
warn(`LLM ${task} failed: ${error2 instanceof Error ? error2.message : String(error2)}. Keeping results so far.`);
|
|
2944
|
+
};
|
|
2945
|
+
if (tasks.enhance && tasks.categorize) {
|
|
2946
|
+
try {
|
|
2792
2947
|
info("Enhancing and categorizing entries with LLM...");
|
|
2793
2948
|
const result = await enhanceAndCategorize(provider, context.entries, llmContext);
|
|
2794
2949
|
enhanced.entries = result.enhancedEntries;
|
|
2795
2950
|
enhanced.categories = buildOrderedCategories(result.categories, llmContext.categories);
|
|
2796
2951
|
info(`Enhanced ${enhanced.entries.length} entries into ${result.categories.length} categories`);
|
|
2797
|
-
}
|
|
2798
|
-
|
|
2952
|
+
} catch (error2) {
|
|
2953
|
+
taskFailed("enhance+categorize", error2);
|
|
2954
|
+
}
|
|
2955
|
+
} else {
|
|
2956
|
+
if (tasks.enhance) {
|
|
2957
|
+
try {
|
|
2799
2958
|
info("Enhancing entries with LLM...");
|
|
2800
2959
|
enhanced.entries = await enhanceEntries(provider, context.entries, llmContext, llmConfig.concurrency);
|
|
2801
2960
|
info(`Enhanced ${enhanced.entries.length} entries`);
|
|
2961
|
+
} catch (error2) {
|
|
2962
|
+
taskFailed("enhance", error2);
|
|
2802
2963
|
}
|
|
2803
|
-
|
|
2964
|
+
}
|
|
2965
|
+
if (tasks.categorize) {
|
|
2966
|
+
try {
|
|
2804
2967
|
info("Categorizing entries with LLM...");
|
|
2805
2968
|
const categorized = await categorizeEntries(provider, enhanced.entries, llmContext);
|
|
2806
2969
|
enhanced.categories = buildOrderedCategories(categorized, llmContext.categories);
|
|
2807
2970
|
info(`Created ${categorized.length} categories`);
|
|
2971
|
+
} catch (error2) {
|
|
2972
|
+
taskFailed("categorize", error2);
|
|
2808
2973
|
}
|
|
2809
2974
|
}
|
|
2810
|
-
|
|
2975
|
+
}
|
|
2976
|
+
if (tasks.summarize) {
|
|
2977
|
+
try {
|
|
2811
2978
|
info("Summarizing entries with LLM...");
|
|
2812
2979
|
enhanced.summary = await summarizeEntries(provider, enhanced.entries, llmContext);
|
|
2813
2980
|
if (enhanced.summary) {
|
|
@@ -2816,8 +2983,12 @@ async function processWithLLM(context, llmConfig, examples, packageNames) {
|
|
|
2816
2983
|
} else {
|
|
2817
2984
|
warn("Summary generation returned empty result");
|
|
2818
2985
|
}
|
|
2986
|
+
} catch (error2) {
|
|
2987
|
+
taskFailed("summarize", error2);
|
|
2819
2988
|
}
|
|
2820
|
-
|
|
2989
|
+
}
|
|
2990
|
+
if (tasks.releaseNotes) {
|
|
2991
|
+
try {
|
|
2821
2992
|
info("Generating release notes with LLM...");
|
|
2822
2993
|
enhanced.releaseNotes = await generateReleaseNotes(provider, enhanced.entries, llmContext);
|
|
2823
2994
|
if (enhanced.releaseNotes) {
|
|
@@ -2825,16 +2996,14 @@ async function processWithLLM(context, llmConfig, examples, packageNames) {
|
|
|
2825
2996
|
} else {
|
|
2826
2997
|
warn("Release notes generation returned empty result");
|
|
2827
2998
|
}
|
|
2999
|
+
} catch (error2) {
|
|
3000
|
+
taskFailed("releaseNotes", error2);
|
|
2828
3001
|
}
|
|
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
3002
|
}
|
|
3003
|
+
return {
|
|
3004
|
+
...context,
|
|
3005
|
+
enhanced
|
|
3006
|
+
};
|
|
2838
3007
|
}
|
|
2839
3008
|
function getBuiltinTemplatePath(style) {
|
|
2840
3009
|
let packageRoot;
|
|
@@ -2929,10 +3098,11 @@ async function runPipeline(input, config, dryRun, pipelineOptions) {
|
|
|
2929
3098
|
}));
|
|
2930
3099
|
}
|
|
2931
3100
|
const allPackageNames = contexts.map((c) => c.packageName);
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
3101
|
+
const concurrency = llmConfig.concurrency ?? LLM_DEFAULTS.concurrency;
|
|
3102
|
+
contexts = await mapWithConcurrency(
|
|
3103
|
+
contexts,
|
|
3104
|
+
concurrency,
|
|
3105
|
+
(ctx) => processWithLLM(ctx, llmConfig, examplesByPackage.get(ctx.packageName) ?? [], allPackageNames)
|
|
2936
3106
|
);
|
|
2937
3107
|
}
|
|
2938
3108
|
const files = [];
|
|
@@ -2980,7 +3150,7 @@ async function runPipeline(input, config, dryRun, pipelineOptions) {
|
|
|
2980
3150
|
const dir = releaseNotesConfig.file.dir;
|
|
2981
3151
|
info(`Generating release notes \u2192 ${dir}`);
|
|
2982
3152
|
try {
|
|
2983
|
-
const { detectMonorepo } = await import("./aggregator-
|
|
3153
|
+
const { detectMonorepo } = await import("./aggregator-NMUD72J2.js");
|
|
2984
3154
|
const nested = detectMonorepo(process.cwd()).isMonorepo || contexts.length > 1;
|
|
2985
3155
|
const renderContent = (ctx) => {
|
|
2986
3156
|
if (releaseNotesConfig.templates?.path) {
|
|
@@ -3042,7 +3212,7 @@ async function processInput(inputJson, config, dryRun, pipelineOptions) {
|
|
|
3042
3212
|
return runPipeline(input, config, dryRun, pipelineOptions);
|
|
3043
3213
|
}
|
|
3044
3214
|
async function writeMonorepoFiles(contexts, config, dryRun, fileName, refs) {
|
|
3045
|
-
const { detectMonorepo, writeMonorepoChangelogs } = await import("./aggregator-
|
|
3215
|
+
const { detectMonorepo, writeMonorepoChangelogs } = await import("./aggregator-NMUD72J2.js");
|
|
3046
3216
|
const cwd = process.cwd();
|
|
3047
3217
|
const detected = detectMonorepo(cwd);
|
|
3048
3218
|
if (!detected.isMonorepo) return [];
|
|
@@ -3240,10 +3410,10 @@ async function readStdin() {
|
|
|
3240
3410
|
}
|
|
3241
3411
|
function promptSecret(prompt) {
|
|
3242
3412
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
3243
|
-
return new Promise((
|
|
3413
|
+
return new Promise((resolve3) => {
|
|
3244
3414
|
rl.question(prompt, (answer) => {
|
|
3245
3415
|
rl.close();
|
|
3246
|
-
|
|
3416
|
+
resolve3(answer);
|
|
3247
3417
|
});
|
|
3248
3418
|
});
|
|
3249
3419
|
}
|
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-ZGFPTVWY.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-ZGFPTVWY.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.1",
|
|
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",
|
|
@@ -69,10 +69,10 @@
|
|
|
69
69
|
"tsup": "^8.5.1",
|
|
70
70
|
"typescript": "^5.9.3",
|
|
71
71
|
"vitest": "^4.1.10",
|
|
72
|
-
"@releasekit/
|
|
73
|
-
"@releasekit/git": "0.0.0",
|
|
72
|
+
"@releasekit/config": "0.0.0",
|
|
74
73
|
"@releasekit/core": "0.0.0",
|
|
75
|
-
"@releasekit/
|
|
74
|
+
"@releasekit/forge": "0.0.0",
|
|
75
|
+
"@releasekit/git": "0.0.0"
|
|
76
76
|
},
|
|
77
77
|
"engines": {
|
|
78
78
|
"node": ">=22"
|