arbiterdesign 0.1.3 → 0.1.6

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/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const commander_1 = require("commander");
5
5
  const record_1 = require("./commands/record");
6
+ const request_1 = require("./commands/request");
6
7
  const verify_1 = require("./commands/verify");
7
8
  const sweep_1 = require("./commands/sweep");
8
9
  const candidate_1 = require("./commands/candidate");
@@ -17,6 +18,8 @@ const rules_1 = require("./commands/rules");
17
18
  const init_1 = require("./commands/init");
18
19
  const review_1 = require("./commands/review");
19
20
  const update_1 = require("./commands/update");
21
+ const remove_1 = require("./commands/remove");
22
+ const autopublish_1 = require("./autopublish");
20
23
  const program = new commander_1.Command();
21
24
  program
22
25
  .name('arbiter')
@@ -24,19 +27,20 @@ program
24
27
  .version(require('../package.json').version);
25
28
  program
26
29
  .command('record [json-or-pending-id]')
27
- .description('Append a decision (JSON), queue it (--pending), or judge a queued one (P-0003 --as rule). No input at a terminal: asks step by step.')
30
+ .description('Append a decision (JSON), queue it (--pending), judge a queued one (P-0003 --as rule), or answer a request from the board (R-0001 --as apply). No input at a terminal: asks step by step.')
28
31
  .option('--pending', 'queue in .arbiter/pending.md for later review instead of recording now')
29
32
  .option('--findings <file>', "queue one pending decision per finding in a scanner's JSON output")
30
33
  .option('--tool <name>', 'with --findings: the scanner name for the record')
31
34
  .option('--candidate <id>', 'the candidate (C-0001) this decision was made for')
32
35
  .option('--retire <rule-id>', 'drop an active rule with no replacement (needs --why)')
33
- .option('--why <reason>', 'with --retire: why the rule is dead')
36
+ .option('--why <reason>', 'with --retire: why the rule is dead; with a request and --as decline: why not')
34
37
  .option('--unverified', 'record even if the named files contradict the claim')
35
- .option('--as <action>', 'judge a pending id: accept | rule | skip | fix')
38
+ .option('--as <action>', 'judge a pending id: accept | rule | skip | fix; answer a request id: apply | decline')
39
+ .option('--request <id>', 'the approved request (R-0001) this change was made for — recording it applies the request')
36
40
  .option('--all', 'with --as: judge every pending item the same way')
37
41
  .option('--level <level>', 'with --all: only this level (feature | pattern | polish)')
38
42
  .option('--trigger <text>', 'with --all: only items queued for this piece of work')
39
- .option('--to <decision>', 'with --as fix: what it should be instead')
43
+ .option('--to <decision>', 'with --as fix: what it should be instead; with a request and --as apply: what to do instead of what was asked')
40
44
  .option('--supersedes <id>', 'the active rule this one replaces')
41
45
  .option('--ref <url|key>', 'the ticket this was for: a URL or an issue key like ENG-123')
42
46
  .option('--keep-both', 'record alongside overlapping rules instead of replacing one')
@@ -68,6 +72,15 @@ program
68
72
  result = (0, record_1.judge)(arg, { ...opts, as });
69
73
  }
70
74
  }
75
+ else if (arg && /^R-\d{4,}$/.test(arg)) {
76
+ const as = opts.as;
77
+ if (!as || !['apply', 'decline'].includes(as)) {
78
+ result = { exitCode: 1, output: { status: 'invalid', errors: ['answering a request needs --as apply (Apply, but…: add --to "<instead>") | decline --why "<reason>"'] } };
79
+ }
80
+ else {
81
+ result = (0, request_1.judgeRequest)(arg, { ...opts, as });
82
+ }
83
+ }
71
84
  else {
72
85
  let input = arg ?? (await readStdin());
73
86
  if (!input.trim() && process.stdin.isTTY)
@@ -79,6 +92,9 @@ program
79
92
  result = opts.pending ? (0, record_1.queue)(input, opts) : (0, record_1.record)(input, opts);
80
93
  }
81
94
  process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
95
+ // Queueing never reaches the board — work cards are built from judged decisions.
96
+ if (result.exitCode === 0 && !opts.pending)
97
+ await boardUpdated(opts.cwd);
82
98
  process.exit(result.exitCode);
83
99
  });
84
100
  program
@@ -127,8 +143,9 @@ program
127
143
  });
128
144
  program
129
145
  .command('setup')
130
- .description('Save how Arbiter checks in while you work: --checkin feature (one line after big work) | quiet | every. Marks the project as onboarded.')
146
+ .description('Save how Arbiter checks in while you work: --checkin feature (one line after big work) | quiet (nothing, no questions) | every. Except under quiet, the agent asks whether to review at 5, 10, 15 waiting. Marks the project as onboarded. --app saves where the app runs.')
131
147
  .option('--checkin <mode>', 'feature | quiet | every')
148
+ .option('--app <url>', 'where the app runs, for screenshots: http://localhost:3000 or a staging address (on its own, saves only this)')
132
149
  .action((opts) => {
133
150
  const result = (0, setup_1.setup)(opts);
134
151
  process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
@@ -139,9 +156,11 @@ program
139
156
  .description('Attach a picture to a piece of work, named as its decisions named it: snapshot "Settings build" --file shot.png')
140
157
  .option('--file <image>', 'screenshot to keep beside the work')
141
158
  .option('--capture', 'macOS: drag-select a region of the screen')
142
- .action((work, opts) => {
159
+ .action(async (work, opts) => {
143
160
  const result = (0, snapshot_1.snapshotWork)(work, opts);
144
161
  process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
162
+ if (result.exitCode === 0)
163
+ await boardUpdated(opts.cwd);
145
164
  process.exit(result.exitCode);
146
165
  });
147
166
  program
@@ -156,9 +175,11 @@ program
156
175
  .option('--by <id>', 'with --state superseded: the candidate that replaced it')
157
176
  .option('--keep-others', "approving doesn't supersede sibling directions")
158
177
  .option('--author <name>', 'override the author')
159
- .action((idOrAdd, name, opts) => {
178
+ .action(async (idOrAdd, name, opts) => {
160
179
  const result = idOrAdd === 'add' ? (0, candidate_1.addCandidate)(name ?? '', opts) : (0, candidate_1.updateCandidate)(idOrAdd, opts);
161
180
  process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
181
+ if (result.exitCode === 0)
182
+ await boardUpdated(opts.cwd);
162
183
  process.exit(result.exitCode);
163
184
  });
164
185
  program
@@ -195,8 +216,10 @@ program
195
216
  .option('--admin-token <token>', 'only for a self-hosted Arbiter that gates board creation')
196
217
  .option('--no-push', 'GitHub Pages mode: do everything except push')
197
218
  .option('--on-push', 'also write a GitHub Actions workflow that republishes on every push, and set its secret')
219
+ .option('--auto', 'republish whenever the record changes — no GitHub, no CI, no repository needed')
220
+ .option('--no-auto', 'stop republishing automatically')
198
221
  .action(async (opts) => {
199
- const r = await (0, publish_1.publish)({ noPush: opts.push === false, to: opts.to, admin: opts.adminToken, onPush: opts.onPush });
222
+ 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 });
200
223
  const w = Math.max(...r.steps.map((s) => s.step.length));
201
224
  for (const s of r.steps)
202
225
  process.stdout.write(` ${s.step.padEnd(w)} ${s.outcome}${s.note ? ` — ${s.note}` : ''}\n`);
@@ -206,7 +229,7 @@ program
206
229
  });
207
230
  program
208
231
  .command('pull')
209
- .description('Fetch comments and "looks good" reactions from the hosted board into .arbiter/comments.json.')
232
+ .description('Fetch comments and "looks good" reactions from the hosted board into .arbiter/comments.json. "Request change" becomes a request (R-0001) to answer.')
210
233
  .action(async () => {
211
234
  process.stdout.write((await (0, pull_1.pull)()) + '\n');
212
235
  });
@@ -218,6 +241,28 @@ program
218
241
  .action(async (opts) => {
219
242
  await (0, review_1.review)(opts);
220
243
  });
244
+ program
245
+ .command('remove [id]')
246
+ .description('Take a record out that was never real: a decision (D-0004), a screen (C-0001), or a picture (--snapshot "<work>"). A rule that is simply over is `record --retire` instead.')
247
+ .option('--snapshot <work>', 'remove the picture attached to a piece of work or a screen, keeping the record')
248
+ .option('--force', 'with a screen: unlink the decisions on it rather than refusing')
249
+ .action(async (id, opts) => {
250
+ const result = opts.snapshot ? (0, remove_1.removeSnapshot)(opts.snapshot, opts) : (0, remove_1.remove)(id ?? '', opts);
251
+ process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
252
+ if (result.exitCode === 0)
253
+ await boardUpdated(opts.cwd);
254
+ process.exit(result.exitCode);
255
+ });
256
+ program
257
+ .command('unlink <ids...>')
258
+ .description('Detach decisions from the screen they were recorded against. The decisions stay exactly as they are.')
259
+ .action(async (ids, opts) => {
260
+ const result = (0, remove_1.unlink)(ids, opts);
261
+ process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
262
+ if (result.exitCode === 0)
263
+ await boardUpdated(opts.cwd);
264
+ process.exit(result.exitCode);
265
+ });
221
266
  program
222
267
  .command('update')
223
268
  .description('Bring this project up to the newest Arbiter: install it, refresh the skill file, re-pin the publish workflow. Settings and decisions untouched.')
@@ -242,10 +287,10 @@ program
242
287
  });
243
288
  program
244
289
  .command('rules [id]')
245
- .description('Read decisions. No args: active rules. An id (D-0003): that one in full.')
290
+ .description('Read decisions. No args: active rules. An id (D-0003, or a request R-0001): that one in full.')
246
291
  .option('--dimension <name>', 'only one dimension (structure, interaction, states, content, visual, motion, access)')
247
292
  .option('--archive', 'everything ever recorded — accepts, fixes, superseded — oldest first')
248
- .option('--pending', 'queued decisions not yet judged')
293
+ .option('--pending', 'queued decisions not yet judged, and requests from the board not yet answered or made')
249
294
  .option('--json', 'machine-readable output')
250
295
  .action((id, opts) => {
251
296
  process.stdout.write((0, rules_1.rules)(id, opts) + '\n');
@@ -254,6 +299,12 @@ program.parseAsync(process.argv).catch((e) => {
254
299
  process.stderr.write(`arbiter: ${e.message}\n`);
255
300
  process.exit(1);
256
301
  });
302
+ /** With `hosted.auto`, the board follows the record. Prints a line when it does, or why it didn't. */
303
+ async function boardUpdated(cwd) {
304
+ const line = await (0, autopublish_1.autoPublish)(cwd);
305
+ if (line)
306
+ process.stdout.write(line + '\n');
307
+ }
257
308
  function readStdin() {
258
309
  if (process.stdin.isTTY)
259
310
  return Promise.resolve('');
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ /**
3
+ * Which cards should have a picture and don't. The board covers a card without one in an icon
4
+ * of its kind, so a missing picture never looks broken there, which is exactly why nobody
5
+ * notices. This tells the only people who can still fix it: the agent at `record`, the author
6
+ * at `publish` and on the review page. Never the board's viewers.
7
+ *
8
+ * A change earns a picture when you could point at it on one screen and a still would show it:
9
+ * its layout, its words, its looks. Behaviour doesn't show in a still (interaction, motion,
10
+ * access), a state is photographed only if you were already looking at it, and a global change
11
+ * has no one screen. Polish never reaches the board, so it never asks either, and nor does a
12
+ * scanner finding: it's a line in a file, not a screen.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.pictureHint = exports.needsPicture = void 0;
16
+ exports.missingPictures = missingPictures;
17
+ const candidates_1 = require("./candidates");
18
+ const findings_1 = require("./findings");
19
+ const work_1 = require("./work");
20
+ const PICTURED = ['structure', 'content', 'visual'];
21
+ /** Would a picture of one screen show this change, on a card the board will have? */
22
+ const needsPicture = (d) => d.scope !== 'global' && d.level !== 'polish' && d.verdict !== 'retire' && PICTURED.includes(d.dimension) && !(0, findings_1.isFinding)(d);
23
+ exports.needsPicture = needsPicture;
24
+ /**
25
+ * One entry per card that should have a picture and has none. Cards are found the way the board
26
+ * builds them: a decision on a known candidate rides with it, the rest group by piece of work.
27
+ * A rejected or replaced direction is gone from the app, so nothing asks for its picture.
28
+ */
29
+ function missingPictures(paths, decisions, candidates = (0, candidates_1.readCandidates)(paths)) {
30
+ const byId = new Map(candidates.map((c) => [c.id, c]));
31
+ const out = new Map();
32
+ for (const d of decisions) {
33
+ if (!(0, exports.needsPicture)(d))
34
+ continue;
35
+ const c = d.candidate ? byId.get(d.candidate) : undefined;
36
+ if (c) {
37
+ if (c.snapshot || c.state === 'rejected' || c.state === 'superseded')
38
+ continue;
39
+ out.set(c.id, { name: c.name, command: `npx arbiter candidate ${c.id} --snapshot shot.png` });
40
+ }
41
+ else {
42
+ const id = (0, work_1.workId)(d.trigger);
43
+ if ((0, work_1.workSnapshot)(paths, id))
44
+ continue;
45
+ out.set(id, { name: d.trigger, command: `npx arbiter snapshot ${JSON.stringify(d.trigger)} --file shot.png` });
46
+ }
47
+ }
48
+ return [...out.values()];
49
+ }
50
+ /** The line an agent reads in `record`'s reply, with the app's address when arbiter.json has one. */
51
+ const pictureHint = (m, app) => `No picture of "${m.name}" yet. ${app ? `The app runs at ${app}; if` : 'If'} you can open that screen, take one now (see Screenshots in the skill): ${m.command}`;
52
+ exports.pictureHint = pictureHint;
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+ /**
3
+ * Requests — someone on the board asked for a change, and it has to go somewhere.
4
+ *
5
+ * A comment is input: it sits in .arbiter/comments.json until the owner points at it. A request
6
+ * is a comment that asks for something, so it gets a status and an answer:
7
+ *
8
+ * open pulled, nobody has answered it
9
+ * approved the owner said Apply (or Apply, but…) — the agent makes the change at the next /arbiter
10
+ * applied the change is in the code and recorded; `decisions` says which records did it
11
+ * declined the owner said no, with a reason the requester reads on the board
12
+ *
13
+ * Nothing moves without the owner: pull opens them, only the owner approves or declines, and only
14
+ * an approved request can be applied. The board never writes here — publish carries the answers
15
+ * back as part of the board.
16
+ *
17
+ * .arbiter/requests.json, committed, so everyone on the project sees the same answers.
18
+ */
19
+ var __importDefault = (this && this.__importDefault) || function (mod) {
20
+ return (mod && mod.__esModule) ? mod : { "default": mod };
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.oneLine = exports.REQUEST_STATUSES = exports.REQUEST_ID = void 0;
24
+ exports.readRequests = readRequests;
25
+ exports.writeRequests = writeRequests;
26
+ exports.findRequest = findRequest;
27
+ exports.nextRequestId = nextRequestId;
28
+ exports.openRequests = openRequests;
29
+ exports.dropWithdrawn = dropWithdrawn;
30
+ exports.detachDecision = detachDecision;
31
+ exports.replaceRequest = replaceRequest;
32
+ exports.screenName = screenName;
33
+ exports.cardOf = cardOf;
34
+ exports.describe = describe;
35
+ const node_fs_1 = __importDefault(require("node:fs"));
36
+ const node_path_1 = __importDefault(require("node:path"));
37
+ const candidates_1 = require("./candidates");
38
+ const store_1 = require("./store");
39
+ const work_1 = require("./work");
40
+ exports.REQUEST_ID = /^R-\d{4,}$/;
41
+ exports.REQUEST_STATUSES = ['open', 'approved', 'applied', 'declined'];
42
+ const FILE = 'requests.json';
43
+ const NAME_MAX = 120;
44
+ /** The board's own limit on what someone can write. */
45
+ const BODY_MAX = 4000;
46
+ function readRequests(paths) {
47
+ const f = node_path_1.default.join(paths.archiveDir, FILE);
48
+ if (!node_fs_1.default.existsSync(f))
49
+ return [];
50
+ // Committed and rewritten on every pull, so a merge conflict is the likely way it breaks: say so
51
+ // plainly, before any command has written anything else.
52
+ try {
53
+ // A byte-order mark is what a file saved from PowerShell 5 starts with; it's not a conflict.
54
+ const all = JSON.parse(node_fs_1.default.readFileSync(f, 'utf8').replace(/^/, ''));
55
+ if (!Array.isArray(all))
56
+ throw new Error('not a list');
57
+ return all;
58
+ }
59
+ catch (e) {
60
+ throw new Error(`.arbiter/requests.json can't be read (${e.message.split('\n')[0]}) — a merge conflict? Fix the file, then run this again.`);
61
+ }
62
+ }
63
+ function writeRequests(paths, requests) {
64
+ node_fs_1.default.mkdirSync(paths.archiveDir, { recursive: true });
65
+ node_fs_1.default.writeFileSync(node_path_1.default.join(paths.archiveDir, FILE), JSON.stringify(requests, null, 2) + '\n');
66
+ }
67
+ /**
68
+ * One request by its id. Two sharing an id (a hand-merged file) is refused, not guessed: answering
69
+ * the wrong one would make, or decline, a change nobody asked about.
70
+ */
71
+ function findRequest(all, id) {
72
+ const hits = all.filter((r) => r.id === id);
73
+ if (hits.length > 1)
74
+ return { error: `${id} is in .arbiter/requests.json ${hits.length} times, for different requests (a merge kept both?). Give each its own id in the file, then run this again.` };
75
+ return { request: hits[0] };
76
+ }
77
+ function nextRequestId(requests) {
78
+ const max = requests.reduce((m, r) => Math.max(m, Number(r.id.slice(2))), 0);
79
+ return `R-${String(max + 1).padStart(4, '0')}`;
80
+ }
81
+ /**
82
+ * Every request comment that isn't a request here yet becomes one, open. Keyed on the comment,
83
+ * so pulling twice — or two people pulling the same board — never asks the owner twice.
84
+ */
85
+ function openRequests(paths, comments) {
86
+ const all = readRequests(paths);
87
+ const seen = new Set(all.map((r) => r.comment));
88
+ const added = [];
89
+ for (const c of comments) {
90
+ // A request with no words, or not attached to a card, is nothing to answer — and saving it would
91
+ // break every later read of the queue.
92
+ if (c.kind !== 'request' || seen.has(c.id) || typeof c.body !== 'string' || !c.body.trim() || typeof c.candidate_id !== 'string' || !c.candidate_id)
93
+ continue;
94
+ // Anyone signed in on the board writes these, name included, and the name ends up in the
95
+ // record: one line, a sane length. The words keep their lines; they're cut at the board's cap.
96
+ const name = typeof c.author_name === 'string' ? (0, exports.oneLine)(c.author_name).slice(0, NAME_MAX) : '';
97
+ const r = {
98
+ id: nextRequestId(all),
99
+ comment: c.id,
100
+ screen: c.candidate_id,
101
+ decision: c.decision_id,
102
+ author: name || 'Someone',
103
+ body: c.body.trim().slice(0, BODY_MAX),
104
+ date: typeof c.created_at === 'string' && c.created_at ? c.created_at : (0, store_1.now)(),
105
+ boardVersion: c.board_version ?? null,
106
+ status: 'open',
107
+ instead: null,
108
+ reason: null,
109
+ judgedBy: null,
110
+ judgedAt: null,
111
+ decisions: [],
112
+ appliedAt: null,
113
+ };
114
+ all.push(r);
115
+ added.push(r);
116
+ seen.add(c.id);
117
+ }
118
+ if (added.length)
119
+ writeRequests(paths, all);
120
+ return added;
121
+ }
122
+ /**
123
+ * Requests the person who asked has deleted from the board. Only ones nobody has acted on go: an
124
+ * open one, or an approved one the agent hasn't made yet. Once the change is made it's in the
125
+ * record, and the board won't let an answered request be deleted anyway.
126
+ */
127
+ function dropWithdrawn(paths, onBoard) {
128
+ const all = readRequests(paths);
129
+ const gone = all.filter((r) => (r.status === 'open' || r.status === 'approved') && !onBoard.has(r.comment));
130
+ if (gone.length)
131
+ writeRequests(paths, all.filter((r) => !gone.includes(r)));
132
+ return gone;
133
+ }
134
+ /**
135
+ * A decision is leaving the record (`remove`). If a request was applied by it, the request no
136
+ * longer is. With nothing left doing it, it goes back to open — not approved: the owner removed
137
+ * that record for a reason, and an approved request is one the agent makes without asking.
138
+ */
139
+ function detachDecision(paths, decisionId) {
140
+ const all = readRequests(paths);
141
+ const touched = all.filter((r) => r.decisions.includes(decisionId));
142
+ if (!touched.length)
143
+ return [];
144
+ const next = all.map((r) => {
145
+ if (!r.decisions.includes(decisionId))
146
+ return r;
147
+ const decisions = r.decisions.filter((d) => d !== decisionId);
148
+ return decisions.length ? { ...r, decisions } : { ...r, decisions, status: 'open', instead: null, judgedBy: null, judgedAt: null, appliedAt: null };
149
+ });
150
+ writeRequests(paths, next);
151
+ return next.filter((r) => touched.some((t) => t.comment === r.comment));
152
+ }
153
+ /** Replace one request, found by its comment — unique, where a hand-merged file could repeat an id. */
154
+ function replaceRequest(paths, all, next) {
155
+ writeRequests(paths, all.map((x) => (x.comment === next.comment ? next : x)));
156
+ }
157
+ /** One line, however it was typed on the board — for places that need a single line. */
158
+ const oneLine = (s) => s.replace(/\s+/g, ' ').trim();
159
+ exports.oneLine = oneLine;
160
+ /**
161
+ * What a card is called. A candidate by its name; a piece of work by the trigger its decisions
162
+ * share — the same name to use as the trigger when recording the change, so it lands on that card.
163
+ */
164
+ function screenName(paths, screen, archive = (0, store_1.readArchive)(paths)) {
165
+ if (typeof screen !== 'string')
166
+ return null;
167
+ if (screen.startsWith('C-'))
168
+ return (0, candidates_1.readCandidates)(paths).find((c) => c.id === screen)?.name ?? null;
169
+ return archive.find((d) => (0, work_1.workId)(d.trigger) === screen)?.trigger ?? null;
170
+ }
171
+ /** The card a recorded decision shows on: its candidate if that's still a screen, else its piece of work. */
172
+ function cardOf(paths, d, candidateIds = new Set((0, candidates_1.readCandidates)(paths).map((c) => c.id))) {
173
+ return d.candidate && candidateIds.has(d.candidate) ? d.candidate : (0, work_1.workId)(d.trigger);
174
+ }
175
+ /** A request as the queue shows it: who asked what, where, and whether the board has moved on since. */
176
+ function describe(paths, r, boardVersion, archive = (0, store_1.readArchive)(paths)) {
177
+ return {
178
+ id: r.id,
179
+ author: r.author,
180
+ body: r.body,
181
+ screen: r.screen,
182
+ screenName: screenName(paths, r.screen, archive),
183
+ decision: r.decision,
184
+ // What that decision says, so the question can show it without another lookup.
185
+ decisionText: r.decision ? (archive.find((d) => d.id === r.decision)?.decision ?? null) : null,
186
+ date: r.date,
187
+ // Asked about a board that has since been republished — what they saw may already have changed.
188
+ earlierVersion: !!(r.boardVersion && boardVersion && r.boardVersion !== boardVersion),
189
+ status: r.status,
190
+ instead: r.instead,
191
+ // Approved: what the agent is to make — the ask, or what the owner said instead.
192
+ ...(r.status === 'approved' && { do: r.instead ?? r.body }),
193
+ };
194
+ }
package/dist/store.js CHANGED
@@ -16,14 +16,17 @@ exports.readActive = readActive;
16
16
  exports.writeActive = writeActive;
17
17
  exports.readArchive = readArchive;
18
18
  exports.appendArchive = appendArchive;
19
+ exports.writeArchive = writeArchive;
19
20
  exports.readPending = readPending;
20
21
  exports.writePending = writePending;
21
22
  exports.nextPendingId = nextPendingId;
22
23
  exports.nextId = nextId;
23
24
  exports.currentCommit = currentCommit;
24
25
  exports.gitUserName = gitUserName;
26
+ exports.currentAuthor = currentAuthor;
25
27
  exports.now = now;
26
28
  const node_fs_1 = __importDefault(require("node:fs"));
29
+ const node_os_1 = __importDefault(require("node:os"));
27
30
  const node_path_1 = __importDefault(require("node:path"));
28
31
  const node_child_process_1 = require("node:child_process");
29
32
  const format_1 = require("./format");
@@ -79,6 +82,15 @@ function appendArchive(paths, d) {
79
82
  const prefix = exists ? '\n' : (0, format_1.archiveHeader)() + '\n';
80
83
  node_fs_1.default.appendFileSync(paths.archive, prefix + (0, format_1.formatEntry)(d));
81
84
  }
85
+ /**
86
+ * Rewrites the archive in full. Only `remove` and `unlink` use this: the archive is append-only
87
+ * for judgments — a decision you changed your mind about is superseded, never rewritten — but a
88
+ * record of something that never happened is noise, not history, and has to be able to leave.
89
+ */
90
+ function writeArchive(paths, decisions) {
91
+ node_fs_1.default.mkdirSync(paths.archiveDir, { recursive: true });
92
+ node_fs_1.default.writeFileSync(paths.archive, (0, format_1.archiveHeader)() + '\n' + decisions.map(format_1.formatEntry).join('\n'));
93
+ }
82
94
  function readPending(paths) {
83
95
  if (!node_fs_1.default.existsSync(paths.pending))
84
96
  return [];
@@ -127,6 +139,13 @@ function gitUserName(root) {
127
139
  return null;
128
140
  }
129
141
  }
142
+ /**
143
+ * Whoever is at the keyboard. arbiter.json's author is committed, so in a shared repo it names
144
+ * whoever ran init — it's the fallback for a machine with no git identity, not the default.
145
+ */
146
+ function currentAuthor(root) {
147
+ return gitUserName(root) ?? readConfig(resolvePaths(root))?.author ?? node_os_1.default.userInfo().username;
148
+ }
130
149
  /** Timestamp without milliseconds: 2026-09-15T14:32:10Z */
131
150
  function now() {
132
151
  return new Date().toISOString().replace(/\.\d{3}Z$/, 'Z');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arbiterdesign",
3
- "version": "0.1.3",
3
+ "version": "0.1.6",
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": {