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
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `arbiter unpublish --yes` — take the hosted board down, for everyone.
|
|
4
|
+
*
|
|
5
|
+
* The board is a window onto the record, so deleting it loses nothing the repo holds: decisions,
|
|
6
|
+
* rules, pictures and requests all stay. What lives only on the board is what people said there,
|
|
7
|
+
* so the comments are pulled into .arbiter/comments.json first. Then the board, its pictures and
|
|
8
|
+
* its comments are deleted from the service, and the link here goes with them.
|
|
9
|
+
*
|
|
10
|
+
* Without --yes it deletes nothing and says what it would, because nothing brings a board back:
|
|
11
|
+
* publishing again makes a new one, at a new link, with no comments.
|
|
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.unpublish = unpublish;
|
|
18
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
19
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
20
|
+
const hosted_1 = require("../hosted");
|
|
21
|
+
const store_1 = require("../store");
|
|
22
|
+
const publish_1 = require("./publish");
|
|
23
|
+
/**
|
|
24
|
+
* With `board` and `admin`: a takedown of any board on a server you run, by its link, with the
|
|
25
|
+
* server's admin token from ARBITER_ADMIN_TOKEN. Needs no project here and changes nothing in one.
|
|
26
|
+
*/
|
|
27
|
+
async function unpublish(opts = {}) {
|
|
28
|
+
if (opts.board || opts.admin)
|
|
29
|
+
return takedown(opts);
|
|
30
|
+
const root = (0, store_1.findRoot)(opts.cwd);
|
|
31
|
+
const paths = (0, store_1.resolvePaths)(root);
|
|
32
|
+
const steps = [];
|
|
33
|
+
const link = (0, hosted_1.readLinkOrNull)(paths);
|
|
34
|
+
if (!link) {
|
|
35
|
+
steps.push({ step: 'board', outcome: 'failed', note: 'this project has no hosted board (.arbiter/hosted.json)' });
|
|
36
|
+
return { ok: false, steps, url: null };
|
|
37
|
+
}
|
|
38
|
+
if (!opts.yes) {
|
|
39
|
+
steps.push({
|
|
40
|
+
step: 'board',
|
|
41
|
+
outcome: 'skipped',
|
|
42
|
+
note: `nothing deleted. This deletes ${link.shareUrl} for everyone: the board, its pictures and every comment on it, saving the comments to .arbiter/comments.json first. To go ahead: npx arbiter unpublish --yes`,
|
|
43
|
+
});
|
|
44
|
+
return { ok: false, steps, url: link.shareUrl };
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const r = await (0, hosted_1.unpublishHosted)(paths);
|
|
48
|
+
steps.push({ step: 'comments', outcome: 'done', note: `${r.saved} saved to .arbiter/comments.json` });
|
|
49
|
+
steps.push({ step: 'board', outcome: 'done', note: `deleted ${r.link.shareUrl}, with ${r.pictures} picture${r.pictures === 1 ? '' : 's'} and ${r.comments} comment${r.comments === 1 ? '' : 's'}` });
|
|
50
|
+
steps.push({ step: 'link', outcome: 'done', note: 'removed .arbiter/hosted.json and .arbiter/hosted.token — commit that, so teammates stop publishing to it' });
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
steps.push({ step: 'board', outcome: 'failed', note: e.message });
|
|
54
|
+
return { ok: false, steps, url: null };
|
|
55
|
+
}
|
|
56
|
+
// The workflow would now run on every push and fail: it never creates a board from CI.
|
|
57
|
+
if (node_fs_1.default.existsSync(node_path_1.default.join(root, publish_1.WORKFLOW_FILE))) {
|
|
58
|
+
steps.push({ step: 'workflow', outcome: 'skipped', note: `${publish_1.WORKFLOW_FILE} still runs on every push, and will fail now there's no board. Delete it` });
|
|
59
|
+
}
|
|
60
|
+
return { ok: true, steps, url: null };
|
|
61
|
+
}
|
|
62
|
+
async function takedown(opts) {
|
|
63
|
+
const fail = (note) => ({ ok: false, steps: [{ step: 'board', outcome: 'failed', note }], url: null });
|
|
64
|
+
if (!opts.admin)
|
|
65
|
+
return fail("a board link is for taking down someone else's board, with --admin. To delete this project's own board, leave the link out");
|
|
66
|
+
if (!opts.board)
|
|
67
|
+
return fail('--admin needs the link of the board to take down: npx arbiter unpublish <board link> --admin --yes');
|
|
68
|
+
const board = (0, hosted_1.parseBoardLink)(opts.board);
|
|
69
|
+
if (!board)
|
|
70
|
+
return fail(`${opts.board} isn't a board link. One looks like https://arbiter.design/p/abc123`);
|
|
71
|
+
const admin = process.env[hosted_1.ADMIN_ENV]?.trim();
|
|
72
|
+
if (!admin)
|
|
73
|
+
return fail(`set ${hosted_1.ADMIN_ENV} to the admin token of ${board.origin} first`);
|
|
74
|
+
if (!opts.yes) {
|
|
75
|
+
return {
|
|
76
|
+
ok: false,
|
|
77
|
+
steps: [{ step: 'board', outcome: 'skipped', note: `nothing deleted. This deletes ${board.shareUrl} for everyone: the board, its pictures and every comment on it, and its owner can't get the comments back. To go ahead: npx arbiter unpublish ${board.shareUrl} --admin --yes` }],
|
|
78
|
+
url: board.shareUrl,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
const r = await (0, hosted_1.takedownHosted)(board.shareUrl, admin);
|
|
83
|
+
return { ok: true, steps: [{ step: 'board', outcome: 'done', note: `deleted ${r.shareUrl}, with ${r.pictures} picture${r.pictures === 1 ? '' : 's'} and ${r.comments} comment${r.comments === 1 ? '' : 's'}` }], url: null };
|
|
84
|
+
}
|
|
85
|
+
catch (e) {
|
|
86
|
+
return fail(e.message);
|
|
87
|
+
}
|
|
88
|
+
}
|
package/dist/format.js
CHANGED
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
* - **Rejected:**
|
|
10
10
|
* - Inline confirm — clicked through without reading
|
|
11
11
|
* - **Trigger:** Delete-project flow used an inline "Are you sure?" link
|
|
12
|
-
* - **Scope:** pattern:destructive-confirm · **Dimension:** interaction · **Level:** pattern · **Class:** judgment · **Verdict:** rule
|
|
13
|
-
* - **Author:** edmond · **Date:** 2026-09-15T14:32:10Z · **Commit:** a1b2c3d · **Supersedes:** —
|
|
12
|
+
* - **Scope:** pattern:destructive-confirm · **Dimension:** interaction · **Level:** pattern · **Class:** judgment · **Verdict:** rule · **Call:** asked
|
|
13
|
+
* - **Author:** edmond · **Date:** 2026-09-15T14:32:10Z · **Commit:** a1b2c3d · **Supersedes:** — · **Against:** D-0004
|
|
14
|
+
*
|
|
15
|
+
* `Call`, `Against`, `Candidate` and the `Reworded:` list appear only when set.
|
|
14
16
|
*
|
|
15
17
|
* DECISIONS.md groups entries under `## <Dimension>` headings; the archive is
|
|
16
18
|
* flat and chronological. Round-trip is lossless: parse(format(d)) deep-equals d.
|
|
@@ -29,7 +31,7 @@ const schema_1 = require("./schema");
|
|
|
29
31
|
const SEP = ' · ';
|
|
30
32
|
const NONE = '—';
|
|
31
33
|
const HEADING = /^#{2,3} ([DP]-\d{4,}) · (.*)$/;
|
|
32
|
-
const
|
|
34
|
+
const LIST_ITEM = /^ {2}- (.*)$/;
|
|
33
35
|
const FIELD = /\*\*([A-Za-z]+):\*\* (.*?)(?=\s·\s\*\*|$)/g;
|
|
34
36
|
/**
|
|
35
37
|
* A value as an entry may hold it: one line, with no `**Field:**` marker of its own. Input is
|
|
@@ -45,9 +47,10 @@ function formatEntry(d) {
|
|
|
45
47
|
...(d.change ? [`- **Change:** ${text(d.change)}`] : []),
|
|
46
48
|
`- **Rationale:** ${text(d.rationale)}`,
|
|
47
49
|
...(d.rejected.length ? ['- **Rejected:**', ...d.rejected.map((r) => ` - ${text(r)}`)] : []),
|
|
50
|
+
...(d.reworded.length ? ['- **Reworded:**', ...d.reworded.map((r) => ` - ${text(r)}`)] : []),
|
|
48
51
|
`- **Trigger:** ${text(d.trigger)}`,
|
|
49
|
-
`- **Scope:** ${text(d.scope)}${SEP}**Dimension:** ${d.dimension}${SEP}**Level:** ${d.level}${SEP}**Class:** ${d.class}${SEP}**Verdict:** ${d.verdict}`,
|
|
50
|
-
`- **Author:** ${text(d.author)}${SEP}**Date:** ${text(d.date)}${SEP}**Commit:** ${d.commit ?? NONE}${SEP}**Supersedes:** ${d.supersedes ?? NONE}${d.candidate ? `${SEP}**Candidate:** ${d.candidate}` : ''}`,
|
|
52
|
+
`- **Scope:** ${text(d.scope)}${SEP}**Dimension:** ${d.dimension}${SEP}**Level:** ${d.level}${SEP}**Class:** ${d.class}${SEP}**Verdict:** ${d.verdict}${d.call ? `${SEP}**Call:** ${d.call}` : ''}`,
|
|
53
|
+
`- **Author:** ${text(d.author)}${SEP}**Date:** ${text(d.date)}${SEP}**Commit:** ${d.commit ?? NONE}${SEP}**Supersedes:** ${d.supersedes ?? NONE}${d.candidate ? `${SEP}**Candidate:** ${d.candidate}` : ''}${d.against ? `${SEP}**Against:** ${d.against}` : ''}`,
|
|
51
54
|
...(d.ref ? [`- **Ref:** ${text(d.ref)}`] : []),
|
|
52
55
|
...(d.files.length ? [`- **Files:** ${d.files.map(text).join(SEP)}`] : []),
|
|
53
56
|
...(d.paths.length ? [`- **Paths:** ${d.paths.map(text).join(SEP)}`] : []),
|
|
@@ -83,7 +86,8 @@ function parseEntries(md) {
|
|
|
83
86
|
const out = [];
|
|
84
87
|
const lines = md.split('\n');
|
|
85
88
|
let cur = null;
|
|
86
|
-
|
|
89
|
+
// The two indented lists an entry can carry.
|
|
90
|
+
let inList = null;
|
|
87
91
|
const flush = () => {
|
|
88
92
|
if (!cur)
|
|
89
93
|
return;
|
|
@@ -95,8 +99,8 @@ function parseEntries(md) {
|
|
|
95
99
|
const h = HEADING.exec(line);
|
|
96
100
|
if (h) {
|
|
97
101
|
flush();
|
|
98
|
-
cur = { id: h[1], decision: h[2].trim(), rejected: [] };
|
|
99
|
-
|
|
102
|
+
cur = { id: h[1], decision: h[2].trim(), rejected: [], reworded: [] };
|
|
103
|
+
inList = null;
|
|
100
104
|
continue;
|
|
101
105
|
}
|
|
102
106
|
if (/^#{1,6} /.test(line)) {
|
|
@@ -106,18 +110,18 @@ function parseEntries(md) {
|
|
|
106
110
|
}
|
|
107
111
|
if (!cur)
|
|
108
112
|
continue;
|
|
109
|
-
if (
|
|
110
|
-
const item =
|
|
113
|
+
if (inList) {
|
|
114
|
+
const item = LIST_ITEM.exec(line);
|
|
111
115
|
if (item) {
|
|
112
|
-
cur.
|
|
116
|
+
cur[inList].push(item[1].trim());
|
|
113
117
|
continue;
|
|
114
118
|
}
|
|
115
|
-
|
|
119
|
+
inList = null;
|
|
116
120
|
}
|
|
117
121
|
if (!line.startsWith('- **'))
|
|
118
122
|
continue;
|
|
119
|
-
if (line === '- **Rejected:**') {
|
|
120
|
-
|
|
123
|
+
if (line === '- **Rejected:**' || line === '- **Reworded:**') {
|
|
124
|
+
inList = line === '- **Rejected:**' ? 'rejected' : 'reworded';
|
|
121
125
|
continue;
|
|
122
126
|
}
|
|
123
127
|
for (const m of line.slice(2).matchAll(FIELD)) {
|
|
@@ -166,6 +170,12 @@ function parseEntries(md) {
|
|
|
166
170
|
case 'candidate':
|
|
167
171
|
cur.candidate = val === NONE ? null : val;
|
|
168
172
|
break;
|
|
173
|
+
case 'against':
|
|
174
|
+
cur.against = val === NONE ? null : val;
|
|
175
|
+
break;
|
|
176
|
+
case 'call':
|
|
177
|
+
cur.call = val === NONE ? null : val;
|
|
178
|
+
break;
|
|
169
179
|
case 'files':
|
|
170
180
|
cur.files = val.split(SEP).map((f) => f.trim()).filter(Boolean);
|
|
171
181
|
break;
|
|
@@ -215,6 +225,9 @@ function complete(p) {
|
|
|
215
225
|
expect: p.expect ?? null,
|
|
216
226
|
verified: p.expect ? (p.verified ?? null) : null,
|
|
217
227
|
candidate: p.candidate ?? null,
|
|
228
|
+
against: p.against ?? null,
|
|
229
|
+
call: p.call ?? null,
|
|
230
|
+
reworded: p.reworded ?? [],
|
|
218
231
|
};
|
|
219
232
|
}
|
|
220
233
|
function activeHeader(count, cap) {
|
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
|
-
|
|
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
|
-
*
|
|
195
|
-
*
|
|
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
|
-
|
|
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')
|
|
@@ -33,6 +37,7 @@ program
|
|
|
33
37
|
.option('--tool <name>', 'with --findings: the scanner name for the record')
|
|
34
38
|
.option('--candidate <id>', 'the candidate (C-0001) this decision was made for')
|
|
35
39
|
.option('--retire <rule-id>', 'drop an active rule with no replacement (needs --why)')
|
|
40
|
+
.option('--reword <rule-id>', 'change an active rule\'s wording, same id (needs --to); the old wording stays on the entry')
|
|
36
41
|
.option('--why <reason>', 'with --retire: why the rule is dead; with a request and --as decline: why not')
|
|
37
42
|
.option('--unverified', 'record even if the named files contradict the claim')
|
|
38
43
|
.option('--as <action>', 'judge a pending id: accept | rule | skip | fix; answer a request id: apply | decline')
|
|
@@ -40,8 +45,9 @@ program
|
|
|
40
45
|
.option('--all', 'with --as: judge every pending item the same way')
|
|
41
46
|
.option('--level <level>', 'with --all: only this level (feature | pattern | polish)')
|
|
42
47
|
.option('--trigger <text>', 'with --all: only items queued for this piece of work')
|
|
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')
|
|
48
|
+
.option('--to <decision>', 'with --as fix: what it should be instead; with --reword: the new wording; with a request and --as apply: what to do instead of what was asked')
|
|
44
49
|
.option('--supersedes <id>', 'the active rule this one replaces')
|
|
50
|
+
.option('--against <rule-id>', 'judging a pending id: the rule it goes against — with --as accept, the logged exception to it')
|
|
45
51
|
.option('--ref <url|key>', 'the ticket this was for: a URL or an issue key like ENG-123')
|
|
46
52
|
.option('--keep-both', 'record alongside overlapping rules instead of replacing one')
|
|
47
53
|
.option('--author <name>', 'override the author')
|
|
@@ -51,6 +57,9 @@ program
|
|
|
51
57
|
if (opts.retire) {
|
|
52
58
|
result = (0, record_1.retire)(opts.retire, opts.why, opts);
|
|
53
59
|
}
|
|
60
|
+
else if (opts.reword) {
|
|
61
|
+
result = (0, record_1.reword)(opts.reword, opts.to, opts);
|
|
62
|
+
}
|
|
54
63
|
else if (opts.findings) {
|
|
55
64
|
result = (0, record_1.queueFindings)(opts.findings, opts);
|
|
56
65
|
}
|
|
@@ -103,6 +112,7 @@ program
|
|
|
103
112
|
.option('--client <name>', 'claude-code or cursor (default: detected)')
|
|
104
113
|
.option('--author <name>', 'who decides rules (default: git user.name)')
|
|
105
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)')
|
|
106
116
|
.option('-y, --yes', 'no questions — use detected values')
|
|
107
117
|
.option('--skip-install', 'do not add the package to devDependencies')
|
|
108
118
|
.action(async (opts) => {
|
|
@@ -112,6 +122,8 @@ program
|
|
|
112
122
|
process.stdout.write(` ${s.file.padEnd(w)} ${s.outcome}${s.note ? ` — ${s.note}` : ''}\n`);
|
|
113
123
|
}
|
|
114
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)());
|
|
115
127
|
if (opts.destination === 'git') {
|
|
116
128
|
process.stdout.write([
|
|
117
129
|
'',
|
|
@@ -218,15 +230,35 @@ program
|
|
|
218
230
|
.option('--on-push', 'also write a GitHub Actions workflow that republishes on every push, and set its secret')
|
|
219
231
|
.option('--auto', 'republish whenever the record changes — no GitHub, no CI, no repository needed')
|
|
220
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')
|
|
221
235
|
.action(async (opts) => {
|
|
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 });
|
|
223
|
-
|
|
224
|
-
for (const s of r.steps)
|
|
225
|
-
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);
|
|
226
238
|
if (r.url)
|
|
227
239
|
process.stdout.write(`\n${r.ok ? 'Live in about a minute' : 'Once the failed step is fixed'}: ${r.url}\n`);
|
|
228
240
|
process.exit(r.ok ? 0 : 1);
|
|
229
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
|
+
});
|
|
230
262
|
program
|
|
231
263
|
.command('pull')
|
|
232
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.')
|
|
@@ -299,6 +331,12 @@ program.parseAsync(process.argv).catch((e) => {
|
|
|
299
331
|
process.stderr.write(`arbiter: ${e.message}\n`);
|
|
300
332
|
process.exit(1);
|
|
301
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
|
+
}
|
|
302
340
|
/** With `hosted.auto`, the board follows the record. Prints a line when it does, or why it didn't. */
|
|
303
341
|
async function boardUpdated(cwd) {
|
|
304
342
|
const line = await (0, autopublish_1.autoPublish)(cwd);
|
package/dist/schema.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* nowhere to live.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.CANDIDATE_ID = exports.PENDING_ID = exports.DECISION_ID = exports.ID_PATTERN = exports.FIELDS = exports.DIMENSIONS = exports.SCOPE_KINDS = exports.VERDICTS = exports.LEVELS = exports.CLASSES = void 0;
|
|
9
|
+
exports.CANDIDATE_ID = exports.PENDING_ID = exports.DECISION_ID = exports.ID_PATTERN = exports.FIELDS = exports.CALLS = exports.DIMENSIONS = exports.SCOPE_KINDS = exports.VERDICTS = exports.LEVELS = exports.CLASSES = void 0;
|
|
10
10
|
exports.validateInput = validateInput;
|
|
11
11
|
exports.parseScope = parseScope;
|
|
12
12
|
exports.CLASSES = ['mechanical', 'judgment'];
|
|
@@ -21,6 +21,13 @@ exports.VERDICTS = ['fix', 'accept', 'rule', 'retire'];
|
|
|
21
21
|
exports.SCOPE_KINDS = ['global', 'file', 'pattern'];
|
|
22
22
|
/** What the decision is about. Fixed order — DECISIONS.md groups by it in this order. */
|
|
23
23
|
exports.DIMENSIONS = ['structure', 'interaction', 'states', 'content', 'visual', 'motion', 'access'];
|
|
24
|
+
/**
|
|
25
|
+
* Who made the call. What lets a real choice be told from the agent's habit:
|
|
26
|
+
* asked the user asked for it
|
|
27
|
+
* corrected the user changed what the agent did — what they rejected is on record
|
|
28
|
+
* agent the agent weighed real options and picked one
|
|
29
|
+
*/
|
|
30
|
+
exports.CALLS = ['asked', 'corrected', 'agent'];
|
|
24
31
|
/** Fields in file order. Also the order they're serialized in. */
|
|
25
32
|
exports.FIELDS = [
|
|
26
33
|
'id',
|
|
@@ -44,6 +51,9 @@ exports.FIELDS = [
|
|
|
44
51
|
'expect',
|
|
45
52
|
'verified',
|
|
46
53
|
'candidate',
|
|
54
|
+
'against',
|
|
55
|
+
'call',
|
|
56
|
+
'reworded',
|
|
47
57
|
];
|
|
48
58
|
exports.ID_PATTERN = /^[DP]-\d{4,}$/;
|
|
49
59
|
exports.DECISION_ID = /^D-\d{4,}$/;
|
|
@@ -86,6 +96,7 @@ function validateInput(raw, options = {}) {
|
|
|
86
96
|
const commit = line('commit', false);
|
|
87
97
|
const date = line('date', false);
|
|
88
98
|
const ref = line('ref', false);
|
|
99
|
+
const call = line('call', false);
|
|
89
100
|
const supersedesRaw = obj.supersedes;
|
|
90
101
|
if (cls !== undefined && !exports.CLASSES.includes(cls)) {
|
|
91
102
|
errors.push(`class must be one of ${exports.CLASSES.join(' | ')}`);
|
|
@@ -99,6 +110,9 @@ function validateInput(raw, options = {}) {
|
|
|
99
110
|
if (level !== undefined && !exports.LEVELS.includes(level)) {
|
|
100
111
|
errors.push(`level must be one of ${exports.LEVELS.join(' | ')}`);
|
|
101
112
|
}
|
|
113
|
+
if (call !== undefined && !exports.CALLS.includes(call)) {
|
|
114
|
+
errors.push(`call must be one of ${exports.CALLS.join(' | ')}`);
|
|
115
|
+
}
|
|
102
116
|
if (scope !== undefined && !SCOPE_PATTERN.test(scope)) {
|
|
103
117
|
errors.push('scope must be `global`, `file:<path>`, or `pattern:<name>`');
|
|
104
118
|
}
|
|
@@ -193,8 +207,19 @@ function validateInput(raw, options = {}) {
|
|
|
193
207
|
}
|
|
194
208
|
if (verdict === 'retire' && !supersedes)
|
|
195
209
|
errors.push('retire needs supersedes: the rule being retired');
|
|
210
|
+
let against;
|
|
211
|
+
if (obj.against !== undefined) {
|
|
212
|
+
if (obj.against === null || obj.against === '')
|
|
213
|
+
against = null;
|
|
214
|
+
else if (typeof obj.against !== 'string' || !exports.DECISION_ID.test(obj.against.trim()))
|
|
215
|
+
errors.push('against must be a rule id like D-0011, or null');
|
|
216
|
+
else
|
|
217
|
+
against = obj.against.trim();
|
|
218
|
+
}
|
|
219
|
+
if (against && verdict === 'retire')
|
|
220
|
+
errors.push('against does not apply to a retire');
|
|
196
221
|
for (const key of Object.keys(obj)) {
|
|
197
|
-
if (!exports.FIELDS.includes(key) || key === 'verified' || key === 'id')
|
|
222
|
+
if (!exports.FIELDS.includes(key) || key === 'verified' || key === 'id' || key === 'reworded')
|
|
198
223
|
errors.push(`unknown field: ${key}`);
|
|
199
224
|
}
|
|
200
225
|
if (errors.length)
|
|
@@ -221,6 +246,8 @@ function validateInput(raw, options = {}) {
|
|
|
221
246
|
...(date !== undefined && { date }),
|
|
222
247
|
...(supersedes !== undefined && { supersedes }),
|
|
223
248
|
...(ref !== undefined && { ref }),
|
|
249
|
+
...(against !== undefined && { against }),
|
|
250
|
+
...(call !== undefined && { call: call }),
|
|
224
251
|
},
|
|
225
252
|
};
|
|
226
253
|
}
|
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 `
|
|
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
|
*/
|
package/dist/wording.js
ADDED
|
@@ -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
|
+
}
|