arbiterdesign 0.1.6 → 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/README.md +468 -132
- package/dist/commands/init.js +97 -7
- package/dist/commands/prompt.js +12 -4
- package/dist/commands/publish.js +18 -1
- package/dist/commands/record.js +108 -0
- package/dist/commands/rename.js +109 -0
- package/dist/commands/review.js +20 -1
- package/dist/commands/rules.js +18 -3
- package/dist/commands/sweep.js +3 -0
- package/dist/commands/unpublish.js +88 -0
- package/dist/format.js +27 -14
- package/dist/hosted.js +108 -6
- package/dist/index.js +43 -5
- package/dist/schema.js +29 -2
- package/dist/store.js +1 -1
- package/dist/wording.js +65 -0
- package/dist/work.js +29 -0
- package/package.json +1 -1
- package/templates/SKILL.md +265 -34
- package/templates/fonts/Geist-Variable.woff2 +0 -0
- package/templates/fonts/GeistMono-Variable.woff2 +0 -0
- package/templates/fonts/OFL.txt +92 -0
- package/templates/review.html +259 -91
package/dist/commands/init.js
CHANGED
|
@@ -10,11 +10,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.skillMarker = exports.SKILL_MARKER = exports.PKG_ROOT = void 0;
|
|
13
|
+
exports.skillMarker = exports.SKILL_MARKER = exports.PKG_ROOT = exports.AGENTS_LINE = void 0;
|
|
14
14
|
exports.selfVersion = selfVersion;
|
|
15
15
|
exports.skillPath = skillPath;
|
|
16
16
|
exports.init = init;
|
|
17
17
|
exports.detectClient = detectClient;
|
|
18
|
+
exports.askCheckin = askCheckin;
|
|
19
|
+
exports.checkinHandoff = checkinHandoff;
|
|
18
20
|
exports.detectPm = detectPm;
|
|
19
21
|
exports.addDevDependency = addDevDependency;
|
|
20
22
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
@@ -24,8 +26,16 @@ const node_child_process_1 = require("node:child_process");
|
|
|
24
26
|
const store_1 = require("../store");
|
|
25
27
|
const format_1 = require("../format");
|
|
26
28
|
const prompt_1 = require("./prompt");
|
|
29
|
+
const setup_1 = require("./setup");
|
|
27
30
|
const AGENTS_MARKER = '<!-- arbiter -->';
|
|
28
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The one line in AGENTS.md and CLAUDE.md. It's always loaded, so it carries the one thing that has
|
|
33
|
+
* to hold even when the skill isn't: which wins when a decision and the design system disagree.
|
|
34
|
+
* Without it the decision won 17 times in 20; with it the design system won 20 in 20, and an
|
|
35
|
+
* exception won 20 in 20 (clash study, Opus 5.5, October 2026).
|
|
36
|
+
*/
|
|
37
|
+
exports.AGENTS_LINE = `Before any UI work, read \`DECISIONS.md\` — the design decisions this project has already made. Follow them; don't re-decide them. Record new ones with the \`arbiter\` skill. ` +
|
|
38
|
+
`If the request, or the design system (DESIGN.md, design-system or pattern docs, component guidelines, or the shared components), goes against a decision, don't build yet: ask first, the way the \`arbiter\` skill shows. A decision written as an exception ("Exception to the design system: …") beats the design system without asking: follow it and say so. ${AGENTS_MARKER}`;
|
|
29
39
|
exports.PKG_ROOT = node_path_1.default.join(__dirname, '..', '..');
|
|
30
40
|
const SKILL_TEMPLATE = node_path_1.default.join(exports.PKG_ROOT, 'templates', 'SKILL.md');
|
|
31
41
|
/** The version of the package that's running. */
|
|
@@ -80,8 +90,36 @@ async function init(opts = {}) {
|
|
|
80
90
|
author = guess;
|
|
81
91
|
}
|
|
82
92
|
}
|
|
93
|
+
// ── Question 3: how Arbiter checks in while you work ─────────────────
|
|
94
|
+
// Asked once, here, so no /arbiter has to. Nobody at the terminal (an agent ran this, or
|
|
95
|
+
// --yes): it stays unanswered, and the closing lines hand the question to the agent.
|
|
96
|
+
let checkin = existing?.checkin;
|
|
97
|
+
let onboarded = existing?.onboarded;
|
|
98
|
+
if (opts.checkin !== undefined) {
|
|
99
|
+
if (!setup_1.CHECKINS.includes(opts.checkin))
|
|
100
|
+
throw new Error(`--checkin must be one of ${setup_1.CHECKINS.join(' | ')}`);
|
|
101
|
+
checkin = opts.checkin;
|
|
102
|
+
onboarded ??= (0, store_1.now)();
|
|
103
|
+
}
|
|
104
|
+
else if (!onboarded && ask) {
|
|
105
|
+
const picked = await askCheckin(ask);
|
|
106
|
+
if (picked) {
|
|
107
|
+
checkin = picked;
|
|
108
|
+
onboarded = (0, store_1.now)();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
83
111
|
// ── arbiter.json ─────────────────────────────────────────────────────
|
|
84
|
-
const config = {
|
|
112
|
+
const config = {
|
|
113
|
+
version: 1,
|
|
114
|
+
destination: 'local',
|
|
115
|
+
hosted: { url: 'https://arbiter.design' },
|
|
116
|
+
...existing,
|
|
117
|
+
author,
|
|
118
|
+
client,
|
|
119
|
+
...(opts.destination && { destination: opts.destination }),
|
|
120
|
+
...(checkin && { checkin }),
|
|
121
|
+
...(onboarded && { onboarded }),
|
|
122
|
+
};
|
|
85
123
|
if (!existing) {
|
|
86
124
|
(0, store_1.writeConfig)(paths, config);
|
|
87
125
|
steps.push({ file: 'arbiter.json', outcome: 'created' });
|
|
@@ -142,6 +180,51 @@ function detectClient(root) {
|
|
|
142
180
|
return out;
|
|
143
181
|
}
|
|
144
182
|
const label = (c) => (c === 'cursor' ? 'Cursor' : 'Claude Code');
|
|
183
|
+
/** The one preference Arbiter asks for. The skill asks the same, in the same words, when install couldn't. */
|
|
184
|
+
const CHECKIN_QUESTION = 'When should Arbiter check in about decisions while you work?';
|
|
185
|
+
const CHECKIN_OPTIONS = [
|
|
186
|
+
{ mode: 'feature', label: 'A line after big work (recommended)', detail: 'When a feature-sized piece settles, one sentence saying what changed. Every 5 changes waiting, a yes/no on reviewing. Never mid-iteration.' },
|
|
187
|
+
{ mode: 'quiet', label: 'Nothing until I ask', detail: 'Saved silently. Asks only when something clashes with a rule. /arbiter whenever you want to see it.' },
|
|
188
|
+
{ mode: 'every', label: 'A line after everything', detail: 'One sentence every time a piece of work settles, big or small. Every 5 changes waiting, a yes/no on reviewing.' },
|
|
189
|
+
];
|
|
190
|
+
/**
|
|
191
|
+
* The check-in question at the terminal. Enter takes the recommended one. Null when input ended
|
|
192
|
+
* with no answer: an agent ran install, and a choice nobody made mustn't be recorded as theirs.
|
|
193
|
+
*/
|
|
194
|
+
async function askCheckin(ask) {
|
|
195
|
+
const menu = CHECKIN_OPTIONS.map((o, i) => ` ${i + 1}. ${o.label}. ${o.detail}`).join('\n');
|
|
196
|
+
let q = `\n${CHECKIN_QUESTION}\n${menu}\n(1): `;
|
|
197
|
+
for (;;) {
|
|
198
|
+
const a = await ask.answer(q);
|
|
199
|
+
if (a === null)
|
|
200
|
+
return null;
|
|
201
|
+
const t = a.trim().toLowerCase();
|
|
202
|
+
if (!t)
|
|
203
|
+
return 'feature';
|
|
204
|
+
const n = Number(t);
|
|
205
|
+
if (Number.isInteger(n) && n >= 1 && n <= CHECKIN_OPTIONS.length)
|
|
206
|
+
return CHECKIN_OPTIONS[n - 1].mode;
|
|
207
|
+
if (setup_1.CHECKINS.includes(t))
|
|
208
|
+
return t;
|
|
209
|
+
q = 'Pick 1, 2 or 3 (1): ';
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Install's closing lines when nobody at the terminal answered the check-in question. Usually an
|
|
214
|
+
* agent ran it: it asks the user in chat, on its own, then saves the answer. Bundled with review
|
|
215
|
+
* questions it got dismissed with them and came back on every /arbiter.
|
|
216
|
+
*/
|
|
217
|
+
function checkinHandoff() {
|
|
218
|
+
const w = Math.max(...setup_1.CHECKINS.map((c) => c.length));
|
|
219
|
+
return [
|
|
220
|
+
'',
|
|
221
|
+
`One question left, asked once. ${CHECKIN_QUESTION}`,
|
|
222
|
+
...CHECKIN_OPTIONS.map((o) => ` ${o.mode.padEnd(w)} ${o.label}. ${o.detail}`),
|
|
223
|
+
'Save the answer: npx arbiter setup --checkin feature (or quiet, or every)',
|
|
224
|
+
'Agent: ask the user now, in chat, as one pick-one question on its own, then save their answer. No answer means feature.',
|
|
225
|
+
'',
|
|
226
|
+
].join('\n');
|
|
227
|
+
}
|
|
145
228
|
function skillFor(client) {
|
|
146
229
|
// A Windows checkout with autocrlf hands us CRLF; the frontmatter regex and the marker line assume LF.
|
|
147
230
|
const template = node_fs_1.default.readFileSync(SKILL_TEMPLATE, 'utf8').replace(/\r\n/g, '\n');
|
|
@@ -173,14 +256,21 @@ function mergeAgentsLine(root, file, createIfMissing) {
|
|
|
173
256
|
if (!node_fs_1.default.existsSync(abs)) {
|
|
174
257
|
if (!createIfMissing)
|
|
175
258
|
return { file, outcome: 'skipped', note: 'not present' };
|
|
176
|
-
node_fs_1.default.writeFileSync(abs, `# Agent instructions\n\n${AGENTS_LINE}\n`);
|
|
259
|
+
node_fs_1.default.writeFileSync(abs, `# Agent instructions\n\n${exports.AGENTS_LINE}\n`);
|
|
177
260
|
return { file, outcome: 'created' };
|
|
178
261
|
}
|
|
179
262
|
const before = node_fs_1.default.readFileSync(abs, 'utf8');
|
|
180
|
-
if (before.includes(AGENTS_MARKER))
|
|
181
|
-
|
|
263
|
+
if (before.includes(AGENTS_MARKER)) {
|
|
264
|
+
// The marked line is Arbiter's: an older Arbiter wrote different words, so swap in these.
|
|
265
|
+
// Only that line — whatever else the file says, and where the line sits in it, stays.
|
|
266
|
+
const after = before.replace(/^.*<!-- arbiter -->.*$/m, () => exports.AGENTS_LINE);
|
|
267
|
+
if (after === before)
|
|
268
|
+
return { file, outcome: 'unchanged' };
|
|
269
|
+
node_fs_1.default.writeFileSync(abs, after);
|
|
270
|
+
return { file, outcome: 'updated', note: 'Arbiter line refreshed' };
|
|
271
|
+
}
|
|
182
272
|
const sep = before.endsWith('\n') ? (before.endsWith('\n\n') ? '' : '\n') : '\n\n';
|
|
183
|
-
node_fs_1.default.writeFileSync(abs, before + sep + AGENTS_LINE + '\n');
|
|
273
|
+
node_fs_1.default.writeFileSync(abs, before + sep + exports.AGENTS_LINE + '\n');
|
|
184
274
|
return { file, outcome: 'updated', note: 'one line appended' };
|
|
185
275
|
}
|
|
186
276
|
const CURSOR_COMMAND = `# Arbiter — review queued design decisions
|
package/dist/commands/prompt.js
CHANGED
|
@@ -12,11 +12,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.Prompter = void 0;
|
|
13
13
|
const node_readline_1 = __importDefault(require("node:readline"));
|
|
14
14
|
class Prompter {
|
|
15
|
-
rl
|
|
15
|
+
rl;
|
|
16
16
|
lines = [];
|
|
17
17
|
waiting = [];
|
|
18
18
|
closed = false;
|
|
19
|
-
constructor() {
|
|
19
|
+
constructor(input = process.stdin) {
|
|
20
|
+
this.rl = node_readline_1.default.createInterface({ input, terminal: false });
|
|
20
21
|
this.rl.on('line', (l) => {
|
|
21
22
|
const w = this.waiting.shift();
|
|
22
23
|
if (w)
|
|
@@ -27,16 +28,23 @@ class Prompter {
|
|
|
27
28
|
this.rl.on('close', () => {
|
|
28
29
|
this.closed = true;
|
|
29
30
|
for (const w of this.waiting.splice(0))
|
|
30
|
-
w(
|
|
31
|
+
w(null);
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
question(q) {
|
|
35
|
+
return this.answer(q).then((a) => a ?? '');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Like question, but null when input ended with no line for it: nobody is there to answer.
|
|
39
|
+
* That's an agent running the command (its input is closed), not someone pressing Enter.
|
|
40
|
+
*/
|
|
41
|
+
answer(q) {
|
|
34
42
|
process.stdout.write(q);
|
|
35
43
|
const l = this.lines.shift();
|
|
36
44
|
if (l !== undefined)
|
|
37
45
|
return Promise.resolve(l);
|
|
38
46
|
if (this.closed)
|
|
39
|
-
return Promise.resolve(
|
|
47
|
+
return Promise.resolve(null);
|
|
40
48
|
return new Promise((res) => this.waiting.push(res));
|
|
41
49
|
}
|
|
42
50
|
/** Ask until non-empty, or return the default. */
|
package/dist/commands/publish.js
CHANGED
|
@@ -40,11 +40,28 @@ async function publish(opts = {}) {
|
|
|
40
40
|
// Hosted by default: the flag, then arbiter.json, then arbiter.design. `--to pages` is the git route.
|
|
41
41
|
const chosen = opts.to ?? (0, store_1.readConfig)(paths)?.hosted?.url ?? exports.DEFAULT_HOST;
|
|
42
42
|
const to = chosen === 'pages' || chosen === 'git' ? null : chosen;
|
|
43
|
+
if (opts.password !== undefined && !to) {
|
|
44
|
+
fail('password', 'a GitHub Pages site is public; only a hosted board can ask for a password');
|
|
45
|
+
return { ok: false, steps, url: null };
|
|
46
|
+
}
|
|
47
|
+
// Checked before anything is created, so a short one never leaves a new board up without it.
|
|
48
|
+
if (typeof opts.password === 'string' && opts.password.length < hosted_1.PASSWORD_MIN) {
|
|
49
|
+
fail('password', `at least ${hosted_1.PASSWORD_MIN} characters — or leave it out and get one made up: npx arbiter publish --password`);
|
|
50
|
+
return { ok: false, steps, url: null };
|
|
51
|
+
}
|
|
43
52
|
if (to) {
|
|
53
|
+
const password = opts.password === undefined ? undefined : opts.password === false ? null : opts.password === true ? (0, hosted_1.newPassword)() : opts.password;
|
|
44
54
|
try {
|
|
45
|
-
const r = await (0, hosted_1.publishHosted)(paths, to, { admin: opts.admin });
|
|
55
|
+
const r = await (0, hosted_1.publishHosted)(paths, to, { admin: opts.admin, password });
|
|
46
56
|
if (r.created)
|
|
47
57
|
done('project', `created on ${to} — link in .arbiter/hosted.json (commit it); token in .arbiter/hosted.token (git-ignored — teammates set ARBITER_PUBLISH_TOKEN)`);
|
|
58
|
+
// A made-up password is printed once, here: the service keeps only a hash. One you chose isn't echoed.
|
|
59
|
+
if (password === null)
|
|
60
|
+
done('password', 'off — anyone with the link can see the board');
|
|
61
|
+
else if (password !== undefined)
|
|
62
|
+
done('password', opts.password === true
|
|
63
|
+
? `${password} — send it with the link. It isn't saved anywhere it can be read back; to change it, run --password again`
|
|
64
|
+
: 'set — send it with the link');
|
|
48
65
|
// No image count: a card without a picture shows an icon of its kind, and that's usually right.
|
|
49
66
|
done('board', `${r.candidates} screen${r.candidates === 1 ? '' : 's'} published`);
|
|
50
67
|
for (const s of r.skipped)
|
package/dist/commands/record.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* record P-0003 --as rule judge a queued decision (accept | rule | skip | fix --to "<what instead>")
|
|
8
8
|
* record --all --as accept judge every queued decision the same way [--level polish] [--trigger "…"]
|
|
9
9
|
* record --retire D-0003 --why "…" drop a rule from DECISIONS.md with no replacement; the archive keeps both
|
|
10
|
+
* record --reword D-0003 --to "…" change a rule's wording, same id; the old wording stays on the entry
|
|
10
11
|
* record R-0001 --as apply answer a request from the board (apply [--to "<instead>"] | decline --why "…")
|
|
11
12
|
* record '<json>' --request R-0001 record the change made for an approved request; it's applied
|
|
12
13
|
* record (a person at a terminal) walk through it step by step
|
|
@@ -29,6 +30,7 @@ exports.record = record;
|
|
|
29
30
|
exports.queue = queue;
|
|
30
31
|
exports.queueFindings = queueFindings;
|
|
31
32
|
exports.retire = retire;
|
|
33
|
+
exports.reword = reword;
|
|
32
34
|
exports.judge = judge;
|
|
33
35
|
exports.judgeAll = judgeAll;
|
|
34
36
|
exports.recordInput = recordInput;
|
|
@@ -46,21 +48,66 @@ const candidate_1 = require("./candidate");
|
|
|
46
48
|
const update_1 = require("./update");
|
|
47
49
|
const pictures_1 = require("../pictures");
|
|
48
50
|
const request_1 = require("./request");
|
|
51
|
+
const wording_1 = require("../wording");
|
|
49
52
|
// ── Parse + record ─────────────────────────────────────────────────────────
|
|
50
53
|
function record(rawJson, opts = {}) {
|
|
51
54
|
const parsed = parse(rawJson);
|
|
52
55
|
if (!parsed.ok)
|
|
53
56
|
return parsed.result;
|
|
57
|
+
const unclear = plainWords(parsed.input);
|
|
58
|
+
if (unclear)
|
|
59
|
+
return unclear;
|
|
60
|
+
const bad = againstError((0, store_1.resolvePaths)((0, store_1.findRoot)(opts.cwd)), parsed.input);
|
|
61
|
+
if (bad)
|
|
62
|
+
return bad;
|
|
54
63
|
return recordInput(parsed.input, opts);
|
|
55
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* `against` has to name a rule that's in force now: an exception to a rule nobody follows any more
|
|
67
|
+
* isn't one. Checked when a decision comes in, not when a queued one is judged — by then the rule
|
|
68
|
+
* may have been replaced, and the clash is still part of the record.
|
|
69
|
+
*/
|
|
70
|
+
function againstError(paths, input) {
|
|
71
|
+
if (!input.against || (0, store_1.readActive)(paths).some((d) => d.id === input.against))
|
|
72
|
+
return null;
|
|
73
|
+
return fail([`against: ${input.against} is not an active rule`]);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A PM or a designer reads these lines, so one in code words or one that runs on is refused
|
|
77
|
+
* before it's written, and the agent says it again. Nothing is written either way.
|
|
78
|
+
*/
|
|
79
|
+
function plainWords(input) {
|
|
80
|
+
const problems = (0, wording_1.unclearLines)(input);
|
|
81
|
+
if (!problems.length)
|
|
82
|
+
return null;
|
|
83
|
+
return {
|
|
84
|
+
exitCode: 1,
|
|
85
|
+
output: {
|
|
86
|
+
status: 'unclear',
|
|
87
|
+
errors: problems,
|
|
88
|
+
hint: "Nothing was written. Rewrite these lines in a PM's or designer's words, 20 words or fewer, and run it again.",
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
56
92
|
function queue(rawJson, opts = {}) {
|
|
57
93
|
if (opts.request)
|
|
58
94
|
return fail([`--request records a change made for an approved request, directly: drop --pending. Nothing is queued for a request.`]);
|
|
59
95
|
const parsed = parse(rawJson, { pending: true });
|
|
60
96
|
if (!parsed.ok)
|
|
61
97
|
return parsed.result;
|
|
98
|
+
const unclear = plainWords(parsed.input);
|
|
99
|
+
if (unclear)
|
|
100
|
+
return unclear;
|
|
62
101
|
const paths = (0, store_1.resolvePaths)((0, store_1.findRoot)(opts.cwd));
|
|
102
|
+
const bad = againstError(paths, parsed.input);
|
|
103
|
+
if (bad)
|
|
104
|
+
return bad;
|
|
63
105
|
const pending = (0, store_1.readPending)(paths);
|
|
106
|
+
// "Not now" on the same screen against the same rule, a second time: it's on the review list
|
|
107
|
+
// already. Asking about it again is what the list is there to stop.
|
|
108
|
+
const same = parsed.input.against && pending.find((d) => d.against === parsed.input.against && d.trigger === parsed.input.trigger);
|
|
109
|
+
if (same)
|
|
110
|
+
return { exitCode: 0, output: { status: 'already-queued', id: same.id, against: same.against, pending: pending.length } };
|
|
64
111
|
const entry = { ...fill(parsed.input, opts, paths.root), id: (0, store_1.nextPendingId)(pending), verdict: 'pending' };
|
|
65
112
|
const checked = check(entry, paths.root, opts);
|
|
66
113
|
if (checked)
|
|
@@ -192,6 +239,51 @@ function retire(ruleId, why, opts = {}) {
|
|
|
192
239
|
};
|
|
193
240
|
return recordInput(input, opts);
|
|
194
241
|
}
|
|
242
|
+
// ── Reword a rule ──────────────────────────────────────────────────────────
|
|
243
|
+
/**
|
|
244
|
+
* Same rule, clearer words: "Pills are outlined" becomes "Status pills are outlined", or a rule that
|
|
245
|
+
* beats the design system on purpose becomes "Exception to the design system: …". The id stays, so
|
|
246
|
+
* everything that names it still points at it. Rewording isn't a change of mind — that's a new rule
|
|
247
|
+
* that supersedes this one — so the entry is changed in place, in DECISIONS.md and the archive
|
|
248
|
+
* both, and keeps the wording it replaced.
|
|
249
|
+
*/
|
|
250
|
+
function reword(ruleId, to, opts = {}) {
|
|
251
|
+
if (!schema_1.DECISION_ID.test(ruleId))
|
|
252
|
+
return fail([`not a rule id: ${ruleId} (looks like D-0003)`]);
|
|
253
|
+
const next = to?.trim();
|
|
254
|
+
if (!next)
|
|
255
|
+
return fail(['reword needs --to "<the new wording>"']);
|
|
256
|
+
if (/[\r\n]/.test(next))
|
|
257
|
+
return fail(['the new wording must be a single line']);
|
|
258
|
+
const paths = (0, store_1.resolvePaths)((0, store_1.findRoot)(opts.cwd));
|
|
259
|
+
const active = (0, store_1.readActive)(paths);
|
|
260
|
+
const rule = active.find((d) => d.id === ruleId);
|
|
261
|
+
if (!rule)
|
|
262
|
+
return fail([`${ruleId} is not an active rule`]);
|
|
263
|
+
if (next === rule.decision)
|
|
264
|
+
return fail([`${ruleId} already says that`]);
|
|
265
|
+
const was = `${rule.decision} (until ${(0, store_1.now)().slice(0, 10)})`;
|
|
266
|
+
const change = (d) => (d.id === ruleId ? { ...d, decision: next, reworded: [...d.reworded, was] } : d);
|
|
267
|
+
const archive = (0, store_1.readArchive)(paths);
|
|
268
|
+
if (!opts.dryRun) {
|
|
269
|
+
(0, store_1.writeActive)(paths, active.map(change), (0, store_1.readConfig)(paths)?.activeCap ?? store_1.ACTIVE_CAP);
|
|
270
|
+
// A rule recorded before the archive existed lives only in DECISIONS.md; there's nothing to rewrite.
|
|
271
|
+
if (archive.some((d) => d.id === ruleId))
|
|
272
|
+
(0, store_1.writeArchive)(paths, archive.map(change));
|
|
273
|
+
if (rule.candidate)
|
|
274
|
+
(0, candidate_1.refreshCandidates)(paths);
|
|
275
|
+
}
|
|
276
|
+
return {
|
|
277
|
+
exitCode: 0,
|
|
278
|
+
output: {
|
|
279
|
+
status: opts.dryRun ? 'dry-run' : 'reworded',
|
|
280
|
+
id: ruleId,
|
|
281
|
+
decision: next,
|
|
282
|
+
was: rule.decision,
|
|
283
|
+
wrote: opts.dryRun ? [] : ['DECISIONS.md', '.arbiter/archive.md'],
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
}
|
|
195
287
|
// ── Judge a pending item ───────────────────────────────────────────────────
|
|
196
288
|
function judge(pendingId, opts) {
|
|
197
289
|
if (!schema_1.PENDING_ID.test(pendingId))
|
|
@@ -218,11 +310,21 @@ function judge(pendingId, opts) {
|
|
|
218
310
|
decision: to,
|
|
219
311
|
rejected: [`${item.decision} — corrected by ${opts.author ?? item.author}`, ...item.rejected],
|
|
220
312
|
verdict: 'fix',
|
|
313
|
+
// Whoever made the call before, the user just changed it.
|
|
314
|
+
call: 'corrected',
|
|
221
315
|
};
|
|
222
316
|
}
|
|
223
317
|
else {
|
|
224
318
|
input = { ...base, verdict: opts.as };
|
|
225
319
|
}
|
|
320
|
+
if (opts.against) {
|
|
321
|
+
if (!schema_1.DECISION_ID.test(opts.against))
|
|
322
|
+
return fail([`--against needs a rule id like D-0009, not ${opts.against}`]);
|
|
323
|
+
input = { ...input, against: opts.against };
|
|
324
|
+
const bad = againstError(paths, input);
|
|
325
|
+
if (bad)
|
|
326
|
+
return bad;
|
|
327
|
+
}
|
|
226
328
|
const result = recordInput(input, opts);
|
|
227
329
|
if (result.exitCode === 0 && !opts.dryRun)
|
|
228
330
|
(0, store_1.writePending)(paths, rest);
|
|
@@ -238,6 +340,8 @@ function judgeAll(opts) {
|
|
|
238
340
|
// A request is applied by the change made for it, not by everything that happens to be queued.
|
|
239
341
|
if (opts.request)
|
|
240
342
|
return fail([`--request links one change to ${opts.request}; it can't go on --all`]);
|
|
343
|
+
if (opts.against)
|
|
344
|
+
return fail([`--against marks one exception to ${opts.against}; it can't go on --all`]);
|
|
241
345
|
const paths = (0, store_1.resolvePaths)((0, store_1.findRoot)(opts.cwd));
|
|
242
346
|
const targets = (0, store_1.readPending)(paths).filter((d) => (!opts.level || d.level === opts.level) && (!opts.trigger || d.trigger === opts.trigger));
|
|
243
347
|
if (!targets.length)
|
|
@@ -376,6 +480,7 @@ function recordInput(input, opts = {}) {
|
|
|
376
480
|
supersedes: entry.supersedes,
|
|
377
481
|
verified: entry.verified,
|
|
378
482
|
candidate: entry.candidate,
|
|
483
|
+
...(entry.against && { against: entry.against }),
|
|
379
484
|
active: `${nextActive.length} of ${cap}`,
|
|
380
485
|
wrote: opts.dryRun ? [] : entry.verdict === 'rule' || entry.verdict === 'retire' ? ['.arbiter/archive.md', 'DECISIONS.md'] : ['.arbiter/archive.md'],
|
|
381
486
|
...(request && { request: { id: request.id, status: opts.dryRun ? request.status : 'applied', author: request.author } }),
|
|
@@ -434,6 +539,9 @@ function fill(input, opts, root) {
|
|
|
434
539
|
expect: input.expect ?? null,
|
|
435
540
|
verified: null,
|
|
436
541
|
candidate: opts.candidate ?? input.candidate ?? null,
|
|
542
|
+
against: input.against ?? null,
|
|
543
|
+
call: input.call ?? null,
|
|
544
|
+
reworded: [],
|
|
437
545
|
};
|
|
438
546
|
}
|
|
439
547
|
function fail(errors) {
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `arbiter rename "<old name>" "<new name>"` — rename a piece of work, keeping its comments.
|
|
4
|
+
*
|
|
5
|
+
* A piece of work is the decisions that share a `trigger`, and its card id on the board comes from
|
|
6
|
+
* that name (`Settings build` → `W-settings-build`). Changing the name by hand made a new card and
|
|
7
|
+
* left every comment on the old one, which the board no longer shows. This renames it everywhere
|
|
8
|
+
* the repo keeps it — the archive, the queue, DECISIONS.md, its picture, requests and comments —
|
|
9
|
+
* and notes the move in .arbiter/renamed.json, so the next publish moves the board's comments too.
|
|
10
|
+
*
|
|
11
|
+
* Screens (C-0002) aren't renamed here: their id is a number, so a new name never moves a comment.
|
|
12
|
+
*/
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.renameWork = renameWork;
|
|
18
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
19
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
20
|
+
const store_1 = require("../store");
|
|
21
|
+
const candidates_1 = require("../candidates");
|
|
22
|
+
const hosted_1 = require("../hosted");
|
|
23
|
+
const requests_1 = require("../requests");
|
|
24
|
+
const work_1 = require("../work");
|
|
25
|
+
const fail = (errors) => ({ exitCode: 1, output: { status: 'invalid', errors } });
|
|
26
|
+
function renameWork(from, to, opts = {}) {
|
|
27
|
+
const root = (0, store_1.findRoot)(opts.cwd);
|
|
28
|
+
const paths = (0, store_1.resolvePaths)(root);
|
|
29
|
+
const oldName = (0, requests_1.oneLine)(from ?? '');
|
|
30
|
+
const newName = (0, requests_1.oneLine)(to ?? '');
|
|
31
|
+
if (!oldName || !newName)
|
|
32
|
+
return fail(['name the piece of work and what to call it: npx arbiter rename "Settings build" "Settings — billing"']);
|
|
33
|
+
const screen = (0, candidates_1.readCandidates)(paths).find((c) => c.id === oldName || c.name === oldName);
|
|
34
|
+
if (screen)
|
|
35
|
+
return fail([`${screen.id} is a screen, not a piece of work. Its id doesn't come from its name, so its comments stay with it whatever it's called.`]);
|
|
36
|
+
// By id, so case and punctuation don't matter, the way `snapshot` finds work. The id itself works too.
|
|
37
|
+
const oldId = /^W-[a-z0-9-]+$/.test(oldName) ? oldName : (0, work_1.workId)(oldName);
|
|
38
|
+
const newId = (0, work_1.workId)(newName);
|
|
39
|
+
if (newId === 'W-')
|
|
40
|
+
return fail([`"${newName}" has no letters or numbers to name a card by`]);
|
|
41
|
+
const mine = (d) => (0, work_1.workId)(d.trigger) === oldId;
|
|
42
|
+
const archive = (0, store_1.readArchive)(paths);
|
|
43
|
+
const pending = (0, store_1.readPending)(paths);
|
|
44
|
+
const active = (0, store_1.readActive)(paths);
|
|
45
|
+
const all = [...archive, ...pending];
|
|
46
|
+
const found = all.filter(mine);
|
|
47
|
+
if (!found.length)
|
|
48
|
+
return fail([`no piece of work called "${oldName}" — name it as its decisions did (npx arbiter rules --archive shows them)`]);
|
|
49
|
+
const current = found[0].trigger;
|
|
50
|
+
if (current === newName)
|
|
51
|
+
return fail([`"${current}" is already called that`]);
|
|
52
|
+
// Two pieces of work with one id would be one card with two names. Merging them is a different act.
|
|
53
|
+
const taken = newId !== oldId ? all.find((d) => (0, work_1.workId)(d.trigger) === newId) : undefined;
|
|
54
|
+
if (taken)
|
|
55
|
+
return fail([`there's already a piece of work called "${taken.trigger}" — renaming "${current}" onto it would merge the two`]);
|
|
56
|
+
const wrote = [];
|
|
57
|
+
const rename = (ds) => ds.map((d) => (mine(d) ? { ...d, trigger: newName } : d));
|
|
58
|
+
if (archive.some(mine)) {
|
|
59
|
+
(0, store_1.writeArchive)(paths, rename(archive));
|
|
60
|
+
wrote.push('.arbiter/archive.md');
|
|
61
|
+
}
|
|
62
|
+
if (pending.some(mine)) {
|
|
63
|
+
(0, store_1.writePending)(paths, rename(pending));
|
|
64
|
+
wrote.push('.arbiter/pending.md');
|
|
65
|
+
}
|
|
66
|
+
if (active.some(mine)) {
|
|
67
|
+
(0, store_1.writeActive)(paths, rename(active));
|
|
68
|
+
wrote.push('DECISIONS.md');
|
|
69
|
+
}
|
|
70
|
+
if (newId !== oldId) {
|
|
71
|
+
// The picture is filed under the id; it follows. Anything already filed under the new id belongs
|
|
72
|
+
// to no decision (that was checked above), so it's a leftover and goes.
|
|
73
|
+
const shot = (0, work_1.workSnapshot)(paths, oldId);
|
|
74
|
+
if (shot) {
|
|
75
|
+
const stale = (0, work_1.workSnapshot)(paths, newId);
|
|
76
|
+
if (stale)
|
|
77
|
+
node_fs_1.default.rmSync(stale, { force: true });
|
|
78
|
+
const next = node_path_1.default.join((0, work_1.workDir)(paths), newId + node_path_1.default.extname(shot));
|
|
79
|
+
node_fs_1.default.renameSync(shot, next);
|
|
80
|
+
wrote.push(`.arbiter/work/${node_path_1.default.basename(next)}`);
|
|
81
|
+
}
|
|
82
|
+
const requests = (0, requests_1.readRequests)(paths);
|
|
83
|
+
if (requests.some((r) => r.screen === oldId)) {
|
|
84
|
+
(0, requests_1.writeRequests)(paths, requests.map((r) => (r.screen === oldId ? { ...r, screen: newId } : r)));
|
|
85
|
+
wrote.push('.arbiter/requests.json');
|
|
86
|
+
}
|
|
87
|
+
const comments = (0, hosted_1.readComments)(paths);
|
|
88
|
+
if (comments.some((c) => c.candidate_id === oldId)) {
|
|
89
|
+
(0, hosted_1.writeComments)(paths, comments.map((c) => (c.candidate_id === oldId ? { ...c, candidate_id: newId } : c)));
|
|
90
|
+
wrote.push('.arbiter/comments.json');
|
|
91
|
+
}
|
|
92
|
+
(0, work_1.addRename)(paths, oldId, newId);
|
|
93
|
+
wrote.push('.arbiter/renamed.json');
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
exitCode: 0,
|
|
97
|
+
output: {
|
|
98
|
+
status: 'renamed',
|
|
99
|
+
from: current,
|
|
100
|
+
to: newName,
|
|
101
|
+
decisions: found.length,
|
|
102
|
+
...(newId !== oldId ? { card: { from: oldId, to: newId } } : {}),
|
|
103
|
+
wrote,
|
|
104
|
+
note: newId !== oldId
|
|
105
|
+
? 'the board shows the new name, with its comments, after the next `npx arbiter publish`'
|
|
106
|
+
: 'same card on the board; only its name changes, at the next `npx arbiter publish`',
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
package/dist/commands/review.js
CHANGED
|
@@ -27,6 +27,9 @@ const requests_1 = require("../requests");
|
|
|
27
27
|
const work_1 = require("../work");
|
|
28
28
|
const request_1 = require("./request");
|
|
29
29
|
const PAGE = node_path_1.default.join(__dirname, '..', '..', 'templates', 'review.html');
|
|
30
|
+
// Geist, as on arbiter.design. Shipped with the package: the page never loads anything from the network.
|
|
31
|
+
const FONTS = node_path_1.default.join(__dirname, '..', '..', 'templates', 'fonts');
|
|
32
|
+
const FONT_FILES = new Set(['Geist-Variable.woff2', 'GeistMono-Variable.woff2']);
|
|
30
33
|
function review(opts = {}) {
|
|
31
34
|
const root = (0, store_1.findRoot)(opts.cwd);
|
|
32
35
|
const paths = (0, store_1.resolvePaths)(root);
|
|
@@ -49,10 +52,13 @@ function review(opts = {}) {
|
|
|
49
52
|
const f = (0, work_1.workSnapshot)(paths, screen);
|
|
50
53
|
return f ? `/snapshots/${node_path_1.default.basename(f)}` : null;
|
|
51
54
|
};
|
|
55
|
+
const active = (0, store_1.readActive)(paths);
|
|
52
56
|
return {
|
|
53
57
|
project: node_path_1.default.basename(root),
|
|
54
58
|
pending: (0, store_1.readPending)(paths).map((d) => ({
|
|
55
59
|
...d,
|
|
60
|
+
// The rule a clash is with, while it's still in force: the page offers Follow / Replace / Keep as exception.
|
|
61
|
+
againstRule: d.against ? active.filter((r) => r.id === d.against).map((r) => ({ id: r.id, decision: r.decision }))[0] ?? null : null,
|
|
56
62
|
candidateName: d.candidate ? byId.get(d.candidate)?.name ?? null : null,
|
|
57
63
|
snapshotUrl: d.candidate ? byId.get(d.candidate)?.snapshotUrl ?? null : null,
|
|
58
64
|
picture: (0, pictures_1.missingPictures)(paths, [d], candidates)[0] ?? null,
|
|
@@ -64,7 +70,9 @@ function review(opts = {}) {
|
|
|
64
70
|
candidates,
|
|
65
71
|
hosted: (0, hosted_1.readLinkOrNull)(paths)?.shareUrl ?? null,
|
|
66
72
|
boardVersion: (0, hosted_1.readLinkOrNull)(paths)?.boardVersion ?? null,
|
|
67
|
-
|
|
73
|
+
// The rules in force, for the Rules tab: what's already settled before you make another.
|
|
74
|
+
rules: active,
|
|
75
|
+
active: active.length,
|
|
68
76
|
cap: (0, store_1.readConfig)(paths)?.activeCap ?? store_1.ACTIVE_CAP,
|
|
69
77
|
};
|
|
70
78
|
};
|
|
@@ -147,6 +155,17 @@ function review(opts = {}) {
|
|
|
147
155
|
node_fs_1.default.createReadStream(abs).pipe(res);
|
|
148
156
|
return;
|
|
149
157
|
}
|
|
158
|
+
if (req.method === 'GET' && url.pathname.startsWith('/fonts/')) {
|
|
159
|
+
const file = node_path_1.default.basename(url.pathname);
|
|
160
|
+
if (!FONT_FILES.has(file)) {
|
|
161
|
+
res.writeHead(404);
|
|
162
|
+
res.end();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
res.writeHead(200, { 'content-type': 'font/woff2', 'cache-control': 'max-age=86400' });
|
|
166
|
+
node_fs_1.default.createReadStream(node_path_1.default.join(FONTS, file)).pipe(res);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
150
169
|
if (req.method === 'POST' && url.pathname === '/api/candidate') {
|
|
151
170
|
const body = JSON.parse(await readBody(req));
|
|
152
171
|
const result = (0, candidate_1.updateCandidate)(body.id, { state: body.state, why: body.why, keepOthers: body.keepOthers, cwd });
|
package/dist/commands/rules.js
CHANGED
|
@@ -76,7 +76,9 @@ function pendingList(pending, opts, paths) {
|
|
|
76
76
|
const active = (0, store_1.readActive)(paths);
|
|
77
77
|
const ignore = opts.config?.overlap?.ignore;
|
|
78
78
|
return JSON.stringify({
|
|
79
|
-
|
|
79
|
+
// Judged decisions mean someone has been through a review, whatever arbiter.json says: the
|
|
80
|
+
// stamp lives in a committed file, and a branch that never merged takes it along.
|
|
81
|
+
firstRun: !opts.config?.onboarded && !archiveAll.length && !active.length,
|
|
80
82
|
checkin: opts.config?.checkin ?? 'feature',
|
|
81
83
|
...(0, update_1.updateNotice)(paths),
|
|
82
84
|
requests: { open, approved },
|
|
@@ -147,6 +149,8 @@ function reviewLines(d) {
|
|
|
147
149
|
lines.push(`${pad}Pattern ${d.decision}`);
|
|
148
150
|
for (const r of d.rejected)
|
|
149
151
|
lines.push(`${pad}Rejected ${r}`);
|
|
152
|
+
if (d.against)
|
|
153
|
+
lines.push(`${pad}Against ${d.against}`);
|
|
150
154
|
lines.push(`${pad}${d.level} · ${d.dimension} · ${d.scope}`);
|
|
151
155
|
return lines;
|
|
152
156
|
}
|
|
@@ -176,9 +180,20 @@ function one(id, paths, json) {
|
|
|
176
180
|
const later = all.find((x) => x.supersedes === id);
|
|
177
181
|
const supersededBy = later?.id ?? null;
|
|
178
182
|
const status = d.verdict !== 'rule' ? d.verdict : activeIds.has(id) ? 'active' : later ? `${later.verdict === 'retire' ? 'retired' : 'superseded'} by ${later.id}` : 'inactive';
|
|
183
|
+
// Where a rule doesn't hold, and why that's settled: the exceptions confirmed to it, and the
|
|
184
|
+
// clashes waiting on the review list. The agent checks these before asking about a screen twice.
|
|
185
|
+
const short = (x) => ({ id: x.id, trigger: x.trigger, change: x.change ?? x.decision });
|
|
186
|
+
const exceptions = id.startsWith('D-') ? all.filter((x) => x.against === id && x.verdict === 'accept').map(short) : [];
|
|
187
|
+
const waiting = id.startsWith('D-') ? (0, store_1.readPending)(paths).filter((x) => x.against === id).map(short) : [];
|
|
179
188
|
if (json)
|
|
180
|
-
return JSON.stringify({ ...d, status, supersededBy }, null, 2);
|
|
181
|
-
|
|
189
|
+
return JSON.stringify({ ...d, status, supersededBy, exceptions, waiting }, null, 2);
|
|
190
|
+
const list = (xs) => xs.map((x) => `${x.id} (${x.trigger})`).join(' · ');
|
|
191
|
+
return [
|
|
192
|
+
(0, format_1.formatEntry)(d).trimEnd(),
|
|
193
|
+
`- **Status:** ${status}`,
|
|
194
|
+
...(exceptions.length ? [`- **Exceptions:** ${list(exceptions)}`] : []),
|
|
195
|
+
...(waiting.length ? [`- **Waiting:** ${list(waiting)}`] : []),
|
|
196
|
+
].join('\n');
|
|
182
197
|
}
|
|
183
198
|
function archive(all, active, opts) {
|
|
184
199
|
const activeIds = new Set(active.map((d) => d.id));
|