arbiterdesign 0.1.7 → 0.1.9
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/README.md +38 -40
- package/dist/area-names.js +120 -0
- package/dist/areas.js +131 -0
- package/dist/board-types.js +9 -0
- package/dist/candidates.js +7 -1
- package/dist/commands/areas.js +153 -0
- package/dist/commands/candidate.js +4 -2
- package/dist/commands/decision.js +100 -0
- package/dist/commands/export.js +88 -125
- package/dist/commands/init.js +89 -2
- package/dist/commands/prompt.js +12 -4
- package/dist/commands/publish.js +18 -1
- package/dist/commands/record.js +152 -3
- package/dist/commands/rename.js +123 -0
- package/dist/commands/review.js +469 -76
- package/dist/commands/rules.js +8 -1
- package/dist/commands/setup.js +1 -0
- package/dist/commands/snapshot.js +24 -2
- package/dist/commands/sweep.js +1 -1
- package/dist/commands/unpublish.js +88 -0
- package/dist/comments.js +24 -0
- package/dist/handoff.js +283 -0
- package/dist/hook.js +80 -0
- package/dist/hosted.js +117 -20
- package/dist/index.js +93 -24
- package/dist/localboard.js +219 -0
- package/dist/lock.js +134 -0
- package/dist/overlap.js +16 -0
- package/dist/pictures.js +4 -0
- package/dist/settings.js +107 -0
- package/dist/store.js +6 -5
- package/dist/verify.js +4 -2
- package/dist/wording.js +65 -0
- package/dist/work.js +139 -1
- package/package.json +3 -2
- package/templates/SKILL.md +169 -50
- package/templates/board/board.css +2 -0
- package/templates/board/board.js +25 -0
- package/templates/board/index.html +15 -0
- package/templates/fonts/Geist-Variable.woff2 +0 -0
- package/templates/fonts/GeistMono-Variable.woff2 +0 -0
- package/templates/fonts/OFL.txt +92 -0
- package/templates/hooks/arbiter-board.cjs +50 -0
- package/templates/review.html +0 -600
package/README.md
CHANGED
|
@@ -76,8 +76,13 @@ Arbiter fixes that without adding work:
|
|
|
76
76
|
npx arbiterdesign init
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
+
> [!NOTE]
|
|
80
|
+
> On Windows, in PowerShell, type `npx.cmd` instead of `npx`, here and in every command after. PowerShell blocks plain `npx` out of the box, with "running scripts is disabled on this system". Command Prompt and Git Bash don't.
|
|
81
|
+
|
|
79
82
|
That's the whole install. Run it in the folder your agent works in, or ask the agent to run it. It detects Claude Code or Cursor, teaches your agent the protocol, and adds `arbiterdesign` to your devDependencies, which is what makes the shorter `npx arbiter` work from then on. Running it twice changes nothing.
|
|
80
83
|
|
|
84
|
+
It asks one question, once: how often the agent should check in about decisions while you work. If the agent ran the install, it asks you in chat instead.
|
|
85
|
+
|
|
81
86
|
No `package.json` in the project? Add `arbiterdesign` as a dev dependency yourself. New to the terminal? Follow the [step-by-step guide](https://arbiter.design/get-started).
|
|
82
87
|
|
|
83
88
|
If you want the agent to take screenshots of the screens it changes, tell it where your app runs:
|
|
@@ -137,8 +142,8 @@ flowchart TB
|
|
|
137
142
|
|
|
138
143
|
1. **You ask for a screen.** The agent reads `DECISIONS.md` first. After a sizeable piece of work it names up to three rules that shaped it, like *Following D-0001 (removing asks first, no undo bar)*, so you can see the record working.
|
|
139
144
|
2. **You iterate.** The agent says nothing about decisions while you're going back and forth. Each version you move past becomes a rejected alternative on the one that replaced it.
|
|
140
|
-
3. **You move on.** The agent queues the design calls it made, sized as `feature
|
|
141
|
-
4. **You judge them when you want.** In chat with `/arbiter`, or in the browser with `npx arbiter review`.
|
|
145
|
+
3. **You move on.** The agent queues the design calls it made, sized as `feature` or `pattern` (a small one-off fix isn't recorded at all). When 5 are waiting (then 10, 15…) it asks if you want to review them. Only real choices get queued: things you asked for, things you corrected, and options the agent actually weighed. Its habits don't.
|
|
146
|
+
4. **You judge them when you want.** In chat with `/arbiter`, or on your local board: answer "yes, in the browser" when it asks, or open it yourself with `npx arbiter review`. Keep it open while you work: it shows what the agent records as it records it, and in Claude Code the fixes you ask for there reach the agent with your next message. Elsewhere they come at the next `/arbiter`. Close the tab when you're done with it.
|
|
142
147
|
5. **Rules go into `DECISIONS.md`.** Everything you judged goes into the archive. Skipped items disappear. The next session reads the new rules.
|
|
143
148
|
6. **You share it.** `npx arbiter publish` puts the board online, so your team can see each screen, what was decided and why. They can comment or request a change, and `npx arbiter pull` brings that back for you to answer. More in [Share it with your team](#share-it-with-your-team).
|
|
144
149
|
|
|
@@ -168,7 +173,7 @@ Each item reads as **Change** (what happened), **Pattern** (the rule) and **Reje
|
|
|
168
173
|
| **Skip** | Thrown away. |
|
|
169
174
|
| **Fix** | Type a correction and it's recorded your way. |
|
|
170
175
|
|
|
171
|
-
|
|
176
|
+
Small one-off fixes never reach the queue, so each item is a real call. If an item goes against an existing rule, Arbiter says so (*Clashes with D-0009*) and asks which one wins: **Follow D-0009**, **Replace D-0009**, or **Keep as exception**.
|
|
172
177
|
|
|
173
178
|
> [!TIP]
|
|
174
179
|
> Too chatty? `npx arbiter setup --checkin quiet` turns off the check-ins. `--checkin every` does the opposite and mentions a rule every time one changed something.
|
|
@@ -205,23 +210,29 @@ npx arbiter pull
|
|
|
205
210
|
|
|
206
211
|
Brings their comments back into your repo, where `arbiter review` shows them next to each screen.
|
|
207
212
|
|
|
208
|
-
Git stays the source of truth. The service only holds the latest board and its comments, and only `publish` and `pull` ever touch the network.
|
|
213
|
+
Git stays the source of truth. The service only holds the latest board and its comments, and only `publish` and `pull` ever touch the network. A board holds up to 100 pictures (25 MB); a picture that doesn't fit is left off and `publish` says so.
|
|
209
214
|
|
|
210
215
|
**Keep it current automatically:**
|
|
211
216
|
|
|
212
217
|
- `npx arbiter publish --auto` republishes whenever the record changes. Works anywhere: no GitHub, no CI, no repo needed. If a republish fails (offline, service down) the command still succeeds and tells you the board is behind. `--no-auto` turns it off.
|
|
213
218
|
- `npx arbiter publish --on-push` writes a GitHub Actions workflow that republishes when decisions land on your default branch, and sets the `ARBITER_PUBLISH_TOKEN` secret through `gh` if you're signed in. Commit the workflow along with `.arbiter/hosted.json`.
|
|
214
219
|
|
|
220
|
+
**Keep it private, or take it down:**
|
|
221
|
+
|
|
222
|
+
- `npx arbiter publish --password` puts the board behind a password. It makes up a strong one and prints it once, so send it with the link. `--password "<yours>"` sets your own (8 characters or more), `--no-password` takes it off, and a plain `publish` leaves it as it is.
|
|
223
|
+
- `npx arbiter unpublish --yes` deletes the board, its pictures and its comments from the service, saving the comments into `.arbiter/comments.json` first. Without `--yes` it only says what it would delete.
|
|
224
|
+
- Lost the project folder, so you can't run it? Use **Report or remove this board** at the bottom of the board, and it's taken down by hand.
|
|
225
|
+
|
|
215
226
|
### Change requests
|
|
216
227
|
|
|
217
228
|
A comment is just input. **Request change** is different: someone wants something changed, so it gets a proper answer.
|
|
218
229
|
|
|
219
230
|
1. `npx arbiter pull` turns each request into `R-0001` in `.arbiter/requests.json`. Commit it so everyone sees the same answers.
|
|
220
|
-
2. You answer in chat with `/arbiter
|
|
231
|
+
2. You answer in chat with `/arbiter`:
|
|
221
232
|
- **Apply**: `record R-0001 --as apply`
|
|
222
233
|
- **Apply, but…**: `record R-0001 --as apply --to "keep the tab, make the button red"`
|
|
223
234
|
- **Decline**: `record R-0001 --as decline --why "…"` (a reason is required, since the requester reads it)
|
|
224
|
-
3. The agent makes the change
|
|
235
|
+
3. The agent makes the change right away.
|
|
225
236
|
4. `publish` sends the answer back. The requester sees *Open*, *Approved*, *Applied* (with what changed) or *Declined* (with the reason).
|
|
226
237
|
|
|
227
238
|
> [!NOTE]
|
|
@@ -241,7 +252,7 @@ A comment is just input. **Request change** is different: someone wants somethin
|
|
|
241
252
|
|
|
242
253
|
### Other ways to share
|
|
243
254
|
|
|
244
|
-
- **Static export.** `npx arbiter export` writes `arbiter-export/`:
|
|
255
|
+
- **Static export.** `npx arbiter export` writes `arbiter-export/`: the same board as `arbiter review`, read-only, as a folder (`index.html`, the board's script and styles, and the pictures). No server: open it from disk or drop it on any static host. Each change with its picture and how it got there, what was decided in plain words, and with `--include-rules`, your design rules.
|
|
245
256
|
- **GitHub Pages.** With `"destination": "git"` in `arbiter.json`, every candidate change also writes the export to `docs/arbiter/`. Turn on Pages for the `docs` folder once and the board lives at `https://<owner>.github.io/<repo>/arbiter/`. `npx arbiter publish --to pages` does the whole setup in one go.
|
|
246
257
|
|
|
247
258
|
## Screenshots
|
|
@@ -249,13 +260,15 @@ A comment is just input. **Request change** is different: someone wants somethin
|
|
|
249
260
|
The agent takes one picture per piece of work, when the work settles and it changed how a specific screen looks.
|
|
250
261
|
|
|
251
262
|
- **Gets a picture:** layout, wording or visual changes to one screen. Even a small pattern change counts.
|
|
252
|
-
- **Doesn't:** font or token changes (no single screen to show), motion and behaviour (a still can't show it), and
|
|
263
|
+
- **Doesn't:** font or token changes (no single screen to show), motion and behaviour (a still can't show it), and small one-off fixes (they aren't recorded).
|
|
253
264
|
|
|
254
265
|
The agent renders pictures with a headless browser. If it can't (no browser, app not running, screen behind a login) it tells you once and says why. On macOS, `--capture` lets you drag-select a picture yourself; elsewhere, save one and pass `--file`.
|
|
255
266
|
|
|
256
267
|
> [!TIP]
|
|
257
268
|
> Name each piece of work after the screen it changed, like `Settings, billing` instead of one `Settings build` across four routes. Then one picture per piece of work means one per screen.
|
|
258
269
|
|
|
270
|
+
Named it something else first? `arbiter rename "Settings build" "Settings, billing"` moves its decisions, its picture and its comments on the board to the new name.
|
|
271
|
+
|
|
259
272
|
Cards without a picture show an icon of the kind of change, so the board never looks broken. To make sure missing pictures still get noticed, `record` tells the agent the command to add one, the review page marks the group "No picture", and `publish` lists the cards that are missing one.
|
|
260
273
|
|
|
261
274
|
## Keeping the record honest
|
|
@@ -326,7 +339,7 @@ npx arbiter pull # bring comments and requests back
|
|
|
326
339
|
| `arbiter record '<json>'` | Record now (what the agent calls). |
|
|
327
340
|
| `arbiter record --pending '<json>'` | Queue for later. |
|
|
328
341
|
| `arbiter record P-0003 --as rule` | Judge a queued item: `accept`, `rule`, `skip` or `fix --to "…"`. Add `--candidate C-0001` to link it, or `--against D-0009` to name the rule it goes against (with `accept`, it's logged as an exception to that rule). |
|
|
329
|
-
| `arbiter record --all --as accept` | Judge every queued item. Narrow with `--level
|
|
342
|
+
| `arbiter record --all --as accept` | Judge every queued item. Narrow with `--level pattern` or `--trigger "Settings build"`. |
|
|
330
343
|
| `arbiter record --findings f.json` | Queue a scanner's findings for verdicts. |
|
|
331
344
|
| `arbiter record --retire D-0003 --why "…"` | Drop a rule with no replacement. |
|
|
332
345
|
| `arbiter record --reword D-0003 --to "…"` | Change a rule's wording. It keeps its id, and the old wording stays on the entry. |
|
|
@@ -338,7 +351,9 @@ npx arbiter pull # bring comments and requests back
|
|
|
338
351
|
|
|
339
352
|
| Command | What it does |
|
|
340
353
|
|---|---|
|
|
341
|
-
| `arbiter review` |
|
|
354
|
+
| `arbiter review` | Your local board, in the browser: what's waiting for you to judge, every change with its picture, and your design rules. It keeps itself current while it's open, and stops when you close its tab. Nothing is uploaded. What still needs a code change reaches your agent with your next message in Claude Code (a hook `init` installs), or at the next `/arbiter`. |
|
|
355
|
+
| `arbiter review --json` | For an agent that waits on the board: when its last tab closes, hands over what you decided as JSON. |
|
|
356
|
+
| `arbiter review --done` | For the agent, once it has made what the board handed it: clears that, and keeps anything you judged meanwhile. |
|
|
342
357
|
| `arbiter rules [--dimension <name>] [--json]` | Active rules. |
|
|
343
358
|
| `arbiter rules --pending` | The queue, plus requests waiting on an answer. |
|
|
344
359
|
| `arbiter rules --archive` | Everything ever recorded. |
|
|
@@ -355,6 +370,7 @@ npx arbiter pull # bring comments and requests back
|
|
|
355
370
|
| `arbiter candidate C-0002 --state …` | Set its state. |
|
|
356
371
|
| `arbiter board` | Candidates and their states. |
|
|
357
372
|
| `arbiter unlink D-0004` | Detach a decision from the screen it was recorded against. |
|
|
373
|
+
| `arbiter rename "<work>" "<new name>"` | Rename a piece of work everywhere the record keeps it. Its comments on the board follow at the next publish. |
|
|
358
374
|
| `arbiter remove <id>` | Remove a decision, a screen (`C-0001`) or a picture (`--snapshot "<work>"`) that was never real. |
|
|
359
375
|
|
|
360
376
|
#### Sharing
|
|
@@ -365,6 +381,9 @@ npx arbiter pull # bring comments and requests back
|
|
|
365
381
|
| `arbiter publish --to <url\|pages>` | Your own hosted Arbiter, or GitHub Pages. |
|
|
366
382
|
| `arbiter publish --auto` | Republish whenever the record changes. |
|
|
367
383
|
| `arbiter publish --on-push` | Write a GitHub Actions workflow that republishes on every push. |
|
|
384
|
+
| `arbiter publish --password [pw]` | Ask for a password before showing the board. No value makes one up. `--no-password` takes it off. |
|
|
385
|
+
| `arbiter unpublish --yes` | Delete the board, its pictures and its comments, saving the comments to the repo first. |
|
|
386
|
+
| `arbiter unpublish <board link> --admin --yes` | For whoever runs the server: take down any board on it, with the admin token in `ARBITER_ADMIN_TOKEN`. |
|
|
368
387
|
| `arbiter pull` | Bring comments and reactions into `.arbiter/comments.json`, and requests into `.arbiter/requests.json`. |
|
|
369
388
|
| `arbiter export [--feature f] [--include-rules] [--open]` | Static folder of the board for people without the repo. |
|
|
370
389
|
|
|
@@ -390,7 +409,7 @@ npx arbiter pull # bring comments and requests back
|
|
|
390
409
|
| `date` | ISO 8601. |
|
|
391
410
|
| `author` | Who decided. |
|
|
392
411
|
| `class` | `mechanical` (checkable in code) or `judgment`. |
|
|
393
|
-
| `level` | `feature
|
|
412
|
+
| `level` | `feature` or `pattern`. How big a call it is. A `polish` one-off fix isn't recorded: `record` answers `not-recorded` and writes nothing. |
|
|
394
413
|
| `dimension` | `structure`, `interaction`, `states`, `content`, `visual`, `motion` or `access`. |
|
|
395
414
|
| `change` | What happened, in plain words. What the reviewer reads. |
|
|
396
415
|
| `decision` | The same call written as a rule. What future sessions read. |
|
|
@@ -436,28 +455,14 @@ A call the agent made where a reasonable alternative existed: layout, flow, word
|
|
|
436
455
|
<details>
|
|
437
456
|
<summary><b>How do I set it up?</b></summary>
|
|
438
457
|
|
|
439
|
-
Run `npx arbiterdesign init` in the folder your agent works in, or ask the agent to run it. It adds a few plain files and a one-line note telling the agent to read the rules before UI work. Nothing to sign up for
|
|
440
|
-
|
|
441
|
-
</details>
|
|
442
|
-
|
|
443
|
-
<details>
|
|
444
|
-
<summary><b>Do I have to write anything?</b></summary>
|
|
445
|
-
|
|
446
|
-
No. The agent records what it decided and what it chose over. You confirm, make it a rule, or skip, in chat or on the review page. Mid-session you can also just say *"make that a rule"* and it's recorded without a question.
|
|
458
|
+
Run `npx arbiterdesign init` in the folder your agent works in, or ask the agent to run it. It adds a few plain files and a one-line note telling the agent to read the rules before UI work, and asks one question: how often to check in. Nothing to sign up for. From the next session, the agent records as it goes. Step by step, with what you'll see: [Get started](https://arbiter.design/get-started).
|
|
447
459
|
|
|
448
460
|
</details>
|
|
449
461
|
|
|
450
462
|
<details>
|
|
451
|
-
<summary><b>
|
|
463
|
+
<summary><b>Will it interrupt me, or bury me in reviews?</b></summary>
|
|
452
464
|
|
|
453
|
-
No.
|
|
454
|
-
|
|
455
|
-
</details>
|
|
456
|
-
|
|
457
|
-
<details>
|
|
458
|
-
<summary><b>Will I be reviewing hundreds of tiny decisions?</b></summary>
|
|
459
|
-
|
|
460
|
-
No. Every decision is sized as feature, pattern or polish. Feature and pattern items get a card each. Polish is one line per piece of work with a single **Confirm all**. A 7px height fix and a new settings architecture don't get the same treatment.
|
|
465
|
+
No. Decisions queue silently while you iterate and surface in one line when you move on. Only features and patterns are queued, a card each; small one-off fixes aren't recorded at all. You judge them when you want, or never.
|
|
461
466
|
|
|
462
467
|
</details>
|
|
463
468
|
|
|
@@ -478,7 +483,7 @@ Yes. Make the new call and the old rule steps aside. It stays in the archive wit
|
|
|
478
483
|
<details>
|
|
479
484
|
<summary><b>Where does the record live, and who can see it?</b></summary>
|
|
480
485
|
|
|
481
|
-
In your project, as plain-text files you own: `DECISIONS.md` and the `.arbiter/` folder beside it. The board is a copy at a private link. It's unlisted and never indexed,
|
|
486
|
+
In your project, as plain-text files you own: `DECISIONS.md` and the `.arbiter/` folder beside it. The board is a copy at a private link. It's unlisted and never indexed, people sign in by email to comment, and `publish --password` puts it behind a password. `arbiter unpublish` deletes it from the service, after saving its comments into your repo.
|
|
482
487
|
|
|
483
488
|
</details>
|
|
484
489
|
|
|
@@ -490,23 +495,16 @@ Good. Arbiter records decisions, not tokens. Rules can name your components and
|
|
|
490
495
|
</details>
|
|
491
496
|
|
|
492
497
|
<details>
|
|
493
|
-
<summary><b>
|
|
494
|
-
|
|
495
|
-
Claude Code and Cursor get the whole loop: the agent reads your rules before UI work and records what it decides. Other agents that read a project's instructions file, like Codex, Copilot and Gemini CLI, follow the rules but don't record.
|
|
496
|
-
|
|
497
|
-
</details>
|
|
498
|
-
|
|
499
|
-
<details>
|
|
500
|
-
<summary><b>Who installs it, and what does the rest of the team need?</b></summary>
|
|
498
|
+
<summary><b>Is this like ADRs?</b></summary>
|
|
501
499
|
|
|
502
|
-
|
|
500
|
+
Yes, same idea: a call, what it beat, and why. ADRs (architecture decision records) are for engineering: the stack, the data model, the API. Arbiter is for design: layout, flow, copy and states. And no one writes it up. The agent records each call as it works and you approve in seconds.
|
|
503
501
|
|
|
504
502
|
</details>
|
|
505
503
|
|
|
506
504
|
<details>
|
|
507
|
-
<summary><b>
|
|
505
|
+
<summary><b>Doesn't Claude have memory now?</b></summary>
|
|
508
506
|
|
|
509
|
-
|
|
507
|
+
Yes, but memory is what the agent learned. Arbiter is what your team decided. Claude Code's auto memory is notes Claude keeps for itself: nobody approves them, and they stay on one machine. Arbiter's rules are ones you approved, kept in the repo for every teammate, and each one records what it beat and what it replaced.
|
|
510
508
|
|
|
511
509
|
</details>
|
|
512
510
|
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.arrangementOf = exports.keyOf = exports.setName = exports.sameHead = exports.headOf = exports.FOUNDATIONS = void 0;
|
|
4
|
+
exports.areasFor = areasFor;
|
|
5
|
+
exports.layoutOf = layoutOf;
|
|
6
|
+
/** A change to the whole product — type, colour, spacing, voice — rather than to a place in it. */
|
|
7
|
+
exports.FOUNDATIONS = 'Foundations';
|
|
8
|
+
/**
|
|
9
|
+
* "Settings — billing", "Settings—billing", "Settings: billing", "Settings - billing" → "Settings". The way
|
|
10
|
+
* the agent is asked to name work. A dash needs no spaces; a hyphen does, or "Sign-in page" would split.
|
|
11
|
+
*/
|
|
12
|
+
const headOf = (name) => {
|
|
13
|
+
const head = name.split(/\s*[—–]\s*|\s+-\s+|:\s+/)[0].trim();
|
|
14
|
+
return head && head !== name.trim() ? head : null;
|
|
15
|
+
};
|
|
16
|
+
exports.headOf = headOf;
|
|
17
|
+
/**
|
|
18
|
+
* Two options are in one set, the versions of one thing to choose between, when they share their feature
|
|
19
|
+
* (the area) and what their names start with: "Empty state — illustration" and "Empty state — checklist"
|
|
20
|
+
* are one set; "Row layout — compact", in the same area, is another. Names with no head share one set.
|
|
21
|
+
* The board groups by it, and approving one supersedes only the rest of its set.
|
|
22
|
+
*/
|
|
23
|
+
const sameHead = (a, b) => ((0, exports.headOf)(a.name) ?? '').toLowerCase() === ((0, exports.headOf)(b.name) ?? '').toLowerCase();
|
|
24
|
+
exports.sameHead = sameHead;
|
|
25
|
+
/**
|
|
26
|
+
* A set's name: what its options' names start with ("Empty state", in Projects), or its area when the names
|
|
27
|
+
* only say that ("Project card — compact" in Project card, "Card — compact" in Card component).
|
|
28
|
+
*/
|
|
29
|
+
const setName = (area, c) => {
|
|
30
|
+
const head = (0, exports.headOf)(c.name);
|
|
31
|
+
return head && !area.toLowerCase().startsWith(head.toLowerCase()) ? head : area;
|
|
32
|
+
};
|
|
33
|
+
exports.setName = setName;
|
|
34
|
+
const everywhere = (c) => c.decisions.length > 0 && c.decisions.every((d) => d.scope === 'global');
|
|
35
|
+
/** `name` starts with the area `k` at a word boundary: "reports filters", "reports—x", "reports: x" — not "reportsx". */
|
|
36
|
+
const under = (name, k) => name === k || (name.startsWith(k) && /^[\s:—–]/.test(name.slice(k.length)));
|
|
37
|
+
/**
|
|
38
|
+
* The product area each card belongs to — what the board groups by, and what the rail lists.
|
|
39
|
+
* A set of options has one: the feature it was explored for. A change that was simply made
|
|
40
|
+
* (a piece of work) takes one from its name: "Settings — billing" is Settings, and "Reports
|
|
41
|
+
* filters" is Reports when Reports is an area on this board. A change where every decision
|
|
42
|
+
* applies everywhere is Foundations. Anything else is an area of its own, by its name.
|
|
43
|
+
*
|
|
44
|
+
* Needs the whole board: which areas exist decides where a name like "Reports filters" goes.
|
|
45
|
+
*/
|
|
46
|
+
function areasFor(cards) {
|
|
47
|
+
const known = new Map();
|
|
48
|
+
const learn = (name) => { if (!known.has(name.toLowerCase()))
|
|
49
|
+
known.set(name.toLowerCase(), name); };
|
|
50
|
+
for (const c of cards)
|
|
51
|
+
if (c.feature)
|
|
52
|
+
learn(c.feature);
|
|
53
|
+
for (const c of cards) {
|
|
54
|
+
if (!c.work || c.feature)
|
|
55
|
+
continue;
|
|
56
|
+
// A named head is an area; so is a plain change's whole name ("Reports"), unless it's a foundation.
|
|
57
|
+
const head = (0, exports.headOf)(c.name);
|
|
58
|
+
if (head)
|
|
59
|
+
learn(head);
|
|
60
|
+
else if (!everywhere(c))
|
|
61
|
+
learn(c.name.trim());
|
|
62
|
+
}
|
|
63
|
+
// Longest first, so "Settings billing" isn't taken by an area called "Set".
|
|
64
|
+
const byLength = [...known.entries()].sort((a, b) => b[0].length - a[0].length);
|
|
65
|
+
return (c) => {
|
|
66
|
+
if (c.feature)
|
|
67
|
+
return c.feature;
|
|
68
|
+
const lower = c.name.trim().toLowerCase();
|
|
69
|
+
// An area it sits under — never itself: its own name is an area for others, not a match for it.
|
|
70
|
+
for (const [k, v] of byLength)
|
|
71
|
+
if (k !== lower && under(lower, k))
|
|
72
|
+
return v;
|
|
73
|
+
if (everywhere(c))
|
|
74
|
+
return exports.FOUNDATIONS;
|
|
75
|
+
return known.get(lower) ?? c.name.trim();
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const low = (s) => s.toLowerCase();
|
|
79
|
+
const keyOf = (e) => (e.kind === 'folder' ? `folder:${e.id}` : low(e.name));
|
|
80
|
+
exports.keyOf = keyOf;
|
|
81
|
+
/**
|
|
82
|
+
* The Areas list as it was arranged: that order first, then anything new in the board's own order. A
|
|
83
|
+
* folder keeps only the areas on the board now, and an area sits in one folder at most.
|
|
84
|
+
*/
|
|
85
|
+
function layoutOf(names, arr) {
|
|
86
|
+
const known = new Map(names.map((n) => [low(n), n]));
|
|
87
|
+
const filed = new Set();
|
|
88
|
+
const folders = (arr?.folders ?? []).map((f) => {
|
|
89
|
+
const areas = [];
|
|
90
|
+
for (const a of f.areas) {
|
|
91
|
+
const n = known.get(low(a));
|
|
92
|
+
if (n && !filed.has(low(n))) {
|
|
93
|
+
filed.add(low(n));
|
|
94
|
+
areas.push(n);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return { kind: 'folder', id: f.id, name: f.name, areas };
|
|
98
|
+
});
|
|
99
|
+
const all = [...folders, ...names.filter((n) => !filed.has(low(n))).map((name) => ({ kind: 'area', name }))];
|
|
100
|
+
const byKey = new Map(all.map((e) => [(0, exports.keyOf)(e), e]));
|
|
101
|
+
const out = [];
|
|
102
|
+
const used = new Set();
|
|
103
|
+
for (const k of arr?.order ?? []) {
|
|
104
|
+
const e = byKey.get(k.startsWith('folder:') ? k : low(k));
|
|
105
|
+
if (e && !used.has((0, exports.keyOf)(e))) {
|
|
106
|
+
used.add((0, exports.keyOf)(e));
|
|
107
|
+
out.push(e);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
for (const e of all)
|
|
111
|
+
if (!used.has((0, exports.keyOf)(e)))
|
|
112
|
+
out.push(e);
|
|
113
|
+
return out;
|
|
114
|
+
}
|
|
115
|
+
/** The rows as they're saved. */
|
|
116
|
+
const arrangementOf = (es) => ({
|
|
117
|
+
folders: es.flatMap((e) => (e.kind === 'folder' ? [{ id: e.id, name: e.name, areas: e.areas }] : [])),
|
|
118
|
+
order: es.map((e) => (e.kind === 'folder' ? `folder:${e.id}` : e.name)),
|
|
119
|
+
});
|
|
120
|
+
exports.arrangementOf = arrangementOf;
|
package/dist/areas.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Folders in the local board's side nav: what you make under Areas, name, and drag areas into. Saved
|
|
4
|
+
* in `.arbiter/areas.json`, beside the record, so it travels with the project: teammates and an
|
|
5
|
+
* exported copy see the same folders. Areas themselves stay automatic (src/board-types.ts, `areasFor`
|
|
6
|
+
* on the page); a folder only holds them, by name, so a change that joins an area joins its folder too.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.areasPath = exports.AREAS_FILE = void 0;
|
|
13
|
+
exports.readArrangement = readArrangement;
|
|
14
|
+
exports.cleanArrangement = cleanArrangement;
|
|
15
|
+
exports.writeArrangement = writeArrangement;
|
|
16
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
17
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
18
|
+
exports.AREAS_FILE = 'areas.json';
|
|
19
|
+
const MAX_FOLDERS = 50;
|
|
20
|
+
const MAX_NAME = 60;
|
|
21
|
+
const MAX_AREA = 200;
|
|
22
|
+
const MAX_ORDER = 1000;
|
|
23
|
+
const FOLDER_ID = /^[a-z0-9]{1,24}$/;
|
|
24
|
+
const areasPath = (paths) => node_path_1.default.join(paths.archiveDir, exports.AREAS_FILE);
|
|
25
|
+
exports.areasPath = areasPath;
|
|
26
|
+
/** The saved folders, or null when there are none. A file that doesn't read is no folders, not a broken board. */
|
|
27
|
+
function readArrangement(paths) {
|
|
28
|
+
const file = (0, exports.areasPath)(paths);
|
|
29
|
+
if (!node_fs_1.default.existsSync(file))
|
|
30
|
+
return null;
|
|
31
|
+
try {
|
|
32
|
+
const r = cleanArrangement(JSON.parse(node_fs_1.default.readFileSync(file, 'utf8')));
|
|
33
|
+
return r.ok ? r.value : null;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* What the page sent, checked and tidied: names trimmed, an area in one folder at most (the first),
|
|
41
|
+
* one entry per thing in the order. Anything it can't make sense of is refused whole, with why.
|
|
42
|
+
*/
|
|
43
|
+
function cleanArrangement(input) {
|
|
44
|
+
const errors = [];
|
|
45
|
+
const raw = (input ?? {});
|
|
46
|
+
if (!Array.isArray(raw.folders))
|
|
47
|
+
errors.push('folders must be a list');
|
|
48
|
+
if (raw.order !== undefined && !Array.isArray(raw.order))
|
|
49
|
+
errors.push('order must be a list');
|
|
50
|
+
if (errors.length)
|
|
51
|
+
return { ok: false, errors };
|
|
52
|
+
const list = raw.folders;
|
|
53
|
+
if (list.length > MAX_FOLDERS)
|
|
54
|
+
return { ok: false, errors: [`At most ${MAX_FOLDERS} folders`] };
|
|
55
|
+
const folders = [];
|
|
56
|
+
const ids = new Set();
|
|
57
|
+
const names = new Set();
|
|
58
|
+
const filed = new Set();
|
|
59
|
+
for (const f of list) {
|
|
60
|
+
const x = (f ?? {});
|
|
61
|
+
const id = typeof x.id === 'string' ? x.id : '';
|
|
62
|
+
const name = typeof x.name === 'string' ? x.name.replace(/\s+/g, ' ').trim() : '';
|
|
63
|
+
if (!FOLDER_ID.test(id)) {
|
|
64
|
+
errors.push(`A folder id must be letters and digits: ${JSON.stringify(x.id)}`);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (ids.has(id)) {
|
|
68
|
+
errors.push(`Two folders share the id ${id}`);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (!name) {
|
|
72
|
+
errors.push('A folder needs a name');
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (name.length > MAX_NAME) {
|
|
76
|
+
errors.push(`A folder name is ${MAX_NAME} characters at most`);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (names.has(name.toLowerCase())) {
|
|
80
|
+
errors.push(`There's already a folder called ${name}`);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (!Array.isArray(x.areas)) {
|
|
84
|
+
errors.push(`${name}: areas must be a list`);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
ids.add(id);
|
|
88
|
+
names.add(name.toLowerCase());
|
|
89
|
+
const areas = [];
|
|
90
|
+
for (const a of x.areas) {
|
|
91
|
+
if (typeof a !== 'string')
|
|
92
|
+
continue;
|
|
93
|
+
const area = a.trim();
|
|
94
|
+
if (!area || area.length > MAX_AREA || filed.has(area.toLowerCase()))
|
|
95
|
+
continue;
|
|
96
|
+
filed.add(area.toLowerCase());
|
|
97
|
+
areas.push(area);
|
|
98
|
+
}
|
|
99
|
+
folders.push({ id, name, areas });
|
|
100
|
+
}
|
|
101
|
+
if (errors.length)
|
|
102
|
+
return { ok: false, errors };
|
|
103
|
+
const order = [];
|
|
104
|
+
const seen = new Set();
|
|
105
|
+
for (const k of raw.order ?? []) {
|
|
106
|
+
if (typeof k !== 'string')
|
|
107
|
+
continue;
|
|
108
|
+
const key = k.trim();
|
|
109
|
+
if (!key || key.length > MAX_AREA + 7 || seen.has(key.toLowerCase()))
|
|
110
|
+
continue;
|
|
111
|
+
// A folder that isn't there, or an area that's inside a folder, has no place at the top.
|
|
112
|
+
if (key.startsWith('folder:') ? !ids.has(key.slice(7)) : filed.has(key.toLowerCase()))
|
|
113
|
+
continue;
|
|
114
|
+
seen.add(key.toLowerCase());
|
|
115
|
+
order.push(key);
|
|
116
|
+
if (order.length >= MAX_ORDER)
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
return { ok: true, value: { folders, order } };
|
|
120
|
+
}
|
|
121
|
+
/** Saves the folders. With none left and no order of your own, the file goes, and the board is as it was. */
|
|
122
|
+
function writeArrangement(paths, a) {
|
|
123
|
+
const file = (0, exports.areasPath)(paths);
|
|
124
|
+
if (!a.folders.length && !a.order.length) {
|
|
125
|
+
if (node_fs_1.default.existsSync(file))
|
|
126
|
+
node_fs_1.default.rmSync(file);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
node_fs_1.default.mkdirSync(paths.archiveDir, { recursive: true });
|
|
130
|
+
node_fs_1.default.writeFileSync(file, `${JSON.stringify(a, null, 2)}\n`);
|
|
131
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* What the local board draws, as the CLI sends it: one definition for both sides. The CLI builds it
|
|
4
|
+
* (src/localboard.ts) and the page reads it (board/types.ts, board/lib/board.ts), so a change to one
|
|
5
|
+
* that the other doesn't follow fails the build instead of breaking the page.
|
|
6
|
+
*
|
|
7
|
+
* Types only, with no imports: the page's build reads this file too.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/candidates.js
CHANGED
|
@@ -81,6 +81,12 @@ function formatCandidate(c, decisions) {
|
|
|
81
81
|
}
|
|
82
82
|
const HEADING = /^# (C-\d{4,}) · (.*)$/;
|
|
83
83
|
const IMG = /^!\[.*?\]\((.+?)\)$/;
|
|
84
|
+
/**
|
|
85
|
+
* The only pictures a card has: the ones `candidate` copies in, named by its id. Anything else in the
|
|
86
|
+
* file (`../hosted.token`, a path out of the project) is no picture, so export, the board and remove
|
|
87
|
+
* never read, copy or delete outside the candidates folder.
|
|
88
|
+
*/
|
|
89
|
+
const PICTURE = /^C-\d{4,}\.(png|jpe?g|webp|gif|svg)$/;
|
|
84
90
|
const FIELD = /\*\*([A-Za-z ]+):\*\* (.*?)(?=\s·\s\*\*|$)/g;
|
|
85
91
|
function parseCandidate(md) {
|
|
86
92
|
const lines = md.split('\n');
|
|
@@ -111,7 +117,7 @@ function parseCandidate(md) {
|
|
|
111
117
|
continue;
|
|
112
118
|
const img = IMG.exec(line);
|
|
113
119
|
if (img) {
|
|
114
|
-
c.snapshot = img[1];
|
|
120
|
+
c.snapshot = PICTURE.test(img[1]) ? img[1] : null;
|
|
115
121
|
continue;
|
|
116
122
|
}
|
|
117
123
|
if (!line.startsWith('- **'))
|