arbiterdesign 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -40
- package/dist/area-names.js +120 -0
- package/dist/areas.js +131 -0
- package/dist/board-types.js +9 -0
- package/dist/candidates.js +7 -1
- package/dist/commands/areas.js +153 -0
- package/dist/commands/candidate.js +4 -2
- package/dist/commands/decision.js +100 -0
- package/dist/commands/export.js +88 -125
- package/dist/commands/init.js +89 -2
- package/dist/commands/prompt.js +12 -4
- package/dist/commands/publish.js +18 -1
- package/dist/commands/record.js +152 -3
- package/dist/commands/rename.js +123 -0
- package/dist/commands/review.js +469 -76
- package/dist/commands/rules.js +8 -1
- package/dist/commands/setup.js +1 -0
- package/dist/commands/snapshot.js +24 -2
- package/dist/commands/sweep.js +1 -1
- package/dist/commands/unpublish.js +88 -0
- package/dist/comments.js +24 -0
- package/dist/handoff.js +283 -0
- package/dist/hook.js +80 -0
- package/dist/hosted.js +117 -20
- package/dist/index.js +93 -24
- package/dist/localboard.js +219 -0
- package/dist/lock.js +134 -0
- package/dist/overlap.js +16 -0
- package/dist/pictures.js +4 -0
- package/dist/settings.js +107 -0
- package/dist/store.js +6 -5
- package/dist/verify.js +4 -2
- package/dist/wording.js +65 -0
- package/dist/work.js +139 -1
- package/package.json +3 -2
- package/templates/SKILL.md +169 -50
- package/templates/board/board.css +2 -0
- package/templates/board/board.js +25 -0
- package/templates/board/index.html +15 -0
- package/templates/fonts/Geist-Variable.woff2 +0 -0
- package/templates/fonts/GeistMono-Variable.woff2 +0 -0
- package/templates/fonts/OFL.txt +92 -0
- package/templates/hooks/arbiter-board.cjs +50 -0
- package/templates/review.html +0 -600
package/dist/hosted.js
CHANGED
|
@@ -12,23 +12,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.publishable = exports.ADMIN_ENV = exports.TOKEN_ENV = void 0;
|
|
15
|
+
exports.PASSWORD_MIN = exports.publishable = exports.ADMIN_ENV = exports.TOKEN_ENV = exports.writeComments = exports.readComments = void 0;
|
|
16
16
|
exports.readLinkOrNull = readLinkOrNull;
|
|
17
17
|
exports.readLink = readLink;
|
|
18
18
|
exports.writeLink = writeLink;
|
|
19
19
|
exports.readToken = readToken;
|
|
20
20
|
exports.writeToken = writeToken;
|
|
21
|
-
exports.readComments = readComments;
|
|
22
|
-
exports.writeComments = writeComments;
|
|
23
21
|
exports.buildManifest = buildManifest;
|
|
22
|
+
exports.newPassword = newPassword;
|
|
24
23
|
exports.publishHosted = publishHosted;
|
|
25
24
|
exports.pullHosted = pullHosted;
|
|
25
|
+
exports.unpublishHosted = unpublishHosted;
|
|
26
|
+
exports.parseBoardLink = parseBoardLink;
|
|
27
|
+
exports.takedownHosted = takedownHosted;
|
|
26
28
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
27
29
|
const node_path_1 = __importDefault(require("node:path"));
|
|
30
|
+
const node_crypto_1 = require("node:crypto");
|
|
28
31
|
const candidates_1 = require("./candidates");
|
|
29
32
|
const store_1 = require("./store");
|
|
30
33
|
const work_1 = require("./work");
|
|
31
34
|
const requests_1 = require("./requests");
|
|
35
|
+
const comments_1 = require("./comments");
|
|
32
36
|
/** The link for places that only want to know about the board, where a broken hosted.json shouldn't stop the command. */
|
|
33
37
|
function readLinkOrNull(paths) {
|
|
34
38
|
try {
|
|
@@ -38,9 +42,12 @@ function readLinkOrNull(paths) {
|
|
|
38
42
|
return null;
|
|
39
43
|
}
|
|
40
44
|
}
|
|
45
|
+
// Pulled comments live in their own module; pull writes them, and these names stay here for it.
|
|
46
|
+
var comments_2 = require("./comments");
|
|
47
|
+
Object.defineProperty(exports, "readComments", { enumerable: true, get: function () { return comments_2.readComments; } });
|
|
48
|
+
Object.defineProperty(exports, "writeComments", { enumerable: true, get: function () { return comments_2.writeComments; } });
|
|
41
49
|
const LINK_FILE = 'hosted.json';
|
|
42
50
|
const TOKEN_FILE = 'hosted.token';
|
|
43
|
-
const COMMENTS_FILE = 'comments.json';
|
|
44
51
|
exports.TOKEN_ENV = 'ARBITER_PUBLISH_TOKEN';
|
|
45
52
|
exports.ADMIN_ENV = 'ARBITER_ADMIN_TOKEN';
|
|
46
53
|
const IMAGE_TYPES = { '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.gif': 'image/gif' };
|
|
@@ -79,15 +86,6 @@ function writeToken(paths, token) {
|
|
|
79
86
|
lines.push(TOKEN_FILE);
|
|
80
87
|
node_fs_1.default.writeFileSync(gi, lines.join('\n') + '\n');
|
|
81
88
|
}
|
|
82
|
-
function readComments(paths) {
|
|
83
|
-
const f = node_path_1.default.join(paths.archiveDir, COMMENTS_FILE);
|
|
84
|
-
return node_fs_1.default.existsSync(f) ? JSON.parse(node_fs_1.default.readFileSync(f, 'utf8')) : [];
|
|
85
|
-
}
|
|
86
|
-
/** Every comment on file, minus email addresses: nothing here needs them, and the file is committed. */
|
|
87
|
-
function writeComments(paths, comments) {
|
|
88
|
-
const kept = comments.map(({ author_email: _email, ...c }) => c);
|
|
89
|
-
node_fs_1.default.writeFileSync(node_path_1.default.join(paths.archiveDir, COMMENTS_FILE), JSON.stringify(kept, null, 2) + '\n');
|
|
90
|
-
}
|
|
91
89
|
const publishable = (d) => d.verdict !== 'pending' && d.verdict !== 'retire' && d.level !== 'polish';
|
|
92
90
|
exports.publishable = publishable;
|
|
93
91
|
const wire = (d) => ({ id: d.id, change: d.change, decision: d.decision, rejected: d.rejected, verdict: d.verdict, dimension: d.dimension, scope: d.scope, ref: d.ref });
|
|
@@ -96,6 +94,8 @@ const wire = (d) => ({ id: d.id, change: d.change, decision: d.decision, rejecte
|
|
|
96
94
|
* candidate rides with that screen; the rest are grouped by the piece of work they came from
|
|
97
95
|
* (`trigger`) and become a card each — no picture, state `recorded`. Most work is one direction,
|
|
98
96
|
* iterated; the board shouldn't be empty for it.
|
|
97
|
+
*
|
|
98
|
+
* Only for the team board. The local board builds its own from the same files (src/localboard.ts).
|
|
99
99
|
*/
|
|
100
100
|
function buildManifest(paths, opts = {}) {
|
|
101
101
|
const skipped = [];
|
|
@@ -150,7 +150,7 @@ function buildManifest(paths, opts = {}) {
|
|
|
150
150
|
// Work has no product area of its own; it joins one only when the trigger names an existing one.
|
|
151
151
|
id, name: trigger, feature: areas.get(trigger.toLowerCase()) ?? null, state: 'recorded', work: true,
|
|
152
152
|
author: last.author, date: last.date, reason: null, notes: '', supersededBy: null, url: null, snapshot,
|
|
153
|
-
decisions: ds.map(wire),
|
|
153
|
+
decisions: ds.filter(exports.publishable).map(wire),
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
// The day each became a rule, for the board's Design rules page.
|
|
@@ -173,7 +173,11 @@ function buildManifest(paths, opts = {}) {
|
|
|
173
173
|
return d ? [{ id: d.id, change: d.change ?? d.decision, card: (0, requests_1.cardOf)(paths, d, ids) }] : [];
|
|
174
174
|
}),
|
|
175
175
|
}));
|
|
176
|
-
|
|
176
|
+
// Renamed pieces of work, so the board moves their comments. Not one whose old name is a card again:
|
|
177
|
+
// the board would move the new card's comments away to the old one's new name.
|
|
178
|
+
const live = new Set(candidates.map((c) => c.id));
|
|
179
|
+
const renamed = (0, work_1.readRenames)(paths).filter((r) => !live.has(r.from));
|
|
180
|
+
return { manifest: { project: node_path_1.default.basename(paths.root), exported: new Date().toISOString().slice(0, 10), candidates, rules, requests, renamed }, skipped };
|
|
177
181
|
}
|
|
178
182
|
async function api(url, init = {}) {
|
|
179
183
|
const headers = { 'content-type': 'application/json', ...init.headers };
|
|
@@ -190,9 +194,23 @@ async function api(url, init = {}) {
|
|
|
190
194
|
catch { /* non-json error */ }
|
|
191
195
|
return { ok: res.ok, status: res.status, body };
|
|
192
196
|
}
|
|
197
|
+
/** The service's own floor for a board password. */
|
|
198
|
+
exports.PASSWORD_MIN = 8;
|
|
199
|
+
/**
|
|
200
|
+
* A password nobody will guess: 12 characters from 31 that can't be misread (no 0/o, 1/l/i), in
|
|
201
|
+
* three groups so it can be read out. About 59 bits.
|
|
202
|
+
*/
|
|
203
|
+
function newPassword() {
|
|
204
|
+
const abc = 'abcdefghjkmnpqrstuvwxyz23456789';
|
|
205
|
+
const pick = () => Array.from({ length: 4 }, () => abc[(0, node_crypto_1.randomInt)(abc.length)]).join('');
|
|
206
|
+
return `${pick()}-${pick()}-${pick()}`;
|
|
207
|
+
}
|
|
193
208
|
/**
|
|
194
|
-
* Create the project on first publish; then the
|
|
195
|
-
*
|
|
209
|
+
* Create the project on first publish; then the password, if one was given; then the images, one
|
|
210
|
+
* request each; then the board. The password goes before anything else, so a new board is never
|
|
211
|
+
* readable without it. Keeps every request under Vercel's 4.5 MB body cap however many screens there are.
|
|
212
|
+
*
|
|
213
|
+
* `password`: a string sets it, null takes it off, left out leaves it as it is.
|
|
196
214
|
*/
|
|
197
215
|
async function publishHosted(paths, serviceUrl, opts = {}) {
|
|
198
216
|
const base = serviceUrl.replace(/\/$/, '');
|
|
@@ -208,8 +226,9 @@ async function publishHosted(paths, serviceUrl, opts = {}) {
|
|
|
208
226
|
const r = await api(`${base}/api/projects`, { method: 'POST', body: JSON.stringify({ name: node_path_1.default.basename(paths.root) }), admin });
|
|
209
227
|
if (r.status === 401)
|
|
210
228
|
throw new Error(`${base} only lets an admin create boards. Ask whoever runs it for the token, then: npx arbiter publish --to ${base} --admin-token <token>`);
|
|
229
|
+
// The service says which limit it was: this network's, or everyone's.
|
|
211
230
|
if (r.status === 429)
|
|
212
|
-
throw new Error(`${base} is busy right now — try again in an hour`);
|
|
231
|
+
throw new Error(typeof r.body.error === 'string' ? r.body.error : `${base} is busy right now — try again in an hour`);
|
|
213
232
|
if (!r.ok)
|
|
214
233
|
throw new Error(`could not create project on ${base}: ${r.body.error ?? r.status}`);
|
|
215
234
|
link = { url: base, projectId: String(r.body.id), slug: String(r.body.slug), shareUrl: String(r.body.url) };
|
|
@@ -220,6 +239,15 @@ async function publishHosted(paths, serviceUrl, opts = {}) {
|
|
|
220
239
|
const token = readToken(paths);
|
|
221
240
|
if (!token)
|
|
222
241
|
throw new Error(`no publish token for ${link.shareUrl}. Teammate? Get it from whoever first published, then: ${exports.TOKEN_ENV}=<token> npx arbiter publish`);
|
|
242
|
+
if (opts.password !== undefined) {
|
|
243
|
+
const pw = await api(`${base}/api/projects/${link.projectId}/password`, { method: 'PUT', body: JSON.stringify({ password: opts.password }), token });
|
|
244
|
+
if (pw.status === 401)
|
|
245
|
+
throw new Error(`the publish token was refused by ${base} — wrong ${exports.TOKEN_ENV}, or the project was deleted`);
|
|
246
|
+
if (pw.status === 404 || pw.status === 405)
|
|
247
|
+
throw new Error(`${base} doesn't take board passwords yet — it runs an older Arbiter than this one. Nothing was published.`);
|
|
248
|
+
if (!pw.ok)
|
|
249
|
+
throw new Error(`password not ${opts.password === null ? 'removed' : 'set'}: ${pw.body.error ?? pw.status}. Nothing was published.`);
|
|
250
|
+
}
|
|
223
251
|
const config = (0, store_1.readConfig)(paths);
|
|
224
252
|
const { manifest, skipped } = buildManifest(paths, { includeRules: !!(config?.pages && config.pages.includeRules) });
|
|
225
253
|
let snapshots = 0;
|
|
@@ -229,6 +257,13 @@ async function publishHosted(paths, serviceUrl, opts = {}) {
|
|
|
229
257
|
const up = await api(`${base}/api/projects/${link.projectId}/snapshots/${c.id}`, { method: 'PUT', body: Buffer.from(c.snapshot.data, 'base64'), headers: { 'content-type': c.snapshot.type }, token });
|
|
230
258
|
if (up.status === 401)
|
|
231
259
|
throw new Error(`the publish token was refused by ${base} — wrong ${exports.TOKEN_ENV}, or the project was deleted`);
|
|
260
|
+
// The board, or the whole service, is out of room for pictures. The rest of the board is still
|
|
261
|
+
// worth publishing: this card goes up without its picture, and the reason is reported.
|
|
262
|
+
if (up.status === 413 || up.status === 507) {
|
|
263
|
+
skipped.push(`${c.id}: not uploaded — ${up.body.error ?? 'no room for it'}`);
|
|
264
|
+
c.snapshot = null;
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
232
267
|
if (!up.ok)
|
|
233
268
|
throw new Error(`${c.id}: snapshot upload failed: ${up.body.error ?? up.status}`);
|
|
234
269
|
c.snapshot = String(up.body.url);
|
|
@@ -260,11 +295,17 @@ async function pullHosted(paths) {
|
|
|
260
295
|
if (!Array.isArray(r.body.comments))
|
|
261
296
|
throw new Error('pull failed: the board sent no comment list');
|
|
262
297
|
const current = r.body.comments;
|
|
263
|
-
|
|
298
|
+
// What's on file keeps its words, but takes the board's card: a renamed piece of work's comments
|
|
299
|
+
// move there at publish, and a copy pulled before that would still point at the old card.
|
|
300
|
+
const onBoard = new Map(current.map((c) => [c.id, c]));
|
|
301
|
+
const existing = (0, comments_1.readComments)(paths).map((c) => {
|
|
302
|
+
const now = onBoard.get(c.id);
|
|
303
|
+
return now && now.candidate_id !== c.candidate_id ? { ...c, candidate_id: now.candidate_id } : c;
|
|
304
|
+
});
|
|
264
305
|
const seen = new Set(existing.map((c) => c.id));
|
|
265
306
|
const fresh = current.filter((c) => !seen.has(c.id));
|
|
266
307
|
const merged = [...existing, ...fresh].sort((a, b) => String(a.created_at ?? '').localeCompare(String(b.created_at ?? '')));
|
|
267
|
-
writeComments(paths, merged);
|
|
308
|
+
(0, comments_1.writeComments)(paths, merged);
|
|
268
309
|
// hosted.json is committed: rewrite it only when the board has moved on, or every pull on every
|
|
269
310
|
// machine would leave it changed, and two of them would conflict.
|
|
270
311
|
const boardVersion = r.body.board_version ?? link.boardVersion ?? null;
|
|
@@ -274,3 +315,59 @@ async function pullHosted(paths) {
|
|
|
274
315
|
}
|
|
275
316
|
return { link, fresh, current, total: merged.length };
|
|
276
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* Delete the board from the service: the board, its pictures, every comment. Comments are pulled
|
|
320
|
+
* into .arbiter/comments.json first, so nothing said on the board is lost with it. Then the link
|
|
321
|
+
* goes, so nothing here publishes to a board that no longer exists.
|
|
322
|
+
*/
|
|
323
|
+
async function unpublishHosted(paths) {
|
|
324
|
+
const link = readLink(paths);
|
|
325
|
+
if (!link)
|
|
326
|
+
throw new Error('this project has no hosted board (.arbiter/hosted.json)');
|
|
327
|
+
const token = readToken(paths);
|
|
328
|
+
if (!token)
|
|
329
|
+
throw new Error(`no publish token for ${link.shareUrl}. Only someone who can publish the board can delete it: ${exports.TOKEN_ENV}=<token> npx arbiter unpublish --yes`);
|
|
330
|
+
const { total } = await pullHosted(paths);
|
|
331
|
+
const r = await api(`${link.url}/api/projects/${link.projectId}`, { method: 'DELETE', token });
|
|
332
|
+
if (r.status === 401)
|
|
333
|
+
throw new Error(`${link.url} refused the publish token — wrong ${exports.TOKEN_ENV}, or the board is already gone. If it is, delete .arbiter/hosted.json and .arbiter/hosted.token.`);
|
|
334
|
+
if (r.status === 404 || r.status === 405)
|
|
335
|
+
throw new Error(`${link.url} can't delete boards yet — it runs an older Arbiter than this one. Nothing was deleted.`);
|
|
336
|
+
if (!r.ok)
|
|
337
|
+
throw new Error(`delete failed: ${r.body.error ?? r.status}. Nothing here was changed.`);
|
|
338
|
+
for (const f of [LINK_FILE, TOKEN_FILE])
|
|
339
|
+
node_fs_1.default.rmSync(node_path_1.default.join(paths.archiveDir, f), { force: true });
|
|
340
|
+
return { link, saved: total, pictures: Number(r.body.pictures ?? 0), comments: Number(r.body.comments ?? 0) };
|
|
341
|
+
}
|
|
342
|
+
/** The share link of a board, from any page on it: `https://arbiter.design/p/abc123/c/C-0001` is board abc123. */
|
|
343
|
+
function parseBoardLink(link) {
|
|
344
|
+
let u;
|
|
345
|
+
try {
|
|
346
|
+
u = new URL(link);
|
|
347
|
+
}
|
|
348
|
+
catch {
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
const slug = u.pathname.match(/^\/p\/([a-z0-9]+)(?:\/|$)/)?.[1];
|
|
352
|
+
return slug ? { origin: u.origin, slug, shareUrl: `${u.origin}/p/${slug}` } : null;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Take down any board on a server you run, by its link, with that server's admin token: for a board
|
|
356
|
+
* reported as unlawful, or an owner who lost the publish token with the folder. Nothing in this
|
|
357
|
+
* project changes, since the board isn't this project's, and nobody gets its comments back.
|
|
358
|
+
*/
|
|
359
|
+
async function takedownHosted(link, admin) {
|
|
360
|
+
const board = parseBoardLink(link);
|
|
361
|
+
if (!board)
|
|
362
|
+
throw new Error(`${link} isn't a board link. One looks like https://arbiter.design/p/abc123`);
|
|
363
|
+
const r = await api(`${board.origin}/api/projects/${board.slug}`, { method: 'DELETE', admin });
|
|
364
|
+
if (r.status === 404)
|
|
365
|
+
throw new Error(`${board.origin} has no board at ${board.shareUrl}: it's already gone, or the link is wrong`);
|
|
366
|
+
if (r.status === 401)
|
|
367
|
+
throw new Error(`${board.origin} refused the admin token (${exports.ADMIN_ENV}), or runs an older Arbiter that can't take boards down. Nothing was deleted.`);
|
|
368
|
+
if (r.status === 405)
|
|
369
|
+
throw new Error(`${board.origin} can't delete boards yet — it runs an older Arbiter than this one. Nothing was deleted.`);
|
|
370
|
+
if (!r.ok)
|
|
371
|
+
throw new Error(`delete failed: ${r.body.error ?? r.status}. Nothing was deleted.`);
|
|
372
|
+
return { shareUrl: board.shareUrl, pictures: Number(r.body.pictures ?? 0), comments: Number(r.body.comments ?? 0) };
|
|
373
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -11,15 +11,23 @@ const board_1 = require("./commands/board");
|
|
|
11
11
|
const drift_1 = require("./commands/drift");
|
|
12
12
|
const export_1 = require("./commands/export");
|
|
13
13
|
const publish_1 = require("./commands/publish");
|
|
14
|
+
const unpublish_1 = require("./commands/unpublish");
|
|
15
|
+
const rename_1 = require("./commands/rename");
|
|
16
|
+
const areas_1 = require("./commands/areas");
|
|
14
17
|
const pull_1 = require("./commands/pull");
|
|
15
18
|
const snapshot_1 = require("./commands/snapshot");
|
|
16
19
|
const setup_1 = require("./commands/setup");
|
|
17
20
|
const rules_1 = require("./commands/rules");
|
|
18
21
|
const init_1 = require("./commands/init");
|
|
19
22
|
const review_1 = require("./commands/review");
|
|
23
|
+
const handoff_1 = require("./handoff");
|
|
20
24
|
const update_1 = require("./commands/update");
|
|
21
25
|
const remove_1 = require("./commands/remove");
|
|
22
26
|
const autopublish_1 = require("./autopublish");
|
|
27
|
+
const hosted_1 = require("./hosted");
|
|
28
|
+
const store_1 = require("./store");
|
|
29
|
+
const hook_1 = require("./hook");
|
|
30
|
+
const lock_1 = require("./lock");
|
|
23
31
|
const program = new commander_1.Command();
|
|
24
32
|
program
|
|
25
33
|
.name('arbiter')
|
|
@@ -39,7 +47,7 @@ program
|
|
|
39
47
|
.option('--as <action>', 'judge a pending id: accept | rule | skip | fix; answer a request id: apply | decline')
|
|
40
48
|
.option('--request <id>', 'the approved request (R-0001) this change was made for — recording it applies the request')
|
|
41
49
|
.option('--all', 'with --as: judge every pending item the same way')
|
|
42
|
-
.option('--level <level>', 'with --all: only this level (feature | pattern
|
|
50
|
+
.option('--level <level>', 'with --all: only this level (feature | pattern)')
|
|
43
51
|
.option('--trigger <text>', 'with --all: only items queued for this piece of work')
|
|
44
52
|
.option('--to <decision>', 'with --as fix: what it should be instead; with --reword: the new wording; with a request and --as apply: what to do instead of what was asked')
|
|
45
53
|
.option('--supersedes <id>', 'the active rule this one replaces')
|
|
@@ -51,13 +59,13 @@ program
|
|
|
51
59
|
.action(async (arg, opts) => {
|
|
52
60
|
let result;
|
|
53
61
|
if (opts.retire) {
|
|
54
|
-
result = (0, record_1.retire)(opts.retire, opts.why, opts);
|
|
62
|
+
result = locked(opts.cwd, () => (0, record_1.retire)(opts.retire, opts.why, opts));
|
|
55
63
|
}
|
|
56
64
|
else if (opts.reword) {
|
|
57
|
-
result = (0, record_1.reword)(opts.reword, opts.to, opts);
|
|
65
|
+
result = locked(opts.cwd, () => (0, record_1.reword)(opts.reword, opts.to, opts));
|
|
58
66
|
}
|
|
59
67
|
else if (opts.findings) {
|
|
60
|
-
result = (0, record_1.queueFindings)(opts.findings, opts);
|
|
68
|
+
result = locked(opts.cwd, () => (0, record_1.queueFindings)(opts.findings, opts));
|
|
61
69
|
}
|
|
62
70
|
else if (opts.all) {
|
|
63
71
|
const as = opts.as;
|
|
@@ -65,7 +73,7 @@ program
|
|
|
65
73
|
result = { exitCode: 1, output: { status: 'invalid', errors: ['--all needs --as accept | rule | skip'] } };
|
|
66
74
|
}
|
|
67
75
|
else {
|
|
68
|
-
result = (0, record_1.judgeAll)({ ...opts, as });
|
|
76
|
+
result = locked(opts.cwd, () => (0, record_1.judgeAll)({ ...opts, as }));
|
|
69
77
|
}
|
|
70
78
|
}
|
|
71
79
|
else if (arg && /^P-\d{4,}$/.test(arg)) {
|
|
@@ -74,7 +82,7 @@ program
|
|
|
74
82
|
result = { exitCode: 1, output: { status: 'invalid', errors: ['judging a pending id needs --as accept | rule | skip | fix'] } };
|
|
75
83
|
}
|
|
76
84
|
else {
|
|
77
|
-
result = (0, record_1.judge)(arg, { ...opts, as });
|
|
85
|
+
result = locked(opts.cwd, () => (0, record_1.judge)(arg, { ...opts, as }));
|
|
78
86
|
}
|
|
79
87
|
}
|
|
80
88
|
else if (arg && /^R-\d{4,}$/.test(arg)) {
|
|
@@ -83,7 +91,7 @@ program
|
|
|
83
91
|
result = { exitCode: 1, output: { status: 'invalid', errors: ['answering a request needs --as apply (Apply, but…: add --to "<instead>") | decline --why "<reason>"'] } };
|
|
84
92
|
}
|
|
85
93
|
else {
|
|
86
|
-
result = (0, request_1.judgeRequest)(arg, { ...opts, as });
|
|
94
|
+
result = locked(opts.cwd, () => (0, request_1.judgeRequest)(arg, { ...opts, as }));
|
|
87
95
|
}
|
|
88
96
|
}
|
|
89
97
|
else {
|
|
@@ -94,7 +102,7 @@ program
|
|
|
94
102
|
process.stdout.write(JSON.stringify({ status: 'invalid', errors: ['no input — pass JSON as an argument or on stdin'] }, null, 2) + '\n');
|
|
95
103
|
process.exit(1);
|
|
96
104
|
}
|
|
97
|
-
result = opts.pending ? (0, record_1.queue)(input, opts) : (0, record_1.record)(input, opts);
|
|
105
|
+
result = (0, record_1.oneOffGate)(input) ?? locked(opts.cwd, () => (opts.pending ? (0, record_1.queue)(input, opts) : (0, record_1.record)(input, opts)));
|
|
98
106
|
}
|
|
99
107
|
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
100
108
|
// Queueing never reaches the board — work cards are built from judged decisions.
|
|
@@ -108,6 +116,7 @@ program
|
|
|
108
116
|
.option('--client <name>', 'claude-code or cursor (default: detected)')
|
|
109
117
|
.option('--author <name>', 'who decides rules (default: git user.name)')
|
|
110
118
|
.option('--destination <name>', 'local (default) or git — git also commits candidate pages and prints GitHub links')
|
|
119
|
+
.option('--checkin <mode>', 'how Arbiter checks in while you work: feature | quiet | every (default: asked)')
|
|
111
120
|
.option('-y, --yes', 'no questions — use detected values')
|
|
112
121
|
.option('--skip-install', 'do not add the package to devDependencies')
|
|
113
122
|
.action(async (opts) => {
|
|
@@ -117,6 +126,8 @@ program
|
|
|
117
126
|
process.stdout.write(` ${s.file.padEnd(w)} ${s.outcome}${s.note ? ` — ${s.note}` : ''}\n`);
|
|
118
127
|
}
|
|
119
128
|
process.stdout.write('\nDone. Start a new agent session — it will read DECISIONS.md before UI work.\n');
|
|
129
|
+
if (!(0, store_1.readConfig)((0, store_1.resolvePaths)(process.cwd()))?.onboarded)
|
|
130
|
+
process.stdout.write((0, init_1.checkinHandoff)());
|
|
120
131
|
if (opts.destination === 'git') {
|
|
121
132
|
process.stdout.write([
|
|
122
133
|
'',
|
|
@@ -143,7 +154,7 @@ program
|
|
|
143
154
|
.option('--author <name>', 'author for queued items')
|
|
144
155
|
.option('--json', 'machine-readable output')
|
|
145
156
|
.action((id, opts) => {
|
|
146
|
-
const r = (0, sweep_1.sweepCommand)(id, opts);
|
|
157
|
+
const r = opts.queue ? locked(opts.cwd, () => (0, sweep_1.sweepCommand)(id, opts)) : (0, sweep_1.sweepCommand)(id, opts);
|
|
147
158
|
process.stdout.write(r.text + '\n');
|
|
148
159
|
});
|
|
149
160
|
program
|
|
@@ -152,7 +163,7 @@ program
|
|
|
152
163
|
.option('--checkin <mode>', 'feature | quiet | every')
|
|
153
164
|
.option('--app <url>', 'where the app runs, for screenshots: http://localhost:3000 or a staging address (on its own, saves only this)')
|
|
154
165
|
.action((opts) => {
|
|
155
|
-
const result = (0, setup_1.setup)(opts);
|
|
166
|
+
const result = locked(opts.cwd, () => (0, setup_1.setup)(opts));
|
|
156
167
|
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
157
168
|
process.exit(result.exitCode);
|
|
158
169
|
});
|
|
@@ -162,7 +173,7 @@ program
|
|
|
162
173
|
.option('--file <image>', 'screenshot to keep beside the work')
|
|
163
174
|
.option('--capture', 'macOS: drag-select a region of the screen')
|
|
164
175
|
.action(async (work, opts) => {
|
|
165
|
-
const result = (0, snapshot_1.snapshotWork)(work, opts);
|
|
176
|
+
const result = locked(opts.cwd, () => (0, snapshot_1.snapshotWork)(work, opts));
|
|
166
177
|
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
167
178
|
if (result.exitCode === 0)
|
|
168
179
|
await boardUpdated(opts.cwd);
|
|
@@ -181,7 +192,7 @@ program
|
|
|
181
192
|
.option('--keep-others', "approving doesn't supersede sibling directions")
|
|
182
193
|
.option('--author <name>', 'override the author')
|
|
183
194
|
.action(async (idOrAdd, name, opts) => {
|
|
184
|
-
const result = idOrAdd === 'add' ? (0, candidate_1.addCandidate)(name ?? '', opts) : (0, candidate_1.updateCandidate)(idOrAdd, opts);
|
|
195
|
+
const result = locked(opts.cwd, () => (idOrAdd === 'add' ? (0, candidate_1.addCandidate)(name ?? '', opts) : (0, candidate_1.updateCandidate)(idOrAdd, opts)));
|
|
185
196
|
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
186
197
|
if (result.exitCode === 0)
|
|
187
198
|
await boardUpdated(opts.cwd);
|
|
@@ -205,14 +216,14 @@ program
|
|
|
205
216
|
});
|
|
206
217
|
program
|
|
207
218
|
.command('export')
|
|
208
|
-
.description('Write a
|
|
219
|
+
.description('Write your board as a read-only folder for people without the repo: the same pages as arbiter review, without the review queue. Opens anywhere.')
|
|
209
220
|
.option('--out <dir>', 'output folder (default: arbiter-export)')
|
|
210
221
|
.option('--feature <name>', 'one feature only')
|
|
211
|
-
.option('--include-rules', '
|
|
222
|
+
.option('--include-rules', 'add the design rules page')
|
|
212
223
|
.option('--open', 'open it in the browser')
|
|
213
224
|
.action((opts) => {
|
|
214
225
|
const r = (0, export_1.exportBoard)(opts);
|
|
215
|
-
process.stdout.write(`Exported ${r.candidates}
|
|
226
|
+
process.stdout.write(`Exported ${r.candidates} change${r.candidates === 1 ? '' : 's'}, ${r.snapshots} picture${r.snapshots === 1 ? '' : 's'} → ${r.dir}\nOpen ${r.index}, or put the folder on any static host.\n`);
|
|
216
227
|
});
|
|
217
228
|
program
|
|
218
229
|
.command('publish')
|
|
@@ -223,15 +234,46 @@ program
|
|
|
223
234
|
.option('--on-push', 'also write a GitHub Actions workflow that republishes on every push, and set its secret')
|
|
224
235
|
.option('--auto', 'republish whenever the record changes — no GitHub, no CI, no repository needed')
|
|
225
236
|
.option('--no-auto', 'stop republishing automatically')
|
|
237
|
+
.option('--password [password]', 'the board asks for a password before showing anything; leave the value out to get a strong one made up. Once: later publishes keep it')
|
|
238
|
+
.option('--no-password', 'take the password off: anyone with the link can see the board')
|
|
226
239
|
.action(async (opts) => {
|
|
227
|
-
const r = await (0, publish_1.publish)({ noPush: opts.push === false, to: opts.to, admin: opts.adminToken, onPush: opts.onPush, auto: opts.auto === undefined ? undefined : !!opts.auto });
|
|
228
|
-
|
|
229
|
-
for (const s of r.steps)
|
|
230
|
-
process.stdout.write(` ${s.step.padEnd(w)} ${s.outcome}${s.note ? ` — ${s.note}` : ''}\n`);
|
|
240
|
+
const r = await (0, publish_1.publish)({ noPush: opts.push === false, to: opts.to, admin: opts.adminToken, onPush: opts.onPush, auto: opts.auto === undefined ? undefined : !!opts.auto, password: opts.password });
|
|
241
|
+
printSteps(r.steps);
|
|
231
242
|
if (r.url)
|
|
232
243
|
process.stdout.write(`\n${r.ok ? 'Live in about a minute' : 'Once the failed step is fixed'}: ${r.url}\n`);
|
|
233
244
|
process.exit(r.ok ? 0 : 1);
|
|
234
245
|
});
|
|
246
|
+
program
|
|
247
|
+
.command('unpublish [board-link]')
|
|
248
|
+
.description('Delete the hosted board, for everyone: the board, its pictures and every comment on it. Comments are saved to .arbiter/comments.json first; the record in the repo is untouched.')
|
|
249
|
+
.option('--yes', 'go ahead; without it, nothing is deleted and it says what would be')
|
|
250
|
+
.option('--admin', `with a board's link: take down any board on a server you run, with its admin token in ${hosted_1.ADMIN_ENV}`)
|
|
251
|
+
.action(async (boardLink, opts) => {
|
|
252
|
+
const r = await (0, unpublish_1.unpublish)({ yes: !!opts.yes, board: boardLink, admin: !!opts.admin });
|
|
253
|
+
printSteps(r.steps);
|
|
254
|
+
process.exit(r.ok ? 0 : 1);
|
|
255
|
+
});
|
|
256
|
+
program
|
|
257
|
+
.command('areas')
|
|
258
|
+
.description('Where everything sits on the board: folders, the areas in them, and the changes in each. Read it before naming new work, so it joins an area that is already there. --save writes folders, once the person has said yes to them.')
|
|
259
|
+
.option('--json', 'print it as JSON')
|
|
260
|
+
.option('--save <json>', 'replace the folders: {"folders":[{"name":"Local board","areas":["Review inbox","Change page"]}]}')
|
|
261
|
+
.action((opts) => {
|
|
262
|
+
const result = opts.save ? locked(undefined, () => (0, areas_1.areasCommand)({ json: opts.json, save: opts.save })) : (0, areas_1.areasCommand)({ json: opts.json, save: opts.save });
|
|
263
|
+
process.stdout.write(result.exitCode !== 0 || opts.json ? JSON.stringify(result.output, null, 2) + '\n' : `${result.text}\n`);
|
|
264
|
+
process.exit(result.exitCode);
|
|
265
|
+
});
|
|
266
|
+
program
|
|
267
|
+
.command('rename <work> <new-name>')
|
|
268
|
+
.description('Rename a piece of work everywhere the record keeps it. Its comments on the board follow it at the next publish.')
|
|
269
|
+
.option('--merge', 'the new name is a piece of work that already exists: this one joins it, decisions, pictures and comments')
|
|
270
|
+
.action(async (work, newName, opts) => {
|
|
271
|
+
const result = locked(opts.cwd, () => (0, rename_1.renameWork)(work, newName, opts));
|
|
272
|
+
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
273
|
+
if (result.exitCode === 0)
|
|
274
|
+
await boardUpdated(opts.cwd);
|
|
275
|
+
process.exit(result.exitCode);
|
|
276
|
+
});
|
|
235
277
|
program
|
|
236
278
|
.command('pull')
|
|
237
279
|
.description('Fetch comments and "looks good" reactions from the hosted board into .arbiter/comments.json. "Request change" becomes a request (R-0001) to answer.')
|
|
@@ -240,11 +282,25 @@ program
|
|
|
240
282
|
});
|
|
241
283
|
program
|
|
242
284
|
.command('review')
|
|
243
|
-
.description('Open
|
|
244
|
-
.option('--port <n>',
|
|
285
|
+
.description('Open your local board: everything decided, and what waits for review. Keep it open while you work: it redraws as the agent records, and the fixes you ask for reach your agent with your next message (Claude Code) or at the next /arbiter. Stops when you close its tab.')
|
|
286
|
+
.option('--port <n>', "port (default: the same one each time for this project, or the next free one; if this project's board is already running, it opens that one)", (v) => Number(v))
|
|
245
287
|
.option('--no-open', "print the URL, don't open a browser")
|
|
288
|
+
.option('--json', "for an agent waiting on the page: when the last tab closes, print what was decided, and what's left to change in the code, as JSON")
|
|
289
|
+
.option('--done', 'for the agent, once it has made what it was handed from the board: clears that from .arbiter/last-review.json, keeping anything judged since')
|
|
246
290
|
.action(async (opts) => {
|
|
247
|
-
|
|
291
|
+
if (opts.done) {
|
|
292
|
+
const r = locked(opts.cwd, () => (0, handoff_1.handoffDone)((0, store_1.resolvePaths)((0, store_1.findRoot)(opts.cwd))));
|
|
293
|
+
process.stdout.write(JSON.stringify(r, null, 2) + '\n');
|
|
294
|
+
process.exit(r.status === 'not-taken' ? 1 : 0);
|
|
295
|
+
}
|
|
296
|
+
const handoff = await (0, review_1.review)(opts);
|
|
297
|
+
if (opts.json)
|
|
298
|
+
process.stdout.write(JSON.stringify(handoff, null, 2) + '\n');
|
|
299
|
+
else {
|
|
300
|
+
const line = (0, handoff_1.handoffLine)(handoff, (0, hook_1.hookInstalled)((0, store_1.findRoot)()) ? 'with your next message' : 'at the next /arbiter');
|
|
301
|
+
if (line)
|
|
302
|
+
process.stdout.write(line + '\n');
|
|
303
|
+
}
|
|
248
304
|
});
|
|
249
305
|
program
|
|
250
306
|
.command('remove [id]')
|
|
@@ -252,7 +308,7 @@ program
|
|
|
252
308
|
.option('--snapshot <work>', 'remove the picture attached to a piece of work or a screen, keeping the record')
|
|
253
309
|
.option('--force', 'with a screen: unlink the decisions on it rather than refusing')
|
|
254
310
|
.action(async (id, opts) => {
|
|
255
|
-
const result = opts.snapshot ? (0, remove_1.removeSnapshot)(opts.snapshot, opts) : (0, remove_1.remove)(id ?? '', opts);
|
|
311
|
+
const result = locked(opts.cwd, () => (opts.snapshot ? (0, remove_1.removeSnapshot)(opts.snapshot, opts) : (0, remove_1.remove)(id ?? '', opts)));
|
|
256
312
|
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
257
313
|
if (result.exitCode === 0)
|
|
258
314
|
await boardUpdated(opts.cwd);
|
|
@@ -262,7 +318,7 @@ program
|
|
|
262
318
|
.command('unlink <ids...>')
|
|
263
319
|
.description('Detach decisions from the screen they were recorded against. The decisions stay exactly as they are.')
|
|
264
320
|
.action(async (ids, opts) => {
|
|
265
|
-
const result = (0, remove_1.unlink)(ids, opts);
|
|
321
|
+
const result = locked(opts.cwd, () => (0, remove_1.unlink)(ids, opts));
|
|
266
322
|
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
267
323
|
if (result.exitCode === 0)
|
|
268
324
|
await boardUpdated(opts.cwd);
|
|
@@ -304,6 +360,19 @@ program.parseAsync(process.argv).catch((e) => {
|
|
|
304
360
|
process.stderr.write(`arbiter: ${e.message}\n`);
|
|
305
361
|
process.exit(1);
|
|
306
362
|
});
|
|
363
|
+
/**
|
|
364
|
+
* One write at a time: the agent's commands, several at once perhaps, and the board's clicks take turns
|
|
365
|
+
* on the record (.arbiter/.lock), so none writes over another.
|
|
366
|
+
*/
|
|
367
|
+
function locked(cwd, fn) {
|
|
368
|
+
return (0, lock_1.withLock)((0, store_1.resolvePaths)((0, store_1.findRoot)(cwd)), fn);
|
|
369
|
+
}
|
|
370
|
+
/** `publish` and `unpublish` report one line per step: name, outcome, why. */
|
|
371
|
+
function printSteps(steps) {
|
|
372
|
+
const w = Math.max(...steps.map((s) => s.step.length));
|
|
373
|
+
for (const s of steps)
|
|
374
|
+
process.stdout.write(` ${s.step.padEnd(w)} ${s.outcome}${s.note ? ` — ${s.note}` : ''}\n`);
|
|
375
|
+
}
|
|
307
376
|
/** With `hosted.auto`, the board follows the record. Prints a line when it does, or why it didn't. */
|
|
308
377
|
async function boardUpdated(cwd) {
|
|
309
378
|
const line = await (0, autopublish_1.autoPublish)(cwd);
|