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.
Files changed (44) hide show
  1. package/README.md +38 -40
  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 +89 -2
  11. package/dist/commands/prompt.js +12 -4
  12. package/dist/commands/publish.js +18 -1
  13. package/dist/commands/record.js +152 -3
  14. package/dist/commands/rename.js +123 -0
  15. package/dist/commands/review.js +469 -76
  16. package/dist/commands/rules.js +8 -1
  17. package/dist/commands/setup.js +1 -0
  18. package/dist/commands/snapshot.js +24 -2
  19. package/dist/commands/sweep.js +1 -1
  20. package/dist/commands/unpublish.js +88 -0
  21. package/dist/comments.js +24 -0
  22. package/dist/handoff.js +283 -0
  23. package/dist/hook.js +80 -0
  24. package/dist/hosted.js +117 -20
  25. package/dist/index.js +93 -24
  26. package/dist/localboard.js +219 -0
  27. package/dist/lock.js +134 -0
  28. package/dist/overlap.js +16 -0
  29. package/dist/pictures.js +4 -0
  30. package/dist/settings.js +107 -0
  31. package/dist/store.js +6 -5
  32. package/dist/verify.js +4 -2
  33. package/dist/wording.js +65 -0
  34. package/dist/work.js +139 -1
  35. package/package.json +3 -2
  36. package/templates/SKILL.md +169 -50
  37. package/templates/board/board.css +2 -0
  38. package/templates/board/board.js +25 -0
  39. package/templates/board/index.html +15 -0
  40. package/templates/fonts/Geist-Variable.woff2 +0 -0
  41. package/templates/fonts/GeistMono-Variable.woff2 +0 -0
  42. package/templates/fonts/OFL.txt +92 -0
  43. package/templates/hooks/arbiter-board.cjs +50 -0
  44. package/templates/review.html +0 -600
package/dist/work.js CHANGED
@@ -8,10 +8,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
8
8
  return (mod && mod.__esModule) ? mod : { "default": mod };
9
9
  };
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.workDir = exports.workId = void 0;
11
+ exports.KEEP_VERSIONS = exports.workDir = exports.workId = void 0;
12
+ exports.readRenames = readRenames;
13
+ exports.addRename = addRename;
12
14
  exports.workSnapshot = workSnapshot;
13
15
  exports.copyImage = copyImage;
14
16
  exports.captureImage = captureImage;
17
+ exports.keepEarlier = keepEarlier;
18
+ exports.restoreEarlier = restoreEarlier;
19
+ exports.moveHistory = moveHistory;
20
+ exports.workVersions = workVersions;
21
+ exports.historyFile = historyFile;
22
+ exports.mergePictures = mergePictures;
15
23
  const node_fs_1 = __importDefault(require("node:fs"));
16
24
  const node_path_1 = __importDefault(require("node:path"));
17
25
  const node_child_process_1 = require("node:child_process");
@@ -21,6 +29,33 @@ const workId = (trigger) => 'W-' + trigger.toLowerCase().replace(/[^a-z0-9]+/g,
21
29
  exports.workId = workId;
22
30
  const workDir = (paths) => node_path_1.default.join(paths.archiveDir, 'work');
23
31
  exports.workDir = workDir;
32
+ const RENAMED_FILE = 'renamed.json';
33
+ function readRenames(paths) {
34
+ const f = node_path_1.default.join(paths.archiveDir, RENAMED_FILE);
35
+ if (!node_fs_1.default.existsSync(f))
36
+ return [];
37
+ try {
38
+ const all = JSON.parse(node_fs_1.default.readFileSync(f, 'utf8').replace(/^/, ''));
39
+ if (!Array.isArray(all))
40
+ throw new Error('not a list');
41
+ return all.filter((r) => typeof r?.from === 'string' && typeof r?.to === 'string');
42
+ }
43
+ catch (e) {
44
+ throw new Error(`.arbiter/${RENAMED_FILE} can't be read (${e.message.split('\n')[0]}) — a merge conflict? Fix the file, then run this again.`);
45
+ }
46
+ }
47
+ /**
48
+ * Note one rename. Earlier names that led to `from` now lead to `to`, so a card renamed twice still
49
+ * gathers all its comments; and nothing leads away from `to`, which is a live name again.
50
+ */
51
+ function addRename(paths, from, to) {
52
+ const all = readRenames(paths)
53
+ .filter((r) => r.from !== to && r.from !== from)
54
+ .map((r) => (r.to === from ? { ...r, to } : r));
55
+ all.push({ from, to });
56
+ node_fs_1.default.mkdirSync(paths.archiveDir, { recursive: true });
57
+ node_fs_1.default.writeFileSync(node_path_1.default.join(paths.archiveDir, RENAMED_FILE), JSON.stringify(all, null, 2) + '\n');
58
+ }
24
59
  /** The snapshot file for a piece of work, if one was attached. */
25
60
  function workSnapshot(paths, id) {
26
61
  for (const ext of IMAGE_EXT) {
@@ -62,3 +97,106 @@ function captureImage(dir, id) {
62
97
  return { ok: false, error: 'capture cancelled — no snapshot saved' };
63
98
  return { ok: true, file: `${id}.png` };
64
99
  }
100
+ /**
101
+ * Earlier pictures of a piece of work, so the board can show how it got where it is. A new picture
102
+ * doesn't overwrite the last: the last moves to `.arbiter/work/history/<id>/<when it was taken>.<ext>`,
103
+ * and the newest stays where it always was, `<id>.<ext>`, so everything that reads the current picture
104
+ * still finds it. The ten most recent earlier pictures are kept.
105
+ */
106
+ exports.KEEP_VERSIONS = 10;
107
+ const HISTORY = 'history';
108
+ const STAMP = /^(\d{4}-\d{2}-\d{2})T(\d{2})-(\d{2})-(\d{2})(?:-(\d{3}))?Z$/;
109
+ const stampOf = (d) => d.toISOString().replace(/:/g, '-').replace('.', '-');
110
+ const dateOfStamp = (s) => {
111
+ const m = STAMP.exec(s);
112
+ return m ? `${m[1]}T${m[2]}:${m[3]}:${m[4]}.${m[5] ?? '000'}Z` : null;
113
+ };
114
+ /** The current picture moves into the history, dated when it was taken. Returns where it went, to put it back if the new one fails. */
115
+ function keepEarlier(paths, id) {
116
+ const cur = workSnapshot(paths, id);
117
+ if (!cur)
118
+ return null;
119
+ const dir = node_path_1.default.join((0, exports.workDir)(paths), HISTORY, id);
120
+ node_fs_1.default.mkdirSync(dir, { recursive: true });
121
+ const to = node_path_1.default.join(dir, stampOf(node_fs_1.default.statSync(cur).mtime) + node_path_1.default.extname(cur).toLowerCase());
122
+ node_fs_1.default.renameSync(cur, to);
123
+ // Only the most recent earlier pictures stay.
124
+ const all = node_fs_1.default.readdirSync(dir).filter((f) => dateOfStamp(node_path_1.default.parse(f).name)).sort();
125
+ for (const f of all.slice(0, Math.max(0, all.length - exports.KEEP_VERSIONS)))
126
+ node_fs_1.default.rmSync(node_path_1.default.join(dir, f), { force: true });
127
+ return { from: cur, to };
128
+ }
129
+ /** A new picture didn't come: the one moved into the history goes back. */
130
+ function restoreEarlier(moved) {
131
+ if (moved && node_fs_1.default.existsSync(moved.to) && !node_fs_1.default.existsSync(moved.from))
132
+ node_fs_1.default.renameSync(moved.to, moved.from);
133
+ }
134
+ /** A renamed piece of work takes its earlier pictures with it. */
135
+ function moveHistory(paths, from, to) {
136
+ const src = node_path_1.default.join((0, exports.workDir)(paths), HISTORY, from);
137
+ if (!node_fs_1.default.existsSync(src))
138
+ return false;
139
+ const dst = node_path_1.default.join((0, exports.workDir)(paths), HISTORY, to);
140
+ node_fs_1.default.rmSync(dst, { recursive: true, force: true });
141
+ node_fs_1.default.mkdirSync(node_path_1.default.dirname(dst), { recursive: true });
142
+ node_fs_1.default.renameSync(src, dst);
143
+ return true;
144
+ }
145
+ /**
146
+ * Every picture of a piece of work, oldest first, the current one last: `file` relative to
147
+ * `.arbiter/work/`, and when it was taken. Empty when there's no picture.
148
+ */
149
+ function workVersions(paths, id) {
150
+ const out = [];
151
+ const dir = node_path_1.default.join((0, exports.workDir)(paths), HISTORY, id);
152
+ if (node_fs_1.default.existsSync(dir)) {
153
+ for (const f of node_fs_1.default.readdirSync(dir).sort()) {
154
+ const date = dateOfStamp(node_path_1.default.parse(f).name);
155
+ if (date && IMAGE_EXT.includes(node_path_1.default.extname(f).toLowerCase()))
156
+ out.push({ file: `${HISTORY}/${id}/${f}`, date });
157
+ }
158
+ }
159
+ const cur = workSnapshot(paths, id);
160
+ if (cur)
161
+ out.push({ file: node_path_1.default.basename(cur), date: node_fs_1.default.statSync(cur).mtime.toISOString() });
162
+ return out;
163
+ }
164
+ /** An earlier picture's path under `.arbiter/work/`, as a URL names it: `history/W-…/2026-11-09T17-39-00-000Z.png`. Null for anything else. */
165
+ function historyFile(paths, rel) {
166
+ const m = /^history\/(W-[a-z0-9-]{1,48})\/([0-9T-]+Z)\.(png|jpe?g|webp|gif|svg)$/.exec(rel);
167
+ if (!m || !dateOfStamp(m[2]))
168
+ return null;
169
+ const abs = node_path_1.default.join((0, exports.workDir)(paths), HISTORY, m[1], `${m[2]}.${m[3]}`);
170
+ return node_fs_1.default.existsSync(abs) ? abs : null;
171
+ }
172
+ /**
173
+ * A piece of work merged into another: every picture of both, by when each was taken, becomes the
174
+ * other's. The newest is its picture; the rest are its earlier pictures, the most recent ten kept.
175
+ * False when the merged one had no pictures.
176
+ */
177
+ function mergePictures(paths, from, to) {
178
+ const mine = workVersions(paths, from);
179
+ if (!mine.length)
180
+ return false;
181
+ const all = [...mine, ...workVersions(paths, to)].map((v) => ({ abs: node_path_1.default.join((0, exports.workDir)(paths), v.file), date: v.date }));
182
+ const dir = node_path_1.default.join((0, exports.workDir)(paths), HISTORY, to);
183
+ node_fs_1.default.mkdirSync(dir, { recursive: true });
184
+ // Everything into the history first, named by when it was taken; then the newest comes back out.
185
+ const staged = all.map((v) => {
186
+ let dest = node_path_1.default.join(dir, stampOf(new Date(v.date)) + node_path_1.default.extname(v.abs).toLowerCase());
187
+ if (dest !== v.abs && node_fs_1.default.existsSync(dest))
188
+ dest = node_path_1.default.join(dir, stampOf(new Date(Date.parse(v.date) + 1)) + node_path_1.default.extname(v.abs).toLowerCase());
189
+ if (dest !== v.abs)
190
+ node_fs_1.default.renameSync(v.abs, dest);
191
+ return { abs: dest, date: v.date };
192
+ }).sort((a, b) => Date.parse(a.date) - Date.parse(b.date));
193
+ const newest = staged[staged.length - 1];
194
+ const cur = node_path_1.default.join((0, exports.workDir)(paths), to + node_path_1.default.extname(newest.abs));
195
+ node_fs_1.default.renameSync(newest.abs, cur);
196
+ node_fs_1.default.utimesSync(cur, new Date(newest.date), new Date(newest.date));
197
+ const left = node_fs_1.default.readdirSync(dir).filter((f) => dateOfStamp(node_path_1.default.parse(f).name)).sort();
198
+ for (const f of left.slice(0, Math.max(0, left.length - exports.KEEP_VERSIONS)))
199
+ node_fs_1.default.rmSync(node_path_1.default.join(dir, f), { force: true });
200
+ node_fs_1.default.rmSync(node_path_1.default.join((0, exports.workDir)(paths), HISTORY, from), { recursive: true, force: true });
201
+ return true;
202
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arbiterdesign",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Records design decisions made during agent-assisted UI work and feeds them back into the agent's context.",
5
5
  "homepage": "https://arbiter.design",
6
6
  "repository": {
@@ -28,7 +28,8 @@
28
28
  "templates"
29
29
  ],
30
30
  "scripts": {
31
- "build": "tsc -p tsconfig.json",
31
+ "build": "tsc -p tsconfig.json && node board/build.mjs",
32
+ "board:install": "npm install --prefix board",
32
33
  "prepare": "npm run build",
33
34
  "test": "node --test \"dist/test/**/*.test.js\""
34
35
  },