@scalar/release-notes 0.2.10 → 0.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @scalar/release-notes
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#10935](https://github.com/scalar/scalar/pull/10935): feat(release-notes): add a per-product `maxHighlights` option (1 to 20, default 5) that sets how many highlights a generated note may carry. The limit is stated in the default system prompt, enforced when the response is validated, and passed to custom system prompts, and the default output token budget grows with it.
8
+
9
+ ### Patch Changes
10
+
11
+ - [#10900](https://github.com/scalar/scalar/pull/10900): Upgrade the CLI to Commander 15 and require Node.js 22.12.0 or later.
12
+
3
13
  ## 0.2.10
4
14
 
5
15
  ## 0.2.9
package/README.md CHANGED
@@ -17,6 +17,8 @@ Scalar is an open-source API platform for teams who want beautiful developer int
17
17
 
18
18
  ## Install
19
19
 
20
+ Requires Node.js 22.12.0 or later.
21
+
20
22
  ```bash
21
23
  pnpm add -D @scalar/release-notes
22
24
  ```
@@ -68,6 +70,8 @@ export default defineReleaseNotesConfig({
68
70
  changelogPath: 'packages/client/CHANGELOG.md',
69
71
  outputPath: 'packages/client/RELEASE_NOTES.json',
70
72
  markdownPath: 'packages/client/RELEASE_NOTES.md',
73
+ // Most highlights a generated note may carry, from 1 to 20. Defaults to 5.
74
+ maxHighlights: 5,
71
75
  },
72
76
  ],
73
77
  })
@@ -79,6 +83,35 @@ JavaScript, JSON, and TypeScript config files are discovered by name. TypeScript
79
83
 
80
84
  The published JSON Schema for `RELEASE_NOTES.json` is available at `@scalar/release-notes/schema`.
81
85
 
86
+ ## Highlight limit
87
+
88
+ Each generated note carries at most five highlights by default, which suits a small in-app "What's new" modal. Set `maxHighlights` on a product to allow up to 20 when the notes are shown somewhere with more room, such as a changelog page:
89
+
90
+ ```js
91
+ export default defineReleaseNotesConfig({
92
+ products: [
93
+ {
94
+ slug: 'client',
95
+ // ...
96
+ maxHighlights: 10,
97
+ },
98
+ ],
99
+ })
100
+ ```
101
+
102
+ The limit is stated in the default system prompt and enforced when the response is validated, and the default output token budget grows with it so a longer note is not cut off. A custom `prompts.systemPrompt` receives the limit as `maxHighlights`. If it builds on the default prompt, forward it so the model is told the same limit its response is checked against:
103
+
104
+ ```js
105
+ import { buildDefaultSystemPrompt, defineReleaseNotesConfig } from '@scalar/release-notes'
106
+
107
+ export default defineReleaseNotesConfig({
108
+ prompts: {
109
+ systemPrompt: ({ product, ...context }) =>
110
+ [buildDefaultSystemPrompt(product, context), '', 'House style: ...'].join('\n'),
111
+ },
112
+ })
113
+ ```
114
+
82
115
  ## Pull request context
83
116
 
84
117
  When `github.repo` is configured, every referenced pull request (`#123`) is fetched from the GitHub REST API and its title and description are fed to the provider as extra context. Turn it off to skip those calls and generate from the CHANGELOG alone:
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,KAAK,EAAuB,kBAAkB,EAAuB,MAAM,iBAAiB,CAAA;AA+DnG,eAAO,MAAM,kCAAkC,GAAI,aAAY,kBAAuB,KAAG,OAiFxF,CAAA;AAED,eAAO,MAAM,qBAAqB,SAAuC,CAAA"}
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,KAAK,EAAuB,kBAAkB,EAAuB,MAAM,iBAAiB,CAAA;AAgEnG,eAAO,MAAM,kCAAkC,GAAI,aAAY,kBAAuB,KAAG,OAyFxF,CAAA;AAED,eAAO,MAAM,qBAAqB,SAAuC,CAAA"}
@@ -2,6 +2,7 @@ import { Command } from 'commander';
2
2
  import { hasBuiltInProviderApiKey, readReleaseNotesConfig } from '../config/read-config.js';
3
3
  import { getChangedPathsForReleaseFiltering } from '../core/detect-versioned-changelog-paths.js';
4
4
  import { runReleaseNotesGeneratorForProduct } from '../core/run-release-notes-generator.js';
5
+ import { assertValidMaxHighlights } from '../types.js';
5
6
  const createAdHocProduct = (options, fallbackDescription) => {
6
7
  if (!options.package || !options.changelog || !options.output) {
7
8
  throw new Error('Pass --all or provide --package, --changelog, and --output.');
@@ -78,6 +79,13 @@ export const createReleaseNotesGeneratorCommand = (baseConfig = {}) => {
78
79
  if (products.length === 0) {
79
80
  throw new Error(options.product ? `No configured product found for slug ${options.product}.` : 'No products configured.');
80
81
  }
82
+ // Check every product before generating any, so a typo in one product's limit does not
83
+ // leave a multi-product run half-written after the earlier products already called the provider.
84
+ for (const product of products) {
85
+ if (product.maxHighlights !== undefined) {
86
+ assertValidMaxHighlights(product.maxHighlights);
87
+ }
88
+ }
81
89
  const changedPaths = options.all && !options.force
82
90
  ? await getChangedPathsForReleaseFiltering(config.github.baseBranch ?? 'main')
83
91
  : null;
@@ -18,6 +18,11 @@ export type ReleaseNotesProduct = {
18
18
  markdownPath?: string;
19
19
  /** Dependency CHANGELOGs folded into the parent release note. */
20
20
  dependencyChangelogPaths?: readonly string[];
21
+ /**
22
+ * The most highlights a generated note for this product may carry, from 1 to 20. Defaults to 5.
23
+ * Raise it when the notes are shown somewhere with room for a longer list, such as a changelog page.
24
+ */
25
+ maxHighlights?: number;
21
26
  };
22
27
  export type ProductPromptContext = {
23
28
  /** User-facing product name. */
@@ -32,6 +37,11 @@ export type PromptContext = {
32
37
  * default system prompt reacts to, so a custom prompt can describe the same inputs.
33
38
  */
34
39
  includePullRequestContext: boolean;
40
+ /**
41
+ * The most highlights the response may carry. Responses with more fail validation, so a custom
42
+ * prompt should state this limit, for example by passing it to `buildDefaultSystemPrompt`.
43
+ */
44
+ maxHighlights: number;
35
45
  };
36
46
  export type PromptOptions = {
37
47
  /** Fallback description used when the CLI creates an ad-hoc product. */
@@ -1 +1 @@
1
- {"version":3,"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BAA4B;IAC5B,QAAQ,EAAE,SAAS,mBAAmB,EAAE,CAAA;IACxC,0DAA0D;IAC1D,MAAM,EAAE,aAAa,CAAA;IACrB,kCAAkC;IAClC,OAAO,EAAE,aAAa,CAAA;CACvB,CAAA"}
@@ -21,16 +21,29 @@ export type GenerateReleaseNoteOptions = {
21
21
  prompts?: PromptOptions;
22
22
  dependencyChangelogs?: readonly DependencyChangelog[];
23
23
  pullRequests?: ReadonlyMap<number, PullRequestSummary>;
24
+ /**
25
+ * The most highlights the generated note may carry, from 1 to 20. Defaults to 5. Enforced by the
26
+ * response schema and stated in the default system prompt.
27
+ */
28
+ maxHighlights?: number;
29
+ /** Output token budget for each provider call. Defaults to a budget sized for `maxHighlights`. */
24
30
  maxOutputTokens?: number;
25
31
  signal?: AbortSignal;
26
32
  };
33
+ /**
34
+ * Build the system prompt the generator uses when no custom prompt is configured. A custom prompt
35
+ * that builds on this one should forward the `maxHighlights` it receives in its context, so the
36
+ * limit the model is told matches the limit its response is validated against.
37
+ */
27
38
  export declare const buildDefaultSystemPrompt: (product: ProductPromptContext, options?: {
28
39
  includePullRequestContext?: boolean;
40
+ maxHighlights?: number;
29
41
  }) => string;
30
42
  export declare const buildSystemPrompt: (options: {
31
43
  product: ProductPromptContext;
32
44
  prompts?: PromptOptions;
33
45
  includePullRequestContext?: boolean;
46
+ maxHighlights?: number;
34
47
  }) => string;
35
48
  export declare const buildPullRequestContext: (pullRequests: ReadonlyMap<number, PullRequestSummary> | undefined) => string;
36
49
  export declare const buildDependencyChangelogContext: (dependencyChangelogs: readonly DependencyChangelog[] | undefined) => string;
@@ -1 +1 @@
1
- {"version":3,"file":"generate-release-note.d.ts","sourceRoot":"","sources":["../../src/core/generate-release-note.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAChG,OAAO,EAAE,KAAK,WAAW,EAAqD,MAAM,UAAU,CAAA;AAC9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AAED,eAAO,MAAM,eAAe,GAC1B,SAAS,IAAI,CACX,0BAA0B,EAC1B,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,kBAAkB,GAAG,YAAY,GAAG,cAAc,GAAG,sBAAsB,CACjH,KACA,MAyBF,CAAA;AAgED;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAAU,SAAS,0BAA0B,KAAG,OAAO,CAAC,WAAW,CA0ClG,CAAA"}
1
+ {"version":3,"file":"generate-release-note.d.ts","sourceRoot":"","sources":["../../src/core/generate-release-note.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAChG,OAAO,EAEL,KAAK,WAAW,EAGjB,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAsB/D;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,gBAAgB,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,oBAAoB,CAAA;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,oBAAoB,CAAA;IAC9B,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,oBAAoB,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAA;IACrD,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;IACtD;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,kGAAkG;IAClG,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACnC,SAAS,oBAAoB,EAC7B,UAAS;IAAE,yBAAyB,CAAC,EAAE,OAAO,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAO,KAC5E,MAoCF,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,SAAS;IACzC,OAAO,EAAE,oBAAoB,CAAA;IAC7B,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,yBAAyB,CAAC,EAAE,OAAO,CAAA;IACnC,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,KAAG,MAQH,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAI,cAAc,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,SAAS,KAAG,MAU3G,CAAA;AAED,eAAO,MAAM,+BAA+B,GAC1C,sBAAsB,SAAS,mBAAmB,EAAE,GAAG,SAAS,KAC/D,MAkBF,CAAA;AAED,eAAO,MAAM,eAAe,GAC1B,SAAS,IAAI,CACX,0BAA0B,EAC1B,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,kBAAkB,GAAG,YAAY,GAAG,cAAc,GAAG,sBAAsB,CACjH,KACA,MAyBF,CAAA;AAmED;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAAU,SAAS,0BAA0B,KAAG,OAAO,CAAC,WAAW,CAkDlG,CAAA"}
@@ -1,5 +1,12 @@
1
- import { aiReleaseNoteSchema, buildReleaseNoteFromAiOutput } from '../types.js';
1
+ import { DEFAULT_MAX_HIGHLIGHTS, buildReleaseNoteFromAiOutput, createAiReleaseNoteSchema, } from '../types.js';
2
2
  const DEFAULT_MAX_OUTPUT_TOKENS = 1024;
3
+ /**
4
+ * Pick an output token budget that leaves room for every highlight the schema allows. A note with
5
+ * the full number of highlights, each near the 280-character limit, plus the title and description,
6
+ * would otherwise be cut off mid-JSON for larger limits, and a truncated response can never pass
7
+ * validation however many times it is retried. The default limit keeps the original 1024 budget.
8
+ */
9
+ const getDefaultMaxOutputTokens = (maxHighlights) => Math.max(DEFAULT_MAX_OUTPUT_TOKENS, 256 + maxHighlights * 128);
3
10
  /**
4
11
  * How many times to ask the provider for a note before giving up. The output
5
12
  * is non-deterministic, so a single run occasionally trips a schema limit
@@ -8,7 +15,13 @@ const DEFAULT_MAX_OUTPUT_TOKENS = 1024;
8
15
  * validation error back to the provider and let it correct itself.
9
16
  */
10
17
  const MAX_ATTEMPTS = 3;
18
+ /**
19
+ * Build the system prompt the generator uses when no custom prompt is configured. A custom prompt
20
+ * that builds on this one should forward the `maxHighlights` it receives in its context, so the
21
+ * limit the model is told matches the limit its response is validated against.
22
+ */
11
23
  export const buildDefaultSystemPrompt = (product, options = {}) => {
24
+ const maxHighlights = options.maxHighlights ?? DEFAULT_MAX_HIGHLIGHTS;
12
25
  const inputs = [
13
26
  'Inputs:',
14
27
  '- The CHANGELOG section is the source of truth for what changed in the released package.',
@@ -33,17 +46,18 @@ export const buildDefaultSystemPrompt = (product, options = {}) => {
33
46
  '',
34
47
  'Output format:',
35
48
  '- You MUST respond with a single JSON object and nothing else. No markdown fences, no commentary.',
36
- '- Keys only: version, title, description (optional), highlights (optional array, max 5). No other keys.',
49
+ `- Keys only: version, title, description (optional), highlights (optional array, max ${maxHighlights}). No other keys.`,
37
50
  '- version must match the package version from the user message (semver string).',
38
51
  '- title is one short sentence (max 120 characters).',
39
52
  '- description is one paragraph that sets context (max 500 characters). Omit it when there is only one thing to say.',
40
- '- highlights are single-sentence bullet points (at most 5, each max 280 characters). Keep each one short and split a long highlight into two rather than letting it run over. Omit the array when there are fewer than two interesting changes.',
53
+ `- highlights are single-sentence bullet points (at most ${maxHighlights}, each max 280 characters). Keep each one short and split a long highlight into two rather than letting it run over. Omit the array when there are fewer than two interesting changes.`,
41
54
  ].join('\n');
42
55
  };
43
56
  export const buildSystemPrompt = (options) => {
44
57
  const includePullRequestContext = options.includePullRequestContext !== false;
45
- return (options.prompts?.systemPrompt?.({ product: options.product, includePullRequestContext }) ??
46
- buildDefaultSystemPrompt(options.product, { includePullRequestContext }));
58
+ const maxHighlights = options.maxHighlights ?? DEFAULT_MAX_HIGHLIGHTS;
59
+ return (options.prompts?.systemPrompt?.({ product: options.product, includePullRequestContext, maxHighlights }) ??
60
+ buildDefaultSystemPrompt(options.product, { includePullRequestContext, maxHighlights }));
47
61
  };
48
62
  export const buildPullRequestContext = (pullRequests) => {
49
63
  if (!pullRequests || pullRequests.size === 0) {
@@ -118,7 +132,7 @@ const parseProviderJson = (payload) => {
118
132
  * send back to the provider on the next attempt and the verbose `fatalError`
119
133
  * to surface if we run out of attempts.
120
134
  */
121
- const validateProviderResponse = (raw) => {
135
+ const validateProviderResponse = (raw, schema) => {
122
136
  let parsed;
123
137
  try {
124
138
  parsed = parseProviderJson(raw);
@@ -137,7 +151,7 @@ const validateProviderResponse = (raw) => {
137
151
  fatalError: new Error(`AI provider returned JSON that is not an object.\nPayload:\n${JSON.stringify(parsed, null, 2)}`),
138
152
  };
139
153
  }
140
- const aiResult = aiReleaseNoteSchema.safeParse(parsed);
154
+ const aiResult = schema.safeParse(parsed);
141
155
  if (!aiResult.success) {
142
156
  return {
143
157
  ok: false,
@@ -161,8 +175,16 @@ export const generateReleaseNote = async (options) => {
161
175
  displayName: options.packageName,
162
176
  description: options.prompts?.productDescriptionFallback ?? 'an open-source package',
163
177
  };
178
+ const maxHighlights = options.maxHighlights ?? DEFAULT_MAX_HIGHLIGHTS;
179
+ // Built before any provider call, so an out-of-range limit fails fast instead of after a paid request.
180
+ const schema = createAiReleaseNoteSchema(maxHighlights);
164
181
  const includePullRequestContext = (options.pullRequests?.size ?? 0) > 0;
165
- const systemPrompt = buildSystemPrompt({ product, prompts: options.prompts, includePullRequestContext });
182
+ const systemPrompt = buildSystemPrompt({
183
+ product,
184
+ prompts: options.prompts,
185
+ includePullRequestContext,
186
+ maxHighlights,
187
+ });
166
188
  const baseUserPrompt = buildUserPrompt(options);
167
189
  let userPrompt = baseUserPrompt;
168
190
  for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
@@ -170,11 +192,11 @@ export const generateReleaseNote = async (options) => {
170
192
  model: options.model ?? options.provider.defaultModel,
171
193
  systemPrompt,
172
194
  userPrompt,
173
- schema: aiReleaseNoteSchema,
174
- maxOutputTokens: options.maxOutputTokens ?? DEFAULT_MAX_OUTPUT_TOKENS,
195
+ schema,
196
+ maxOutputTokens: options.maxOutputTokens ?? getDefaultMaxOutputTokens(maxHighlights),
175
197
  signal: options.signal,
176
198
  });
177
- const result = validateProviderResponse(raw);
199
+ const result = validateProviderResponse(raw, schema);
178
200
  if (result.ok) {
179
201
  return buildReleaseNoteFromAiOutput(result.data, {
180
202
  version: options.version,
@@ -1 +1 @@
1
- {"version":3,"file":"run-release-notes-generator.d.ts","sourceRoot":"","sources":["../../src/core/run-release-notes-generator.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAe9G,MAAM,MAAM,+BAA+B,GAAG;IAC5C,OAAO,EAAE,mBAAmB,CAAA;IAC5B,QAAQ,EAAE,oBAAoB,CAAA;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAAA;IACzC,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,EAAE,OAAO,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAoDD,eAAO,MAAM,iBAAiB,GAAI,SAAS;IACzC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE,MAAM,CAAA;CAChB,KAAG,MAMH,CAAA;AAED,eAAO,MAAM,kCAAkC,GAC7C,SAAS,+BAA+B,KACvC,OAAO,CAAC,8BAA8B,CAsHxC,CAAA"}
1
+ {"version":3,"file":"run-release-notes-generator.d.ts","sourceRoot":"","sources":["../../src/core/run-release-notes-generator.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAe9G,MAAM,MAAM,+BAA+B,GAAG;IAC5C,OAAO,EAAE,mBAAmB,CAAA;IAC5B,QAAQ,EAAE,oBAAoB,CAAA;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAAA;IACzC,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,EAAE,OAAO,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAoDD,eAAO,MAAM,iBAAiB,GAAI,SAAS;IACzC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE,MAAM,CAAA;CAChB,KAAG,MAMH,CAAA;AAED,eAAO,MAAM,kCAAkC,GAC7C,SAAS,+BAA+B,KACvC,OAAO,CAAC,8BAA8B,CAuHxC,CAAA"}
@@ -129,6 +129,7 @@ export const runReleaseNotesGeneratorForProduct = async (options) => {
129
129
  pullRequests,
130
130
  dependencyChangelogs,
131
131
  prompts: options.prompts,
132
+ maxHighlights: product.maxHighlights,
132
133
  product: {
133
134
  displayName: product.displayName,
134
135
  description: product.description,
package/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@ export { buildChangelogUrl, runReleaseNotesGeneratorForProduct } from './core/ru
14
14
  export { createAnthropicProvider } from './providers/anthropic.js';
15
15
  export { createOpenAIProvider } from './providers/openai.js';
16
16
  export type { ReleaseNote, ReleaseNoteContentBlock } from './types.js';
17
- export { aiReleaseNoteSchema, buildReleaseNoteFromAiOutput, releaseNoteSchema, releaseNotesFileSchema, } from './types.js';
17
+ export { DEFAULT_MAX_HIGHLIGHTS, MAX_HIGHLIGHTS_LIMIT, aiReleaseNoteSchema, buildReleaseNoteFromAiOutput, createAiReleaseNoteSchema, releaseNoteSchema, releaseNotesFileSchema, } from './types.js';
18
18
  export { mergeReleaseNotes, readReleaseNotesJsonFile, writeReleaseNoteJson } from './writers/write-release-notes-json.js';
19
19
  export { writeReleaseNotesMarkdown } from './writers/write-release-notes-markdown.js';
20
20
  export type { ReleaseNotesJsonSchemaMetadata } from './writers/write-release-notes-schema.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC/F,OAAO,EAAE,qCAAqC,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AAC1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,EAAE,qBAAqB,EAAE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D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACzD,YAAY,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AACnE,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,4BAA4B,EAC5B,yBAAyB,EACzB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AACtH,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAA;AAClF,YAAY,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAA;AAC1F,OAAO,EACL,+BAA+B,EAC/B,iCAAiC,EACjC,kCAAkC,EAClC,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,sCAAsC,CAAA"}
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ export { buildDefaultSystemPrompt, buildDependencyChangelogContext, buildPullReq
9
9
  export { buildChangelogUrl, runReleaseNotesGeneratorForProduct } from './core/run-release-notes-generator.js';
10
10
  export { createAnthropicProvider } from './providers/anthropic.js';
11
11
  export { createOpenAIProvider } from './providers/openai.js';
12
- export { aiReleaseNoteSchema, buildReleaseNoteFromAiOutput, releaseNoteSchema, releaseNotesFileSchema, } from './types.js';
12
+ export { DEFAULT_MAX_HIGHLIGHTS, MAX_HIGHLIGHTS_LIMIT, aiReleaseNoteSchema, buildReleaseNoteFromAiOutput, createAiReleaseNoteSchema, releaseNoteSchema, releaseNotesFileSchema, } from './types.js';
13
13
  export { mergeReleaseNotes, readReleaseNotesJsonFile, writeReleaseNoteJson } from './writers/write-release-notes-json.js';
14
14
  export { writeReleaseNotesMarkdown } from './writers/write-release-notes-markdown.js';
15
15
  export { DEFAULT_RELEASE_NOTES_SCHEMA_ID, DEFAULT_RELEASE_NOTES_SCHEMA_PATH, DEFAULT_RELEASE_NOTES_SCHEMA_TITLE, buildReleaseNotesJsonSchema, writeReleaseNotesJsonSchema, } from './writers/write-release-notes-schema.js';
package/dist/types.d.ts CHANGED
@@ -1,4 +1,16 @@
1
1
  import { z } from 'zod';
2
+ declare const versionSchema: z.ZodString;
3
+ declare const titleSchema: z.ZodString;
4
+ declare const descriptionSchema: z.ZodString;
5
+ declare const highlightItemSchema: z.ZodString;
6
+ /** Highlights a generated note may carry when the product does not set `maxHighlights`. */
7
+ export declare const DEFAULT_MAX_HIGHLIGHTS = 5;
8
+ /**
9
+ * The most highlights a generated note may carry. Highlights land in a stored `list` block, and
10
+ * the published `RELEASE_NOTES.json` schema caps list blocks at this many items, so a larger limit
11
+ * would produce notes that validate here and then fail when they are written.
12
+ */
13
+ export declare const MAX_HIGHLIGHTS_LIMIT = 20;
2
14
  declare const contentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3
15
  type: z.ZodLiteral<"paragraph">;
4
16
  text: z.ZodString;
@@ -32,13 +44,30 @@ declare const contentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
32
44
  label: z.ZodString;
33
45
  }, z.core.$strip>], "type">;
34
46
  /**
35
- * JSON object returned by an AI provider before trusted release metadata is merged in.
47
+ * Check a highlight limit before it reaches the schema, so a bad config value fails with a message
48
+ * that names the setting instead of a confusing validation error on every generated note.
49
+ */
50
+ export declare const assertValidMaxHighlights: (maxHighlights: number) => void;
51
+ /**
52
+ * Build the schema for the JSON object an AI provider returns, before trusted release metadata is
53
+ * merged in. The highlight limit is a parameter because products render highlights in different
54
+ * places: a small in-app modal wants a short list, while a changelog page can take a longer one.
55
+ */
56
+ export declare const createAiReleaseNoteSchema: (maxHighlights?: number) => z.ZodObject<{
57
+ version: typeof versionSchema;
58
+ title: typeof titleSchema;
59
+ description: z.ZodOptional<typeof descriptionSchema>;
60
+ highlights: z.ZodOptional<z.ZodArray<typeof highlightItemSchema>>;
61
+ }, z.core.$strict>;
62
+ /**
63
+ * JSON object returned by an AI provider before trusted release metadata is merged in, with the
64
+ * default highlight limit. Use `createAiReleaseNoteSchema` for a different limit.
36
65
  */
37
66
  export declare const aiReleaseNoteSchema: z.ZodObject<{
38
- version: z.ZodString;
39
- title: z.ZodString;
40
- description: z.ZodOptional<z.ZodString>;
41
- highlights: z.ZodOptional<z.ZodArray<z.ZodString>>;
67
+ version: typeof versionSchema;
68
+ title: typeof titleSchema;
69
+ description: z.ZodOptional<typeof descriptionSchema>;
70
+ highlights: z.ZodOptional<z.ZodArray<typeof highlightItemSchema>>;
42
71
  }, z.core.$strict>;
43
72
  export declare const releaseNoteSchema: z.ZodObject<{
44
73
  version: z.ZodString;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AA8HvB,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAS2F,CAAA;AAEnH;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;kBAQ4D,CAAA;AAE5F,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAae,CAAA;AAE7C,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAEmC,CAAA;AAEtE,KAAK,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAExD,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AACxE,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAE3D;;GAEG;AACH,eAAO,MAAM,4BAA4B,GACvC,IAAI,aAAa,EACjB,SAAS;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,KACvD,WAmBF,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ae,CAAA;AAE7C,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAEmC,CAAA;AAEtE,KAAK,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAExD,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AACxE,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAE3D;;GAEG;AACH,eAAO,MAAM,4BAA4B,GACvC,IAAI,aAAa,EACjB,SAAS;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,KACvD,WAmBF,CAAA"}
package/dist/types.js CHANGED
@@ -18,10 +18,14 @@ const highlightItemSchema = z
18
18
  .min(1)
19
19
  .max(280)
20
20
  .describe('A single-sentence highlight rendered as a bullet point.');
21
- const aiHighlightsSchema = z
22
- .array(highlightItemSchema)
23
- .max(5)
24
- .describe('Optional bullet list of single-sentence highlights (at most five items for generated notes).');
21
+ /** Highlights a generated note may carry when the product does not set `maxHighlights`. */
22
+ export const DEFAULT_MAX_HIGHLIGHTS = 5;
23
+ /**
24
+ * The most highlights a generated note may carry. Highlights land in a stored `list` block, and
25
+ * the published `RELEASE_NOTES.json` schema caps list blocks at this many items, so a larger limit
26
+ * would produce notes that validate here and then fail when they are written.
27
+ */
28
+ export const MAX_HIGHLIGHTS_LIMIT = 20;
25
29
  const paragraphBlockSchema = z
26
30
  .object({
27
31
  type: z.literal('paragraph').describe('Discriminator for the paragraph block type.'),
@@ -48,7 +52,7 @@ const listBlockSchema = z
48
52
  items: z
49
53
  .array(z.string().min(1).max(280).describe('A single-sentence list item.'))
50
54
  .min(1)
51
- .max(20)
55
+ .max(MAX_HIGHLIGHTS_LIMIT)
52
56
  .describe('Bullet items rendered as a list. Keep each item to a single sentence.'),
53
57
  ordered: z.boolean().optional().describe('Render as a numbered list when `true`. Defaults to a bullet list.'),
54
58
  })
@@ -116,17 +120,40 @@ const contentBlockSchema = z
116
120
  ])
117
121
  .describe('Rich content block rendered inside a release note (paragraph, heading, list, image, video, or href).');
118
122
  /**
119
- * JSON object returned by an AI provider before trusted release metadata is merged in.
123
+ * Check a highlight limit before it reaches the schema, so a bad config value fails with a message
124
+ * that names the setting instead of a confusing validation error on every generated note.
120
125
  */
121
- export const aiReleaseNoteSchema = z
122
- .object({
123
- version: versionSchema,
124
- title: titleSchema,
125
- description: descriptionSchema.optional(),
126
- highlights: aiHighlightsSchema.optional(),
127
- })
128
- .strict()
129
- .describe('Minimal AI-generated release note payload before merge with trusted metadata.');
126
+ export const assertValidMaxHighlights = (maxHighlights) => {
127
+ if (!Number.isInteger(maxHighlights) || maxHighlights < 1 || maxHighlights > MAX_HIGHLIGHTS_LIMIT) {
128
+ throw new Error(`maxHighlights must be an integer between 1 and ${MAX_HIGHLIGHTS_LIMIT}, received ${String(maxHighlights)}.`);
129
+ }
130
+ };
131
+ /**
132
+ * Build the schema for the JSON object an AI provider returns, before trusted release metadata is
133
+ * merged in. The highlight limit is a parameter because products render highlights in different
134
+ * places: a small in-app modal wants a short list, while a changelog page can take a longer one.
135
+ */
136
+ export const createAiReleaseNoteSchema = (maxHighlights = DEFAULT_MAX_HIGHLIGHTS) => {
137
+ assertValidMaxHighlights(maxHighlights);
138
+ return z
139
+ .object({
140
+ version: versionSchema,
141
+ title: titleSchema,
142
+ description: descriptionSchema.optional(),
143
+ highlights: z
144
+ .array(highlightItemSchema)
145
+ .max(maxHighlights)
146
+ .optional()
147
+ .describe(`Optional bullet list of single-sentence highlights (at most ${maxHighlights} items).`),
148
+ })
149
+ .strict()
150
+ .describe('Minimal AI-generated release note payload before merge with trusted metadata.');
151
+ };
152
+ /**
153
+ * JSON object returned by an AI provider before trusted release metadata is merged in, with the
154
+ * default highlight limit. Use `createAiReleaseNoteSchema` for a different limit.
155
+ */
156
+ export const aiReleaseNoteSchema = createAiReleaseNoteSchema();
130
157
  export const releaseNoteSchema = z
131
158
  .object({
132
159
  version: versionSchema,
package/package.json CHANGED
@@ -16,9 +16,9 @@
16
16
  "changesets",
17
17
  "ai"
18
18
  ],
19
- "version": "0.2.10",
19
+ "version": "0.3.0",
20
20
  "engines": {
21
- "node": ">=22"
21
+ "node": ">=22.12.0"
22
22
  },
23
23
  "type": "module",
24
24
  "main": "dist/index.js",
@@ -48,14 +48,14 @@
48
48
  },
49
49
  "sideEffects": false,
50
50
  "dependencies": {
51
- "@scalar/helpers": "0.17.0",
52
- "commander": "14.0.3",
51
+ "@scalar/helpers": "0.17.1",
52
+ "commander": "15.0.0",
53
53
  "zod": "^4.6.7"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/node": "^24.19.2",
57
57
  "tsx": "4.23.15",
58
- "vitest": "4.1.12"
58
+ "vitest": "5.0.5"
59
59
  },
60
60
  "scripts": {
61
61
  "build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",