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
package/dist/store.js CHANGED
@@ -7,7 +7,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
7
7
  return (mod && mod.__esModule) ? mod : { "default": mod };
8
8
  };
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ACTIVE_CAP = void 0;
10
+ exports.withCommand = exports.RULES_FILE_ALTERNATIVES = exports.RULES_FILE = exports.ACTIVE_CAP = void 0;
11
+ exports.rulesFileAllowed = rulesFileAllowed;
12
+ exports.rulesName = rulesName;
13
+ exports.chooseRulesFile = chooseRulesFile;
14
+ exports.arbiterCommand = arbiterCommand;
15
+ exports.takeRulesMoved = takeRulesMoved;
16
+ exports.rulesMovedLine = rulesMovedLine;
11
17
  exports.resolvePaths = resolvePaths;
12
18
  exports.findRoot = findRoot;
13
19
  exports.readConfig = readConfig;
@@ -30,11 +36,149 @@ const node_os_1 = __importDefault(require("node:os"));
30
36
  const node_path_1 = __importDefault(require("node:path"));
31
37
  const node_child_process_1 = require("node:child_process");
32
38
  const format_1 = require("./format");
39
+ const lock_1 = require("./lock");
33
40
  exports.ACTIVE_CAP = 40;
41
+ /** The rules file's name when arbiter.json doesn't give another. */
42
+ exports.RULES_FILE = 'DECISIONS.md';
43
+ /** Where the rules go instead when the project's DECISIONS.md is someone else's, in order. */
44
+ exports.RULES_FILE_ALTERNATIVES = ['DESIGN-DECISIONS.md', 'ARBITER-DECISIONS.md'];
45
+ /** Files a rules file may never be: Arbiter rewrites its rules file in full. CANDIDATES.md is Arbiter's own index. */
46
+ const NEVER_RULES = new Set(['readme.md', 'claude.md', 'agents.md', 'changelog.md', 'license.md', 'contributing.md', 'candidates.md', 'design.md']);
47
+ /** Names Windows keeps for devices, whatever follows the dot. */
48
+ const DEVICE = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i;
49
+ /**
50
+ * A rules file arbiter.json may name: a Markdown file in the project's root and nothing else, so
51
+ * the setting can't reach outside the project or into a file that belongs to something else. A
52
+ * different spelling of DECISIONS.md is refused too: on Windows and macOS it is the same file.
53
+ */
54
+ function rulesFileAllowed(name) {
55
+ if (typeof name !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._-]*\.md$/.test(name))
56
+ return false;
57
+ const lower = name.toLowerCase();
58
+ return !NEVER_RULES.has(lower) && !DEVICE.test(name) && !(lower === exports.RULES_FILE.toLowerCase() && name !== exports.RULES_FILE);
59
+ }
60
+ /** The rules file arbiter.json names, or DECISIONS.md. A missing or unreadable arbiter.json is the default. */
61
+ function rulesFileOf(root) {
62
+ try {
63
+ const name = JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(root, 'arbiter.json'), 'utf8')).decisions;
64
+ if (rulesFileAllowed(name))
65
+ return name;
66
+ }
67
+ catch {
68
+ // No arbiter.json yet, or one that isn't JSON: readConfig says so where it matters.
69
+ }
70
+ return exports.RULES_FILE;
71
+ }
72
+ /** The rules file's name as people see it in messages, the skill and the board: `DECISIONS.md` unless arbiter.json names another. */
73
+ function rulesName(paths) {
74
+ return node_path_1.default.basename(paths.decisions);
75
+ }
76
+ /**
77
+ * Where this project's rules live, at install. DECISIONS.md, unless the project already has one of
78
+ * its own (a decision log, say): Arbiter rewrites its rules file whenever a rule changes, so it never
79
+ * takes over a file it didn't write. Then the first free name of the alternatives. A name arbiter.json
80
+ * already gives is kept, so a re-run never moves the rules.
81
+ */
82
+ function chooseRulesFile(root, existing) {
83
+ const named = existing?.decisions;
84
+ // A name set by hand is kept only while it's free or Arbiter's: never someone else's file.
85
+ if (rulesFileAllowed(named) && (!node_fs_1.default.existsSync(node_path_1.default.join(root, named)) || (0, format_1.isRulesFile)(node_fs_1.default.readFileSync(node_path_1.default.join(root, named), 'utf8'))))
86
+ return named;
87
+ for (const name of [exports.RULES_FILE, ...exports.RULES_FILE_ALTERNATIVES]) {
88
+ const abs = node_path_1.default.join(root, name);
89
+ if (!node_fs_1.default.existsSync(abs) || (0, format_1.isRulesFile)(node_fs_1.default.readFileSync(abs, 'utf8')))
90
+ return name;
91
+ }
92
+ throw new Error(`${[exports.RULES_FILE, ...exports.RULES_FILE_ALTERNATIVES].join(', ')} are all files of your own, so Arbiter has nowhere to keep its rules. Set "decisions" in arbiter.json to a new file name, like "UI-DECISIONS.md", and run init again.`);
93
+ }
94
+ /**
95
+ * How the agent and the board run Arbiter in this project. `npx arbiter` finds the copy install added to
96
+ * package.json. With none there (no package.json, or install couldn't add it), `npx arbiter` would fetch
97
+ * the npm package called arbiter, which is someone else's, so the full name is used instead.
98
+ */
99
+ function arbiterCommand(root) {
100
+ try {
101
+ const pkg = JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(root, 'package.json'), 'utf8'));
102
+ if (pkg.name === 'arbiterdesign' || pkg.devDependencies?.arbiterdesign || pkg.dependencies?.arbiterdesign)
103
+ return 'npx arbiter';
104
+ }
105
+ catch {
106
+ // No package.json, or one that isn't JSON.
107
+ }
108
+ return 'npx arbiterdesign';
109
+ }
110
+ /** Text that runs `npx arbiter …`, as this project runs it. */
111
+ const withCommand = (text, command) => (command === 'npx arbiter' ? text : text.replace(/npx arbiter(?![A-Za-z])/g, command));
112
+ exports.withCommand = withCommand;
113
+ /** What to tell the user when this command moved the rules to a file of their own: once, then null. */
114
+ let moved = null;
115
+ function takeRulesMoved() {
116
+ const file = moved;
117
+ moved = null;
118
+ return file ? { file, say: rulesMovedLine(file, true) } : null;
119
+ }
120
+ /** The one line that says why the rules are in another file. `now`: it happened just now, not at install. */
121
+ function rulesMovedLine(file, now = false) {
122
+ return now
123
+ ? `You already have a DECISIONS.md, so Arbiter has put your design rules in their own file, ${file}. Yours stays exactly as it is: Arbiter never writes to it.`
124
+ : `You already have a DECISIONS.md, so Arbiter keeps your design rules in their own file, ${file}. Yours stays exactly as it is: Arbiter never writes to it.`;
125
+ }
126
+ /**
127
+ * Points `paths` at the rules file arbiter.json names now. A board started before the rules moved, or
128
+ * any `paths` resolved before, would otherwise read and write the old file, which may be someone else's.
129
+ */
130
+ function syncRulesPath(paths) {
131
+ const now = node_path_1.default.join(paths.root, rulesFileOf(paths.root));
132
+ if (now !== paths.decisions)
133
+ paths.decisions = now;
134
+ }
135
+ /**
136
+ * Before the first write into DECISIONS.md: if it isn't Arbiter's (the project's own, from before an
137
+ * install that checked, with no `npx arbiter update` since, or with no install at all), it's left alone.
138
+ * The rules go in a new file of their own, arbiter.json says which (made, if there's none), and what
139
+ * points the agent at the rules points there instead. With no free name, nothing moves: the file is
140
+ * still written with every line of theirs kept.
141
+ */
142
+ function claimRulesFile(paths) {
143
+ if (!node_fs_1.default.existsSync(paths.decisions))
144
+ return;
145
+ let config;
146
+ try {
147
+ config = readConfig(paths);
148
+ }
149
+ catch {
150
+ if (!(0, format_1.isRulesFile)(node_fs_1.default.readFileSync(paths.decisions, 'utf8'))) {
151
+ throw new Error(`arbiter.json isn't valid JSON, so Arbiter can't tell where its rules go, and ${rulesName(paths)} isn't one it wrote. Nothing was written to it. Fix arbiter.json, then try again.`);
152
+ }
153
+ return;
154
+ }
155
+ if (config && rulesFileAllowed(config.decisions) && config.decisions !== exports.RULES_FILE)
156
+ return;
157
+ if ((0, format_1.isRulesFile)(node_fs_1.default.readFileSync(paths.decisions, 'utf8')))
158
+ return;
159
+ // Only a name nobody's using: rules already in a file mean arbiter.json lost track, and a guess could write over them.
160
+ const name = exports.RULES_FILE_ALTERNATIVES.find((n) => {
161
+ const abs = node_path_1.default.join(paths.root, n);
162
+ return !node_fs_1.default.existsSync(abs) || !node_fs_1.default.readFileSync(abs, 'utf8').trim();
163
+ });
164
+ if (!name)
165
+ return;
166
+ writeConfig(paths, { ...(config ?? { version: 1, destination: 'local' }), decisions: name });
167
+ paths.decisions = node_path_1.default.join(paths.root, name);
168
+ moved = name;
169
+ try {
170
+ // Here and not at the top: init reads this file, so a top-level import would go round in a circle.
171
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
172
+ require('./commands/init').pointAgentsAt(paths.root, config?.client, name);
173
+ }
174
+ catch {
175
+ // The rules are safe either way; `npx arbiter update` points the agent at them.
176
+ }
177
+ }
34
178
  function resolvePaths(root = process.cwd()) {
35
179
  return {
36
180
  root,
37
- decisions: node_path_1.default.join(root, 'DECISIONS.md'),
181
+ decisions: node_path_1.default.join(root, rulesFileOf(root)),
38
182
  archiveDir: node_path_1.default.join(root, '.arbiter'),
39
183
  archive: node_path_1.default.join(root, '.arbiter', 'archive.md'),
40
184
  pending: node_path_1.default.join(root, '.arbiter', 'pending.md'),
@@ -59,16 +203,28 @@ function readConfig(paths) {
59
203
  return JSON.parse(node_fs_1.default.readFileSync(paths.config, 'utf8'));
60
204
  }
61
205
  function writeConfig(paths, config) {
62
- node_fs_1.default.writeFileSync(paths.config, JSON.stringify(config, null, 2) + '\n');
206
+ (0, lock_1.writeAtomic)(paths.config, JSON.stringify(config, null, 2) + '\n');
63
207
  }
64
208
  function readActive(paths) {
209
+ syncRulesPath(paths);
65
210
  if (!node_fs_1.default.existsSync(paths.decisions))
66
211
  return [];
67
212
  return (0, format_1.parseEntries)(node_fs_1.default.readFileSync(paths.decisions, 'utf8'));
68
213
  }
69
- /** Rewrites DECISIONS.md in full. Entries are re-serialized, so hand edits survive. */
214
+ /**
215
+ * Rewrites the rules file in full. Entries are re-serialized, so hand edits to them survive, and
216
+ * anything else written in the file (a preamble, a section of notes) is kept word for word: above
217
+ * the rules if it was above them, below otherwise.
218
+ */
70
219
  function writeActive(paths, decisions, cap = exports.ACTIVE_CAP) {
71
- node_fs_1.default.writeFileSync(paths.decisions, (0, format_1.activeHeader)(decisions.length, cap) + '\n' + (0, format_1.formatGrouped)(decisions));
220
+ syncRulesPath(paths);
221
+ claimRulesFile(paths);
222
+ const before = node_fs_1.default.existsSync(paths.decisions) ? node_fs_1.default.readFileSync(paths.decisions, 'utf8') : '';
223
+ // A file arbiter.json names by hand that turns out to be someone else's: never written into.
224
+ if (before.trim() && !(0, format_1.isRulesFile)(before) && rulesName(paths) !== exports.RULES_FILE) {
225
+ throw new Error(`arbiter.json names ${rulesName(paths)} as the rules file, but it isn't one Arbiter wrote, so nothing was written to it. Point "decisions" in arbiter.json at a new file name.`);
226
+ }
227
+ (0, lock_1.writeAtomic)(paths.decisions, (0, format_1.formatActive)(decisions, cap, (0, format_1.notesOf)(before)));
72
228
  }
73
229
  function readArchive(paths) {
74
230
  if (!node_fs_1.default.existsSync(paths.archive))
@@ -79,7 +235,7 @@ function readArchive(paths) {
79
235
  function appendArchive(paths, d) {
80
236
  node_fs_1.default.mkdirSync(paths.archiveDir, { recursive: true });
81
237
  const exists = node_fs_1.default.existsSync(paths.archive);
82
- const prefix = exists ? '\n' : (0, format_1.archiveHeader)() + '\n';
238
+ const prefix = exists ? '\n' : (0, format_1.archiveHeader)(rulesName(paths)) + '\n';
83
239
  node_fs_1.default.appendFileSync(paths.archive, prefix + (0, format_1.formatEntry)(d));
84
240
  }
85
241
  /**
@@ -89,7 +245,7 @@ function appendArchive(paths, d) {
89
245
  */
90
246
  function writeArchive(paths, decisions) {
91
247
  node_fs_1.default.mkdirSync(paths.archiveDir, { recursive: true });
92
- node_fs_1.default.writeFileSync(paths.archive, (0, format_1.archiveHeader)() + '\n' + decisions.map(format_1.formatEntry).join('\n'));
248
+ (0, lock_1.writeAtomic)(paths.archive, (0, format_1.archiveHeader)(rulesName(paths)) + '\n' + decisions.map(format_1.formatEntry).join('\n'));
93
249
  }
94
250
  function readPending(paths) {
95
251
  if (!node_fs_1.default.existsSync(paths.pending))
@@ -99,7 +255,7 @@ function readPending(paths) {
99
255
  /** Rewrites pending.md in full. */
100
256
  function writePending(paths, decisions) {
101
257
  node_fs_1.default.mkdirSync(paths.archiveDir, { recursive: true });
102
- node_fs_1.default.writeFileSync(paths.pending, (0, format_1.pendingHeader)() + '\n' + decisions.map(format_1.formatEntry).join('\n'));
258
+ (0, lock_1.writeAtomic)(paths.pending, (0, format_1.pendingHeader)(rulesName(paths)) + '\n' + decisions.map(format_1.formatEntry).join('\n'));
103
259
  }
104
260
  /** Next P- id. Pending ids are never reused within the file but may repeat once it empties. */
105
261
  function nextPendingId(pending) {
package/dist/verify.js CHANGED
@@ -49,8 +49,10 @@ function verify(root, files, expect) {
49
49
  for (const needle of expect?.absent ?? []) {
50
50
  for (const [f, text] of contents) {
51
51
  const line = lineOf(text, needle);
52
- if (line !== null)
53
- checks.push({ kind: 'absent', file: f, needle, ok: false, detail: `found at line ${line}` });
52
+ if (line === null)
53
+ continue;
54
+ const found = needle.startsWith('regex:') ? new RegExp(needle.slice(6)).exec(text)?.[0] : undefined;
55
+ checks.push({ kind: 'absent', file: f, needle, ok: false, detail: `found at line ${line}`, ...(found !== undefined && { found }) });
54
56
  }
55
57
  if (!checks.some((c) => c.kind === 'absent' && c.needle === needle && !c.ok)) {
56
58
  checks.push({ kind: 'absent', file: files.join(', '), needle, ok: true });
package/dist/work.js CHANGED
@@ -8,12 +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
12
  exports.readRenames = readRenames;
13
13
  exports.addRename = addRename;
14
14
  exports.workSnapshot = workSnapshot;
15
15
  exports.copyImage = copyImage;
16
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;
17
23
  const node_fs_1 = __importDefault(require("node:fs"));
18
24
  const node_path_1 = __importDefault(require("node:path"));
19
25
  const node_child_process_1 = require("node:child_process");
@@ -91,3 +97,106 @@ function captureImage(dir, id) {
91
97
  return { ok: false, error: 'capture cancelled — no snapshot saved' };
92
98
  return { ok: true, file: `${id}.png` };
93
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.8",
3
+ "version": "0.1.10",
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
  },