@scalar/release-notes 0.1.9 → 0.2.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,29 @@
1
1
  # @scalar/release-notes
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#10129](https://github.com/scalar/scalar/pull/10129): feat: select a built-in provider by name in the config and add a pull request context switch
8
+
9
+ `provider` now accepts `'anthropic'` or `'openai'` in addition to a custom provider object, and `model` and `apiKeyEnv` are config fields, so a config file (including `release-notes.config.json`) can pick a built-in provider without importing a factory. A `provider` value that is neither a known name nor a provider object now throws a clear error instead of failing later with `provider.generateJson is not a function`.
10
+
11
+ A config-level `model` now reaches the provider, custom providers included, where previously only `--model` did. Set `github.pullRequestContext: false` (or pass `--no-pull-request-context`) to skip fetching pull request titles and descriptions and generate from the CHANGELOG alone. The default system prompt no longer describes a pull request context block when none was fetched.
12
+
13
+ `model` and `apiKeyEnv` only apply to the provider their own layer of configuration selects, so settings written for one provider are never handed to another. Selecting a different provider with `--provider`, or in a config file that overrides a base config, drops the model id and API key environment variable that came with the provider it replaced. A config that names no provider counts as selecting the default one.
14
+
15
+ The exported `PromptContext` handed to a `prompts.systemPrompt` callback gained an `includePullRequestContext` field, so a custom prompt can react to the same signal the default prompt does. `PromptContext`, the `ProviderOption` type, and the `hasBuiltInProviderApiKey` helper (the check the CLI uses to skip gracefully when a key is missing) are now exported.
16
+
17
+ The exported `ResolvedReleaseNotesConfig` type changed shape: `provider` is now required and always a constructed provider, and `builtInProviderName` was added. Because provider resolution now happens while the config is read, `sync-release-notes-markdown` validates the `provider` field too, even though it does no AI work.
18
+
19
+ ### Patch Changes
20
+
21
+ - [#10140](https://github.com/scalar/scalar/pull/10140): Replace redundant type assertions with compiler-checked annotations, typed accumulators, and existing guards across helpers, API conversion, request handling, and schema rendering.
22
+
23
+ Narrow DOM elements and caught errors before accessing their properties. Correct header lookup to include missing values and handle them during PowerShell snippet generation.
24
+
25
+ Validate release-note provider responses, represent unresolved references and absent groups in helper return types, and require narrowing merged object values. Preserve AsyncAPI broker credentials separately from HTTP authentication schemes.
26
+
3
27
  ## 0.1.9
4
28
 
5
29
  ## 0.1.8
package/README.md CHANGED
@@ -43,17 +43,21 @@ scalar-release-notes \
43
43
  Create `release-notes.config.mjs`:
44
44
 
45
45
  ```js
46
- import { createAnthropicProvider, defineReleaseNotesConfig } from '@scalar/release-notes'
46
+ import { defineReleaseNotesConfig } from '@scalar/release-notes'
47
47
 
48
48
  export default defineReleaseNotesConfig({
49
- provider: createAnthropicProvider({
50
- apiKey: process.env.ANTHROPIC_API_KEY,
51
- model: 'claude-sonnet-4-5',
52
- }),
49
+ // A built-in provider name: 'anthropic' (default) or 'openai'.
50
+ provider: 'anthropic',
51
+ model: 'claude-sonnet-4-5',
52
+ // Environment variable holding the provider API key.
53
+ // Defaults to ANTHROPIC_API_KEY or OPENAI_API_KEY.
54
+ apiKeyEnv: 'ANTHROPIC_API_KEY',
53
55
  github: {
54
56
  repo: 'owner/repo',
55
57
  token: process.env.GITHUB_TOKEN,
56
58
  baseBranch: 'main',
59
+ // Set to false to generate from the CHANGELOG alone, with no GitHub API calls.
60
+ pullRequestContext: true,
57
61
  },
58
62
  products: [
59
63
  {
@@ -69,37 +73,70 @@ export default defineReleaseNotesConfig({
69
73
  })
70
74
  ```
71
75
 
76
+ For full control over how a provider is created, pass a provider object instead of a name. See [Providers](#providers).
77
+
72
78
  JavaScript, JSON, and TypeScript config files are discovered by name. TypeScript config loading depends on your runtime being able to import `.ts` files, for example through `tsx`.
73
79
 
74
80
  The published JSON Schema for `RELEASE_NOTES.json` is available at `@scalar/release-notes/schema`.
75
81
 
82
+ ## Pull request context
83
+
84
+ 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:
85
+
86
+ ```js
87
+ export default defineReleaseNotesConfig({
88
+ github: {
89
+ repo: 'owner/repo',
90
+ pullRequestContext: false,
91
+ },
92
+ })
93
+ ```
94
+
95
+ Or per run:
96
+
97
+ ```bash
98
+ scalar-release-notes --all --no-pull-request-context
99
+ ```
100
+
101
+ The flag only turns pull request context off. There is no counterpart that turns it back on for a config that set `pullRequestContext: false`.
102
+
76
103
  ## Providers
77
104
 
105
+ A built-in provider is selected by name (`'anthropic'` or `'openai'`) in the config or with `--provider`, and is constructed with its defaults. Pass a provider object instead when you need control over how it is built.
106
+
107
+ `model` and `apiKeyEnv` belong to the provider their own config selects, so switching provider drops them. Passing `--provider openai` ignores the `model` and `apiKeyEnv` of a config that selects Anthropic, whether it names Anthropic or relies on the default. Pass `--model` and `--api-key-env` alongside it to set them for the new provider.
108
+
78
109
  Use Anthropic:
79
110
 
80
111
  ```js
81
- import { createAnthropicProvider } from '@scalar/release-notes'
112
+ import { createAnthropicProvider, defineReleaseNotesConfig } from '@scalar/release-notes'
82
113
 
83
- createAnthropicProvider({
84
- apiKey: process.env.ANTHROPIC_API_KEY,
85
- model: 'claude-sonnet-4-5',
114
+ export default defineReleaseNotesConfig({
115
+ provider: createAnthropicProvider({
116
+ apiKey: process.env.ANTHROPIC_API_KEY,
117
+ model: 'claude-sonnet-4-5',
118
+ }),
86
119
  })
87
120
  ```
88
121
 
89
122
  Use OpenAI:
90
123
 
91
124
  ```js
92
- import { createOpenAIProvider } from '@scalar/release-notes'
125
+ import { createOpenAIProvider, defineReleaseNotesConfig } from '@scalar/release-notes'
93
126
 
94
- createOpenAIProvider({
95
- apiKey: process.env.OPENAI_API_KEY,
96
- model: 'gpt-4.1-mini',
127
+ export default defineReleaseNotesConfig({
128
+ provider: createOpenAIProvider({
129
+ apiKey: process.env.OPENAI_API_KEY,
130
+ model: 'gpt-4.1-mini',
131
+ }),
97
132
  })
98
133
  ```
99
134
 
100
135
  Use a custom provider:
101
136
 
102
137
  ```js
138
+ import { defineReleaseNotesConfig } from '@scalar/release-notes'
139
+
103
140
  export default defineReleaseNotesConfig({
104
141
  provider: {
105
142
  name: 'internal-agent',
@@ -110,6 +147,8 @@ export default defineReleaseNotesConfig({
110
147
  })
111
148
  ```
112
149
 
150
+ A provider object builds itself, so the top-level `apiKeyEnv` does not apply to it. A top-level `model` still does: it is passed to `generateJson`.
151
+
113
152
  The provider can return either a JSON object or a JSON string. The package validates the result before writing `RELEASE_NOTES.json`.
114
153
 
115
154
  ## GitHub Actions
@@ -136,7 +175,7 @@ OpenAI:
136
175
 
137
176
  ## Markdown Sync
138
177
 
139
- Regenerate Markdown from JSON without using AI:
178
+ Regenerate Markdown from JSON without using AI. The config file is still read and its `provider` field still validated, so an unusable `provider` value fails here too:
140
179
 
141
180
  ```bash
142
181
  scalar-release-notes sync-release-notes-markdown \
@@ -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;AAQnC,OAAO,KAAK,EAAuB,kBAAkB,EAAuB,MAAM,iBAAiB,CAAA;AA6DnG,eAAO,MAAM,kCAAkC,GAAI,aAAY,kBAAuB,KAAG,OAwFxF,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;AA+DnG,eAAO,MAAM,kCAAkC,GAAI,aAAY,kBAAuB,KAAG,OAgFxF,CAAA;AAED,eAAO,MAAM,qBAAqB,SAAuC,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { Command } from 'commander';
2
- import { createBuiltInProvider, hasBuiltInProviderApiKey, readReleaseNotesConfig, } from '../config/read-config.js';
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
5
  const createAdHocProduct = (options, fallbackDescription) => {
@@ -29,6 +29,7 @@ const resolveCliOverrides = (options) => {
29
29
  apiKeyEnv: options.apiKeyEnv,
30
30
  repo: options.repo,
31
31
  baseBranch: options.baseBranch,
32
+ pullRequestContext: options.pullRequestContext,
32
33
  };
33
34
  };
34
35
  export const createReleaseNotesGeneratorCommand = (baseConfig = {}) => {
@@ -52,10 +53,10 @@ export const createReleaseNotesGeneratorCommand = (baseConfig = {}) => {
52
53
  .option('--dry-run', 'Print the generated note instead of writing it', false)
53
54
  .option('--force', 'With --all, generate release notes for every configured product', false)
54
55
  .option('--no-markdown-output', 'Skip Markdown regeneration')
56
+ .option('--no-pull-request-context', 'Skip fetching pull request titles and descriptions for AI context')
55
57
  .action(async (options) => {
56
58
  const cliOverrides = resolveCliOverrides(options);
57
59
  const config = await readReleaseNotesConfig(cliOverrides, baseConfig);
58
- const builtInProvider = cliOverrides.provider ?? 'anthropic';
59
60
  // When relying on a built-in provider, skip gracefully if its API key is missing.
60
61
  // This keeps `pnpm release:version --all` from failing on forks, contributor
61
62
  // machines, or CI that do not have the provider secret configured.
@@ -64,17 +65,10 @@ export const createReleaseNotesGeneratorCommand = (baseConfig = {}) => {
64
65
  // environment variable name. The env var name is harmless to log, but keeping
65
66
  // it out of the message avoids a false-positive clear-text-logging alert from
66
67
  // CodeQL, whose name-based heuristic flags anything derived from `apiKeyEnv`.
67
- const usesBuiltInProvider = Boolean(cliOverrides.provider) || !config.provider;
68
- if (usesBuiltInProvider && !hasBuiltInProviderApiKey(builtInProvider, options.apiKeyEnv)) {
69
- console.warn(`No API key set for the ${builtInProvider} provider; skipping release-notes generation.`);
68
+ if (config.builtInProviderName && !hasBuiltInProviderApiKey(config.builtInProviderName, config.apiKeyEnv)) {
69
+ console.warn(`No API key set for the ${config.builtInProviderName} provider; skipping release-notes generation.`);
70
70
  return;
71
71
  }
72
- const provider = config.provider ??
73
- createBuiltInProvider({
74
- provider: builtInProvider,
75
- model: options.model,
76
- apiKeyEnv: options.apiKeyEnv,
77
- });
78
72
  const products = options.all
79
73
  ? config.products
80
74
  : options.product
@@ -89,10 +83,10 @@ export const createReleaseNotesGeneratorCommand = (baseConfig = {}) => {
89
83
  for (const product of products) {
90
84
  await runReleaseNotesGeneratorForProduct({
91
85
  product,
92
- provider,
86
+ provider: config.provider,
93
87
  version: options.version,
94
88
  date: options.date,
95
- model: options.model,
89
+ model: config.model,
96
90
  dryRun: options.dryRun,
97
91
  changedPaths,
98
92
  writeMarkdown: options.markdownOutput,
@@ -6,6 +6,11 @@ export type CliConfigOverrides = {
6
6
  apiKeyEnv?: string;
7
7
  repo?: string;
8
8
  baseBranch?: string;
9
+ /**
10
+ * Only `false` has an effect: the CLI can turn pull request context off, but never
11
+ * back on over a config file that disabled it.
12
+ */
13
+ pullRequestContext?: boolean;
9
14
  };
10
15
  /** Whether the API key for a built-in provider is available (and non-empty) in the environment. */
11
16
  export declare const hasBuiltInProviderApiKey: (provider: BuiltInProviderName, apiKeyEnv?: string) => boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"read-config.d.ts","sourceRoot":"","sources":["../../src/config/read-config.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,mBAAmB,EAEnB,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,EAC3B,MAAM,SAAS,CAAA;AAShB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,mBAAmB,CAAA;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAyCD,mGAAmG;AACnG,eAAO,MAA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B,CAqBpC,CAAA"}
@@ -50,37 +50,114 @@ export const createBuiltInProvider = (options) => {
50
50
  }
51
51
  return createAnthropicProvider({ apiKey, model: options.model });
52
52
  };
53
- const resolveGithub = (configGithub, overrides) => {
53
+ /** Provider used when neither the config nor the CLI names one. */
54
+ const DEFAULT_PROVIDER = 'anthropic';
55
+ const isBuiltInProviderName = (value) => value === 'anthropic' || value === 'openai';
56
+ const isReleaseNotesProvider = (value) => typeof value === 'object' &&
57
+ value !== null &&
58
+ typeof value.generateJson === 'function';
59
+ /**
60
+ * Pick the provider, and the model and API key environment variable that belong with it.
61
+ *
62
+ * `model` and `apiKeyEnv` describe whichever provider their own layer selects, so they are only
63
+ * carried over from layers that select the winning provider. That keeps settings written for one
64
+ * provider from reaching another: a config written for Anthropic never hands an Anthropic model
65
+ * id, or an Anthropic API key, to OpenAI.
66
+ *
67
+ * A layer that names no provider is not provider-agnostic: it selects whatever the next layer
68
+ * down selects. When no layer names one, they all select the default provider, which is the
69
+ * provider each of them would have used on its own.
70
+ *
71
+ * Layers are ordered by precedence, highest first.
72
+ */
73
+ const resolveProviderSelection = (layers) => {
74
+ // Treat `null` as unset, so a JSON round-trip that nulls a field falls through to a lower layer.
75
+ // An empty string is a typo rather than a setting: naming no environment variable at all beats
76
+ // resolving `process.env['']` and reporting a missing API key.
77
+ const optional = (value) => value === '' ? undefined : (value ?? undefined);
78
+ const normalized = layers.map((layer) => ({
79
+ provider: layer.provider ?? undefined,
80
+ model: optional(layer.model),
81
+ apiKeyEnv: optional(layer.apiKeyEnv),
82
+ }));
83
+ const effectiveProviders = normalized.map((_, index) => normalized
84
+ .slice(index)
85
+ .map((layer) => layer.provider)
86
+ .find((provider) => provider !== undefined) ?? DEFAULT_PROVIDER);
87
+ const selection = effectiveProviders[0] ?? DEFAULT_PROVIDER;
88
+ const applicable = normalized.filter((_, index) => effectiveProviders[index] === selection);
54
89
  return {
55
- repo: overrides.repo ?? configGithub?.repo,
56
- baseBranch: overrides.baseBranch ?? configGithub?.baseBranch ?? 'main',
57
- token: configGithub?.token ?? process.env.GITHUB_TOKEN,
90
+ selection,
91
+ model: applicable.find((layer) => layer.model !== undefined)?.model,
92
+ apiKeyEnv: applicable.find((layer) => layer.apiKeyEnv !== undefined)?.apiKeyEnv,
93
+ };
94
+ };
95
+ /**
96
+ * Turn a provider name or provider object into a constructed provider.
97
+ */
98
+ const resolveProvider = (selection, model, apiKeyEnv) => {
99
+ // A custom provider is used as-is. It builds itself, so apiKeyEnv is meaningless here,
100
+ // though `model` still reaches it later through generateJson.
101
+ if (isReleaseNotesProvider(selection)) {
102
+ return { provider: selection, builtInProviderName: null };
103
+ }
104
+ if (isBuiltInProviderName(selection)) {
105
+ return {
106
+ provider: createBuiltInProvider({ provider: selection, model, apiKeyEnv }),
107
+ builtInProviderName: selection,
108
+ };
109
+ }
110
+ throw new Error('Unsupported provider. Use "anthropic", "openai", or a provider object with a generateJson function.');
111
+ };
112
+ /**
113
+ * Merge option objects, highest precedence first, ignoring keys a layer left unset.
114
+ *
115
+ * Unlike an object spread, an explicit `undefined` or `null` in one layer never wipes a value a
116
+ * lower layer set, and fields this file does not know about are carried through untouched. Every
117
+ * key is optional in the result, so this suits option types whose fields are all optional.
118
+ */
119
+ const layerOptions = (layers) => {
120
+ const merged = new Map();
121
+ for (const layer of [...layers].reverse()) {
122
+ for (const [key, value] of Object.entries(layer ?? {})) {
123
+ if (value !== undefined && value !== null) {
124
+ merged.set(key, value);
125
+ }
126
+ }
127
+ }
128
+ // `Object.fromEntries` defines own properties, so a `__proto__` key from a config file stays
129
+ // inert data rather than re-pointing the prototype the way an assignment would.
130
+ return Object.fromEntries(merged);
131
+ };
132
+ /** Layers are ordered by precedence, highest first, matching `layerOptions`. */
133
+ const resolveGithub = (githubLayers, overrides) => {
134
+ const github = layerOptions(githubLayers);
135
+ return {
136
+ ...github,
137
+ repo: overrides.repo ?? github.repo,
138
+ baseBranch: overrides.baseBranch ?? github.baseBranch ?? 'main',
139
+ token: github.token ?? process.env.GITHUB_TOKEN,
140
+ // The CLI flag can only turn pull request context off, never back on.
141
+ pullRequestContext: overrides.pullRequestContext === false ? false : (github.pullRequestContext ?? true),
58
142
  };
59
143
  };
60
144
  export const readReleaseNotesConfig = async (overrides = {}, baseConfig = {}, cwd = process.env.INIT_CWD ?? process.cwd()) => {
61
145
  const configPath = overrides.config ? resolve(cwd, overrides.config) : await findConfigPath(cwd);
62
146
  const fileConfig = configPath ? await loadConfigFile(configPath) : {};
63
- const config = {
64
- ...baseConfig,
65
- ...fileConfig,
66
- github: {
67
- ...baseConfig.github,
68
- ...fileConfig.github,
69
- },
70
- prompts: {
71
- ...baseConfig.prompts,
72
- ...fileConfig.prompts,
73
- },
74
- products: fileConfig.products ?? baseConfig.products,
75
- provider: fileConfig.provider ?? baseConfig.provider,
76
- };
77
- const provider = overrides.provider
78
- ? createBuiltInProvider({ provider: overrides.provider, model: overrides.model, apiKeyEnv: overrides.apiKeyEnv })
79
- : config.provider;
147
+ const { selection, model, apiKeyEnv } = resolveProviderSelection([
148
+ { provider: overrides.provider, model: overrides.model, apiKeyEnv: overrides.apiKeyEnv },
149
+ { provider: fileConfig.provider, model: fileConfig.model, apiKeyEnv: fileConfig.apiKeyEnv },
150
+ { provider: baseConfig.provider, model: baseConfig.model, apiKeyEnv: baseConfig.apiKeyEnv },
151
+ ]);
152
+ const { provider, builtInProviderName } = resolveProvider(selection, model, apiKeyEnv);
80
153
  return {
81
154
  provider,
82
- products: config.products ?? [],
83
- github: resolveGithub(config.github, overrides),
84
- prompts: config.prompts ?? {},
155
+ builtInProviderName,
156
+ model,
157
+ // A custom provider built itself, so the environment variable never applied to it.
158
+ apiKeyEnv: builtInProviderName ? apiKeyEnv : undefined,
159
+ products: fileConfig.products ?? baseConfig.products ?? [],
160
+ github: resolveGithub([fileConfig.github, baseConfig.github], overrides),
161
+ prompts: layerOptions([fileConfig.prompts, baseConfig.prompts]),
85
162
  };
86
163
  };
@@ -27,6 +27,11 @@ export type ProductPromptContext = {
27
27
  };
28
28
  export type PromptContext = {
29
29
  product: ProductPromptContext;
30
+ /**
31
+ * Whether a "Pull request context" block will be present in the user prompt. Mirrors what the
32
+ * default system prompt reacts to, so a custom prompt can describe the same inputs.
33
+ */
34
+ includePullRequestContext: boolean;
30
35
  };
31
36
  export type PromptOptions = {
32
37
  /** Fallback description used when the CLI creates an ad-hoc product. */
@@ -41,6 +46,12 @@ export type GithubOptions = {
41
46
  baseBranch?: string;
42
47
  /** GitHub token for PR context fetching. */
43
48
  token?: string;
49
+ /**
50
+ * Whether to fetch referenced pull requests and feed their titles and descriptions
51
+ * to the AI provider. Defaults to `true`. Set to `false` to skip the GitHub API
52
+ * calls entirely and generate from the CHANGELOG alone.
53
+ */
54
+ pullRequestContext?: boolean;
44
55
  };
45
56
  /**
46
57
  * Pluggable AI provider contract used by the generic release notes generator.
@@ -58,13 +69,51 @@ export type ReleaseNotesProvider = {
58
69
  }): Promise<unknown>;
59
70
  };
60
71
  export type BuiltInProviderName = 'anthropic' | 'openai';
72
+ /** A built-in provider selected by name, or a custom pluggable provider. */
73
+ export type ProviderOption = BuiltInProviderName | ReleaseNotesProvider;
74
+ /**
75
+ * User-facing release notes configuration, as written in a `release-notes.config.*` file.
76
+ */
61
77
  export type ReleaseNotesConfig = {
62
- provider?: ReleaseNotesProvider;
78
+ /**
79
+ * Either a built-in provider name (`'anthropic'` or `'openai'`) that is created with
80
+ * its defaults, or a custom provider object. Defaults to `'anthropic'`.
81
+ */
82
+ provider?: ProviderOption;
83
+ /** Model id handed to the provider. Falls back to the provider's own default model. */
84
+ model?: string;
85
+ /**
86
+ * Environment variable that holds the built-in provider API key. Defaults to
87
+ * `ANTHROPIC_API_KEY` or `OPENAI_API_KEY`. Ignored by custom providers.
88
+ */
89
+ apiKeyEnv?: string;
90
+ /** Release note targets. */
63
91
  products?: readonly ReleaseNotesProduct[];
92
+ /** GitHub settings for PR context and changelog links. */
64
93
  github?: GithubOptions;
94
+ /** Prompt customisation hooks. */
65
95
  prompts?: PromptOptions;
66
96
  };
67
- export type ResolvedReleaseNotesConfig = Required<Pick<ReleaseNotesConfig, 'github' | 'prompts'>> & Omit<ReleaseNotesConfig, 'github' | 'prompts'> & {
97
+ /**
98
+ * Release notes configuration after file discovery, CLI overrides, and provider construction.
99
+ */
100
+ export type ResolvedReleaseNotesConfig = {
101
+ /** The provider to call, already constructed. */
102
+ provider: ReleaseNotesProvider;
103
+ /**
104
+ * Set when the provider came from a built-in name, so callers can check for its API key
105
+ * before running. `null` for custom providers.
106
+ */
107
+ builtInProviderName: BuiltInProviderName | null;
108
+ /** Model id handed to the provider. Falls back to the provider's own default model. */
109
+ model?: string;
110
+ /** Environment variable that holds the built-in provider API key. */
111
+ apiKeyEnv?: string;
112
+ /** Release note targets. */
68
113
  products: readonly ReleaseNotesProduct[];
114
+ /** GitHub settings for PR context and changelog links. */
115
+ github: GithubOptions;
116
+ /** Prompt customisation hooks. */
117
+ prompts: PromptOptions;
69
118
  };
70
119
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAA;IACZ,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAA;IACnB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAA;IACnB,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAAA;IACnB,6DAA6D;IAC7D,aAAa,EAAE,MAAM,CAAA;IACrB,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAA;IAClB,wFAAwF;IACxF,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,iEAAiE;IACjE,wBAAwB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,gCAAgC;IAChC,WAAW,EAAE,MAAM,CAAA;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AAC,EAAE,MAAM,CAAA;IAClB,4BAA4B;IAC5B,QAAQ,EAAE,SAAS,mBAAmB,EAAE,CAAA;IACxC,0DAA0D;IAC1D,MAAM,EAAE,aAAa,CAAA;IACrB,kCAAkC;IAClC,OAAO,EAAE,aAAa,CAAA;CACvB,CAAA"}
@@ -43,7 +43,7 @@ const getPathsChangedSinceBase = async (baseBranch) => {
43
43
  return new Set(paths);
44
44
  }
45
45
  catch (error) {
46
- console.warn(`Could not read git diff for release-notes filtering: ${error.message}. Generating for all registered products.`);
46
+ console.warn(`Could not read git diff for release-notes filtering: ${error instanceof Error ? error.message : String(error)}. Generating for all registered products.`);
47
47
  return null;
48
48
  }
49
49
  };
@@ -58,7 +58,7 @@ export const fetchPullRequests = async (options) => {
58
58
  summaries.set(number, { number, title, body });
59
59
  }
60
60
  catch (error) {
61
- console.warn(`Skipping PR #${number}: ${error.message}`);
61
+ console.warn(`Skipping PR #${number}: ${error instanceof Error ? error.message : String(error)}`);
62
62
  }
63
63
  }
64
64
  return summaries;
@@ -24,10 +24,13 @@ export type GenerateReleaseNoteOptions = {
24
24
  maxOutputTokens?: number;
25
25
  signal?: AbortSignal;
26
26
  };
27
- export declare const buildDefaultSystemPrompt: (product: ProductPromptContext) => string;
27
+ export declare const buildDefaultSystemPrompt: (product: ProductPromptContext, options?: {
28
+ includePullRequestContext?: boolean;
29
+ }) => string;
28
30
  export declare const buildSystemPrompt: (options: {
29
31
  product: ProductPromptContext;
30
32
  prompts?: PromptOptions;
33
+ includePullRequestContext?: boolean;
31
34
  }) => string;
32
35
  export declare const buildPullRequestContext: (pullRequests: ReadonlyMap<number, PullRequestSummary> | undefined) => string;
33
36
  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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AAA;CACrB,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,SAAS,oBAAoB,EAC7B,UAAS;IAAE,yBAAyB,CAAC,EAAE,OAAO,CAAA;CAAO,KACpD,MAmCF,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,SAAS;IACzC,OAAO,EAAE,oBAAoB,CAAA;IAC7B,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,yBAAyB,CAAC,EAAE,OAAO,CAAA;CACpC,KAAG,MAOH,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;AAgED;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAAU,SAAS,0BAA0B,KAAG,OAAO,CAAC,WAAW,CA0ClG,CAAA"}
@@ -8,7 +8,16 @@ const DEFAULT_MAX_OUTPUT_TOKENS = 1024;
8
8
  * validation error back to the provider and let it correct itself.
9
9
  */
10
10
  const MAX_ATTEMPTS = 3;
11
- export const buildDefaultSystemPrompt = (product) => {
11
+ export const buildDefaultSystemPrompt = (product, options = {}) => {
12
+ const inputs = [
13
+ 'Inputs:',
14
+ '- The CHANGELOG section is the source of truth for what changed in the released package.',
15
+ '- "Dependency CHANGELOG" blocks may follow with sections from dependencies that ship inside this release. Treat their entries as user-facing changes that landed in the parent release.',
16
+ ];
17
+ // Only advertise the pull request block when the prompt actually carries one.
18
+ if (options.includePullRequestContext !== false) {
19
+ inputs.push('- A "Pull request context" block may follow with each PR\'s title and description. Use it to understand the why behind each entry, but do not invent details that are not supported by these inputs.');
20
+ }
12
21
  return [
13
22
  `You write release notes for ${product.displayName} - ${product.description}.`,
14
23
  'You are summarising a Changesets-style CHANGELOG section for users reading curated release notes.',
@@ -20,10 +29,7 @@ export const buildDefaultSystemPrompt = (product) => {
20
29
  '- Talk about user-facing changes only. Skip refactors, dependency bumps, internal CI changes, and chores.',
21
30
  '- If every entry is a chore or dependency bump, return a single short note that says polish and bug fixes shipped.',
22
31
  '',
23
- 'Inputs:',
24
- '- The CHANGELOG section is the source of truth for what changed in the released package.',
25
- '- "Dependency CHANGELOG" blocks may follow with sections from dependencies that ship inside this release. Treat their entries as user-facing changes that landed in the parent release.',
26
- '- A "Pull request context" block may follow with each PR\'s title and description. Use it to understand the why behind each entry, but do not invent details that are not supported by these inputs.',
32
+ ...inputs,
27
33
  '',
28
34
  'Output format:',
29
35
  '- You MUST respond with a single JSON object and nothing else. No markdown fences, no commentary.',
@@ -35,7 +41,9 @@ export const buildDefaultSystemPrompt = (product) => {
35
41
  ].join('\n');
36
42
  };
37
43
  export const buildSystemPrompt = (options) => {
38
- return options.prompts?.systemPrompt?.({ product: options.product }) ?? buildDefaultSystemPrompt(options.product);
44
+ const includePullRequestContext = options.includePullRequestContext !== false;
45
+ return (options.prompts?.systemPrompt?.({ product: options.product, includePullRequestContext }) ??
46
+ buildDefaultSystemPrompt(options.product, { includePullRequestContext }));
39
47
  };
40
48
  export const buildPullRequestContext = (pullRequests) => {
41
49
  if (!pullRequests || pullRequests.size === 0) {
@@ -99,7 +107,7 @@ const parseProviderJson = (payload) => {
99
107
  return JSON.parse(jsonText);
100
108
  }
101
109
  catch (error) {
102
- throw new Error(`AI provider returned invalid JSON: ${error.message}\nRaw text:\n${jsonText}`);
110
+ throw new Error(`AI provider returned invalid JSON: ${error instanceof Error ? error.message : String(error)}\nRaw text:\n${jsonText}`);
103
111
  }
104
112
  }
105
113
  return payload;
@@ -118,8 +126,8 @@ const validateProviderResponse = (raw) => {
118
126
  catch (error) {
119
127
  return {
120
128
  ok: false,
121
- feedback: `Your previous response was not valid JSON (${error.message}). Respond with a single valid JSON object and nothing else.`,
122
- fatalError: error,
129
+ feedback: `Your previous response was not valid JSON (${error instanceof Error ? error.message : String(error)}). Respond with a single valid JSON object and nothing else.`,
130
+ fatalError: error instanceof Error ? error : new Error(String(error)),
123
131
  };
124
132
  }
125
133
  if (typeof parsed !== 'object' || parsed === null) {
@@ -153,7 +161,8 @@ export const generateReleaseNote = async (options) => {
153
161
  displayName: options.packageName,
154
162
  description: options.prompts?.productDescriptionFallback ?? 'an open-source package',
155
163
  };
156
- const systemPrompt = buildSystemPrompt({ product, prompts: options.prompts });
164
+ const includePullRequestContext = (options.pullRequests?.size ?? 0) > 0;
165
+ const systemPrompt = buildSystemPrompt({ product, prompts: options.prompts, includePullRequestContext });
157
166
  const baseUserPrompt = buildUserPrompt(options);
158
167
  let userPrompt = baseUserPrompt;
159
168
  for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
@@ -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;AAkDD,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,CAmHxC,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,CAsHxC,CAAA"}
@@ -35,7 +35,7 @@ const loadDependencyChangelog = async (changelogPath) => {
35
35
  changelog = await readFile(resolvedPath, 'utf-8');
36
36
  }
37
37
  catch (error) {
38
- console.warn(`Skipping dependency changelog ${changelogPath}: ${error.message}`);
38
+ console.warn(`Skipping dependency changelog ${changelogPath}: ${error instanceof Error ? error.message : String(error)}`);
39
39
  return null;
40
40
  }
41
41
  const section = extractChangelogSection(changelog, info.version);
@@ -99,7 +99,10 @@ export const runReleaseNotesGeneratorForProduct = async (options) => {
99
99
  });
100
100
  const changelogSection = section ?? '';
101
101
  const dependencyChangelogText = dependencyChangelogs.map((entry) => entry.changelogSection).join('\n');
102
- const pullRequestNumbers = extractPullRequestNumbers([changelogSection, dependencyChangelogText].filter(Boolean).join('\n'), options.github?.repo);
102
+ const includePullRequestContext = options.github?.pullRequestContext !== false;
103
+ const pullRequestNumbers = includePullRequestContext
104
+ ? extractPullRequestNumbers([changelogSection, dependencyChangelogText].filter(Boolean).join('\n'), options.github?.repo)
105
+ : [];
103
106
  const pullRequests = pullRequestNumbers.length && options.github?.repo
104
107
  ? await fetchPullRequests({
105
108
  numbers: pullRequestNumbers,
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export { createReleaseNotesGeneratorCommand, releaseNotesGenerator } from './commands/generate.js';
2
2
  export { createSyncReleaseNotesMarkdownCommand, syncReleaseNotesMarkdown } from './commands/sync-markdown.js';
3
3
  export { defineReleaseNotesConfig } from './config/define-config.js';
4
- export { createBuiltInProvider, readReleaseNotesConfig } from './config/read-config.js';
5
- export type { BuiltInProviderName, GithubOptions, ProductPromptContext, PromptOptions, ReleaseNotesConfig, ReleaseNotesProduct, ReleaseNotesProvider, ResolvedReleaseNotesConfig, } from './config/types.js';
4
+ export { createBuiltInProvider, hasBuiltInProviderApiKey, readReleaseNotesConfig } from './config/read-config.js';
5
+ export type { BuiltInProviderName, GithubOptions, ProductPromptContext, PromptContext, PromptOptions, ProviderOption, ReleaseNotesConfig, ReleaseNotesProduct, ReleaseNotesProvider, ResolvedReleaseNotesConfig, } from './config/types.js';
6
6
  export { getChangedPathsForReleaseFiltering } from './core/detect-versioned-changelog-paths.js';
7
7
  export { extractChangelogSection } from './core/extract-changelog-section.js';
8
8
  export type { PullRequestSummary } from './core/fetch-pull-requests.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,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AACpF,YAAY,EACV,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAA;AAC5F,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAA;AAC1E,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AACzF,YAAY,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAA;AAC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js CHANGED
@@ -1,7 +1,7 @@
1
1
  export { createReleaseNotesGeneratorCommand, releaseNotesGenerator } from './commands/generate.js';
2
2
  export { createSyncReleaseNotesMarkdownCommand, syncReleaseNotesMarkdown } from './commands/sync-markdown.js';
3
3
  export { defineReleaseNotesConfig } from './config/define-config.js';
4
- export { createBuiltInProvider, readReleaseNotesConfig } from './config/read-config.js';
4
+ export { createBuiltInProvider, hasBuiltInProviderApiKey, readReleaseNotesConfig } from './config/read-config.js';
5
5
  export { getChangedPathsForReleaseFiltering } from './core/detect-versioned-changelog-paths.js';
6
6
  export { extractChangelogSection } from './core/extract-changelog-section.js';
7
7
  export { extractPullRequestNumbers, fetchPullRequests } from './core/fetch-pull-requests.js';
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAM3D,KAAK,wBAAwB,GAAG;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CACzB,CAAA;AAgBD,eAAO,MAAM,uBAAuB,GAAI,UAAS,wBAA6B,KAAG,oBA6ChF,CAAA"}
1
+ {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAM3D,KAAK,wBAAwB,GAAG;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CACzB,CAAA;AAkBD,eAAO,MAAM,uBAAuB,GAAI,UAAS,wBAA6B,KAAG,oBAkDhF,CAAA"}
@@ -1,6 +1,11 @@
1
+ import { z } from 'zod';
1
2
  const ANTHROPIC_API_URL = 'https://api.anthropic.com/v1/messages';
2
3
  const ANTHROPIC_API_VERSION = '2023-06-01';
3
4
  const DEFAULT_MODEL = 'claude-sonnet-4-5';
5
+ const responseSchema = z.object({
6
+ content: z.array(z.object({ type: z.string(), text: z.string().optional() })).optional(),
7
+ error: z.object({ message: z.string().optional() }).optional(),
8
+ });
4
9
  const extractText = (response) => {
5
10
  const block = response.content?.find((entry) => entry.type === 'text' && typeof entry.text === 'string');
6
11
  const text = block?.text?.trim() ?? '';
@@ -43,7 +48,12 @@ export const createAnthropicProvider = (options = {}) => {
43
48
  const detail = await response.text().catch(() => '');
44
49
  throw new Error(`Anthropic API call failed (${response.status}): ${detail}`);
45
50
  }
46
- const payload = (await response.json());
51
+ const body = await response.json();
52
+ const parsed = responseSchema.safeParse(body);
53
+ if (!parsed.success) {
54
+ throw new Error('Anthropic API returned a malformed response', { cause: parsed.error });
55
+ }
56
+ const payload = parsed.data;
47
57
  if (payload.error?.message) {
48
58
  throw new Error(`Anthropic API returned an error: ${payload.error.message}`);
49
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAK3D,KAAK,qBAAqB,GAAG;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CACzB,CAAA;AAqBD,eAAO,MAAM,oBAAoB,GAAI,UAAS,qBAA0B,KAAG,oBAgD1E,CAAA"}
1
+ {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAK3D,KAAK,qBAAqB,GAAG;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CACzB,CAAA;AAuBD,eAAO,MAAM,oBAAoB,GAAI,UAAS,qBAA0B,KAAG,oBAqD1E,CAAA"}
@@ -1,5 +1,14 @@
1
+ import { z } from 'zod';
1
2
  const OPENAI_API_URL = 'https://api.openai.com/v1/chat/completions';
2
3
  const DEFAULT_MODEL = 'gpt-4.1-mini';
4
+ const responseSchema = z.object({
5
+ choices: z
6
+ .array(z.object({
7
+ message: z.object({ content: z.string().nullable().optional() }).optional(),
8
+ }))
9
+ .optional(),
10
+ error: z.object({ message: z.string().optional() }).optional(),
11
+ });
3
12
  const extractText = (response) => {
4
13
  const text = response.choices?.[0]?.message?.content?.trim() ?? '';
5
14
  if (!text) {
@@ -44,7 +53,12 @@ export const createOpenAIProvider = (options = {}) => {
44
53
  const detail = await response.text().catch(() => '');
45
54
  throw new Error(`OpenAI API call failed (${response.status}): ${detail}`);
46
55
  }
47
- const payload = (await response.json());
56
+ const body = await response.json();
57
+ const parsed = responseSchema.safeParse(body);
58
+ if (!parsed.success) {
59
+ throw new Error('OpenAI API returned a malformed response', { cause: parsed.error });
60
+ }
61
+ const payload = parsed.data;
48
62
  if (payload.error?.message) {
49
63
  throw new Error(`OpenAI API returned an error: ${payload.error.message}`);
50
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"write-release-notes-json.d.ts","sourceRoot":"","sources":["../../src/writers/write-release-notes-json.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,WAAW,EAAqB,MAAM,UAAU,CAAA;AAiB9D,eAAO,MAAM,wBAAwB,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,WAAW,EAAE,CA6BlF,CAAA;AA2BD,eAAO,MAAM,iBAAiB,GAAI,UAAU,SAAS,WAAW,EAAE,EAAE,MAAM,WAAW,KAAG,WAAW,EAalG,CAAA;AAED,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,WAAW,CAAA;CAClB,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,WAAW,EAAE,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAU,SAAS,gBAAgB,KAAG,OAAO,CAAC,eAAe,CAS7F,CAAA"}
1
+ {"version":3,"file":"write-release-notes-json.d.ts","sourceRoot":"","sources":["../../src/writers/write-release-notes-json.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,WAAW,EAAqB,MAAM,UAAU,CAAA;AAiB9D,eAAO,MAAM,wBAAwB,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,WAAW,EAAE,CA6BlF,CAAA;AA2BD,eAAO,MAAM,iBAAiB,GAAI,UAAU,SAAS,WAAW,EAAE,EAAE,MAAM,WAAW,KAAG,WAAW,EAalG,CAAA;AAED,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,WAAW,CAAA;CAClB,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,WAAW,EAAE,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAU,SAAS,gBAAgB,KAAG,OAAO,CAAC,eAAe,CAS7F,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import { mkdir, readFile, writeFile } from 'node:fs/promises';
2
2
  import { dirname } from 'node:path';
3
3
  import { compareVersions } from '@scalar/helpers/general/compare-versions';
4
+ import { isObjectLike } from '@scalar/helpers/object/is-object';
4
5
  import { releaseNoteSchema } from '../types.js';
5
6
  const parseReleaseNoteEntries = (parsed, pathForLogs) => {
6
7
  const valid = [];
@@ -21,7 +22,7 @@ export const readReleaseNotesJsonFile = async (path) => {
21
22
  raw = await readFile(path, 'utf-8');
22
23
  }
23
24
  catch (error) {
24
- if (error.code === 'ENOENT') {
25
+ if (isObjectLike(error) && error.code === 'ENOENT') {
25
26
  throw new Error(`Release notes JSON not found: ${path}`);
26
27
  }
27
28
  throw error;
@@ -31,7 +32,7 @@ export const readReleaseNotesJsonFile = async (path) => {
31
32
  parsed = JSON.parse(raw);
32
33
  }
33
34
  catch (error) {
34
- throw new Error(`Could not parse ${path} as JSON: ${error.message}`);
35
+ throw new Error(`Could not parse ${path} as JSON: ${error instanceof Error ? error.message : String(error)}`);
35
36
  }
36
37
  if (!Array.isArray(parsed)) {
37
38
  throw new Error(`Expected ${path} to contain a JSON array of release notes.`);
@@ -93,7 +94,7 @@ const readJsonIfExists = async (path) => {
93
94
  raw = await readFile(path, 'utf-8');
94
95
  }
95
96
  catch (error) {
96
- if (error.code === 'ENOENT') {
97
+ if (isObjectLike(error) && error.code === 'ENOENT') {
97
98
  return null;
98
99
  }
99
100
  throw error;
@@ -103,7 +104,7 @@ const readJsonIfExists = async (path) => {
103
104
  parsed = JSON.parse(raw);
104
105
  }
105
106
  catch (error) {
106
- console.warn(`Could not parse ${path} as JSON; treating as empty. ${error.message}`);
107
+ console.warn(`Could not parse ${path} as JSON; treating as empty. ${error instanceof Error ? error.message : String(error)}`);
107
108
  return [];
108
109
  }
109
110
  if (!Array.isArray(parsed)) {
@@ -1 +1 @@
1
- {"version":3,"file":"write-release-notes-markdown.d.ts","sourceRoot":"","sources":["../../src/writers/write-release-notes-markdown.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,SAAS,WAAW,EAAE,CAAA;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,KAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,yBAAyB,GAAU,SAAS,oBAAoB,KAAG,OAAO,CAAC,mBAAmB,CAS1G,CAAA"}
1
+ {"version":3,"file":"write-release-notes-markdown.d.ts","sourceRoot":"","sources":["../../src/writers/write-release-notes-markdown.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,SAAS,WAAW,EAAE,CAAA;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,KAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,yBAAyB,GAAU,SAAS,oBAAoB,KAAG,OAAO,CAAC,mBAAmB,CAS1G,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import { mkdir, stat, writeFile } from 'node:fs/promises';
2
2
  import { dirname } from 'node:path';
3
- import { buildReleaseNotesPreamble, serializeReleaseNotes, } from '@scalar/helpers/markdown/release-notes';
3
+ import { buildReleaseNotesPreamble, serializeReleaseNotes } from '@scalar/helpers/markdown/release-notes';
4
+ import { isObjectLike } from '@scalar/helpers/object/is-object';
4
5
  export const writeReleaseNotesMarkdown = async (options) => {
5
6
  const created = !(await pathExists(options.path));
6
7
  const preamble = options.preamble ?? buildReleaseNotesPreamble();
@@ -15,7 +16,7 @@ const pathExists = async (path) => {
15
16
  return true;
16
17
  }
17
18
  catch (error) {
18
- if (error.code === 'ENOENT') {
19
+ if (isObjectLike(error) && error.code === 'ENOENT') {
19
20
  return false;
20
21
  }
21
22
  throw error;
@@ -1 +1 @@
1
- {"version":3,"file":"write-release-notes-schema.d.ts","sourceRoot":"","sources":["../../src/writers/write-release-notes-schema.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iCAAiC,sCAAsC,CAAA;AACpF,eAAO,MAAM,+BAA+B,yDAAyD,CAAA;AACrG,eAAO,MAAM,kCAAkC,kBAAkB,CAAA;AAEjE,MAAM,MAAM,8BAA8B,GAAG;IAC3C,yBAAyB;IACzB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,yBAAyB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,2BAA2B,GAAI,UAAS,8BAAmC,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAYhH,CAAA;AAED,KAAK,kBAAkB,GAAG,8BAA8B,GAAG;IACzD,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,2BAA2B,GAAU,SAAS,kBAAkB,KAAG,OAAO,CAAC,iBAAiB,CAmBxG,CAAA"}
1
+ {"version":3,"file":"write-release-notes-schema.d.ts","sourceRoot":"","sources":["../../src/writers/write-release-notes-schema.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,iCAAiC,sCAAsC,CAAA;AACpF,eAAO,MAAM,+BAA+B,yDAAyD,CAAA;AACrG,eAAO,MAAM,kCAAkC,kBAAkB,CAAA;AAEjE,MAAM,MAAM,8BAA8B,GAAG;IAC3C,yBAAyB;IACzB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,yBAAyB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,2BAA2B,GAAI,UAAS,8BAAmC,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAYhH,CAAA;AAED,KAAK,kBAAkB,GAAG,8BAA8B,GAAG;IACzD,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,2BAA2B,GAAU,SAAS,kBAAkB,KAAG,OAAO,CAAC,iBAAiB,CAmBxG,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { mkdir, readFile, writeFile } from 'node:fs/promises';
2
2
  import { dirname } from 'node:path';
3
+ import { isObjectLike } from '@scalar/helpers/object/is-object';
3
4
  import { z } from 'zod';
4
5
  import { releaseNotesFileSchema } from '../types.js';
5
6
  export const DEFAULT_RELEASE_NOTES_SCHEMA_PATH = 'schemas/release-notes.schema.json';
@@ -24,7 +25,7 @@ export const writeReleaseNotesJsonSchema = async (options) => {
24
25
  previous = await readFile(options.path, 'utf-8');
25
26
  }
26
27
  catch (error) {
27
- if (error.code !== 'ENOENT') {
28
+ if (!isObjectLike(error) || error.code !== 'ENOENT') {
28
29
  throw error;
29
30
  }
30
31
  }
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "changesets",
17
17
  "ai"
18
18
  ],
19
- "version": "0.1.9",
19
+ "version": "0.2.0",
20
20
  "engines": {
21
21
  "node": ">=22"
22
22
  },
@@ -50,7 +50,7 @@
50
50
  "dependencies": {
51
51
  "commander": "13.1.0",
52
52
  "zod": "^4.4.3",
53
- "@scalar/helpers": "0.11.3"
53
+ "@scalar/helpers": "0.12.0"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/node": "^24.1.0",