arbiterdesign 0.1.7 → 0.1.9
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 +38 -40
- package/dist/area-names.js +120 -0
- package/dist/areas.js +131 -0
- package/dist/board-types.js +9 -0
- package/dist/candidates.js +7 -1
- package/dist/commands/areas.js +153 -0
- package/dist/commands/candidate.js +4 -2
- package/dist/commands/decision.js +100 -0
- package/dist/commands/export.js +88 -125
- package/dist/commands/init.js +89 -2
- package/dist/commands/prompt.js +12 -4
- package/dist/commands/publish.js +18 -1
- package/dist/commands/record.js +152 -3
- package/dist/commands/rename.js +123 -0
- package/dist/commands/review.js +469 -76
- package/dist/commands/rules.js +8 -1
- package/dist/commands/setup.js +1 -0
- package/dist/commands/snapshot.js +24 -2
- package/dist/commands/sweep.js +1 -1
- package/dist/commands/unpublish.js +88 -0
- package/dist/comments.js +24 -0
- package/dist/handoff.js +283 -0
- package/dist/hook.js +80 -0
- package/dist/hosted.js +117 -20
- package/dist/index.js +93 -24
- package/dist/localboard.js +219 -0
- package/dist/lock.js +134 -0
- package/dist/overlap.js +16 -0
- package/dist/pictures.js +4 -0
- package/dist/settings.js +107 -0
- package/dist/store.js +6 -5
- package/dist/verify.js +4 -2
- package/dist/wording.js +65 -0
- package/dist/work.js +139 -1
- package/package.json +3 -2
- package/templates/SKILL.md +169 -50
- package/templates/board/board.css +2 -0
- package/templates/board/board.js +25 -0
- package/templates/board/index.html +15 -0
- 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/hooks/arbiter-board.cjs +50 -0
- package/templates/review.html +0 -600
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `arbiter areas` — where everything sits on the board: Folder → Area → Change → Decision.
|
|
4
|
+
*
|
|
5
|
+
* The agent reads it before naming a piece of work, so new work joins an area that's already there
|
|
6
|
+
* ("Review inbox — Sorting") instead of starting one of its own. `--save` writes the folders, once the
|
|
7
|
+
* person has said yes to them; it's the same file the board's side nav saves (`.arbiter/areas.json`).
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.structureOf = structureOf;
|
|
11
|
+
exports.structureText = structureText;
|
|
12
|
+
exports.areasCommand = areasCommand;
|
|
13
|
+
exports.saveFolders = saveFolders;
|
|
14
|
+
exports.placement = placement;
|
|
15
|
+
const store_1 = require("../store");
|
|
16
|
+
const localboard_1 = require("../localboard");
|
|
17
|
+
const area_names_1 = require("../area-names");
|
|
18
|
+
const areas_1 = require("../areas");
|
|
19
|
+
const work_1 = require("../work");
|
|
20
|
+
/** The board as the side nav shows it: folders with their areas, then the areas in no folder, each with its changes. */
|
|
21
|
+
function structureOf(paths) {
|
|
22
|
+
const data = (0, localboard_1.liveBoard)(paths);
|
|
23
|
+
// Work with nothing judged yet is placed by what's waiting on it, as the board places it.
|
|
24
|
+
const cards = data.board.candidates.map((c) => (c.work && !c.decisions.length ? { ...c, decisions: data.queued[c.id] ?? [] } : c));
|
|
25
|
+
const of = (0, area_names_1.areasFor)(cards);
|
|
26
|
+
const changes = new Map();
|
|
27
|
+
for (const c of cards)
|
|
28
|
+
changes.set(of(c), [...(changes.get(of(c)) ?? []), c.name]);
|
|
29
|
+
const view = (name) => ({ name, changes: changes.get(name) ?? [] });
|
|
30
|
+
const rows = (0, area_names_1.layoutOf)([...changes.keys()], data.arrangement);
|
|
31
|
+
const folders = rows.flatMap((e) => (e.kind === 'folder' ? [{ id: e.id, name: e.name, areas: e.areas.map(view) }] : []));
|
|
32
|
+
const loose = rows.flatMap((e) => (e.kind === 'area' ? [view(e.name)] : []));
|
|
33
|
+
return { folders, loose, counts: { folders: folders.length, areas: changes.size, changes: cards.length } };
|
|
34
|
+
}
|
|
35
|
+
/** The structure as lines: folders, their areas with a count, the changes under each. */
|
|
36
|
+
function structureText(s) {
|
|
37
|
+
const n = (k, one) => `${k} ${one}${k === 1 ? '' : 's'}`;
|
|
38
|
+
const out = [`Areas · ${[s.counts.folders ? n(s.counts.folders, 'folder') : '', n(s.counts.areas, 'area'), n(s.counts.changes, 'change')].filter(Boolean).join(', ')}`, ''];
|
|
39
|
+
const area = (a, indent) => {
|
|
40
|
+
out.push(`${indent}${a.name} · ${a.changes.length}`);
|
|
41
|
+
for (const c of a.changes)
|
|
42
|
+
out.push(`${indent} ${c}`);
|
|
43
|
+
};
|
|
44
|
+
for (const f of s.folders) {
|
|
45
|
+
out.push(f.name);
|
|
46
|
+
if (!f.areas.length)
|
|
47
|
+
out.push(' (empty)');
|
|
48
|
+
for (const a of f.areas)
|
|
49
|
+
area(a, ' ');
|
|
50
|
+
}
|
|
51
|
+
if (s.folders.length && s.loose.length)
|
|
52
|
+
out.push('Not in a folder');
|
|
53
|
+
for (const a of s.loose)
|
|
54
|
+
area(a, s.folders.length ? ' ' : '');
|
|
55
|
+
return out.join('\n');
|
|
56
|
+
}
|
|
57
|
+
function areasCommand(opts = {}) {
|
|
58
|
+
const paths = (0, store_1.resolvePaths)((0, store_1.findRoot)(opts.cwd));
|
|
59
|
+
if (opts.save !== undefined) {
|
|
60
|
+
const saved = saveFolders(paths, opts.save);
|
|
61
|
+
if (saved.exitCode !== 0)
|
|
62
|
+
return saved;
|
|
63
|
+
}
|
|
64
|
+
const s = structureOf(paths);
|
|
65
|
+
// Turned off in Preferences: the agent doesn't offer to group areas into folders.
|
|
66
|
+
const quiet = (0, store_1.readConfig)(paths)?.suggestFolders === false;
|
|
67
|
+
return {
|
|
68
|
+
exitCode: 0,
|
|
69
|
+
output: { ...(opts.save !== undefined ? { status: 'saved' } : {}), ...s, ...(quiet ? { suggestFolders: false } : {}) },
|
|
70
|
+
text: structureText(s) + (quiet ? '\n\nFolder suggestions are off (Preferences, on the board): don\'t offer to group areas.' : ''),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Folders as the agent proposes them, once the person has said yes: `{ "folders": [{ "name", "areas" }] }`.
|
|
75
|
+
* It replaces the folders there were. Every area named has to be on the board, so a typo is caught
|
|
76
|
+
* rather than saved; areas left out stay where they are, in no folder.
|
|
77
|
+
*/
|
|
78
|
+
function saveFolders(paths, raw) {
|
|
79
|
+
let input;
|
|
80
|
+
try {
|
|
81
|
+
input = JSON.parse(raw);
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
return fail([`not JSON: ${e.message}`]);
|
|
85
|
+
}
|
|
86
|
+
if (!Array.isArray(input?.folders))
|
|
87
|
+
return fail(['expected { "folders": [{ "name": "Local board", "areas": ["Review inbox", "Change page"] }] }']);
|
|
88
|
+
const s = structureOf(paths);
|
|
89
|
+
const known = new Map([...s.folders.flatMap((f) => f.areas), ...s.loose].map((a) => [a.name.toLowerCase(), a.name]));
|
|
90
|
+
const unknown = input.folders.flatMap((f) => (f.areas ?? []).filter((a) => !known.has(String(a).trim().toLowerCase())));
|
|
91
|
+
if (unknown.length)
|
|
92
|
+
return fail([`not an area on the board: ${unknown.join(', ')}`, `areas: ${[...known.values()].join(', ')}`]);
|
|
93
|
+
// Ids from names, kept for folders that already had one, so the board's open folders stay open.
|
|
94
|
+
const had = new Map(s.folders.map((f) => [f.name.toLowerCase(), f.id]));
|
|
95
|
+
const used = new Set();
|
|
96
|
+
const idFor = (name) => {
|
|
97
|
+
const base = had.get(name.toLowerCase()) ?? (name.toLowerCase().replace(/[^a-z0-9]+/g, '').slice(0, 20) || 'folder');
|
|
98
|
+
let id = base;
|
|
99
|
+
for (let i = 2; used.has(id); i++)
|
|
100
|
+
id = `${base.slice(0, 20)}${i}`;
|
|
101
|
+
used.add(id);
|
|
102
|
+
return id;
|
|
103
|
+
};
|
|
104
|
+
const folders = input.folders.map((f) => ({ kind: 'folder', id: f.id && /^[a-z0-9]{1,24}$/.test(f.id) ? f.id : idFor(String(f.name ?? '')), name: String(f.name ?? ''), areas: (f.areas ?? []).map((a) => known.get(String(a).trim().toLowerCase())) }));
|
|
105
|
+
const filed = new Set(folders.flatMap((f) => (f.kind === 'folder' ? f.areas.map((a) => a.toLowerCase()) : [])));
|
|
106
|
+
// The folders first, in the order given, then every area left out, in the order it had.
|
|
107
|
+
const rest = [...s.folders.flatMap((f) => f.areas), ...s.loose].filter((a) => !filed.has(a.name.toLowerCase())).map((a) => ({ kind: 'area', name: a.name }));
|
|
108
|
+
const r = (0, areas_1.cleanArrangement)((0, area_names_1.arrangementOf)([...folders, ...rest]));
|
|
109
|
+
if (!r.ok)
|
|
110
|
+
return fail(r.errors);
|
|
111
|
+
(0, areas_1.writeArrangement)(paths, r.value);
|
|
112
|
+
return { exitCode: 0, output: { status: 'saved' } };
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* For the reply to `record --pending`: the area a piece of work landed in, and, when it's the first
|
|
116
|
+
* decision of new work that starts an area of its own, the areas already there, so the agent can
|
|
117
|
+
* rename it into one of them.
|
|
118
|
+
*/
|
|
119
|
+
function placement(paths, entry, earlier) {
|
|
120
|
+
if (entry.candidate)
|
|
121
|
+
return {};
|
|
122
|
+
try {
|
|
123
|
+
const s = structureOf(paths);
|
|
124
|
+
const all = [...s.folders.flatMap((f) => f.areas.map((a) => ({ ...a, folder: f.name }))), ...s.loose.map((a) => ({ ...a, folder: null }))];
|
|
125
|
+
const mine = all.find((a) => a.changes.some((c) => (0, work_1.workId)(c) === (0, work_1.workId)(entry.trigger)));
|
|
126
|
+
if (!mine)
|
|
127
|
+
return {};
|
|
128
|
+
const first = !earlier.some((d) => (0, work_1.workId)(d.trigger) === (0, work_1.workId)(entry.trigger)) && !(0, store_1.readArchive)(paths).some((d) => (0, work_1.workId)(d.trigger) === (0, work_1.workId)(entry.trigger));
|
|
129
|
+
const others = all.filter((a) => a !== mine).map((a) => a.name);
|
|
130
|
+
const fresh = first && mine.changes.length === 1 && others.length > 0;
|
|
131
|
+
// New work beside changes already in its area: it may continue one of them, and then it belongs in it.
|
|
132
|
+
const beside = first && !fresh ? mine.changes.filter((c) => (0, work_1.workId)(c) !== (0, work_1.workId)(entry.trigger)) : [];
|
|
133
|
+
return {
|
|
134
|
+
area: mine.name,
|
|
135
|
+
...(mine.folder ? { folder: mine.folder } : {}),
|
|
136
|
+
...(fresh ? {
|
|
137
|
+
newArea: true,
|
|
138
|
+
areas: others.slice(0, 40),
|
|
139
|
+
hint: `"${entry.trigger}" starts an area of its own. If it belongs in one of these, rename it: npx arbiter rename "${entry.trigger}" "<Area> — <what changed>"`,
|
|
140
|
+
} : {}),
|
|
141
|
+
...(beside.length ? {
|
|
142
|
+
newChange: true,
|
|
143
|
+
changes: beside.slice(0, 40),
|
|
144
|
+
hint: `"${entry.trigger}" is a new change in ${mine.name}. If it continues one of these, merge it, so its picture becomes that change's next version: npx arbiter rename "${entry.trigger}" "<that change>" --merge`,
|
|
145
|
+
} : {}),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
// Where it sits is a courtesy: a board that won't read never stops a decision being queued.
|
|
150
|
+
return {};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const fail = (errors) => ({ exitCode: 1, output: { status: 'invalid', errors } });
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* candidate C-0002 --state rejected --why "…"
|
|
8
8
|
* candidate C-0002 --snapshot new.png
|
|
9
9
|
*
|
|
10
|
-
* Approving one direction supersedes its siblings (same feature, still open)
|
|
10
|
+
* Approving one direction supersedes its siblings (same set: feature and name head, still open)
|
|
11
11
|
* with the reason retained — the rejected branches are the point.
|
|
12
12
|
*/
|
|
13
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
@@ -24,6 +24,7 @@ const node_child_process_1 = require("node:child_process");
|
|
|
24
24
|
const candidates_1 = require("../candidates");
|
|
25
25
|
const store_1 = require("../store");
|
|
26
26
|
const destination_1 = require("../destination");
|
|
27
|
+
const area_names_1 = require("../area-names");
|
|
27
28
|
function addCandidate(name, opts = {}) {
|
|
28
29
|
if (!name?.trim())
|
|
29
30
|
return fail(['a name is required']);
|
|
@@ -84,7 +85,8 @@ function updateCandidate(id, opts = {}) {
|
|
|
84
85
|
c.reason = opts.why.trim() || null;
|
|
85
86
|
if (state === 'approved' && !opts.keepOthers && c.feature) {
|
|
86
87
|
for (const sib of all) {
|
|
87
|
-
|
|
88
|
+
// Only its own set: another thing explored in the same area stays open.
|
|
89
|
+
if (sib.id === c.id || sib.feature !== c.feature || !(0, area_names_1.sameHead)(sib, c))
|
|
88
90
|
continue;
|
|
89
91
|
if (sib.state !== 'generated' && sib.state !== 'in_review')
|
|
90
92
|
continue;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* What a change's page can do to one of its decisions, beside what Design rules does to a rule: fix
|
|
4
|
+
* the words of its Change line, make a decision you only confirmed a rule, and put back a decision
|
|
5
|
+
* removed from the page by mistake. Removing one is `remove`; a rule is retired instead.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.editChange = editChange;
|
|
9
|
+
exports.promote = promote;
|
|
10
|
+
exports.restoreDecision = restoreDecision;
|
|
11
|
+
const store_1 = require("../store");
|
|
12
|
+
const schema_1 = require("../schema");
|
|
13
|
+
const overlap_1 = require("../overlap");
|
|
14
|
+
const candidate_1 = require("./candidate");
|
|
15
|
+
const candidates_1 = require("../candidates");
|
|
16
|
+
const fail = (errors) => ({ exitCode: 1, output: { status: 'invalid', errors } });
|
|
17
|
+
/**
|
|
18
|
+
* New words for what happened, the Change line, on a decision that isn't a rule (a rule's own words are
|
|
19
|
+
* reworded on Design rules). The id stays; the old words stay on the entry, under Reworded, so editing
|
|
20
|
+
* tidies the wording without quietly changing what was decided.
|
|
21
|
+
*/
|
|
22
|
+
function editChange(id, to, opts = {}) {
|
|
23
|
+
if (!schema_1.DECISION_ID.test(id))
|
|
24
|
+
return fail([`not a decision id: ${id} (looks like D-0003)`]);
|
|
25
|
+
const next = to?.replace(/\s+/g, ' ').trim();
|
|
26
|
+
if (!next)
|
|
27
|
+
return fail(['say what changed, in one line']);
|
|
28
|
+
const paths = (0, store_1.resolvePaths)((0, store_1.findRoot)(opts.cwd));
|
|
29
|
+
const archive = (0, store_1.readArchive)(paths);
|
|
30
|
+
const entry = archive.find((d) => d.id === id);
|
|
31
|
+
if (!entry)
|
|
32
|
+
return fail([`${id} is not in the record`]);
|
|
33
|
+
const was = entry.change ?? entry.decision;
|
|
34
|
+
if (next === was)
|
|
35
|
+
return fail([`${id} already says that`]);
|
|
36
|
+
const edited = { ...entry, change: next, reworded: [...entry.reworded, `Change was: ${was} (until ${(0, store_1.now)().slice(0, 10)})`] };
|
|
37
|
+
(0, store_1.writeArchive)(paths, archive.map((d) => (d.id === id ? edited : d)));
|
|
38
|
+
// A rule's entry in DECISIONS.md carries its Change line too.
|
|
39
|
+
const active = (0, store_1.readActive)(paths);
|
|
40
|
+
if (active.some((d) => d.id === id))
|
|
41
|
+
(0, store_1.writeActive)(paths, active.map((d) => (d.id === id ? { ...d, change: next, reworded: edited.reworded } : d)), (0, store_1.readConfig)(paths)?.activeCap ?? store_1.ACTIVE_CAP);
|
|
42
|
+
if (entry.candidate)
|
|
43
|
+
(0, candidate_1.refreshCandidates)(paths);
|
|
44
|
+
return { exitCode: 0, output: { status: 'edited', id, change: next } };
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Make it a rule, for a decision you only confirmed: the same entry, now a rule in DECISIONS.md, so its
|
|
48
|
+
* id and its page stay as they are. Checked against the rules already there, as any new rule is: an
|
|
49
|
+
* overlap comes back (exit 2) to keep both or replace one, and a full DECISIONS.md (exit 3) waits for room.
|
|
50
|
+
*/
|
|
51
|
+
function promote(id, opts = {}) {
|
|
52
|
+
if (!schema_1.DECISION_ID.test(id))
|
|
53
|
+
return fail([`not a decision id: ${id} (looks like D-0003)`]);
|
|
54
|
+
const paths = (0, store_1.resolvePaths)((0, store_1.findRoot)(opts.cwd));
|
|
55
|
+
const archive = (0, store_1.readArchive)(paths);
|
|
56
|
+
const entry = archive.find((d) => d.id === id);
|
|
57
|
+
if (!entry)
|
|
58
|
+
return fail([`${id} is not in the record`]);
|
|
59
|
+
let active = (0, store_1.readActive)(paths);
|
|
60
|
+
if (active.some((d) => d.id === id))
|
|
61
|
+
return fail([`${id} is a rule already`]);
|
|
62
|
+
if (entry.verdict !== 'accept' && entry.verdict !== 'fix')
|
|
63
|
+
return fail([`${id} can't become a rule`]);
|
|
64
|
+
const config = (0, store_1.readConfig)(paths);
|
|
65
|
+
const cap = config?.activeCap ?? store_1.ACTIVE_CAP;
|
|
66
|
+
if (opts.supersedes) {
|
|
67
|
+
if (!active.some((d) => d.id === opts.supersedes))
|
|
68
|
+
return fail([`${opts.supersedes} is not an active rule`]);
|
|
69
|
+
active = active.filter((d) => d.id !== opts.supersedes);
|
|
70
|
+
}
|
|
71
|
+
else if (!opts.keepBoth) {
|
|
72
|
+
const overlaps = (0, overlap_1.findOverlaps)(entry, active, { ignore: config?.overlap?.ignore });
|
|
73
|
+
// Each with why, as the Review inbox has it: what both apply to (a sure match), or the words they share
|
|
74
|
+
// (a guess), so a guess doesn't read as sure.
|
|
75
|
+
if (overlaps.length)
|
|
76
|
+
return { exitCode: 2, output: { status: 'overlap', overlaps: (0, overlap_1.explainOverlaps)(entry, overlaps, active, new Map((0, candidates_1.readCandidates)(paths).map((c) => [c.id, c.name]))) } };
|
|
77
|
+
}
|
|
78
|
+
// Full: the rules there, so one can be picked for this to replace without leaving the page.
|
|
79
|
+
if (active.length >= cap)
|
|
80
|
+
return { exitCode: 3, output: { status: 'cap', cap, active: active.map((d) => ({ id: d.id, decision: d.decision })), errors: [`DECISIONS.md is full (${cap} rules). Remove one first, or raise the limit in Preferences.`] } };
|
|
81
|
+
const rule = { ...entry, verdict: 'rule', ...(opts.supersedes ? { supersedes: opts.supersedes } : {}) };
|
|
82
|
+
(0, store_1.writeArchive)(paths, archive.map((d) => (d.id === id ? rule : d)));
|
|
83
|
+
(0, store_1.writeActive)(paths, [...active, rule], cap);
|
|
84
|
+
if (rule.candidate)
|
|
85
|
+
(0, candidate_1.refreshCandidates)(paths);
|
|
86
|
+
return { exitCode: 0, output: { status: 'rule', id, active: `${active.length + 1} of ${cap}`, ...(opts.supersedes ? { replaced: opts.supersedes } : {}) } };
|
|
87
|
+
}
|
|
88
|
+
/** Undo for a decision removed on the board: back in the record where it was. */
|
|
89
|
+
function restoreDecision(r, opts = {}) {
|
|
90
|
+
const paths = (0, store_1.resolvePaths)((0, store_1.findRoot)(opts.cwd));
|
|
91
|
+
const archive = (0, store_1.readArchive)(paths);
|
|
92
|
+
if (archive.some((d) => d.id === r.entry.id))
|
|
93
|
+
return fail([`${r.entry.id} is in the record already`]);
|
|
94
|
+
const next = [...archive];
|
|
95
|
+
next.splice(Math.min(r.index, next.length), 0, r.entry);
|
|
96
|
+
(0, store_1.writeArchive)(paths, next);
|
|
97
|
+
if (r.entry.candidate)
|
|
98
|
+
(0, candidate_1.refreshCandidates)(paths);
|
|
99
|
+
return { exitCode: 0, output: { status: 'restored', id: r.entry.id } };
|
|
100
|
+
}
|
package/dist/commands/export.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* `arbiter export` — a
|
|
4
|
-
*
|
|
3
|
+
* `arbiter export` — the local board as a folder, for people without the repo. Open index.html, or
|
|
4
|
+
* put the folder on any static host (`publish --to pages` does). No server, no login.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* The cheap test of Stage 6's assumption: does a stakeholder, given a link,
|
|
11
|
-
* actually look?
|
|
6
|
+
* The same pages `arbiter review` serves (templates/board), read-only: every change with its
|
|
7
|
+
* picture, and the design rules if asked for. No review queue, no buttons, and no comments: people
|
|
8
|
+
* wrote those on the team board, not in a file that gets passed around.
|
|
12
9
|
*/
|
|
13
10
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
11
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -18,44 +15,73 @@ exports.exportBoard = exportBoard;
|
|
|
18
15
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
19
16
|
const node_path_1 = __importDefault(require("node:path"));
|
|
20
17
|
const node_child_process_1 = require("node:child_process");
|
|
18
|
+
const localboard_1 = require("../localboard");
|
|
21
19
|
const candidates_1 = require("../candidates");
|
|
22
|
-
const
|
|
23
|
-
const format_1 = require("../format");
|
|
20
|
+
const work_1 = require("../work");
|
|
24
21
|
const store_1 = require("../store");
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const
|
|
22
|
+
const areas_1 = require("../areas");
|
|
23
|
+
const BOARD = node_path_1.default.join(__dirname, '..', '..', 'templates', 'board');
|
|
24
|
+
const FONTS = node_path_1.default.join(__dirname, '..', '..', 'templates', 'fonts');
|
|
25
|
+
const PICTURES = 'snapshots/';
|
|
26
|
+
// Line and paragraph separators end a line inside a <script>, so they are escaped like <.
|
|
27
|
+
const LINE_SEP = String.fromCharCode(0x2028);
|
|
28
|
+
const PARA_SEP = String.fromCharCode(0x2029);
|
|
28
29
|
function exportBoard(opts = {}) {
|
|
29
30
|
const root = (0, store_1.findRoot)(opts.cwd);
|
|
30
31
|
const paths = (0, store_1.resolvePaths)(root);
|
|
31
32
|
const outDir = node_path_1.default.resolve(root, opts.out ?? 'arbiter-export');
|
|
32
33
|
const snapDir = node_path_1.default.join(outDir, 'snapshots');
|
|
34
|
+
// Pictures from an earlier export go: a screen since removed mustn't stay in a folder people get sent.
|
|
35
|
+
// Only those, by their names: anything else in a snapshots/ folder is someone's own, and stays.
|
|
36
|
+
clearPictures(snapDir);
|
|
33
37
|
node_fs_1.default.mkdirSync(snapDir, { recursive: true });
|
|
34
|
-
|
|
38
|
+
const manifest = (0, localboard_1.boardOf)(paths, { pictures: PICTURES, includeRules: !!opts.includeRules, queued: [] });
|
|
39
|
+
let cards = manifest.candidates;
|
|
35
40
|
if (opts.feature)
|
|
36
|
-
|
|
37
|
-
const byId = new Map(candidates.map((c) => [c.id, c]));
|
|
41
|
+
cards = cards.filter((c) => c.feature === opts.feature);
|
|
38
42
|
let snapshots = 0;
|
|
39
|
-
for (const c of
|
|
43
|
+
for (const c of cards) {
|
|
40
44
|
if (!c.snapshot)
|
|
41
45
|
continue;
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
const file = c.snapshot.slice(PICTURES.length);
|
|
47
|
+
const src = node_path_1.default.join(file.startsWith('W-') ? (0, work_1.workDir)(paths) : (0, candidates_1.candidatesDir)(paths), file);
|
|
48
|
+
if (node_fs_1.default.existsSync(src)) {
|
|
49
|
+
node_fs_1.default.copyFileSync(src, node_path_1.default.join(snapDir, file));
|
|
50
|
+
snapshots++;
|
|
51
|
+
}
|
|
52
|
+
else
|
|
53
|
+
c.snapshot = null;
|
|
54
|
+
// Its earlier pictures too, so the copy shows how it got here.
|
|
55
|
+
if (c.versions) {
|
|
56
|
+
c.versions = c.versions.filter((v) => {
|
|
57
|
+
const rel = v.src.slice(PICTURES.length);
|
|
58
|
+
if (rel === file)
|
|
59
|
+
return true;
|
|
60
|
+
const abs = (0, work_1.historyFile)(paths, rel);
|
|
61
|
+
if (!abs)
|
|
62
|
+
return false;
|
|
63
|
+
node_fs_1.default.mkdirSync(node_path_1.default.dirname(node_path_1.default.join(snapDir, rel)), { recursive: true });
|
|
64
|
+
node_fs_1.default.copyFileSync(abs, node_path_1.default.join(snapDir, rel));
|
|
65
|
+
return true;
|
|
66
|
+
});
|
|
67
|
+
if (c.versions.length < 2)
|
|
68
|
+
delete c.versions;
|
|
69
|
+
}
|
|
47
70
|
}
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
71
|
+
// Read-only: `live: false` keeps the review pages, Done and the team board buttons out of it.
|
|
72
|
+
const board = { ...manifest, candidates: cards, requests: [] };
|
|
73
|
+
// The folders as you made them, so the copy's side nav reads the same as yours. Nobody can move them in it.
|
|
74
|
+
const data = { board, comments: [], waiting: {}, queued: {}, pending: 0, hosted: null, version: null, live: false, arrangement: (0, areas_1.readArrangement)(paths), settings: null };
|
|
75
|
+
// In a <script>, so nothing in a name can close the tag or run.
|
|
76
|
+
const json = JSON.stringify(data).replace(/</g, '\\u003c').split(LINE_SEP).join('\\u2028').split(PARA_SEP).join('\\u2029');
|
|
77
|
+
// Functions, not strings: a `$&` in someone's decision would otherwise be read as a pattern.
|
|
78
|
+
const html = node_fs_1.default.readFileSync(node_path_1.default.join(BOARD, 'index.html'), 'utf8')
|
|
79
|
+
.replace('</head>', () => `<style>${fontFaces()}</style>\n</head>`)
|
|
80
|
+
.replace('<script src="board.js">', () => `<script>window.__ARBITER_BOARD__ = ${json};</script>\n<script src="board.js">`);
|
|
57
81
|
const index = node_path_1.default.join(outDir, 'index.html');
|
|
58
82
|
node_fs_1.default.writeFileSync(index, html);
|
|
83
|
+
for (const f of ['board.js', 'board.css'])
|
|
84
|
+
node_fs_1.default.copyFileSync(node_path_1.default.join(BOARD, f), node_path_1.default.join(outDir, f));
|
|
59
85
|
if (opts.open) {
|
|
60
86
|
const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open';
|
|
61
87
|
const args = process.platform === 'win32' ? ['/c', 'start', '', index] : [index];
|
|
@@ -64,100 +90,37 @@ function exportBoard(opts = {}) {
|
|
|
64
90
|
}
|
|
65
91
|
catch { /* path is printed anyway */ }
|
|
66
92
|
}
|
|
67
|
-
return { dir: outDir, index, candidates:
|
|
68
|
-
}
|
|
69
|
-
function page(d) {
|
|
70
|
-
const features = [...new Set(d.candidates.map((c) => c.feature ?? 'Other'))];
|
|
71
|
-
const body = d.candidates.length
|
|
72
|
-
? features.map((f) => section(f, d.candidates.filter((c) => (c.feature ?? 'Other') === f), d)).join('\n')
|
|
73
|
-
: `<p class="empty">Nothing to show yet.</p>`;
|
|
74
|
-
const rules = d.rules ? rulesSection(d.rules) : '';
|
|
75
|
-
const counts = STATE_ORDER.map((s) => [s, d.candidates.filter((c) => c.state === s).length]).filter(([, n]) => n);
|
|
76
|
-
return `<!doctype html>
|
|
77
|
-
<html lang="en">
|
|
78
|
-
<head>
|
|
79
|
-
<meta charset="utf-8">
|
|
80
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
81
|
-
<title>${esc(d.project)} — design decisions</title>
|
|
82
|
-
<style>
|
|
83
|
-
:root { color-scheme: light dark; --bg:#fafaf9; --card:#fff; --ink:#1c1917; --muted:#78716c; --line:#e7e5e4; --tag:#f5f5f4; --ok:#15803d; --bad:#b91c1c; --warn:#b45309; }
|
|
84
|
-
@media (prefers-color-scheme: dark) { :root { --bg:#0c0a09; --card:#1c1917; --ink:#fafaf9; --muted:#a8a29e; --line:#292524; --tag:#292524; --ok:#4ade80; --bad:#f87171; --warn:#fbbf24; } }
|
|
85
|
-
* { box-sizing: border-box; }
|
|
86
|
-
body { margin:0; background:var(--bg); color:var(--ink); font:16px/1.55 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,sans-serif; padding:0 20px 80px; }
|
|
87
|
-
header, main { max-width: 920px; margin: 0 auto; }
|
|
88
|
-
header { padding: 40px 0 8px; }
|
|
89
|
-
header h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
|
|
90
|
-
header p { color: var(--muted); margin: 6px 0 0; font-size: 14px; }
|
|
91
|
-
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 44px 0 14px; }
|
|
92
|
-
.cand { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 24px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px; margin-bottom: 14px; }
|
|
93
|
-
.cand.lesser { grid-template-columns: 220px minmax(0,1fr); padding: 16px 20px; opacity: .85; }
|
|
94
|
-
.cand.noshot { grid-template-columns: minmax(0,1fr); }
|
|
95
|
-
@media (max-width: 680px) { .cand, .cand.lesser { grid-template-columns: 1fr; } }
|
|
96
|
-
.shot { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--tag); min-height: 60px; display:flex; align-items:center; justify-content:center; color: var(--muted); font-size: 13px; }
|
|
97
|
-
.shot img { display:block; width:100%; height:auto; }
|
|
98
|
-
h3 { font-size: 18px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
|
|
99
|
-
.lesser h3 { font-size: 15px; }
|
|
100
|
-
.state { font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 999px; background: var(--tag); color: var(--muted); vertical-align: 2px; margin-left: 8px; }
|
|
101
|
-
.state.approved { color: var(--ok); } .state.rejected, .state.superseded { color: var(--bad); } .state.in_review { color: var(--warn); }
|
|
102
|
-
.who { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
|
|
103
|
-
.reason { font-style: italic; margin: 0 0 12px; }
|
|
104
|
-
.decs h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }
|
|
105
|
-
.decs ul { margin: 0; padding-left: 18px; }
|
|
106
|
-
.decs li { margin: 3px 0; }
|
|
107
|
-
.decs li small { color: var(--muted); display: block; }
|
|
108
|
-
.empty { color: var(--muted); text-align: center; padding: 80px 0; }
|
|
109
|
-
.rules { margin-top: 60px; border-top: 1px solid var(--line); padding-top: 30px; }
|
|
110
|
-
.rules ul { padding-left: 18px; } .rules li { margin: 6px 0; } .rules li small { color: var(--muted); display: block; }
|
|
111
|
-
footer { max-width: 920px; margin: 60px auto 0; color: var(--muted); font-size: 13px; }
|
|
112
|
-
</style>
|
|
113
|
-
</head>
|
|
114
|
-
<body>
|
|
115
|
-
<header>
|
|
116
|
-
<h1>${esc(d.project)} — design decisions</h1>
|
|
117
|
-
<p>${d.candidates.length} screen${d.candidates.length === 1 ? '' : 's'}${counts.length ? ' · ' + counts.map(([s, n]) => `${n} ${STATE_LABEL[s].toLowerCase()}`).join(' · ') : ''} · exported ${d.generated}</p>
|
|
118
|
-
</header>
|
|
119
|
-
<main>
|
|
120
|
-
${body}
|
|
121
|
-
${rules}
|
|
122
|
-
</main>
|
|
123
|
-
<footer>Read-only. Feedback goes to whoever owns these decisions — they decide what becomes a rule. Made with Arbiter.</footer>
|
|
124
|
-
</body>
|
|
125
|
-
</html>
|
|
126
|
-
`;
|
|
127
|
-
}
|
|
128
|
-
function section(feature, cands, d) {
|
|
129
|
-
const sorted = [...cands].sort((a, b) => STATE_ORDER.indexOf(a.state) - STATE_ORDER.indexOf(b.state) || a.id.localeCompare(b.id));
|
|
130
|
-
return `<h2>${esc(feature)}</h2>\n${sorted.map((c) => card(c, d)).join('\n')}`;
|
|
93
|
+
return { dir: outDir, index, candidates: cards.length, snapshots };
|
|
131
94
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return '';
|
|
156
|
-
const groups = schema_1.DIMENSIONS.map((dim) => [dim, rules.filter((r) => r.dimension === dim)]).filter(([, rs]) => rs.length);
|
|
157
|
-
return `<section class="rules"><h2>Design rules · ${rules.length}</h2>${groups
|
|
158
|
-
.map(([dim, rs]) => `<h4>${format_1.DIMENSION_LABELS[dim]}</h4><ul>${rs.map((r) => `<li>${esc(r.decision)}<small>${esc(r.rationale)}</small></li>`).join('')}</ul>`)
|
|
159
|
-
.join('')}</section>`;
|
|
95
|
+
/**
|
|
96
|
+
* The pictures an export writes, and only those: a card's or a piece of work's own (C-0001.png,
|
|
97
|
+
* W-settings-billing.png) and its earlier ones under history/<W-…>/. A folder left empty goes too.
|
|
98
|
+
*/
|
|
99
|
+
function clearPictures(snapDir) {
|
|
100
|
+
const id = /^(C-\d{4,}|W-[a-z0-9-]{1,48})$/;
|
|
101
|
+
const picture = /^(C-\d{4,}|W-[a-z0-9-]{1,48})\.(png|jpe?g|webp|gif|svg)$/;
|
|
102
|
+
const list = (dir) => { try {
|
|
103
|
+
return node_fs_1.default.readdirSync(dir, { withFileTypes: true });
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return [];
|
|
107
|
+
} };
|
|
108
|
+
for (const e of list(snapDir))
|
|
109
|
+
if (e.isFile() && picture.test(e.name))
|
|
110
|
+
node_fs_1.default.rmSync(node_path_1.default.join(snapDir, e.name));
|
|
111
|
+
const history = node_path_1.default.join(snapDir, 'history');
|
|
112
|
+
for (const e of list(history))
|
|
113
|
+
if (e.isDirectory() && id.test(e.name))
|
|
114
|
+
node_fs_1.default.rmSync(node_path_1.default.join(history, e.name), { recursive: true, force: true });
|
|
115
|
+
for (const dir of [history, snapDir])
|
|
116
|
+
if (node_fs_1.default.existsSync(dir) && !list(dir).length)
|
|
117
|
+
node_fs_1.default.rmdirSync(dir);
|
|
160
118
|
}
|
|
161
|
-
|
|
162
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Geist, inside the page. Opened from disk, a browser won't load a font file sitting next to it, and
|
|
121
|
+
* the board would fall back to the system font.
|
|
122
|
+
*/
|
|
123
|
+
function fontFaces() {
|
|
124
|
+
const face = (family, file) => `@font-face{font-family:"${family}";src:url(data:font/woff2;base64,${node_fs_1.default.readFileSync(node_path_1.default.join(FONTS, file)).toString('base64')}) format("woff2");font-weight:100 900;font-display:swap}`;
|
|
125
|
+
return face('Geist', 'Geist-Variable.woff2') + face('Geist Mono', 'GeistMono-Variable.woff2');
|
|
163
126
|
}
|