opencode-github-pr 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +331 -2
- package/demo/demo.gif +0 -0
- package/demo/fixtures.ts +158 -0
- package/package.json +56 -4
- package/plugins/app/DashboardView.tsx +290 -0
- package/plugins/app/PRRow.tsx +209 -0
- package/plugins/app/actions.tsx +25 -0
- package/plugins/app/config.ts +85 -0
- package/plugins/app/theme.ts +62 -0
- package/plugins/app/usePRData.ts +193 -0
- package/plugins/domain/format.ts +38 -0
- package/plugins/domain/login.ts +33 -0
- package/plugins/domain/messages.ts +161 -0
- package/plugins/domain/pr-filters.ts +40 -0
- package/plugins/domain/pr-links.ts +12 -0
- package/plugins/domain/pr-status.ts +127 -0
- package/plugins/domain/types.ts +77 -0
- package/plugins/infra/git.ts +156 -0
- package/plugins/infra/github-enterprise.ts +31 -0
- package/plugins/infra/loader.ts +123 -0
- package/plugins/infra/mappers.ts +117 -0
- package/plugins/infra/octokit.ts +115 -0
- package/plugins/infra/queries.ts +69 -0
- package/plugins/pr-dashboard.ts +8 -0
- package/plugins/pr-dashboard.tui.tsx +154 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Duncan Williams
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,332 @@
|
|
|
1
|
-
#
|
|
1
|
+
# opencode-github-pr
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A GitHub pull request dashboard for the [OpenCode](https://opencode.ai) V2 sidebar. See your PRs for the current
|
|
4
|
+
repository, their CI, review and merge status, and jump straight to the right page on GitHub, without leaving OpenCode.
|
|
5
|
+
|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **PR list in the sidebar** for the repository of the active session, refreshed automatically.
|
|
11
|
+
- **Status at a glance:** mergeability, CI checks, reviews and unresolved review comments on every row.
|
|
12
|
+
- **Click-through to GitHub:** each part of a row opens the matching GitHub page (overview, checks, files or merge
|
|
13
|
+
status).
|
|
14
|
+
- **Filters:** show PRs for the current branch, authored by you, assigned to you, or all of them, and choose open,
|
|
15
|
+
closed or all states.
|
|
16
|
+
- **Follows your theme:** colours come from your active OpenCode theme, and every colour and icon can be overridden.
|
|
17
|
+
- **Works with GitHub.com and GitHub Enterprise Server**, over HTTPS or SSH remotes, including linked Git worktrees.
|
|
18
|
+
|
|
19
|
+
## Requirements
|
|
20
|
+
|
|
21
|
+
- OpenCode **2.0.20 or later** (V2 plugin API).
|
|
22
|
+
- [Bun](https://bun.sh), to install the plugin's dependencies.
|
|
23
|
+
- A GitHub token, or the [GitHub CLI](https://cli.github.com) signed in with `gh auth login`. See
|
|
24
|
+
[Authentication](#authentication).
|
|
25
|
+
- A terminal font with [Nerd Font](https://www.nerdfonts.com) glyphs for the default icons. Without one, use
|
|
26
|
+
[plain icons](#plain-text-icons).
|
|
27
|
+
|
|
28
|
+
## Install from npm
|
|
29
|
+
|
|
30
|
+
Add the package name to the `plugins` array in your OpenCode config, either globally at
|
|
31
|
+
`~/.config/opencode/opencode.json` or in a project's `opencode.json`:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"$schema": "https://opencode.ai/config.json",
|
|
36
|
+
"plugins": ["opencode-github-pr"]
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Restart OpenCode. The **Pull Requests** panel appears in the session sidebar. Add the plugin to `opencode.json`, not
|
|
41
|
+
`cli.json`. The package has a server part and a TUI part; the TUI loads its part from the server's plugin list, including
|
|
42
|
+
when it is connected to a remote server.
|
|
43
|
+
|
|
44
|
+
## Install from source
|
|
45
|
+
|
|
46
|
+
1. Clone the repository and install its dependencies:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
git clone https://github.com/987poiuytrewq/opencode-github-pr.git
|
|
50
|
+
cd opencode-github-pr
|
|
51
|
+
bun install
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
2. Add the clone's absolute path to the `plugins` array in your OpenCode config, using the example above with
|
|
55
|
+
`"/absolute/path/to/opencode-github-pr"` as the plugin value.
|
|
56
|
+
|
|
57
|
+
3. Restart OpenCode.
|
|
58
|
+
|
|
59
|
+
## Authentication
|
|
60
|
+
|
|
61
|
+
The plugin looks for a token in this order:
|
|
62
|
+
|
|
63
|
+
1. `GITHUB_TOKEN`
|
|
64
|
+
2. `GH_TOKEN`
|
|
65
|
+
3. `GITHUB_PERSONAL_ACCESS_TOKEN`
|
|
66
|
+
4. `gh auth token` (for the Enterprise host when [`GITHUB_ENTERPRISE_URL`](#github-enterprise-server) is set)
|
|
67
|
+
|
|
68
|
+
If you already use the GitHub CLI, `gh auth login` is all you need. Environment variables must be set where the
|
|
69
|
+
OpenCode server process starts; a token exported in a different shell won't be seen.
|
|
70
|
+
|
|
71
|
+
The token only needs read access. The dashboard doesn't change anything on GitHub.
|
|
72
|
+
|
|
73
|
+
| Token type | What it needs |
|
|
74
|
+
| --- | --- |
|
|
75
|
+
| `gh auth login` | The default scopes are enough. |
|
|
76
|
+
| Classic personal access token | `repo` for private repositories; no scope for public ones. |
|
|
77
|
+
| Fine-grained personal access token | Read access to **Pull requests** and **Commit statuses** on the repositories you use. |
|
|
78
|
+
|
|
79
|
+
## Using the dashboard
|
|
80
|
+
|
|
81
|
+
The dashboard shows PRs for the repository the active session is working in. It finds the repository from the Git
|
|
82
|
+
remotes: `origin` first, then any other remote that points at GitHub (or your Enterprise host).
|
|
83
|
+
|
|
84
|
+
### Reading a row
|
|
85
|
+
|
|
86
|
+
Each PR takes two lines. The first has a PR icon and the title. The second has the PR number, the lines added
|
|
87
|
+
and removed, and on the right, the unresolved comment count, review status and check status.
|
|
88
|
+
|
|
89
|
+
| Element | Meaning | Click opens |
|
|
90
|
+
| --- | --- | --- |
|
|
91
|
+
| PR icon | Green: ready to merge. Red: merge conflict. Grey: draft, closed or unknown. Theme accent: merged. | Merge status panel |
|
|
92
|
+
| Title | The PR title, shortened to fit the sidebar. | PR overview |
|
|
93
|
+
| `#128` | PR number. | PR overview |
|
|
94
|
+
| `+42 -7` | Lines added and removed. | Files changed |
|
|
95
|
+
| Comment icon and count | Unresolved review threads. Hidden when there are none. | Files changed |
|
|
96
|
+
| Review icon | Green: approved. Red: changes requested. Yellow: review requested. Grey: commented. | PR overview |
|
|
97
|
+
| Check dot | Green: passing. Red: failing. Yellow: pending. Grey: neutral or skipped. | Checks |
|
|
98
|
+
|
|
99
|
+
When reviews or checks are in more than one state, each state gets its own icon with a count, for example three green
|
|
100
|
+
dots and one red dot for three passing checks and one failing.
|
|
101
|
+
|
|
102
|
+
### Filters
|
|
103
|
+
|
|
104
|
+
The two labels at the top right of the panel are filters. Click one to cycle through its values.
|
|
105
|
+
|
|
106
|
+
| Filter | Values | Default |
|
|
107
|
+
| --- | --- | --- |
|
|
108
|
+
| Scope | `branch` (PRs from the current branch), `author` (opened by you), `assignee` (assigned to you), `all` | `author` |
|
|
109
|
+
| Status | `open`, `closed` (closed or merged), `all` | `open` |
|
|
110
|
+
|
|
111
|
+
You can change the defaults with [`defaultScope` and `defaultStatusFilter`](#configuration).
|
|
112
|
+
|
|
113
|
+
### Pages
|
|
114
|
+
|
|
115
|
+
The panel shows five PRs at a time. When there are more, use the arrows at the bottom of the panel to page through them.
|
|
116
|
+
|
|
117
|
+
### Commands
|
|
118
|
+
|
|
119
|
+
These commands are available as slash commands and in the command palette, under **PR Dashboard**:
|
|
120
|
+
|
|
121
|
+
| Slash command | Palette title | What it does |
|
|
122
|
+
| --- | --- | --- |
|
|
123
|
+
| `/pr-refresh` | PRs: Refresh dashboard | Reloads the PR list now. |
|
|
124
|
+
| `/pr-open` | PRs: Open selected in browser | Opens the PR you last clicked, or the first PR in the list. |
|
|
125
|
+
|
|
126
|
+
### Refreshing
|
|
127
|
+
|
|
128
|
+
The list refreshes when OpenCode starts, each time a session goes idle (for example after the agent finishes a task),
|
|
129
|
+
and every 60 seconds while a session is open. Use `/pr-refresh` to reload it on demand.
|
|
130
|
+
|
|
131
|
+
The dashboard loads the 100 most recently updated open PRs in the repository. Closed and merged PRs are loaded
|
|
132
|
+
separately, the first time you switch the status filter to `closed` or `all`, and then kept so switching back is
|
|
133
|
+
instant. Loading them separately means a backlog of closed PRs can't push open ones out of the list.
|
|
134
|
+
|
|
135
|
+
If a repository has more PRs than were loaded, the panel says so. Raise [`maxPRPages`](#configuration) to load more.
|
|
136
|
+
|
|
137
|
+
## Configuration
|
|
138
|
+
|
|
139
|
+
Pass options in the plugin entry's `options` object. Every option is optional:
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"$schema": "https://opencode.ai/config.json",
|
|
144
|
+
"plugins": [
|
|
145
|
+
{
|
|
146
|
+
"package": "/absolute/path/to/opencode-github-pr",
|
|
147
|
+
"options": {
|
|
148
|
+
"pageSize": 8,
|
|
149
|
+
"refreshIntervalMs": 30000,
|
|
150
|
+
"defaultScope": "all",
|
|
151
|
+
"defaultStatusFilter": "open"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
| Option | Default | Description |
|
|
159
|
+
| --- | --- | --- |
|
|
160
|
+
| `enabled` | `true` | Set to `false` to turn the dashboard off without uninstalling it. |
|
|
161
|
+
| `pageSize` | `5` | PRs shown per page. |
|
|
162
|
+
| `maxPRPages` | `1` | Pages of 100 PRs to load from GitHub for open PRs, and again for closed PRs when shown. `2` loads up to 200 of each. Higher values use more API quota. |
|
|
163
|
+
| `refreshIntervalMs` | `60000` | How often the list refreshes while a session is open, in milliseconds. |
|
|
164
|
+
| `requestTimeoutMs` | `15000` | How long to wait for a GitHub request before giving up, in milliseconds. |
|
|
165
|
+
| `defaultScope` | `"author"` | Scope filter at startup: `branch`, `author`, `assignee` or `all`. |
|
|
166
|
+
| `defaultStatusFilter` | `"open"` | Status filter at startup: `open`, `closed` or `all`. |
|
|
167
|
+
| `colors` | Theme | Colour overrides. See [Colours](#colours). |
|
|
168
|
+
| `icons` | Nerd Font glyphs | Icon overrides. See [Icons](#icons). |
|
|
169
|
+
|
|
170
|
+
Numeric options must be positive numbers. Invalid values fall back to the default.
|
|
171
|
+
|
|
172
|
+
### Colours
|
|
173
|
+
|
|
174
|
+
By default, colours come from your active OpenCode theme. Override any of them with a colour string such as
|
|
175
|
+
`"#a371f7"`:
|
|
176
|
+
|
|
177
|
+
| Key | Used for | Default theme token |
|
|
178
|
+
| --- | --- | --- |
|
|
179
|
+
| `panel` | Panel background | Background |
|
|
180
|
+
| `panelAlt` | Background of each row's second line | Raised background |
|
|
181
|
+
| `border` | Divider above the page controls | Border |
|
|
182
|
+
| `borderActive` | Divider while a page arrow is hovered | Primary action text |
|
|
183
|
+
| `text` | PR titles and the panel heading | Text |
|
|
184
|
+
| `muted` | Secondary text, neutral states | Muted text |
|
|
185
|
+
| `accent` | Hovered filters and page arrows | Primary action text |
|
|
186
|
+
| `success` | Passing checks, approvals, mergeable PRs, additions | Success text |
|
|
187
|
+
| `warning` | Pending checks, requested reviews, warnings | Warning text |
|
|
188
|
+
| `error` | Failing checks, requested changes, conflicts, deletions, errors | Error text |
|
|
189
|
+
| `draft` | Draft PR icon | Muted text |
|
|
190
|
+
| `merged` | Merged PR icon | Primary action text |
|
|
191
|
+
|
|
192
|
+
Colour and icon overrides go inside the plugin entry's `options`, next to the other options:
|
|
193
|
+
|
|
194
|
+
```json
|
|
195
|
+
{
|
|
196
|
+
"options": {
|
|
197
|
+
"colors": {
|
|
198
|
+
"merged": "#a371f7",
|
|
199
|
+
"panelAlt": "#1d1d1d"
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Icons
|
|
206
|
+
|
|
207
|
+
Every icon can be replaced with any non-empty string. The defaults are [Nerd Font](https://www.nerdfonts.com) glyphs:
|
|
208
|
+
|
|
209
|
+
| Key | Default | Used for |
|
|
210
|
+
| --- | --- | --- |
|
|
211
|
+
| `openPR` | `U+E726` | Open, draft and closed PRs |
|
|
212
|
+
| `mergedPR` | `U+E727` | Merged PRs |
|
|
213
|
+
| `review` | `U+F4FF` | Review status |
|
|
214
|
+
| `openComment` | `U+F017A` | Unresolved review threads |
|
|
215
|
+
| `check` | `●` | CI check status |
|
|
216
|
+
| `scope` | `U+F4D7` | Scope filter label |
|
|
217
|
+
| `status` | `U+E726` | Status filter label |
|
|
218
|
+
| `loading` | `U+F051F` | Loading message |
|
|
219
|
+
| `info` | `U+F129` | Informational messages |
|
|
220
|
+
| `error` | `U+E654` | Error messages |
|
|
221
|
+
| `previousPage` | `U+EB6F` | Previous page arrow |
|
|
222
|
+
| `nextPage` | `U+EB70` | Next page arrow |
|
|
223
|
+
|
|
224
|
+
#### Plain-text icons
|
|
225
|
+
|
|
226
|
+
If your terminal font has no Nerd Font glyphs, the default icons show as empty boxes. Replace them with plain
|
|
227
|
+
characters:
|
|
228
|
+
|
|
229
|
+
```json
|
|
230
|
+
{
|
|
231
|
+
"options": {
|
|
232
|
+
"icons": {
|
|
233
|
+
"openPR": "o",
|
|
234
|
+
"mergedPR": "m",
|
|
235
|
+
"review": "R",
|
|
236
|
+
"openComment": "C",
|
|
237
|
+
"check": "*",
|
|
238
|
+
"scope": "@",
|
|
239
|
+
"status": "~",
|
|
240
|
+
"loading": "...",
|
|
241
|
+
"info": "i",
|
|
242
|
+
"error": "!",
|
|
243
|
+
"previousPage": "<",
|
|
244
|
+
"nextPage": ">"
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## GitHub Enterprise Server
|
|
251
|
+
|
|
252
|
+
Set `GITHUB_ENTERPRISE_URL` where the OpenCode server starts:
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
export GITHUB_ENTERPRISE_URL="https://github.example.com"
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Use the server URL or its `/api/v3` URL; it must be HTTPS. The plugin then recognises remotes on that host, uses its
|
|
259
|
+
APIs, and asks `gh auth token` for that host's token. While it is set, github.com remotes aren't recognised. Leave it
|
|
260
|
+
unset for GitHub.com.
|
|
261
|
+
|
|
262
|
+
## Troubleshooting
|
|
263
|
+
|
|
264
|
+
| You see | What to do |
|
|
265
|
+
| --- | --- |
|
|
266
|
+
| No **Pull Requests** panel | Check that the plugin is in `opencode.json` (not `cli.json`), that `bun install` has run in the clone, and that `enabled` isn't `false`. Restart OpenCode. Plugin load errors are written to `~/.local/share/opencode/log/opencode.log`. |
|
|
267
|
+
| Icons show as boxes or question marks | Your font has no Nerd Font glyphs. Install one, or use [plain-text icons](#plain-text-icons). |
|
|
268
|
+
| **No GitHub repo** | The session's directory isn't a Git repository with a GitHub remote. Add a remote, or open a session in the right project. For Enterprise, check `GITHUB_ENTERPRISE_URL`. |
|
|
269
|
+
| **GitHub sign-in failed** | No valid token was found. Run `gh auth login`, or set `GITHUB_TOKEN` where the OpenCode server starts. |
|
|
270
|
+
| **Permission denied** or **Repo not found** | Your token can't read this repository. Check its scopes or fine-grained permissions, and SSO authorisation for organisation repositories. |
|
|
271
|
+
| **Rate limit exceeded** | GitHub's API limit has been reached. The panel shows when you can try again. Lower `maxPRPages` or raise `refreshIntervalMs` to use less quota. |
|
|
272
|
+
| **Request timed out** or **Cannot reach GitHub** | Check your connection or proxy. On slow networks, raise `requestTimeoutMs`. |
|
|
273
|
+
| **No matching PRs** | No PRs match the current filters. Click the scope or status label to widen them. |
|
|
274
|
+
| `branch` scope is empty | The current branch has no PR, or the session is in detached HEAD. |
|
|
275
|
+
|
|
276
|
+
## Development
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
bun install
|
|
280
|
+
make opencode
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
`make opencode` starts OpenCode on this checkout with the plugin loaded from it, using a temporary config so your own
|
|
284
|
+
OpenCode config isn't changed. It uses `GH_TOKEN`, `GITHUB_TOKEN` or `GITHUB_PERSONAL_ACCESS_TOKEN` if set, otherwise
|
|
285
|
+
`gh auth token`.
|
|
286
|
+
|
|
287
|
+
### Project layout
|
|
288
|
+
|
|
289
|
+
| Path | Contents |
|
|
290
|
+
| --- | --- |
|
|
291
|
+
| `plugins/pr-dashboard.ts` | Server part: plugin registration. |
|
|
292
|
+
| `plugins/pr-dashboard.tui.tsx` | TUI part: sidebar slot, commands and refresh scheduling. |
|
|
293
|
+
| `plugins/app/` | Solid UI components, options and theme handling. |
|
|
294
|
+
| `plugins/domain/` | Pure logic: filters, status rollups, formatting and messages. |
|
|
295
|
+
| `plugins/infra/` | Git remote detection, Octokit client and GitHub queries. |
|
|
296
|
+
| `tests/` | Unit, integration and end-to-end tests. |
|
|
297
|
+
| `demo/` | Demo recording script and fixtures. |
|
|
298
|
+
|
|
299
|
+
### Tests
|
|
300
|
+
|
|
301
|
+
| Command | Runs |
|
|
302
|
+
| --- | --- |
|
|
303
|
+
| `make test` | Everything below. |
|
|
304
|
+
| `make format-check` | Formatting, and checks that the first JSON example in this README is strict JSON. |
|
|
305
|
+
| `make typecheck` | TypeScript. |
|
|
306
|
+
| `make test-unit` | Unit tests. |
|
|
307
|
+
| `make test-integration` | Integration tests. |
|
|
308
|
+
| `make test-e2e` | End-to-end tests against a real OpenCode TUI in tmux. |
|
|
309
|
+
|
|
310
|
+
The end-to-end tests need `tmux` and the OpenCode CLI (version `2.0.20` by default). Point them at a different binary
|
|
311
|
+
with:
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
make test-e2e OPENCODE_BIN=/path/to/opencode
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
CI installs these with `make ci-tools` and runs `make ci` on every pull request.
|
|
318
|
+
|
|
319
|
+
### Recording the demo
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
make demo
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
This records the real OpenCode TUI with fictional PR data, then writes `demo/demo.cast` and `demo/demo.gif`. It needs
|
|
326
|
+
`asciinema`, `agg`, `tmux`, Bun and the OpenCode CLI. It runs in a temporary repository and home directory with GitHub
|
|
327
|
+
access turned off, so it doesn't touch your config or make network requests. Replay it with
|
|
328
|
+
`asciinema play demo/demo.cast`.
|
|
329
|
+
|
|
330
|
+
## License
|
|
331
|
+
|
|
332
|
+
[MIT](LICENSE)
|
package/demo/demo.gif
ADDED
|
Binary file
|
package/demo/fixtures.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DashboardStatus,
|
|
3
|
+
type DashboardState,
|
|
4
|
+
type PR,
|
|
5
|
+
} from "../plugins/domain/types";
|
|
6
|
+
|
|
7
|
+
function demoPR(overrides: Partial<PR> & Pick<PR, "number" | "title">): PR {
|
|
8
|
+
const { number, title, ...values } = overrides;
|
|
9
|
+
return {
|
|
10
|
+
number,
|
|
11
|
+
title,
|
|
12
|
+
url: `https://github.com/acme/launchpad/pull/${number}`,
|
|
13
|
+
isDraft: false,
|
|
14
|
+
isMerged: false,
|
|
15
|
+
isClosed: values.isClosed ?? values.isMerged ?? false,
|
|
16
|
+
headRefName: "feature/demo",
|
|
17
|
+
authorLogin: "octocat",
|
|
18
|
+
assigneeLogins: ["octocat"],
|
|
19
|
+
additions: 64,
|
|
20
|
+
deletions: 18,
|
|
21
|
+
baseRefName: "main",
|
|
22
|
+
mergeable: "MERGEABLE",
|
|
23
|
+
statusCheckRollup: { state: "SUCCESS" },
|
|
24
|
+
checkStatuses: ["SUCCESS"],
|
|
25
|
+
reviewThreads: [],
|
|
26
|
+
reviewRequests: [],
|
|
27
|
+
latestReviews: [],
|
|
28
|
+
...values,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const demoPRs: PR[] = [
|
|
33
|
+
demoPR({
|
|
34
|
+
number: 248,
|
|
35
|
+
title: "Add passkey sign-in",
|
|
36
|
+
headRefName: "feature/passkeys",
|
|
37
|
+
additions: 128,
|
|
38
|
+
deletions: 36,
|
|
39
|
+
reviewThreads: [{ isResolved: true }],
|
|
40
|
+
latestReviews: [{ author: { login: "samantha" }, state: "APPROVED" }],
|
|
41
|
+
}),
|
|
42
|
+
demoPR({
|
|
43
|
+
number: 247,
|
|
44
|
+
title: "Retry expired sessions",
|
|
45
|
+
assigneeLogins: ["mia"],
|
|
46
|
+
statusCheckRollup: { state: "FAILURE" },
|
|
47
|
+
checkStatuses: ["SUCCESS", "FAILURE"],
|
|
48
|
+
reviewRequests: [{ login: "alex" }],
|
|
49
|
+
reviewThreads: [{ isResolved: false }, { isResolved: true }],
|
|
50
|
+
}),
|
|
51
|
+
demoPR({
|
|
52
|
+
number: 246,
|
|
53
|
+
title: "Add audit log filters",
|
|
54
|
+
headRefName: "feature/audit-filters",
|
|
55
|
+
statusCheckRollup: { state: "PENDING" },
|
|
56
|
+
checkStatuses: ["SUCCESS", "IN_PROGRESS"],
|
|
57
|
+
latestReviews: [{ author: { login: "jules" }, state: "COMMENTED" }],
|
|
58
|
+
}),
|
|
59
|
+
demoPR({
|
|
60
|
+
number: 245,
|
|
61
|
+
title: "Improve keyboard navigation",
|
|
62
|
+
assigneeLogins: ["mia"],
|
|
63
|
+
latestReviews: [{ author: { login: "samantha" }, state: "APPROVED" }],
|
|
64
|
+
}),
|
|
65
|
+
demoPR({
|
|
66
|
+
number: 244,
|
|
67
|
+
title: "Cache organization membership",
|
|
68
|
+
statusCheckRollup: { state: "PENDING" },
|
|
69
|
+
checkStatuses: ["QUEUED"],
|
|
70
|
+
reviewRequests: [{ login: "jules" }],
|
|
71
|
+
}),
|
|
72
|
+
demoPR({
|
|
73
|
+
number: 243,
|
|
74
|
+
title: "Add CLI configuration hints",
|
|
75
|
+
assigneeLogins: ["mia"],
|
|
76
|
+
additions: 31,
|
|
77
|
+
deletions: 9,
|
|
78
|
+
}),
|
|
79
|
+
demoPR({
|
|
80
|
+
number: 242,
|
|
81
|
+
title: "Simplify session settings",
|
|
82
|
+
isDraft: true,
|
|
83
|
+
mergeable: "CONFLICTING",
|
|
84
|
+
statusCheckRollup: { state: "FAILURE" },
|
|
85
|
+
checkStatuses: ["FAILURE"],
|
|
86
|
+
assigneeLogins: ["octocat"],
|
|
87
|
+
}),
|
|
88
|
+
demoPR({
|
|
89
|
+
number: 241,
|
|
90
|
+
title: "Add workspace export",
|
|
91
|
+
headRefName: "feature/workspace-export",
|
|
92
|
+
authorLogin: "octocat",
|
|
93
|
+
assigneeLogins: ["samantha"],
|
|
94
|
+
statusCheckRollup: { state: "PENDING" },
|
|
95
|
+
checkStatuses: ["SUCCESS", "EXPECTED"],
|
|
96
|
+
}),
|
|
97
|
+
demoPR({
|
|
98
|
+
number: 240,
|
|
99
|
+
title: "Fix landing page contrast",
|
|
100
|
+
authorLogin: "mia",
|
|
101
|
+
assigneeLogins: ["octocat"],
|
|
102
|
+
additions: 12,
|
|
103
|
+
deletions: 7,
|
|
104
|
+
}),
|
|
105
|
+
demoPR({
|
|
106
|
+
number: 239,
|
|
107
|
+
title: "Prepare the v2.4 release",
|
|
108
|
+
isMerged: true,
|
|
109
|
+
isClosed: true,
|
|
110
|
+
latestReviews: [{ author: { login: "samantha" }, state: "APPROVED" }],
|
|
111
|
+
}),
|
|
112
|
+
demoPR({
|
|
113
|
+
number: 238,
|
|
114
|
+
title: "Remove legacy auth fallback",
|
|
115
|
+
authorLogin: "jules",
|
|
116
|
+
assigneeLogins: ["octocat"],
|
|
117
|
+
isClosed: true,
|
|
118
|
+
mergeable: "CONFLICTING",
|
|
119
|
+
statusCheckRollup: { state: "FAILURE" },
|
|
120
|
+
checkStatuses: ["FAILURE"],
|
|
121
|
+
}),
|
|
122
|
+
demoPR({
|
|
123
|
+
number: 237,
|
|
124
|
+
title: "Streamline onboarding",
|
|
125
|
+
isMerged: true,
|
|
126
|
+
isClosed: true,
|
|
127
|
+
latestReviews: [{ author: { login: "mia" }, state: "APPROVED" }],
|
|
128
|
+
}),
|
|
129
|
+
];
|
|
130
|
+
|
|
131
|
+
export function demoDashboardState(): DashboardState {
|
|
132
|
+
return {
|
|
133
|
+
status: DashboardStatus.Ok,
|
|
134
|
+
repo: { owner: "acme", repo: "launchpad" },
|
|
135
|
+
prs: demoPRs.map((pr) => ({
|
|
136
|
+
...pr,
|
|
137
|
+
assigneeLogins: [...pr.assigneeLogins],
|
|
138
|
+
checkStatuses: pr.checkStatuses ? [...pr.checkStatuses] : null,
|
|
139
|
+
reviewThreads: pr.reviewThreads
|
|
140
|
+
? pr.reviewThreads.map((thread) => ({ ...thread }))
|
|
141
|
+
: null,
|
|
142
|
+
reviewRequests: pr.reviewRequests
|
|
143
|
+
? pr.reviewRequests.map((request) => ({ ...request }))
|
|
144
|
+
: null,
|
|
145
|
+
latestReviews: pr.latestReviews
|
|
146
|
+
? pr.latestReviews.map((review) => ({
|
|
147
|
+
...review,
|
|
148
|
+
author: { ...review.author },
|
|
149
|
+
}))
|
|
150
|
+
: null,
|
|
151
|
+
})),
|
|
152
|
+
currentBranch: "feature/passkeys",
|
|
153
|
+
viewerLogin: "octocat",
|
|
154
|
+
fetchedAt: 0,
|
|
155
|
+
closedLoaded: true,
|
|
156
|
+
truncated: { open: false, closed: false },
|
|
157
|
+
};
|
|
158
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-github-pr",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "GitHub pull request dashboard for the OpenCode sidebar: CI, review and merge status for your PRs.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"opencode",
|
|
7
|
+
"opencode-plugin",
|
|
8
|
+
"github",
|
|
9
|
+
"pull-requests",
|
|
10
|
+
"tui"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/987poiuytrewq/opencode-github-pr.git"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/987poiuytrewq/opencode-github-pr#readme",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/987poiuytrewq/opencode-github-pr/issues"
|
|
20
|
+
},
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": "./plugins/pr-dashboard.ts",
|
|
24
|
+
"./tui": "./plugins/pr-dashboard.tui.tsx"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"plugins/",
|
|
28
|
+
"demo/fixtures.ts",
|
|
29
|
+
"demo/demo.gif",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"test": "make test",
|
|
35
|
+
"test:unit": "make test-unit",
|
|
36
|
+
"test:integration": "make test-integration",
|
|
37
|
+
"test:e2e": "make test-e2e",
|
|
38
|
+
"test:watch": "make test-watch",
|
|
39
|
+
"typecheck": "make typecheck",
|
|
40
|
+
"format:check": "make format-check"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/bun": "latest",
|
|
44
|
+
"bun-types": "latest",
|
|
45
|
+
"typescript": "^5.9.3"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@octokit/plugin-retry": "^8.1.0",
|
|
49
|
+
"@octokit/plugin-throttling": "^11.0.3",
|
|
50
|
+
"@octokit/rest": "^22.0.1",
|
|
51
|
+
"@opencode/plugin": "2.0.20",
|
|
52
|
+
"@opencode/theme": "2.0.20",
|
|
53
|
+
"@opentui/core": "0.6.6",
|
|
54
|
+
"@opentui/solid": "0.6.6",
|
|
55
|
+
"open": "^11.0.4",
|
|
56
|
+
"solid-js": "^1.9.14"
|
|
57
|
+
}
|
|
58
|
+
}
|