arbiterdesign 0.1.8 → 0.1.10

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.
Files changed (42) hide show
  1. package/README.md +288 -242
  2. package/dist/area-names.js +120 -0
  3. package/dist/areas.js +131 -0
  4. package/dist/board-types.js +9 -0
  5. package/dist/candidates.js +7 -1
  6. package/dist/commands/areas.js +153 -0
  7. package/dist/commands/candidate.js +4 -2
  8. package/dist/commands/decision.js +100 -0
  9. package/dist/commands/export.js +88 -125
  10. package/dist/commands/init.js +198 -73
  11. package/dist/commands/invite.js +67 -0
  12. package/dist/commands/publish.js +4 -4
  13. package/dist/commands/record.js +133 -8
  14. package/dist/commands/remove.js +1 -1
  15. package/dist/commands/rename.js +25 -11
  16. package/dist/commands/review.js +458 -78
  17. package/dist/commands/rules.js +22 -3
  18. package/dist/commands/setup.js +1 -0
  19. package/dist/commands/snapshot.js +24 -2
  20. package/dist/commands/sweep.js +1 -1
  21. package/dist/commands/update.js +5 -0
  22. package/dist/comments.js +24 -0
  23. package/dist/format.js +112 -7
  24. package/dist/handoff.js +286 -0
  25. package/dist/hook.js +82 -0
  26. package/dist/hosted.js +50 -17
  27. package/dist/index.js +99 -37
  28. package/dist/localboard.js +219 -0
  29. package/dist/lock.js +134 -0
  30. package/dist/overlap.js +16 -0
  31. package/dist/pictures.js +4 -0
  32. package/dist/settings.js +107 -0
  33. package/dist/store.js +164 -8
  34. package/dist/verify.js +4 -2
  35. package/dist/work.js +110 -1
  36. package/package.json +3 -2
  37. package/templates/SKILL.md +146 -51
  38. package/templates/board/board.css +2 -0
  39. package/templates/board/board.js +25 -0
  40. package/templates/board/index.html +15 -0
  41. package/templates/hooks/arbiter-board.cjs +50 -0
  42. package/templates/review.html +0 -757
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
  /**
3
- * `arbiter export` — a static, self-contained folder of the board for people
4
- * without the repo. index.html + snapshots. No server, no JS, no login.
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
- * Stakeholder view only: screen, state, who approved, why the others lost,
7
- * what was decided — in plain Change language. No verdict buttons, no scope
8
- * tags. Feedback comes back through a human; comments never become rules.
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 schema_1 = require("../schema");
23
- const format_1 = require("../format");
20
+ const work_1 = require("../work");
24
21
  const store_1 = require("../store");
25
- const STATE_ORDER = ['approved', 'in_review', 'generated', 'rejected', 'superseded'];
26
- /** In a designer's words, as the hosted board says them. The record keeps its own (`generated`, `superseded`). */
27
- const STATE_LABEL = { approved: 'Approved', in_review: 'In review', generated: 'Draft', rejected: 'Rejected', superseded: 'Replaced' };
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
- let candidates = (0, candidates_1.readCandidates)(paths);
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
- candidates = candidates.filter((c) => c.feature === opts.feature);
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 candidates) {
43
+ for (const c of cards) {
40
44
  if (!c.snapshot)
41
45
  continue;
42
- const src = node_path_1.default.join((0, candidates_1.candidatesDir)(paths), c.snapshot);
43
- if (!node_fs_1.default.existsSync(src))
44
- continue;
45
- node_fs_1.default.copyFileSync(src, node_path_1.default.join(snapDir, c.snapshot));
46
- snapshots++;
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
- const project = (0, store_1.readConfig)(paths)?.author ? node_path_1.default.basename(root) : node_path_1.default.basename(root);
49
- const html = page({
50
- project,
51
- generated: new Date().toISOString().slice(0, 10),
52
- candidates,
53
- byId,
54
- decisions: (id) => (0, candidates_1.decisionsFor)(paths, id).filter((d) => d.verdict !== 'pending' && d.level !== 'polish'),
55
- rules: opts.includeRules ? (0, store_1.readActive)(paths) : null,
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, rulesFile: (0, store_1.rulesName)(paths) };
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: candidates.length, snapshots };
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
- function card(c, d) {
133
- const lesser = c.state === 'rejected' || c.state === 'superseded';
134
- const by = c.supersededBy ? d.byId.get(c.supersededBy) : null;
135
- const state = c.state === 'superseded' && by ? `Replaced by ${esc(by.name)}` : STATE_LABEL[c.state];
136
- // No picture, no frame — the card is its words alone, as on the hosted board.
137
- const shot = c.snapshot ? `<div class="shot"><img src="snapshots/${esc(c.snapshot)}" alt="${esc(c.name)}"></div>` : '';
138
- const decs = d.decisions(c.id);
139
- const decisions = decs.length
140
- ? `<div class="decs"><h4>Decided here</h4><ul>${decs.map((x) => `<li>${esc(x.change ?? x.decision)}${x.rejected.length ? `<small>over ${esc(x.rejected.map((r) => r.split(' — ')[0]).join(', '))}</small>` : ''}</li>`).join('')}</ul></div>`
141
- : '';
142
- return `<article class="cand${lesser ? ' lesser' : ''}${shot ? '' : ' noshot'}">
143
- ${shot}
144
- <div>
145
- <h3>${esc(c.name)}<span class="state ${c.state}">${state}</span></h3>
146
- <p class="who">${esc(c.author)} · ${c.date.slice(0, 10)}</p>
147
- ${c.reason ? `<p class="reason">“${esc(c.reason)}”</p>` : ''}
148
- ${c.notes ? `<p>${esc(c.notes)}</p>` : ''}
149
- ${decisions}
150
- </div>
151
- </article>`;
152
- }
153
- function rulesSection(rules) {
154
- if (!rules.length)
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
- function esc(s) {
162
- return s.replace(/[&<>"']/g, (ch) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[ch]);
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
  }