arbiterdesign 0.1.8 → 0.1.10
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 +288 -242
- 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 +198 -73
- package/dist/commands/invite.js +67 -0
- package/dist/commands/publish.js +4 -4
- package/dist/commands/record.js +133 -8
- package/dist/commands/remove.js +1 -1
- package/dist/commands/rename.js +25 -11
- package/dist/commands/review.js +458 -78
- package/dist/commands/rules.js +22 -3
- package/dist/commands/setup.js +1 -0
- package/dist/commands/snapshot.js +24 -2
- package/dist/commands/sweep.js +1 -1
- package/dist/commands/update.js +5 -0
- package/dist/comments.js +24 -0
- package/dist/format.js +112 -7
- package/dist/handoff.js +286 -0
- package/dist/hook.js +82 -0
- package/dist/hosted.js +50 -17
- package/dist/index.js +99 -37
- 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 +164 -8
- package/dist/verify.js +4 -2
- package/dist/work.js +110 -1
- package/package.json +3 -2
- package/templates/SKILL.md +146 -51
- package/templates/board/board.css +2 -0
- package/templates/board/board.js +25 -0
- package/templates/board/index.html +15 -0
- package/templates/hooks/arbiter-board.cjs +50 -0
- package/templates/review.html +0 -757
package/dist/hook.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The Claude Code hook. Before each message you send, it tells the agent what you've judged on
|
|
4
|
+
* the local board since its last turn that needs the code changed, so the agent makes it then,
|
|
5
|
+
* without waiting for /arbiter. A script in .claude/hooks/ (templates/hooks/arbiter-board.cjs),
|
|
6
|
+
* run by a UserPromptSubmit entry in .claude/settings.json. Claude Code only: Cursor and Codex
|
|
7
|
+
* have no such hook, and pick it up at /arbiter.
|
|
8
|
+
*
|
|
9
|
+
* The script is plain node with nothing to install, since it runs before every message: it reads
|
|
10
|
+
* one file and, nearly always, finds nothing to say.
|
|
11
|
+
*/
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.HOOK_COMMAND = void 0;
|
|
17
|
+
exports.hookInstalled = hookInstalled;
|
|
18
|
+
exports.installHook = installHook;
|
|
19
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
20
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
21
|
+
const SCRIPT = node_path_1.default.join('.claude', 'hooks', 'arbiter-board.cjs');
|
|
22
|
+
const SETTINGS = node_path_1.default.join('.claude', 'settings.json');
|
|
23
|
+
const TEMPLATE = node_path_1.default.join(__dirname, '..', 'templates', 'hooks', 'arbiter-board.cjs');
|
|
24
|
+
/** Claude Code sets the project's root in this; the script finds the board's files from there. */
|
|
25
|
+
exports.HOOK_COMMAND = 'node "$CLAUDE_PROJECT_DIR/.claude/hooks/arbiter-board.cjs"';
|
|
26
|
+
const ours = (e) => (e.hooks ?? []).some((h) => h.command?.includes('arbiter-board.cjs'));
|
|
27
|
+
/** Both halves in place: the script, and the entry that runs it. */
|
|
28
|
+
function hookInstalled(root) {
|
|
29
|
+
if (!node_fs_1.default.existsSync(node_path_1.default.join(root, SCRIPT)))
|
|
30
|
+
return false;
|
|
31
|
+
try {
|
|
32
|
+
const s = JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(root, SETTINGS), 'utf8'));
|
|
33
|
+
return (s.hooks?.UserPromptSubmit ?? []).some(ours);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Write the script, and add the entry to .claude/settings.json beside whatever is there. A
|
|
41
|
+
* settings file that isn't plain JSON is left alone: rewriting it could lose what someone wrote.
|
|
42
|
+
*/
|
|
43
|
+
function installHook(root, rules = 'DECISIONS.md', command = 'npx arbiter') {
|
|
44
|
+
const steps = [];
|
|
45
|
+
const script = node_path_1.default.join(root, SCRIPT);
|
|
46
|
+
// What it tells the agent names the rules file and the command as this project has them.
|
|
47
|
+
const named = node_fs_1.default.readFileSync(TEMPLATE, 'utf8').replace(/\r\n/g, '\n').split('DECISIONS.md').join(rules);
|
|
48
|
+
const content = command === 'npx arbiter' ? named : named.replace(/npx arbiter(?![A-Za-z])/g, command);
|
|
49
|
+
const before = node_fs_1.default.existsSync(script) ? node_fs_1.default.readFileSync(script, 'utf8') : null;
|
|
50
|
+
if (before === content)
|
|
51
|
+
steps.push({ file: '.claude/hooks/arbiter-board.cjs', outcome: 'unchanged' });
|
|
52
|
+
else {
|
|
53
|
+
node_fs_1.default.mkdirSync(node_path_1.default.dirname(script), { recursive: true });
|
|
54
|
+
node_fs_1.default.writeFileSync(script, content);
|
|
55
|
+
steps.push({ file: '.claude/hooks/arbiter-board.cjs', outcome: before === null ? 'created' : 'updated' });
|
|
56
|
+
}
|
|
57
|
+
const file = node_path_1.default.join(root, SETTINGS);
|
|
58
|
+
const exists = node_fs_1.default.existsSync(file);
|
|
59
|
+
let settings = {};
|
|
60
|
+
if (exists) {
|
|
61
|
+
try {
|
|
62
|
+
settings = JSON.parse(node_fs_1.default.readFileSync(file, 'utf8'));
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
steps.push({ file: '.claude/settings.json', outcome: 'skipped', attention: true, note: `not plain JSON, so Arbiter left it alone. Add a UserPromptSubmit hook that runs: ${exports.HOOK_COMMAND}` });
|
|
66
|
+
return steps;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const entries = settings.hooks?.UserPromptSubmit ?? [];
|
|
70
|
+
const mine = entries.find(ours);
|
|
71
|
+
if (mine?.hooks?.some((h) => h.command === exports.HOOK_COMMAND)) {
|
|
72
|
+
steps.push({ file: '.claude/settings.json', outcome: 'unchanged' });
|
|
73
|
+
return steps;
|
|
74
|
+
}
|
|
75
|
+
const entry = { hooks: [{ type: 'command', command: exports.HOOK_COMMAND }] };
|
|
76
|
+
const next = mine ? entries.map((e) => (e === mine ? entry : e)) : [...entries, entry];
|
|
77
|
+
settings = { ...settings, hooks: { ...settings.hooks, UserPromptSubmit: next } };
|
|
78
|
+
node_fs_1.default.mkdirSync(node_path_1.default.dirname(file), { recursive: true });
|
|
79
|
+
node_fs_1.default.writeFileSync(file, JSON.stringify(settings, null, 2) + '\n');
|
|
80
|
+
steps.push({ file: '.claude/settings.json', outcome: exists ? 'updated' : 'created' });
|
|
81
|
+
return steps;
|
|
82
|
+
}
|
package/dist/hosted.js
CHANGED
|
@@ -12,14 +12,12 @@ 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.PASSWORD_MIN = exports.publishable = exports.ADMIN_ENV = exports.TOKEN_ENV = void 0;
|
|
15
|
+
exports.PASSWORD_MIN = exports.publishable = exports.INVITE_ENV = 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;
|
|
24
22
|
exports.newPassword = newPassword;
|
|
25
23
|
exports.publishHosted = publishHosted;
|
|
@@ -27,6 +25,9 @@ exports.pullHosted = pullHosted;
|
|
|
27
25
|
exports.unpublishHosted = unpublishHosted;
|
|
28
26
|
exports.parseBoardLink = parseBoardLink;
|
|
29
27
|
exports.takedownHosted = takedownHosted;
|
|
28
|
+
exports.makeInvite = makeInvite;
|
|
29
|
+
exports.listInvites = listInvites;
|
|
30
|
+
exports.switchOffInvite = switchOffInvite;
|
|
30
31
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
31
32
|
const node_path_1 = __importDefault(require("node:path"));
|
|
32
33
|
const node_crypto_1 = require("node:crypto");
|
|
@@ -34,6 +35,7 @@ const candidates_1 = require("./candidates");
|
|
|
34
35
|
const store_1 = require("./store");
|
|
35
36
|
const work_1 = require("./work");
|
|
36
37
|
const requests_1 = require("./requests");
|
|
38
|
+
const comments_1 = require("./comments");
|
|
37
39
|
/** The link for places that only want to know about the board, where a broken hosted.json shouldn't stop the command. */
|
|
38
40
|
function readLinkOrNull(paths) {
|
|
39
41
|
try {
|
|
@@ -43,11 +45,16 @@ function readLinkOrNull(paths) {
|
|
|
43
45
|
return null;
|
|
44
46
|
}
|
|
45
47
|
}
|
|
48
|
+
// Pulled comments live in their own module; pull writes them, and these names stay here for it.
|
|
49
|
+
var comments_2 = require("./comments");
|
|
50
|
+
Object.defineProperty(exports, "readComments", { enumerable: true, get: function () { return comments_2.readComments; } });
|
|
51
|
+
Object.defineProperty(exports, "writeComments", { enumerable: true, get: function () { return comments_2.writeComments; } });
|
|
46
52
|
const LINK_FILE = 'hosted.json';
|
|
47
53
|
const TOKEN_FILE = 'hosted.token';
|
|
48
|
-
const COMMENTS_FILE = 'comments.json';
|
|
49
54
|
exports.TOKEN_ENV = 'ARBITER_PUBLISH_TOKEN';
|
|
50
55
|
exports.ADMIN_ENV = 'ARBITER_ADMIN_TOKEN';
|
|
56
|
+
/** An invite code for the first publish, instead of --invite. */
|
|
57
|
+
exports.INVITE_ENV = 'ARBITER_INVITE';
|
|
51
58
|
const IMAGE_TYPES = { '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.gif': 'image/gif' };
|
|
52
59
|
function readLink(paths) {
|
|
53
60
|
const f = node_path_1.default.join(paths.archiveDir, LINK_FILE);
|
|
@@ -84,15 +91,6 @@ function writeToken(paths, token) {
|
|
|
84
91
|
lines.push(TOKEN_FILE);
|
|
85
92
|
node_fs_1.default.writeFileSync(gi, lines.join('\n') + '\n');
|
|
86
93
|
}
|
|
87
|
-
function readComments(paths) {
|
|
88
|
-
const f = node_path_1.default.join(paths.archiveDir, COMMENTS_FILE);
|
|
89
|
-
return node_fs_1.default.existsSync(f) ? JSON.parse(node_fs_1.default.readFileSync(f, 'utf8')) : [];
|
|
90
|
-
}
|
|
91
|
-
/** Every comment on file, minus email addresses: nothing here needs them, and the file is committed. */
|
|
92
|
-
function writeComments(paths, comments) {
|
|
93
|
-
const kept = comments.map(({ author_email: _email, ...c }) => c);
|
|
94
|
-
node_fs_1.default.writeFileSync(node_path_1.default.join(paths.archiveDir, COMMENTS_FILE), JSON.stringify(kept, null, 2) + '\n');
|
|
95
|
-
}
|
|
96
94
|
const publishable = (d) => d.verdict !== 'pending' && d.verdict !== 'retire' && d.level !== 'polish';
|
|
97
95
|
exports.publishable = publishable;
|
|
98
96
|
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 });
|
|
@@ -101,6 +99,8 @@ const wire = (d) => ({ id: d.id, change: d.change, decision: d.decision, rejecte
|
|
|
101
99
|
* candidate rides with that screen; the rest are grouped by the piece of work they came from
|
|
102
100
|
* (`trigger`) and become a card each — no picture, state `recorded`. Most work is one direction,
|
|
103
101
|
* iterated; the board shouldn't be empty for it.
|
|
102
|
+
*
|
|
103
|
+
* Only for the team board. The local board builds its own from the same files (src/localboard.ts).
|
|
104
104
|
*/
|
|
105
105
|
function buildManifest(paths, opts = {}) {
|
|
106
106
|
const skipped = [];
|
|
@@ -155,7 +155,7 @@ function buildManifest(paths, opts = {}) {
|
|
|
155
155
|
// Work has no product area of its own; it joins one only when the trigger names an existing one.
|
|
156
156
|
id, name: trigger, feature: areas.get(trigger.toLowerCase()) ?? null, state: 'recorded', work: true,
|
|
157
157
|
author: last.author, date: last.date, reason: null, notes: '', supersededBy: null, url: null, snapshot,
|
|
158
|
-
decisions: ds.map(wire),
|
|
158
|
+
decisions: ds.filter(exports.publishable).map(wire),
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
161
|
// The day each became a rule, for the board's Design rules page.
|
|
@@ -216,6 +216,8 @@ function newPassword() {
|
|
|
216
216
|
* readable without it. Keeps every request under Vercel's 4.5 MB body cap however many screens there are.
|
|
217
217
|
*
|
|
218
218
|
* `password`: a string sets it, null takes it off, left out leaves it as it is.
|
|
219
|
+
* `invite`: the code a new board needs while the service is invite-only. Only the first publish sends
|
|
220
|
+
* it; after that the publish token does, so it's never saved.
|
|
219
221
|
*/
|
|
220
222
|
async function publishHosted(paths, serviceUrl, opts = {}) {
|
|
221
223
|
const base = serviceUrl.replace(/\/$/, '');
|
|
@@ -228,9 +230,16 @@ async function publishHosted(paths, serviceUrl, opts = {}) {
|
|
|
228
230
|
throw new Error(`no .arbiter/hosted.json for ${base} — publish once from a laptop and commit that file, so CI updates the existing board instead of creating a new one`);
|
|
229
231
|
}
|
|
230
232
|
const admin = opts.admin ?? process.env[exports.ADMIN_ENV];
|
|
231
|
-
const
|
|
233
|
+
const invite = (opts.invite ?? process.env[exports.INVITE_ENV])?.trim() || undefined;
|
|
234
|
+
const r = await api(`${base}/api/projects`, { method: 'POST', body: JSON.stringify({ name: node_path_1.default.basename(paths.root), ...(invite ? { invite } : {}) }), admin });
|
|
232
235
|
if (r.status === 401)
|
|
233
236
|
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>`);
|
|
237
|
+
// Invite-only: the service says why, and where to ask. Asked without a code, say how to use one.
|
|
238
|
+
if (r.status === 403 && typeof r.body.error === 'string') {
|
|
239
|
+
// A self-hosted server is named again in the line, so the command works as typed.
|
|
240
|
+
const to = base === 'https://arbiter.design' ? '' : ` --to ${base}`;
|
|
241
|
+
throw new Error(r.body.invite === 'required' ? `${r.body.error}\n With an invite code: npx arbiter publish --invite <code>${to}` : r.body.error);
|
|
242
|
+
}
|
|
234
243
|
// The service says which limit it was: this network's, or everyone's.
|
|
235
244
|
if (r.status === 429)
|
|
236
245
|
throw new Error(typeof r.body.error === 'string' ? r.body.error : `${base} is busy right now — try again in an hour`);
|
|
@@ -303,14 +312,14 @@ async function pullHosted(paths) {
|
|
|
303
312
|
// What's on file keeps its words, but takes the board's card: a renamed piece of work's comments
|
|
304
313
|
// move there at publish, and a copy pulled before that would still point at the old card.
|
|
305
314
|
const onBoard = new Map(current.map((c) => [c.id, c]));
|
|
306
|
-
const existing = readComments(paths).map((c) => {
|
|
315
|
+
const existing = (0, comments_1.readComments)(paths).map((c) => {
|
|
307
316
|
const now = onBoard.get(c.id);
|
|
308
317
|
return now && now.candidate_id !== c.candidate_id ? { ...c, candidate_id: now.candidate_id } : c;
|
|
309
318
|
});
|
|
310
319
|
const seen = new Set(existing.map((c) => c.id));
|
|
311
320
|
const fresh = current.filter((c) => !seen.has(c.id));
|
|
312
321
|
const merged = [...existing, ...fresh].sort((a, b) => String(a.created_at ?? '').localeCompare(String(b.created_at ?? '')));
|
|
313
|
-
writeComments(paths, merged);
|
|
322
|
+
(0, comments_1.writeComments)(paths, merged);
|
|
314
323
|
// hosted.json is committed: rewrite it only when the board has moved on, or every pull on every
|
|
315
324
|
// machine would leave it changed, and two of them would conflict.
|
|
316
325
|
const boardVersion = r.body.board_version ?? link.boardVersion ?? null;
|
|
@@ -376,3 +385,27 @@ async function takedownHosted(link, admin) {
|
|
|
376
385
|
throw new Error(`delete failed: ${r.body.error ?? r.status}. Nothing was deleted.`);
|
|
377
386
|
return { shareUrl: board.shareUrl, pictures: Number(r.body.pictures ?? 0), comments: Number(r.body.comments ?? 0) };
|
|
378
387
|
}
|
|
388
|
+
async function inviteCall(base, admin, route, init = {}) {
|
|
389
|
+
const r = await api(`${base}${route}`, { ...init, admin });
|
|
390
|
+
if (r.status === 401)
|
|
391
|
+
throw new Error(`${base} refused the admin token (${exports.ADMIN_ENV})`);
|
|
392
|
+
// An older service has no invites at all: Next answers its unknown routes with a 404 page, not JSON.
|
|
393
|
+
if (r.status === 404 && typeof r.body.error !== 'string')
|
|
394
|
+
throw new Error(`${base} doesn't do invites yet: it runs an older Arbiter than this one`);
|
|
395
|
+
if (!r.ok)
|
|
396
|
+
throw new Error(String(r.body.error ?? r.status));
|
|
397
|
+
return r.body;
|
|
398
|
+
}
|
|
399
|
+
/** A new invite. Its code comes back this once; the service keeps only a hash. */
|
|
400
|
+
async function makeInvite(base, admin, opts = {}) {
|
|
401
|
+
const b = await inviteCall(base, admin, '/api/invites', { method: 'POST', body: JSON.stringify({ note: opts.note ?? '', ...(opts.boards !== undefined ? { boards: opts.boards } : {}) }) });
|
|
402
|
+
return { id: String(b.id), code: String(b.code), note: String(b.note ?? ''), boards: Number(b.boards) };
|
|
403
|
+
}
|
|
404
|
+
async function listInvites(base, admin) {
|
|
405
|
+
return ((await inviteCall(base, admin, '/api/invites')).invites ?? []);
|
|
406
|
+
}
|
|
407
|
+
/** It makes no more boards. Boards it made stay up. */
|
|
408
|
+
async function switchOffInvite(base, admin, id) {
|
|
409
|
+
const b = await inviteCall(base, admin, `/api/invites/${encodeURIComponent(id)}`, { method: 'DELETE' });
|
|
410
|
+
return { note: typeof b.note === 'string' ? b.note : null, already: !!b.already };
|
|
411
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -13,17 +13,22 @@ const export_1 = require("./commands/export");
|
|
|
13
13
|
const publish_1 = require("./commands/publish");
|
|
14
14
|
const unpublish_1 = require("./commands/unpublish");
|
|
15
15
|
const rename_1 = require("./commands/rename");
|
|
16
|
+
const areas_1 = require("./commands/areas");
|
|
16
17
|
const pull_1 = require("./commands/pull");
|
|
17
18
|
const snapshot_1 = require("./commands/snapshot");
|
|
18
19
|
const setup_1 = require("./commands/setup");
|
|
19
20
|
const rules_1 = require("./commands/rules");
|
|
20
21
|
const init_1 = require("./commands/init");
|
|
21
22
|
const review_1 = require("./commands/review");
|
|
23
|
+
const handoff_1 = require("./handoff");
|
|
22
24
|
const update_1 = require("./commands/update");
|
|
23
25
|
const remove_1 = require("./commands/remove");
|
|
24
26
|
const autopublish_1 = require("./autopublish");
|
|
25
27
|
const hosted_1 = require("./hosted");
|
|
28
|
+
const invite_1 = require("./commands/invite");
|
|
26
29
|
const store_1 = require("./store");
|
|
30
|
+
const hook_1 = require("./hook");
|
|
31
|
+
const lock_1 = require("./lock");
|
|
27
32
|
const program = new commander_1.Command();
|
|
28
33
|
program
|
|
29
34
|
.name('arbiter')
|
|
@@ -43,7 +48,7 @@ program
|
|
|
43
48
|
.option('--as <action>', 'judge a pending id: accept | rule | skip | fix; answer a request id: apply | decline')
|
|
44
49
|
.option('--request <id>', 'the approved request (R-0001) this change was made for — recording it applies the request')
|
|
45
50
|
.option('--all', 'with --as: judge every pending item the same way')
|
|
46
|
-
.option('--level <level>', 'with --all: only this level (feature | pattern
|
|
51
|
+
.option('--level <level>', 'with --all: only this level (feature | pattern)')
|
|
47
52
|
.option('--trigger <text>', 'with --all: only items queued for this piece of work')
|
|
48
53
|
.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')
|
|
49
54
|
.option('--supersedes <id>', 'the active rule this one replaces')
|
|
@@ -55,13 +60,13 @@ program
|
|
|
55
60
|
.action(async (arg, opts) => {
|
|
56
61
|
let result;
|
|
57
62
|
if (opts.retire) {
|
|
58
|
-
result = (0, record_1.retire)(opts.retire, opts.why, opts);
|
|
63
|
+
result = locked(opts.cwd, () => (0, record_1.retire)(opts.retire, opts.why, opts));
|
|
59
64
|
}
|
|
60
65
|
else if (opts.reword) {
|
|
61
|
-
result = (0, record_1.reword)(opts.reword, opts.to, opts);
|
|
66
|
+
result = locked(opts.cwd, () => (0, record_1.reword)(opts.reword, opts.to, opts));
|
|
62
67
|
}
|
|
63
68
|
else if (opts.findings) {
|
|
64
|
-
result = (0, record_1.queueFindings)(opts.findings, opts);
|
|
69
|
+
result = locked(opts.cwd, () => (0, record_1.queueFindings)(opts.findings, opts));
|
|
65
70
|
}
|
|
66
71
|
else if (opts.all) {
|
|
67
72
|
const as = opts.as;
|
|
@@ -69,7 +74,7 @@ program
|
|
|
69
74
|
result = { exitCode: 1, output: { status: 'invalid', errors: ['--all needs --as accept | rule | skip'] } };
|
|
70
75
|
}
|
|
71
76
|
else {
|
|
72
|
-
result = (0, record_1.judgeAll)({ ...opts, as });
|
|
77
|
+
result = locked(opts.cwd, () => (0, record_1.judgeAll)({ ...opts, as }));
|
|
73
78
|
}
|
|
74
79
|
}
|
|
75
80
|
else if (arg && /^P-\d{4,}$/.test(arg)) {
|
|
@@ -78,7 +83,7 @@ program
|
|
|
78
83
|
result = { exitCode: 1, output: { status: 'invalid', errors: ['judging a pending id needs --as accept | rule | skip | fix'] } };
|
|
79
84
|
}
|
|
80
85
|
else {
|
|
81
|
-
result = (0, record_1.judge)(arg, { ...opts, as });
|
|
86
|
+
result = locked(opts.cwd, () => (0, record_1.judge)(arg, { ...opts, as }));
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
89
|
else if (arg && /^R-\d{4,}$/.test(arg)) {
|
|
@@ -87,7 +92,7 @@ program
|
|
|
87
92
|
result = { exitCode: 1, output: { status: 'invalid', errors: ['answering a request needs --as apply (Apply, but…: add --to "<instead>") | decline --why "<reason>"'] } };
|
|
88
93
|
}
|
|
89
94
|
else {
|
|
90
|
-
result = (0, request_1.judgeRequest)(arg, { ...opts, as });
|
|
95
|
+
result = locked(opts.cwd, () => (0, request_1.judgeRequest)(arg, { ...opts, as }));
|
|
91
96
|
}
|
|
92
97
|
}
|
|
93
98
|
else {
|
|
@@ -98,9 +103,9 @@ program
|
|
|
98
103
|
process.stdout.write(JSON.stringify({ status: 'invalid', errors: ['no input — pass JSON as an argument or on stdin'] }, null, 2) + '\n');
|
|
99
104
|
process.exit(1);
|
|
100
105
|
}
|
|
101
|
-
result = opts.pending ? (0, record_1.queue)(input, opts) : (0, record_1.record)(input, opts);
|
|
106
|
+
result = (0, record_1.oneOffGate)(input) ?? locked(opts.cwd, () => (opts.pending ? (0, record_1.queue)(input, opts) : (0, record_1.record)(input, opts)));
|
|
102
107
|
}
|
|
103
|
-
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
108
|
+
process.stdout.write(JSON.stringify(withNotices(result.output), null, 2) + '\n');
|
|
104
109
|
// Queueing never reaches the board — work cards are built from judged decisions.
|
|
105
110
|
if (result.exitCode === 0 && !opts.pending)
|
|
106
111
|
await boardUpdated(opts.cwd);
|
|
@@ -115,15 +120,17 @@ program
|
|
|
115
120
|
.option('--checkin <mode>', 'how Arbiter checks in while you work: feature | quiet | every (default: asked)')
|
|
116
121
|
.option('-y, --yes', 'no questions — use detected values')
|
|
117
122
|
.option('--skip-install', 'do not add the package to devDependencies')
|
|
123
|
+
.option('--verbose', 'list every file install wrote or left alone')
|
|
118
124
|
.action(async (opts) => {
|
|
125
|
+
const root = process.cwd();
|
|
119
126
|
const steps = await (0, init_1.init)(opts);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
+
// An agent ran it: nobody saw any of this, so the agent says it in chat, and asks what install couldn't.
|
|
128
|
+
const config = (0, store_1.readConfig)((0, store_1.resolvePaths)(root));
|
|
129
|
+
const rules = (0, store_1.rulesName)((0, store_1.resolvePaths)(root));
|
|
130
|
+
const theirs = steps.some((s) => s.file === 'DECISIONS.md' && s.note?.startsWith('yours')) && steps.some((s) => s.file === rules && s.outcome === 'created');
|
|
131
|
+
const handoff = !config?.onboarded ? (0, init_1.checkinHandoff)(theirs ? (0, store_1.rulesMovedLine)(rules) : undefined)
|
|
132
|
+
: theirs && !process.stdin.isTTY ? (0, init_1.checkinHandoff)((0, store_1.rulesMovedLine)(rules), false) : '';
|
|
133
|
+
process.stdout.write('\n' + (0, init_1.installReport)(root, steps, { verbose: !!opts.verbose, closing: !handoff }) + handoff);
|
|
127
134
|
if (opts.destination === 'git') {
|
|
128
135
|
process.stdout.write([
|
|
129
136
|
'',
|
|
@@ -150,7 +157,7 @@ program
|
|
|
150
157
|
.option('--author <name>', 'author for queued items')
|
|
151
158
|
.option('--json', 'machine-readable output')
|
|
152
159
|
.action((id, opts) => {
|
|
153
|
-
const r = (0, sweep_1.sweepCommand)(id, opts);
|
|
160
|
+
const r = opts.queue ? locked(opts.cwd, () => (0, sweep_1.sweepCommand)(id, opts)) : (0, sweep_1.sweepCommand)(id, opts);
|
|
154
161
|
process.stdout.write(r.text + '\n');
|
|
155
162
|
});
|
|
156
163
|
program
|
|
@@ -159,8 +166,8 @@ program
|
|
|
159
166
|
.option('--checkin <mode>', 'feature | quiet | every')
|
|
160
167
|
.option('--app <url>', 'where the app runs, for screenshots: http://localhost:3000 or a staging address (on its own, saves only this)')
|
|
161
168
|
.action((opts) => {
|
|
162
|
-
const result = (0, setup_1.setup)(opts);
|
|
163
|
-
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
169
|
+
const result = locked(opts.cwd, () => (0, setup_1.setup)(opts));
|
|
170
|
+
process.stdout.write(JSON.stringify(withNotices(result.output), null, 2) + '\n');
|
|
164
171
|
process.exit(result.exitCode);
|
|
165
172
|
});
|
|
166
173
|
program
|
|
@@ -169,8 +176,8 @@ program
|
|
|
169
176
|
.option('--file <image>', 'screenshot to keep beside the work')
|
|
170
177
|
.option('--capture', 'macOS: drag-select a region of the screen')
|
|
171
178
|
.action(async (work, opts) => {
|
|
172
|
-
const result = (0, snapshot_1.snapshotWork)(work, opts);
|
|
173
|
-
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
179
|
+
const result = locked(opts.cwd, () => (0, snapshot_1.snapshotWork)(work, opts));
|
|
180
|
+
process.stdout.write(JSON.stringify(withNotices(result.output), null, 2) + '\n');
|
|
174
181
|
if (result.exitCode === 0)
|
|
175
182
|
await boardUpdated(opts.cwd);
|
|
176
183
|
process.exit(result.exitCode);
|
|
@@ -188,8 +195,8 @@ program
|
|
|
188
195
|
.option('--keep-others', "approving doesn't supersede sibling directions")
|
|
189
196
|
.option('--author <name>', 'override the author')
|
|
190
197
|
.action(async (idOrAdd, name, opts) => {
|
|
191
|
-
const result = idOrAdd === 'add' ? (0, candidate_1.addCandidate)(name ?? '', opts) : (0, candidate_1.updateCandidate)(idOrAdd, opts);
|
|
192
|
-
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
198
|
+
const result = locked(opts.cwd, () => (idOrAdd === 'add' ? (0, candidate_1.addCandidate)(name ?? '', opts) : (0, candidate_1.updateCandidate)(idOrAdd, opts)));
|
|
199
|
+
process.stdout.write(JSON.stringify(withNotices(result.output), null, 2) + '\n');
|
|
193
200
|
if (result.exitCode === 0)
|
|
194
201
|
await boardUpdated(opts.cwd);
|
|
195
202
|
process.exit(result.exitCode);
|
|
@@ -212,19 +219,20 @@ program
|
|
|
212
219
|
});
|
|
213
220
|
program
|
|
214
221
|
.command('export')
|
|
215
|
-
.description('Write a
|
|
222
|
+
.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.')
|
|
216
223
|
.option('--out <dir>', 'output folder (default: arbiter-export)')
|
|
217
224
|
.option('--feature <name>', 'one feature only')
|
|
218
|
-
.option('--include-rules', '
|
|
225
|
+
.option('--include-rules', 'add the design rules page')
|
|
219
226
|
.option('--open', 'open it in the browser')
|
|
220
227
|
.action((opts) => {
|
|
221
228
|
const r = (0, export_1.exportBoard)(opts);
|
|
222
|
-
process.stdout.write(`Exported ${r.candidates}
|
|
229
|
+
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`);
|
|
223
230
|
});
|
|
224
231
|
program
|
|
225
232
|
.command('publish')
|
|
226
|
-
.description('Put the board online at arbiter.design and print the link. --to <url> for your own hosted Arbiter; --to pages for GitHub Pages (git destination, export, commit, push).
|
|
233
|
+
.description('Put the board online at arbiter.design and print the link. Arbiter Team is in early access, by invitation: a new board\'s first publish needs --invite <code> (arbiter.design/plans). For a read-only copy anyone can open, use export. --to <url> for your own hosted Arbiter; --to pages for GitHub Pages (git destination, export, commit, push).')
|
|
227
234
|
.option('--to <url|pages>', 'where to publish: a hosted Arbiter (default arbiter.design), or `pages` for GitHub Pages')
|
|
235
|
+
.option('--invite <code>', `your invite code, for the first publish only (or set ${hosted_1.INVITE_ENV}); later publishes don't need it`)
|
|
228
236
|
.option('--admin-token <token>', 'only for a self-hosted Arbiter that gates board creation')
|
|
229
237
|
.option('--no-push', 'GitHub Pages mode: do everything except push')
|
|
230
238
|
.option('--on-push', 'also write a GitHub Actions workflow that republishes on every push, and set its secret')
|
|
@@ -233,7 +241,7 @@ program
|
|
|
233
241
|
.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')
|
|
234
242
|
.option('--no-password', 'take the password off: anyone with the link can see the board')
|
|
235
243
|
.action(async (opts) => {
|
|
236
|
-
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 });
|
|
244
|
+
const r = await (0, publish_1.publish)({ noPush: opts.push === false, to: opts.to, admin: opts.adminToken, invite: opts.invite, onPush: opts.onPush, auto: opts.auto === undefined ? undefined : !!opts.auto, password: opts.password });
|
|
237
245
|
printSteps(r.steps);
|
|
238
246
|
if (r.url)
|
|
239
247
|
process.stdout.write(`\n${r.ok ? 'Live in about a minute' : 'Once the failed step is fixed'}: ${r.url}\n`);
|
|
@@ -249,12 +257,37 @@ program
|
|
|
249
257
|
printSteps(r.steps);
|
|
250
258
|
process.exit(r.ok ? 0 : 1);
|
|
251
259
|
});
|
|
260
|
+
// Only for whoever runs the server, so it stays out of --help.
|
|
261
|
+
program
|
|
262
|
+
.command('invite [note]', { hidden: true })
|
|
263
|
+
.description(`Make an invite to Arbiter Team, which is in early access, by invitation: a code good for 1 board, shown once. Needs the server's admin token in ${hosted_1.ADMIN_ENV}.`)
|
|
264
|
+
.option('--boards <n>', 'how many boards it can make (default 1)')
|
|
265
|
+
.option('--list', 'every invite: who it is for, boards made and left')
|
|
266
|
+
.option('--off <id>', 'switch an invite off: it makes no more boards; the boards it made stay up')
|
|
267
|
+
.option('--to <url>', 'the server (default arbiter.design)')
|
|
268
|
+
.option('--json', 'print JSON')
|
|
269
|
+
.action(async (note, opts) => {
|
|
270
|
+
const r = await (0, invite_1.invite)(note, opts);
|
|
271
|
+
(r.ok ? process.stdout : process.stderr).write(r.out + '\n');
|
|
272
|
+
process.exit(r.ok ? 0 : 1);
|
|
273
|
+
});
|
|
274
|
+
program
|
|
275
|
+
.command('areas')
|
|
276
|
+
.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.')
|
|
277
|
+
.option('--json', 'print it as JSON')
|
|
278
|
+
.option('--save <json>', 'replace the folders: {"folders":[{"name":"Local board","areas":["Review inbox","Change page"]}]}')
|
|
279
|
+
.action((opts) => {
|
|
280
|
+
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 });
|
|
281
|
+
process.stdout.write(result.exitCode !== 0 || opts.json ? JSON.stringify(withNotices(result.output), null, 2) + '\n' : `${result.text}\n`);
|
|
282
|
+
process.exit(result.exitCode);
|
|
283
|
+
});
|
|
252
284
|
program
|
|
253
285
|
.command('rename <work> <new-name>')
|
|
254
286
|
.description('Rename a piece of work everywhere the record keeps it. Its comments on the board follow it at the next publish.')
|
|
287
|
+
.option('--merge', 'the new name is a piece of work that already exists: this one joins it, decisions, pictures and comments')
|
|
255
288
|
.action(async (work, newName, opts) => {
|
|
256
|
-
const result = (0, rename_1.renameWork)(work, newName, opts);
|
|
257
|
-
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
289
|
+
const result = locked(opts.cwd, () => (0, rename_1.renameWork)(work, newName, opts));
|
|
290
|
+
process.stdout.write(JSON.stringify(withNotices(result.output), null, 2) + '\n');
|
|
258
291
|
if (result.exitCode === 0)
|
|
259
292
|
await boardUpdated(opts.cwd);
|
|
260
293
|
process.exit(result.exitCode);
|
|
@@ -267,11 +300,25 @@ program
|
|
|
267
300
|
});
|
|
268
301
|
program
|
|
269
302
|
.command('review')
|
|
270
|
-
.description('Open
|
|
271
|
-
.option('--port <n>',
|
|
303
|
+
.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.')
|
|
304
|
+
.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))
|
|
272
305
|
.option('--no-open', "print the URL, don't open a browser")
|
|
306
|
+
.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")
|
|
307
|
+
.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')
|
|
273
308
|
.action(async (opts) => {
|
|
274
|
-
|
|
309
|
+
if (opts.done) {
|
|
310
|
+
const r = locked(opts.cwd, () => (0, handoff_1.handoffDone)((0, store_1.resolvePaths)((0, store_1.findRoot)(opts.cwd))));
|
|
311
|
+
process.stdout.write(JSON.stringify(r, null, 2) + '\n');
|
|
312
|
+
process.exit(r.status === 'not-taken' ? 1 : 0);
|
|
313
|
+
}
|
|
314
|
+
const handoff = await (0, review_1.review)(opts);
|
|
315
|
+
if (opts.json)
|
|
316
|
+
process.stdout.write(JSON.stringify(handoff, null, 2) + '\n');
|
|
317
|
+
else {
|
|
318
|
+
const line = (0, handoff_1.handoffLine)(handoff, (0, hook_1.hookInstalled)((0, store_1.findRoot)()) ? 'with your next message' : 'at the next /arbiter');
|
|
319
|
+
if (line)
|
|
320
|
+
process.stdout.write(line + '\n');
|
|
321
|
+
}
|
|
275
322
|
});
|
|
276
323
|
program
|
|
277
324
|
.command('remove [id]')
|
|
@@ -279,8 +326,8 @@ program
|
|
|
279
326
|
.option('--snapshot <work>', 'remove the picture attached to a piece of work or a screen, keeping the record')
|
|
280
327
|
.option('--force', 'with a screen: unlink the decisions on it rather than refusing')
|
|
281
328
|
.action(async (id, opts) => {
|
|
282
|
-
const result = opts.snapshot ? (0, remove_1.removeSnapshot)(opts.snapshot, opts) : (0, remove_1.remove)(id ?? '', opts);
|
|
283
|
-
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
329
|
+
const result = locked(opts.cwd, () => (opts.snapshot ? (0, remove_1.removeSnapshot)(opts.snapshot, opts) : (0, remove_1.remove)(id ?? '', opts)));
|
|
330
|
+
process.stdout.write(JSON.stringify(withNotices(result.output), null, 2) + '\n');
|
|
284
331
|
if (result.exitCode === 0)
|
|
285
332
|
await boardUpdated(opts.cwd);
|
|
286
333
|
process.exit(result.exitCode);
|
|
@@ -289,8 +336,8 @@ program
|
|
|
289
336
|
.command('unlink <ids...>')
|
|
290
337
|
.description('Detach decisions from the screen they were recorded against. The decisions stay exactly as they are.')
|
|
291
338
|
.action(async (ids, opts) => {
|
|
292
|
-
const result = (0, remove_1.unlink)(ids, opts);
|
|
293
|
-
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
339
|
+
const result = locked(opts.cwd, () => (0, remove_1.unlink)(ids, opts));
|
|
340
|
+
process.stdout.write(JSON.stringify(withNotices(result.output), null, 2) + '\n');
|
|
294
341
|
if (result.exitCode === 0)
|
|
295
342
|
await boardUpdated(opts.cwd);
|
|
296
343
|
process.exit(result.exitCode);
|
|
@@ -331,6 +378,21 @@ program.parseAsync(process.argv).catch((e) => {
|
|
|
331
378
|
process.stderr.write(`arbiter: ${e.message}\n`);
|
|
332
379
|
process.exit(1);
|
|
333
380
|
});
|
|
381
|
+
/**
|
|
382
|
+
* One write at a time: the agent's commands, several at once perhaps, and the board's clicks take turns
|
|
383
|
+
* on the record (.arbiter/.lock), so none writes over another.
|
|
384
|
+
*/
|
|
385
|
+
function locked(cwd, fn) {
|
|
386
|
+
return (0, lock_1.withLock)((0, store_1.resolvePaths)((0, store_1.findRoot)(cwd)), fn);
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* A command's JSON, with what the agent has to pass on: when this command found the project's own
|
|
390
|
+
* DECISIONS.md and moved the rules to a file of their own, `rulesFile.say` is the line to tell the user.
|
|
391
|
+
*/
|
|
392
|
+
function withNotices(output) {
|
|
393
|
+
const moved = (0, store_1.takeRulesMoved)();
|
|
394
|
+
return moved ? { ...output, rulesFile: moved } : output;
|
|
395
|
+
}
|
|
334
396
|
/** `publish` and `unpublish` report one line per step: name, outcome, why. */
|
|
335
397
|
function printSteps(steps) {
|
|
336
398
|
const w = Math.max(...steps.map((s) => s.step.length));
|