arbiterdesign 0.1.4 → 0.1.6
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 +32 -9
- package/dist/commands/export.js +9 -6
- package/dist/commands/init.js +4 -0
- package/dist/commands/publish.js +12 -1
- package/dist/commands/pull.js +25 -4
- package/dist/commands/record.js +80 -14
- package/dist/commands/remove.js +17 -1
- package/dist/commands/request.js +123 -0
- package/dist/commands/review.js +91 -8
- package/dist/commands/rules.js +61 -7
- package/dist/commands/setup.js +39 -2
- package/dist/commands/snapshot.js +12 -5
- package/dist/findings.js +10 -1
- package/dist/format.js +17 -10
- package/dist/hosted.js +60 -13
- package/dist/index.js +20 -8
- package/dist/pictures.js +52 -0
- package/dist/requests.js +194 -0
- package/dist/store.js +9 -0
- package/package.json +1 -1
- package/templates/SKILL.md +162 -26
- package/templates/review.html +114 -4
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ That's the whole install. It writes:
|
|
|
16
16
|
| `.arbiter/candidates/` | One page per generated screen or direction, with its state, snapshot, decisions, and why it lost. |
|
|
17
17
|
| `CANDIDATES.md` | Index of candidates — written only when `destination` is `git`. |
|
|
18
18
|
| `.claude/skills/arbiter/SKILL.md` or `.cursor/rules/arbiter.mdc` | Tells the agent to surface its decisions after UI work and record what you confirm. |
|
|
19
|
-
| `arbiter.json` | Config. `destination: "local"`. |
|
|
19
|
+
| `arbiter.json` | Config. `destination: "local"`. `app.url` (from `npx arbiter setup --app http://localhost:3000`) is where the agent opens screens for pictures. |
|
|
20
20
|
| `AGENTS.md` | One line appended, pointing at `DECISIONS.md`. Merged, never overwritten. |
|
|
21
21
|
| `CLAUDE.md` (Claude Code) / `.cursor/commands/arbiter.md` (Cursor) | Same pointer line in Claude Code's own context file; a `/arbiter` command for Cursor. |
|
|
22
22
|
|
|
@@ -24,10 +24,10 @@ Running `init` twice changes nothing.
|
|
|
24
24
|
|
|
25
25
|
## How it works
|
|
26
26
|
|
|
27
|
-
1. You ask the agent to build a screen. It reads `DECISIONS.md` first.
|
|
27
|
+
1. You ask the agent to build a screen. It reads `DECISIONS.md` first. After a sizeable piece of work it names up to three rules that shaped it, *Following D-0001 (removing asks first, no undo bar)*, so you can see the record working. How often follows the check-in setting: never under `quiet`, every time a rule changed something under `every`.
|
|
28
28
|
2. You iterate. It says nothing about decisions while you're iterating — each version you move past becomes a rejected alternative on the one that replaced it.
|
|
29
|
-
3. When you move on, it queues the design calls it made — sized as `feature`, `pattern`, or `polish` — and, after feature-level work, says one line about what changed.
|
|
30
|
-
4. You judge them when you want — in chat with `/arbiter`, or in the browser with `npx arbiter review`. Grouped by piece of work; each item reads **Change** (what happened) / **Pattern** (the rule) / **Rejected** (what lost). Per item: **Confirm**, **Make it a rule**, **Skip**, or type a correction. Polish is one line per group — **Confirm all**.
|
|
29
|
+
3. When you move on, it queues the design calls it made — sized as `feature`, `pattern`, or `polish` — and, after feature-level work, says one line about what changed. When 5 changes are waiting (then 10, 15…), it asks in plain text whether you want to review them now; polish doesn't count, and `setup --checkin quiet` turns both off.
|
|
30
|
+
4. You judge them when you want — in chat with `/arbiter`, or in the browser with `npx arbiter review`. Grouped by piece of work; each item reads **Change** (what happened) / **Pattern** (the rule) / **Rejected** (what lost). Per item: **Confirm**, **Make it a rule**, **Skip**, or type a correction. Polish is one line per group — **Confirm all**. In chat, an item that goes against an active rule says so (*Clashes — D-0009*) and asks which wins: **Follow D-0009**, **Replace D-0009**, or **Keep as exception**.
|
|
31
31
|
5. Rules enter `DECISIONS.md`. Everything judged enters the archive. Skips vanish.
|
|
32
32
|
|
|
33
33
|
You can also just say it: *"make that a rule"*, *"reject the tabs, going with a single page"*. It records without asking.
|
|
@@ -38,6 +38,8 @@ Nothing enforces anything. Rules inform generation; they don't gate it.
|
|
|
38
38
|
|
|
39
39
|
```
|
|
40
40
|
arbiter init install into this project [--destination git]
|
|
41
|
+
arbiter setup --checkin <mode> how often the agent checks in: feature | quiet | every
|
|
42
|
+
arbiter setup --app <url> where the app runs, so the agent can open screens for pictures
|
|
41
43
|
arbiter snapshot "<work>" --file x.png a picture for a piece of work (or --capture on macOS); publish carries it
|
|
42
44
|
arbiter record walk through a decision at the terminal
|
|
43
45
|
arbiter record '<json>' record now (what the agent calls)
|
|
@@ -46,6 +48,8 @@ arbiter record P-0003 --as rule judge a queued one: accept | rule | skip | f
|
|
|
46
48
|
arbiter record --all --as accept judge every queued item [--level polish] [--trigger "Settings build"]
|
|
47
49
|
arbiter record --findings f.json queue a scanner's findings for verdicts
|
|
48
50
|
arbiter record --retire D-0003 --why "…" drop a rule with no replacement
|
|
51
|
+
arbiter record R-0001 --as apply answer a request from the board: apply [--to "<instead>"] | decline --why "…"
|
|
52
|
+
arbiter record '<json>' --request R-0001 record the change made for an approved request; it's applied
|
|
49
53
|
arbiter remove D-0004 take out a record that was never real: a decision, a screen (C-0001),
|
|
50
54
|
or a picture (--snapshot "<work>")
|
|
51
55
|
arbiter unlink D-0004 detach a decision from the screen it was recorded against
|
|
@@ -60,12 +64,13 @@ arbiter publish board online at arbiter.design, with comment
|
|
|
60
64
|
arbiter publish --to <url|pages> your own hosted Arbiter, or GitHub Pages (git destination + export + commit + push)
|
|
61
65
|
arbiter publish --on-push also write a GitHub Actions workflow that republishes on every push, and set its secret
|
|
62
66
|
arbiter publish --auto republish whenever the record changes — no GitHub, no CI, no repository needed
|
|
63
|
-
arbiter pull bring comments and "looks good" reactions down into .arbiter/comments.json
|
|
67
|
+
arbiter pull bring comments and "looks good" reactions down into .arbiter/comments.json;
|
|
68
|
+
"Request change" becomes a request (R-0001) in .arbiter/requests.json
|
|
64
69
|
arbiter drift deviations per screen: accepts, unverified claims, rules broken
|
|
65
70
|
arbiter rules active rules [--dimension <name>] [--json]
|
|
66
|
-
arbiter rules --pending the queue
|
|
71
|
+
arbiter rules --pending the queue, and requests waiting on an answer
|
|
67
72
|
arbiter rules --archive everything ever
|
|
68
|
-
arbiter rules D-0003 one decision in full
|
|
73
|
+
arbiter rules D-0003 one decision in full (R-0001: one request)
|
|
69
74
|
arbiter update newest Arbiter: install it, refresh the skill file, re-pin the workflow [--check]
|
|
70
75
|
```
|
|
71
76
|
|
|
@@ -73,12 +78,14 @@ arbiter update newest Arbiter: install it, refresh the skil
|
|
|
73
78
|
|
|
74
79
|
## Screenshots
|
|
75
80
|
|
|
76
|
-
The agent takes one picture per piece of work, when the work settles and it changed how a specific screen looks. Size isn't the test — a
|
|
81
|
+
The agent takes one picture per piece of work, when the work settles and it changed how a specific screen looks. Size isn't the test — a small pattern change on one screen earns a picture; a font or token change has no single screen to point at and doesn't. Motion and anything behavioural can't be carried by a still, so they don't either. Work that's only polish gets none: polish never reaches the board, so there'd be no card to show it on.
|
|
77
82
|
|
|
78
83
|
The agent's own screenshot tool hands it an image, not a file, so it renders to disk with a headless browser (`chrome --headless --screenshot=…`) and attaches that. When it can't — no browser, app not running, screen behind a login — it says so once, naming the reason, whatever the check-in setting. `--capture` is the manual fallback and is macOS only; elsewhere, save a screenshot and pass `--file`.
|
|
79
84
|
|
|
80
85
|
Name a piece of work after the screen it changed where the work splits that way — `Settings — billing` rather than one `Settings build` across four routes — and one picture per piece of work is one per screen.
|
|
81
86
|
|
|
87
|
+
The board shows an icon of the kind of change where a card has no picture, so a missing one never looks broken there. That's also why nobody notices, so Arbiter says it where it can still be fixed. A change asks for a picture when it's about one screen (not `global`) and is layout, words or looks (`structure`, `content`, `visual`); interaction, states, motion and access are right as an icon. When such a card has none, `record` adds a `picture` line with the command to the agent's reply, the review page marks the group "No picture", and `publish` to arbiter.design lists the card (the agent passes the list on). Scanner findings never ask: they're a line in a file, not a screen. Nothing on the board changes.
|
|
88
|
+
|
|
82
89
|
## Taking something out
|
|
83
90
|
|
|
84
91
|
Three acts, and only one is a removal.
|
|
@@ -122,7 +129,7 @@ The scan set is the rule's `paths` (directories or files) if it names any, else
|
|
|
122
129
|
|
|
123
130
|
## Hosted board
|
|
124
131
|
|
|
125
|
-
The hosted board at [arbiter.design](https://arbiter.design) serves a board at a share link and lets people comment or say "looks good" after a magic-link sign-in. Git stays the record: the service holds one board version per project and the comments, nothing else. `npx arbiter publish` uploads; `npx arbiter pull` brings comments back, where `arbiter review` shows them beside each screen. Only `publish` and `pull` ever touch the network. The service itself is a separate, private codebase.
|
|
132
|
+
The hosted board at [arbiter.design](https://arbiter.design) serves a board at a share link and lets people comment, request a change, or say "looks good" after a magic-link sign-in. Git stays the record: the service holds one board version per project and the comments, nothing else. `npx arbiter publish` uploads; `npx arbiter pull` brings comments back, where `arbiter review` shows them beside each screen. Only `publish` and `pull` ever touch the network. The service itself is a separate, private codebase.
|
|
126
133
|
|
|
127
134
|
Two ways to keep the board current without anyone remembering.
|
|
128
135
|
|
|
@@ -130,6 +137,22 @@ Two ways to keep the board current without anyone remembering.
|
|
|
130
137
|
|
|
131
138
|
`npx arbiter publish --on-push` is the GitHub route, and it writes `.github/workflows/arbiter.yml`, which runs `publish` when decisions land on the default branch, and sets the `ARBITER_PUBLISH_TOKEN` repository secret through `gh` if it's signed in (otherwise it prints the one-line instruction). Commit the workflow together with `.arbiter/hosted.json`. Under CI, `publish` only ever updates the board that file names — it refuses to create one, so a repo where the file wasn't committed can't mint orphan boards on every push.
|
|
132
139
|
|
|
140
|
+
## Requests from the board
|
|
141
|
+
|
|
142
|
+
A comment is input; it waits until the owner points at it. **Request change** on the board is different: someone wants something changed, so it gets an answer.
|
|
143
|
+
|
|
144
|
+
1. `npx arbiter pull` turns each one into a request, `R-0001`, in `.arbiter/requests.json` (commit it — everyone sees the same answers). Pulling twice never asks twice. If the person who asked deletes it on the board before the change is made, the next pull takes it off the queue and says so.
|
|
145
|
+
2. The owner answers — in chat with `/arbiter`, or on the **Requests** tab of `arbiter review`:
|
|
146
|
+
- **Apply** — `record R-0001 --as apply`
|
|
147
|
+
- **Apply, but…** — `record R-0001 --as apply --to "keep the tab, make the button red"`: do this instead of what was asked
|
|
148
|
+
- **Decline** — `record R-0001 --as decline --why "…"`: the reason is required, because the requester reads it
|
|
149
|
+
3. Approving changes no code — only the agent can. In chat it makes the change right away; approved from the review page, it's made at the next `/arbiter`. The agent records what it did with `--request R-0001`, and that's what applies it. Only an approved request can be applied; a change the owner hasn't said yes to is refused.
|
|
150
|
+
4. `publish` carries the answers back: the requester sees *Open*, *Approved*, *Applied* — with what actually changed — or *Declined* with the reason, under their request.
|
|
151
|
+
|
|
152
|
+
Nothing is applied without the owner, and the board never writes to git: requests come in through `pull`, answers go out through `publish`. Removing the last decision that applied a request opens the request again, for a fresh answer — the agent never remakes it unasked. A screen or decision with a request waiting on it (open, or approved and not yet made) can't be removed until the request is declined or applied.
|
|
153
|
+
|
|
154
|
+
Whoever is signed in on the board chooses their own display name, and what they write is theirs, so neither is trusted: names arrive as one line, and the record can't be given a line, an entry or a field by anything it stores.
|
|
155
|
+
|
|
133
156
|
## Candidates
|
|
134
157
|
|
|
135
158
|
When several directions are generated for one feature, each is a candidate. A snapshot comes from the agent's browser tool (`--snapshot <image>`) or, on macOS, from you: `--capture` drops into drag-to-select and saves what you pick. Approving one supersedes the rest with the reason kept. Decisions link to a candidate; its page lists them. `npx arbiter publish` does all of the below in one go — switches to git, exports, commits, turns on GitHub Pages through `gh` if it's signed in, pushes, prints the link. It's the only command that touches the network, and only when you run it.
|
package/dist/commands/export.js
CHANGED
|
@@ -23,7 +23,8 @@ const schema_1 = require("../schema");
|
|
|
23
23
|
const format_1 = require("../format");
|
|
24
24
|
const store_1 = require("../store");
|
|
25
25
|
const STATE_ORDER = ['approved', 'in_review', 'generated', 'rejected', 'superseded'];
|
|
26
|
-
|
|
26
|
+
/** In a designer's words, as the hosted board says them. The record keeps its own (`generated`, `superseded`). */
|
|
27
|
+
const STATE_LABEL = { approved: 'Approved', in_review: 'In review', generated: 'Draft', rejected: 'Rejected', superseded: 'Replaced' };
|
|
27
28
|
function exportBoard(opts = {}) {
|
|
28
29
|
const root = (0, store_1.findRoot)(opts.cwd);
|
|
29
30
|
const paths = (0, store_1.resolvePaths)(root);
|
|
@@ -90,6 +91,7 @@ function page(d) {
|
|
|
90
91
|
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 44px 0 14px; }
|
|
91
92
|
.cand { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 24px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px; margin-bottom: 14px; }
|
|
92
93
|
.cand.lesser { grid-template-columns: 220px minmax(0,1fr); padding: 16px 20px; opacity: .85; }
|
|
94
|
+
.cand.noshot { grid-template-columns: minmax(0,1fr); }
|
|
93
95
|
@media (max-width: 680px) { .cand, .cand.lesser { grid-template-columns: 1fr; } }
|
|
94
96
|
.shot { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--tag); min-height: 60px; display:flex; align-items:center; justify-content:center; color: var(--muted); font-size: 13px; }
|
|
95
97
|
.shot img { display:block; width:100%; height:auto; }
|
|
@@ -130,14 +132,15 @@ function section(feature, cands, d) {
|
|
|
130
132
|
function card(c, d) {
|
|
131
133
|
const lesser = c.state === 'rejected' || c.state === 'superseded';
|
|
132
134
|
const by = c.supersededBy ? d.byId.get(c.supersededBy) : null;
|
|
133
|
-
const state = c.state === 'superseded' && by ? `
|
|
134
|
-
|
|
135
|
+
const state = c.state === 'superseded' && by ? `Replaced by ${esc(by.name)}` : STATE_LABEL[c.state];
|
|
136
|
+
// No picture, no frame — the card is its words alone, as on the hosted board.
|
|
137
|
+
const shot = c.snapshot ? `<div class="shot"><img src="snapshots/${esc(c.snapshot)}" alt="${esc(c.name)}"></div>` : '';
|
|
135
138
|
const decs = d.decisions(c.id);
|
|
136
139
|
const decisions = decs.length
|
|
137
140
|
? `<div class="decs"><h4>Decided here</h4><ul>${decs.map((x) => `<li>${esc(x.change ?? x.decision)}${x.rejected.length ? `<small>over ${esc(x.rejected.map((r) => r.split(' — ')[0]).join(', '))}</small>` : ''}</li>`).join('')}</ul></div>`
|
|
138
141
|
: '';
|
|
139
|
-
return `<article class="cand${lesser ? ' lesser' : ''}">
|
|
140
|
-
|
|
142
|
+
return `<article class="cand${lesser ? ' lesser' : ''}${shot ? '' : ' noshot'}">
|
|
143
|
+
${shot}
|
|
141
144
|
<div>
|
|
142
145
|
<h3>${esc(c.name)}<span class="state ${c.state}">${state}</span></h3>
|
|
143
146
|
<p class="who">${esc(c.author)} · ${c.date.slice(0, 10)}</p>
|
|
@@ -151,7 +154,7 @@ function rulesSection(rules) {
|
|
|
151
154
|
if (!rules.length)
|
|
152
155
|
return '';
|
|
153
156
|
const groups = schema_1.DIMENSIONS.map((dim) => [dim, rules.filter((r) => r.dimension === dim)]).filter(([, rs]) => rs.length);
|
|
154
|
-
return `<section class="rules"><h2>
|
|
157
|
+
return `<section class="rules"><h2>Design rules · ${rules.length}</h2>${groups
|
|
155
158
|
.map(([dim, rs]) => `<h4>${format_1.DIMENSION_LABELS[dim]}</h4><ul>${rs.map((r) => `<li>${esc(r.decision)}<small>${esc(r.rationale)}</small></li>`).join('')}</ul>`)
|
|
156
159
|
.join('')}</section>`;
|
|
157
160
|
}
|
package/dist/commands/init.js
CHANGED
|
@@ -218,6 +218,10 @@ function installSelf(root) {
|
|
|
218
218
|
return { file: 'package.json', outcome: 'skipped', note: `no package.json here — add ${self.name} as a dev dependency yourself` };
|
|
219
219
|
}
|
|
220
220
|
const host = JSON.parse(node_fs_1.default.readFileSync(hostPkgPath, 'utf8'));
|
|
221
|
+
// Arbiter's own repo, dogfooding: `npx arbiter` already resolves to the package itself.
|
|
222
|
+
if (host.name === self.name) {
|
|
223
|
+
return { file: 'package.json', outcome: 'unchanged', note: `this is ${self.name} itself — not adding it as its own dependency` };
|
|
224
|
+
}
|
|
221
225
|
if (host.devDependencies?.[self.name] || host.dependencies?.[self.name]) {
|
|
222
226
|
return { file: 'package.json', outcome: 'unchanged', note: `${self.name} already a dependency` };
|
|
223
227
|
}
|
package/dist/commands/publish.js
CHANGED
|
@@ -24,6 +24,7 @@ const candidates_1 = require("../candidates");
|
|
|
24
24
|
const destination_1 = require("../destination");
|
|
25
25
|
const store_1 = require("../store");
|
|
26
26
|
const hosted_1 = require("../hosted");
|
|
27
|
+
const pictures_1 = require("../pictures");
|
|
27
28
|
const init_1 = require("./init");
|
|
28
29
|
/** Where `arbiter publish` goes when nothing says otherwise. */
|
|
29
30
|
exports.DEFAULT_HOST = 'https://arbiter.design';
|
|
@@ -44,9 +45,11 @@ async function publish(opts = {}) {
|
|
|
44
45
|
const r = await (0, hosted_1.publishHosted)(paths, to, { admin: opts.admin });
|
|
45
46
|
if (r.created)
|
|
46
47
|
done('project', `created on ${to} — link in .arbiter/hosted.json (commit it); token in .arbiter/hosted.token (git-ignored — teammates set ARBITER_PUBLISH_TOKEN)`);
|
|
47
|
-
|
|
48
|
+
// No image count: a card without a picture shows an icon of its kind, and that's usually right.
|
|
49
|
+
done('board', `${r.candidates} screen${r.candidates === 1 ? '' : 's'} published`);
|
|
48
50
|
for (const s of r.skipped)
|
|
49
51
|
skip('snapshot', s);
|
|
52
|
+
steps.push(...pictureSteps(paths));
|
|
50
53
|
if (opts.onPush)
|
|
51
54
|
for (const s of onPush(root, paths))
|
|
52
55
|
steps.push(s);
|
|
@@ -126,6 +129,14 @@ async function publish(opts = {}) {
|
|
|
126
129
|
const ok = steps.every((s) => s.outcome !== 'failed');
|
|
127
130
|
return { ok, steps, url };
|
|
128
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* The last chance to notice before someone opens the board: a line per card that should have a
|
|
134
|
+
* picture and doesn't, with the command. Cards that are right as an icon say nothing. Hosted
|
|
135
|
+
* only: the Pages export has no work cards, so it would be asking for pictures nobody sees.
|
|
136
|
+
*/
|
|
137
|
+
function pictureSteps(paths) {
|
|
138
|
+
return (0, pictures_1.missingPictures)(paths, (0, store_1.readArchive)(paths).filter(hosted_1.publishable)).map((m) => ({ step: 'picture', outcome: 'missing', note: `${m.name}: ${m.command}` }));
|
|
139
|
+
}
|
|
129
140
|
/**
|
|
130
141
|
* Keep the board current without anyone remembering to publish: a workflow that runs `publish`
|
|
131
142
|
* when decisions land on the default branch. The publish token becomes a repository secret —
|
package/dist/commands/pull.js
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* `arbiter pull` — bring comments and "looks good" reactions down from the hosted board. A
|
|
4
|
+
* "Request change" becomes a request (R-0001) waiting on the owner's answer.
|
|
5
|
+
*/
|
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
7
|
exports.pull = pull;
|
|
5
8
|
const candidates_1 = require("../candidates");
|
|
6
9
|
const hosted_1 = require("../hosted");
|
|
10
|
+
const requests_1 = require("../requests");
|
|
7
11
|
const store_1 = require("../store");
|
|
8
12
|
async function pull(opts = {}) {
|
|
9
13
|
const paths = (0, store_1.resolvePaths)((0, store_1.findRoot)(opts.cwd));
|
|
10
|
-
const { link, fresh, total } = await (0, hosted_1.pullHosted)(paths);
|
|
14
|
+
const { link, fresh, current, total } = await (0, hosted_1.pullHosted)(paths);
|
|
15
|
+
// Withdrawn first: a request deleted on the board leaves the queue before anything new arrives.
|
|
16
|
+
const withdrawn = (0, requests_1.dropWithdrawn)(paths, new Set(current.filter((c) => c.kind === 'request').map((c) => c.id)));
|
|
17
|
+
// Every request on the board, not only the fresh ones: one pulled by an older Arbiter still counts.
|
|
18
|
+
const opened = new Map((0, requests_1.openRequests)(paths, current).map((r) => [r.comment, r.id]));
|
|
19
|
+
const waiting = (0, requests_1.readRequests)(paths).filter((r) => r.status === 'open').length;
|
|
20
|
+
const toAnswer = `${waiting} request${waiting === 1 ? '' : 's'} to answer — /arbiter in chat, or npx arbiter review.`;
|
|
21
|
+
const gone = withdrawn.map((r) => `${r.author} withdrew ${r.id} on the board, so it's off your queue: ${(0, requests_1.oneLine)(r.body)}`);
|
|
11
22
|
if (!fresh.length)
|
|
12
|
-
return `Nothing new on ${link.shareUrl} (${total} comment${total === 1 ? '' : 's'} so far)
|
|
23
|
+
return [`Nothing new on ${link.shareUrl} (${total} comment${total === 1 ? '' : 's'} so far).`, ...gone, ...(waiting ? [toAnswer] : [])].join('\n');
|
|
13
24
|
const names = new Map((0, candidates_1.readCandidates)(paths).map((c) => [c.id, c.name]));
|
|
14
25
|
const lines = [`${fresh.length} new from ${link.shareUrl}:`, ''];
|
|
15
26
|
const byCand = new Map();
|
|
@@ -19,9 +30,19 @@ async function pull(opts = {}) {
|
|
|
19
30
|
lines.push(` ${cid} ${names.get(cid) ?? (cid.startsWith('W-') ? cid.slice(2).replace(/-/g, ' ').replace(/^\w/, (ch) => ch.toUpperCase()) : '')}`);
|
|
20
31
|
for (const c of cs) {
|
|
21
32
|
const stale = c.board_version && link.boardVersion && c.board_version !== link.boardVersion ? ' (earlier version)' : '';
|
|
22
|
-
|
|
33
|
+
const on = c.decision_id ? ` on ${c.decision_id}` : '';
|
|
34
|
+
if (c.kind === 'approve')
|
|
35
|
+
lines.push(` ✓ ${c.author_name} — looks good${stale}`);
|
|
36
|
+
else if (c.kind === 'request')
|
|
37
|
+
lines.push(` ${c.author_name} requests a change${on}: ${c.body}${stale}${opened.has(c.id) ? ` → ${opened.get(c.id)}` : ''}`);
|
|
38
|
+
else
|
|
39
|
+
lines.push(` ${c.author_name}${on}: ${c.body}${stale}`);
|
|
23
40
|
}
|
|
24
41
|
}
|
|
25
42
|
lines.push('', 'Saved to .arbiter/comments.json — npx arbiter review shows them beside each screen. Say "record Sam\'s comment as a rule" in a session to act on one.');
|
|
43
|
+
if (gone.length)
|
|
44
|
+
lines.push(...gone);
|
|
45
|
+
if (waiting)
|
|
46
|
+
lines.push(toAnswer);
|
|
26
47
|
return lines.join('\n');
|
|
27
48
|
}
|
package/dist/commands/record.js
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* record P-0003 --as rule judge a queued decision (accept | rule | skip | fix --to "<what instead>")
|
|
8
8
|
* record --all --as accept judge every queued decision the same way [--level polish] [--trigger "…"]
|
|
9
9
|
* record --retire D-0003 --why "…" drop a rule from DECISIONS.md with no replacement; the archive keeps both
|
|
10
|
+
* record R-0001 --as apply answer a request from the board (apply [--to "<instead>"] | decline --why "…")
|
|
11
|
+
* record '<json>' --request R-0001 record the change made for an approved request; it's applied
|
|
10
12
|
* record (a person at a terminal) walk through it step by step
|
|
11
13
|
*
|
|
12
14
|
* Output is JSON on stdout, always — an agent is usually on the other end.
|
|
@@ -22,6 +24,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
24
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
25
|
};
|
|
24
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.REVIEW_EVERY = void 0;
|
|
25
28
|
exports.record = record;
|
|
26
29
|
exports.queue = queue;
|
|
27
30
|
exports.queueFindings = queueFindings;
|
|
@@ -30,7 +33,6 @@ exports.judge = judge;
|
|
|
30
33
|
exports.judgeAll = judgeAll;
|
|
31
34
|
exports.recordInput = recordInput;
|
|
32
35
|
exports.interactiveInput = interactiveInput;
|
|
33
|
-
const node_os_1 = __importDefault(require("node:os"));
|
|
34
36
|
const node_path_1 = __importDefault(require("node:path"));
|
|
35
37
|
const schema_1 = require("../schema");
|
|
36
38
|
const store_1 = require("../store");
|
|
@@ -42,6 +44,8 @@ const prompt_1 = require("./prompt");
|
|
|
42
44
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
43
45
|
const candidate_1 = require("./candidate");
|
|
44
46
|
const update_1 = require("./update");
|
|
47
|
+
const pictures_1 = require("../pictures");
|
|
48
|
+
const request_1 = require("./request");
|
|
45
49
|
// ── Parse + record ─────────────────────────────────────────────────────────
|
|
46
50
|
function record(rawJson, opts = {}) {
|
|
47
51
|
const parsed = parse(rawJson);
|
|
@@ -50,6 +54,8 @@ function record(rawJson, opts = {}) {
|
|
|
50
54
|
return recordInput(parsed.input, opts);
|
|
51
55
|
}
|
|
52
56
|
function queue(rawJson, opts = {}) {
|
|
57
|
+
if (opts.request)
|
|
58
|
+
return fail([`--request records a change made for an approved request, directly: drop --pending. Nothing is queued for a request.`]);
|
|
53
59
|
const parsed = parse(rawJson, { pending: true });
|
|
54
60
|
if (!parsed.ok)
|
|
55
61
|
return parsed.result;
|
|
@@ -64,6 +70,10 @@ function queue(rawJson, opts = {}) {
|
|
|
64
70
|
if (entry.candidate)
|
|
65
71
|
(0, candidate_1.refreshCandidates)(paths);
|
|
66
72
|
}
|
|
73
|
+
// What the user would actually be asked about: polish is logged with its group, never presented.
|
|
74
|
+
const before = pending.filter((d) => d.level !== 'polish').length;
|
|
75
|
+
const waiting = before + (entry.level === 'polish' ? 0 : 1);
|
|
76
|
+
const checkin = (0, store_1.readConfig)(paths)?.checkin ?? 'feature';
|
|
67
77
|
return {
|
|
68
78
|
exitCode: 0,
|
|
69
79
|
output: {
|
|
@@ -72,13 +82,29 @@ function queue(rawJson, opts = {}) {
|
|
|
72
82
|
dimension: entry.dimension,
|
|
73
83
|
verified: entry.verified,
|
|
74
84
|
pending: pending.length + 1,
|
|
75
|
-
checkin
|
|
85
|
+
checkin,
|
|
86
|
+
waiting,
|
|
87
|
+
// A dry run wrote nothing, so the count it reached isn't real yet.
|
|
88
|
+
...(opts.dryRun ? {} : askToReview(before, waiting, checkin)),
|
|
76
89
|
review: 'npx arbiter review',
|
|
90
|
+
...picture(paths, entry),
|
|
77
91
|
// Present only when the project's skill file is from an older Arbiter than this one.
|
|
78
92
|
...(0, update_1.updateNotice)(paths),
|
|
79
93
|
},
|
|
80
94
|
};
|
|
81
95
|
}
|
|
96
|
+
/** Ask once each time the waiting count reaches another multiple of this. */
|
|
97
|
+
exports.REVIEW_EVERY = 5;
|
|
98
|
+
/**
|
|
99
|
+
* At 5, 10, 15 changes waiting, the agent asks whether to review now. A "no" just waits for the
|
|
100
|
+
* next multiple, and judging brings the count down, so the next ask comes when it climbs back.
|
|
101
|
+
* Quiet means quiet: someone who chose "Nothing until I ask" is never asked.
|
|
102
|
+
*/
|
|
103
|
+
function askToReview(before, after, checkin) {
|
|
104
|
+
if (checkin === 'quiet' || Math.floor(after / exports.REVIEW_EVERY) <= Math.floor(before / exports.REVIEW_EVERY))
|
|
105
|
+
return {};
|
|
106
|
+
return { ask: `You have ${after} changes waiting in Arbiter. Review them now? (yes / no)` };
|
|
107
|
+
}
|
|
82
108
|
/** Queue one pending decision per finding in a scanner's JSON output. */
|
|
83
109
|
function queueFindings(file, opts = {}) {
|
|
84
110
|
const paths = (0, store_1.resolvePaths)((0, store_1.findRoot)(opts.cwd));
|
|
@@ -94,6 +120,7 @@ function queueFindings(file, opts = {}) {
|
|
|
94
120
|
return fail(['no findings recognised in that file — expected an array of { file, message, line?, rule?, suggestion? } or ESLint-style output']);
|
|
95
121
|
const tool = opts.tool ?? node_path_1.default.basename(file, node_path_1.default.extname(file));
|
|
96
122
|
const pending = (0, store_1.readPending)(paths);
|
|
123
|
+
const before = pending.filter((d) => d.level !== 'polish').length;
|
|
97
124
|
const seen = new Set(pending.map((d) => d.trigger));
|
|
98
125
|
const added = [];
|
|
99
126
|
let skipped = 0;
|
|
@@ -110,7 +137,24 @@ function queueFindings(file, opts = {}) {
|
|
|
110
137
|
}
|
|
111
138
|
if (!opts.dryRun)
|
|
112
139
|
(0, store_1.writePending)(paths, pending);
|
|
113
|
-
|
|
140
|
+
// Findings are asked about like any other queued change, so they count toward the review question.
|
|
141
|
+
const waiting = pending.filter((d) => d.level !== 'polish').length;
|
|
142
|
+
const checkin = (0, store_1.readConfig)(paths)?.checkin ?? 'feature';
|
|
143
|
+
return {
|
|
144
|
+
exitCode: 0,
|
|
145
|
+
output: {
|
|
146
|
+
status: 'queued',
|
|
147
|
+
tool,
|
|
148
|
+
queued: added.length,
|
|
149
|
+
skippedDuplicates: skipped,
|
|
150
|
+
ids: added,
|
|
151
|
+
pending: pending.length,
|
|
152
|
+
checkin,
|
|
153
|
+
waiting,
|
|
154
|
+
...(opts.dryRun ? {} : askToReview(before, waiting, checkin)),
|
|
155
|
+
review: 'npx arbiter review',
|
|
156
|
+
},
|
|
157
|
+
};
|
|
114
158
|
}
|
|
115
159
|
function parse(rawJson, options = {}) {
|
|
116
160
|
let raw;
|
|
@@ -191,6 +235,9 @@ function judge(pendingId, opts) {
|
|
|
191
235
|
function judgeAll(opts) {
|
|
192
236
|
if (opts.as === 'fix')
|
|
193
237
|
return fail(['fix is one at a time — it needs its own --to']);
|
|
238
|
+
// A request is applied by the change made for it, not by everything that happens to be queued.
|
|
239
|
+
if (opts.request)
|
|
240
|
+
return fail([`--request links one change to ${opts.request}; it can't go on --all`]);
|
|
194
241
|
const paths = (0, store_1.resolvePaths)((0, store_1.findRoot)(opts.cwd));
|
|
195
242
|
const targets = (0, store_1.readPending)(paths).filter((d) => (!opts.level || d.level === opts.level) && (!opts.trigger || d.trigger === opts.trigger));
|
|
196
243
|
if (!targets.length)
|
|
@@ -225,15 +272,28 @@ function recordInput(input, opts = {}) {
|
|
|
225
272
|
const paths = (0, store_1.resolvePaths)(root);
|
|
226
273
|
const config = (0, store_1.readConfig)(paths);
|
|
227
274
|
const cap = config?.activeCap ?? store_1.ACTIVE_CAP;
|
|
275
|
+
// A change made for a request from the board — only once the owner has said yes.
|
|
276
|
+
let request = null;
|
|
277
|
+
if (opts.request) {
|
|
278
|
+
const gate = (0, request_1.requestGate)(paths, opts.request);
|
|
279
|
+
if (!gate.ok)
|
|
280
|
+
return fail(gate.errors);
|
|
281
|
+
request = gate.request;
|
|
282
|
+
input = (0, request_1.withRequest)(paths, input, request);
|
|
283
|
+
}
|
|
228
284
|
const active = (0, store_1.readActive)(paths);
|
|
229
285
|
const archive = (0, store_1.readArchive)(paths);
|
|
230
286
|
const supersedes = opts.supersedes ?? input.supersedes ?? null;
|
|
231
287
|
const entry = { ...fill(input, opts, root), id: (0, store_1.nextId)(archive), supersedes };
|
|
288
|
+
// Nothing written means the request isn't applied yet. Whatever the re-run is, it has to carry
|
|
289
|
+
// --request too, or the change lands and the request stays approved, to be made again.
|
|
290
|
+
const again = request ? ` --request ${request.id}` : '';
|
|
291
|
+
const keepRequest = (r) => request ? { ...r, output: { ...r.output, request: request.id, note: `Nothing was written, so ${request.id} isn't applied yet. Re-run with${again}.` } } : r;
|
|
232
292
|
// An `accept` is a deviation by definition — nothing to verify. Rules and fixes make claims.
|
|
233
293
|
if (entry.verdict !== 'accept') {
|
|
234
294
|
const checked = check(entry, root, opts);
|
|
235
295
|
if (checked)
|
|
236
|
-
return checked;
|
|
296
|
+
return keepRequest(checked);
|
|
237
297
|
}
|
|
238
298
|
let nextActive = active;
|
|
239
299
|
if (entry.verdict === 'retire') {
|
|
@@ -257,7 +317,7 @@ function recordInput(input, opts = {}) {
|
|
|
257
317
|
else if (!opts.keepBoth) {
|
|
258
318
|
const overlaps = (0, overlap_1.findOverlaps)(input, active, { ignore: config?.overlap?.ignore });
|
|
259
319
|
if (overlaps.length) {
|
|
260
|
-
return {
|
|
320
|
+
return keepRequest({
|
|
261
321
|
exitCode: 2,
|
|
262
322
|
output: {
|
|
263
323
|
status: 'overlap',
|
|
@@ -266,17 +326,17 @@ function recordInput(input, opts = {}) {
|
|
|
266
326
|
overlaps,
|
|
267
327
|
options: [
|
|
268
328
|
...overlaps.map((o) => ({
|
|
269
|
-
flag: `--supersedes ${o.id}`,
|
|
329
|
+
flag: `--supersedes ${o.id}${again}`,
|
|
270
330
|
effect: `${o.id} leaves DECISIONS.md and stays in the archive; the new rule records supersedes: ${o.id}`,
|
|
271
331
|
})),
|
|
272
|
-
{ flag:
|
|
332
|
+
{ flag: `--keep-both${again}`, effect: 'both rules stay active' },
|
|
273
333
|
],
|
|
274
334
|
},
|
|
275
|
-
};
|
|
335
|
+
});
|
|
276
336
|
}
|
|
277
337
|
}
|
|
278
338
|
if (nextActive.length >= cap) {
|
|
279
|
-
return {
|
|
339
|
+
return keepRequest({
|
|
280
340
|
exitCode: 3,
|
|
281
341
|
output: {
|
|
282
342
|
status: 'cap',
|
|
@@ -284,7 +344,7 @@ function recordInput(input, opts = {}) {
|
|
|
284
344
|
candidate: input,
|
|
285
345
|
active: nextActive.map((d) => ({ id: d.id, decision: d.decision, scope: d.scope })),
|
|
286
346
|
},
|
|
287
|
-
};
|
|
347
|
+
});
|
|
288
348
|
}
|
|
289
349
|
nextActive = [...nextActive, entry];
|
|
290
350
|
}
|
|
@@ -294,6 +354,8 @@ function recordInput(input, opts = {}) {
|
|
|
294
354
|
(0, store_1.writeActive)(paths, nextActive, cap);
|
|
295
355
|
if (entry.candidate)
|
|
296
356
|
(0, candidate_1.refreshCandidates)(paths);
|
|
357
|
+
if (request)
|
|
358
|
+
(0, request_1.markApplied)(paths, request, entry.id);
|
|
297
359
|
}
|
|
298
360
|
// A new mechanical rule reaches backwards: say how much existing code it touches.
|
|
299
361
|
let sweepSummary;
|
|
@@ -316,10 +378,17 @@ function recordInput(input, opts = {}) {
|
|
|
316
378
|
candidate: entry.candidate,
|
|
317
379
|
active: `${nextActive.length} of ${cap}`,
|
|
318
380
|
wrote: opts.dryRun ? [] : entry.verdict === 'rule' || entry.verdict === 'retire' ? ['.arbiter/archive.md', 'DECISIONS.md'] : ['.arbiter/archive.md'],
|
|
381
|
+
...(request && { request: { id: request.id, status: opts.dryRun ? request.status : 'applied', author: request.author } }),
|
|
319
382
|
...(sweepSummary && { sweep: sweepSummary }),
|
|
383
|
+
...picture(paths, entry),
|
|
320
384
|
},
|
|
321
385
|
};
|
|
322
386
|
}
|
|
387
|
+
/** The agent is still there with the app running: the moment to say a screen has no picture. */
|
|
388
|
+
function picture(paths, entry) {
|
|
389
|
+
const [m] = (0, pictures_1.missingPictures)(paths, [entry]);
|
|
390
|
+
return m ? { picture: (0, pictures_1.pictureHint)(m, (0, store_1.readConfig)(paths)?.app?.url) } : {};
|
|
391
|
+
}
|
|
323
392
|
/**
|
|
324
393
|
* Check a decision's claim against its files. Sets `verified`; returns a
|
|
325
394
|
* failing result if contradicted and the caller didn't say --unverified.
|
|
@@ -344,12 +413,9 @@ function check(entry, root, opts) {
|
|
|
344
413
|
}
|
|
345
414
|
/** Fill the fields the caller doesn't supply. Id is set by the caller. */
|
|
346
415
|
function fill(input, opts, root) {
|
|
347
|
-
const config = (0, store_1.readConfig)((0, store_1.resolvePaths)(root));
|
|
348
416
|
return {
|
|
349
417
|
date: input.date ?? (0, store_1.now)(),
|
|
350
|
-
|
|
351
|
-
// whoever ran init — it's the fallback for a machine with no git identity, not the default.
|
|
352
|
-
author: opts.author ?? input.author ?? (0, store_1.gitUserName)(root) ?? config?.author ?? node_os_1.default.userInfo().username,
|
|
418
|
+
author: opts.author ?? input.author ?? (0, store_1.currentAuthor)(root),
|
|
353
419
|
class: input.class,
|
|
354
420
|
dimension: input.dimension,
|
|
355
421
|
decision: input.decision,
|
package/dist/commands/remove.js
CHANGED
|
@@ -31,6 +31,7 @@ const store_1 = require("../store");
|
|
|
31
31
|
const candidates_1 = require("../candidates");
|
|
32
32
|
const destination_1 = require("../destination");
|
|
33
33
|
const work_1 = require("../work");
|
|
34
|
+
const requests_1 = require("../requests");
|
|
34
35
|
const fail = (errors) => ({ exitCode: 1, output: { status: 'invalid', errors } });
|
|
35
36
|
// ── remove ─────────────────────────────────────────────────────────────────
|
|
36
37
|
function remove(id, opts = {}) {
|
|
@@ -61,12 +62,22 @@ function removeDecision(id, opts) {
|
|
|
61
62
|
if (later) {
|
|
62
63
|
return fail([`${later.id} supersedes ${id} — removing it would leave ${later.id} pointing at nothing. Remove ${later.id} first if neither is real.`]);
|
|
63
64
|
}
|
|
65
|
+
// Read before anything is written: a broken requests.json must stop the removal, not interrupt it.
|
|
66
|
+
// A request still waiting that was asked about this decision would outlive it, and then read as
|
|
67
|
+
// if it were about whatever takes the id next.
|
|
68
|
+
const about = (0, requests_1.readRequests)(paths).filter((r) => r.decision === id && (r.status === 'open' || r.status === 'approved'));
|
|
69
|
+
if (about.length)
|
|
70
|
+
return fail([`${about.map((r) => `${r.id} (${r.author})`).join(', ')} ${about.length === 1 ? 'was' : 'were'} asked about ${id} and ${about.length === 1 ? 'is' : 'are'} still waiting. The owner answers first; if ${id} is going, that's a reason they can decline with.`]);
|
|
64
71
|
(0, store_1.writeArchive)(paths, archive.filter((d) => d.id !== id));
|
|
65
72
|
if (isActive) {
|
|
66
73
|
const config = (0, store_1.readConfig)(paths);
|
|
67
74
|
(0, store_1.writeActive)(paths, active.filter((d) => d.id !== id), config?.activeCap ?? store_1.ACTIVE_CAP);
|
|
68
75
|
}
|
|
69
76
|
const touched = refreshLinked(paths, entry.candidate);
|
|
77
|
+
// A request this decision applied isn't applied by nothing: with no record left doing it, it's
|
|
78
|
+
// open again, for the owner to answer afresh.
|
|
79
|
+
const detached = (0, requests_1.detachDecision)(paths, id);
|
|
80
|
+
const reopened = detached.filter((r) => r.status === 'open').map((r) => r.id);
|
|
70
81
|
// Removing a rule doesn't bring back the one it replaced: that one may have been real, and
|
|
71
82
|
// guessing would put a rule back the user never re-confirmed. Say so rather than lose it quietly.
|
|
72
83
|
const replaced = entry.supersedes && archive.find((d) => d.id === entry.supersedes);
|
|
@@ -80,8 +91,9 @@ function removeDecision(id, opts) {
|
|
|
80
91
|
id,
|
|
81
92
|
decision: entry.decision,
|
|
82
93
|
...(replaced ? { note: `${replaced.id} — which ${id} replaced — is still inactive. Record it again if it should apply.` } : {}),
|
|
94
|
+
...(reopened.length ? { requests: `${reopened.join(', ')} ${reopened.length === 1 ? 'is' : 'are'} open again — nothing on record makes ${reopened.length === 1 ? 'that change' : 'those changes'} now, so ${reopened.length === 1 ? 'it needs' : 'they need'} a fresh answer` } : {}),
|
|
83
95
|
...(reused ? { idReuse: `${id} was the newest, so the next decision recorded will take that id again. If this board is published, comments on the old ${id} will read as if they were about the new one — republish after recording.` } : {}),
|
|
84
|
-
wrote: ['.arbiter/archive.md', ...(isActive ? ['DECISIONS.md'] : []), ...touched],
|
|
96
|
+
wrote: ['.arbiter/archive.md', ...(isActive ? ['DECISIONS.md'] : []), ...touched, ...(detached.length ? ['.arbiter/requests.json'] : [])],
|
|
85
97
|
// Printed in full so it can be put back by hand — not everyone has git.
|
|
86
98
|
removed: (0, format_1.formatEntry)(entry).trimEnd(),
|
|
87
99
|
},
|
|
@@ -97,6 +109,10 @@ function removeCandidate(id, opts) {
|
|
|
97
109
|
const by = all.find((x) => x.supersededBy === id);
|
|
98
110
|
if (by)
|
|
99
111
|
return fail([`${by.id} says it was superseded by ${id} — clear that first: npx arbiter candidate ${by.id} --state generated`]);
|
|
112
|
+
// A request still waiting on this screen would outlive it — and point at whatever takes its id next.
|
|
113
|
+
const asked = (0, requests_1.readRequests)(paths).filter((r) => r.screen === id && (r.status === 'open' || r.status === 'approved'));
|
|
114
|
+
if (asked.length)
|
|
115
|
+
return fail([`${asked.map((r) => `${r.id} (${r.author})`).join(', ')} ${asked.length === 1 ? 'was' : 'were'} asked on ${id} and ${asked.length === 1 ? 'is' : 'are'} still waiting. The owner answers first; if the screen is going, that's a reason they can decline with.`]);
|
|
100
116
|
const archive = (0, store_1.readArchive)(paths);
|
|
101
117
|
const pending = (0, store_1.readPending)(paths);
|
|
102
118
|
const linked = [...archive, ...pending].filter((d) => d.candidate === id);
|