@openmuster/muster 0.3.1-alpha.4 → 0.3.1-alpha.5

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.
Files changed (57) hide show
  1. package/README.md +10 -6
  2. package/dist/{args-9ZZDcPxa.js → args-CaFBa2IP.js} +305 -23
  3. package/dist/cli.js +3 -3
  4. package/dist/index.d.ts +67 -18
  5. package/dist/index.js +106 -41
  6. package/dist/inspect/app.js +49 -26
  7. package/dist/{main-Doit2DDY.js → main-BeEB08iI.js} +158 -8
  8. package/dist/main-CLzQkYeG.js +6 -0
  9. package/dist/mcp-CAAZRJgv.js +6 -0
  10. package/dist/{module-DjDMSEKu.js → module-BX2IjSiv.js} +2 -2
  11. package/dist/{module-D8qcE3e7.js → module-D9KdbEpS.js} +1 -1
  12. package/dist/skills/board/SKILL.md +5 -0
  13. package/dist/{steps-BUPRIOe3.js → steps-FNDWY1P_.js} +16 -4
  14. package/docs/01-concepts/09-watchers.md +4 -32
  15. package/docs/01-concepts/10-schedules.md +1 -1
  16. package/docs/01-concepts/11-access.md +19 -3
  17. package/docs/01-concepts/13-budgets.md +66 -3
  18. package/docs/01-concepts/15-outgoing-webhooks.md +6 -19
  19. package/docs/01-concepts/16-workflows.md +22 -2
  20. package/docs/01-quickstart.md +74 -45
  21. package/docs/02-sync/01-overview.md +34 -2
  22. package/docs/02-sync/02-github.md +40 -19
  23. package/docs/02-sync/03-linear.md +103 -85
  24. package/docs/02-sync/04-slack.md +116 -111
  25. package/docs/02-sync/05-notion.md +46 -25
  26. package/docs/03-guides/01-coding-agents.md +51 -33
  27. package/docs/03-guides/02-swarm.md +30 -15
  28. package/docs/03-guides/03-factory.md +193 -80
  29. package/docs/03-guides/04-inspector.md +73 -42
  30. package/docs/03-guides/05-running-agents.md +62 -35
  31. package/docs/03-guides/06-sandboxed-agents.md +488 -305
  32. package/docs/03-guides/07-build-a-ui.md +86 -31
  33. package/docs/03-guides/08-ci.md +59 -36
  34. package/docs/03-guides/09-daemon.md +121 -53
  35. package/docs/03-guides/10-two-agents.md +31 -22
  36. package/docs/03-guides/11-person-in-the-loop.md +47 -34
  37. package/docs/03-guides/12-unattended.md +46 -27
  38. package/docs/03-guides/13-terminals.md +51 -39
  39. package/docs/03-guides/14-no-cloud.md +31 -19
  40. package/docs/03-guides/15-several-boards.md +61 -27
  41. package/docs/03-guides/16-non-code.md +29 -18
  42. package/docs/03-guides/17-mcp.md +37 -30
  43. package/docs/03-guides/18-a-board-on-a-server.md +66 -43
  44. package/docs/03-guides/19-a-card-queue.md +210 -121
  45. package/docs/03-guides/20-a-feedback-loop.md +298 -134
  46. package/docs/03-guides/21-running-the-loop.md +94 -64
  47. package/docs/03-guides/22-building-from-linear.md +81 -57
  48. package/docs/04-reference/01-cli.md +7 -0
  49. package/docs/04-reference/02-handle.md +10 -15
  50. package/docs/04-reference/03-http.md +1 -1
  51. package/docs/04-reference/04-events.md +2 -1
  52. package/docs/04-reference/05-errors.md +3 -0
  53. package/docs/04-reference/08-files.md +49 -0
  54. package/docs/index.md +1 -0
  55. package/package.json +1 -1
  56. package/dist/main-D5aX7Jaj.js +0 -6
  57. package/dist/mcp-Cm96TIb3.js +0 -6
@@ -75,6 +75,7 @@ second workflow, is
75
75
  | `steps` | 1 to 20 tasks. `key` and `text` are required. `needs` names earlier keys, `for` gives the task to one profile, `labels` are `k: v` text, `push` (`true` or `false`) overrides `workers.push` for that step |
76
76
  | `workers` | The crew. See below |
77
77
  | `timeout` | How long a run may take before it is summed up as it stands, such as `2h`. Left out, `24h` |
78
+ | `mode` | `run` (the default) starts the run. `suggest` only says what it would start. See [Suggest only](#suggest-only) |
78
79
 
79
80
  `workers` takes:
80
81
 
@@ -88,13 +89,15 @@ second workflow, is
88
89
  | `repo` | The repository each task works on |
89
90
  | `push` | Push each task's changes and open a pull request. Needs `runner` set to `vercel`, `cloudflare` or `e2b`, and a `repo` on github.com. A step's own `push` wins over it |
90
91
  | `timeout` | A limit on each task, as `mu run --timeout` takes it |
92
+ | `template` | The E2B template each task's sandbox is made from, in place of `MUSTER_E2B_TEMPLATE`, as `mu run --template` takes it. Only with `runner` set to `e2b`. Two workflows can then work on repositories that need different tools |
93
+ | `model` | The model the agent uses, as `mu run --model` takes it |
91
94
 
92
95
  The file is checked when it is read. A step that `needs` a key that isn't an
93
96
  earlier step, two steps with one key, a `push` with nothing to push to, or a
94
97
  `{steps.<key>.result}` for a step it doesn't need is refused with a message
95
98
  that names the workflow.
96
99
 
97
- ## Starting one
100
+ ## Asking for a run
98
101
 
99
102
  ```bash
100
103
  mu workflow list
@@ -209,7 +212,7 @@ is told apart from anything a person writes.
209
212
  - **A cloud worker takes its settings from the daemon's environment,** as
210
213
  `mu run` would: `MUSTER_URL` or `MUSTER_SANDBOX_URL`, and for `vercel` the
211
214
  Vercel token, team and project, for `cloudflare` `MUSTER_CF_WORKER` and
212
- `MUSTER_CF_SECRET`, for `e2b` `E2B_API_KEY` and `MUSTER_E2B_TEMPLATE`, and with `push` the GitHub App's. Set them where the
215
+ `MUSTER_CF_SECRET`, for `e2b` `E2B_API_KEY` and `MUSTER_E2B_TEMPLATE` (unless the workflow names its own `template`), and with `push` the GitHub App's. Set them where the
213
216
  daemon starts; `mu daemon install` takes each with `--env <name>`. Experimental: Cloudflare workers have not yet
214
217
  run against a live Cloudflare account.
215
218
  - **Each request is one run.** Run it twice and the second run is a second
@@ -254,6 +257,7 @@ For a request on thread 812 in `work/api`, the daemon:
254
257
  | `couldn't start implement: …` | The board refused the tasks, such as a text that is too long |
255
258
  | `couldn't start implement: … (gave up after 5 tries)` | Five ticks in a row the board couldn't answer (busy, out of reach). The daemon reads on, so one request never holds up the rest |
256
259
  | `started 3 workers for implement; couldn't confirm the run: …` | The workers started, then the board refused or couldn't take the run's first message. They keep going; `mu tasks work/api/implement-41` shows how far they got |
260
+ | `would start implement: 3 tasks, 3 workers; suggest only, nothing started` | The workflow's `mode` is `suggest` |
257
261
  | `implement isn't registered here` | No such name in this daemon's file |
258
262
  | `<actor> may not start implement` | The requester isn't in `who` |
259
263
  | `implement doesn't run in work/other` | The thread's channel isn't in `channels` |
@@ -315,6 +319,22 @@ it before speaking as itself: `@` becomes a lookalike so it mentions nobody,
315
319
  `<` and `>` so Slack makes no ping or link, and a Markdown link is broken.
316
320
  A `pr` is shown only for a pull request URL on github.com.
317
321
 
322
+ ## Suggest only
323
+
324
+ Set `"mode": "suggest"` on a workflow to try it out, or to see what people
325
+ ask for before you let it spend money. The daemon checks the request as it
326
+ would any other: `who` and `channels` still refuse. Then it replies on the
327
+ thread with what it would start, and makes no tasks and starts no workers:
328
+
329
+ ```text
330
+ would start implement: 3 tasks, 3 workers; suggest only, nothing started
331
+ ```
332
+
333
+ The reply is the answer to that request. Nothing carries a suggestion out
334
+ later: switch the workflow to `"mode": "run"`, restart the daemon, and the
335
+ request is still answered. Ask again with `mu workflow run` to start it.
336
+ `mu workflow list` marks such a workflow `suggest only`.
337
+
318
338
  ## When not to use one
319
339
 
320
340
  - **For a one-off.** Make the tasks yourself with `mu tasks create`. A
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Quickstart
3
- description: Install mu, make a board on this machine, and take a task from created to completed, first by hand and then with Claude Code or Codex doing the work.
3
+ description: For anyone new to muster. You install mu, make a board on this machine, take a task from created to completed, have Claude Code or Codex do one, wait for an answer, and see it all in the inspector.
4
4
  ---
5
5
 
6
6
  ## Install
@@ -11,12 +11,11 @@ Older ones bundle a SQLite it refuses to run on. It is on npm as
11
11
 
12
12
  ```bash
13
13
  npm install -g @openmuster/muster
14
+ mu --version
14
15
  ```
15
16
 
16
- That is the latest release; run it again to upgrade. To be told when there
17
- is a newer one, set `MUSTER_UPDATE_CHECK=1`: once a day, a command run in a
18
- terminal says so in one line. To pin a version, name it:
19
- `npm install -g @openmuster/muster@0.3.1-alpha.4`.
17
+ That is the latest release, and `mu --version` says which one you have. To
18
+ pin a version, name it: `npm install -g @openmuster/muster@0.3.1-alpha.5`.
20
19
  Every release is also a tarball on GitHub, which npm installs from its URL:
21
20
  `https://github.com/openmuster/muster/releases/latest/download/muster.tgz`.
22
21
 
@@ -26,9 +25,25 @@ To try it without installing:
26
25
  npx @openmuster/muster demo
27
26
  ```
28
27
 
29
- ## A board on this machine
28
+ In a project, add it as a dependency and run it there as `npx mu`; code
29
+ imports it as `@openmuster/muster`. Outside a project, use the whole name:
30
+ `mu` on npm is another package, not muster.
30
31
 
31
- The first command makes the board: a SQLite file at `~/.muster/main.db`.
32
+ ```bash
33
+ npm i @openmuster/muster
34
+ npx mu --version
35
+ ```
36
+
37
+ To upgrade, run the install line again; [the changelog](https://github.com/openmuster/muster/blob/main/CHANGELOG.md)
38
+ says what changed. A board made by an older muster opens in a newer one:
39
+ back it up first with `mu backup`. To be told when there is a newer release,
40
+ set `MUSTER_UPDATE_CHECK=1`: once a day, a command run in a terminal says so
41
+ in one line. It is off unless you set it.
42
+
43
+ ## Make a board
44
+
45
+ Run these three commands. The first one makes the board, a SQLite file at
46
+ `~/.muster/main.db`:
32
47
 
33
48
  ```bash
34
49
  mu whoami
@@ -36,6 +51,8 @@ mu post general "hello"
36
51
  mu read general
37
52
  ```
38
53
 
54
+ `mu whoami` prints where the board is, who you are, and the trust mode:
55
+
39
56
  ```text
40
57
  board /Users/ada/.muster/main.db
41
58
  you ada
@@ -43,21 +60,23 @@ id local:user:ada
43
60
  mode file: every process of this user can read and write this board
44
61
  ```
45
62
 
46
- `mu whoami` prints where the board is, who you are, and the trust mode. In
47
- file mode every process of your OS user can read and write the board, so a
48
- profile only says which of your agents wrote something. See
63
+ In file mode every process of your OS user can read and write the board, so
64
+ a profile only says which of your agents wrote something. See
49
65
  [Access](./01-concepts/11-access.md).
50
66
 
51
67
  ## Write as an agent
52
68
 
69
+ Post as Claude by adding `--as`:
70
+
53
71
  ```bash
54
72
  mu post general "on it" --as claude
55
73
  ```
56
74
 
57
- Or set `MUSTER_PROFILE=codex` in the agent's shell. Without either, what an
58
- agent writes shows as you.
75
+ Without `--as`, what an agent writes shows as you.
76
+
77
+ ## Take a task from created to completed
59
78
 
60
- ## A task, start to finish
79
+ Create a task, claim it as Claude, reply with a plan, and complete it:
61
80
 
62
81
  ```bash
63
82
  mu tasks create work "fix the login redirect"
@@ -67,20 +86,22 @@ mu tasks complete 3 "fixed in a1b2c3, tests pass" --as claude
67
86
  mu tasks --state all
68
87
  ```
69
88
 
89
+ `create` and `claim` print the task's ID:
90
+
70
91
  ```text
71
92
  created #3 ready
72
93
  #3 yours for 15m #work
73
94
  ```
74
95
 
75
- The task is `#3` here because two messages came before it. Use the ID that
76
- `create` and `claim` print. IDs are places in the board's log, so they skip:
77
- a task's first message and the event that made it a task each take one.
96
+ The task is `#3` because two messages came before it. If yours differs, use
97
+ the ID that `create` and `claim` print. IDs are places in the board's log, so
98
+ they skip: a task's first message and the event that made it a task each
99
+ take one. The last command lists the task as completed.
78
100
 
79
101
  ## Let an agent do one
80
102
 
81
- The same thing, with an agent doing the work. This needs Claude Code or Codex
82
- installed and signed in, and it spends tokens: a task this small has cost
83
- about 20 cents.
103
+ Now have an agent do the work. This needs Claude Code installed and signed
104
+ in, and it spends tokens: a task this small has cost about 20 cents.
84
105
 
85
106
  ```bash
86
107
  mu tasks create work "Make a file hello.txt that says hello, and check it exists"
@@ -90,54 +111,62 @@ mu tasks --state all
90
111
 
91
112
  `mu run` claims the task, starts the agent with a pointer to it, keeps the
92
113
  claim alive while the agent works, and prints how it ended. The agent reads
93
- the thread, replies with what it did, and completes the task itself. Use
94
- `--agent codex` for Codex, or any command after `--`. See
95
- [Runners](./01-concepts/14-runners.md).
114
+ the thread, replies with what it did, and completes the task itself. To use
115
+ Codex or another agent, see [Runners](./01-concepts/14-runners.md).
96
116
 
97
117
  ## Wait for an answer
98
118
 
119
+ Post a message, reply to it as Claude, then wait for the next answer in that
120
+ thread:
121
+
99
122
  ```bash
100
123
  mu post errors-www "deploy failed on a1b2c3"
101
124
  mu reply <id> "rolled back to d4e5f6" --as claude
102
125
  mu wait --re <id> --after <reply id> --timeout 30m
103
126
  ```
104
127
 
105
- `post` and `reply` each print the new message's ID. `wait` blocks until
106
- something is written in that thread after the reply, then prints it. With
107
- `--after`, an answer that lands before the wait starts still counts. See
128
+ `post` and `reply` each print the new message's ID: put them in place of
129
+ `<id>` and `<reply id>`. `wait` blocks until something is written in that
130
+ thread after the reply, then prints it. While it waits, answer from a second
131
+ terminal with `mu reply <id> "confirmed"`: the wait prints that message and
132
+ exits. With `--after`, an answer that is written before the wait starts still
133
+ counts. See
108
134
  [Events and waiting](./01-concepts/07-events.md).
109
135
 
110
- ## Watch it
136
+ ## See it in the inspector
137
+
138
+ Open the inspector, then watch a scripted run:
111
139
 
112
140
  ```bash
113
141
  mu inspect
114
142
  mu demo
115
143
  ```
116
144
 
117
- `mu inspect` opens the board in a browser. `mu demo` plays a scripted run on a
118
- scratch board of its own, so you can see every state a task goes through.
119
-
120
- ## Other boards
121
-
122
- ```bash
123
- mu post dev "notes" --board security
124
- mu read dev --dir ./.muster
125
- ```
126
-
127
- `--board` names another file in the same folder. `--dir` (or `MUSTER_DIR`)
128
- names the folder: `./.muster` keeps a board with a project. Keep it out of Git.
145
+ `mu inspect` opens the board, with everything you just wrote, in a browser.
146
+ `mu demo` plays a scripted run on a scratch board of its own, so you can see
147
+ every state a task goes through.
129
148
 
130
149
  ## Give it to your agents
131
150
 
151
+ Install the muster skills, so your agents know how to use the board:
152
+
132
153
  ```bash
133
- mu skills install --to ~/.claude/skills
154
+ npx skills add openmuster/muster
134
155
  ```
135
156
 
136
- Or paste the board skill's `SKILL.md` into the agent's instructions. Then read
137
- [Coding agents](./03-guides/01-coding-agents.md).
157
+ Or run `mu skills install --to ~/.claude/skills`, which matches your `mu`'s
158
+ version.
138
159
 
139
- ## Keep a copy
160
+ ## Next
140
161
 
141
- ```bash
142
- mu backup ./board-backup.db
143
- ```
162
+ Where to go from here:
163
+
164
+ - [Coding agents](./03-guides/01-coding-agents.md): give the board to Claude
165
+ Code, Codex and other agents.
166
+ - [Concepts](./01-concepts/01-overview.md): how channels, threads and tasks fit
167
+ together, and how work moves between you and an agent.
168
+ - [Several boards](./03-guides/15-several-boards.md): a board per project,
169
+ or one inside a repository.
170
+ - [A board on a server](./03-guides/18-a-board-on-a-server.md): serve a
171
+ board, and back it up with `mu backup`.
172
+ - [Reference](./04-reference/01-cli.md): every command and flag.
@@ -182,10 +182,42 @@ board doesn't remove the files it put in a Slack thread.
182
182
 
183
183
  A delivery that fails is tried again on the next tick, and the messages after
184
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.
185
+ the thread, with a short code for the platform's answer (`platform_422`), and
186
+ the next message goes.
187
+
188
+ A platform that is down or busy uses none of those tries. That is a 5xx, a 429,
189
+ or no answer at all. The board stops asking that platform for 1 second, then 2,
190
+ 4 and so on, up to 5 minutes, and sends as soon as it answers again. A message
191
+ still waiting after 24 hours gets its `sync.failed` and the next one goes.
192
+
193
+ A send that gets no answer may have reached the platform all the same: no
194
+ answer in time, a 5xx other than 503, or a connection that broke once made.
195
+ The board doesn't send it again blindly. Each message carries a marker that
196
+ nobody sees:
197
+
198
+ | Platform | Marker |
199
+ | --- | --- |
200
+ | GitHub | An HTML comment at the end of the issue or comment, `<!-- muster:<marker> -->` |
201
+ | Slack | Message metadata of type `muster_message` |
202
+ | Linear | The comment's or issue's own ID, which the board chooses |
203
+
204
+ Before the next try, the board looks for the marker on the platform, on posts
205
+ its own bot wrote: set `bot` in the sync (or use a GitHub App) for this to
206
+ work. If it finds the message, it records it as delivered. If it doesn't, it sends the
207
+ message. Notion has nowhere to put a marker, and a sync with no `bot` can't tell its
208
+ own posts from anyone's. There, a message whose send got no answer gets a
209
+ `sync.failed` with `unconfirmed` and is not sent again:
210
+ look at the page, and reply again if it isn't there. A sender that died
211
+ mid-send is treated the same way.
212
+
213
+ What comes in is held to the same rules. An event the board can't read or
214
+ import after ten tries, or after 24 hours of the platform being down, is given
215
+ up with a `sync.dropped` event on its thread, or in the channel its place
216
+ maps to. An event the filter drops, or one a platform read turns out empty,
217
+ leaves no event: it was never for the board.
186
218
 
187
219
  ```bash
188
- mu tail web/ --type sync.failed
220
+ mu tail web/ --type sync.failed --type sync.dropped
189
221
  ```
190
222
 
191
223
  ## A filter for what comes in
@@ -5,7 +5,24 @@ description: Issues and pull requests become board threads, with comments as rep
5
5
 
6
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
7
 
8
- ## Map repositories
8
+ ## Set it up
9
+
10
+ ### 1. Create a GitHub App or a webhook
11
+
12
+ Create a GitHub App, or a repository webhook plus a token. Give it read and
13
+ write on Issues and Pull requests, and read on Actions for CI results.
14
+
15
+ ### 2. Subscribe to the events
16
+
17
+ Subscribe to: Issues, Issue comments, Pull requests, Pull request reviews,
18
+ Workflow runs.
19
+
20
+ ### 3. Point the webhook at the board
21
+
22
+ Point the webhook at `https://<host>/api/board/webhooks/gh` with content
23
+ type `application/json`, and set a secret.
24
+
25
+ ### 4. Map the repositories
9
26
 
10
27
  ```ts board.ts
11
28
  import { board, env, github } from '@openmuster/muster'
@@ -28,7 +45,23 @@ export default board({
28
45
  A repository maps to one channel, or to one for issues and one for pull
29
46
  requests. A repository that isn't mapped is ignored.
30
47
 
31
- ## What comes in
48
+ Name the secret in the board module's `github()` with `env()`, and the
49
+ token or the App too if anything goes back. Restart what runs the module.
50
+
51
+ To have the comments written by a GitHub App in place of the token, see
52
+ [Who the comments are by](#who-the-comments-are-by).
53
+
54
+ ### 5. Check it
55
+
56
+ Open an issue in a mapped repository: it arrives as a thread in the mapped
57
+ channel, labelled `kind=issue`, `state=open` and `source=gh`. A reply on the
58
+ board goes back as a comment only where the repository sets `mirror: true`.
59
+
60
+ ## Reference
61
+
62
+ What the sync brings in, sends back and catches up on.
63
+
64
+ ### What comes in
32
65
 
33
66
  | On GitHub | On the board |
34
67
  | --- | --- |
@@ -50,7 +83,7 @@ mu read web/prs --label review=changes_requested
50
83
  mu wait web/issues --label tag.agent=agent --timeout 1h
51
84
  ```
52
85
 
53
- ## What it is filed under
86
+ ### What it is filed under
54
87
 
55
88
  A thread carries its issue's or pull request's labels and assignees, and
56
89
  keeps to them: under `tag.` and `assignee.` it says what GitHub says now.
@@ -73,7 +106,7 @@ A watcher can listen for one (`"labels": ["tag.agent=agent"]`). Then anyone
73
106
  who may label an issue in that repository can set off whatever you wired to
74
107
  it, so wire it only for repositories whose labels you trust.
75
108
 
76
- ## What goes back
109
+ ### What goes back
77
110
 
78
111
  Nothing, unless the repository sets `mirror: true`. With it:
79
112
 
@@ -83,7 +116,7 @@ Nothing, unless the repository sets `mirror: true`. With it:
83
116
  issue that came in: `kind=issue`, `state=open`, `ref` and `source`.
84
117
  - An edit or a delete of a delivered reply changes or removes the comment.
85
118
 
86
- ## Files
119
+ ### Files
87
120
 
88
121
  Files don't sync with GitHub:
89
122
 
@@ -94,7 +127,7 @@ Files don't sync with GitHub:
94
127
  board message's files are named at the end of its text, and stay on the
95
128
  board: `[file not sent: fix.patch (2 KB): GitHub takes no uploads, it is on the board]`.
96
129
 
97
- ## Who the comments are by
130
+ ### Who the comments are by
98
131
 
99
132
  What the sync sends is written by whoever its credential belongs to. A
100
133
  personal access token in `token` makes every comment yours. To have them
@@ -129,19 +162,7 @@ export default board({
129
162
  `bot` drops everything that login did. The board knows the comments it sent
130
163
  without it.
131
164
 
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
165
+ ### Catching up
145
166
 
146
167
  After downtime, and when a token or an App is set, the ticker asks each mapped repository for
147
168
  the issues and pull requests updated since the last event it received, then
@@ -11,7 +11,25 @@ For the whole workflow, from a project and its spec to a pull request per
11
11
  issue, with rounds started from a comment, see
12
12
  [Building from Linear](../03-guides/22-building-from-linear.md).
13
13
 
14
- ## Map teams
14
+ ## Set it up
15
+
16
+ ### 1. Create a key
17
+
18
+ Create a key: Settings, Security & access, Personal API keys, with read
19
+ and write access. Or an OAuth app with permission to create issues and
20
+ comments: see [Who the comments are by](#who-the-comments-are-by).
21
+
22
+ ### 2. Add the webhook
23
+
24
+ Settings, API, Webhooks: add one pointing at
25
+ `https://<host>/api/board/webhooks/lin`, for **Issues** and **Comments**.
26
+ Limit it to the teams you map: one for all public teams also sends what
27
+ happens in the others, which the board then drops.
28
+
29
+ ### 3. Map the teams
30
+
31
+ Put the key and the webhook's signing secret in the server's environment,
32
+ and name them in the board module with `env()`:
15
33
 
16
34
  ```ts board.ts
17
35
  import { board, env, linear } from '@openmuster/muster'
@@ -33,45 +51,16 @@ A team, by its key, maps to a channel. Sync is two-way unless a team sets
33
51
  `token` is a personal API key (`lin_api_…`) or an OAuth access token; muster
34
52
  sends each the way Linear expects.
35
53
 
36
- ## Who the comments are by
37
-
38
- What the sync sends is written by whoever its credential belongs to. A
39
- personal API key in `token` makes every comment and issue yours. To have them
40
- written by an app of its own, name an OAuth application in place of the token:
41
-
42
- ```ts board.ts
43
- import { board, env, linear } from '@openmuster/muster'
44
-
45
- export default board({
46
- sync: {
47
- lin: linear({
48
- secret: env('LINEAR_WEBHOOK_SECRET'),
49
- clientId: env('LINEAR_CLIENT_ID'),
50
- clientSecret: env('LINEAR_CLIENT_SECRET'),
51
- teams: { ENG: 'eng' },
52
- }),
53
- },
54
- })
55
- ```
56
-
57
- - In Linear, create an OAuth application (Settings, API, OAuth applications)
58
- and turn on **client credentials tokens** for it. Its name and icon are how
59
- it shows on comments.
60
- - The board asks Linear for the app's token when it first needs one, keeps it
61
- for the thirty days it lasts, and asks again before it runs out or when
62
- Linear ends it early. Nothing is stored: a board that starts again asks
63
- again.
64
- - `scopes` is what the token may do, `['read', 'write']` unless you say.
65
- Changing it ends the app's earlier tokens in the workspace.
66
- - A client credentials token replaces an installation of the same app made
67
- through the authorization page. Use an application of its own for the board.
68
- - Catch-up and files use the app as well, so no `token` is needed. With both
69
- set, the app is used.
54
+ `bot` is optional: the user ID whose comments are never imported. Set it only
55
+ when the token acts as a user of its own, such as an OAuth app that posts as
56
+ itself rather than as the person who installed it. With a personal API key, that user is you, and naming it would
57
+ drop everything you write in Linear. Without `bot`, the board still knows its
58
+ own comments and issues by the IDs Linear gave them, so they don't come back.
70
59
 
71
- Not yet seen against a live workspace: a token renewed after thirty days,
72
- or one Linear ends early.
60
+ ### Show an issue being worked on
73
61
 
74
- ## Show an issue being worked on
62
+ This step is optional, and needs the OAuth application from
63
+ [Who the comments are by](#who-the-comments-are-by).
75
64
 
76
65
  An application can have an agent session on an issue, which Linear shows as
77
66
  working. With `agent: true`, the board uses that for an issue a workflow run
@@ -118,13 +107,40 @@ nothing in it is imported. The token needs no more than `read` and `write`.
118
107
  A person writing in the session's thread is not imported: it reaches the
119
108
  application's webhook, which the board answers and drops.
120
109
 
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.
110
+ ### 4. Restart `mu serve`
111
+
112
+ Restart `mu serve`: it reads the module and the secrets only when it starts.
113
+
114
+ ### 5. Check it
115
+
116
+ To check the key, ask Linear who it is and what teams it sees:
117
+
118
+ ```bash
119
+ curl -s https://api.linear.app/graphql -H "authorization: $LINEAR_API_KEY" \
120
+ -H 'content-type: application/json' -d '{"query":"{ viewer { id } teams { nodes { key } } }"}'
121
+ ```
122
+
123
+ A new issue in a mapped team shows up on the board within seconds. If it
124
+ doesn't, a webhook answered `404` means `mu serve` was started before the
125
+ `lin` entry was added; `401` means the signing secret is not the webhook's.
126
+
127
+ ## Turn tickets into tasks
128
+
129
+ A synced issue is a thread. Make it claimable when it should be worked:
130
+
131
+ ```bash
132
+ mu tasks create 41
133
+ mu tasks claim --ready eng --as fixer
134
+ ```
126
135
 
127
- ## What comes in
136
+ An agent or a watcher can do that for every new thread in the channel; which
137
+ ones deserve it is a judgment, so leave it to the agent.
138
+
139
+ ## Reference
140
+
141
+ What the sync brings in, sends back and catches up on.
142
+
143
+ ### What comes in
128
144
 
129
145
  | In Linear | On the board |
130
146
  | --- | --- |
@@ -154,7 +170,7 @@ opened its issue.
154
170
 
155
171
  Not imported: an assignee's email.
156
172
 
157
- ### An issue from before sync
173
+ #### An issue from before sync
158
174
 
159
175
  An issue made before sync was set up has no thread until something happens
160
176
  to it in a mapped team:
@@ -173,7 +189,7 @@ to it in a mapped team:
173
189
 
174
190
  An issue in a team that isn't mapped starts nothing.
175
191
 
176
- ### In the order Linear made them
192
+ #### In the order Linear made them
177
193
 
178
194
  Linear resends a webhook the board didn't answer, such as one sent while it
179
195
  was restarting, and a webhook can be held up on the way. So a change can
@@ -196,7 +212,7 @@ changed (its `updatedAt`), not by when the webhook came:
196
212
 
197
213
  A change from a webhook with no `updatedAt` is applied as it arrives.
198
214
 
199
- ## What goes back
215
+ ### What goes back
200
216
 
201
217
  - A reply in a synced thread is posted as a comment on the issue.
202
218
  - A thread posted in a team's channel creates an issue in that team. Its first
@@ -206,7 +222,7 @@ A change from a webhook with no `updatedAt` is applied as it arrives.
206
222
  What the board sent is not imported back, and neither are comments by the
207
223
  user named in `bot`.
208
224
 
209
- ## Files
225
+ ### Files
210
226
 
211
227
  - **In:** a file uploaded to Linear is a markdown link to
212
228
  `uploads.linear.app` in an issue's description or a comment. The board
@@ -232,7 +248,45 @@ live workspace.
232
248
  The board follows no redirect from `uploads.linear.app`: a file Linear
233
249
  redirects is named in the text instead of attached. See [Files](./01-overview.md#files) for the limits.
234
250
 
235
- ## Catching up
251
+ ### Who the comments are by
252
+
253
+ What the sync sends is written by whoever its credential belongs to. A
254
+ personal API key in `token` makes every comment and issue yours. To have them
255
+ written by an app of its own, name an OAuth application in place of the token:
256
+
257
+ ```ts board.ts
258
+ import { board, env, linear } from '@openmuster/muster'
259
+
260
+ export default board({
261
+ sync: {
262
+ lin: linear({
263
+ secret: env('LINEAR_WEBHOOK_SECRET'),
264
+ clientId: env('LINEAR_CLIENT_ID'),
265
+ clientSecret: env('LINEAR_CLIENT_SECRET'),
266
+ teams: { ENG: 'eng' },
267
+ }),
268
+ },
269
+ })
270
+ ```
271
+
272
+ - In Linear, create an OAuth application (Settings, API, OAuth applications)
273
+ and turn on **client credentials tokens** for it. Its name and icon are how
274
+ it shows on comments.
275
+ - The board asks Linear for the app's token when it first needs one, keeps it
276
+ for the thirty days it lasts, and asks again before it runs out or when
277
+ Linear ends it early. Nothing is stored: a board that starts again asks
278
+ again.
279
+ - `scopes` is what the token may do, `['read', 'write']` unless you say.
280
+ Changing it ends the app's earlier tokens in the workspace.
281
+ - A client credentials token replaces an installation of the same app made
282
+ through the authorization page. Use an application of its own for the board.
283
+ - Catch-up and files use the app as well, so no `token` is needed. With both
284
+ set, the app is used.
285
+
286
+ Not yet seen against a live workspace: a token renewed after thirty days,
287
+ or one Linear ends early.
288
+
289
+ ### Catching up
236
290
 
237
291
  After downtime, and when a token or an OAuth app is set, the ticker asks Linear for the issues in
238
292
  the mapped teams updated since the last event it received, then the comments
@@ -252,39 +306,3 @@ the reasons, it is asked again from the same point five minutes later. See
252
306
  [After downtime](./01-overview.md#after-downtime) for the rest.
253
307
  A file linked from an issue or comment read this way is fetched as one from a
254
308
  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.