|
1 | 1 | #!/usr/bin/env bun |
2 | 2 |
|
3 | 3 | import { $ } from "bun" |
4 | | - |
| 4 | +import { createOpencodeClient, createOpencodeServer } from "@opencode-ai/sdk" |
5 | 5 | if (process.versions.bun !== "1.2.21") { |
6 | 6 | throw new Error("This script requires bun@1.2.21") |
7 | 7 | } |
@@ -66,30 +66,48 @@ if (!snapshot) { |
66 | 66 | }) |
67 | 67 | .then((data) => data.tag_name) |
68 | 68 |
|
69 | | - console.log("finding commits between", previous, "and", "HEAD") |
70 | | - const commits = await fetch(`https://api.github.com/repos/sst/opencode/compare/${previous}...HEAD`) |
71 | | - .then((res) => res.json()) |
72 | | - .then((data) => data.commits || []) |
73 | | - |
74 | | - const raw = commits.map((commit: any) => `- ${commit.commit.message.split("\n").join(" ")}`) |
75 | | - console.log(raw) |
76 | | - |
77 | | - const notes = |
78 | | - raw |
79 | | - .filter((x: string) => { |
80 | | - const lower = x.toLowerCase() |
81 | | - return ( |
82 | | - !lower.includes("release:") && |
83 | | - !lower.includes("ignore:") && |
84 | | - !lower.includes("chore:") && |
85 | | - !lower.includes("ci:") && |
86 | | - !lower.includes("wip:") && |
87 | | - !lower.includes("docs:") && |
88 | | - !lower.includes("doc:") |
89 | | - ) |
90 | | - }) |
91 | | - .join("\n") || "No notable changes" |
92 | | - |
| 69 | + const server = await createOpencodeServer() |
| 70 | + const client = createOpencodeClient({ baseUrl: server.url }) |
| 71 | + const session = await client.session.create() |
| 72 | + console.log("generating changelog since " + previous) |
| 73 | + const notes = await client.session |
| 74 | + .prompt({ |
| 75 | + path: { |
| 76 | + id: session.data!.id, |
| 77 | + }, |
| 78 | + body: { |
| 79 | + parts: [ |
| 80 | + { |
| 81 | + type: "text", |
| 82 | + text: ` |
| 83 | + Analyze the commits between ${previous} and HEAD. |
| 84 | +
|
| 85 | + We care about changes to |
| 86 | + - packages/opencode |
| 87 | + - packages/sdk |
| 88 | + - packages/plugin |
| 89 | +
|
| 90 | + We do not care about anything else |
| 91 | +
|
| 92 | + Return a changelog of all notable user facing changes. |
| 93 | +
|
| 94 | + - Do NOT make general statements about "improvements", be very specific about what was changed. |
| 95 | + - Do NOT include any information about code changes if they do not affect the user facing changes. |
| 96 | + |
| 97 | + IMPORTANT: ONLY return a bulleted list of changes, do not include any other information. Do not include a preamble like "Based on my analysis..." |
| 98 | +
|
| 99 | + <example> |
| 100 | + - Added ability to @ mention agents |
| 101 | + - Fixed a bug where the TUI would render improperly on some terminals |
| 102 | + </example> |
| 103 | + `, |
| 104 | + }, |
| 105 | + ], |
| 106 | + }, |
| 107 | + }) |
| 108 | + .then((x) => x.data?.parts?.find((y) => y.type === "text")?.text) |
| 109 | + console.log(notes) |
| 110 | + server.close() |
93 | 111 | await $`gh release create v${version} --title "v${version}" --notes ${notes} ./packages/opencode/dist/*.zip` |
94 | 112 | } |
95 | 113 | if (snapshot) { |
|
0 commit comments