arbiterdesign 0.1.7 → 0.1.8

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/dist/hosted.js CHANGED
@@ -12,7 +12,7 @@ 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 = void 0;
16
16
  exports.readLinkOrNull = readLinkOrNull;
17
17
  exports.readLink = readLink;
18
18
  exports.writeLink = writeLink;
@@ -21,10 +21,15 @@ exports.writeToken = writeToken;
21
21
  exports.readComments = readComments;
22
22
  exports.writeComments = writeComments;
23
23
  exports.buildManifest = buildManifest;
24
+ exports.newPassword = newPassword;
24
25
  exports.publishHosted = publishHosted;
25
26
  exports.pullHosted = pullHosted;
27
+ exports.unpublishHosted = unpublishHosted;
28
+ exports.parseBoardLink = parseBoardLink;
29
+ exports.takedownHosted = takedownHosted;
26
30
  const node_fs_1 = __importDefault(require("node:fs"));
27
31
  const node_path_1 = __importDefault(require("node:path"));
32
+ const node_crypto_1 = require("node:crypto");
28
33
  const candidates_1 = require("./candidates");
29
34
  const store_1 = require("./store");
30
35
  const work_1 = require("./work");
@@ -173,7 +178,11 @@ function buildManifest(paths, opts = {}) {
173
178
  return d ? [{ id: d.id, change: d.change ?? d.decision, card: (0, requests_1.cardOf)(paths, d, ids) }] : [];
174
179
  }),
175
180
  }));
176
- return { manifest: { project: node_path_1.default.basename(paths.root), exported: new Date().toISOString().slice(0, 10), candidates, rules, requests }, skipped };
181
+ // Renamed pieces of work, so the board moves their comments. Not one whose old name is a card again:
182
+ // the board would move the new card's comments away to the old one's new name.
183
+ const live = new Set(candidates.map((c) => c.id));
184
+ const renamed = (0, work_1.readRenames)(paths).filter((r) => !live.has(r.from));
185
+ return { manifest: { project: node_path_1.default.basename(paths.root), exported: new Date().toISOString().slice(0, 10), candidates, rules, requests, renamed }, skipped };
177
186
  }
178
187
  async function api(url, init = {}) {
179
188
  const headers = { 'content-type': 'application/json', ...init.headers };
@@ -190,9 +199,23 @@ async function api(url, init = {}) {
190
199
  catch { /* non-json error */ }
191
200
  return { ok: res.ok, status: res.status, body };
192
201
  }
202
+ /** The service's own floor for a board password. */
203
+ exports.PASSWORD_MIN = 8;
193
204
  /**
194
- * Create the project on first publish; then the images, one request each; then the board.
195
- * Keeps every request under Vercel's 4.5 MB body cap however many screens there are.
205
+ * A password nobody will guess: 12 characters from 31 that can't be misread (no 0/o, 1/l/i), in
206
+ * three groups so it can be read out. About 59 bits.
207
+ */
208
+ function newPassword() {
209
+ const abc = 'abcdefghjkmnpqrstuvwxyz23456789';
210
+ const pick = () => Array.from({ length: 4 }, () => abc[(0, node_crypto_1.randomInt)(abc.length)]).join('');
211
+ return `${pick()}-${pick()}-${pick()}`;
212
+ }
213
+ /**
214
+ * Create the project on first publish; then the password, if one was given; then the images, one
215
+ * request each; then the board. The password goes before anything else, so a new board is never
216
+ * readable without it. Keeps every request under Vercel's 4.5 MB body cap however many screens there are.
217
+ *
218
+ * `password`: a string sets it, null takes it off, left out leaves it as it is.
196
219
  */
197
220
  async function publishHosted(paths, serviceUrl, opts = {}) {
198
221
  const base = serviceUrl.replace(/\/$/, '');
@@ -208,8 +231,9 @@ async function publishHosted(paths, serviceUrl, opts = {}) {
208
231
  const r = await api(`${base}/api/projects`, { method: 'POST', body: JSON.stringify({ name: node_path_1.default.basename(paths.root) }), admin });
209
232
  if (r.status === 401)
210
233
  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>`);
234
+ // The service says which limit it was: this network's, or everyone's.
211
235
  if (r.status === 429)
212
- throw new Error(`${base} is busy right now — try again in an hour`);
236
+ throw new Error(typeof r.body.error === 'string' ? r.body.error : `${base} is busy right now — try again in an hour`);
213
237
  if (!r.ok)
214
238
  throw new Error(`could not create project on ${base}: ${r.body.error ?? r.status}`);
215
239
  link = { url: base, projectId: String(r.body.id), slug: String(r.body.slug), shareUrl: String(r.body.url) };
@@ -220,6 +244,15 @@ async function publishHosted(paths, serviceUrl, opts = {}) {
220
244
  const token = readToken(paths);
221
245
  if (!token)
222
246
  throw new Error(`no publish token for ${link.shareUrl}. Teammate? Get it from whoever first published, then: ${exports.TOKEN_ENV}=<token> npx arbiter publish`);
247
+ if (opts.password !== undefined) {
248
+ const pw = await api(`${base}/api/projects/${link.projectId}/password`, { method: 'PUT', body: JSON.stringify({ password: opts.password }), token });
249
+ if (pw.status === 401)
250
+ throw new Error(`the publish token was refused by ${base} — wrong ${exports.TOKEN_ENV}, or the project was deleted`);
251
+ if (pw.status === 404 || pw.status === 405)
252
+ throw new Error(`${base} doesn't take board passwords yet — it runs an older Arbiter than this one. Nothing was published.`);
253
+ if (!pw.ok)
254
+ throw new Error(`password not ${opts.password === null ? 'removed' : 'set'}: ${pw.body.error ?? pw.status}. Nothing was published.`);
255
+ }
223
256
  const config = (0, store_1.readConfig)(paths);
224
257
  const { manifest, skipped } = buildManifest(paths, { includeRules: !!(config?.pages && config.pages.includeRules) });
225
258
  let snapshots = 0;
@@ -229,6 +262,13 @@ async function publishHosted(paths, serviceUrl, opts = {}) {
229
262
  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
263
  if (up.status === 401)
231
264
  throw new Error(`the publish token was refused by ${base} — wrong ${exports.TOKEN_ENV}, or the project was deleted`);
265
+ // The board, or the whole service, is out of room for pictures. The rest of the board is still
266
+ // worth publishing: this card goes up without its picture, and the reason is reported.
267
+ if (up.status === 413 || up.status === 507) {
268
+ skipped.push(`${c.id}: not uploaded — ${up.body.error ?? 'no room for it'}`);
269
+ c.snapshot = null;
270
+ continue;
271
+ }
232
272
  if (!up.ok)
233
273
  throw new Error(`${c.id}: snapshot upload failed: ${up.body.error ?? up.status}`);
234
274
  c.snapshot = String(up.body.url);
@@ -260,7 +300,13 @@ async function pullHosted(paths) {
260
300
  if (!Array.isArray(r.body.comments))
261
301
  throw new Error('pull failed: the board sent no comment list');
262
302
  const current = r.body.comments;
263
- const existing = readComments(paths);
303
+ // What's on file keeps its words, but takes the board's card: a renamed piece of work's comments
304
+ // move there at publish, and a copy pulled before that would still point at the old card.
305
+ const onBoard = new Map(current.map((c) => [c.id, c]));
306
+ const existing = readComments(paths).map((c) => {
307
+ const now = onBoard.get(c.id);
308
+ return now && now.candidate_id !== c.candidate_id ? { ...c, candidate_id: now.candidate_id } : c;
309
+ });
264
310
  const seen = new Set(existing.map((c) => c.id));
265
311
  const fresh = current.filter((c) => !seen.has(c.id));
266
312
  const merged = [...existing, ...fresh].sort((a, b) => String(a.created_at ?? '').localeCompare(String(b.created_at ?? '')));
@@ -274,3 +320,59 @@ async function pullHosted(paths) {
274
320
  }
275
321
  return { link, fresh, current, total: merged.length };
276
322
  }
323
+ /**
324
+ * Delete the board from the service: the board, its pictures, every comment. Comments are pulled
325
+ * into .arbiter/comments.json first, so nothing said on the board is lost with it. Then the link
326
+ * goes, so nothing here publishes to a board that no longer exists.
327
+ */
328
+ async function unpublishHosted(paths) {
329
+ const link = readLink(paths);
330
+ if (!link)
331
+ throw new Error('this project has no hosted board (.arbiter/hosted.json)');
332
+ const token = readToken(paths);
333
+ if (!token)
334
+ 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`);
335
+ const { total } = await pullHosted(paths);
336
+ const r = await api(`${link.url}/api/projects/${link.projectId}`, { method: 'DELETE', token });
337
+ if (r.status === 401)
338
+ 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.`);
339
+ if (r.status === 404 || r.status === 405)
340
+ throw new Error(`${link.url} can't delete boards yet — it runs an older Arbiter than this one. Nothing was deleted.`);
341
+ if (!r.ok)
342
+ throw new Error(`delete failed: ${r.body.error ?? r.status}. Nothing here was changed.`);
343
+ for (const f of [LINK_FILE, TOKEN_FILE])
344
+ node_fs_1.default.rmSync(node_path_1.default.join(paths.archiveDir, f), { force: true });
345
+ return { link, saved: total, pictures: Number(r.body.pictures ?? 0), comments: Number(r.body.comments ?? 0) };
346
+ }
347
+ /** The share link of a board, from any page on it: `https://arbiter.design/p/abc123/c/C-0001` is board abc123. */
348
+ function parseBoardLink(link) {
349
+ let u;
350
+ try {
351
+ u = new URL(link);
352
+ }
353
+ catch {
354
+ return null;
355
+ }
356
+ const slug = u.pathname.match(/^\/p\/([a-z0-9]+)(?:\/|$)/)?.[1];
357
+ return slug ? { origin: u.origin, slug, shareUrl: `${u.origin}/p/${slug}` } : null;
358
+ }
359
+ /**
360
+ * Take down any board on a server you run, by its link, with that server's admin token: for a board
361
+ * reported as unlawful, or an owner who lost the publish token with the folder. Nothing in this
362
+ * project changes, since the board isn't this project's, and nobody gets its comments back.
363
+ */
364
+ async function takedownHosted(link, admin) {
365
+ const board = parseBoardLink(link);
366
+ if (!board)
367
+ throw new Error(`${link} isn't a board link. One looks like https://arbiter.design/p/abc123`);
368
+ const r = await api(`${board.origin}/api/projects/${board.slug}`, { method: 'DELETE', admin });
369
+ if (r.status === 404)
370
+ throw new Error(`${board.origin} has no board at ${board.shareUrl}: it's already gone, or the link is wrong`);
371
+ if (r.status === 401)
372
+ 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.`);
373
+ if (r.status === 405)
374
+ throw new Error(`${board.origin} can't delete boards yet — it runs an older Arbiter than this one. Nothing was deleted.`);
375
+ if (!r.ok)
376
+ throw new Error(`delete failed: ${r.body.error ?? r.status}. Nothing was deleted.`);
377
+ return { shareUrl: board.shareUrl, pictures: Number(r.body.pictures ?? 0), comments: Number(r.body.comments ?? 0) };
378
+ }
package/dist/index.js CHANGED
@@ -11,6 +11,8 @@ 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");
14
16
  const pull_1 = require("./commands/pull");
15
17
  const snapshot_1 = require("./commands/snapshot");
16
18
  const setup_1 = require("./commands/setup");
@@ -20,6 +22,8 @@ const review_1 = require("./commands/review");
20
22
  const update_1 = require("./commands/update");
21
23
  const remove_1 = require("./commands/remove");
22
24
  const autopublish_1 = require("./autopublish");
25
+ const hosted_1 = require("./hosted");
26
+ const store_1 = require("./store");
23
27
  const program = new commander_1.Command();
24
28
  program
25
29
  .name('arbiter')
@@ -108,6 +112,7 @@ program
108
112
  .option('--client <name>', 'claude-code or cursor (default: detected)')
109
113
  .option('--author <name>', 'who decides rules (default: git user.name)')
110
114
  .option('--destination <name>', 'local (default) or git — git also commits candidate pages and prints GitHub links')
115
+ .option('--checkin <mode>', 'how Arbiter checks in while you work: feature | quiet | every (default: asked)')
111
116
  .option('-y, --yes', 'no questions — use detected values')
112
117
  .option('--skip-install', 'do not add the package to devDependencies')
113
118
  .action(async (opts) => {
@@ -117,6 +122,8 @@ program
117
122
  process.stdout.write(` ${s.file.padEnd(w)} ${s.outcome}${s.note ? ` — ${s.note}` : ''}\n`);
118
123
  }
119
124
  process.stdout.write('\nDone. Start a new agent session — it will read DECISIONS.md before UI work.\n');
125
+ if (!(0, store_1.readConfig)((0, store_1.resolvePaths)(process.cwd()))?.onboarded)
126
+ process.stdout.write((0, init_1.checkinHandoff)());
120
127
  if (opts.destination === 'git') {
121
128
  process.stdout.write([
122
129
  '',
@@ -223,15 +230,35 @@ program
223
230
  .option('--on-push', 'also write a GitHub Actions workflow that republishes on every push, and set its secret')
224
231
  .option('--auto', 'republish whenever the record changes — no GitHub, no CI, no repository needed')
225
232
  .option('--no-auto', 'stop republishing automatically')
233
+ .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
+ .option('--no-password', 'take the password off: anyone with the link can see the board')
226
235
  .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
- const w = Math.max(...r.steps.map((s) => s.step.length));
229
- for (const s of r.steps)
230
- process.stdout.write(` ${s.step.padEnd(w)} ${s.outcome}${s.note ? ` — ${s.note}` : ''}\n`);
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 });
237
+ printSteps(r.steps);
231
238
  if (r.url)
232
239
  process.stdout.write(`\n${r.ok ? 'Live in about a minute' : 'Once the failed step is fixed'}: ${r.url}\n`);
233
240
  process.exit(r.ok ? 0 : 1);
234
241
  });
242
+ program
243
+ .command('unpublish [board-link]')
244
+ .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.')
245
+ .option('--yes', 'go ahead; without it, nothing is deleted and it says what would be')
246
+ .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}`)
247
+ .action(async (boardLink, opts) => {
248
+ const r = await (0, unpublish_1.unpublish)({ yes: !!opts.yes, board: boardLink, admin: !!opts.admin });
249
+ printSteps(r.steps);
250
+ process.exit(r.ok ? 0 : 1);
251
+ });
252
+ program
253
+ .command('rename <work> <new-name>')
254
+ .description('Rename a piece of work everywhere the record keeps it. Its comments on the board follow it at the next publish.')
255
+ .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');
258
+ if (result.exitCode === 0)
259
+ await boardUpdated(opts.cwd);
260
+ process.exit(result.exitCode);
261
+ });
235
262
  program
236
263
  .command('pull')
237
264
  .description('Fetch comments and "looks good" reactions from the hosted board into .arbiter/comments.json. "Request change" becomes a request (R-0001) to answer.')
@@ -304,6 +331,12 @@ program.parseAsync(process.argv).catch((e) => {
304
331
  process.stderr.write(`arbiter: ${e.message}\n`);
305
332
  process.exit(1);
306
333
  });
334
+ /** `publish` and `unpublish` report one line per step: name, outcome, why. */
335
+ function printSteps(steps) {
336
+ const w = Math.max(...steps.map((s) => s.step.length));
337
+ for (const s of steps)
338
+ process.stdout.write(` ${s.step.padEnd(w)} ${s.outcome}${s.note ? ` — ${s.note}` : ''}\n`);
339
+ }
307
340
  /** With `hosted.auto`, the board follows the record. Prints a line when it does, or why it didn't. */
308
341
  async function boardUpdated(cwd) {
309
342
  const line = await (0, autopublish_1.autoPublish)(cwd);
package/dist/store.js CHANGED
@@ -83,7 +83,7 @@ function appendArchive(paths, d) {
83
83
  node_fs_1.default.appendFileSync(paths.archive, prefix + (0, format_1.formatEntry)(d));
84
84
  }
85
85
  /**
86
- * Rewrites the archive in full. Only `remove` and `unlink` use this: the archive is append-only
86
+ * Rewrites the archive in full. Only `remove`, `unlink` and `rename` use this: the archive is append-only
87
87
  * for judgments — a decision you changed your mind about is superseded, never rewritten — but a
88
88
  * record of something that never happened is noise, not history, and has to be able to leave.
89
89
  */
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ /**
3
+ * The people judging are PMs and designers. They read a decision in the review, on the board and
4
+ * in DECISIONS.md, never next to the code, so a line written in code words gets misread or
5
+ * skipped. `record` refuses one, and the agent says it again in plain words before anyone sees it.
6
+ *
7
+ * Only what is surely code is caught: a file name, a class name, a name stuck together like
8
+ * onClick or ArrowUpRight, backticks. A product name (Next.js, iPhone, GitHub) or a size a
9
+ * designer would say (16px) passes. Two-part names like TagPill do too, since they can't be told
10
+ * apart from brands like FigJam; the skill's examples cover those.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.MAX_WORDS = void 0;
14
+ exports.codeWords = codeWords;
15
+ exports.unclearLines = unclearLines;
16
+ /** Words in one line. The skill asks for 20 or fewer; this is where it stops being one thing. */
17
+ exports.MAX_WORDS = 25;
18
+ const SIZE = String.raw `(?:\d+(?:\.\d+)?|px|xs|sm|base|md|lg|xl|[2-9]xl|full|screen|auto|none)`;
19
+ const UTILITY = String.raw `(?:text|bg|border|rounded|shadow|font|leading|tracking|gap|space|ring|opacity|grid-cols|col-span|row-span|basis|w|h|size|min-w|max-w|min-h|max-h|p|px|py|pt|pb|pl|pr|m|mx|my|mt|mb|ml|mr|z|inset)`;
20
+ const CODE = [
21
+ /`[^`]*`?/g,
22
+ // A path, a source file, or a lowercase .js/.md file (Next.js is a product; next.config.js is a file).
23
+ /\b[\w.-]*\/[\w./-]*\.[a-z]{2,5}\b|\b[\w-]+\.(?:tsx|jsx|ts|css|scss|vue|svelte|json|html|py|rb|swift|kt)\b|\b[a-z][\w-]*\.(?:js|mjs|md)\b/g,
24
+ // onClick, useState: lowercase then humps. iPhone and macOS aren't.
25
+ /\b[a-z]{2,}(?:[A-Z][a-z0-9]+)+\b/g,
26
+ // ArrowUpRight: three humps or more.
27
+ /\b[A-Z][a-z]+(?:[A-Z][a-z]+){2,}\b/g,
28
+ // Utility classes with a size or a shade: text-xs, w-24, gap-x-2, md:grid-cols-3, bg-ink-500.
29
+ new RegExp(String.raw `\b(?:(?:sm|md|lg|xl|2xl):)?${UTILITY}(?:-[xy])?-(?:${SIZE}|[a-z]+-\d{2,3})\b|\b(?:sm|md|lg|xl|2xl):[a-z][\w-]*|\bfont-(?:light|normal|medium|semibold|bold|sans|serif|mono)\b`, 'g'),
30
+ /\baria-[a-z]+/g,
31
+ /<\/?[a-z][a-z0-9-]*[\s/>]|=>|[{}]|\b\w+\(\)/g,
32
+ /\b(?:fg|bg|div|props|href|z-index|boolean|enum|regex)\b|\b\d+(?:\.\d+)?fr\b/g,
33
+ ];
34
+ /** What reads like code in a line, as written, at most three. */
35
+ function codeWords(text) {
36
+ const found = new Set();
37
+ for (const re of CODE)
38
+ for (const m of text.matchAll(re))
39
+ found.add(m[0].trim());
40
+ return [...found].filter(Boolean).slice(0, 3);
41
+ }
42
+ const words = (text) => text.trim().split(/\s+/).filter(Boolean).length;
43
+ /**
44
+ * Problems with the lines a person reads: Change, Pattern and each Rejected. A mechanical rule's
45
+ * `decision` may name a token, since that's what its check looks for; its `change` still can't.
46
+ */
47
+ function unclearLines(input) {
48
+ const lines = [
49
+ ...(input.change ? [['change', input.change]] : []),
50
+ ['decision', input.decision],
51
+ ...(input.rejected ?? []).map((r, i) => [`rejected[${i}]`, r]),
52
+ ];
53
+ const problems = [];
54
+ for (const [field, text] of lines) {
55
+ const n = words(text);
56
+ if (n > exports.MAX_WORDS)
57
+ problems.push(`${field} is ${n} words, over ${exports.MAX_WORDS}: say one thing, what a person sees or does`);
58
+ if (field === 'decision' && input.class === 'mechanical')
59
+ continue;
60
+ const code = codeWords(text);
61
+ if (code.length)
62
+ problems.push(`${field} reads like code (${code.map((c) => `"${c}"`).join(', ')}): say it the way it looks on screen`);
63
+ }
64
+ return problems;
65
+ }
package/dist/work.js CHANGED
@@ -9,6 +9,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  };
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.workDir = exports.workId = void 0;
12
+ exports.readRenames = readRenames;
13
+ exports.addRename = addRename;
12
14
  exports.workSnapshot = workSnapshot;
13
15
  exports.copyImage = copyImage;
14
16
  exports.captureImage = captureImage;
@@ -21,6 +23,33 @@ const workId = (trigger) => 'W-' + trigger.toLowerCase().replace(/[^a-z0-9]+/g,
21
23
  exports.workId = workId;
22
24
  const workDir = (paths) => node_path_1.default.join(paths.archiveDir, 'work');
23
25
  exports.workDir = workDir;
26
+ const RENAMED_FILE = 'renamed.json';
27
+ function readRenames(paths) {
28
+ const f = node_path_1.default.join(paths.archiveDir, RENAMED_FILE);
29
+ if (!node_fs_1.default.existsSync(f))
30
+ return [];
31
+ try {
32
+ const all = JSON.parse(node_fs_1.default.readFileSync(f, 'utf8').replace(/^/, ''));
33
+ if (!Array.isArray(all))
34
+ throw new Error('not a list');
35
+ return all.filter((r) => typeof r?.from === 'string' && typeof r?.to === 'string');
36
+ }
37
+ catch (e) {
38
+ throw new Error(`.arbiter/${RENAMED_FILE} can't be read (${e.message.split('\n')[0]}) — a merge conflict? Fix the file, then run this again.`);
39
+ }
40
+ }
41
+ /**
42
+ * Note one rename. Earlier names that led to `from` now lead to `to`, so a card renamed twice still
43
+ * gathers all its comments; and nothing leads away from `to`, which is a live name again.
44
+ */
45
+ function addRename(paths, from, to) {
46
+ const all = readRenames(paths)
47
+ .filter((r) => r.from !== to && r.from !== from)
48
+ .map((r) => (r.to === from ? { ...r, to } : r));
49
+ all.push({ from, to });
50
+ node_fs_1.default.mkdirSync(paths.archiveDir, { recursive: true });
51
+ node_fs_1.default.writeFileSync(node_path_1.default.join(paths.archiveDir, RENAMED_FILE), JSON.stringify(all, null, 2) + '\n');
52
+ }
24
53
  /** The snapshot file for a piece of work, if one was attached. */
25
54
  function workSnapshot(paths, id) {
26
55
  for (const ext of IMAGE_EXT) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arbiterdesign",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Records design decisions made during agent-assisted UI work and feeds them back into the agent's context.",
5
5
  "homepage": "https://arbiter.design",
6
6
  "repository": {
@@ -7,6 +7,8 @@ description: Apply and record this project's design decisions (DECISIONS.md). Us
7
7
 
8
8
  `DECISIONS.md` holds the design calls this project has already made — what was chosen, what was rejected, and why. Your job is to apply them, and to capture new ones as they happen, without asking the user to write anything.
9
9
 
10
+ The commands below start with `npx`. On Windows, if one fails with "running scripts is disabled on this system", that's PowerShell blocking `npx`, not Arbiter: run the same command with `npx.cmd`, and keep using it for the rest of the session.
11
+
10
12
  ## Before UI work
11
13
 
12
14
  If `DECISIONS.md` exists, read it before building or changing any component, screen, or style. Treat every entry as settled. Do not re-decide it, and do not try the alternatives it lists as rejected. When what you're about to build would go against a rule (the user asks for it, the design system says otherwise, another rule disagrees), don't pick a side yourself: **When something clashes with a rule**, below, says when to ask and how.
@@ -204,7 +206,7 @@ Design work is iterative. A screen redesigned six times is one piece of work, no
204
206
  npx arbiter record --pending '<json>'
205
207
  ```
206
208
 
207
- (JSON shape below). The output carries `checkin`, the user's answer from their first `/arbiter`; `waiting`, how many changes are waiting for them (polish isn't counted, since they're never asked about it); sometimes `ask`; and sometimes `picture`, a screen this changed that has no picture yet (see **Screenshots**).
209
+ (JSON shape below). The output carries `checkin`, the user's answer to the check-in question; `waiting`, how many changes are waiting for them (polish isn't counted, since they're never asked about it); sometimes `ask`; and sometimes `picture`, a screen this changed that has no picture yet (see **Screenshots**).
208
210
 
209
211
  - `feature` (default) — **only if the piece of work included a `feature`-level decision**, add one line to your reply carrying its Change line, not a count.
210
212
  - `quiet` — say nothing. Ever. They run `/arbiter` when they want it. `ask` never comes back.
@@ -240,9 +242,13 @@ Arbiter's skill file is from 0.1.3 (the CLI is 0.1.4) — say "update arbiter" a
240
242
 
241
243
  Never run it unasked. When they say yes — or say *"update arbiter"* unprompted — run the command `update.command` names and relay what it prints. It leaves `DECISIONS.md`, the archive and the settings alone.
242
244
 
243
- ## The first `/arbiter` — intro, then the queue
245
+ ## Right after install
246
+
247
+ Install asks one question: when Arbiter should check in. Run in a terminal, it asks there. Run by you, nobody can answer, so its last lines hand you the question. Ask it then, on its own, before anything else: the widget below, with just this one question. Then save the answer with `setup --checkin`, as below. Asked once; `/arbiter` never asks it again.
248
+
249
+ ## The first `/arbiter`, if nobody answered at install — intro, then the queue
244
250
 
245
- The queue JSON carries `firstRun: true` until the project has been through this once. When it does, before anything else, say this — verbatim, it's been written for the reader:
251
+ The queue JSON carries `firstRun: true` only while nobody has answered the check-in question (an install from before it asked, or one where it was never relayed) and nothing has been judged yet. When it does, before anything else, say this — verbatim, it's been written for the reader:
246
252
 
247
253
  > **Arbiter's on.** While I build UI, I record the design decisions I make — what changed, the rule behind it, what was rejected — so nothing gets re-decided and your team can see why things are the way they are.
248
254
  >
@@ -256,7 +262,7 @@ The queue JSON carries `firstRun: true` until the project has been through this
256
262
  > - **publish** — say it, get the board link
257
263
  > - **"record that"** / **"make that a rule"** — mid-chat, recorded, no questions
258
264
 
259
- Then one question, with the selection widget (text fallback: the same three lines, numbered):
265
+ Then one question, with the selection widget (text fallback: the same three lines, numbered). It goes alone, before the queue. Never fold it into the review's questions: dismissed along with them, it comes back on every `/arbiter`.
260
266
 
261
267
  - **header** — `While you work`
262
268
  - **question** — `When should Arbiter check in about decisions?`
@@ -265,7 +271,7 @@ Then one question, with the selection widget (text fallback: the same three line
265
271
  - `Nothing until I ask` — *Saved silently. Asks only when something clashes with a rule. /arbiter whenever you want to see it.*
266
272
  - `A line after everything` — *One sentence every time a piece of work settles, big or small. Every 5 changes waiting, a yes/no on reviewing.*
267
273
 
268
- Record the answer — Skip means the recommended one:
274
+ Record the answer, whatever comes back. Skip, a dismissed widget or no answer all mean the recommended one, so it's asked once:
269
275
 
270
276
  ```
271
277
  npx arbiter setup --checkin feature # A line after big work
@@ -344,7 +350,7 @@ Skip mechanical necessities (imports, prop plumbing, file placement), and non-vi
344
350
 
345
351
  | Level | What it is | Examples | Review behaviour |
346
352
  |---|---|---|---|
347
- | `feature` | A new surface, flow, or structure | Settings shell with four routes; a second card on Audit; a stage-aware back link | Always presented |
353
+ | `feature` | A new surface, flow, or structure | Settings split into four tabs; a second card on Audit; a back link that knows which step you came from | Always presented |
348
354
  | `pattern` | A reusable call that could apply elsewhere | Icon-only buttons on half-width cards; "Status" not "Health"; save buttons bottom-right | Presented; "make it a rule" is the likely answer |
349
355
  | `polish` | A one-off fix to one screen | Match heights at `h-9`; drop a chevron; remove a pill | **Never presented.** Queued, then logged automatically when the group is reviewed |
350
356
 
@@ -362,27 +368,31 @@ Only when asked (see above). If you have a question tool that presents options (
362
368
 
363
369
  Each question:
364
370
 
365
- - **header** — the dimension, Title case: `Structure`, `Interaction`, `States`, `Content`, `Visual`
366
- - **question** — a heading line, a blank line, then four labelled lines:
371
+ - **header** — the dimension, Title case: `Structure`, `Interaction`, `States`, `Content`, `Visual`. Some apps don't show the header, so the heading line carries it too.
372
+ - **question** — a heading line, then four labelled lines, with a blank line before each. The widget shows plain text in one block, so the blank lines are what separate them:
367
373
 
368
374
  ```
369
- Rescan button · 1 of 1
375
+ Rescan button · Interaction · 1 of 1
370
376
 
371
377
  Change — The Rescan button on the small Health check card is now just an icon
372
- Pattern — Half-width cards use icon-only action buttons with aria-label and title
378
+
379
+ Pattern — Half-width cards use icon-only action buttons
380
+
373
381
  Rejected — Full-label button: wrapped to a second row on mobile
382
+
374
383
  Applies to — Compact card actions, anywhere
375
384
  ```
376
385
 
377
- - The heading is **the thing the user was working on, at the grain they worked at** — `Rescan button`, `Delete flow`, `Settings`, `Billing page`. Say it the way they'd say it. It's the `trigger`. Then `n of N` within that piece of work.
378
- - `Change` is what happened, as a PM would say it. `Pattern` is the rule-shaped sentence (`decision`). `Rejected` is each alternative with why it lost, `·`-separated if more than one; omit the line if nothing was rejected. `Applies to` is the scope in words: a file name, `<Pattern name>, anywhere`, or `Everywhere`.
386
+ - The heading is **the thing the user was working on, at the grain they worked at** — `Rescan button`, `Delete flow`, `Settings`, `Billing page`. Say it the way they'd say it. It's the `trigger`. Then the dimension, then `n of N` within that piece of work.
387
+ - `Change` is what happened, as a PM would say it. `Pattern` is the rule-shaped sentence (`decision`). `Rejected` is each alternative with why it lost, `·`-separated if more than one; omit the line if nothing was rejected. `Applies to` is the scope in words: the screen or area (`Writing list`), `<Pattern name>, anywhere`, or `Everywhere`. Never a file name.
388
+ - Every line in plain words, as **Write it for a PM or a designer** shows. The widget can't bold or format anything, so short lines are all that makes it readable.
379
389
  - **options**, these two, in this order:
380
390
  - `Confirm` — *Saved to the decision log.*
381
391
  - `Make it a rule` — *Kept in DECISIONS.md, referenced in future sessions.*
382
392
  - The built-in **Other** box is the correction path. If the user types there, treat it as a fix: what they typed is the decision, what you did is rejected. If they type `skip`, drop the item.
383
393
  - The widget's own **Skip** button means "not now" — everything stays in the queue. Don't add a Skip option.
384
394
 
385
- **A clash** adds a line under `Applies to` — `Clashes — D-0009 · Destructive actions undo instead of confirming` — and has its own three options:
395
+ **A clash** adds a line under `Applies to`, after a blank line like the others — `Clashes — D-0009 · Destructive actions undo instead of confirming` — and has its own three options:
386
396
 
387
397
  - `Follow D-0009` — *Change it back to match the rule.*
388
398
  - `Replace D-0009` — *This becomes the rule; D-0009 goes to the decision archive.*
@@ -410,7 +420,7 @@ Settings build — 2 decisions, +4 polish
410
420
  Pattern: Destructive actions confirm in a dialog
411
421
  Clashes: D-0009 · Destructive actions undo instead of confirming
412
422
  → follow D-0009 · replace D-0009 · keep as exception
413
- 5. Change: Settings is now a tab-row shell with four routes under it [feature]
423
+ 5. Change: Settings is now one page with four tabs [feature]
414
424
  …
415
425
 
416
426
  Reply per number — confirm · rule · skip · or type what it should be
@@ -455,6 +465,29 @@ Used by `record --pending` (queue) and `record` (record now):
455
465
 
456
466
  Two sentences, two jobs. **Write `change` as what a PM would say happened** — concrete, past tense, names the thing on the screen. **Write `decision` as the rule someone could follow** — present tense, naming exactly what it's about and where it applies. The user judges from `change`; future sessions obey `decision`. Never cram both into one line.
457
467
 
468
+ ### Write it for a PM or a designer
469
+
470
+ The people judging are PMs and designers. They read these lines in the review, on the board and in `DECISIONS.md`, never next to the code. You've just been in the code, so you'll reach for its words: catch that.
471
+
472
+ - **Say what a person sees or does**, not how it was built. "Jumps to that rule", not "the row is an anchor".
473
+ - **No code words.** No file names, component names, class names, CSS values or attributes (`aria-label`, `text-xs`, `ArrowUpRight`, `lib/writing.ts`, `1fr`). Call things what they're called on screen.
474
+ - **One thing per line, 20 words or fewer.** A line that lists four parts of a card is four details, and the person only needs the one that was decided.
475
+ - **`Applies to` is a screen or an area**: `Writing list`, `Project cards, anywhere`. Never a file.
476
+
477
+ This goes for `change`, `decision` and each `rejected`. A mechanical rule's `decision` may name a token, since that's what its check looks for; its `change` still says it in words.
478
+
479
+ Not this → this, from real queues:
480
+
481
+ | Not this | This |
482
+ |---|---|
483
+ | The rule badge on a screen page links to that rule's row under Standing rules; the row is an anchor and its id turns fg when it is the target | Clicking a Rule badge jumps to that rule, with its number highlighted |
484
+ | The Projects page now has an Other projects section: three cards in a row under the main cards, each with a title, impact line, tag pills and a screen, tinted per project | The Projects page has a new Other projects row: three smaller cards under the main ones |
485
+ | Writing rows that link off-site use an ArrowUpRight and a text-xs source line with the site mark under the excerpt | Articles from other sites show an arrow pointing out and a small line naming the site |
486
+ | Rejected: source label in the date column, too cramped at the w-24 mobile column | Rejected: source in the date column, too cramped on phones |
487
+ | Applies to: lib/writing.ts | Applies to: Writing list |
488
+
489
+ `record` checks. A line over 25 words, or one with something that's surely code (a file name, a class name, a name like `onClick` or `ArrowUpRight`, backticks), exits `1` with `status: "unclear"` and the words it caught. Nothing is written. Say it again in plain words and re-run.
490
+
458
491
  `verdict` is omitted when queueing (`--pending`); include it (`accept | rule | fix`) only when recording directly.
459
492
 
460
493
  For **mechanical** decisions, add evidence so Arbiter can check the claim against the files you wrote:
@@ -470,7 +503,7 @@ If the work belongs to a candidate (below), add `"candidate": "C-0001"` or pass
470
503
 
471
504
  If the session mentioned a ticket — a Linear or Jira key like `ENG-123`, a GitHub issue, a pasted tracker link — add `"ref": "<url or key>"` or pass `--ref`. It's how the board links each decision to the work it came from. Never ask for one; leave it out when nothing was mentioned. `--ref` on a bulk `--all` stamps every item.
472
505
 
473
- - `change` — what happened, in plain words. One line. Required. This is what the person judging reads.
506
+ - `change` — what happened, in plain words. One line, 20 words or fewer. Required. This is what the person judging reads.
474
507
  - `decision` — the same call as a rule someone could follow. Present tense. One line. It's the rule's title in `DECISIONS.md`, and with many rules a future session picks what to read from titles alone. So name the exact thing and where it applies: `Reply pills on the guest list are filled`, not `Pills are filled`; `Form errors go in one box at the top of the form`, not `Errors go at the top`. A vague title gets skipped, or looks like it clashes with a rule about something else. For `polish` it can repeat `change`.
475
508
  - `level` — `feature | pattern | polish` (table above). Default is `pattern`; set it every time.
476
509
  - `trigger` — the thing the user was working on, named the way they'd say it, at the grain they worked at: `Rescan button`, `Delete flow`, `Settings`, `Billing page`. Every decision from the same piece of work gets the **same** trigger — it's the grouping key and the heading they see.
@@ -487,7 +520,7 @@ If the session mentioned a ticket — a Linear or Jira key like `ENG-123`, a Git
487
520
  The command prints JSON and exits:
488
521
 
489
522
  - `0` — recorded. Note the `id`. If the output has a `sweep` block with violations, see **Sweep** below.
490
- - `1` — invalid. Fix the payload and retry.
523
+ - `1` — invalid. Fix the payload and retry. With `status: "unclear"`, a line reads like code or runs on: rewrite it (see **Write it for a PM or a designer**) and retry.
491
524
  - `2` — **overlap**. Nothing was written. See below.
492
525
  - `3` — `DECISIONS.md` is at its cap. Tell the user, and ask which existing rule this replaces.
493
526
  - `4` — **contradicted**. The files don't match the claim. Nothing was written. Fix the code or the claim.
@@ -534,6 +567,8 @@ A picture isn't evidence of the change; there's one image and nothing to compare
534
567
 
535
568
  **Name the piece of work after the screen it changed**, where the work honestly splits that way: `Settings — billing`, `Settings — profile`, rather than one `Settings build` covering four routes. One picture per piece of work is then one per screen, and the review reads screen by screen instead of one lump. Work that shouldn't be split — a flow across three steps, a nav change touching every page — stays one piece of work and gets one representative picture.
536
569
 
570
+ When the user wants a piece of work called something else after it's recorded (*"call that Settings — billing"*), rename it; don't re-record it: `npx arbiter rename "Settings build" "Settings — billing"`. Its decisions, picture, requests and comments follow, and the board's comments move to the new card at the next publish. From then on, use the new name as the `trigger`. A screen (`C-0001`) keeps its id whatever it's called, so it never needs this.
571
+
537
572
  ### Taking it
538
573
 
539
574
  Your own screenshot tool hands the image back to you in the conversation; `arbiter snapshot` needs a **file on disk**. So write one:
@@ -635,6 +670,10 @@ It goes to arbiter.design. Nothing to set up, no token, no account: the first pu
635
670
 
636
671
  *"Every time I push"*, and the project is on GitHub — `npx arbiter publish --on-push`. That publishes, writes `.github/workflows/arbiter.yml` (republishes when decisions land on the default branch), and sets the repository secret through `gh` if it's signed in — otherwise it prints the one-line instruction; relay it. Tell the user to commit the workflow and `.arbiter/hosted.json` together.
637
672
 
673
+ *"Put a password on it"*, *"make the board private"* — `npx arbiter publish --password`. It makes up a strong password, prints it once on the `password` line, and the board asks for it before showing anything. Give the user the password with the link: nothing can show it again. `--password "<theirs>"` uses one they chose (8 characters or more), and `--no-password` takes it off. Only when they ask: every `--password` makes a new one and locks out everyone who had the old one. A plain `publish` keeps it.
674
+
675
+ *"Take the board down"*, *"delete the board"* — `npx arbiter unpublish`. Without `--yes` it deletes nothing and says what would go, for everyone: relay that and ask. Run `npx arbiter unpublish --yes` only after they say yes. Their comments are saved to `.arbiter/comments.json` first, and the record in the repo stays. Tell them to commit the removal of `.arbiter/hosted.json`.
676
+
638
677
  ## Requests from the board
639
678
 
640
679
  On the board, anyone signed in can press **Request change** on a screen or a decision. `npx arbiter pull` turns each one into a request — `R-0001` — and it waits for the owner. The requester asks, the owner answers, and you make the change only once the owner has said yes. If the requester deletes it on the board before you've made it, the next pull takes it off the queue.
@@ -650,16 +689,17 @@ Making 2 changes you approved — Sam: move the danger zone to the bottom · Pri
650
689
  **Then open ones** (`requests.open`), before any queued decision. With the widget:
651
690
 
652
691
  - **header** — `Request`
653
- - **question** — a heading line, a blank line, then what was asked:
692
+ - **question** — a heading line, then what was asked, with a blank line before each labelled line:
654
693
 
655
694
  ```
656
- Sam · Settings — billing
695
+ Request from Sam · Settings — billing
657
696
 
658
697
  Asked — Move the danger zone to the bottom, not in its own tab
698
+
659
699
  About — D-0012 · Danger zone lives in its own tab
660
700
  ```
661
701
 
662
- The heading is who asked and `screenName`. `About` only when it was asked about one decision: `decision` (its id) and `decisionText` (what it says). If `earlierVersion` is true, end the heading with `· asked about an earlier version` — the screen may have changed since.
702
+ The heading is `Request from` who asked, then `screenName`: some apps don't show the header, so the heading says it's a request. `About` only when it was asked about one decision: `decision` (its id) and `decisionText` (what it says). If `earlierVersion` is true, end the heading with `· asked about an earlier version` — the screen may have changed since.
663
703
  - **options**, in this order:
664
704
  - `Apply` — *I make the change now. Sam sees it done on the board.*
665
705
  - `Decline` — *Sam sees your reason on the board.*
@@ -781,7 +821,7 @@ Recorded D-0010 (accept), D-0011 (rule), +3 polish · DECISIONS.md: 6 of 40
781
821
 
782
822
  ## Never
783
823
 
784
- - Edit `DECISIONS.md` or `.arbiter/archive.md` by hand. Always go through `record`, `remove` or `unlink`.
824
+ - Edit `DECISIONS.md` or `.arbiter/archive.md` by hand. Always go through `record`, `remove`, `unlink` or `rename`.
785
825
  - Remove a record because the user disagrees with it. Removal is for records that are false; a call they've changed their mind about is a new decision that supersedes the old one.
786
826
  - Record something the user didn't select.
787
827
  - Make a change someone asked for on the board before the owner approved it, or write a decline's reason for them.