From 00c52c56cff0ee63ff4202648209f4b097c37bf4 Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Wed, 18 Nov 2026 20:29:14 +0000 Subject: [PATCH] chore: simplify release tooling --- .github/workflows/release-please.yml | 4 +- bun.lock | 26 +--- docs/release.md | 12 -- package.json | 5 +- release-please-config.json | 1 - .../release-please-ai/changelog-notes.test.ts | 83 ------------ scripts/release-please-ai/changelog-notes.ts | 91 ------------- scripts/release-please-ai/generate.ts | 37 ------ scripts/release-please-ai/prompt.test.ts | 31 ----- scripts/release-please-ai/prompt.ts | 20 --- scripts/release-please-ai/render.test.ts | 36 ------ scripts/release-please-ai/sections.test.ts | 44 ------- scripts/release-please-ai/sections.ts | 84 ------------ scripts/release-please-ai/tools.test.ts | 88 ------------- scripts/release-please-ai/tools.ts | 120 ------------------ scripts/release-please-ai/types.ts | 27 ---- scripts/release-please-runner.ts | 2 - 17 files changed, 3 insertions(+), 708 deletions(-) delete mode 100644 scripts/release-please-ai/changelog-notes.test.ts delete mode 100644 scripts/release-please-ai/changelog-notes.ts delete mode 100644 scripts/release-please-ai/generate.ts delete mode 100644 scripts/release-please-ai/prompt.test.ts delete mode 100644 scripts/release-please-ai/prompt.ts delete mode 100644 scripts/release-please-ai/render.test.ts delete mode 100644 scripts/release-please-ai/sections.test.ts delete mode 100644 scripts/release-please-ai/sections.ts delete mode 100644 scripts/release-please-ai/tools.test.ts delete mode 100644 scripts/release-please-ai/tools.ts delete mode 100644 scripts/release-please-ai/types.ts diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 03a36bc9..42c612ce 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -37,15 +37,13 @@ jobs: run: bun install --frozen-lockfile - name: Test release tooling - run: bun test scripts/release-please-ai scripts/release-please-runner.test.ts + run: bun test scripts/release-please-runner.test.ts - name: Run Release Please id: release-please env: GITHUB_TOKEN: ${{ github.token }} GITHUB_REPOSITORY: ${{ github.repository }} - ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} - RELEASE_NOTES_MODEL: ${{ vars.RELEASE_NOTES_MODEL || secrets.RELEASE_NOTES_MODEL }} run: bun run release-please - name: Dispatch publish workflow for stable release diff --git a/bun.lock b/bun.lock index 5508ba54..ca38cf2d 100644 --- a/bun.lock +++ b/bun.lock @@ -1,16 +1,15 @@ { "lockfileVersion": 1, + "configVersion": 0, "workspaces": { "": { "name": "@cmux/ghostty-terminal", "devDependencies": { - "@ai-sdk/anthropic": "^4.0.0", "@biomejs/biome": "^1.9.4", "@happy-dom/global-registrator": "^15.11.0", "@types/bun": "^1.3.2", "@xterm/headless": "^5.5.0", "@xterm/xterm": "^5.5.0", - "ai": "^7.0.2", "mitata": "^1.0.34", "prettier": "^3.6.2", "release-please": "17.9.0", @@ -18,19 +17,10 @@ "typescript": "^5.9.3", "vite": "^4.5.0", "vite-plugin-dts": "^4.5.4", - "zod": "^4.4.3", }, }, }, "packages": { - "@ai-sdk/anthropic": ["@ai-sdk/anthropic@4.0.0", "", { "dependencies": { "@ai-sdk/provider": "4.0.0", "@ai-sdk/provider-utils": "5.0.0" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-N0lT1g6/5DEIZvalpkpwYRCdu7n5qb8qPN3PcTem6k4VkPBLC2+T2LAAyx1GS0eNOxavVa0CP7n2kCiye0yyfw=="], - - "@ai-sdk/gateway": ["@ai-sdk/gateway@4.0.2", "", { "dependencies": { "@ai-sdk/provider": "4.0.0", "@ai-sdk/provider-utils": "5.0.0", "@vercel/oidc": "3.2.0" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-Jz1BiiTSvhDsCBJrkFRSqLHDRMVjFtYk9GdbSi3UOqY+/epza+oIESMDzfN4m+YHT/1IYmNEmxaMfjXOvxKDjQ=="], - - "@ai-sdk/provider": ["@ai-sdk/provider@4.0.0", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-fr9Gs89prDWiuox/T+kCA+i2cJkHpxU5S+tr4megjTzRC27ZsvFhwjU/+XrqqMbvBUlfmXxTOYWy8ng45dsjIg=="], - - "@ai-sdk/provider-utils": ["@ai-sdk/provider-utils@5.0.0", "", { "dependencies": { "@ai-sdk/provider": "4.0.0", "@standard-schema/spec": "^1.1.0", "@workflow/serde": "4.1.0", "eventsource-parser": "^3.0.8" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-zj66M02jc6ASYwIgWZowsooDUwaVngeNZQ3H10GwcPMZ+KR6gHMhcUuKl6tkai+JPXTKDyHY1pnszuxRtw2D4A=="], - "@babel/code-frame": ["@babel/code-frame@7.29.7", "", { "dependencies": { "@babel/helper-validator-identifier": "^7.29.7", "js-tokens": "^4.0.0", "picocolors": "^1.1.1" } }, "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw=="], "@babel/helper-string-parser": ["@babel/helper-string-parser@7.27.1", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="], @@ -173,8 +163,6 @@ "@rushstack/ts-command-line": ["@rushstack/ts-command-line@5.1.3", "", { "dependencies": { "@rushstack/terminal": "0.19.3", "@types/argparse": "1.0.38", "argparse": "~1.0.9", "string-argv": "~0.3.1" } }, "sha512-Kdv0k/BnnxIYFlMVC1IxrIS0oGQd4T4b7vKfx52Y2+wk2WZSDFIvedr7JrhenzSlm3ou5KwtoTGTGd5nbODRug=="], - "@standard-schema/spec": ["@standard-schema/spec@1.1.0", "", {}, "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w=="], - "@types/argparse": ["@types/argparse@1.0.38", "", {}, "sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA=="], "@types/bun": ["@types/bun@1.3.2", "", { "dependencies": { "bun-types": "1.3.2" } }, "sha512-t15P7k5UIgHKkxwnMNkJbWlh/617rkDGEdSsDbu+qNHTaz9SKf7aC8fiIlUdD5RPpH6GEkP0cK7WlvmrEBRtWg=="], @@ -193,8 +181,6 @@ "@types/unist": ["@types/unist@2.0.11", "", {}, "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA=="], - "@vercel/oidc": ["@vercel/oidc@3.2.0", "", {}, "sha512-UycprH3T6n3jH0k44NHMa7pnFHGu/N05MjojYr+Mc6I7obkoLIJujSWwin1pCvdy/eOxrI/l3uDLQsmcrOb4ug=="], - "@volar/language-core": ["@volar/language-core@2.4.23", "", { "dependencies": { "@volar/source-map": "2.4.23" } }, "sha512-hEEd5ET/oSmBC6pi1j6NaNYRWoAiDhINbT8rmwtINugR39loROSlufGdYMF9TaKGfz+ViGs1Idi3mAhnuPcoGQ=="], "@volar/source-map": ["@volar/source-map@2.4.23", "", {}, "sha512-Z1Uc8IB57Lm6k7q6KIDu/p+JWtf3xsXJqAX/5r18hYOTpJyBn0KXUR8oTJ4WFYOcDzWC9n3IflGgHowx6U6z9Q=="], @@ -211,8 +197,6 @@ "@vue/shared": ["@vue/shared@3.5.24", "", {}, "sha512-9cwHL2EsJBdi8NY22pngYYWzkTDhld6fAD6jlaeloNGciNSJL6bLpbxVgXl96X00Jtc6YWQv96YA/0sxex/k1A=="], - "@workflow/serde": ["@workflow/serde@4.1.0", "", {}, "sha512-pav4F2BoirECWR7Nf1TKt+2eETcBj7jj4cBefQ8VXQCA6NPkaKeLfj/zMgi+3zYV5ZIBT4GuUiphsj0/b9hPQQ=="], - "@xmldom/xmldom": ["@xmldom/xmldom@0.8.13", "", {}, "sha512-KRYzxepc14G/CEpEGc3Yn+JKaAeT63smlDr+vjB8jRfgTBBI9wRj/nkQEO+ucV8p8I9bfKLWp37uHgFrbntPvw=="], "@xterm/headless": ["@xterm/headless@5.5.0", "", {}, "sha512-5xXB7kdQlFBP82ViMJTwwEc3gKCLGKR/eoxQm4zge7GPBl86tCdI0IdPJjoKd8mUSFXz5V7i/25sfsEkP4j46g=="], @@ -223,8 +207,6 @@ "agent-base": ["agent-base@7.1.4", "", {}, "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ=="], - "ai": ["ai@7.0.2", "", { "dependencies": { "@ai-sdk/gateway": "4.0.2", "@ai-sdk/provider": "4.0.0", "@ai-sdk/provider-utils": "5.0.0" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-VMU08jHIDJnnKDrbC9AFa5ZsPpOTfAPRLvTRHtJk4FGAoeldmJROMxvZ2ak5lCjEJ2GP2OLPQbMRyEK8w0+S4A=="], - "ajv": ["ajv@8.12.0", "", { "dependencies": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2", "uri-js": "^4.2.2" } }, "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA=="], "ajv-draft-04": ["ajv-draft-04@1.0.0", "", { "peerDependencies": { "ajv": "^8.5.0" }, "optionalPeers": ["ajv"] }, "sha512-mv00Te6nmYbRp5DCwclxtt7yV/joXJPGS7nM+97GdxvuttCOfgI3K4U25zboyeX0O+myI8ERluxQe5wljMmVIw=="], @@ -325,8 +307,6 @@ "estree-walker": ["estree-walker@2.0.2", "", {}, "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="], - "eventsource-parser": ["eventsource-parser@3.1.0", "", {}, "sha512-kJezFj9YFAMLeORyi7aCLxLbD5/qWMQnoMVlVPyHIll7lgRJCc3JVln9Vgl9nwQi0YkMnhdGTMNn7CkRRAptMg=="], - "exsolve": ["exsolve@1.0.8", "", {}, "sha512-LmDxfWXwcTArk8fUEnOfSZpHOJ6zOMUJKOtFLFqJLoKJetuQG874Uc7/Kki7zFLzYybmZhp1M7+98pfMqeX8yA=="], "fast-deep-equal": ["fast-deep-equal@3.1.3", "", {}, "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="], @@ -387,8 +367,6 @@ "json-parse-even-better-errors": ["json-parse-even-better-errors@2.3.1", "", {}, "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w=="], - "json-schema": ["json-schema@0.4.0", "", {}, "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA=="], - "json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="], "json-stringify-safe": ["json-stringify-safe@5.0.1", "", {}, "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA=="], @@ -591,8 +569,6 @@ "yargs-parser": ["yargs-parser@21.1.1", "", {}, "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw=="], - "zod": ["zod@4.4.3", "", {}, "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ=="], - "@babel/code-frame/@babel/helper-validator-identifier": ["@babel/helper-validator-identifier@7.29.7", "", {}, "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg=="], "@microsoft/api-extractor/diff": ["diff@8.0.2", "", {}, "sha512-sSuxWU5j5SR9QQji/o2qMvqRNYRDOcBTgsJ/DeCf4iSN4gW+gNMXM7wFIP+fdXZxoNiAnHUTGjCr+TSWXdRDKg=="], diff --git a/docs/release.md b/docs/release.md index cd18f255..ff5650b3 100644 --- a/docs/release.md +++ b/docs/release.md @@ -9,16 +9,6 @@ 5. The Release Please workflow explicitly dispatches `.github/workflows/publish.yml` for the tag because workflows created with `GITHUB_TOKEN` do not reliably trigger follow-up workflows automatically. 6. `publish.yml` validates the tag and source versions, runs the release quality gates, publishes `ghostty-web`, then publishes `@ghostty-web/demo` with its `ghostty-web` dependency pinned to the exact release version. -## AI release notes - -Release Please owns the canonical changelog structure, commit sections, headings, and links. The custom `changelog-type: "ai"` generator only inserts a concise editorial summary and optional highlights below the version heading. - -The AI path uses an AI SDK `ToolLoopAgent` with scoped tools. It can list the release commits and inspect GitHub commit diffs for those SHAs before producing the structured editorial summary. The tools reject SHAs outside the current release scope. - -- Configure `ANTHROPIC_API_KEY` as a repository secret to enable AI editorial notes. -- Configure `RELEASE_NOTES_MODEL` as a repository variable or secret to choose the model. The workflow reads the variable first and falls back to the secret for compatibility with secret-only setups. -- If either setting is missing or model generation fails, the runner logs the reason and falls back to default Release Please notes. - ## Next publishes `.github/workflows/publish.yml` also publishes `ghostty-web@next` and `@ghostty-web/demo@next` after successful CI on `main`. Release-only squash commits whose subject matches `chore(release): ...` are skipped so version/changelog-only release PR merges do not create noisy prereleases. @@ -46,7 +36,5 @@ When the pipeline has been test-driven successfully and maintainers are ready fo Before the first automated stable release: - Configure npm trusted publishers for both `ghostty-web` and `@ghostty-web/demo` for `.github/workflows/publish.yml`. -- Add the `ANTHROPIC_API_KEY` repository secret if AI editorial notes should be enabled. -- Add the `RELEASE_NOTES_MODEL` repository variable when using AI notes. - Enable squash merging, disable merge commits and rebase merging, and set squash commit titles to use the pull request title. - Require the `pr-title`, `fmt`, `lint`, `type check`, `test`, and `build` checks before merge; require merge-group variants too if merge queue is enabled. diff --git a/package.json b/package.json index ecaf531a..41e02c72 100644 --- a/package.json +++ b/package.json @@ -63,20 +63,17 @@ "release-please": "tsx scripts/release-please-runner.ts" }, "devDependencies": { - "@ai-sdk/anthropic": "^4.0.0", "@biomejs/biome": "^1.9.4", "@happy-dom/global-registrator": "^15.11.0", "@types/bun": "^1.3.2", "@xterm/headless": "^5.5.0", "@xterm/xterm": "^5.5.0", - "ai": "^7.0.2", "mitata": "^1.0.34", "prettier": "^3.6.2", "release-please": "17.9.0", "tsx": "^4.22.4", "typescript": "^5.9.3", "vite": "^4.5.0", - "vite-plugin-dts": "^4.5.4", - "zod": "^4.4.3" + "vite-plugin-dts": "^4.5.4" } } diff --git a/release-please-config.json b/release-please-config.json index c80e04f7..b4e6d6d4 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -1,7 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", "release-type": "node", - "changelog-type": "ai", "include-component-in-tag": false, "include-v-in-tag": true, "bump-minor-pre-major": true, diff --git a/scripts/release-please-ai/changelog-notes.test.ts b/scripts/release-please-ai/changelog-notes.test.ts deleted file mode 100644 index 15b340db..00000000 --- a/scripts/release-please-ai/changelog-notes.test.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { describe, expect, test } from 'bun:test'; -import type { BuildNotesOptions, ChangelogNotes } from 'release-please/build/src/changelog-notes'; -import type { ConventionalCommit } from 'release-please/build/src/commit'; -import { AiChangelogNotes } from './changelog-notes'; - -const options: BuildNotesOptions = { - owner: 'coder', - repository: 'ghostty-web', - version: '1.2.3', - currentTag: 'v1.2.3', - targetBranch: 'main', - changelogSections: [{ type: 'feat', section: 'Features' }], -}; - -const commits: ConventionalCommit[] = [ - { - sha: 'abc123', - message: 'feat: add renderer support', - files: [], - type: 'feat', - scope: null, - notes: [], - references: [ - { action: null, owner: null, repository: null, issue: '17', raw: '#17', prefix: '#' }, - ], - bareMessage: 'add renderer support', - breaking: false, - }, -]; - -class FakeDefaultNotes implements ChangelogNotes { - async buildNotes(): Promise { - return '## [1.2.3](link)\n\n### Features\n- add renderer support'; - } -} - -describe('AiChangelogNotes', () => { - test('returns default release-please notes when ANTHROPIC_API_KEY is missing', async () => { - const notes = new AiChangelogNotes({ - defaultNotes: new FakeDefaultNotes(), - env: {}, - generate: async () => { - throw new Error('should not call the model without credentials'); - }, - }); - - await expect(notes.buildNotes(commits, options)).resolves.toBe( - '## [1.2.3](link)\n\n### Features\n- add renderer support' - ); - }); - - test('injects mocked editorial notes when model generation succeeds', async () => { - const notes = new AiChangelogNotes({ - defaultNotes: new FakeDefaultNotes(), - env: { ANTHROPIC_API_KEY: 'test-key', RELEASE_NOTES_MODEL: 'test-model' }, - generate: async ({ commits: visible }) => { - expect(visible).toHaveLength(1); - return { - summary: 'Renderer support improves terminal integrations.', - highlights: [{ text: 'Renderer support', prNumber: 17 }], - }; - }, - }); - - await expect(notes.buildNotes(commits, options)).resolves.toBe( - '## [1.2.3](link)\n\nRenderer support improves terminal integrations.\n\n**Highlights**\n\n- Renderer support (#17)\n\n### Features\n- add renderer support' - ); - }); - test('falls back to default release-please notes when model generation fails', async () => { - const notes = new AiChangelogNotes({ - defaultNotes: new FakeDefaultNotes(), - env: { ANTHROPIC_API_KEY: 'test-key', RELEASE_NOTES_MODEL: 'test-model' }, - logger: { log() {}, warn() {} }, - generate: async () => { - throw new Error('model unavailable'); - }, - }); - - await expect(notes.buildNotes(commits, options)).resolves.toBe( - '## [1.2.3](link)\n\n### Features\n- add renderer support' - ); - }); -}); diff --git a/scripts/release-please-ai/changelog-notes.ts b/scripts/release-please-ai/changelog-notes.ts deleted file mode 100644 index dd23066e..00000000 --- a/scripts/release-please-ai/changelog-notes.ts +++ /dev/null @@ -1,91 +0,0 @@ -import type { BuildNotesOptions, ChangelogNotes } from 'release-please/build/src/changelog-notes'; -import { DefaultChangelogNotes } from 'release-please/build/src/changelog-notes/default'; -import type { ConventionalCommit } from 'release-please/build/src/commit'; -import { - type ChangelogNotesFactoryOptions, - registerChangelogNotes, -} from 'release-please/build/src/factories/changelog-notes-factory'; -import { generateEditorial } from './generate'; -import { injectAfterHeader, renderEditorial, visibleCommits } from './sections'; -import type { GenerateEditorial } from './types'; - -export const AI_CHANGELOG_TYPE = 'ai'; - -type Env = Pick; - -export interface AiChangelogNotesOptions { - defaultNotes?: ChangelogNotes; - env?: Env; - generate?: GenerateEditorial; - logger?: Pick; -} - -export class AiChangelogNotes implements ChangelogNotes { - private readonly defaultNotes: ChangelogNotes; - private readonly env: Env; - private readonly generate: GenerateEditorial; - private readonly logger: Pick; - - constructor(options: AiChangelogNotesOptions = {}) { - this.defaultNotes = options.defaultNotes ?? new DefaultChangelogNotes(); - this.env = options.env ?? process.env; - this.generate = options.generate ?? generateEditorial; - this.logger = options.logger ?? console; - } - - async buildNotes(commits: ConventionalCommit[], options: BuildNotesOptions): Promise { - const defaultNotes = await this.defaultNotes.buildNotes(commits, options); - const apiKey = this.env.ANTHROPIC_API_KEY; - const model = this.env.RELEASE_NOTES_MODEL; - - if (!apiKey) { - this.logger.log( - 'Release notes AI disabled: ANTHROPIC_API_KEY is not configured; using default notes.' - ); - return defaultNotes; - } - if (!model) { - this.logger.warn( - 'Release notes AI disabled: RELEASE_NOTES_MODEL is not configured; using default notes.' - ); - return defaultNotes; - } - - const visible = visibleCommits(commits, options.changelogSections); - if (visible.length === 0) { - this.logger.log('Release notes AI skipped: no visible commits; using default notes.'); - return defaultNotes; - } - - try { - const editorial = await this.generate({ - commits: visible, - owner: options.owner, - repository: options.repository, - version: options.version, - model, - githubToken: this.env.GITHUB_TOKEN, - }); - const rendered = renderEditorial(editorial); - this.logger.log('Release notes AI generated editorial summary.'); - return injectAfterHeader(defaultNotes, rendered); - } catch (error) { - this.logger.warn( - `Release notes AI failed; using default notes. ${error instanceof Error ? error.message : String(error)}` - ); - return defaultNotes; - } - } -} - -export function registerAiChangelogNotes(): void { - registerChangelogNotes(AI_CHANGELOG_TYPE, (options: ChangelogNotesFactoryOptions) => { - return new AiChangelogNotes({ - defaultNotes: new DefaultChangelogNotes({ - commitPartial: options.commitPartial, - headerPartial: options.headerPartial, - mainTemplate: options.mainTemplate, - }), - }); - }); -} diff --git a/scripts/release-please-ai/generate.ts b/scripts/release-please-ai/generate.ts deleted file mode 100644 index b3c69acf..00000000 --- a/scripts/release-please-ai/generate.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { createAnthropic } from '@ai-sdk/anthropic'; -import { Output, ToolLoopAgent, stepCountIs } from 'ai'; -import { buildReleaseNotesPrompt } from './prompt'; -import { createReleaseInspectionTools } from './tools'; -import { type Editorial, type GenerateEditorialInput, editorialSchema } from './types'; - -export async function generateEditorial(input: GenerateEditorialInput): Promise { - if (!input.model) { - throw new Error('RELEASE_NOTES_MODEL is required when ANTHROPIC_API_KEY is set'); - } - - const anthropic = createAnthropic({ apiKey: process.env.ANTHROPIC_API_KEY }); - const tools = createReleaseInspectionTools({ - commits: input.commits, - owner: input.owner, - repository: input.repository, - githubToken: input.githubToken, - }); - const agent = new ToolLoopAgent({ - model: anthropic(input.model), - tools, - toolChoice: 'auto', - stopWhen: stepCountIs(6), - output: Output.object({ - schema: editorialSchema, - name: 'ghosttyWebReleaseNotesEditorial', - description: 'Concise editorial release notes summary and highlights.', - }), - instructions: - 'You are writing release notes for ghostty-web. Inspect relevant commit diffs with the provided tools before producing the final structured output.', - }); - - const result = await agent.generate({ - prompt: buildReleaseNotesPrompt(input.commits, input.version), - }); - return result.output; -} diff --git a/scripts/release-please-ai/prompt.test.ts b/scripts/release-please-ai/prompt.test.ts deleted file mode 100644 index 8f078db0..00000000 --- a/scripts/release-please-ai/prompt.test.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { describe, expect, test } from 'bun:test'; -import type { ConventionalCommit } from 'release-please/build/src/commit'; -import { buildReleaseNotesPrompt } from './prompt'; - -function commit(): ConventionalCommit { - return { - sha: 'abc123def456', - message: 'feat(renderer): improve cursor contrast (#42)', - files: [], - type: 'feat', - scope: 'renderer', - notes: [], - references: [ - { action: null, owner: null, repository: null, issue: '42', raw: '#42', prefix: '#' }, - ], - bareMessage: 'improve cursor contrast', - breaking: false, - }; -} - -describe('buildReleaseNotesPrompt', () => { - test('directs the model to inspect diffs with tools instead of relying on commit titles only', () => { - const prompt = buildReleaseNotesPrompt([commit()], '1.2.3'); - - expect(prompt).toContain('Call `listReleaseCommits`'); - expect(prompt).toContain('`inspectCommit`'); - expect(prompt).toContain('abc123def456'); - expect(prompt).toContain('"prNumber": 42'); - expect(prompt).not.toContain('- feat(renderer): improve cursor contrast'); - }); -}); diff --git a/scripts/release-please-ai/prompt.ts b/scripts/release-please-ai/prompt.ts deleted file mode 100644 index aced8848..00000000 --- a/scripts/release-please-ai/prompt.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { ConventionalCommit } from 'release-please/build/src/commit'; -import { summarizeReleaseCommits } from './tools'; - -export function buildReleaseNotesPrompt(commits: ConventionalCommit[], version: string): string { - return [ - `Write concise editorial release notes for ghostty-web ${version}.`, - '', - 'Audience: engineers using a browser terminal emulator, integrating WASM terminal parsing, Canvas rendering, keyboard/input handling, selection, PTY demo tooling, or xterm.js-compatible APIs.', - 'Explain what changed and why it matters. Be factual and sparse when commit titles are sparse.', - 'Highlight user-visible terminal rendering, input/keyboard protocol, WASM/VT parsing, selection/clipboard, demo/server usability, performance, and compatibility changes.', - 'Skip pure internal chores, CI, tests, formatting, and release automation unless they directly affect users.', - '', - 'Call `listReleaseCommits` first, then call `inspectCommit` for notable or ambiguous changes so the summary is based on actual diffs rather than commit titles alone.', - 'Use only PR numbers returned by the tools; do not guess PR numbers.', - 'Return only the structured summary/highlights object requested by the output schema.', - '', - 'Release commit scope:', - JSON.stringify(summarizeReleaseCommits(commits), null, 2), - ].join('\n'); -} diff --git a/scripts/release-please-ai/render.test.ts b/scripts/release-please-ai/render.test.ts deleted file mode 100644 index fdd53500..00000000 --- a/scripts/release-please-ai/render.test.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { describe, expect, test } from 'bun:test'; -import { injectAfterHeader, renderEditorial } from './sections'; - -describe('renderEditorial', () => { - test('renders flattened summary and linked highlights', () => { - expect( - renderEditorial({ - summary: 'First line\n## not a heading', - highlights: [ - { text: 'Adds rendering fix\nwith details', prNumber: 42 }, - { text: 'No PR link', prNumber: null }, - ], - }) - ).toBe( - 'First line ## not a heading\n\n**Highlights**\n\n- Adds rendering fix with details (#42)\n- No PR link' - ); - }); - - test('omits an empty highlight list', () => { - expect(renderEditorial({ summary: 'Only summary', highlights: [] })).toBe('Only summary'); - }); -}); - -describe('injectAfterHeader', () => { - test('injects editorial notes immediately below the version heading', () => { - expect(injectAfterHeader('## [1.0.0](link)\n\n### Features\n- one', 'Summary')).toBe( - '## [1.0.0](link)\n\nSummary\n\n### Features\n- one' - ); - }); - - test('falls back safely when release-please notes have no heading', () => { - expect(injectAfterHeader('### Features\n- one', 'Summary')).toBe( - 'Summary\n\n### Features\n- one' - ); - }); -}); diff --git a/scripts/release-please-ai/sections.test.ts b/scripts/release-please-ai/sections.test.ts deleted file mode 100644 index 8a10d24c..00000000 --- a/scripts/release-please-ai/sections.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { describe, expect, test } from 'bun:test'; -import type { ChangelogSection } from 'release-please/build/src/changelog-notes'; -import type { ConventionalCommit } from 'release-please/build/src/commit'; -import { visibleCommits } from './sections'; - -function commit(type: string, bareMessage = `${type}: message`): ConventionalCommit { - return { - sha: `sha-${type}`, - message: bareMessage, - files: [], - type, - scope: null, - notes: [], - references: [], - bareMessage, - breaking: false, - }; -} - -describe('visibleCommits', () => { - test('filters commits whose configured changelog section is hidden', () => { - const sections: ChangelogSection[] = [ - { type: 'feat', section: 'Features' }, - { type: 'fix', section: 'Bug Fixes' }, - { type: 'chore', section: 'Chores', hidden: true }, - { type: 'ci', section: 'CI', hidden: true }, - ]; - - expect( - visibleCommits([commit('feat'), commit('chore'), commit('fix'), commit('ci')], sections).map( - (c) => c.type - ) - ).toEqual(['feat', 'fix']); - }); - - test('uses the ghostty-web visible type allowlist when sections are absent', () => { - expect( - visibleCommits( - [commit('docs'), commit('build'), commit('deps'), commit('test')], - undefined - ).map((c) => c.type) - ).toEqual(['docs', 'deps']); - }); -}); diff --git a/scripts/release-please-ai/sections.ts b/scripts/release-please-ai/sections.ts deleted file mode 100644 index 76ffed3d..00000000 --- a/scripts/release-please-ai/sections.ts +++ /dev/null @@ -1,84 +0,0 @@ -import type { ChangelogSection } from 'release-please/build/src/changelog-notes'; -import type { ConventionalCommit } from 'release-please/build/src/commit'; -import type { Editorial } from './types'; - -const DEFAULT_VISIBLE_TYPES = new Set([ - 'feat', - 'fix', - 'perf', - 'revert', - 'deps', - 'docs', - 'refactor', -]); - -export function visibleCommits( - commits: ConventionalCommit[], - sections?: ChangelogSection[] -): ConventionalCommit[] { - if (!sections?.length) { - return commits.filter((commit) => DEFAULT_VISIBLE_TYPES.has(commit.type)); - } - - const visibleTypes = new Set( - sections.filter((section) => !section.hidden).map((section) => section.type) - ); - return commits.filter((commit) => visibleTypes.has(commit.type)); -} - -function flattenMarkdownLine(value: string): string { - return value - .replace(/[\r\n]+/g, ' ') - .replace(/\s+/g, ' ') - .trim(); -} - -export function renderEditorial(editorial: Editorial): string { - const summary = flattenMarkdownLine(editorial.summary); - const highlights = editorial.highlights - .map((highlight) => ({ - text: flattenMarkdownLine(highlight.text), - prNumber: highlight.prNumber, - })) - .filter((highlight) => highlight.text.length > 0) - .slice(0, 5); - - if (highlights.length === 0) { - return summary; - } - - return [ - summary, - '', - '**Highlights**', - '', - ...highlights.map( - (highlight) => `- ${highlight.text}${highlight.prNumber ? ` (#${highlight.prNumber})` : ''}` - ), - ].join('\n'); -} - -export function injectAfterHeader(defaultNotes: string, editorialMarkdown: string): string { - const editorial = editorialMarkdown.trim(); - if (!editorial) { - return defaultNotes; - } - - const match = defaultNotes.match(/^(##\s+[^\n]+)\n+/); - if (!match) { - return `${editorial}\n\n${defaultNotes}`; - } - - return `${match[1]}\n\n${editorial}\n\n${defaultNotes.slice(match[0].length)}`; -} - -export function firstPullRequestNumber(commit: ConventionalCommit): number | null { - for (const reference of commit.references ?? []) { - const issue = Number.parseInt(reference.issue, 10); - if (Number.isInteger(issue) && issue > 0) { - return issue; - } - } - const prNumber = commit.pullRequest?.number; - return Number.isInteger(prNumber) && prNumber > 0 ? prNumber : null; -} diff --git a/scripts/release-please-ai/tools.test.ts b/scripts/release-please-ai/tools.test.ts deleted file mode 100644 index b1305f9f..00000000 --- a/scripts/release-please-ai/tools.test.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { describe, expect, test } from 'bun:test'; -import type { ConventionalCommit } from 'release-please/build/src/commit'; -import { createReleaseInspectionTools } from './tools'; - -function commit(): ConventionalCommit { - return { - sha: 'abc123', - message: 'fix: render cursor accent (#9)', - files: [], - type: 'fix', - scope: null, - notes: [], - references: [ - { action: null, owner: null, repository: null, issue: '9', raw: '#9', prefix: '#' }, - ], - bareMessage: 'render cursor accent', - breaking: false, - }; -} - -describe('createReleaseInspectionTools', () => { - test('lists scoped release commits for the agent', async () => { - const tools = createReleaseInspectionTools({ - commits: [commit()], - owner: 'coder', - repository: 'ghostty-web', - fetch: async () => new Response('{}'), - }); - - const result = await tools.listReleaseCommits.execute({}, {} as never); - - expect(result).toEqual([ - { - sha: 'abc123', - type: 'fix', - scope: null, - message: 'render cursor accent', - prNumber: 9, - }, - ]); - }); - - test('inspects only allowed release commit diffs and truncates patches', async () => { - const tools = createReleaseInspectionTools({ - commits: [commit()], - owner: 'coder', - repository: 'ghostty-web', - fetch: async (url) => { - expect(String(url)).toContain('/repos/coder/ghostty-web/commits/abc123'); - return Response.json({ - sha: 'abc123', - commit: { message: 'fix: render cursor accent (#9)' }, - files: [ - { - filename: 'lib/renderer.ts', - status: 'modified', - additions: 10, - deletions: 2, - patch: `${'x'.repeat(5000)}\nend`, - }, - ], - }); - }, - }); - - const result = await tools.inspectCommit.execute({ sha: 'abc123' }, {} as never); - - expect(result.sha).toBe('abc123'); - expect(result.files).toHaveLength(1); - expect(result.files[0].patch.length).toBeLessThan(4200); - expect(result.files[0].patch).toContain('…'); - }); - - test('rejects commits outside the release scope', async () => { - const tools = createReleaseInspectionTools({ - commits: [commit()], - owner: 'coder', - repository: 'ghostty-web', - fetch: async () => { - throw new Error('should not fetch unknown commits'); - }, - }); - - await expect(tools.inspectCommit.execute({ sha: 'unknown' }, {} as never)).rejects.toThrow( - 'not part of this release' - ); - }); -}); diff --git a/scripts/release-please-ai/tools.ts b/scripts/release-please-ai/tools.ts deleted file mode 100644 index d083430a..00000000 --- a/scripts/release-please-ai/tools.ts +++ /dev/null @@ -1,120 +0,0 @@ -import { tool } from 'ai'; -import type { ConventionalCommit } from 'release-please/build/src/commit'; -import { z } from 'zod'; -import { firstPullRequestNumber } from './sections'; - -const MAX_FILES = 12; -const MAX_PATCH_CHARS = 4_000; -const MAX_TOTAL_PATCH_CHARS = 16_000; - -export interface ReleaseInspectionToolsOptions { - commits: ConventionalCommit[]; - owner: string; - repository: string; - githubToken?: string; - fetch?: typeof fetch; -} - -interface GitHubCommitFile { - filename: string; - status?: string; - additions?: number; - deletions?: number; - patch?: string; -} - -interface GitHubCommitResponse { - sha: string; - commit?: { message?: string }; - files?: GitHubCommitFile[]; -} - -function truncate(value: string, maxLength: number): string { - if (value.length <= maxLength) { - return value; - } - return `${value.slice(0, maxLength)}\n… truncated …`; -} - -function summarizeCommit(commit: ConventionalCommit) { - return { - sha: commit.sha, - type: commit.type, - scope: commit.scope, - message: commit.bareMessage, - prNumber: firstPullRequestNumber(commit), - }; -} - -export function summarizeReleaseCommits( - commits: ConventionalCommit[] -): ReturnType[] { - return commits.map(summarizeCommit); -} - -export function createReleaseInspectionTools(options: ReleaseInspectionToolsOptions) { - const commitsBySha = new Map(options.commits.map((commit) => [commit.sha, commit])); - const fetchImpl = options.fetch ?? fetch; - - return { - listReleaseCommits: tool({ - description: 'List the release commits that may be inspected for this changelog.', - inputSchema: z.object({}), - execute: async () => summarizeReleaseCommits(options.commits), - }), - inspectCommit: tool({ - description: - 'Fetch a scoped GitHub commit diff for one release commit. Use this before writing notes for non-trivial changes.', - inputSchema: z.object({ - sha: z.string().describe('One SHA returned by listReleaseCommits.'), - }), - execute: async ({ sha }) => { - const commit = commitsBySha.get(sha); - if (!commit) { - throw new Error(`Commit ${sha} is not part of this release.`); - } - - const headers: Record = { - Accept: 'application/vnd.github+json', - 'X-GitHub-Api-Version': '2022-11-28', - }; - if (options.githubToken) { - headers.Authorization = `Bearer ${options.githubToken}`; - } - - const response = await fetchImpl( - `https://api.github.com/repos/${options.owner}/${options.repository}/commits/${sha}`, - { headers } - ); - if (!response.ok) { - throw new Error( - `GitHub commit lookup failed for ${sha}: ${response.status} ${response.statusText}` - ); - } - - const data = (await response.json()) as GitHubCommitResponse; - let totalPatchChars = 0; - const files = (data.files ?? []).slice(0, MAX_FILES).map((file) => { - const remaining = Math.max(0, MAX_TOTAL_PATCH_CHARS - totalPatchChars); - const patch = truncate(file.patch ?? '', Math.min(MAX_PATCH_CHARS, remaining)); - totalPatchChars += patch.length; - return { - filename: file.filename, - status: file.status ?? 'modified', - additions: file.additions ?? 0, - deletions: file.deletions ?? 0, - patch, - }; - }); - - return { - sha: data.sha || sha, - message: data.commit?.message || commit.message, - releaseSummary: summarizeCommit(commit), - files, - truncatedFiles: Math.max(0, (data.files?.length ?? 0) - files.length), - }; - }, - }), - }; -} diff --git a/scripts/release-please-ai/types.ts b/scripts/release-please-ai/types.ts deleted file mode 100644 index 1b28271c..00000000 --- a/scripts/release-please-ai/types.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { ConventionalCommit } from 'release-please/build/src/commit'; -import { z } from 'zod'; - -export const editorialSchema = z.object({ - summary: z.string(), - highlights: z - .array( - z.object({ - text: z.string(), - prNumber: z.number().int().positive().nullable(), - }) - ) - .default([]), -}); - -export type Editorial = z.infer; - -export interface GenerateEditorialInput { - commits: ConventionalCommit[]; - owner: string; - repository: string; - version: string; - model: string; - githubToken?: string; -} - -export type GenerateEditorial = (input: GenerateEditorialInput) => Promise; diff --git a/scripts/release-please-runner.ts b/scripts/release-please-runner.ts index 8258afb8..fb7e54fa 100644 --- a/scripts/release-please-runner.ts +++ b/scripts/release-please-runner.ts @@ -1,7 +1,6 @@ import { appendFileSync } from 'node:fs'; import { createRequire } from 'node:module'; import type { BaseStrategyOptions } from 'release-please/build/src/strategies/base'; -import { registerAiChangelogNotes } from './release-please-ai/changelog-notes'; const nodeRequire = createRequire(import.meta.url); @@ -61,7 +60,6 @@ async function registerReleasePleaseExtensions(): Promise { } } - registerAiChangelogNotes(); registerReleaseType( 'node', (options: BaseStrategyOptions) => new GhosttyWebNodeStrategy(options)