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
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>Arbiter review</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root {
|
|
9
|
+
color-scheme: light dark;
|
|
10
|
+
--bg: #fafaf9; --card: #fff; --ink: #1c1917; --muted: #78716c; --line: #e7e5e4;
|
|
11
|
+
--accent: #1c1917; --accent-ink: #fff; --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
|
|
12
|
+
--tag: #f5f5f4; --shot: #f5f5f4;
|
|
13
|
+
}
|
|
14
|
+
@media (prefers-color-scheme: dark) {
|
|
15
|
+
:root {
|
|
16
|
+
--bg: #0c0a09; --card: #1c1917; --ink: #fafaf9; --muted: #a8a29e; --line: #292524;
|
|
17
|
+
--accent: #fafaf9; --accent-ink: #0c0a09; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171;
|
|
18
|
+
--tag: #292524; --shot: #0c0a09;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
* { box-sizing: border-box; }
|
|
22
|
+
body {
|
|
23
|
+
margin: 0; background: var(--bg); color: var(--ink);
|
|
24
|
+
font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
|
|
25
|
+
padding: 0 16px 80px;
|
|
26
|
+
}
|
|
27
|
+
header {
|
|
28
|
+
max-width: 800px; margin: 0 auto; padding: 28px 0 8px;
|
|
29
|
+
display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
|
|
30
|
+
}
|
|
31
|
+
header h1 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
|
|
32
|
+
header .project { color: var(--muted); }
|
|
33
|
+
header .count { color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }
|
|
34
|
+
nav { max-width: 800px; margin: 12px auto 0; display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
|
|
35
|
+
nav button {
|
|
36
|
+
border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted);
|
|
37
|
+
padding: 8px 12px; margin-bottom: -1px; font-weight: 500;
|
|
38
|
+
}
|
|
39
|
+
nav button:hover { border-color: var(--line); color: var(--ink); }
|
|
40
|
+
nav button.on { color: var(--ink); border-bottom-color: var(--ink); }
|
|
41
|
+
main { max-width: 800px; margin: 0 auto; }
|
|
42
|
+
h2 {
|
|
43
|
+
font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
|
|
44
|
+
color: var(--muted); margin: 32px 0 10px;
|
|
45
|
+
}
|
|
46
|
+
.card {
|
|
47
|
+
background: var(--card); border: 1px solid var(--line); border-radius: 12px;
|
|
48
|
+
padding: 18px 20px 16px; margin-bottom: 12px;
|
|
49
|
+
}
|
|
50
|
+
.card.done { opacity: 0.55; padding: 12px 20px; }
|
|
51
|
+
.card h3 { font-size: 16px; font-weight: 600; margin: 0 0 8px; letter-spacing: -0.01em; }
|
|
52
|
+
.card .why { margin: 0 0 8px; }
|
|
53
|
+
.lines { margin: 0 0 10px; display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; }
|
|
54
|
+
.lines dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; padding-top: 3px; }
|
|
55
|
+
.lines dd { margin: 0; }
|
|
56
|
+
.lines dd.muted { color: var(--muted); }
|
|
57
|
+
.level { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--tag); color: var(--muted); vertical-align: 2px; margin-left: 8px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
|
|
58
|
+
.level.feature { color: var(--ink); }
|
|
59
|
+
.group { display: flex; align-items: baseline; gap: 10px; margin: 32px 0 10px; }
|
|
60
|
+
.group h2 { margin: 0; text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--ink); }
|
|
61
|
+
.group span { color: var(--muted); font-size: 13px; }
|
|
62
|
+
.polish { background: var(--card); border: 1px dashed var(--line); border-radius: 12px; padding: 12px 20px; margin-bottom: 12px; }
|
|
63
|
+
.polish .row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
|
|
64
|
+
.polish .row .n { color: var(--muted); flex: 1; }
|
|
65
|
+
.polish ul { list-style: none; margin: 10px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); }
|
|
66
|
+
.polish li { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
|
|
67
|
+
.polish li span { flex: 1; }
|
|
68
|
+
.polish li button { padding: 3px 10px; font-size: 13px; }
|
|
69
|
+
.card ul { margin: 0 0 10px; padding: 0; list-style: none; }
|
|
70
|
+
.card ul.rejected li { padding-left: 18px; position: relative; }
|
|
71
|
+
.card ul.rejected li::before { content: "✗"; position: absolute; left: 0; color: var(--muted); }
|
|
72
|
+
.split { display: flex; gap: 18px; align-items: flex-start; }
|
|
73
|
+
.split .body { flex: 1; min-width: 0; }
|
|
74
|
+
.thumb {
|
|
75
|
+
flex: 0 0 180px; max-width: 40%; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
|
|
76
|
+
background: var(--shot); cursor: zoom-in;
|
|
77
|
+
}
|
|
78
|
+
.thumb img { display: block; width: 100%; height: auto; }
|
|
79
|
+
.thumb .cap { font-size: 12px; color: var(--muted); padding: 4px 8px; border-top: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
80
|
+
.meta { color: var(--muted); font-size: 13px; display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
|
|
81
|
+
.meta .tag { background: var(--tag); padding: 1px 8px; border-radius: 4px; cursor: help; }
|
|
82
|
+
.meta a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
|
|
83
|
+
.meta a:hover { color: var(--ink); }
|
|
84
|
+
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
|
|
85
|
+
button {
|
|
86
|
+
font: inherit; font-size: 14px; border-radius: 8px; border: 1px solid var(--line);
|
|
87
|
+
background: var(--card); color: var(--ink); padding: 7px 14px; cursor: pointer;
|
|
88
|
+
}
|
|
89
|
+
button:hover { border-color: var(--ink); }
|
|
90
|
+
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
|
|
91
|
+
button.quiet { color: var(--muted); border-color: transparent; }
|
|
92
|
+
button.quiet:hover { border-color: var(--line); }
|
|
93
|
+
textarea {
|
|
94
|
+
font: inherit; width: 100%; min-height: 64px; border: 1px solid var(--line); border-radius: 8px;
|
|
95
|
+
background: var(--bg); color: var(--ink); padding: 10px 12px; margin: 10px 0; resize: vertical;
|
|
96
|
+
}
|
|
97
|
+
.panel { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
|
|
98
|
+
.panel p { margin: 0 0 10px; }
|
|
99
|
+
.panel .rule { padding: 10px 12px; background: var(--tag); border-radius: 8px; margin-bottom: 10px; }
|
|
100
|
+
.panel .rule b { display: block; }
|
|
101
|
+
.conf { font-size: 12px; padding: 1px 6px; border-radius: 4px; background: var(--tag); color: var(--muted); }
|
|
102
|
+
.conf.exact { color: var(--ok); }
|
|
103
|
+
.conf.possible { color: var(--warn); }
|
|
104
|
+
.result { display: flex; align-items: center; gap: 10px; }
|
|
105
|
+
.result .ok { color: var(--ok); }
|
|
106
|
+
.result .skip { color: var(--muted); }
|
|
107
|
+
.bad { color: var(--bad); }
|
|
108
|
+
.empty { text-align: center; color: var(--muted); padding: 80px 0; }
|
|
109
|
+
.empty h2 { text-transform: none; letter-spacing: 0; font-size: 18px; color: var(--ink); }
|
|
110
|
+
/* candidates */
|
|
111
|
+
.cand { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 18px; }
|
|
112
|
+
@media (max-width: 640px) { .cand { grid-template-columns: 1fr; } .split { flex-direction: column; } .thumb { max-width: 100%; flex-basis: auto; } }
|
|
113
|
+
.cand .shot { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--shot); cursor: zoom-in; min-height: 80px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
|
|
114
|
+
.cand .shot img { display: block; width: 100%; height: auto; }
|
|
115
|
+
.state { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--tag); color: var(--muted); vertical-align: middle; margin-left: 8px; font-weight: 500; }
|
|
116
|
+
.state.approved { color: var(--ok); }
|
|
117
|
+
.state.rejected, .state.superseded { color: var(--bad); }
|
|
118
|
+
.state.in_review { color: var(--warn); }
|
|
119
|
+
.cand .decs { margin: 8px 0 12px; padding: 0; list-style: none; font-size: 14px; }
|
|
120
|
+
.cand .decs li { color: var(--muted); }
|
|
121
|
+
.cand .decs b { color: var(--ink); font-weight: 500; }
|
|
122
|
+
.reason { color: var(--muted); font-style: italic; margin: 0 0 10px; }
|
|
123
|
+
.comments { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; font-size: 14px; }
|
|
124
|
+
.comments .ok { color: var(--ok); }
|
|
125
|
+
.comments p { margin: 4px 0; } .comments b { font-weight: 500; }
|
|
126
|
+
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: none; align-items: center; justify-content: center; cursor: zoom-out; z-index: 10; padding: 24px; }
|
|
127
|
+
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }
|
|
128
|
+
footer {
|
|
129
|
+
position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg);
|
|
130
|
+
border-top: 1px solid var(--line); padding: 12px 16px;
|
|
131
|
+
}
|
|
132
|
+
footer div { max-width: 800px; margin: 0 auto; display: flex; justify-content: flex-end; }
|
|
133
|
+
</style>
|
|
134
|
+
</head>
|
|
135
|
+
<body>
|
|
136
|
+
<header>
|
|
137
|
+
<h1>Arbiter</h1>
|
|
138
|
+
<span class="project" id="project"></span>
|
|
139
|
+
<span class="count" id="count"></span>
|
|
140
|
+
</header>
|
|
141
|
+
<nav id="nav"></nav>
|
|
142
|
+
<main id="main"></main>
|
|
143
|
+
<div id="lightbox" onclick="this.style.display='none'"><img alt=""></div>
|
|
144
|
+
<footer><div><button id="done" class="primary">Done</button></div></footer>
|
|
145
|
+
|
|
146
|
+
<script>
|
|
147
|
+
const DIMS = ['structure','interaction','states','content','visual','motion','access'];
|
|
148
|
+
const LABEL = { structure:'Structure', interaction:'Interaction', states:'States', content:'Content', visual:'Visual', motion:'Motion', access:'Accessibility' };
|
|
149
|
+
const STATE_LABEL = { generated:'Generated', in_review:'In review', approved:'Approved', rejected:'Rejected', superseded:'Superseded' };
|
|
150
|
+
const results = {}; // pending id -> {item, kind, text}
|
|
151
|
+
let state = null;
|
|
152
|
+
let tab = 'decisions';
|
|
153
|
+
|
|
154
|
+
async function load() {
|
|
155
|
+
state = await (await fetch('/api/state')).json();
|
|
156
|
+
render();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function render() {
|
|
160
|
+
document.getElementById('project').textContent = state.project;
|
|
161
|
+
document.getElementById('count').textContent = `${state.active} of ${state.cap} rules`;
|
|
162
|
+
const nav = document.getElementById('nav');
|
|
163
|
+
nav.innerHTML = '';
|
|
164
|
+
nav.appendChild(tabBtn('decisions', `Decisions · ${state.pending.length}`));
|
|
165
|
+
nav.appendChild(tabBtn('candidates', `Candidates · ${state.candidates.length}`));
|
|
166
|
+
const main = document.getElementById('main');
|
|
167
|
+
main.innerHTML = '';
|
|
168
|
+
(tab === 'decisions' ? renderDecisions : renderCandidates)(main);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function tabBtn(id, label) {
|
|
172
|
+
const b = btn(label, tab === id ? 'on' : '', () => { tab = id; render(); });
|
|
173
|
+
return b;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/* ── helpers ─────────────────────────────────────────────────────────── */
|
|
177
|
+
function el(tag, cls, text) { const e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e; }
|
|
178
|
+
function btn(label, cls, onClick) { const b = el('button', cls, label); b.onclick = onClick; return b; }
|
|
179
|
+
function clearPanel(c) { c.querySelectorAll('.panel').forEach(p => p.remove()); }
|
|
180
|
+
function zoom(src) { const lb = document.getElementById('lightbox'); lb.querySelector('img').src = src; lb.style.display = 'flex'; }
|
|
181
|
+
/* A ticket ref: a link when it's a URL (labelled host · last path segment), plain text for a bare key like ENG-123. */
|
|
182
|
+
function refLink(ref) {
|
|
183
|
+
if (!/^https?:\/\//i.test(ref)) return el('span', null, ref);
|
|
184
|
+
const a = el('a'); a.href = ref; a.target = '_blank'; a.rel = 'noreferrer'; a.title = ref;
|
|
185
|
+
try { const u = new URL(ref); const last = u.pathname.split('/').filter(Boolean).pop(); a.textContent = u.hostname.replace(/^www\./, '') + (last ? ' · ' + last : ''); }
|
|
186
|
+
catch { a.textContent = ref; }
|
|
187
|
+
return a;
|
|
188
|
+
}
|
|
189
|
+
function scopeWords(scope) {
|
|
190
|
+
if (scope === 'global') return 'Everywhere';
|
|
191
|
+
const i = scope.indexOf(':'); const kind = scope.slice(0, i), target = scope.slice(i + 1);
|
|
192
|
+
if (kind === 'file') return target.split('/').pop();
|
|
193
|
+
return target.replace(/[-_]+/g, ' ').replace(/^\w/, ch => ch.toUpperCase()) + ' pattern';
|
|
194
|
+
}
|
|
195
|
+
function messagePanel(c, text, cls) {
|
|
196
|
+
clearPanel(c);
|
|
197
|
+
const p = el('div', 'panel');
|
|
198
|
+
p.appendChild(el('p', cls, text));
|
|
199
|
+
p.appendChild(btn('OK', 'quiet', () => clearPanel(c)));
|
|
200
|
+
c.appendChild(p);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/* ── decisions tab ───────────────────────────────────────────────────── */
|
|
204
|
+
const open = {}; // trigger -> polish list expanded
|
|
205
|
+
const promoted = {}; // polish id -> shown as a full card
|
|
206
|
+
|
|
207
|
+
function renderDecisions(main) {
|
|
208
|
+
const done = Object.keys(results).filter(id => !state.pending.some(p => p.id === id)).map(id => results[id].item);
|
|
209
|
+
const all = [...state.pending, ...done];
|
|
210
|
+
if (!all.length) {
|
|
211
|
+
main.innerHTML = '<div class="empty"><h2>All caught up.</h2><p>Nothing pending. The agent queues decisions here when work settles.</p></div>';
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const polishTotal = state.pending.filter(d => d.level === 'polish').length;
|
|
215
|
+
if (polishTotal > 1) {
|
|
216
|
+
const bar = el('div', 'actions'); bar.style.margin = '20px 0 0';
|
|
217
|
+
bar.appendChild(btn(`Confirm all ${polishTotal} polish`, null, () => sendAll({ as: 'accept', level: 'polish' })));
|
|
218
|
+
main.appendChild(bar);
|
|
219
|
+
}
|
|
220
|
+
for (const g of groupByTrigger(all)) {
|
|
221
|
+
const items = g.items, polish = g.polish.filter(d => !results[d.id] || promoted[d.id]);
|
|
222
|
+
const head = el('div', 'group');
|
|
223
|
+
head.appendChild(el('h2', null, g.trigger));
|
|
224
|
+
const n = items.filter(d => !results[d.id]).length;
|
|
225
|
+
head.appendChild(el('span', null, `${n} decision${n === 1 ? '' : 's'}${polish.length ? ` · +${polish.length} polish` : ''}`));
|
|
226
|
+
main.appendChild(head);
|
|
227
|
+
for (const d of items) main.appendChild(results[d.id] ? doneCard(d) : card(d));
|
|
228
|
+
for (const d of g.polish.filter(d => promoted[d.id])) main.appendChild(results[d.id] ? doneCard(d) : card(d));
|
|
229
|
+
const rest = g.polish.filter(d => !promoted[d.id]);
|
|
230
|
+
if (rest.length) main.appendChild(polishRow(g.trigger, rest));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function groupByTrigger(list) {
|
|
235
|
+
const out = [];
|
|
236
|
+
for (const d of list) {
|
|
237
|
+
let g = out.find(x => x.trigger === d.trigger);
|
|
238
|
+
if (!g) { g = { trigger: d.trigger, items: [], polish: [] }; out.push(g); }
|
|
239
|
+
(d.level === 'polish' ? g.polish : g.items).push(d);
|
|
240
|
+
}
|
|
241
|
+
return out;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function polishRow(trigger, list) {
|
|
245
|
+
const pending = list.filter(d => !results[d.id]);
|
|
246
|
+
const box = el('div', 'polish');
|
|
247
|
+
const row = el('div', 'row');
|
|
248
|
+
row.appendChild(el('span', 'n', pending.length ? `${pending.length} polish — one-off fixes, no rules come from these` : 'Polish confirmed'));
|
|
249
|
+
if (pending.length) {
|
|
250
|
+
row.appendChild(btn('Confirm all', 'primary', () => sendAll({ as: 'accept', level: 'polish', trigger })));
|
|
251
|
+
row.appendChild(btn(open[trigger] ? 'Hide' : 'Show', 'quiet', () => { open[trigger] = !open[trigger]; render(); }));
|
|
252
|
+
}
|
|
253
|
+
box.appendChild(row);
|
|
254
|
+
if (open[trigger] || !pending.length) {
|
|
255
|
+
const ul = el('ul');
|
|
256
|
+
for (const d of list) {
|
|
257
|
+
const li = el('li');
|
|
258
|
+
const r = results[d.id];
|
|
259
|
+
li.appendChild(el('span', r ? 'muted' : '', (r ? (r.kind === 'ok' ? '✓ ' : '— ') : '') + (d.change || d.decision)));
|
|
260
|
+
if (!r) {
|
|
261
|
+
li.appendChild(btn('Confirm', 'quiet', () => sendRow(d, li, { as: 'accept' })));
|
|
262
|
+
li.appendChild(btn('Skip', 'quiet', () => sendRow(d, li, { as: 'skip' })));
|
|
263
|
+
li.appendChild(btn('More', 'quiet', () => { promoted[d.id] = true; render(); }));
|
|
264
|
+
}
|
|
265
|
+
ul.appendChild(li);
|
|
266
|
+
}
|
|
267
|
+
box.appendChild(ul);
|
|
268
|
+
}
|
|
269
|
+
return box;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function card(d) {
|
|
273
|
+
const c = el('div', 'card'); c.dataset.id = d.id;
|
|
274
|
+
const split = el('div', 'split');
|
|
275
|
+
const body = el('div', 'body');
|
|
276
|
+
const h = el('h3', null, d.change || d.decision);
|
|
277
|
+
h.appendChild(el('span', 'level ' + d.level, d.level));
|
|
278
|
+
body.appendChild(h);
|
|
279
|
+
const dl = el('dl', 'lines');
|
|
280
|
+
const line = (k, v, cls) => { dl.appendChild(el('dt', null, k)); dl.appendChild(el('dd', cls, v)); };
|
|
281
|
+
if (d.change) line('Pattern', d.decision);
|
|
282
|
+
for (const r of d.rejected) line('Rejected', r);
|
|
283
|
+
line('Why', d.rationale, 'muted');
|
|
284
|
+
body.appendChild(dl);
|
|
285
|
+
const meta = el('div', 'meta');
|
|
286
|
+
const tag = el('span', 'tag', scopeWords(d.scope)); tag.title = d.scope; meta.appendChild(tag);
|
|
287
|
+
meta.appendChild(el('span', null, d.class));
|
|
288
|
+
if (d.verified === false) { const v = el('span', 'bad', '· unverified'); v.title = 'The files did not match this claim when it was queued'; meta.appendChild(v); }
|
|
289
|
+
meta.appendChild(el('span', null, '· ' + d.author + ', ' + d.date.slice(0, 10)));
|
|
290
|
+
if (d.ref) { meta.appendChild(el('span', null, '·')); meta.appendChild(refLink(d.ref)); }
|
|
291
|
+
body.appendChild(meta);
|
|
292
|
+
body.appendChild(actions(d, c));
|
|
293
|
+
split.appendChild(body);
|
|
294
|
+
if (d.snapshotUrl) {
|
|
295
|
+
const t = el('div', 'thumb'); t.onclick = () => zoom(d.snapshotUrl);
|
|
296
|
+
const img = el('img'); img.src = d.snapshotUrl; img.alt = d.candidateName || d.candidate; t.appendChild(img);
|
|
297
|
+
t.appendChild(el('div', 'cap', `${d.candidate} · ${d.candidateName || ''}`));
|
|
298
|
+
split.appendChild(t);
|
|
299
|
+
}
|
|
300
|
+
c.appendChild(split);
|
|
301
|
+
return c;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
async function sendAll(body) {
|
|
305
|
+
const res = await (await fetch('/api/judge-all', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) })).json();
|
|
306
|
+
const targets = state.pending.filter(d => (!body.level || d.level === body.level) && (!body.trigger || d.trigger === body.trigger));
|
|
307
|
+
for (const d of targets) if (!(res.failed || []).some(f => f.id === d.id)) results[d.id] = { item: d, kind: body.as === 'skip' ? 'skip' : 'ok', text: body.as === 'skip' ? 'Skipped' : 'Confirmed' };
|
|
308
|
+
await load();
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
async function sendRow(d, li, body) {
|
|
312
|
+
li.querySelectorAll('button').forEach(b => b.disabled = true);
|
|
313
|
+
const res = await (await fetch('/api/judge', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: d.id, ...body }) })).json();
|
|
314
|
+
if (res.exitCode !== 0) { li.querySelectorAll('button').forEach(b => b.disabled = false); return; }
|
|
315
|
+
results[d.id] = { item: d, kind: res.status === 'skipped' ? 'skip' : 'ok', text: res.status === 'skipped' ? 'Skipped' : `Recorded ${res.id}` };
|
|
316
|
+
await load();
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function actions(d, c) {
|
|
320
|
+
const a = el('div', 'actions');
|
|
321
|
+
a.appendChild(btn('Confirm', d.level === 'polish' ? 'primary' : null, () => send(d, c, { as: 'accept' })));
|
|
322
|
+
if (d.level !== 'polish') a.appendChild(btn('Make it a rule', 'primary', () => send(d, c, { as: 'rule' })));
|
|
323
|
+
a.appendChild(btn('Skip', 'quiet', () => send(d, c, { as: 'skip' })));
|
|
324
|
+
a.appendChild(btn('Fix', 'quiet', () => fixPanel(d, c)));
|
|
325
|
+
return a;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function fixPanel(d, c) {
|
|
329
|
+
clearPanel(c);
|
|
330
|
+
const p = el('div', 'panel');
|
|
331
|
+
p.appendChild(el('p', null, 'What should it be instead?'));
|
|
332
|
+
const ta = el('textarea'); ta.placeholder = d.decision; p.appendChild(ta);
|
|
333
|
+
const row = el('div', 'actions');
|
|
334
|
+
row.appendChild(btn('Save fix', 'primary', () => { if (ta.value.trim()) send(d, c, { as: 'fix', to: ta.value.trim() }); }));
|
|
335
|
+
row.appendChild(btn('Cancel', 'quiet', () => clearPanel(c)));
|
|
336
|
+
p.appendChild(row);
|
|
337
|
+
c.appendChild(p); ta.focus();
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function overlapPanel(d, c, res, body) {
|
|
341
|
+
clearPanel(c);
|
|
342
|
+
const p = el('div', 'panel');
|
|
343
|
+
p.appendChild(el('p', null, `Overlaps ${res.overlaps.length} active rule${res.overlaps.length === 1 ? '' : 's'}:`));
|
|
344
|
+
for (const o of res.overlaps) {
|
|
345
|
+
const r = el('div', 'rule');
|
|
346
|
+
r.appendChild(el('b', null, `${o.id} · ${o.decision}`));
|
|
347
|
+
r.appendChild(el('span', 'conf ' + o.confidence, (o.confidence === 'exact' ? 'exact — ' : 'possible — ') + o.reason));
|
|
348
|
+
p.appendChild(r);
|
|
349
|
+
}
|
|
350
|
+
const row = el('div', 'actions');
|
|
351
|
+
for (const o of res.overlaps) row.appendChild(btn(`Replace ${o.id}`, 'primary', () => send(d, c, { ...body, supersedes: o.id })));
|
|
352
|
+
row.appendChild(btn('Keep both', null, () => send(d, c, { ...body, keepBoth: true })));
|
|
353
|
+
row.appendChild(btn('Cancel', 'quiet', () => clearPanel(c)));
|
|
354
|
+
p.appendChild(row);
|
|
355
|
+
c.appendChild(p);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function contradictedPanel(d, c, res) {
|
|
359
|
+
clearPanel(c);
|
|
360
|
+
const p = el('div', 'panel');
|
|
361
|
+
p.appendChild(el('p', 'bad', 'The files don\'t match this claim:'));
|
|
362
|
+
const ul = el('ul', 'rejected');
|
|
363
|
+
for (const f of res.failed) ul.appendChild(el('li', null, `${f.kind}${f.needle ? ` "${f.needle}"` : ''} — ${f.file}${f.detail ? ` (${f.detail})` : ''}`));
|
|
364
|
+
p.appendChild(ul);
|
|
365
|
+
p.appendChild(el('p', null, 'Ask the agent to fix the code, or confirm it as an exception instead.'));
|
|
366
|
+
p.appendChild(btn('OK', 'quiet', () => clearPanel(c)));
|
|
367
|
+
c.appendChild(p);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
async function send(d, c, body) {
|
|
371
|
+
c.querySelectorAll('button').forEach(b => b.disabled = true);
|
|
372
|
+
const res = await (await fetch('/api/judge', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: d.id, ...body }) })).json();
|
|
373
|
+
c.querySelectorAll('button').forEach(b => b.disabled = false);
|
|
374
|
+
if (res.exitCode === 2) return overlapPanel(d, c, res, body);
|
|
375
|
+
if (res.exitCode === 3) return messagePanel(c, res.message, 'bad');
|
|
376
|
+
if (res.exitCode === 4) return contradictedPanel(d, c, res);
|
|
377
|
+
if (res.exitCode !== 0) return messagePanel(c, (res.errors || ['Something went wrong']).join(' · '), 'bad');
|
|
378
|
+
results[d.id] = { item: d, kind: res.status === 'skipped' ? 'skip' : 'ok',
|
|
379
|
+
text: res.status === 'skipped' ? 'Skipped' : `Recorded ${res.id} as ${res.verdict}${res.supersedes ? ', replacing ' + res.supersedes : ''}` };
|
|
380
|
+
await load();
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function doneCard(d) {
|
|
384
|
+
const r = results[d.id];
|
|
385
|
+
const c = el('div', 'card done');
|
|
386
|
+
const row = el('div', 'result');
|
|
387
|
+
row.appendChild(el('span', r.kind, r.kind === 'ok' ? '✓' : '—'));
|
|
388
|
+
row.appendChild(el('span', null, d.change || d.decision));
|
|
389
|
+
row.appendChild(el('span', 'meta', r.text));
|
|
390
|
+
c.appendChild(row);
|
|
391
|
+
return c;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/* ── candidates tab ──────────────────────────────────────────────────── */
|
|
395
|
+
function renderCandidates(main) {
|
|
396
|
+
const all = state.candidates;
|
|
397
|
+
if (!all.length) {
|
|
398
|
+
main.innerHTML = '<div class="empty"><h2>No candidates yet.</h2><p>When the agent explores several directions for one feature, each one shows up here with its picture, its decisions, and — once you pick — why the others lost.</p></div>';
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
const features = [...new Set(all.map(c => c.feature || '—'))];
|
|
402
|
+
for (const f of features) {
|
|
403
|
+
main.appendChild(el('h2', null, f));
|
|
404
|
+
for (const c of all.filter(c => (c.feature || '—') === f)) main.appendChild(candCard(c));
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function candCard(c) {
|
|
409
|
+
const card = el('div', 'card'); card.dataset.id = c.id;
|
|
410
|
+
const grid = el('div', 'cand');
|
|
411
|
+
const body = el('div');
|
|
412
|
+
const h = el('h3', null, `${c.name}`);
|
|
413
|
+
const st = el('span', 'state ' + c.state, STATE_LABEL[c.state] + (c.state === 'superseded' && c.supersededBy ? ` → ${c.supersededBy}` : ''));
|
|
414
|
+
h.appendChild(st); body.appendChild(h);
|
|
415
|
+
if (c.reason) body.appendChild(el('p', 'reason', '“' + c.reason + '”'));
|
|
416
|
+
const decs = el('ul', 'decs');
|
|
417
|
+
if (!c.decisions.length) decs.appendChild(el('li', null, 'No decisions linked yet.'));
|
|
418
|
+
for (const d of c.decisions) { const li = el('li'); li.appendChild(el('b', null, d.decision)); li.appendChild(document.createTextNode(` · ${d.id} · ${d.verdict}`)); decs.appendChild(li); }
|
|
419
|
+
body.appendChild(decs);
|
|
420
|
+
const meta = el('div', 'meta');
|
|
421
|
+
meta.appendChild(el('span', null, c.id));
|
|
422
|
+
meta.appendChild(el('span', null, '· ' + c.author + ', ' + c.date.slice(0, 10)));
|
|
423
|
+
if (c.commit) meta.appendChild(el('span', null, '· ' + c.commit));
|
|
424
|
+
body.appendChild(meta);
|
|
425
|
+
if (c.comments && c.comments.length) {
|
|
426
|
+
const box = el('div', 'comments');
|
|
427
|
+
const stale = x => !!(x.board_version && state.boardVersion && x.board_version !== state.boardVersion);
|
|
428
|
+
const approvals = c.comments.filter(x => x.kind === 'approve' && !stale(x));
|
|
429
|
+
const earlier = c.comments.filter(x => x.kind === 'approve' && stale(x));
|
|
430
|
+
if (approvals.length) box.appendChild(el('p', 'ok', '✓ Looks good to ' + approvals.map(a => a.author_name).join(', ')));
|
|
431
|
+
if (earlier.length) box.appendChild(el('p', 'muted', 'Looked good to ' + earlier.map(a => a.author_name).join(', ') + ' on an earlier version'));
|
|
432
|
+
for (const x of c.comments.filter(x => x.kind === 'comment')) { const p = el('p'); p.appendChild(el('b', null, x.author_name + (x.decision_id ? ' on ' + x.decision_id : '') + ' ')); p.appendChild(document.createTextNode(x.body + (stale(x) ? ' (earlier version)' : ''))); box.appendChild(p); }
|
|
433
|
+
body.appendChild(box);
|
|
434
|
+
}
|
|
435
|
+
if (c.state === 'generated' || c.state === 'in_review') {
|
|
436
|
+
const a = el('div', 'actions');
|
|
437
|
+
a.appendChild(btn('Approve', 'primary', () => whyPanel(card, c, 'approved', 'Why this one? (kept on the directions it replaces)')));
|
|
438
|
+
a.appendChild(btn('Reject', null, () => whyPanel(card, c, 'rejected', 'Why not?')));
|
|
439
|
+
if (c.state === 'generated') a.appendChild(btn('In review', 'quiet', () => sendCand(card, c, { state: 'in_review' })));
|
|
440
|
+
body.appendChild(a);
|
|
441
|
+
}
|
|
442
|
+
grid.appendChild(body);
|
|
443
|
+
const shot = el('div', 'shot');
|
|
444
|
+
if (c.snapshotUrl) { const img = el('img'); img.src = c.snapshotUrl; img.alt = c.name; shot.appendChild(img); shot.onclick = () => zoom(c.snapshotUrl); }
|
|
445
|
+
else { shot.textContent = 'No snapshot'; shot.style.cursor = 'default'; shot.title = `npx arbiter candidate ${c.id} --capture`; }
|
|
446
|
+
grid.appendChild(shot);
|
|
447
|
+
card.appendChild(grid);
|
|
448
|
+
return card;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function whyPanel(card, c, newState, prompt) {
|
|
452
|
+
clearPanel(card);
|
|
453
|
+
const p = el('div', 'panel');
|
|
454
|
+
p.appendChild(el('p', null, prompt));
|
|
455
|
+
const ta = el('textarea'); ta.placeholder = 'One line'; p.appendChild(ta);
|
|
456
|
+
const row = el('div', 'actions');
|
|
457
|
+
row.appendChild(btn(newState === 'approved' ? 'Approve' : 'Reject', 'primary', () => sendCand(card, c, { state: newState, why: ta.value.trim() || undefined })));
|
|
458
|
+
row.appendChild(btn('Cancel', 'quiet', () => clearPanel(card)));
|
|
459
|
+
p.appendChild(row);
|
|
460
|
+
card.appendChild(p); ta.focus();
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
async function sendCand(card, c, body) {
|
|
464
|
+
card.querySelectorAll('button').forEach(b => b.disabled = true);
|
|
465
|
+
const res = await (await fetch('/api/candidate', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: c.id, ...body }) })).json();
|
|
466
|
+
card.querySelectorAll('button').forEach(b => b.disabled = false);
|
|
467
|
+
if (res.exitCode !== 0) return messagePanel(card, (res.errors || ['Something went wrong']).join(' · '), 'bad');
|
|
468
|
+
await load();
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
document.getElementById('done').onclick = async () => {
|
|
472
|
+
await fetch('/api/done', { method: 'POST' });
|
|
473
|
+
document.body.innerHTML = '<div class="empty"><h2>Review closed.</h2><p>You can close this tab.</p></div>';
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
load();
|
|
477
|
+
</script>
|
|
478
|
+
</body>
|
|
479
|
+
</html>
|