@@ -6,34 +6,6 @@ import { Script } from "@opencode-ai/script" |
6 | 6 |
|
7 | 7 | const notes = [] as string[] |
8 | 8 |
|
9 | | -const team = [ |
10 | | - "actions-user", |
11 | | - "opencode", |
12 | | - "rekram1-node", |
13 | | - "thdxr", |
14 | | - "kommander", |
15 | | - "jayair", |
16 | | - "fwang", |
17 | | - "adamdotdevin", |
18 | | - "iamdavidhill", |
19 | | - "opencode-agent[bot]", |
20 | | -] |
21 | | - |
22 | | -function getAreaFromPath(file: string): string { |
23 | | - if (file.startsWith("packages/")) { |
24 | | - const parts = file.replace("packages/", "").split("/") |
25 | | - if (parts[0] === "extensions" && parts[1]) return `extensions/${parts[1]}` |
26 | | - return parts[0] || "other" |
27 | | - } |
28 | | - if (file.startsWith("sdks/")) { |
29 | | - const name = file.replace("sdks/", "").split("/")[0] || "other" |
30 | | - return `extensions/${name}` |
31 | | - } |
32 | | - const rootDir = file.split("/")[0] |
33 | | - if (rootDir && !rootDir.includes(".")) return rootDir |
34 | | - return "other" |
35 | | -} |
36 | | - |
37 | 9 | console.log("=== publishing ===\n") |
38 | 10 |
|
39 | 11 | if (!Script.preview) { |
@@ -44,59 +16,13 @@ if (!Script.preview) { |
44 | 16 | }) |
45 | 17 | .then((data: any) => data.version) |
46 | 18 |
|
47 | | - // Fetch commit authors from GitHub API (hash -> login) |
48 | | - const compare = |
49 | | - await $`gh api "/repos/sst/opencode/compare/v${previous}...HEAD" --jq '.commits[] | {sha: .sha, login: .author.login, message: .commit.message}'`.text() |
50 | | - const authorByHash = new Map<string, string>() |
51 | | - const contributors = new Map<string, string[]>() |
| 19 | + const log = |
| 20 | + await $`git log v${previous}..HEAD --oneline --format="%h %s" -- packages/opencode packages/sdk packages/plugin packages/tauri packages/desktop`.text() |
52 | 21 |
|
53 | | - for (const line of compare.split("\n").filter(Boolean)) { |
54 | | - const { sha, login, message } = JSON.parse(line) as { sha: string; login: string | null; message: string } |
55 | | - const shortHash = sha.slice(0, 7) |
56 | | - if (login) authorByHash.set(shortHash, login) |
57 | | - |
58 | | - const title = message.split("\n")[0] || "" |
59 | | - if (title.match(/^(ignore:|test:|chore:|ci:|release:)/i)) continue |
60 | | - if (login && !team.includes(login)) { |
61 | | - if (!contributors.has(login)) contributors.set(login, []) |
62 | | - contributors.get(login)?.push(title) |
63 | | - } |
64 | | - } |
65 | | - |
66 | | - // Batch-fetch files for all commits (hash -> areas) |
67 | | - const diffLog = await $`git log v${previous}..HEAD --name-only --format="%h"`.text() |
68 | | - const areasByHash = new Map<string, Set<string>>() |
69 | | - let currentHash: string | null = null |
70 | | - |
71 | | - for (const rawLine of diffLog.split("\n")) { |
72 | | - const line = rawLine.trim() |
73 | | - if (!line) continue |
74 | | - if (/^[0-9a-f]{7}$/i.test(line)) { |
75 | | - currentHash = line |
76 | | - if (!areasByHash.has(currentHash)) areasByHash.set(currentHash, new Set()) |
77 | | - continue |
78 | | - } |
79 | | - if (currentHash) { |
80 | | - areasByHash.get(currentHash)!.add(getAreaFromPath(line)) |
81 | | - } |
82 | | - } |
83 | | - |
84 | | - // Build commit lines with author and areas |
85 | | - const log = await $`git log v${previous}..HEAD --oneline --format="%h %s"`.text() |
86 | | - const commitLines = log.split("\n").filter((line) => line && !line.match(/^\w+ (ignore:|test:|chore:|ci:|release:)/i)) |
87 | | - |
88 | | - const commitsWithMeta = commitLines |
89 | | - .map((line) => { |
90 | | - const hash = line.split(" ")[0] |
91 | | - if (!hash) return null |
92 | | - const author = authorByHash.get(hash) |
93 | | - const authorStr = author ? ` [author: ${author}]` : "" |
94 | | - const areas = areasByHash.get(hash) |
95 | | - const areaStr = areas && areas.size > 0 ? ` [areas: ${[...areas].join(", ")}]` : " [areas: other]" |
96 | | - return `${line}${authorStr}${areaStr}` |
97 | | - }) |
98 | | - .filter(Boolean) as string[] |
99 | | - const commits = commitsWithMeta.join("\n") |
| 22 | + const commits = log |
| 23 | + .split("\n") |
| 24 | + .filter((line) => line && !line.match(/^\w+ (ignore:|test:|chore:|ci:)/i)) |
| 25 | + .join("\n") |
100 | 26 |
|
101 | 27 | const opencode = await createOpencode() |
102 | 28 | const session = await opencode.client.session.create() |
@@ -109,72 +35,37 @@ if (!Script.preview) { |
109 | 35 | body: { |
110 | 36 | model: { |
111 | 37 | providerID: "opencode", |
112 | | - modelID: "gemini-3-flash", |
| 38 | + modelID: "claude-haiku-4-5", |
113 | 39 | }, |
114 | 40 | parts: [ |
115 | 41 | { |
116 | 42 | type: "text", |
117 | 43 | text: ` |
118 | | -Analyze these commits and generate a changelog of all notable user facing changes, grouped by area. |
119 | | -
|
120 | | -Each commit below includes: |
121 | | -- [author: username] showing the GitHub username of the commit author |
122 | | -- [areas: ...] showing which areas of the codebase were modified |
123 | | -
|
124 | | -Commits between ${previous} and HEAD: |
125 | | -${commits} |
126 | | -
|
127 | | -Group the changes into these categories based on the [areas: ...] tags (omit any category with no changes): |
128 | | -- **TUI**: Changes to "opencode" area (the terminal/CLI interface) |
129 | | -- **Desktop**: Changes to "desktop" or "tauri" areas (the desktop application) |
130 | | -- **SDK**: Changes to "sdk" or "plugin" areas (the SDK and plugin system) |
131 | | -- **Extensions**: Changes to "extensions/zed", "extensions/vscode", or "github" areas (editor extensions and GitHub Action) |
132 | | -- **Other**: Any user-facing changes that don't fit the above categories |
133 | | -
|
134 | | -Excluded areas (omit these entirely unless they contain user-facing changes like refactors that may affect behavior): |
135 | | -- "nix", "infra", "script" - CI/build infrastructure |
136 | | -- "ui", "docs", "web", "console", "enterprise", "function", "util", "identity", "slack" - internal packages |
137 | | -
|
138 | | -Rules: |
139 | | -- Use the [areas: ...] tags to determine the correct category. If a commit touches multiple areas, put it in the most relevant user-facing category. |
140 | | -- ONLY include commits that have user-facing impact. Omit purely internal changes (CI, build scripts, internal tooling). |
141 | | -- However, DO include refactors that touch user-facing code - refactors can introduce bugs or change behavior. |
142 | | -- Do NOT make general statements about "improvements", be very specific about what was changed. |
143 | | -- For commits that are already well-written and descriptive, avoid rewording them. Simply capitalize the first letter, fix any misspellings, and ensure proper English grammar. |
144 | | -- DO NOT read any other commits than the ones listed above (THIS IS IMPORTANT TO AVOID DUPLICATING THINGS IN OUR CHANGELOG). |
145 | | -- If a commit was made and then reverted do not include it in the changelog. If the commits only include a revert but not the original commit, then include the revert in the changelog. |
146 | | -- Omit categories that have no changes. |
147 | | -- For community contributors: if the [author: username] is NOT in the team list, add (@username) at the end of the changelog entry. This is REQUIRED for all non-team contributors. |
148 | | -- The team members are: ${team.join(", ")}. Do NOT add @ mentions for team members. |
149 | | -
|
150 | | -IMPORTANT: ONLY return the grouped changelog, do not include any other information. Do not include a preamble like "Based on my analysis..." or "Here is the changelog..." |
151 | | -
|
152 | | -<example> |
153 | | -## TUI |
154 | | -- Added experimental support for the Ty language server (@OpeOginni) |
155 | | -- Added /fork slash command for keyboard-friendly session forking (@ariane-emory) |
156 | | -- Increased retry attempts for failed requests |
157 | | -- Fixed model validation before executing slash commands (@devxoul) |
158 | | -
|
159 | | -## Desktop |
160 | | -- Added shell mode support |
161 | | -- Fixed prompt history navigation and optimistic prompt duplication |
162 | | -- Disabled pinch-to-zoom on Linux (@Brendonovich) |
163 | | -
|
164 | | -## Extensions |
165 | | -- Added OIDC_BASE_URL support for custom GitHub App installations (@elithrar) |
166 | | -</example> |
167 | | -`, |
| 44 | + Analyze these commits and generate a changelog of all notable user facing changes. |
| 45 | +
|
| 46 | + Commits between ${previous} and HEAD: |
| 47 | + ${commits} |
| 48 | +
|
| 49 | + - Do NOT make general statements about "improvements", be very specific about what was changed. |
| 50 | + - Do NOT include any information about code changes if they do not affect the user facing changes. |
| 51 | + - For commits that are already well-written and descriptive, avoid rewording them. Simply capitalize the first letter, fix any misspellings, and ensure proper English grammar. |
| 52 | + - DO NOT read any other commits than the ones listed above (THIS IS IMPORTANT TO AVOID DUPLICATING THINGS IN OUR CHANGELOG) |
| 53 | + - If a commit was made and then reverted do not include it in the changelog. If the commits only include a revert but not the original commit, then include the revert in the changelog. |
| 54 | +
|
| 55 | + IMPORTANT: ONLY return a bulleted list of changes, do not include any other information. Do not include a preamble like "Based on my analysis..." |
| 56 | +
|
| 57 | + <example> |
| 58 | + - Added ability to @ mention agents |
| 59 | + - Fixed a bug where the TUI would render improperly on some terminals |
| 60 | + </example> |
| 61 | + `, |
168 | 62 | }, |
169 | 63 | ], |
170 | 64 | }, |
171 | 65 | }) |
172 | 66 | .then((x) => x.data?.parts?.find((y) => y.type === "text")?.text) |
173 | 67 | for (const line of raw?.split("\n") ?? []) { |
174 | | - if (line.startsWith("## ")) { |
175 | | - if (notes.length > 0) notes.push("") |
176 | | - notes.push(line) |
177 | | - } else if (line.startsWith("- ")) { |
| 68 | + if (line.startsWith("- ")) { |
178 | 69 | notes.push(line) |
179 | 70 | } |
180 | 71 | } |
@@ -183,11 +74,42 @@ IMPORTANT: ONLY return the grouped changelog, do not include any other informati |
183 | 74 | console.log("-----------------------------") |
184 | 75 | opencode.server.close() |
185 | 76 |
|
| 77 | + // Get contributors |
| 78 | + const team = [ |
| 79 | + "actions-user", |
| 80 | + "opencode", |
| 81 | + "rekram1-node", |
| 82 | + "thdxr", |
| 83 | + "kommander", |
| 84 | + "jayair", |
| 85 | + "fwang", |
| 86 | + "adamdotdevin", |
| 87 | + "iamdavidhill", |
| 88 | + "opencode-agent[bot]", |
| 89 | + ] |
| 90 | + const compare = |
| 91 | + await $`gh api "/repos/sst/opencode/compare/v${previous}...HEAD" --jq '.commits[] | {login: .author.login, message: .commit.message}'`.text() |
| 92 | + const contributors = new Map<string, string[]>() |
| 93 | + |
| 94 | + for (const line of compare.split("\n").filter(Boolean)) { |
| 95 | + const { login, message } = JSON.parse(line) as { login: string | null; message: string } |
| 96 | + const title = message.split("\n")[0] ?? "" |
| 97 | + if (title.match(/^(ignore:|test:|chore:|ci:|release:)/i)) continue |
| 98 | + |
| 99 | + if (login && !team.includes(login)) { |
| 100 | + if (!contributors.has(login)) contributors.set(login, []) |
| 101 | + contributors.get(login)?.push(title) |
| 102 | + } |
| 103 | + } |
| 104 | + |
186 | 105 | if (contributors.size > 0) { |
187 | 106 | notes.push("") |
188 | 107 | notes.push(`**Thank you to ${contributors.size} community contributor${contributors.size > 1 ? "s" : ""}:**`) |
189 | | - for (const username of contributors.keys()) { |
190 | | - notes.push(`- @${username}`) |
| 108 | + for (const [username, userCommits] of contributors) { |
| 109 | + notes.push(`- @${username}:`) |
| 110 | + for (const commit of userCommits) { |
| 111 | + notes.push(` - ${commit}`) |
| 112 | + } |
191 | 113 | } |
192 | 114 | } |
193 | 115 | } |
|