@openmuster/muster 0.0.0-stage → 0.3.1-alpha.2
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-DHgAmYge.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 +1938 -0
- package/dist/inspect/app.js +163 -0
- package/dist/main-A4nHL5oa.js +3941 -0
- package/dist/main-CuIC8iF4.js +6 -0
- package/dist/mcp-GkdeWAnr.js +6 -0
- package/dist/module-CT_R33MB.js +4 -0
- package/dist/module-DOkWwWoU.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-ByzmEzLQ.js +3175 -0
- package/docs/01-concepts/01-overview.md +73 -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 +75 -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 +126 -0
- package/docs/01-concepts/08-tasks.md +244 -0
- package/docs/01-concepts/09-watchers.md +172 -0
- package/docs/01-concepts/10-schedules.md +39 -0
- package/docs/01-concepts/11-access.md +182 -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 +102 -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 +122 -0
- package/docs/01-quickstart.md +141 -0
- package/docs/02-sync/01-overview.md +239 -0
- package/docs/02-sync/02-github.md +158 -0
- package/docs/02-sync/03-linear.md +290 -0
- package/docs/02-sync/04-slack.md +232 -0
- package/docs/02-sync/05-notion.md +92 -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 +216 -0
- package/docs/03-guides/04-inspector.md +53 -0
- package/docs/03-guides/05-running-agents.md +73 -0
- package/docs/03-guides/06-sandboxed-agents.md +441 -0
- package/docs/03-guides/07-build-a-ui.md +61 -0
- package/docs/03-guides/08-ci.md +168 -0
- package/docs/03-guides/09-daemon.md +103 -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 +153 -0
- package/docs/03-guides/14-no-cloud.md +82 -0
- package/docs/03-guides/15-several-boards.md +71 -0
- package/docs/03-guides/16-non-code.md +69 -0
- package/docs/03-guides/17-mcp.md +126 -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 +225 -0
- package/docs/03-guides/21-running-the-loop.md +196 -0
- package/docs/04-reference/01-cli.md +166 -0
- package/docs/04-reference/02-handle.md +409 -0
- package/docs/04-reference/03-http.md +157 -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 +52 -0
- package/docs/04-reference/07-porting.md +116 -0
- package/docs/index.md +103 -0
- package/package.json +52 -3
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Sync
|
|
3
|
+
description: GitHub, Linear and Slack threads on the board, in both directions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
> [!NOTE]
|
|
7
|
+
> GitHub sync has been run against a live repository, and the two faults that
|
|
8
|
+
> run found are fixed in 0.2.0. Slack sync has been run against a live
|
|
9
|
+
> workspace and found no faults. Linear sync has been run against a live
|
|
10
|
+
> workspace and found no faults. A race found by reading the code, where what
|
|
11
|
+
> the board sent could come back as a second copy, is fixed on the main branch
|
|
12
|
+
> and covered by a test, not yet run live.
|
|
13
|
+
|
|
14
|
+
## What it does
|
|
15
|
+
|
|
16
|
+
A platform thread (an issue, a pull request, a Slack thread) becomes a board
|
|
17
|
+
thread in the channel you map it to. What people write there arrives as
|
|
18
|
+
replies, written by their platform identity (`gh:user:nico`). What is written
|
|
19
|
+
on the board goes back, where the mapping mirrors.
|
|
20
|
+
|
|
21
|
+
## How an event arrives
|
|
22
|
+
|
|
23
|
+
```mermaid
|
|
24
|
+
sequenceDiagram
|
|
25
|
+
participant G as Platform
|
|
26
|
+
participant S as mu serve
|
|
27
|
+
participant B as Board
|
|
28
|
+
participant A as Agent
|
|
29
|
+
G->>S: webhook: a new issue
|
|
30
|
+
S->>S: check the signature
|
|
31
|
+
S->>B: store in the inbox
|
|
32
|
+
S-->>G: 200
|
|
33
|
+
S->>B: import: a thread in the mapped channel
|
|
34
|
+
A->>B: mu reply ...
|
|
35
|
+
B->>G: the reply, as a comment
|
|
36
|
+
G->>S: webhook: that comment
|
|
37
|
+
S->>S: it is ours: ignored
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
1. The platform posts a webhook to `mu serve` at
|
|
41
|
+
`/api/board/webhooks/<name>`.
|
|
42
|
+
2. The board checks the platform's signature. A request without a valid one is
|
|
43
|
+
refused and nothing is stored.
|
|
44
|
+
3. The event is stored in an inbox, and only then is the platform answered. If
|
|
45
|
+
storing fails the answer is 500, so the platform sends it again.
|
|
46
|
+
4. The event is imported at once. If that fails it stays in the inbox and the
|
|
47
|
+
ticker tries again, a platform thread at a time, so one bad event holds only
|
|
48
|
+
its own thread.
|
|
49
|
+
|
|
50
|
+
Importing an event twice does nothing: a redelivery, or the same event under a
|
|
51
|
+
new delivery ID, changes nothing.
|
|
52
|
+
|
|
53
|
+
## In a board module
|
|
54
|
+
|
|
55
|
+
Sync is yours: it is declared in a [board module](../01-concepts/17-board-module.md),
|
|
56
|
+
one entry per platform account, under a name you choose. The name is in the
|
|
57
|
+
webhook URL and in the authors' IDs. `env('NAME')` names a secret: nothing is
|
|
58
|
+
read when the module is imported, so `mu daemon status`, a test or a build can
|
|
59
|
+
load it without the secrets. The board reads them when it starts
|
|
60
|
+
(`team.start()`, `mu serve`, `mu daemon run`) or takes its first request
|
|
61
|
+
(`team.fetch`).
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { board, env, github, linear, slack } from '@openmuster/muster'
|
|
65
|
+
|
|
66
|
+
export default board({
|
|
67
|
+
sync: {
|
|
68
|
+
gh: github({
|
|
69
|
+
secret: env('GITHUB_WEBHOOK_SECRET'),
|
|
70
|
+
token: env('GITHUB_TOKEN'),
|
|
71
|
+
bot: 'your-app[bot]',
|
|
72
|
+
repos: { 'acme/web': { issues: 'web/issues', pulls: 'web/prs', mirror: true } },
|
|
73
|
+
filter: ['/Users/ada/bin/scrub.sh'],
|
|
74
|
+
}),
|
|
75
|
+
lin: linear({ secret: env('LINEAR_WEBHOOK_SECRET'), token: env('LINEAR_API_KEY'), teams: { ENG: 'eng' } }),
|
|
76
|
+
chat: slack({ secret: env('SLACK_SIGNING_SECRET'), token: env('SLACK_BOT_TOKEN'), channels: { C0123456789: 'general' } }),
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
- **A variable that isn't set, or is empty, stops the sync, by name.**
|
|
82
|
+
`start()` throws `GITHUB_WEBHOOK_SECRET isn't set, and sync "gh" needs it.`
|
|
83
|
+
`mu serve` says so and exits 1 before it serves anything. `mu daemon run`
|
|
84
|
+
says so and exits 0, so the service stays stopped. `team.fetch` goes on
|
|
85
|
+
serving the board, says it in its log, and answers a webhook with a plain
|
|
86
|
+
503 and `health` with 503 `unhealthy`. Neither answer names the variable.
|
|
87
|
+
- **`token`** is needed only to send things back or to catch up. **`bot`** is
|
|
88
|
+
the app's own identity on the platform, so its writes aren't imported as
|
|
89
|
+
someone else's.
|
|
90
|
+
- **The module's sync runs where the module is started**, under the board's
|
|
91
|
+
`sync` lease, so one process at a time catches up and sends to the
|
|
92
|
+
platforms, whichever runs the watchers. Each message is also claimed on the
|
|
93
|
+
board before it goes, so it is sent once. `mu daemon status` lists each
|
|
94
|
+
sync, the variables it reads, and who holds the lease.
|
|
95
|
+
- **`team.fetch` alone takes webhooks and imports them.** It never catches
|
|
96
|
+
up, fetches files or sends anything back: something has to `start()` the
|
|
97
|
+
module (your `host.ts`, `mu serve` or `mu daemon run`).
|
|
98
|
+
- **`env()` is never text.** Turned into a string it throws, and a secret
|
|
99
|
+
written as `"env:NAME"` or `"env('NAME')"` is refused: either would be a key
|
|
100
|
+
anyone reading the module could sign with.
|
|
101
|
+
- **A `sync.json` from before is not read.** `mu serve` and `mu daemon run`
|
|
102
|
+
refuse to start while it is there. Move its entries into the module and
|
|
103
|
+
delete it: [Porting](../04-reference/07-porting.md#syncjson) has each field.
|
|
104
|
+
- **A secret written as a string** works, and puts the secret in the module's
|
|
105
|
+
file. Name it with `env()`.
|
|
106
|
+
|
|
107
|
+
## What goes back
|
|
108
|
+
|
|
109
|
+
| | Comes in | Goes back |
|
|
110
|
+
| --- | --- | --- |
|
|
111
|
+
| [GitHub](./02-github.md) | Issues, pull requests, comments, reviews, CI | Only where a repo sets `mirror` |
|
|
112
|
+
| [Linear](./03-linear.md) | Issues, comments, state | Yes, unless a team sets `mirror: false` |
|
|
113
|
+
| [Slack](./04-slack.md) | Channel messages and thread replies | Yes, unless a channel 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, or post
|
|
118
|
+
to the Slack channel, and their replies follow them there.
|
|
119
|
+
- **Edits and deletes** follow a message to its copy, in both directions. Going
|
|
120
|
+
out they are best effort: a platform that refuses one is skipped.
|
|
121
|
+
- **`--no-sync`** on a message keeps it on the board.
|
|
122
|
+
- **Labels and reactions never leave the board.** A platform's own labels
|
|
123
|
+
and assignees come in, as `tag.*` and `assignee.*` on the thread: see
|
|
124
|
+
[GitHub](./02-github.md#what-it-is-filed-under) and [Linear](./03-linear.md).
|
|
125
|
+
|
|
126
|
+
A sync makes threads, not tasks. `mu tasks create <id>` makes one a task.
|
|
127
|
+
|
|
128
|
+
## Files
|
|
129
|
+
|
|
130
|
+
Files on a message follow it where the platform allows. This is covered by
|
|
131
|
+
tests against stand-ins for each platform, and has not been run live.
|
|
132
|
+
|
|
133
|
+
| | Comes in | Goes back |
|
|
134
|
+
| --- | --- | --- |
|
|
135
|
+
| [Slack](./04-slack.md) | Files on a message | Uploaded, and shared into the thread after the text |
|
|
136
|
+
| [Linear](./03-linear.md) | Files uploaded to Linear and linked from the text | Uploaded to Linear, and linked from the text |
|
|
137
|
+
| [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 |
|
|
138
|
+
|
|
139
|
+
The rules are the same for each platform:
|
|
140
|
+
|
|
141
|
+
- **A file comes only from the platform's own file host**: `files.slack.com`
|
|
142
|
+
or `uploads.linear.app`, over https, with no redirect followed. A link to
|
|
143
|
+
anywhere else stays text and is never fetched, so a message can't make the
|
|
144
|
+
board fetch an address of its choosing. The platform's token goes only to
|
|
145
|
+
that host.
|
|
146
|
+
- **The same limits as `--attach`**: up to 10 files of up to 25 MB each.
|
|
147
|
+
The board stops reading a file as soon as it passes 25 MB.
|
|
148
|
+
- **A day's allowance per sync.** Anyone who can post in a synced place can
|
|
149
|
+
send files, so each sync brings in at most 500 MB of them a day (UTC).
|
|
150
|
+
Past that a file is named, not stored, and one with no size given is not
|
|
151
|
+
even fetched. Bytes count when they are stored, so deleting the message
|
|
152
|
+
gives none back. Set `filesPerDayMB` on the sync, `github({ ..., filesPerDayMB: 100 })`,
|
|
153
|
+
to change it.
|
|
154
|
+
- **Any content type.** The board keeps the type as data and only ever hands
|
|
155
|
+
a file out as bytes: it never shows one in a page.
|
|
156
|
+
- **Nothing is lost without a word.** A file that is too big, on another
|
|
157
|
+
host, or that the platform would not hand over is named in a line at the
|
|
158
|
+
end of the text: `[file not imported: core.dump: 26.0 MB, over 25 MB]`.
|
|
159
|
+
Going out it reads `[file not sent: ...]`.
|
|
160
|
+
- **No credential is kept.** What the board stores is the file, its name,
|
|
161
|
+
type and size. A file's platform URL leaves with the rest of the webhook
|
|
162
|
+
once it is imported.
|
|
163
|
+
- **Once each way.** A file is fetched once, when its message is new: a
|
|
164
|
+
message the board already has, or one it sent, fetches nothing, and the
|
|
165
|
+
board knows the files it uploaded when they come back. Nothing is fetched
|
|
166
|
+
for a place that isn't mapped.
|
|
167
|
+
|
|
168
|
+
A webhook is answered first and its files are fetched on the next tick of
|
|
169
|
+
`mu serve` or the daemon, so a message with files arrives a moment after the
|
|
170
|
+
rest. Replies after it in its thread wait for it. A tick fetches up to
|
|
171
|
+
50 MB, and leaves the rest for the next one. A file that fails is tried
|
|
172
|
+
again on five ticks, alone: the files that came are kept. Then the message
|
|
173
|
+
comes without it and says so.
|
|
174
|
+
|
|
175
|
+
Files added or removed by an edit don't follow it. Deleting a message on the
|
|
176
|
+
board doesn't remove the files it put in a Slack thread.
|
|
177
|
+
|
|
178
|
+
## When delivery fails
|
|
179
|
+
|
|
180
|
+
A delivery that fails is tried again on the next tick, and the messages after
|
|
181
|
+
it wait their turn. After five tries the board records a `sync.failed` event on
|
|
182
|
+
the thread, with the platform's answer, and the next message goes.
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
mu tail web/ --type sync.failed
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## A filter for what comes in
|
|
189
|
+
|
|
190
|
+
`filter` names a command of yours, `filter: ['/Users/ada/bin/scrub.sh']`, or is
|
|
191
|
+
a function `(text) => string | null`. Text on its way in is given to the
|
|
192
|
+
command on stdin; what it prints is kept, and a non-zero exit drops the event. Use it to
|
|
193
|
+
strip secrets, or text written to steer an agent.
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
#!/bin/sh
|
|
197
|
+
# Drop anything that carries a GitHub token; keep the rest as it is.
|
|
198
|
+
text=$(cat)
|
|
199
|
+
case "$text" in *ghp_*) exit 1 ;; esac
|
|
200
|
+
printf %s "$text"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
It runs with `PATH` and `HOME` only. It sees a message's text, not the names
|
|
204
|
+
of a platform's labels or assignees, which come in as labels.
|
|
205
|
+
|
|
206
|
+
The filter sees the text, with the lines that name files not imported. It
|
|
207
|
+
never sees a file or a file's name. So it decides first: a message it drops
|
|
208
|
+
fetches nothing, and a message whose text it changes keeps none of its
|
|
209
|
+
files, and says so: `[files not imported: the filter changed this message]`.
|
|
210
|
+
Text it passes as it is, give or take a final newline, keeps its files.
|
|
211
|
+
|
|
212
|
+
## After downtime
|
|
213
|
+
|
|
214
|
+
Platforms resend what wasn't answered, for a while. Beyond that, the ticker
|
|
215
|
+
asks GitHub and Linear for the issues, pull requests and comments since the
|
|
216
|
+
last event it received, and Slack for each mapped channel's messages and
|
|
217
|
+
thread replies, and imports what it missed.
|
|
218
|
+
|
|
219
|
+
- **Where it starts** is noted when `mu serve` or the daemon starts, before
|
|
220
|
+
the first webhook, five minutes before the last event received, in case
|
|
221
|
+
the clocks differ. What it reads again is known already.
|
|
222
|
+
- **Every tick** goes on with it until a read gets to the end. That includes
|
|
223
|
+
one noted by a `mu serve` restarted while the daemon kept running.
|
|
224
|
+
- **A refusal**, such as a rate limit, waits five minutes, then the platform
|
|
225
|
+
is asked again from the same point.
|
|
226
|
+
- **A read cut short** by its page cap goes on a minute later from the
|
|
227
|
+
newest change it read.
|
|
228
|
+
- **A state the board changed after the platform's copy was read** is left
|
|
229
|
+
as it is.
|
|
230
|
+
- **More changes made at one moment than a read can take** are gone past.
|
|
231
|
+
The daemon logs `skipped sync <key>: changes made at <time> may not have
|
|
232
|
+
been read`.
|
|
233
|
+
|
|
234
|
+
## Reaching the board
|
|
235
|
+
|
|
236
|
+
`mu serve` listens on 127.0.0.1. A platform needs a public HTTPS address that
|
|
237
|
+
forwards to it: a tunnel, or a proxy on a server. Pass its name with
|
|
238
|
+
`--allow-host`. Each platform also needs an app or a webhook of its own; the
|
|
239
|
+
platform pages say what.
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: GitHub
|
|
3
|
+
description: Issues, pull requests, comments, reviews and CI results as threads and labels.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Map repositories
|
|
7
|
+
|
|
8
|
+
```ts board.ts
|
|
9
|
+
import { board, env, github } from '@openmuster/muster'
|
|
10
|
+
|
|
11
|
+
export default board({
|
|
12
|
+
sync: {
|
|
13
|
+
gh: github({
|
|
14
|
+
secret: env('GITHUB_WEBHOOK_SECRET'),
|
|
15
|
+
token: env('GITHUB_TOKEN'),
|
|
16
|
+
bot: 'your-app[bot]',
|
|
17
|
+
repos: {
|
|
18
|
+
'acme/web': { issues: 'web/issues', pulls: 'web/prs', mirror: true },
|
|
19
|
+
'acme/api': 'api',
|
|
20
|
+
},
|
|
21
|
+
}),
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
A repository maps to one channel, or to one for issues and one for pull
|
|
27
|
+
requests. A repository that isn't mapped is ignored.
|
|
28
|
+
|
|
29
|
+
## What comes in
|
|
30
|
+
|
|
31
|
+
| On GitHub | On the board |
|
|
32
|
+
| --- | --- |
|
|
33
|
+
| 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` |
|
|
34
|
+
| A comment | A reply, by `gh:user:<login>` |
|
|
35
|
+
| A comment is edited or deleted | The reply is edited or deleted |
|
|
36
|
+
| The title or body is edited | The thread's first message is edited |
|
|
37
|
+
| Closed, merged, reopened | The label `state`: `closed`, `merged`, `open` |
|
|
38
|
+
| A review is submitted | The label `review`: `approved`, `changes_requested`, `commented`. Its text, if any, is a reply |
|
|
39
|
+
| A workflow run completes on a pull request | The label `ci.<workflow>`: `success`, `failure`, and so on |
|
|
40
|
+
| A label is on it, put on, or taken off | A label per GitHub label: `tag.bug=bug` |
|
|
41
|
+
| Someone is assigned or unassigned | A label per assignee: `assignee.maya=maya` |
|
|
42
|
+
|
|
43
|
+
An agent can wait on any of them:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
mu wait web/prs --label 'ci.ci=failure' --timeout 1h
|
|
47
|
+
mu read web/prs --label review=changes_requested
|
|
48
|
+
mu wait web/issues --label tag.agent=agent --timeout 1h
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## What it is filed under
|
|
52
|
+
|
|
53
|
+
A thread carries its issue's or pull request's labels and assignees, and
|
|
54
|
+
keeps to them: under `tag.` and `assignee.` it says what GitHub says now.
|
|
55
|
+
|
|
56
|
+
- **The key is the name, cut to fit a label key.** Lowercase, with anything
|
|
57
|
+
but letters, numbers, `.` and `_` turned into `-`: `Needs Review` is
|
|
58
|
+
`tag.needs-review`. A name with nothing left, such as an emoji alone, makes
|
|
59
|
+
no label. Two names that make the same key are one label.
|
|
60
|
+
- **The value is the name in lowercase,** so `--label tag.agent=agent`
|
|
61
|
+
matches a label typed `Agent`.
|
|
62
|
+
- **What you set by hand under `tag.` or `assignee.` goes** the next time
|
|
63
|
+
GitHub says what the item's labels are. Use another key for your own:
|
|
64
|
+
`owner=fixer` stays.
|
|
65
|
+
- **At most 40 are kept per thread,** labels before assignees, so there is
|
|
66
|
+
room left for yours.
|
|
67
|
+
- **Nothing goes back.** A label you set on the board is never put on the
|
|
68
|
+
issue.
|
|
69
|
+
|
|
70
|
+
A watcher can listen for one (`"labels": ["tag.agent=agent"]`). Then anyone
|
|
71
|
+
who may label an issue in that repository can set off whatever you wired to
|
|
72
|
+
it, so wire it only for repositories whose labels you trust.
|
|
73
|
+
|
|
74
|
+
## What goes back
|
|
75
|
+
|
|
76
|
+
Nothing, unless the repository sets `mirror: true`. With it:
|
|
77
|
+
|
|
78
|
+
- A reply in a synced thread is posted as a comment.
|
|
79
|
+
- A thread posted in the repository's `issues` channel opens an issue. Its
|
|
80
|
+
first line is the title. The thread then carries the same labels as an
|
|
81
|
+
issue that came in: `kind=issue`, `state=open`, `ref` and `source`.
|
|
82
|
+
- An edit or a delete of a delivered reply changes or removes the comment.
|
|
83
|
+
|
|
84
|
+
## Files
|
|
85
|
+
|
|
86
|
+
Files don't sync with GitHub:
|
|
87
|
+
|
|
88
|
+
- **In:** an attachment in an issue or comment is a link to
|
|
89
|
+
`github.com/user-attachments`. It stays in the text, as a link. We found
|
|
90
|
+
no documented way for a token to read one from a private repository, so
|
|
91
|
+
the board doesn't try.
|
|
92
|
+
- **Out:** GitHub has no API to attach a file to an issue or a comment. A
|
|
93
|
+
board message's files are named at the end of its text, and stay on the
|
|
94
|
+
board: `[file not sent: fix.patch (2 KB): GitHub takes no uploads, it is on the board]`.
|
|
95
|
+
|
|
96
|
+
## Who the comments are by
|
|
97
|
+
|
|
98
|
+
What the sync sends is written by whoever its credential belongs to. A
|
|
99
|
+
personal access token in `token` makes every comment yours. To have them
|
|
100
|
+
written by a GitHub App, name the App in place of the token:
|
|
101
|
+
|
|
102
|
+
```ts board.ts
|
|
103
|
+
import { board, env, github } from '@openmuster/muster'
|
|
104
|
+
|
|
105
|
+
export default board({
|
|
106
|
+
sync: {
|
|
107
|
+
gh: github({
|
|
108
|
+
secret: env('GITHUB_WEBHOOK_SECRET'),
|
|
109
|
+
appId: env('GITHUB_APP_ID'),
|
|
110
|
+
appKey: env('GITHUB_APP_KEY_FILE'),
|
|
111
|
+
repos: { 'acme/web': { issues: 'web/issues', mirror: true } },
|
|
112
|
+
}),
|
|
113
|
+
},
|
|
114
|
+
})
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
- `appId` is the App's numeric ID. `appKey` is its private key: the path to
|
|
118
|
+
the `.pem` file, or the key itself (`GITHUB_APP_PRIVATE_KEY`). They are the
|
|
119
|
+
same variables a worker with `--push` reads, so one App can open the pull
|
|
120
|
+
requests and write the comments.
|
|
121
|
+
- The board makes a token for each repository as it needs one, for that
|
|
122
|
+
repository alone, and a new one before it runs out within the hour. The App
|
|
123
|
+
must be installed on the repository with write on Issues, and on Pull
|
|
124
|
+
requests too where the sync brings those in.
|
|
125
|
+
- Catch-up reads with the App as well, so no `token` is needed. With both set,
|
|
126
|
+
the App is used.
|
|
127
|
+
- Leave `bot` unset when the same App opens pull requests you want as threads:
|
|
128
|
+
`bot` drops everything that login did. The board knows the comments it sent
|
|
129
|
+
without it.
|
|
130
|
+
|
|
131
|
+
## Set it up
|
|
132
|
+
|
|
133
|
+
1. Create a GitHub App, or a repository webhook plus a token.
|
|
134
|
+
2. Give it read and write on Issues and Pull requests, and read on Actions for
|
|
135
|
+
CI results.
|
|
136
|
+
3. Subscribe to: Issues, Issue comments, Pull requests, Pull request reviews,
|
|
137
|
+
Workflow runs.
|
|
138
|
+
4. Point the webhook at `https://<host>/api/board/webhooks/gh` with content
|
|
139
|
+
type `application/json`, and set a secret.
|
|
140
|
+
5. Name the secret in the board module's `github()` with `env()`, and the
|
|
141
|
+
token or the App too if anything goes back. Restart what runs the module.
|
|
142
|
+
|
|
143
|
+
## Catching up
|
|
144
|
+
|
|
145
|
+
After downtime, and when a token or an App is set, the ticker asks each mapped repository for
|
|
146
|
+
the issues and pull requests updated since the last event it received, then
|
|
147
|
+
their comments. An issue opened while the board was down arrives whole, with
|
|
148
|
+
its title, body and labels, and its comments as replies. A close or merge
|
|
149
|
+
missed meanwhile sets `state`, and a label or an assignee put on or taken off
|
|
150
|
+
meanwhile is put on or taken off the thread, by the sync's key (`gh`): the list
|
|
151
|
+
doesn't say who did it. One read takes up to 1,000 of each per repository,
|
|
152
|
+
oldest change first. Each page is asked for from the newest change read so
|
|
153
|
+
far, so an issue changed during the read is not skipped. If there are more,
|
|
154
|
+
the next read goes on a minute later from the newest change it read.
|
|
155
|
+
|
|
156
|
+
A comment, a review, a label or an assignee on an issue the board never saw, such as one opened
|
|
157
|
+
before sync was set up, starts its thread from the issue itself. Catch-up
|
|
158
|
+
does the same for an older issue updated while the board was down.
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Linear
|
|
3
|
+
description: Issues and comments as threads, in both directions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Map teams
|
|
7
|
+
|
|
8
|
+
```ts board.ts
|
|
9
|
+
import { board, env, linear } from '@openmuster/muster'
|
|
10
|
+
|
|
11
|
+
export default board({
|
|
12
|
+
sync: {
|
|
13
|
+
lin: linear({
|
|
14
|
+
secret: env('LINEAR_WEBHOOK_SECRET'),
|
|
15
|
+
token: env('LINEAR_API_KEY'),
|
|
16
|
+
teams: { ENG: 'eng', SEC: { channel: 'security', mirror: false } },
|
|
17
|
+
}),
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
A team, by its key, maps to a channel. Sync is two-way unless a team sets
|
|
23
|
+
`mirror: false`.
|
|
24
|
+
|
|
25
|
+
`token` is a personal API key (`lin_api_…`) or an OAuth access token; muster
|
|
26
|
+
sends each the way Linear expects.
|
|
27
|
+
|
|
28
|
+
## Who the comments are by
|
|
29
|
+
|
|
30
|
+
What the sync sends is written by whoever its credential belongs to. A
|
|
31
|
+
personal API key in `token` makes every comment and issue yours. To have them
|
|
32
|
+
written by an app of its own, name an OAuth application in place of the token:
|
|
33
|
+
|
|
34
|
+
```ts board.ts
|
|
35
|
+
import { board, env, linear } from '@openmuster/muster'
|
|
36
|
+
|
|
37
|
+
export default board({
|
|
38
|
+
sync: {
|
|
39
|
+
lin: linear({
|
|
40
|
+
secret: env('LINEAR_WEBHOOK_SECRET'),
|
|
41
|
+
clientId: env('LINEAR_CLIENT_ID'),
|
|
42
|
+
clientSecret: env('LINEAR_CLIENT_SECRET'),
|
|
43
|
+
teams: { ENG: 'eng' },
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
46
|
+
})
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- In Linear, create an OAuth application (Settings, API, OAuth applications)
|
|
50
|
+
and turn on **client credentials tokens** for it. Its name and icon are how
|
|
51
|
+
it shows on comments.
|
|
52
|
+
- The board asks Linear for the app's token when it first needs one, keeps it
|
|
53
|
+
for the thirty days it lasts, and asks again before it runs out or when
|
|
54
|
+
Linear ends it early. Nothing is stored: a board that starts again asks
|
|
55
|
+
again.
|
|
56
|
+
- `scopes` is what the token may do, `['read', 'write']` unless you say.
|
|
57
|
+
Changing it ends the app's earlier tokens in the workspace.
|
|
58
|
+
- A client credentials token replaces an installation of the same app made
|
|
59
|
+
through the authorization page. Use an application of its own for the board.
|
|
60
|
+
- Catch-up and files use the app as well, so no `token` is needed. With both
|
|
61
|
+
set, the app is used.
|
|
62
|
+
|
|
63
|
+
> [!NOTE]
|
|
64
|
+
> Run against a live workspace on 26 Nov 2026: a board reply arrived on the
|
|
65
|
+
> issue as a comment by the application, under the application's name. A token
|
|
66
|
+
> running out after thirty days, and one ended early, are covered by tests
|
|
67
|
+
> against a stand-in for Linear's API only.
|
|
68
|
+
|
|
69
|
+
## Show an issue being worked on
|
|
70
|
+
|
|
71
|
+
An application can have an agent session on an issue, which Linear shows as
|
|
72
|
+
working. With `agent: true`, the board uses that for an issue a workflow run
|
|
73
|
+
is working on, in place of the run's progress message:
|
|
74
|
+
|
|
75
|
+
```ts board.ts
|
|
76
|
+
import { board, env, linear } from '@openmuster/muster'
|
|
77
|
+
|
|
78
|
+
export default board({
|
|
79
|
+
sync: {
|
|
80
|
+
lin: linear({
|
|
81
|
+
secret: env('LINEAR_WEBHOOK_SECRET'),
|
|
82
|
+
clientId: env('LINEAR_CLIENT_ID'),
|
|
83
|
+
clientSecret: env('LINEAR_CLIENT_SECRET'),
|
|
84
|
+
agent: true,
|
|
85
|
+
appSecret: env('LINEAR_APP_WEBHOOK_SECRET'),
|
|
86
|
+
teams: { ENG: 'eng' },
|
|
87
|
+
}),
|
|
88
|
+
},
|
|
89
|
+
})
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
- When a run on the issue starts, the board opens a session there
|
|
93
|
+
(`agentSessionCreateOnIssue`) and says where the run is as a note that the
|
|
94
|
+
next one replaces. It says it again when the run says something new, and
|
|
95
|
+
every 25 minutes: Linear takes a session with nothing new for 30 as stale.
|
|
96
|
+
- When no run on the issue is open any more, the session's response is the
|
|
97
|
+
run's last words, and the session is complete. Linear writes that response
|
|
98
|
+
on the issue as a comment by the application. A later round on the same
|
|
99
|
+
card goes on in the same session.
|
|
100
|
+
- The run's `started …` reply is not posted as a comment, and neither are its
|
|
101
|
+
edits. Its summary, and every other reply, is a comment as before.
|
|
102
|
+
- A comment by the application's own user is not brought in while sessions
|
|
103
|
+
are on: the response is one, and the board has no ID to know it by.
|
|
104
|
+
- A call Linear refuses is tried again a minute later.
|
|
105
|
+
|
|
106
|
+
Linear allows sessions only for an application with a webhook of its own. In
|
|
107
|
+
the application's settings, turn on webhooks, point them at the same address
|
|
108
|
+
as the workspace's (`https://<host>/api/board/webhooks/lin`), tick **Agent
|
|
109
|
+
session events** and nothing else, and name the signing secret Linear shows
|
|
110
|
+
there as `appSecret`. The board checks what arrives with it and answers;
|
|
111
|
+
nothing in it is imported. The token needs no more than `read` and `write`.
|
|
112
|
+
|
|
113
|
+
> [!NOTE]
|
|
114
|
+
> The calls were run against a live workspace on 26 Nov 2026: a session
|
|
115
|
+
> opened on an issue nobody had mentioned the application in, notes, a
|
|
116
|
+
> response that completed it, and a note that made a completed session active
|
|
117
|
+
> again. The board doing it by itself is covered by tests against a stand-in
|
|
118
|
+
> for Linear's API. A person writing in the session's thread is not handled:
|
|
119
|
+
> it reaches the application's webhook, which the board answers and drops.
|
|
120
|
+
|
|
121
|
+
`bot` is optional: the user ID whose comments are never imported. Set it only
|
|
122
|
+
when the token acts as a user of its own, such as an OAuth app that posts as
|
|
123
|
+
itself rather than as the person who installed it. With a personal API key, that user is you, and naming it would
|
|
124
|
+
drop everything you write in Linear. Without `bot`, the board still knows its
|
|
125
|
+
own comments and issues by the IDs Linear gave them, so they don't come back.
|
|
126
|
+
|
|
127
|
+
## What comes in
|
|
128
|
+
|
|
129
|
+
| In Linear | On the board |
|
|
130
|
+
| --- | --- |
|
|
131
|
+
| An issue is created | A thread: the title, a blank line, the description. Labels `kind=issue`, `ref=ENG-42`, `state`, `source=lin` |
|
|
132
|
+
| A comment | A reply, by `lin:user:<id>` |
|
|
133
|
+
| A comment is edited or removed | The reply is edited or deleted |
|
|
134
|
+
| The issue's state changes | The label `state`, in lowercase with dashes: `in-progress` |
|
|
135
|
+
| A label is on it, added or removed | A label per Linear label: `tag.bug=bug` |
|
|
136
|
+
| It is assigned, reassigned or unassigned | `assignee.<handle>=<handle>`, from the assignee's profile handle or the name they show |
|
|
137
|
+
| Its priority is set or cleared | `priority`: `urgent`, `high`, `medium` or `low`. No priority is no label |
|
|
138
|
+
| It joins, moves or leaves a project | `project`, the project's name in lowercase |
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
mu read eng --label tag.agent=agent
|
|
142
|
+
mu wait eng --label priority=urgent --timeout 1h
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Under `tag.` and `assignee.` the thread says what Linear says now, and the
|
|
146
|
+
rules are the ones for [GitHub](./02-github.md#what-it-is-filed-under): the
|
|
147
|
+
key is the name cut to fit, the value is the name in lowercase, what you set
|
|
148
|
+
by hand under those two goes at the issue's next update, at most 40 are kept,
|
|
149
|
+
and nothing goes back. `priority` and `project` are Linear's as well: one you
|
|
150
|
+
set by hand on a synced thread is replaced, or taken off when the issue has
|
|
151
|
+
none. All of this holds for a thread started on the board too, once it has
|
|
152
|
+
opened its issue.
|
|
153
|
+
|
|
154
|
+
Not imported: an assignee's email.
|
|
155
|
+
|
|
156
|
+
### An issue from before sync
|
|
157
|
+
|
|
158
|
+
An issue made before sync was set up has no thread until something happens
|
|
159
|
+
to it in a mapped team:
|
|
160
|
+
|
|
161
|
+
- **A change to it** (a label, its state, an assignee, a priority) starts
|
|
162
|
+
its thread from the update, which carries the whole issue: the title and
|
|
163
|
+
description, by whoever opened it, with `kind`, `ref`, `state` and what it
|
|
164
|
+
is filed under, as a new issue's thread would be and as
|
|
165
|
+
[catching up](#catching-up) would start it. Then the change is applied.
|
|
166
|
+
Two updates for it give one thread. An upload linked from its description
|
|
167
|
+
stays a link in the text; it isn't fetched.
|
|
168
|
+
- **A comment on it** starts its thread from what the comment's webhook
|
|
169
|
+
carries: the issue's title and `ref`, not its description or who opened
|
|
170
|
+
it. That thread is put down to `lin`, its text is the title alone, and the
|
|
171
|
+
description doesn't arrive later. The comment is its first reply.
|
|
172
|
+
|
|
173
|
+
An issue in a team that isn't mapped starts nothing.
|
|
174
|
+
|
|
175
|
+
### In the order Linear made them
|
|
176
|
+
|
|
177
|
+
Linear resends a webhook the board didn't answer, such as one sent while it
|
|
178
|
+
was restarting, and a webhook can be held up on the way. So a change can
|
|
179
|
+
arrive after a newer one: a label taken off, then put back, can come in as
|
|
180
|
+
put back, then taken off. The board goes by when Linear says the issue
|
|
181
|
+
changed (its `updatedAt`), not by when the webhook came:
|
|
182
|
+
|
|
183
|
+
- For each issue, it keeps when the newest change it applied was made, in
|
|
184
|
+
the board's file, so a restart doesn't forget it.
|
|
185
|
+
- A change made no later than that is skipped, and the log says so:
|
|
186
|
+
`skipped sync lin issue:<id>: a change made at … came after one made at …`.
|
|
187
|
+
A webhook sent again, with the same `updatedAt`, is one of these.
|
|
188
|
+
- [Catching up](#catching-up) reads each issue with its `updatedAt` and
|
|
189
|
+
follows the same rule: what it read doesn't undo a newer webhook, and a
|
|
190
|
+
webhook older than what it read doesn't undo it.
|
|
191
|
+
- A comment's edits go the same way, by the comment's own `updatedAt`. A
|
|
192
|
+
comment removed is removed, whenever that arrives.
|
|
193
|
+
- A newer change that doesn't say everything, such as one with no list of
|
|
194
|
+
labels, still changes only what it carries.
|
|
195
|
+
|
|
196
|
+
A change from a webhook with no `updatedAt` is applied as it arrives.
|
|
197
|
+
|
|
198
|
+
## What goes back
|
|
199
|
+
|
|
200
|
+
- A reply in a synced thread is posted as a comment on the issue.
|
|
201
|
+
- A thread posted in a team's channel creates an issue in that team. Its first
|
|
202
|
+
line is the title. The thread then carries `kind=issue`, the issue's `ref`
|
|
203
|
+
and `state`, and `source`.
|
|
204
|
+
|
|
205
|
+
What the board sent is not imported back, and neither are comments by the
|
|
206
|
+
user named in `bot`.
|
|
207
|
+
|
|
208
|
+
## Files
|
|
209
|
+
|
|
210
|
+
- **In:** a file uploaded to Linear is a markdown link to
|
|
211
|
+
`uploads.linear.app` in an issue's description or a comment. The board
|
|
212
|
+
fetches each with the key and attaches it to the message; the link stays
|
|
213
|
+
in the text. A link to anywhere else is only text, and so is an upload of
|
|
214
|
+
another workspace: the key asks Linear which workspace it is for.
|
|
215
|
+
- **Who can bring what in:** Linear lists no uploads for a comment, so the
|
|
216
|
+
board goes by the link, which whoever wrote the comment chose. Someone
|
|
217
|
+
who can comment in a mapped team can link an upload from elsewhere in the
|
|
218
|
+
workspace, one they can't open themselves, and the key will fetch it onto
|
|
219
|
+
the board. If the board is read by people who shouldn't see every upload
|
|
220
|
+
in the workspace, use a key whose user sees only the mapped teams.
|
|
221
|
+
- **Out:** each file on a board message is uploaded to Linear's storage, and
|
|
222
|
+
a link to it is added to the comment or the new issue's description. An
|
|
223
|
+
image shows inline. The bytes go only to `storage.googleapis.com`, where
|
|
224
|
+
Linear's upload URLs point today, with only the storage's own headers from
|
|
225
|
+
Linear's answer; an upload URL anywhere else is refused and the file named.
|
|
226
|
+
|
|
227
|
+
A personal API key with read and write access fetches and uploads files.
|
|
228
|
+
What an OAuth app's scopes need for files has not been checked.
|
|
229
|
+
|
|
230
|
+
Linear's docs don't say whether `uploads.linear.app` answers with the file
|
|
231
|
+
or redirects to a storage host. The board follows no redirect, so if Linear
|
|
232
|
+
sends one, the file is named in the text instead of attached. This has not
|
|
233
|
+
been tried against Linear. See [Files](./01-overview.md#files) for the limits.
|
|
234
|
+
|
|
235
|
+
## Catching up
|
|
236
|
+
|
|
237
|
+
After downtime, and when a token is set, the ticker asks Linear for the issues in
|
|
238
|
+
the mapped teams updated since the last event it received, then the comments
|
|
239
|
+
on them. An issue created while the board was down arrives whole, with its
|
|
240
|
+
title, description and labels, and its comments as replies. A state change
|
|
241
|
+
missed meanwhile sets `state`, and what the issue is filed under now (its
|
|
242
|
+
labels, assignee, priority and project) is brought up to date, by `lin`: Linear's list doesn't say who
|
|
243
|
+
moved the issue, so the change is put down to the sync. An older issue updated while the board was down
|
|
244
|
+
starts a thread too. What the board already has, by webhook or because it
|
|
245
|
+
sent it, isn't imported again.
|
|
246
|
+
|
|
247
|
+
Edits and removals made while the board was down are not read; nor are they
|
|
248
|
+
for GitHub. One read takes up to 500 issues and 500 comments, oldest change
|
|
249
|
+
first, in pages of 50. If there are more, the next read goes on a minute
|
|
250
|
+
later from the newest change it read. If Linear refuses, a rate limit among
|
|
251
|
+
the reasons, it is asked again from the same point five minutes later. See
|
|
252
|
+
[After downtime](./01-overview.md#after-downtime) for the rest.
|
|
253
|
+
A file linked from an issue or comment read this way is fetched as one from a
|
|
254
|
+
webhook would be, with the same limits.
|
|
255
|
+
|
|
256
|
+
## Set it up
|
|
257
|
+
|
|
258
|
+
1. Create a key: Settings, Security & access, Personal API keys, with read
|
|
259
|
+
and write access. Or an OAuth app with permission to create issues and
|
|
260
|
+
comments.
|
|
261
|
+
2. Settings, API, Webhooks: add one pointing at
|
|
262
|
+
`https://<host>/api/board/webhooks/lin`, for **Issues** and **Comments**.
|
|
263
|
+
Limit it to the teams you map: one for all public teams also sends what
|
|
264
|
+
happens in the others, which the board then drops.
|
|
265
|
+
3. Put the key and the webhook's signing secret in the server's environment,
|
|
266
|
+
and name them in the board module with `env()`, as above.
|
|
267
|
+
4. Restart `mu serve`: it reads the module and the secrets only when it starts.
|
|
268
|
+
|
|
269
|
+
To check the key, ask Linear who it is and what teams it sees:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
curl -s https://api.linear.app/graphql -H "authorization: $LINEAR_API_KEY" \
|
|
273
|
+
-H 'content-type: application/json' -d '{"query":"{ viewer { id } teams { nodes { key } } }"}'
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
A new issue in a mapped team shows up on the board within seconds. If it
|
|
277
|
+
doesn't, a webhook answered `404` means `mu serve` was started before the
|
|
278
|
+
`lin` entry was added; `401` means the signing secret is not the webhook's.
|
|
279
|
+
|
|
280
|
+
## Turn tickets into tasks
|
|
281
|
+
|
|
282
|
+
A synced issue is a thread. Make it claimable when it should be worked:
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
mu tasks create 41
|
|
286
|
+
mu tasks claim --ready eng --as fixer
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
An agent or a watcher can do that for every new thread in the channel; which
|
|
290
|
+
ones deserve it is a judgment, so leave it to the agent.
|