@releasekit/notes 0.30.2 → 0.31.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.
@@ -3,8 +3,8 @@ import {
3
3
  detectMonorepo,
4
4
  splitByPackage,
5
5
  writeMonorepoChangelogs
6
- } from "./chunk-ECD44YFA.js";
7
- import "./chunk-E6757S4V.js";
6
+ } from "./chunk-UDVQUE2N.js";
7
+ import "./chunk-IC4SXXRM.js";
8
8
  export {
9
9
  aggregateToRoot,
10
10
  detectMonorepo,
@@ -10,7 +10,7 @@ import {
10
10
  success,
11
11
  warn,
12
12
  writeMarkdown
13
- } from "./chunk-E6757S4V.js";
13
+ } from "./chunk-IC4SXXRM.js";
14
14
 
15
15
  // ../config/dist/index.js
16
16
  import * as fs from "fs";
@@ -86,8 +86,8 @@ var VersionGroupSchema = z.object({
86
86
  packages: z.array(z.string()).min(1).describe(
87
87
  "Package patterns (exact names, @scope/*, or globs) whose matched packages form this group. Same matching rules as version.packages."
88
88
  ),
89
- sync: z.enum(["fixed", "linked"]).describe(
90
- "fixed: all members release together at the shared group version. linked: only changed members release, all at the same computed version."
89
+ sync: z.enum(["fixed", "linked", "independent"]).describe(
90
+ "fixed: all members release together at the shared group version. linked: only changed members release, all at the same computed version. independent: only changed members release, each on its own commit-driven version line (no shared version), but the set ships atomically."
91
91
  )
92
92
  });
93
93
  var VersionConfigSchema = z.object({
@@ -111,7 +111,7 @@ var VersionConfigSchema = z.object({
111
111
  "Global lockstep versioning. true is sugar for one implicit fixed group of every package \u2014 it shares the same mechanism as version.groups. Set to false when using version.groups; sync: true alongside groups is treated as the implicit all-packages fixed group taking precedence (a config conflict, warned about at runtime)."
112
112
  ),
113
113
  groups: z.record(z.string(), VersionGroupSchema).optional().describe(
114
- "Named version groups. Each group binds a set of package patterns to a fixed or linked sync mode. fixed: any releasable change in any member releases ALL members at the shared group version (bump(max(member baselines))). linked: only members with releasable changes release, but every releasing member shares the same computed version. Packages not matched by any group version independently. A package may belong to at most one group. Set version.sync to false when using groups."
114
+ "Named version groups. Each group binds a set of package patterns to a fixed, linked, or independent sync mode. fixed: any releasable change in any member releases ALL members at the shared group version (bump(max(member baselines))). linked: only members with releasable changes release, but every releasing member shares the same computed version. independent: only members with releasable changes release, each on its own commit-driven version line (no shared version), but the set is atomic \u2014 targeting any member pulls in the whole group. Packages not matched by any group version independently. A package may belong to at most one group. Set version.sync to false when using groups."
115
115
  ),
116
116
  packages: z.array(z.string()).default([]).describe("Packages to include in versioning"),
117
117
  mainPackage: z.string().optional().describe("Package to use for version determination"),
@@ -138,7 +138,8 @@ var NpmConfigSchema = z.object({
138
138
  access: z.enum(["public", "restricted"]).default("public").describe("Package access level"),
139
139
  registry: z.string().default("https://registry.npmjs.org").describe("NPM registry URL"),
140
140
  copyFiles: z.array(z.string()).default(["LICENSE"]).describe("Files to copy to package before publishing"),
141
- tag: z.string().default("latest").describe("NPM dist tag")
141
+ tag: z.string().default("latest").describe("NPM dist tag"),
142
+ publishOrder: z.array(z.string()).default([]).describe("Explicit publish order for npm packages; empty auto-sorts dependencies first")
142
143
  });
143
144
  var CargoPublishConfigSchema = z.object({
144
145
  enabled: z.boolean().default(false).describe("Enable Cargo publishing"),
@@ -220,7 +221,8 @@ var PublishConfigSchema = z.object({
220
221
  access: "public",
221
222
  registry: "https://registry.npmjs.org",
222
223
  copyFiles: ["LICENSE"],
223
- tag: "latest"
224
+ tag: "latest",
225
+ publishOrder: []
224
226
  }).describe("NPM publishing configuration"),
225
227
  cargo: CargoPublishConfigSchema.default({
226
228
  enabled: false,
@@ -414,7 +416,10 @@ var CILabelsConfigSchema = z.object({
414
416
  ),
415
417
  major: z.string().default("bump:major").describe("Label to force a major bump"),
416
418
  minor: z.string().default("bump:minor").describe("Label to force a minor bump"),
417
- patch: z.string().default("bump:patch").describe("Label to force a patch bump")
419
+ patch: z.string().default("bump:patch").describe("Label to force a patch bump"),
420
+ withPrerequisites: z.string().default("release:with-prerequisites").describe(
421
+ "Label on the standing PR that also releases the changed prerequisites (transitive internal dependencies) of the targeted/scoped packages \u2014 each at its own commit-driven bump. Standing-pr mode only."
422
+ )
418
423
  });
419
424
  var StandingPrConfigSchema = z.object({
420
425
  branch: z.string().default("release/next").describe("Branch name for the standing release PR."),
@@ -456,7 +461,8 @@ var CIConfigSchema = z.object({
456
461
  previewNotes: "release:preview-notes",
457
462
  major: "bump:major",
458
463
  minor: "bump:minor",
459
- patch: "bump:patch"
464
+ patch: "bump:patch",
465
+ withPrerequisites: "release:with-prerequisites"
460
466
  }).describe("PR label names used for release control. Override to match your repository's label conventions."),
461
467
  scopeLabels: z.record(z.string(), z.string()).optional().describe(
462
468
  "Map of scope labels to package patterns. When a PR has a label matching a key, only packages matching the corresponding pattern are released."
@@ -799,9 +805,187 @@ function withContentHashCache(provider, identity, dir = defaultCacheDir()) {
799
805
  };
800
806
  }
801
807
 
802
- // src/llm/context/prFetcher.ts
803
- import { RequestError } from "@octokit/request-error";
808
+ // ../forge/dist/index.js
804
809
  import { Octokit } from "@octokit/rest";
810
+ function forgeErrorStatus(error2) {
811
+ if (error2 && typeof error2 === "object" && "status" in error2) {
812
+ const { status } = error2;
813
+ if (typeof status === "number") return status;
814
+ }
815
+ return void 0;
816
+ }
817
+ var MAX_RELEASE_PAGES = 3;
818
+ function labelNames(labels) {
819
+ return (labels ?? []).map((label) => typeof label === "string" ? label : label.name ?? "");
820
+ }
821
+ function isAlreadyExistsError(error2) {
822
+ if (typeof error2 !== "object" || error2 === null) return false;
823
+ if (error2.status !== 422) return false;
824
+ const errors = error2.response?.data?.errors;
825
+ return Array.isArray(errors) && errors.some((e) => e?.code === "already_exists");
826
+ }
827
+ var GitHubForge = class {
828
+ constructor(octokit, owner, repo) {
829
+ this.octokit = octokit;
830
+ this.owner = owner;
831
+ this.repo = repo;
832
+ }
833
+ get base() {
834
+ return { owner: this.owner, repo: this.repo };
835
+ }
836
+ async listPullRequestsForCommit(commitSha) {
837
+ const { data } = await this.octokit.rest.repos.listPullRequestsAssociatedWithCommit({
838
+ ...this.base,
839
+ commit_sha: commitSha
840
+ });
841
+ return data.map((pr) => ({ number: pr.number, mergedAt: pr.merged_at }));
842
+ }
843
+ async findStandingPR(branch) {
844
+ const { data } = await this.octokit.rest.pulls.list({
845
+ ...this.base,
846
+ head: `${this.owner}:${branch}`,
847
+ state: "open",
848
+ per_page: 1
849
+ });
850
+ const pr = data[0];
851
+ return pr ? { number: pr.number, url: pr.html_url, labels: labelNames(pr.labels).filter(Boolean) } : null;
852
+ }
853
+ async listRecentlyClosedPullRequests(branch, limit) {
854
+ const { data } = await this.octokit.rest.pulls.list({
855
+ ...this.base,
856
+ head: `${this.owner}:${branch}`,
857
+ state: "closed",
858
+ sort: "updated",
859
+ direction: "desc",
860
+ per_page: limit
861
+ });
862
+ return data.map((pr) => ({ number: pr.number, mergedAt: pr.merged_at }));
863
+ }
864
+ async getIssue(issueNumber) {
865
+ const { data } = await this.octokit.rest.issues.get({ ...this.base, issue_number: issueNumber });
866
+ return {
867
+ body: data.body ?? "",
868
+ title: data.title,
869
+ labels: labelNames(data.labels),
870
+ isPullRequest: Boolean(data.pull_request)
871
+ };
872
+ }
873
+ async getPullRequest(prNumber) {
874
+ const { data } = await this.octokit.rest.pulls.get({ ...this.base, pull_number: prNumber });
875
+ return { body: data.body ?? "", labels: labelNames(data.labels) };
876
+ }
877
+ async createPullRequest(pr) {
878
+ const { data } = await this.octokit.rest.pulls.create({ ...this.base, ...pr });
879
+ return { number: data.number, url: data.html_url };
880
+ }
881
+ async updatePullRequest(prNumber, changes) {
882
+ await this.octokit.rest.pulls.update({ ...this.base, pull_number: prNumber, ...changes });
883
+ }
884
+ async mergePullRequest(prNumber, method) {
885
+ await this.octokit.rest.pulls.merge({ ...this.base, pull_number: prNumber, merge_method: method });
886
+ }
887
+ async findComment(prNumber, marker) {
888
+ const iterator = this.octokit.paginate.iterator(this.octokit.rest.issues.listComments, {
889
+ ...this.base,
890
+ issue_number: prNumber,
891
+ per_page: 100
892
+ });
893
+ for await (const response of iterator) {
894
+ for (const comment of response.data) {
895
+ if (comment.body?.startsWith(marker)) return { id: comment.id, body: comment.body };
896
+ }
897
+ }
898
+ return null;
899
+ }
900
+ async createComment(prNumber, body) {
901
+ await this.octokit.rest.issues.createComment({ ...this.base, issue_number: prNumber, body });
902
+ }
903
+ async updateComment(commentId, body) {
904
+ await this.octokit.rest.issues.updateComment({ ...this.base, comment_id: commentId, body });
905
+ }
906
+ async upsertMarkerComment(prNumber, marker, body) {
907
+ const existing = await this.findComment(prNumber, marker);
908
+ if (existing) {
909
+ await this.updateComment(existing.id, body);
910
+ } else {
911
+ await this.createComment(prNumber, body);
912
+ }
913
+ }
914
+ async listLabelNames() {
915
+ const names = [];
916
+ const iterator = this.octokit.paginate.iterator(this.octokit.rest.issues.listLabelsForRepo, {
917
+ ...this.base,
918
+ per_page: 100
919
+ });
920
+ for await (const response of iterator) {
921
+ for (const label of response.data) names.push(label.name);
922
+ }
923
+ return names;
924
+ }
925
+ async createLabel(label) {
926
+ try {
927
+ await this.octokit.rest.issues.createLabel({ ...this.base, ...label });
928
+ return "created";
929
+ } catch (error2) {
930
+ if (isAlreadyExistsError(error2)) return "exists";
931
+ throw error2;
932
+ }
933
+ }
934
+ async setLabels(issueNumber, labels) {
935
+ await this.octokit.rest.issues.setLabels({ ...this.base, issue_number: issueNumber, labels });
936
+ }
937
+ async setCommitStatus(status) {
938
+ await this.octokit.rest.repos.createCommitStatus({ ...this.base, ...status });
939
+ }
940
+ async listReleases() {
941
+ const releases = [];
942
+ for (let page = 1; page <= MAX_RELEASE_PAGES; page++) {
943
+ const { data } = await this.octokit.rest.repos.listReleases({ ...this.base, per_page: 100, page });
944
+ for (const r of data) {
945
+ releases.push({ tagName: r.tag_name, draft: r.draft, prerelease: r.prerelease, body: r.body ?? "" });
946
+ }
947
+ if (data.length < 100) break;
948
+ }
949
+ return releases;
950
+ }
951
+ async createRelease(release) {
952
+ const { data } = await this.octokit.rest.repos.createRelease({
953
+ ...this.base,
954
+ tag_name: release.tagName,
955
+ name: release.name,
956
+ body: release.body,
957
+ draft: release.draft,
958
+ prerelease: release.prerelease,
959
+ generate_release_notes: release.generateReleaseNotes ?? false
960
+ });
961
+ return { id: data.id, url: data.html_url, tagName: data.tag_name };
962
+ }
963
+ async updateRelease(releaseId, release) {
964
+ const { data } = await this.octokit.rest.repos.updateRelease({
965
+ ...this.base,
966
+ release_id: releaseId,
967
+ tag_name: release.tagName,
968
+ name: release.name,
969
+ body: release.body,
970
+ draft: release.draft,
971
+ prerelease: release.prerelease
972
+ });
973
+ return { id: data.id, url: data.html_url, tagName: data.tag_name };
974
+ }
975
+ async getReleaseByTag(tag) {
976
+ try {
977
+ const { data } = await this.octokit.rest.repos.getReleaseByTag({ ...this.base, tag });
978
+ return { id: data.id, url: data.html_url, tagName: data.tag_name };
979
+ } catch {
980
+ return null;
981
+ }
982
+ }
983
+ };
984
+ function createGitHubForge({ token, owner, repo }) {
985
+ return new GitHubForge(new Octokit({ auth: token }), owner, repo);
986
+ }
987
+
988
+ // src/llm/context/prFetcher.ts
805
989
  var BODY_CAP = 2048;
806
990
  function stripHtmlComments(input) {
807
991
  let result = "";
@@ -847,31 +1031,26 @@ function truncateBody(body) {
847
1031
  \u2026`;
848
1032
  }
849
1033
  var FETCH_CONCURRENCY = 5;
850
- async function fetchPullRequestContext(owner, repo, issueNumbers, token, cache) {
851
- const octokit = new Octokit({ auth: token });
1034
+ async function fetchPullRequestContext(owner, repo, issueNumbers, token, cache, forge = createGitHubForge({ token, owner, repo })) {
852
1035
  const needed = issueNumbers.filter((n) => !cache.has(n));
853
1036
  for (let i = 0; i < needed.length; i += FETCH_CONCURRENCY) {
854
1037
  const batch = needed.slice(i, i + FETCH_CONCURRENCY);
855
1038
  await Promise.all(
856
1039
  batch.map(async (number) => {
857
1040
  try {
858
- const { data } = await octokit.rest.issues.get({ owner, repo, issue_number: number });
859
- if (!data.pull_request) {
1041
+ const issue = await forge.getIssue(number);
1042
+ if (!issue.isPullRequest) {
860
1043
  cache.set(number, null);
861
1044
  return;
862
1045
  }
863
- const raw = data.body ?? "";
864
- const body = truncateBody(sanitiseBody(raw));
865
- cache.set(number, { number, title: data.title, body });
1046
+ const body = truncateBody(sanitiseBody(issue.body));
1047
+ cache.set(number, { number, title: issue.title, body });
866
1048
  } catch (error2) {
867
- if (error2 instanceof RequestError) {
868
- if (error2.status === 401 || error2.status === 403) {
869
- warn(`GitHub API auth error fetching PR #${number} (${error2.status}): check GITHUB_TOKEN permissions`);
870
- } else if (error2.status === 404) {
871
- cache.set(number, null);
872
- } else {
873
- debug(`Failed to fetch PR #${number}: ${error2.message}`);
874
- }
1049
+ const status = forgeErrorStatus(error2);
1050
+ if (status === 401 || status === 403) {
1051
+ warn(`GitHub API auth error fetching PR #${number} (${status}): check GITHUB_TOKEN permissions`);
1052
+ } else if (status === 404) {
1053
+ cache.set(number, null);
875
1054
  } else {
876
1055
  debug(`Failed to fetch PR #${number}: ${error2 instanceof Error ? error2.message : String(error2)}`);
877
1056
  }
@@ -914,8 +1093,6 @@ import { createHash as createHash2 } from "crypto";
914
1093
  import * as fs7 from "fs";
915
1094
  import * as os3 from "os";
916
1095
  import * as path7 from "path";
917
- import { RequestError as RequestError2 } from "@octokit/request-error";
918
- import { Octokit as Octokit2 } from "@octokit/rest";
919
1096
 
920
1097
  // src/llm/examples/parser.ts
921
1098
  var LEAD_IN_RE = /^\*\*([^*]+)\*\*:\s*/;
@@ -1008,25 +1185,17 @@ async function fetchExamples(options) {
1008
1185
  debug("No GitHub token available \u2014 skipping examples fetch");
1009
1186
  return [];
1010
1187
  }
1011
- const octokit = new Octokit2({ auth: token });
1188
+ const forge = options.forge ?? createGitHubForge({ token, owner, repo });
1012
1189
  try {
1013
- const allReleases = [];
1014
- for (let page = 1; page <= 3; page++) {
1015
- const { data } = await octokit.rest.repos.listReleases({ owner, repo, per_page: 100, page });
1016
- allReleases.push(...data);
1017
- const totalScoped = allReleases.filter(
1018
- (r) => !r.draft && !r.prerelease && matchesPackageScoped(r.tag_name, packageName)
1019
- ).length;
1020
- if (totalScoped >= count || data.length < 100) break;
1021
- }
1190
+ const allReleases = await forge.listReleases();
1022
1191
  const nonDraft = allReleases.filter((r) => !r.draft && !r.prerelease);
1023
- const packageScoped = nonDraft.filter((r) => matchesPackageScoped(r.tag_name, packageName));
1024
- const matching = (packageScoped.length > 0 ? packageScoped : isMonorepo ? [] : nonDraft.filter((r) => matchesBareVersion(r.tag_name))).slice(0, count);
1192
+ const packageScoped = nonDraft.filter((r) => matchesPackageScoped(r.tagName, packageName));
1193
+ const matching = (packageScoped.length > 0 ? packageScoped : isMonorepo ? [] : nonDraft.filter((r) => matchesBareVersion(r.tagName))).slice(0, count);
1025
1194
  if (matching.length === 0) {
1026
1195
  debug(`No matching releases found for ${packageName}`);
1027
1196
  return [];
1028
1197
  }
1029
- const latestTag = matching[0].tag_name;
1198
+ const latestTag = matching[0].tagName;
1030
1199
  const key = cacheKey(owner, repo, packageName);
1031
1200
  const cached = readCache(key, latestTag, count);
1032
1201
  if (cached) {
@@ -1036,7 +1205,7 @@ async function fetchExamples(options) {
1036
1205
  const examples = [];
1037
1206
  for (const release of matching) {
1038
1207
  if (!release.body) continue;
1039
- const version = release.tag_name.replace(/^.*@/, "").replace(/^v/, "");
1208
+ const version = release.tagName.replace(/^.*@/, "").replace(/^v/, "");
1040
1209
  const example = parseReleaseBodyToExample(release.body, version);
1041
1210
  if (example) examples.push(example);
1042
1211
  }
@@ -1044,8 +1213,9 @@ async function fetchExamples(options) {
1044
1213
  debug(`Fetched ${examples.length} examples for ${packageName}`);
1045
1214
  return examples;
1046
1215
  } catch (error2) {
1047
- if (error2 instanceof RequestError2 && (error2.status === 401 || error2.status === 403)) {
1048
- warn(`GitHub API auth error (${error2.status}) \u2014 skipping examples fetch; check GITHUB_TOKEN permissions`);
1216
+ const status = forgeErrorStatus(error2);
1217
+ if (status === 401 || status === 403) {
1218
+ warn(`GitHub API auth error (${status}) \u2014 skipping examples fetch; check GITHUB_TOKEN permissions`);
1049
1219
  } else {
1050
1220
  debug(`Failed to fetch examples: ${error2 instanceof Error ? error2.message : String(error2)}`);
1051
1221
  }
@@ -2604,7 +2774,7 @@ async function runPipeline(input, config, dryRun, pipelineOptions) {
2604
2774
  const dir = releaseNotesConfig.file.dir;
2605
2775
  info(`Generating release notes \u2192 ${dir}`);
2606
2776
  try {
2607
- const { detectMonorepo } = await import("./aggregator-6TEWRELZ.js");
2777
+ const { detectMonorepo } = await import("./aggregator-KOMXAK6Y.js");
2608
2778
  const nested = detectMonorepo(process.cwd()).isMonorepo || contexts.length > 1;
2609
2779
  const renderContent = (ctx) => {
2610
2780
  if (releaseNotesConfig.templates?.path) {
@@ -2666,7 +2836,7 @@ async function processInput(inputJson, config, dryRun, pipelineOptions) {
2666
2836
  return runPipeline(input, config, dryRun, pipelineOptions);
2667
2837
  }
2668
2838
  async function writeMonorepoFiles(contexts, config, dryRun, fileName) {
2669
- const { detectMonorepo, writeMonorepoChangelogs } = await import("./aggregator-6TEWRELZ.js");
2839
+ const { detectMonorepo, writeMonorepoChangelogs } = await import("./aggregator-KOMXAK6Y.js");
2670
2840
  const cwd = process.cwd();
2671
2841
  const detected = detectMonorepo(cwd);
2672
2842
  if (!detected.isMonorepo) return [];
@@ -5,7 +5,7 @@ import {
5
5
  prependVersion,
6
6
  renderMarkdown,
7
7
  success
8
- } from "./chunk-E6757S4V.js";
8
+ } from "./chunk-IC4SXXRM.js";
9
9
 
10
10
  // src/monorepo/aggregator.ts
11
11
  import * as fs from "fs";
package/dist/cli.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createNotesCommand
4
- } from "./chunk-3FFQJOP4.js";
4
+ } from "./chunk-HN4CXPIU.js";
5
5
  import {
6
6
  readPackageVersion
7
- } from "./chunk-E6757S4V.js";
7
+ } from "./chunk-IC4SXXRM.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-3FFQJOP4.js";
21
+ } from "./chunk-HN4CXPIU.js";
22
22
  import {
23
23
  aggregateToRoot,
24
24
  detectMonorepo,
25
25
  writeMonorepoChangelogs
26
- } from "./chunk-ECD44YFA.js";
26
+ } from "./chunk-UDVQUE2N.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-E6757S4V.js";
34
+ } from "./chunk-IC4SXXRM.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.30.2",
3
+ "version": "0.31.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",
@@ -48,7 +48,6 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@anthropic-ai/sdk": "^0.104.1",
51
- "@octokit/request-error": "^7.1.0",
52
51
  "@octokit/rest": "^22.0.1",
53
52
  "chalk": "^5.6.2",
54
53
  "commander": "^14.0.3",
@@ -71,7 +70,8 @@
71
70
  "typescript": "^5.9.3",
72
71
  "vitest": "^4.1.9",
73
72
  "@releasekit/config": "0.0.0",
74
- "@releasekit/core": "0.0.0"
73
+ "@releasekit/core": "0.0.0",
74
+ "@releasekit/forge": "0.0.0"
75
75
  },
76
76
  "engines": {
77
77
  "node": ">=22"
File without changes