@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
@@ -1,24 +1,26 @@
1
1
  ---
2
2
  title: A feedback loop
3
- description: For steering a project from reports in Slack, Linear, GitHub, Notion or your app. Each report is triaged into a spec, an agent opens a pull request, and a trusted reply starts another round on the same pull request.
3
+ description: For steering a project from reports in Slack, Linear, GitHub, Notion or your app. You end with a loop that triages each report into a spec, has an agent open a pull request, and starts another round on that pull request from a trusted reply.
4
4
  ---
5
5
 
6
6
  ## Who this is for
7
7
 
8
8
  You build something with agents and want to steer it from wherever you are:
9
- a report in Slack, a Linear issue, a Notion page, a button in the app itself. Each report
10
- should become a card with a proper title and spec, the change should come
11
- back as a pull request with screenshots, and a reply on the card should send
12
- it round again, on the same pull request, until it is right.
9
+ a report in Slack, a Linear issue, a Notion page, a button in the app
10
+ itself. Each report should become a card with a proper title and spec. The
11
+ change should come back as a pull request with screenshots. A reply on the
12
+ card should start another round, on the same pull request, until it is
13
+ right.
13
14
 
14
15
  **You need:** what [A card queue](./19-a-card-queue.md) needs (muster where
15
16
  the board is, `mu serve` behind a tunnel or a proxy, a Vercel project for the
16
17
  sandboxes, a GitHub App on the repository, a model key), and the keys for
17
18
  the sources you sync.
18
19
 
19
- ## The parts
20
+ ## How it fits together
20
21
 
21
- `templates/loop` is a board module and a workflow file:
22
+ `templates/loop` is a [board module](../01-concepts/17-board-module.md) and a
23
+ workflow file:
22
24
 
23
25
  ```mermaid
24
26
  flowchart LR
@@ -31,58 +33,87 @@ flowchart LR
31
33
  C -->|a trusted reply| W
32
34
  ```
33
35
 
34
- - **A card is a thread and a task.** Its hold says where it is: `backlog`
35
- while it is parked, `planning` while an agent shapes it with you, `triage`, `approval`, `working`,
36
- `declined` when the triage made no card, `done` when its run was approved
37
- but it couldn't be completed, or `edited` when its author changed the
38
- report.
39
- - **Each source has its own channel** under `cards/`: `cards/slack`,
40
- `cards/linear`, `cards/github`, `cards/notion`, `cards/app`. A card's runs are in channels
41
- under its own, so the card is what Slack and Linear mirror.
36
+ - **A card is a thread and a task.** Its
37
+ [hold](../01-concepts/08-tasks.md#states) (the kind of block on its task)
38
+ says where it is:
39
+ - `backlog`: [parked](../01-concepts/08-tasks.md#parking-work-for-later),
40
+ and nothing runs until it is moved to ready
41
+ - `planning`: an agent shapes it with you
42
+ - `triage`: an agent is turning the report into a spec
43
+ - `approval`: the spec is on the card, and the report's author isn't
44
+ trusted
45
+ - `working`: the `card` workflow is making the change, as a pull request
46
+ - `duplicate`: the triage found the same request on another card
47
+ - `declined`: the triage made no card
48
+ - `done`: its run was approved but it couldn't be completed
49
+ - `edited`: its author changed the report
50
+ - `queued`: its change, or its next round, waits for a run to end, under a
51
+ cap on runs
52
+ - **Each source has its own channel.** The channels are under `cards/`:
53
+ `cards/slack`, `cards/linear`, `cards/github`, `cards/notion`,
54
+ `cards/app`. A card's runs are in channels under the card's own, so the
55
+ card is what Slack and Linear mirror.
42
56
  - **The triage agent writes the card.** It reads the report and the
43
57
  repository, changes nothing, and completes with a title on the first line,
44
58
  then what to change and how to check it. The spec goes on the card as a
45
59
  reply, written as `triage`, only when the triage run's own worker completed
46
60
  it.
47
- - **The card run quotes that reply** with `{on.text}`, fenced as content,
48
- not instructions. The triage step alone reads the report.
61
+ - **The card run quotes that reply.** It quotes it with `{on.text}`, fenced
62
+ as content, not instructions. Only the triage step reads the report.
49
63
 
50
64
  ## Set it up
51
65
 
66
+ Copy the workflows, set who is trusted, and start the board with the loop's
67
+ module:
68
+
52
69
  ```bash
53
70
  cp templates/loop/workflows.json ~/.config/muster/
54
71
  export LOOP_TRUSTED=slack:user:U0123,lin:user:3f2a9c1e-4b7d-4e0a-9a51-7c2d8e6b1f03
55
72
  mu serve --module "$PWD/templates/loop/board.ts" --allow-host board.example.com
56
73
  ```
57
74
 
75
+ Replace the IDs in `LOOP_TRUSTED` with your own:
76
+ [Who may start work](#who-may-start-work) says how to write one.
77
+
58
78
  Edit `board.ts` for your Slack channel's ID, your Linear team's key and your
59
79
  repository, and `workflows.json` for your repository. Put the settings in the
60
- environment `mu serve` starts with, as for [a card queue](./19-a-card-queue.md#set-it-up),
61
- with the secrets `board.ts` names in `env()`.
80
+ environment `mu serve` starts with, as for
81
+ [a card queue](./19-a-card-queue.md#set-it-up), with the secrets `board.ts`
82
+ names in `env()`.
83
+
84
+ For more than one repository, set this up once and add each repository as a
85
+ project:
86
+ [Run several repositories on one board](#run-several-repositories-on-one-board).
62
87
 
63
88
  ## Who may start work
64
89
 
65
- `LOOP_TRUSTED` is a comma-separated list of actor IDs: a Slack user is
66
- `<sync key>:user:<their ID>`, an app posting with a token you made is
67
- `<your principal>+<its profile>`. You, as yourself with no profile, always
68
- are. Read it each time a card moves, so a change takes effect at once.
69
-
70
- - **A trusted author's report** is worked as soon as it is triaged, as long
71
- as it is as they first wrote it.
72
- - **Anyone else's** waits, held `approval`, and you are told. Someone trusted
73
- labels it `approved=yes` (`mu label 12 approved=yes`, or in the inspector).
74
- A label by anyone else does nothing.
75
- - **An author sync couldn't name** is never trusted, nor a GitHub author:
76
- GitHub's sync names one by login, which can change hands, so a GitHub
77
- issue always waits for an approval.
78
- - **The work never reads the report.** The card run quotes the spec that was
79
- triaged (and approved, where it had to be) with `{on.text}`, never the
80
- report itself.
90
+ `LOOP_TRUSTED` is a comma-separated list of actor IDs. A Slack user is
91
+ `<sync key>:user:<their ID>`. An app posting with a token you made is
92
+ `<your principal>+<its profile>`
93
+ ([principals and profiles](../01-concepts/06-actors.md#principals-and-profiles)).
94
+ You, as yourself with no profile, are always trusted. The loop reads the
95
+ list each time a card moves, so a change takes effect at once.
96
+
97
+ How the loop uses it:
98
+
99
+ - **A trusted author's report needs no approval.** Its work starts as soon
100
+ as the triage writes the spec, as long as the report is as they first
101
+ wrote it.
102
+ - **Anyone else's report waits.** The card is held `approval`, and the loop
103
+ tells you. Someone trusted labels it `approved=yes`
104
+ (`mu label 12 approved=yes`, or in the [inspector](./04-inspector.md)). A
105
+ label by anyone else does nothing.
106
+ - **An author the sync couldn't name is never trusted.** Nor is a GitHub
107
+ author: GitHub's sync names one by login, which can change hands, so a
108
+ GitHub issue always waits for an approval.
109
+ - **The work never reads the report.** The card run quotes the spec the
110
+ triage wrote (and someone approved, where it had to be) with `{on.text}`,
111
+ never the report itself.
81
112
 
82
113
  ## Stages
83
114
 
84
- A card starts where its source says. Only a ready card is triaged; a parked
85
- one waits, and nothing runs for it.
115
+ A card starts where its source says. The loop triages only a ready card; a
116
+ parked one waits, and nothing runs for it. The stages, by source:
86
117
 
87
118
  | Stage | Notion Status | Linear state | Anywhere else: `stage` label | The card |
88
119
  | --- | --- | --- | --- | --- |
@@ -93,134 +124,267 @@ one waits, and nothing runs for it.
93
124
  | done | Done, written by the loop | Done, written by the loop | | completed |
94
125
  | canceled | | Canceled, Duplicate | | canceled |
95
126
 
127
+ How the stages behave:
128
+
96
129
  - **The source's status moves the card.** Move a Notion page to Ready, or a
97
- Linear issue to Todo, and its card is triaged. Move it back to Not started
98
- or Backlog and it is parked again, unless a run is going: then it stays
99
- `working`, and the card says so.
100
- - **Only the source's own sync moves it.** A card's source is read from how
101
- the board recorded its first message, never from a label. A `state` label
102
- anyone else sets moves nothing, and is never read later.
103
- - **Sources without a status** (Slack, GitHub, your app, the inspector) are
104
- ready when they come in. Someone trusted parks one with
105
- `mu label 12 stage=backlog`, and starts it with `stage=ready`. Anyone
106
- else's `stage` label does nothing.
107
- - **A status the loop doesn't know** parks the card.
108
- - **The loop writes the status back:** In progress when the work starts, and
109
- Done when the review completes with `approve`, which also completes the
110
- card. A write that fails is said on the card, as `loop`, and the card goes
111
- on. Notion's integration needs the "Update content" capability for it.
112
- Linear's status is written by the same OAuth app its sync comments as
113
- (`LINEAR_CLIENT_ID`, `LINEAR_CLIENT_SECRET`), even when a `LINEAR_API_KEY`
114
- is also set; with no app, by that key. The loop asks for the app's token
115
- with its sync's scopes: Linear ends an app's earlier tokens when one is
116
- asked for with other scopes, the sync's among them. A sync given its own
117
- `scopes` needs the same `scopes` in its `SOURCES` entry.
118
- - **A parked card that is edited** stays parked, and is triaged from its new
119
- text when it is moved to ready.
120
-
121
- The mapping is `SOURCES` in `board.ts`, by sync key. `LOOP_STAGES` replaces
122
- an entry with JSON in the same shape:
130
+ Linear issue to Todo, and the loop triages its card. Move it back to Not
131
+ started or Backlog and the loop parks it again, unless a run is going:
132
+ then it stays `working`, and the card says so.
133
+ - **Only the source's own sync moves it.** The loop reads a card's source
134
+ from how the board recorded its first message, never from a label. A
135
+ `state` label anyone else sets moves nothing, and is never read later.
136
+ - **Cards from sources without a status are ready when they come in.** These
137
+ sources are Slack, GitHub, your app and the inspector. Someone trusted
138
+ parks one with `mu label 12 stage=backlog`, and starts it with
139
+ `stage=ready`. Anyone else's `stage` label does nothing.
140
+ - **A status the loop doesn't know parks the card.**
141
+ - **The loop writes the status back.** It writes In progress when the work
142
+ starts, and Done when the review completes with `approve`, which also
143
+ completes the card. When a write fails, the loop says so on the card, as
144
+ `loop`, and the card goes on. Notion's integration needs the "Update
145
+ content" capability for it.
146
+ - **The loop writes Linear's status as the sync's OAuth app.** That is the
147
+ app the sync comments as (`LINEAR_CLIENT_ID`, `LINEAR_CLIENT_SECRET`), even
148
+ when a `LINEAR_API_KEY` is also set. With no app, the loop writes it with
149
+ that key.
150
+ - **A sync given its own `scopes` needs the same `scopes` in its `SOURCES`
151
+ entry.** The loop asks for the app's token with its sync's scopes. Linear
152
+ revokes an app's earlier tokens, the sync's among them, when one is asked
153
+ for with other scopes.
154
+ - **A parked card that is edited stays parked.** When it is moved to ready,
155
+ the loop triages it from its new text.
156
+
157
+ The mapping is `SOURCES` in `board.ts`, by sync key. To replace an entry, set
158
+ `LOOP_STAGES` to JSON in the same shape:
123
159
 
124
160
  ```bash
125
161
  export LOOP_STAGES='{"nt":{"type":"notion","token":"NOTION_TOKEN","stages":{"inbox":"backlog","go":"ready"},"write":{"working":"doing","done":"shipped"}}}'
126
162
  ```
127
163
 
128
- ## Planning
164
+ ## Plan a card with an agent
129
165
 
130
166
  A card in planning gets an agent that shapes it with the people who asked,
131
- before anything is built: the `planning` workflow, one step that reads the
132
- report and the repository and changes nothing.
133
-
134
- - **It answers on the card,** as `planner`: its questions, numbered, then the
135
- card as it stands (a title, what to change, how to check it), and how it
136
- would split a change too big for one pull request.
137
- - **Each trusted reply is its next round,** on the same task: the comments go
138
- to it, fenced as content, and it answers again. Replies made while it
139
- works wait for its answer. Anyone else's replies aren't shown to it.
140
- - **Move it to ready** (Ready, Todo, or `stage=ready`) when the card is
141
- right. The triage writes the spec from the newest plan and what was said
142
- on the card since it, and what was said in planning starts no round of the
143
- work.
144
- - **Edit the report** in planning and a new planner starts from the new
145
- text; the old plan is not shown to the triage.
146
- - One planner per card. Moved back to planning later, it goes on when
147
- someone replies.
167
+ before anything is built. This is the `planning` workflow: one step that
168
+ reads the report and the repository and changes nothing. How planning
169
+ works:
170
+
171
+ - **It answers on the card, as `planner`.** The answer gives its questions,
172
+ numbered, then the card as it stands (a title, what to change, how to
173
+ check it). It also says how it would split a change too big for one pull
174
+ request.
175
+ - **Each trusted reply is its next round, on the same task.** The loop sends
176
+ it the comments, fenced as content, and it answers again. Replies made
177
+ while it works wait for its answer. Anyone else's replies aren't shown to
178
+ it.
179
+ - **Move it to ready when the card is right.** Use Ready, Todo, or
180
+ `stage=ready`. The triage writes the spec from the newest plan and what was
181
+ said on the card since it. What was said in planning starts no round of
182
+ the work.
183
+ - **Editing the report in planning starts a new planner.** It starts from
184
+ the new text, and the triage never sees the old plan.
185
+ - **Each card has one planner.** When the card moves back to planning later,
186
+ its planner goes on when someone replies.
148
187
 
149
188
  ## Related and duplicate cards
150
189
 
151
- Each triage is shown the other cards, newest first, by number, hold and
152
- first line, as many as fit in what a run quotes (2,000 characters, after the
153
- plan when there is one). The list is a reply on the card, written as `cards` and kept on
154
- the board: it never reaches Slack, Linear or Notion. The triage step quotes
155
- it with `{on.text}`, as content.
156
-
157
- - **Related:** a triage result that starts with `related: #36, #16` labels
158
- the card `related=36,16` and says so on the card, by number only: the card
159
- is mirrored where it came from, and another card's words may be private to
160
- its own source. When both cards are
161
- Linear issues of the same sync, the issues are related in Linear too.
162
- - **The same request:** `duplicate-of: #36` holds the card `duplicate`, with
163
- its spec on it, and you are told. Someone trusted labels it `approved=yes`
164
- to work it anyway, or you cancel it. A duplicate the triage wrote no card
165
- for is triaged again when it is moved to ready.
190
+ The loop shows each triage the other cards, newest first: each one's number,
191
+ hold and first line. It shows as many as fit in what a run quotes: 2,000
192
+ characters, after the plan when there is one. The list is a reply on the
193
+ card, written as `cards`, and stays on the board: it never reaches Slack,
194
+ Linear or Notion. The triage step quotes it with `{on.text}`, as content.
195
+
196
+ How related and duplicate cards work:
197
+
198
+ - **Related:** when a triage result starts with `related: #36, #16`, the
199
+ loop labels the card `related=36,16` and says so on the card. It names the
200
+ other cards by number only: the card is mirrored where it came from, and
201
+ another card's words may be private to its own source. When both cards are
202
+ Linear issues of the same sync, the loop relates the issues in Linear too.
203
+ - **The same request:** when a result starts with `duplicate-of: #36`, the
204
+ loop holds the card `duplicate`, with its spec on it, and tells you.
205
+ Someone trusted labels it `approved=yes` to work it anyway, or you cancel
206
+ it. When a duplicate the triage wrote no card for is moved to ready, the
207
+ loop triages it again.
166
208
  - **A public source sees only public cards.** What a triage writes is
167
- mirrored where its card came from, so a card from a public source (GitHub
168
- issues; `LOOP_PUBLIC` lists the channels, comma separated) is shown only
169
- other public cards. A card from Slack, Linear, Notion or your app sees all.
170
- - **Only cards of this loop count.** A number that isn't another card's (the
171
- card itself, a run's task, any other thread) is left out. The lines are
172
- taken off the spec.
209
+ mirrored where its card came from. So a card from a public source (GitHub
210
+ issues; `LOOP_PUBLIC` lists the channels, comma separated) sees only other
211
+ public cards. A card from Slack, Linear, Notion or your app sees all.
212
+ - **Only cards of this loop count.** The loop leaves out a number that isn't
213
+ another card's (the card itself, a run's task, any other thread). It takes
214
+ the `related` and `duplicate-of` lines off the spec.
173
215
  - **Nothing is split.** A report that asks for several things is one card;
174
216
  the spec can list follow-ups for you to file.
175
217
 
176
- ## Another round
218
+ ## Start another round from a reply
177
219
 
178
- A reply on the card by someone trusted, once its run has ended, is another
179
- round. The comment goes to the work task, the work and then its review are
180
- sent back (`mu tasks reopen <id> --round`), and a worker takes them. The work
181
- starts from its branch: see
220
+ A reply on the card by someone trusted, once its run has ended, starts
221
+ another round. The loop sends the comment to the work task and reopens the
222
+ work and then its review (`mu tasks reopen <id> --round`), and a worker
223
+ takes them. The work starts from its branch: see
182
224
  [Another round on the same pull request](./06-sandboxed-agents.md#another-round-on-the-same-pull-request).
183
- A comment made while a round runs waits for it to end. A round's reply on
184
- the card says which comments it took; comments too long for one round wait
185
- for the next. A card that is done comes back the
186
- same way: a trusted reply reopens it, and its status is In progress again.
225
+ A comment made while a round runs waits for it to end.
226
+
227
+ A round's reply on the card says which comments it took; comments too long
228
+ for one round wait for the next. A card that is done comes back the same
229
+ way: a trusted reply reopens it, and its status is In progress again.
230
+
231
+ ## Run several repositories on one board
232
+
233
+ Each repository is a project. A project's cards are in its own channel,
234
+ `cards/<project>/<source>`, such as `cards/acme/linear`, and its runs work on
235
+ its own repository. Everything else is shared: one board, one `mu serve`,
236
+ one set of prompts. The cards right under `cards/` keep running on
237
+ `workflows.json` as before, so you can add projects to a loop that already
238
+ runs. Keep work on a separate board only when it must stay apart, such as a
239
+ client's under an NDA: see
240
+ [Several repositories, several boards](./15-several-boards.md).
241
+
242
+ ### Name each project and its repository
243
+
244
+ Write `loop-projects.json` beside `workflows.json`, in `~/.config/muster/`:
245
+
246
+ ```json loop-projects.json
247
+ {
248
+ "projects": {
249
+ "acme": { "repo": "https://github.com/acme/web", "runner": "vercel", "maxRuns": 2 },
250
+ "globex": {
251
+ "repo": "https://github.com/globex/site",
252
+ "runner": "e2b",
253
+ "template": "globex-go",
254
+ "trusted": ["lin:user:9b1d4e7a-2c3f-4a8b-b6e0-5f1a2d3c4e5f"]
255
+ }
256
+ }
257
+ }
258
+ ```
259
+
260
+ A project's name is a channel segment: lowercase letters, numbers, `_` and
261
+ `-`, and not the name of a source (`slack`, `linear`, `github`, `notion`,
262
+ `app`). Each project takes these settings:
263
+
264
+ | Setting | Meaning |
265
+ | --- | --- |
266
+ | `repo` | The repository its runs work on, as an HTTPS clone address. Required |
267
+ | `runner` | `vercel`, `cloudflare` or `e2b`. Left out, the one in `workflows.json` |
268
+ | `template` | The E2B template its sandboxes are made from, with `runner` set to `e2b`. Give a Go repository and a pnpm repository each the tools it needs |
269
+ | `model` | The model its agents use |
270
+ | `trusted` | Who may start work on its cards, in place of `LOOP_TRUSTED` |
271
+ | `public` | Its sources that anyone can read, by name (`["github"]`), in place of the ones `LOOP_PUBLIC` names |
272
+ | `maxRuns` | The most runs of it going at once |
273
+
274
+ ### Map each project's sources to its channel
275
+
276
+ In `board.ts`, map each tracker team, Slack channel or repository to its
277
+ project's channel. Give each repository one team of its own, so a card's
278
+ project is never in doubt:
279
+
280
+ ```ts board.ts
281
+ import { env, linear } from '@openmuster/muster'
282
+
283
+ export const sync = {
284
+ lin: linear({
285
+ secret: env('LINEAR_WEBHOOK_SECRET'),
286
+ clientId: env('LINEAR_CLIENT_ID'),
287
+ clientSecret: env('LINEAR_CLIENT_SECRET'),
288
+ teams: { ACME: 'cards/acme/linear', GLOBEX: 'cards/globex/linear' },
289
+ }),
290
+ }
291
+ ```
292
+
293
+ A card's runs then go to its own project's workflows. Its triage is shown
294
+ only its own project's cards, so a public repository's triage never sees a
295
+ private project's words.
296
+
297
+ ### Write each project's workflows
298
+
299
+ Write the template's three workflows again for each project, then restart
300
+ `mu serve`, which reads them when it starts:
301
+
302
+ ```bash
303
+ node templates/loop/projects.ts ~/.config/muster/loop-projects.json > ~/.config/muster/workflows.json
304
+ ```
305
+
306
+ Each project gets `triage.<project>`, `planning.<project>` and
307
+ `card.<project>`. They have the template's prompts and your project's
308
+ repository, runner, template and model. The daemon refuses to run one on
309
+ another project's cards. Write them again whenever you change
310
+ `loop-projects.json`.
311
+
312
+ ### Limit what each project spends and runs
313
+
314
+ A [budget](../01-concepts/13-budgets.md) on a project's channel covers all
315
+ its runs:
316
+
317
+ ```bash
318
+ mu budget cards/acme 20
319
+ ```
320
+
321
+ `maxRuns` caps how many of a project's runs go at once, and `LOOP_MAX_RUNS`
322
+ caps all the loop's runs on the board. A run counts from when it is asked for
323
+ until it ends, or until it waits on a person. A card past a cap waits, says so
324
+ once on the card, and starts when a run ends, oldest card first:
325
+
326
+ - **A change, or a round, that waits is held `queued`.** Your comments wait
327
+ with it, and the round takes them when it starts.
328
+ - **A planning round that waits stays in `planning`.**
329
+ - **A task you answered while every place is taken is held `queued` too.** It
330
+ goes on before any card when a run ends.
331
+
332
+ ### Give each project's app its own token
333
+
334
+ An app that posts reports needs a token for its own project's channel only:
335
+
336
+ ```bash
337
+ mu token create --as acme-app --can 'cards/acme/=read,post'
338
+ ```
187
339
 
188
340
  ## What you see
189
341
 
190
- - **The card** in Slack, Linear, GitHub or Notion, wherever the report came
191
- from: the spec, the run's start and summary, the screenshots of each round,
192
- and the pull request's address. GitHub and Notion take no files from the
193
- board, so there each screenshot is named instead.
194
- - **The screenshots** are the ones the project's spec asks for. The work
195
- agent takes them and attaches them to its task, and they are copied onto
342
+ What shows up as a card runs:
343
+
344
+ - **The card:** in Slack, Linear, GitHub or Notion, wherever the report came
345
+ from. It shows the spec, the run's start and summary, the screenshots of
346
+ each round, and the pull request's address. GitHub and Notion take no
347
+ files from the board, so there each screenshot is named instead.
348
+ - **The screenshots:** the ones the project's spec asks for. The work agent
349
+ takes them and attaches them to its task, and the loop copies them onto
196
350
  the card when the round ends. A project whose spec asks for none gets
197
351
  none.
198
- - **A line from `NOTIFY_CMD`**, when it is set: a card that needs your
199
- approval, a task blocked on a decision, a round that is done.
200
- - **The pull request,** one per card, with a commit per round.
352
+ - **A line from `NOTIFY_CMD`:** when it is set, for a card that needs your
353
+ approval, a task blocked on a decision, or a round that is done. A line
354
+ about a project's card starts with the project's name:
355
+ `acme: card #12 needs your approval`.
356
+ - **The pull request:** one per card, with a commit per round.
201
357
 
202
- ## When not to
358
+ ## When not to use the loop
359
+
360
+ Don't use the loop:
203
361
 
204
362
  - For a report you wouldn't hand a stranger's agent: approval is per card,
205
363
  so read the spec before you approve it.
206
364
  - For work that needs several pull requests: a card is one branch.
207
- - For PR review comments as the trigger: a comment on the pull request
208
- doesn't start a round yet. Reply on the card.
365
+ - For pull request review comments as the trigger: a comment on the pull
366
+ request doesn't start a round yet. Reply on the card.
209
367
 
210
368
  ## What goes wrong
211
369
 
212
- - **A round's push is refused** with `push_conflict` when someone pushed to
213
- the branch while the agent worked. The task says so, and the review waits:
370
+ Symptoms, causes and fixes:
371
+
372
+ - **A round's push is refused with `push_conflict`.** Someone pushed to the
373
+ branch while the agent worked. The task says so, and the review waits:
214
374
  read the thread, then reopen the work.
215
- - **A run asked on an edited spec** starts nothing (`asked_message_changed`):
216
- a card that changed after it was triaged is triaged again.
217
- - **The triage agent fails** a report that isn't a change to make here, with
218
- why, in the triage run's summary on the card. The card is held `declined`,
219
- says so, and you are told. Edit the report, or move it to ready again, to
220
- try again; or cancel it. A triage whose agent stopped (out of time, a usage
221
- limit) is declined the same way, and its summary says so.
375
+ - **A run asked on an edited spec starts nothing.** The error is
376
+ `asked_message_changed`. The card changed after its triage, so the loop
377
+ triages it again.
378
+ - **The triage agent fails a report that isn't a change to make here.** It
379
+ says why in the triage run's summary on the card. The loop holds the card
380
+ `declined`, says so on the card, and tells you. Edit the report, or move it
381
+ to ready again, to try again; or cancel it. The loop declines a triage
382
+ whose agent stopped (out of time, a usage limit) the same way, and its
383
+ summary says so.
384
+
385
+ ## Related guides
222
386
 
223
- ## Next
387
+ Where to go next:
224
388
 
225
389
  - [Building from Linear](./22-building-from-linear.md): laying out a Linear
226
390
  project, its spec and its issues for this loop, and what to do from Linear
@@ -229,5 +393,5 @@ same way: a trusted reply reopens it, and its status is In progress again.
229
393
  approving, answering a blocked task, another round, and what to do when
230
394
  something stops.
231
395
  - The `loop-card` skill teaches an agent each step (triage, spec, work,
232
- review): `mu skills install --to ~/.claude/skills` installs it with the
396
+ review): `npx skills add openmuster/muster` installs it with the
233
397
  others.