arbiterdesign 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +143 -0
- package/dist/candidates.js +155 -0
- package/dist/commands/board.js +41 -0
- package/dist/commands/candidate.js +168 -0
- package/dist/commands/drift.js +67 -0
- package/dist/commands/export.js +160 -0
- package/dist/commands/init.js +194 -0
- package/dist/commands/prompt.js +69 -0
- package/dist/commands/publish.js +139 -0
- package/dist/commands/pull.js +27 -0
- package/dist/commands/record.js +408 -0
- package/dist/commands/review.js +135 -0
- package/dist/commands/rules.js +152 -0
- package/dist/commands/snapshot.js +32 -0
- package/dist/commands/sweep.js +87 -0
- package/dist/commands/verify.js +41 -0
- package/dist/destination.js +99 -0
- package/dist/findings.js +70 -0
- package/dist/format.js +247 -0
- package/dist/hosted.js +222 -0
- package/dist/index.js +232 -0
- package/dist/overlap.js +71 -0
- package/dist/schema.js +233 -0
- package/dist/store.js +133 -0
- package/dist/sweep.js +128 -0
- package/dist/test/hosted.test.js +189 -0
- package/dist/test/init.test.js +54 -0
- package/dist/test/pending.test.js +198 -0
- package/dist/test/polish.test.js +130 -0
- package/dist/test/record.test.js +102 -0
- package/dist/test/stages.test.js +188 -0
- package/dist/verify.js +78 -0
- package/dist/work.js +64 -0
- package/package.json +44 -0
- package/templates/SKILL.md +338 -0
- package/templates/review.html +479 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Edmond Hua
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Arbiter
|
|
2
|
+
|
|
3
|
+
A decision layer for AI-generated UI. Records the design calls made during agent-assisted UI work — what was chosen, what was rejected, and why — and feeds them back into the agent's context so the same call never has to be made twice.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx arbiterdesign init
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
That's the whole install. It writes:
|
|
10
|
+
|
|
11
|
+
| File | What it is |
|
|
12
|
+
|---|---|
|
|
13
|
+
| `DECISIONS.md` | Active rules, grouped by dimension. Capped at 40. The agent reads this before UI work. |
|
|
14
|
+
| `.arbiter/archive.md` | Every decision ever, append-only. Never loaded into the agent. |
|
|
15
|
+
| `.arbiter/pending.md` | Decisions the agent queued that you haven't judged yet. |
|
|
16
|
+
| `.arbiter/candidates/` | One page per generated screen or direction, with its state, snapshot, decisions, and why it lost. |
|
|
17
|
+
| `CANDIDATES.md` | Index of candidates — written only when `destination` is `git`. |
|
|
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"`. |
|
|
20
|
+
| `AGENTS.md` | One line appended, pointing at `DECISIONS.md`. Merged, never overwritten. |
|
|
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
|
+
|
|
23
|
+
Running `init` twice changes nothing.
|
|
24
|
+
|
|
25
|
+
## How it works
|
|
26
|
+
|
|
27
|
+
1. You ask the agent to build a screen. It reads `DECISIONS.md` first.
|
|
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**.
|
|
31
|
+
5. Rules enter `DECISIONS.md`. Everything judged enters the archive. Skips vanish.
|
|
32
|
+
|
|
33
|
+
You can also just say it: *"make that a rule"*, *"reject the tabs, going with a single page"*. It records without asking.
|
|
34
|
+
|
|
35
|
+
Nothing enforces anything. Rules inform generation; they don't gate it.
|
|
36
|
+
|
|
37
|
+
## Commands
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
arbiter init install into this project [--destination git]
|
|
41
|
+
arbiter snapshot "<work>" --file x.png a picture for a piece of work (or --capture on macOS); publish carries it
|
|
42
|
+
arbiter record walk through a decision at the terminal
|
|
43
|
+
arbiter record '<json>' record now (what the agent calls)
|
|
44
|
+
arbiter record --pending '<json>' queue for later
|
|
45
|
+
arbiter record P-0003 --as rule judge a queued one: accept | rule | skip | fix --to "…"
|
|
46
|
+
arbiter record --all --as accept judge every queued item [--level polish] [--trigger "Settings build"]
|
|
47
|
+
arbiter record --findings f.json queue a scanner's findings for verdicts
|
|
48
|
+
arbiter record --retire D-0003 --why "…" drop a rule with no replacement
|
|
49
|
+
arbiter review judge the queue in a browser page
|
|
50
|
+
arbiter verify [id] re-check a decision's claim against its files
|
|
51
|
+
arbiter sweep D-0004 [--queue] find existing violations of a mechanical rule
|
|
52
|
+
arbiter candidate add "<name>" track a generated direction [--feature f] [--snapshot img | --capture]
|
|
53
|
+
arbiter candidate C-0002 --state … generated | in_review | approved | rejected | superseded
|
|
54
|
+
arbiter board candidates and their states
|
|
55
|
+
arbiter export static folder of the board for people without the repo [--feature f] [--include-rules] [--open]
|
|
56
|
+
arbiter publish board online via GitHub Pages: git destination + export + commit + push
|
|
57
|
+
arbiter publish --to <url> board online on a hosted Arbiter (hosted/), with comments; prints the share link
|
|
58
|
+
arbiter pull bring comments and "looks good" reactions down into .arbiter/comments.json
|
|
59
|
+
arbiter drift deviations per screen: accepts, unverified claims, rules broken
|
|
60
|
+
arbiter rules active rules [--dimension <name>] [--json]
|
|
61
|
+
arbiter rules --pending the queue
|
|
62
|
+
arbiter rules --archive everything ever
|
|
63
|
+
arbiter rules D-0003 one decision in full
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`record` exit codes: `0` recorded · `1` invalid · `2` overlap — re-run with `--supersedes <id>` or `--keep-both` · `3` cap reached · `4` contradicted — the named files don't match the claim.
|
|
67
|
+
|
|
68
|
+
## Verification
|
|
69
|
+
|
|
70
|
+
A mechanical decision can name `files` and an `expect` — literal strings that must be `present` in / `absent` from them (write `regex:<pattern>` for a pattern, e.g. `regex:#[0-9a-fA-F]{6}\b` for any hex colour). Arbiter reads only those files, never the repo. A claim that doesn't hold is refused. `accept` verdicts are never checked: an exception is a deviation by definition.
|
|
71
|
+
|
|
72
|
+
## Sweep
|
|
73
|
+
|
|
74
|
+
Recording a mechanical rule with `expect.absent` reports how much existing code breaks it. `arbiter sweep <id>` lists the lines; `--queue` turns each file into a pending item to confirm as an exception or fix. Read-only — fixes are the agent's job. Judgment rules can't sweep.
|
|
75
|
+
|
|
76
|
+
The scan set is the rule's `paths` (directories or files) if it names any, else its `file:` scope, else the whole project. Keep token definitions and reference HTML out with `arbiter.json`:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{ "sweep": { "exclude": ["app/globals.css", "design-reference/**", "docs/**"] },
|
|
80
|
+
"overlap": { "ignore": ["audit", "journey"] } }
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`overlap.ignore` lists project words too common to signal that two rules overlap.
|
|
84
|
+
|
|
85
|
+
## Review page
|
|
86
|
+
|
|
87
|
+
`arbiter review` opens a local page with two tabs. **Decisions** — the queue, grouped by dimension, each card showing the screen it was made for. Confirm / Make it a rule / Skip / Fix; overlaps and contradictions surface inline. **Candidates** — every direction with its snapshot; Approve (with why — kept on the ones it replaces), Reject, In review. Both write the same files as the CLI.
|
|
88
|
+
|
|
89
|
+
## Export
|
|
90
|
+
|
|
91
|
+
`arbiter export` writes `arbiter-export/` — one `index.html` plus snapshots, no server, no JS. Open it locally or drop the folder on any static host and send the link. It's the stakeholder view only: each screen, its state, who approved, why the others lost, and what was decided in plain words. No verdict controls — feedback comes back through a person. This is the cheap test of whether stakeholders actually look, before anything hosted gets built.
|
|
92
|
+
|
|
93
|
+
## Hosted board
|
|
94
|
+
|
|
95
|
+
`hosted/` is a small Next.js + Supabase app — the same stack as your other projects — that 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 --to https://your-deployment` uploads; `npx arbiter pull` brings comments back, where `arbiter review` shows them beside each screen. Deploy steps in [hosted/README.md](hosted/README.md). Only `publish` and `pull` ever touch the network.
|
|
96
|
+
|
|
97
|
+
## Candidates
|
|
98
|
+
|
|
99
|
+
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.
|
|
100
|
+
|
|
101
|
+
With `destination: "git"` in `arbiter.json`, every candidate change commits its page, a `CANDIDATES.md` index, and the export page under `docs/arbiter/` (never pushed). Turn on GitHub Pages for the `docs` folder once, and the board is served at `https://<owner>.github.io/<repo>/arbiter/` — always current, no login, no server. `board` prints the URL. Set `"pages": false` to skip, or `"pages": { "dir": "…", "includeRules": true }` to change it.
|
|
102
|
+
|
|
103
|
+
## The record
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
id D-0001, sequential
|
|
107
|
+
date ISO 8601
|
|
108
|
+
author who decided
|
|
109
|
+
class mechanical | judgment
|
|
110
|
+
level feature | pattern | polish — how big a call; polish is never reviewed individually
|
|
111
|
+
dimension structure | interaction | states | content | visual | motion | access
|
|
112
|
+
change what happened, as a PM would say it — what the reviewer reads
|
|
113
|
+
decision the same call as a rule someone could follow — what future sessions read
|
|
114
|
+
rejected alternatives that lost, "<option> — <why>", one line each
|
|
115
|
+
trigger the piece of work ("Settings build") — the grouping key for review
|
|
116
|
+
verdict fix | accept | rule
|
|
117
|
+
scope global | file:<path> | pattern:<name>
|
|
118
|
+
rationale one line, required
|
|
119
|
+
supersedes id | null
|
|
120
|
+
commit short SHA | null
|
|
121
|
+
files files the agent touched — evidence for verification
|
|
122
|
+
paths where a rule applies (directories or files) — what sweep scans
|
|
123
|
+
expect { present?: [..], absent?: [..] } — strings to check in files
|
|
124
|
+
verified true | false | null (never checked / not checkable)
|
|
125
|
+
candidate C-0001 | null
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Only `rule` verdicts enter `DECISIONS.md`. A `rule` whose scope overlaps an active rule is refused until you say whether it replaces the old one; superseded rules leave the active file and stay in the archive.
|
|
129
|
+
|
|
130
|
+
## Kill conditions
|
|
131
|
+
|
|
132
|
+
Fixed before Stage 0 started, per the roadmap. Do not move.
|
|
133
|
+
|
|
134
|
+
- **Stage 0** — if only mechanical verdicts get recorded after three weeks of use, the judgment layer isn't real.
|
|
135
|
+
- **Stage 4 (candidates / board)** — build only if **5 or more** generated screens are in flight at once. If that never happens, cut it.
|
|
136
|
+
|
|
137
|
+
## Development
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
npm install
|
|
141
|
+
npm run build
|
|
142
|
+
npm test
|
|
143
|
+
```
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Candidates: one generated screen or direction, with a state.
|
|
4
|
+
*
|
|
5
|
+
* generated → in_review → approved | rejected | superseded
|
|
6
|
+
*
|
|
7
|
+
* One markdown file each in .arbiter/candidates/, snapshot image beside it.
|
|
8
|
+
* Decisions link to a candidate from their side (`candidate: C-0001`); the
|
|
9
|
+
* list in the candidate file is regenerated on every write, so it's a view,
|
|
10
|
+
* not a second source of truth. GitHub renders these files as-is — that's
|
|
11
|
+
* the whole git destination.
|
|
12
|
+
*/
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.STATES = void 0;
|
|
18
|
+
exports.candidatesDir = candidatesDir;
|
|
19
|
+
exports.candidateFile = candidateFile;
|
|
20
|
+
exports.readCandidates = readCandidates;
|
|
21
|
+
exports.nextCandidateId = nextCandidateId;
|
|
22
|
+
exports.decisionsFor = decisionsFor;
|
|
23
|
+
exports.writeCandidate = writeCandidate;
|
|
24
|
+
exports.formatCandidate = formatCandidate;
|
|
25
|
+
exports.parseCandidate = parseCandidate;
|
|
26
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
27
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
28
|
+
const store_1 = require("./store");
|
|
29
|
+
exports.STATES = ['generated', 'in_review', 'approved', 'rejected', 'superseded'];
|
|
30
|
+
const SEP = ' · ';
|
|
31
|
+
const NONE = '—';
|
|
32
|
+
function candidatesDir(paths) {
|
|
33
|
+
return node_path_1.default.join(paths.archiveDir, 'candidates');
|
|
34
|
+
}
|
|
35
|
+
function candidateFile(paths, id) {
|
|
36
|
+
return node_path_1.default.join(candidatesDir(paths), `${id}.md`);
|
|
37
|
+
}
|
|
38
|
+
function readCandidates(paths) {
|
|
39
|
+
const dir = candidatesDir(paths);
|
|
40
|
+
if (!node_fs_1.default.existsSync(dir))
|
|
41
|
+
return [];
|
|
42
|
+
return node_fs_1.default
|
|
43
|
+
.readdirSync(dir)
|
|
44
|
+
.filter((f) => /^C-\d{4,}\.md$/.test(f))
|
|
45
|
+
.sort()
|
|
46
|
+
.map((f) => parseCandidate(node_fs_1.default.readFileSync(node_path_1.default.join(dir, f), 'utf8')));
|
|
47
|
+
}
|
|
48
|
+
function nextCandidateId(all) {
|
|
49
|
+
const max = all.reduce((m, c) => Math.max(m, Number(c.id.slice(2))), 0);
|
|
50
|
+
return `C-${String(max + 1).padStart(4, '0')}`;
|
|
51
|
+
}
|
|
52
|
+
/** Decisions made for this candidate, judged or pending. */
|
|
53
|
+
function decisionsFor(paths, id) {
|
|
54
|
+
return [...(0, store_1.readArchive)(paths), ...(0, store_1.readPending)(paths)].filter((d) => d.candidate === id);
|
|
55
|
+
}
|
|
56
|
+
function writeCandidate(paths, c) {
|
|
57
|
+
node_fs_1.default.mkdirSync(candidatesDir(paths), { recursive: true });
|
|
58
|
+
node_fs_1.default.writeFileSync(candidateFile(paths, c.id), formatCandidate(c, decisionsFor(paths, c.id)));
|
|
59
|
+
}
|
|
60
|
+
function formatCandidate(c, decisions) {
|
|
61
|
+
const lines = [
|
|
62
|
+
`# ${c.id}${SEP}${c.name}`,
|
|
63
|
+
'',
|
|
64
|
+
...(c.snapshot ? [``, ''] : []),
|
|
65
|
+
`- **Feature:** ${c.feature ?? NONE}`,
|
|
66
|
+
`- **State:** ${c.state}`,
|
|
67
|
+
`- **Author:** ${c.author}${SEP}**Date:** ${c.date}${SEP}**Commit:** ${c.commit ?? NONE}`,
|
|
68
|
+
`- **Superseded by:** ${c.supersededBy ?? NONE}${SEP}**Reason:** ${c.reason ?? NONE}`,
|
|
69
|
+
'',
|
|
70
|
+
'## Decisions',
|
|
71
|
+
'',
|
|
72
|
+
];
|
|
73
|
+
if (!decisions.length)
|
|
74
|
+
lines.push('_None linked yet._');
|
|
75
|
+
for (const d of decisions) {
|
|
76
|
+
const tag = d.verdict === 'pending' ? 'pending' : d.verdict;
|
|
77
|
+
lines.push(`- **${d.id}** · ${d.decision} _(${tag}${d.rejected.length ? `, over: ${d.rejected.map((r) => r.split(' — ')[0]).join(', ')}` : ''})_`);
|
|
78
|
+
}
|
|
79
|
+
lines.push('', '## Notes', '', c.notes || '_None._', '');
|
|
80
|
+
return lines.join('\n');
|
|
81
|
+
}
|
|
82
|
+
const HEADING = /^# (C-\d{4,}) · (.*)$/;
|
|
83
|
+
const IMG = /^!\[.*?\]\((.+?)\)$/;
|
|
84
|
+
const FIELD = /\*\*([A-Za-z ]+):\*\* (.*?)(?=\s·\s\*\*|$)/g;
|
|
85
|
+
function parseCandidate(md) {
|
|
86
|
+
const lines = md.split('\n');
|
|
87
|
+
const c = { snapshot: null, feature: null, supersededBy: null, reason: null, notes: '', commit: null };
|
|
88
|
+
let section = 'head';
|
|
89
|
+
const notes = [];
|
|
90
|
+
for (const raw of lines) {
|
|
91
|
+
const line = raw.replace(/\r$/, '');
|
|
92
|
+
const h = HEADING.exec(line);
|
|
93
|
+
if (h) {
|
|
94
|
+
c.id = h[1];
|
|
95
|
+
c.name = h[2].trim();
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (line === '## Decisions') {
|
|
99
|
+
section = 'decisions';
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (line === '## Notes') {
|
|
103
|
+
section = 'notes';
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (section === 'notes') {
|
|
107
|
+
notes.push(line);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (section !== 'head')
|
|
111
|
+
continue;
|
|
112
|
+
const img = IMG.exec(line);
|
|
113
|
+
if (img) {
|
|
114
|
+
c.snapshot = img[1];
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (!line.startsWith('- **'))
|
|
118
|
+
continue;
|
|
119
|
+
for (const m of line.slice(2).matchAll(FIELD)) {
|
|
120
|
+
const key = m[1].toLowerCase();
|
|
121
|
+
const val = m[2].trim();
|
|
122
|
+
const v = val === NONE ? null : val;
|
|
123
|
+
switch (key) {
|
|
124
|
+
case 'feature':
|
|
125
|
+
c.feature = v;
|
|
126
|
+
break;
|
|
127
|
+
case 'state':
|
|
128
|
+
c.state = val;
|
|
129
|
+
break;
|
|
130
|
+
case 'author':
|
|
131
|
+
c.author = val;
|
|
132
|
+
break;
|
|
133
|
+
case 'date':
|
|
134
|
+
c.date = val;
|
|
135
|
+
break;
|
|
136
|
+
case 'commit':
|
|
137
|
+
c.commit = v;
|
|
138
|
+
break;
|
|
139
|
+
case 'superseded by':
|
|
140
|
+
c.supersededBy = v;
|
|
141
|
+
break;
|
|
142
|
+
case 'reason':
|
|
143
|
+
c.reason = v;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const notesText = notes.join('\n').trim();
|
|
149
|
+
c.notes = notesText === '_None._' ? '' : notesText;
|
|
150
|
+
for (const k of ['id', 'name', 'state', 'author', 'date']) {
|
|
151
|
+
if (c[k] === undefined)
|
|
152
|
+
throw new Error(`candidate ${c.id ?? '?'} is missing: ${k}`);
|
|
153
|
+
}
|
|
154
|
+
return c;
|
|
155
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** `arbiter board` — candidates and their states. Read only. */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.board = board;
|
|
5
|
+
const candidates_1 = require("../candidates");
|
|
6
|
+
const store_1 = require("../store");
|
|
7
|
+
const destination_1 = require("../destination");
|
|
8
|
+
function board(opts = {}) {
|
|
9
|
+
const root = (0, store_1.findRoot)(opts.cwd);
|
|
10
|
+
const paths = (0, store_1.resolvePaths)(root);
|
|
11
|
+
const config = (0, store_1.readConfig)(paths);
|
|
12
|
+
let all = (0, candidates_1.readCandidates)(paths);
|
|
13
|
+
if (opts.feature)
|
|
14
|
+
all = all.filter((c) => c.feature === opts.feature);
|
|
15
|
+
const withDecisions = all.map((c) => ({ ...c, decisions: (0, candidates_1.decisionsFor)(paths, c.id).map((d) => d.id), link: (0, destination_1.linkFor)(root, config, c.id) }));
|
|
16
|
+
if (opts.json)
|
|
17
|
+
return JSON.stringify({ count: all.length, candidates: withDecisions }, null, 2);
|
|
18
|
+
if (!all.length)
|
|
19
|
+
return opts.feature ? `No candidates for ${opts.feature}.` : 'No candidates yet. Add one with `npx arbiter candidate add "<name>" --feature <feature>`.';
|
|
20
|
+
const counts = new Map();
|
|
21
|
+
for (const c of all)
|
|
22
|
+
counts.set(c.state, (counts.get(c.state) ?? 0) + 1);
|
|
23
|
+
const lines = [`${all.length} candidate${all.length === 1 ? '' : 's'} · ${[...counts].map(([s, n]) => `${n} ${s.replace('_', ' ')}`).join(' · ')}`];
|
|
24
|
+
const pages = (0, destination_1.pagesUrl)(root, config);
|
|
25
|
+
if (pages)
|
|
26
|
+
lines.push(`Board page: ${pages} (GitHub Pages → docs/, once pushed)`);
|
|
27
|
+
const features = [...new Set(all.map((c) => c.feature ?? '—'))];
|
|
28
|
+
const w = Math.max(...all.map((c) => c.name.length));
|
|
29
|
+
for (const f of features) {
|
|
30
|
+
lines.push('', f);
|
|
31
|
+
for (const c of withDecisions.filter((c) => (c.feature ?? '—') === f)) {
|
|
32
|
+
const state = c.state === 'superseded' ? `superseded → ${c.supersededBy}` : c.state.replace('_', ' ');
|
|
33
|
+
lines.push(` ${c.id} ${c.name.padEnd(w)} ${state.padEnd(22)} ${c.author} ${c.date.slice(0, 10)}${c.decisions.length ? ` ${c.decisions.join(', ')}` : ''}`);
|
|
34
|
+
if (c.reason)
|
|
35
|
+
lines.push(`${' '.repeat(w + 12)}"${c.reason}"`);
|
|
36
|
+
if (c.link && config?.destination === 'git')
|
|
37
|
+
lines.push(`${' '.repeat(w + 12)}${c.link}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return lines.join('\n');
|
|
41
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `arbiter candidate` — the act verb for generated screens.
|
|
4
|
+
*
|
|
5
|
+
* candidate add "<name>" [--feature f] [--snapshot img] [--notes text]
|
|
6
|
+
* candidate C-0002 --state approved [--why "…"] [--keep-others]
|
|
7
|
+
* candidate C-0002 --state rejected --why "…"
|
|
8
|
+
* candidate C-0002 --snapshot new.png
|
|
9
|
+
*
|
|
10
|
+
* Approving one direction supersedes its siblings (same feature, still open)
|
|
11
|
+
* with the reason retained — the rejected branches are the point.
|
|
12
|
+
*/
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.addCandidate = addCandidate;
|
|
18
|
+
exports.updateCandidate = updateCandidate;
|
|
19
|
+
exports.refreshCandidates = refreshCandidates;
|
|
20
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
21
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
22
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
23
|
+
const node_child_process_1 = require("node:child_process");
|
|
24
|
+
const candidates_1 = require("../candidates");
|
|
25
|
+
const store_1 = require("../store");
|
|
26
|
+
const destination_1 = require("../destination");
|
|
27
|
+
function addCandidate(name, opts = {}) {
|
|
28
|
+
if (!name?.trim())
|
|
29
|
+
return fail(['a name is required']);
|
|
30
|
+
const root = (0, store_1.findRoot)(opts.cwd);
|
|
31
|
+
const paths = (0, store_1.resolvePaths)(root);
|
|
32
|
+
const config = (0, store_1.readConfig)(paths);
|
|
33
|
+
const all = (0, candidates_1.readCandidates)(paths);
|
|
34
|
+
const c = {
|
|
35
|
+
id: (0, candidates_1.nextCandidateId)(all),
|
|
36
|
+
name: name.trim(),
|
|
37
|
+
feature: opts.feature?.trim() || null,
|
|
38
|
+
state: 'generated',
|
|
39
|
+
snapshot: null,
|
|
40
|
+
author: opts.author ?? config?.author ?? (0, store_1.gitUserName)(root) ?? node_os_1.default.userInfo().username,
|
|
41
|
+
date: (0, store_1.now)(),
|
|
42
|
+
commit: (0, store_1.currentCommit)(root),
|
|
43
|
+
supersededBy: null,
|
|
44
|
+
reason: null,
|
|
45
|
+
notes: opts.notes?.trim() ?? '',
|
|
46
|
+
};
|
|
47
|
+
if (opts.snapshot) {
|
|
48
|
+
const snap = copySnapshot(paths, c.id, opts.snapshot);
|
|
49
|
+
if (!snap.ok)
|
|
50
|
+
return fail([snap.error]);
|
|
51
|
+
c.snapshot = snap.file;
|
|
52
|
+
}
|
|
53
|
+
if (opts.capture) {
|
|
54
|
+
const cap = captureScreen(paths, c.id);
|
|
55
|
+
if (!cap.ok)
|
|
56
|
+
return fail([cap.error]);
|
|
57
|
+
c.snapshot = cap.file;
|
|
58
|
+
}
|
|
59
|
+
(0, candidates_1.writeCandidate)(paths, c);
|
|
60
|
+
const delivered = (0, destination_1.deliver)(paths, config, [c], `add ${c.id} — ${c.name}`);
|
|
61
|
+
return { exitCode: 0, output: { status: 'added', id: c.id, name: c.name, feature: c.feature, state: c.state, snapshot: c.snapshot, file: rel(root, paths, c.id), ...delivered } };
|
|
62
|
+
}
|
|
63
|
+
function updateCandidate(id, opts = {}) {
|
|
64
|
+
const root = (0, store_1.findRoot)(opts.cwd);
|
|
65
|
+
const paths = (0, store_1.resolvePaths)(root);
|
|
66
|
+
const config = (0, store_1.readConfig)(paths);
|
|
67
|
+
const all = (0, candidates_1.readCandidates)(paths);
|
|
68
|
+
const c = all.find((x) => x.id === id);
|
|
69
|
+
if (!c)
|
|
70
|
+
return fail([`${id} not found`]);
|
|
71
|
+
const changed = [];
|
|
72
|
+
const superseded = [];
|
|
73
|
+
if (opts.state) {
|
|
74
|
+
if (!candidates_1.STATES.includes(opts.state))
|
|
75
|
+
return fail([`state must be one of ${candidates_1.STATES.join(' | ')}`]);
|
|
76
|
+
const state = opts.state;
|
|
77
|
+
if (state === 'superseded' && !opts.by)
|
|
78
|
+
return fail(['superseded needs --by <candidate id>']);
|
|
79
|
+
if (opts.by && !all.some((x) => x.id === opts.by))
|
|
80
|
+
return fail([`${opts.by} not found`]);
|
|
81
|
+
c.state = state;
|
|
82
|
+
c.supersededBy = state === 'superseded' ? opts.by : null;
|
|
83
|
+
if (opts.why !== undefined)
|
|
84
|
+
c.reason = opts.why.trim() || null;
|
|
85
|
+
if (state === 'approved' && !opts.keepOthers && c.feature) {
|
|
86
|
+
for (const sib of all) {
|
|
87
|
+
if (sib.id === c.id || sib.feature !== c.feature)
|
|
88
|
+
continue;
|
|
89
|
+
if (sib.state !== 'generated' && sib.state !== 'in_review')
|
|
90
|
+
continue;
|
|
91
|
+
sib.state = 'superseded';
|
|
92
|
+
sib.supersededBy = c.id;
|
|
93
|
+
sib.reason = sib.reason ?? (opts.why?.trim() || `${c.id} approved`);
|
|
94
|
+
changed.push(sib);
|
|
95
|
+
superseded.push(sib.id);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else if (opts.why !== undefined) {
|
|
100
|
+
c.reason = opts.why.trim() || null;
|
|
101
|
+
}
|
|
102
|
+
if (opts.snapshot) {
|
|
103
|
+
const snap = copySnapshot(paths, c.id, opts.snapshot);
|
|
104
|
+
if (!snap.ok)
|
|
105
|
+
return fail([snap.error]);
|
|
106
|
+
c.snapshot = snap.file;
|
|
107
|
+
}
|
|
108
|
+
if (opts.capture) {
|
|
109
|
+
const cap = captureScreen(paths, c.id);
|
|
110
|
+
if (!cap.ok)
|
|
111
|
+
return fail([cap.error]);
|
|
112
|
+
c.snapshot = cap.file;
|
|
113
|
+
}
|
|
114
|
+
if (opts.notes !== undefined)
|
|
115
|
+
c.notes = opts.notes.trim();
|
|
116
|
+
if (opts.feature !== undefined)
|
|
117
|
+
c.feature = opts.feature.trim() || null;
|
|
118
|
+
changed.unshift(c);
|
|
119
|
+
for (const x of changed)
|
|
120
|
+
(0, candidates_1.writeCandidate)(paths, x);
|
|
121
|
+
const delivered = (0, destination_1.deliver)(paths, config, changed, `${c.id} ${c.state} — ${c.name}`);
|
|
122
|
+
return {
|
|
123
|
+
exitCode: 0,
|
|
124
|
+
output: { status: 'updated', id: c.id, name: c.name, state: c.state, ...(superseded.length && { superseded }), file: rel(root, paths, c.id), ...delivered },
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/** Refresh every candidate file (decision lists are a view; call after decisions change). */
|
|
128
|
+
function refreshCandidates(paths) {
|
|
129
|
+
for (const c of (0, candidates_1.readCandidates)(paths))
|
|
130
|
+
(0, candidates_1.writeCandidate)(paths, c);
|
|
131
|
+
}
|
|
132
|
+
function copySnapshot(paths, id, src) {
|
|
133
|
+
const abs = node_path_1.default.resolve(paths.root, src);
|
|
134
|
+
if (!node_fs_1.default.existsSync(abs))
|
|
135
|
+
return { ok: false, error: `snapshot not found: ${src}` };
|
|
136
|
+
const ext = node_path_1.default.extname(abs).toLowerCase() || '.png';
|
|
137
|
+
if (!['.png', '.jpg', '.jpeg', '.webp', '.gif', '.svg'].includes(ext))
|
|
138
|
+
return { ok: false, error: `snapshot must be an image (png, jpg, webp, gif, svg), got ${ext}` };
|
|
139
|
+
const file = `${id}${ext}`;
|
|
140
|
+
node_fs_1.default.mkdirSync((0, candidates_1.candidatesDir)(paths), { recursive: true });
|
|
141
|
+
node_fs_1.default.copyFileSync(abs, node_path_1.default.join((0, candidates_1.candidatesDir)(paths), file));
|
|
142
|
+
return { ok: true, file };
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Drag-to-select a screen region with macOS's built-in `screencapture -i`.
|
|
146
|
+
* No browser, no dependency. Escape cancels and leaves the candidate as is.
|
|
147
|
+
*/
|
|
148
|
+
function captureScreen(paths, id) {
|
|
149
|
+
if (process.platform !== 'darwin')
|
|
150
|
+
return { ok: false, error: '--capture uses macOS screencapture; on other platforms pass --snapshot <image>' };
|
|
151
|
+
const file = `${id}.png`;
|
|
152
|
+
node_fs_1.default.mkdirSync((0, candidates_1.candidatesDir)(paths), { recursive: true });
|
|
153
|
+
const out = node_path_1.default.join((0, candidates_1.candidatesDir)(paths), file);
|
|
154
|
+
process.stderr.write('Drag to select the region to capture (Esc to cancel)…\n');
|
|
155
|
+
try {
|
|
156
|
+
(0, node_child_process_1.execFileSync)('screencapture', ['-i', '-x', out], { stdio: 'ignore' });
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
return { ok: false, error: 'screencapture failed' };
|
|
160
|
+
}
|
|
161
|
+
if (!node_fs_1.default.existsSync(out) || node_fs_1.default.statSync(out).size === 0)
|
|
162
|
+
return { ok: false, error: 'capture cancelled — no snapshot saved' };
|
|
163
|
+
return { ok: true, file };
|
|
164
|
+
}
|
|
165
|
+
const rel = (root, paths, id) => node_path_1.default.relative(root, node_path_1.default.join((0, candidates_1.candidatesDir)(paths), `${id}.md`));
|
|
166
|
+
function fail(errors) {
|
|
167
|
+
return { exitCode: 1, output: { status: 'invalid', errors } };
|
|
168
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `arbiter drift` — deviations per screen, screen-versus-system.
|
|
4
|
+
*
|
|
5
|
+
* For each candidate: how many exceptions were accepted for it, how many of
|
|
6
|
+
* its claims were unverified, and which active mechanical rules its files
|
|
7
|
+
* currently break. The number a design lead takes to their manager.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.drift = drift;
|
|
11
|
+
const candidates_1 = require("../candidates");
|
|
12
|
+
const store_1 = require("../store");
|
|
13
|
+
const verify_1 = require("../verify");
|
|
14
|
+
function drift(opts = {}) {
|
|
15
|
+
const root = (0, store_1.findRoot)(opts.cwd);
|
|
16
|
+
const paths = (0, store_1.resolvePaths)(root);
|
|
17
|
+
const active = (0, store_1.readActive)(paths);
|
|
18
|
+
const mechanical = active.filter((d) => d.class === 'mechanical' && d.expect?.absent?.length);
|
|
19
|
+
let candidates = (0, candidates_1.readCandidates)(paths);
|
|
20
|
+
if (opts.feature)
|
|
21
|
+
candidates = candidates.filter((c) => c.feature === opts.feature);
|
|
22
|
+
const rows = candidates.map((c) => {
|
|
23
|
+
const ds = (0, candidates_1.decisionsFor)(paths, c.id);
|
|
24
|
+
const files = [...new Set(ds.flatMap((d) => d.files))];
|
|
25
|
+
const broken = mechanical
|
|
26
|
+
.map((rule) => {
|
|
27
|
+
const r = (0, verify_1.verify)(root, files, { absent: rule.expect.absent });
|
|
28
|
+
const where = r.checks.filter((k) => k.kind === 'absent' && !k.ok).map((k) => `${k.file}${k.detail ? ` (${k.detail})` : ''}`);
|
|
29
|
+
return { id: rule.id, decision: rule.decision, where };
|
|
30
|
+
})
|
|
31
|
+
.filter((b) => b.where.length);
|
|
32
|
+
return {
|
|
33
|
+
id: c.id,
|
|
34
|
+
name: c.name,
|
|
35
|
+
feature: c.feature,
|
|
36
|
+
state: c.state,
|
|
37
|
+
accepts: count(ds, 'accept'),
|
|
38
|
+
fixes: count(ds, 'fix'),
|
|
39
|
+
rules: count(ds, 'rule'),
|
|
40
|
+
unverified: ds.filter((d) => d.verified === false).length,
|
|
41
|
+
files: files.length,
|
|
42
|
+
broken,
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
if (opts.json)
|
|
46
|
+
return JSON.stringify({ rulesChecked: mechanical.map((d) => d.id), screens: rows }, null, 2);
|
|
47
|
+
if (!rows.length)
|
|
48
|
+
return 'No candidates to measure. Drift is per screen — register screens with `npx arbiter candidate add`.';
|
|
49
|
+
const totals = rows.reduce((t, r) => ({ accepts: t.accepts + r.accepts, broken: t.broken + r.broken.length }), { accepts: 0, broken: 0 });
|
|
50
|
+
const lines = [`Drift across ${rows.length} screen${rows.length === 1 ? '' : 's'} — ${totals.accepts} accepted exception${totals.accepts === 1 ? '' : 's'} · ${totals.broken} rule break${totals.broken === 1 ? '' : 's'} · ${mechanical.length} mechanical rule${mechanical.length === 1 ? '' : 's'} checked`];
|
|
51
|
+
const w = Math.max(...rows.map((r) => r.name.length));
|
|
52
|
+
const features = [...new Set(rows.map((r) => r.feature ?? '—'))];
|
|
53
|
+
for (const f of features) {
|
|
54
|
+
lines.push('', f);
|
|
55
|
+
for (const r of rows.filter((r) => (r.feature ?? '—') === f)) {
|
|
56
|
+
const bits = [`${r.accepts} accept${r.accepts === 1 ? '' : 's'}`];
|
|
57
|
+
if (r.unverified)
|
|
58
|
+
bits.push(`${r.unverified} unverified`);
|
|
59
|
+
bits.push(r.broken.length ? `${r.broken.length} rule${r.broken.length === 1 ? '' : 's'} broken` : r.files ? 'clean' : 'no files to check');
|
|
60
|
+
lines.push(` ${r.id} ${r.name.padEnd(w)} ${r.state.replace('_', ' ').padEnd(11)} ${bits.join(' · ')}`);
|
|
61
|
+
for (const b of r.broken)
|
|
62
|
+
lines.push(`${' '.repeat(w + 24)}✗ ${b.id} ${b.decision} — ${b.where.join(', ')}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return lines.join('\n');
|
|
66
|
+
}
|
|
67
|
+
const count = (ds, v) => ds.filter((d) => d.verdict === v).length;
|