@openmuster/muster 0.0.0-stage → 0.3.1-alpha.3
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 +201 -0
- package/README.md +309 -2
- package/dist/args-DX9QSK1f.js +7043 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +31 -0
- package/dist/index.d.ts +2138 -0
- package/dist/index.js +1951 -0
- package/dist/inspect/app.js +163 -0
- package/dist/main-CdVlnWHy.js +6 -0
- package/dist/main-DgrIMbeA.js +3941 -0
- package/dist/mcp-NueWYyQs.js +6 -0
- package/dist/module-C-HJjWWo.js +4 -0
- package/dist/module-CxoN1MOe.js +439 -0
- package/dist/skills/board/SKILL.md +214 -0
- package/dist/skills/board/references/build-a-ui.md +63 -0
- package/dist/skills/board/references/claude.md +54 -0
- package/dist/skills/board/references/codex.md +61 -0
- package/dist/skills/board/references/software-factory.md +89 -0
- package/dist/skills/board/references/swarm.md +165 -0
- package/dist/skills/configure-factory/SKILL.md +116 -0
- package/dist/skills/loop-card/SKILL.md +95 -0
- package/dist/steps-DtzUdcBE.js +3175 -0
- package/docs/01-concepts/01-overview.md +78 -0
- package/docs/01-concepts/02-boards.md +71 -0
- package/docs/01-concepts/03-channels.md +56 -0
- package/docs/01-concepts/04-threads.md +73 -0
- package/docs/01-concepts/05-labels.md +65 -0
- package/docs/01-concepts/06-actors.md +66 -0
- package/docs/01-concepts/07-events.md +133 -0
- package/docs/01-concepts/08-tasks.md +248 -0
- package/docs/01-concepts/09-watchers.md +175 -0
- package/docs/01-concepts/10-schedules.md +39 -0
- package/docs/01-concepts/11-access.md +185 -0
- package/docs/01-concepts/12-files-and-data.md +79 -0
- package/docs/01-concepts/13-budgets.md +35 -0
- package/docs/01-concepts/14-runners.md +103 -0
- package/docs/01-concepts/15-outgoing-webhooks.md +177 -0
- package/docs/01-concepts/16-workflows.md +350 -0
- package/docs/01-concepts/17-board-module.md +124 -0
- package/docs/01-quickstart.md +140 -0
- package/docs/02-sync/01-overview.md +246 -0
- package/docs/02-sync/02-github.md +159 -0
- package/docs/02-sync/03-linear.md +290 -0
- package/docs/02-sync/04-slack.md +228 -0
- package/docs/02-sync/05-notion.md +94 -0
- package/docs/02-sync/meta.json +4 -0
- package/docs/03-guides/01-coding-agents.md +98 -0
- package/docs/03-guides/02-swarm.md +85 -0
- package/docs/03-guides/03-factory.md +212 -0
- package/docs/03-guides/04-inspector.md +69 -0
- package/docs/03-guides/05-running-agents.md +85 -0
- package/docs/03-guides/06-sandboxed-agents.md +427 -0
- package/docs/03-guides/07-build-a-ui.md +80 -0
- package/docs/03-guides/08-ci.md +176 -0
- package/docs/03-guides/09-daemon.md +104 -0
- package/docs/03-guides/10-two-agents.md +76 -0
- package/docs/03-guides/11-person-in-the-loop.md +123 -0
- package/docs/03-guides/12-unattended.md +110 -0
- package/docs/03-guides/13-terminals.md +152 -0
- package/docs/03-guides/14-no-cloud.md +82 -0
- package/docs/03-guides/15-several-boards.md +90 -0
- package/docs/03-guides/16-non-code.md +78 -0
- package/docs/03-guides/17-mcp.md +122 -0
- package/docs/03-guides/18-a-board-on-a-server.md +162 -0
- package/docs/03-guides/19-a-card-queue.md +261 -0
- package/docs/03-guides/20-a-feedback-loop.md +233 -0
- package/docs/03-guides/21-running-the-loop.md +203 -0
- package/docs/03-guides/22-building-from-linear.md +326 -0
- package/docs/03-guides/meta.json +32 -0
- package/docs/04-reference/01-cli.md +166 -0
- package/docs/04-reference/02-handle.md +410 -0
- package/docs/04-reference/03-http.md +158 -0
- package/docs/04-reference/04-events.md +72 -0
- package/docs/04-reference/05-errors.md +221 -0
- package/docs/04-reference/06-conformance.md +54 -0
- package/docs/04-reference/07-porting.md +116 -0
- package/docs/index.md +118 -0
- package/docs/meta.json +3 -0
- package/package.json +52 -3
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Integrations
|
|
3
|
+
description: Bring GitHub, Linear, Slack and Notion threads onto the board for agents to read and wait on, and send the board's replies back. Webhooks, secrets, what goes back where, files, filters and catch-up after downtime.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Each platform has its own page: [GitHub](./02-github.md), [Linear](./03-linear.md), [Slack](./04-slack.md) and [Notion](./05-notion.md). To put sync to work, start from a guide: [Building from Linear](../03-guides/22-building-from-linear.md), [A feedback loop](../03-guides/20-a-feedback-loop.md), [A software factory](../03-guides/03-factory.md) or [CI](../03-guides/08-ci.md).
|
|
7
|
+
|
|
8
|
+
## What it does
|
|
9
|
+
|
|
10
|
+
A platform thread (an issue, a pull request, a Slack thread, a Notion page)
|
|
11
|
+
becomes a board thread in the channel you map it to. What people write there
|
|
12
|
+
arrives as replies, written by their platform identity (`gh:user:nico`). What
|
|
13
|
+
is written on the board goes back, where the mapping mirrors.
|
|
14
|
+
|
|
15
|
+
## How an event arrives
|
|
16
|
+
|
|
17
|
+
```mermaid
|
|
18
|
+
sequenceDiagram
|
|
19
|
+
participant G as Platform
|
|
20
|
+
participant S as mu serve
|
|
21
|
+
participant B as Board
|
|
22
|
+
participant A as Agent
|
|
23
|
+
G->>S: webhook: a new issue
|
|
24
|
+
S->>S: check the signature
|
|
25
|
+
S->>B: store in the inbox
|
|
26
|
+
S-->>G: 200
|
|
27
|
+
S->>B: import: a thread in the mapped channel
|
|
28
|
+
A->>B: mu reply ...
|
|
29
|
+
B->>G: the reply, as a comment
|
|
30
|
+
G->>S: webhook: that comment
|
|
31
|
+
S->>S: it is ours: ignored
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
1. The platform posts a webhook to `mu serve` at
|
|
35
|
+
`/api/board/webhooks/<name>`.
|
|
36
|
+
2. The board checks the platform's signature. A request without a valid one is
|
|
37
|
+
refused and nothing is stored.
|
|
38
|
+
3. The event is stored in an inbox, and only then is the platform answered. If
|
|
39
|
+
storing fails the answer is 500, so the platform sends it again.
|
|
40
|
+
4. The event is imported at once. If that fails it stays in the inbox and the
|
|
41
|
+
ticker tries again, a platform thread at a time, so one bad event holds only
|
|
42
|
+
its own thread.
|
|
43
|
+
|
|
44
|
+
Importing an event twice does nothing: a redelivery, or the same event under a
|
|
45
|
+
new delivery ID, changes nothing.
|
|
46
|
+
|
|
47
|
+
## In a board module
|
|
48
|
+
|
|
49
|
+
Sync is yours: it is declared in a [board module](../01-concepts/17-board-module.md),
|
|
50
|
+
one entry per platform account, under a name you choose. The name is in the
|
|
51
|
+
webhook URL and in the authors' IDs. `env('NAME')` names a secret: nothing is
|
|
52
|
+
read when the module is imported, so `mu daemon status`, a test or a build can
|
|
53
|
+
load it without the secrets. The board reads them when it starts
|
|
54
|
+
(`team.start()`, `mu serve`, `mu daemon run`) or takes its first request
|
|
55
|
+
(`team.fetch`).
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { board, env, github, linear, notion, slack } from '@openmuster/muster'
|
|
59
|
+
|
|
60
|
+
export default board({
|
|
61
|
+
sync: {
|
|
62
|
+
gh: github({
|
|
63
|
+
secret: env('GITHUB_WEBHOOK_SECRET'),
|
|
64
|
+
token: env('GITHUB_TOKEN'),
|
|
65
|
+
bot: 'your-app[bot]',
|
|
66
|
+
repos: { 'acme/web': { issues: 'web/issues', pulls: 'web/prs', mirror: true } },
|
|
67
|
+
filter: ['/Users/ada/bin/scrub.sh'],
|
|
68
|
+
}),
|
|
69
|
+
lin: linear({ secret: env('LINEAR_WEBHOOK_SECRET'), token: env('LINEAR_API_KEY'), teams: { ENG: 'eng' } }),
|
|
70
|
+
chat: slack({ secret: env('SLACK_SIGNING_SECRET'), token: env('SLACK_BOT_TOKEN'), channels: { C0123456789: 'general' } }),
|
|
71
|
+
nt: notion({ secret: env('NOTION_WEBHOOK_SECRET'), token: env('NOTION_TOKEN'), databases: { '1a2b3c4d00004000800000000000d00b': 'feedback' } }),
|
|
72
|
+
},
|
|
73
|
+
})
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
- **A variable that isn't set, or is empty, stops the sync, by name.**
|
|
77
|
+
`start()` throws `GITHUB_WEBHOOK_SECRET isn't set, and sync "gh" needs it.`
|
|
78
|
+
`mu serve` says so and exits 1 before it serves anything. `mu daemon run`
|
|
79
|
+
says so and exits 0, so the service stays stopped. `team.fetch` goes on
|
|
80
|
+
serving the board, says it in its log, and answers a webhook with a plain
|
|
81
|
+
503 and `health` with 503 `unhealthy`. Neither answer names the variable.
|
|
82
|
+
- **`token`** sends things back, catches up and fetches files. Without one,
|
|
83
|
+
GitHub, Linear and Slack still bring in what their webhooks carry. A GitHub
|
|
84
|
+
App ([GitHub](./02-github.md#who-the-comments-are-by)) or a Linear OAuth
|
|
85
|
+
app ([Linear](./03-linear.md#who-the-comments-are-by)) can take its place.
|
|
86
|
+
Notion needs it for everything, since its webhooks say only what changed.
|
|
87
|
+
**`bot`** is the app's own identity on the platform, so its writes aren't
|
|
88
|
+
imported as someone else's.
|
|
89
|
+
- **The module's sync runs where the module is started**, under the board's
|
|
90
|
+
`sync` lease, so one process at a time catches up and sends to the
|
|
91
|
+
platforms, whichever runs the watchers. Each message is also claimed on the
|
|
92
|
+
board before it goes, so it is sent once. `mu daemon status` lists each
|
|
93
|
+
sync, the variables it reads, and who holds the lease.
|
|
94
|
+
- **`team.fetch` alone takes webhooks and imports them.** It never catches
|
|
95
|
+
up, fetches files or sends anything back: something has to `start()` the
|
|
96
|
+
module (your `host.ts`, `mu serve` or `mu daemon run`).
|
|
97
|
+
- **`env()` is never text.** Turned into a string it throws, and a secret
|
|
98
|
+
written as `"env:NAME"` or `"env('NAME')"` is refused: either would be a key
|
|
99
|
+
anyone reading the module could sign with.
|
|
100
|
+
- **A `sync.json` from before is not read.** `mu serve` and `mu daemon run`
|
|
101
|
+
refuse to start while it is there. Move its entries into the module and
|
|
102
|
+
delete it: [Porting](../04-reference/07-porting.md#syncjson) has each field.
|
|
103
|
+
- **A secret written as a string** works, and puts the secret in the module's
|
|
104
|
+
file. Name it with `env()`.
|
|
105
|
+
|
|
106
|
+
## What goes back
|
|
107
|
+
|
|
108
|
+
| | Comes in | Goes back |
|
|
109
|
+
| --- | --- | --- |
|
|
110
|
+
| [GitHub](./02-github.md) | Issues, pull requests, comments, reviews, CI | Only where a repo sets `mirror` |
|
|
111
|
+
| [Linear](./03-linear.md) | Issues, comments, state, labels, assignee, priority, project | Yes, unless a team sets `mirror: false` |
|
|
112
|
+
| [Slack](./04-slack.md) | Channel messages and thread replies | Yes, unless a channel sets `mirror: false` |
|
|
113
|
+
| [Notion](./05-notion.md) | Pages in a database, their Status, comments | Yes, unless a database sets `mirror: false` |
|
|
114
|
+
|
|
115
|
+
- **Replies** in a synced thread are posted on the platform once, and the copy
|
|
116
|
+
that comes back as a webhook is not imported again.
|
|
117
|
+
- **Threads started on the board** in a mapped channel open an issue, post
|
|
118
|
+
to the Slack channel, or make a Notion page, and their replies follow them
|
|
119
|
+
there.
|
|
120
|
+
- **Edits and deletes** follow a message to its copy, in both directions,
|
|
121
|
+
except out to Linear, which keeps a comment as first sent. Going out they
|
|
122
|
+
are best effort: a platform that refuses one is skipped.
|
|
123
|
+
- **`--no-sync`** on a message keeps it on the board.
|
|
124
|
+
- **Labels and reactions never leave the board.** A platform's own labels
|
|
125
|
+
and assignees come in, as `tag.*` and `assignee.*` on the thread: see
|
|
126
|
+
[GitHub](./02-github.md#what-it-is-filed-under) and [Linear](./03-linear.md).
|
|
127
|
+
|
|
128
|
+
A sync makes threads, not tasks. `mu tasks create <id>` makes one a task.
|
|
129
|
+
|
|
130
|
+
## Files
|
|
131
|
+
|
|
132
|
+
Files on a message follow it where the platform allows. Experimental: file
|
|
133
|
+
sync has not yet been run against a live account.
|
|
134
|
+
|
|
135
|
+
| | Comes in | Goes back |
|
|
136
|
+
| --- | --- | --- |
|
|
137
|
+
| [Slack](./04-slack.md) | Files on a message | Uploaded, and shared into the thread after the text |
|
|
138
|
+
| [Linear](./03-linear.md) | Files uploaded to Linear and linked from the text | Uploaded to Linear, and linked from the text |
|
|
139
|
+
| [GitHub](./02-github.md) | No: a link to an attachment stays in the text | No: GitHub has no upload API. The text names each file |
|
|
140
|
+
| [Notion](./05-notion.md) | No | No: each file is named in the comment, and stays on the board |
|
|
141
|
+
|
|
142
|
+
The rules are the same for each platform:
|
|
143
|
+
|
|
144
|
+
- **A file comes only from the platform's own file host**: `files.slack.com`
|
|
145
|
+
or `uploads.linear.app`, over https, with no redirect followed. A link to
|
|
146
|
+
anywhere else stays text and is never fetched, so a message can't make the
|
|
147
|
+
board fetch an address of its choosing. The platform's token goes only to
|
|
148
|
+
that host.
|
|
149
|
+
- **The same limits as `--attach`**: up to 10 files of up to 25 MB each.
|
|
150
|
+
The board stops reading a file as soon as it passes 25 MB.
|
|
151
|
+
- **A day's allowance per sync.** Anyone who can post in a synced place can
|
|
152
|
+
send files, so each sync brings in at most 500 MB of them a day (UTC).
|
|
153
|
+
Past that a file is named, not stored, and one with no size given is not
|
|
154
|
+
even fetched. Bytes count when they are stored, so deleting the message
|
|
155
|
+
gives none back. Set `filesPerDayMB` on the sync, `github({ ..., filesPerDayMB: 100 })`,
|
|
156
|
+
to change it.
|
|
157
|
+
- **Any content type.** The board keeps the type as data and only ever hands
|
|
158
|
+
a file out as bytes: it never shows one in a page.
|
|
159
|
+
- **Nothing is lost without a word.** A file that is too big, on another
|
|
160
|
+
host, or that the platform would not hand over is named in a line at the
|
|
161
|
+
end of the text: `[file not imported: core.dump: 26.0 MB, over 25 MB]`.
|
|
162
|
+
Going out it reads `[file not sent: ...]`.
|
|
163
|
+
- **No credential is kept.** What the board stores is the file, its name,
|
|
164
|
+
type and size. A file's platform URL leaves with the rest of the webhook
|
|
165
|
+
once it is imported.
|
|
166
|
+
- **Once each way.** A file is fetched once, when its message is new: a
|
|
167
|
+
message the board already has, or one it sent, fetches nothing, and the
|
|
168
|
+
board knows the files it uploaded when they come back. Nothing is fetched
|
|
169
|
+
for a place that isn't mapped.
|
|
170
|
+
|
|
171
|
+
A webhook is answered first and its files are fetched on the next tick of
|
|
172
|
+
`mu serve` or the daemon, so a message with files arrives a moment after the
|
|
173
|
+
rest. Replies after it in its thread wait for it. A tick fetches up to
|
|
174
|
+
50 MB, and leaves the rest for the next one. A file that fails is tried
|
|
175
|
+
again on five ticks, alone: the files that came are kept. Then the message
|
|
176
|
+
comes without it and says so.
|
|
177
|
+
|
|
178
|
+
Files added or removed by an edit don't follow it. Deleting a message on the
|
|
179
|
+
board doesn't remove the files it put in a Slack thread.
|
|
180
|
+
|
|
181
|
+
## When delivery fails
|
|
182
|
+
|
|
183
|
+
A delivery that fails is tried again on the next tick, and the messages after
|
|
184
|
+
it wait their turn. After five tries the board records a `sync.failed` event on
|
|
185
|
+
the thread, with the platform's answer, and the next message goes.
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
mu tail web/ --type sync.failed
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## A filter for what comes in
|
|
192
|
+
|
|
193
|
+
`filter` names a command of yours, `filter: ['/Users/ada/bin/scrub.sh']`, or is
|
|
194
|
+
a function `(text) => string | null`. Text on its way in is given to the
|
|
195
|
+
command on stdin; what it prints is kept, and a non-zero exit drops the event. Use it to
|
|
196
|
+
strip secrets, or text written to steer an agent.
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
#!/bin/sh
|
|
200
|
+
# Drop anything that carries a GitHub token; keep the rest as it is.
|
|
201
|
+
text=$(cat)
|
|
202
|
+
case "$text" in *ghp_*) exit 1 ;; esac
|
|
203
|
+
printf %s "$text"
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
It runs with `PATH` and `HOME` only. It sees a message's text, not the names
|
|
207
|
+
of a platform's labels or assignees, which come in as labels.
|
|
208
|
+
|
|
209
|
+
The filter sees the text, with the lines that name files not imported. It
|
|
210
|
+
never sees a file or a file's name. So it decides first: a message it drops
|
|
211
|
+
fetches nothing, and a message whose text it changes keeps none of its
|
|
212
|
+
files, and says so: `[files not imported: the filter changed this message]`.
|
|
213
|
+
Text it passes as it is, give or take a final newline, keeps its files.
|
|
214
|
+
|
|
215
|
+
## After downtime
|
|
216
|
+
|
|
217
|
+
Platforms resend what wasn't answered, for a while. Beyond that, the ticker
|
|
218
|
+
asks GitHub and Linear for the issues, pull requests and comments since the
|
|
219
|
+
last event it received, Slack for each mapped channel's messages and thread
|
|
220
|
+
replies, and Notion for the pages changed in each mapped database and their
|
|
221
|
+
comments, and imports what it missed.
|
|
222
|
+
|
|
223
|
+
- **Where it starts** is noted when `mu serve` or the daemon starts, before
|
|
224
|
+
the first webhook, five minutes before the last event received, in case
|
|
225
|
+
the clocks differ. What it reads again is known already.
|
|
226
|
+
- **Every tick** goes on with it until a read gets to the end. That includes
|
|
227
|
+
one noted by a `mu serve` restarted while the daemon kept running.
|
|
228
|
+
- **A refusal**, such as a rate limit, waits five minutes, then the platform
|
|
229
|
+
is asked again from the same point.
|
|
230
|
+
- **A read cut short** by its page cap goes on a minute later from the
|
|
231
|
+
newest change it read.
|
|
232
|
+
- **A state the board changed after the platform's copy was read** is left
|
|
233
|
+
as it is.
|
|
234
|
+
- **Notion** gives up to 1,000 changed pages a database. A comment on a page
|
|
235
|
+
that didn't otherwise change while the board was down isn't found: see
|
|
236
|
+
[Notion](./05-notion.md#catching-up).
|
|
237
|
+
- **More changes made at one moment than a read can take** are gone past.
|
|
238
|
+
The daemon logs `skipped sync <key>: changes made at <time> may not have
|
|
239
|
+
been read`.
|
|
240
|
+
|
|
241
|
+
## Reaching the board
|
|
242
|
+
|
|
243
|
+
`mu serve` listens on 127.0.0.1. A platform needs a public HTTPS address that
|
|
244
|
+
forwards to it: a tunnel, or a proxy on a server. Pass its name with
|
|
245
|
+
`--allow-host`. Each platform also needs an app or a webhook of its own; the
|
|
246
|
+
platform pages say what.
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: GitHub
|
|
3
|
+
description: Issues and pull requests become board threads, with comments as replies, and state, reviews, CI results, labels and assignees as labels agents can wait on. Nothing goes back to GitHub unless a repository turns on mirroring.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Guides that use it: [CI](../03-guides/08-ci.md) waits on a pull request's checks, [A software factory](../03-guides/03-factory.md) answers issues as they arrive, and [A feedback loop](../03-guides/20-a-feedback-loop.md) turns an issue into a pull request.
|
|
7
|
+
|
|
8
|
+
## Map repositories
|
|
9
|
+
|
|
10
|
+
```ts board.ts
|
|
11
|
+
import { board, env, github } from '@openmuster/muster'
|
|
12
|
+
|
|
13
|
+
export default board({
|
|
14
|
+
sync: {
|
|
15
|
+
gh: github({
|
|
16
|
+
secret: env('GITHUB_WEBHOOK_SECRET'),
|
|
17
|
+
token: env('GITHUB_TOKEN'),
|
|
18
|
+
bot: 'your-app[bot]',
|
|
19
|
+
repos: {
|
|
20
|
+
'acme/web': { issues: 'web/issues', pulls: 'web/prs', mirror: true },
|
|
21
|
+
'acme/api': 'api',
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
A repository maps to one channel, or to one for issues and one for pull
|
|
29
|
+
requests. A repository that isn't mapped is ignored.
|
|
30
|
+
|
|
31
|
+
## What comes in
|
|
32
|
+
|
|
33
|
+
| On GitHub | On the board |
|
|
34
|
+
| --- | --- |
|
|
35
|
+
| An issue or pull request is opened | A thread: the title, a blank line, the body. Labels `kind` (`issue` or `pr`), `state=open`, `ref=acme/web#7`, `source=gh` |
|
|
36
|
+
| A comment | A reply, by `gh:user:<login>` |
|
|
37
|
+
| A comment is edited or deleted | The reply is edited or deleted |
|
|
38
|
+
| The title or body is edited | The thread's first message is edited |
|
|
39
|
+
| Closed, merged, reopened | The label `state`: `closed`, `merged`, `open` |
|
|
40
|
+
| A review is submitted | The label `review`: `approved`, `changes_requested`, `commented`. Its text, if any, is a reply |
|
|
41
|
+
| A workflow run completes on a pull request | The label `ci.<workflow>`: `success`, `failure`, and so on |
|
|
42
|
+
| A label is on it, put on, or taken off | A label per GitHub label: `tag.bug=bug` |
|
|
43
|
+
| Someone is assigned or unassigned | A label per assignee: `assignee.maya=maya` |
|
|
44
|
+
|
|
45
|
+
An agent can wait on any of them:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
mu wait web/prs --label 'ci.ci=failure' --timeout 1h
|
|
49
|
+
mu read web/prs --label review=changes_requested
|
|
50
|
+
mu wait web/issues --label tag.agent=agent --timeout 1h
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## What it is filed under
|
|
54
|
+
|
|
55
|
+
A thread carries its issue's or pull request's labels and assignees, and
|
|
56
|
+
keeps to them: under `tag.` and `assignee.` it says what GitHub says now.
|
|
57
|
+
|
|
58
|
+
- **The key is the name, cut to fit a label key.** Lowercase, with anything
|
|
59
|
+
but letters, numbers, `.` and `_` turned into `-`: `Needs Review` is
|
|
60
|
+
`tag.needs-review`. A name with nothing left, such as an emoji alone, makes
|
|
61
|
+
no label. Two names that make the same key are one label.
|
|
62
|
+
- **The value is the name in lowercase,** so `--label tag.agent=agent`
|
|
63
|
+
matches a label typed `Agent`.
|
|
64
|
+
- **What you set by hand under `tag.` or `assignee.` goes** the next time
|
|
65
|
+
GitHub says what the item's labels are. Use another key for your own:
|
|
66
|
+
`owner=fixer` stays.
|
|
67
|
+
- **At most 40 are kept per thread,** labels before assignees, so there is
|
|
68
|
+
room left for yours.
|
|
69
|
+
- **Nothing goes back.** A label you set on the board is never put on the
|
|
70
|
+
issue.
|
|
71
|
+
|
|
72
|
+
A watcher can listen for one (`"labels": ["tag.agent=agent"]`). Then anyone
|
|
73
|
+
who may label an issue in that repository can set off whatever you wired to
|
|
74
|
+
it, so wire it only for repositories whose labels you trust.
|
|
75
|
+
|
|
76
|
+
## What goes back
|
|
77
|
+
|
|
78
|
+
Nothing, unless the repository sets `mirror: true`. With it:
|
|
79
|
+
|
|
80
|
+
- A reply in a synced thread is posted as a comment.
|
|
81
|
+
- A thread posted in the repository's `issues` channel opens an issue. Its
|
|
82
|
+
first line is the title. The thread then carries the same labels as an
|
|
83
|
+
issue that came in: `kind=issue`, `state=open`, `ref` and `source`.
|
|
84
|
+
- An edit or a delete of a delivered reply changes or removes the comment.
|
|
85
|
+
|
|
86
|
+
## Files
|
|
87
|
+
|
|
88
|
+
Files don't sync with GitHub:
|
|
89
|
+
|
|
90
|
+
- **In:** an attachment in an issue or comment is a link to
|
|
91
|
+
`github.com/user-attachments`. It stays in the text, as a link: the
|
|
92
|
+
board doesn't fetch it.
|
|
93
|
+
- **Out:** GitHub has no API to attach a file to an issue or a comment. A
|
|
94
|
+
board message's files are named at the end of its text, and stay on the
|
|
95
|
+
board: `[file not sent: fix.patch (2 KB): GitHub takes no uploads, it is on the board]`.
|
|
96
|
+
|
|
97
|
+
## Who the comments are by
|
|
98
|
+
|
|
99
|
+
What the sync sends is written by whoever its credential belongs to. A
|
|
100
|
+
personal access token in `token` makes every comment yours. To have them
|
|
101
|
+
written by a GitHub App, name the App in place of the token:
|
|
102
|
+
|
|
103
|
+
```ts board.ts
|
|
104
|
+
import { board, env, github } from '@openmuster/muster'
|
|
105
|
+
|
|
106
|
+
export default board({
|
|
107
|
+
sync: {
|
|
108
|
+
gh: github({
|
|
109
|
+
secret: env('GITHUB_WEBHOOK_SECRET'),
|
|
110
|
+
appId: env('GITHUB_APP_ID'),
|
|
111
|
+
appKey: env('GITHUB_APP_KEY_FILE'),
|
|
112
|
+
repos: { 'acme/web': { issues: 'web/issues', mirror: true } },
|
|
113
|
+
}),
|
|
114
|
+
},
|
|
115
|
+
})
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
- `appId` is the App's numeric ID. `appKey` is its private key: the path to
|
|
119
|
+
the `.pem` file, or the key itself (`GITHUB_APP_PRIVATE_KEY`). They are the
|
|
120
|
+
same variables a worker with `--push` reads, so one App can open the pull
|
|
121
|
+
requests and write the comments.
|
|
122
|
+
- The board makes a token for each repository as it needs one, for that
|
|
123
|
+
repository alone, and a new one before it runs out within the hour. The App
|
|
124
|
+
must be installed on the repository with write on Issues, and on Pull
|
|
125
|
+
requests too where the sync brings those in.
|
|
126
|
+
- Catch-up reads with the App as well, so no `token` is needed. With both set,
|
|
127
|
+
the App is used.
|
|
128
|
+
- Leave `bot` unset when the same App opens pull requests you want as threads:
|
|
129
|
+
`bot` drops everything that login did. The board knows the comments it sent
|
|
130
|
+
without it.
|
|
131
|
+
|
|
132
|
+
## Set it up
|
|
133
|
+
|
|
134
|
+
1. Create a GitHub App, or a repository webhook plus a token.
|
|
135
|
+
2. Give it read and write on Issues and Pull requests, and read on Actions for
|
|
136
|
+
CI results.
|
|
137
|
+
3. Subscribe to: Issues, Issue comments, Pull requests, Pull request reviews,
|
|
138
|
+
Workflow runs.
|
|
139
|
+
4. Point the webhook at `https://<host>/api/board/webhooks/gh` with content
|
|
140
|
+
type `application/json`, and set a secret.
|
|
141
|
+
5. Name the secret in the board module's `github()` with `env()`, and the
|
|
142
|
+
token or the App too if anything goes back. Restart what runs the module.
|
|
143
|
+
|
|
144
|
+
## Catching up
|
|
145
|
+
|
|
146
|
+
After downtime, and when a token or an App is set, the ticker asks each mapped repository for
|
|
147
|
+
the issues and pull requests updated since the last event it received, then
|
|
148
|
+
their comments. An issue opened while the board was down arrives whole, with
|
|
149
|
+
its title, body and labels, and its comments as replies. A close or merge
|
|
150
|
+
missed meanwhile sets `state`, and a label or an assignee put on or taken off
|
|
151
|
+
meanwhile is put on or taken off the thread, by the sync's key (`gh`): the list
|
|
152
|
+
doesn't say who did it. One read takes up to 1,000 of each per repository,
|
|
153
|
+
oldest change first. Each page is asked for from the newest change read so
|
|
154
|
+
far, so an issue changed during the read is not skipped. If there are more,
|
|
155
|
+
the next read goes on a minute later from the newest change it read.
|
|
156
|
+
|
|
157
|
+
A comment, a review, a label or an assignee on an issue the board never saw, such as one opened
|
|
158
|
+
before sync was set up, starts its thread from the issue itself. Catch-up
|
|
159
|
+
does the same for an older issue updated while the board was down.
|