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
@@ -10,13 +10,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
10
10
  return (mod && mod.__esModule) ? mod : { "default": mod };
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.skillMarker = exports.SKILL_MARKER = exports.PKG_ROOT = exports.AGENTS_LINE = void 0;
13
+ exports.withRulesFile = exports.skillMarker = exports.SKILL_MARKER = exports.PKG_ROOT = exports.AGENTS_LINE = exports.agentsLine = void 0;
14
14
  exports.selfVersion = selfVersion;
15
15
  exports.skillPath = skillPath;
16
16
  exports.init = init;
17
17
  exports.detectClient = detectClient;
18
18
  exports.askCheckin = askCheckin;
19
+ exports.installReport = installReport;
19
20
  exports.checkinHandoff = checkinHandoff;
21
+ exports.pointAgentsAt = pointAgentsAt;
20
22
  exports.detectPm = detectPm;
21
23
  exports.addDevDependency = addDevDependency;
22
24
  const node_fs_1 = __importDefault(require("node:fs"));
@@ -27,6 +29,9 @@ const store_1 = require("../store");
27
29
  const format_1 = require("../format");
28
30
  const prompt_1 = require("./prompt");
29
31
  const setup_1 = require("./setup");
32
+ const hook_1 = require("../hook");
33
+ const handoff_1 = require("../handoff");
34
+ const lock_1 = require("../lock");
30
35
  const AGENTS_MARKER = '<!-- arbiter -->';
31
36
  /**
32
37
  * The one line in AGENTS.md and CLAUDE.md. It's always loaded, so it carries the one thing that has
@@ -34,8 +39,10 @@ const AGENTS_MARKER = '<!-- arbiter -->';
34
39
  * Without it the decision won 17 times in 20; with it the design system won 20 in 20, and an
35
40
  * exception won 20 in 20 (clash study, Opus 5.5, October 2026).
36
41
  */
37
- exports.AGENTS_LINE = `Before any UI work, read \`DECISIONS.md\` — the design decisions this project has already made. Follow them; don't re-decide them. Record new ones with the \`arbiter\` skill. ` +
42
+ const agentsLine = (rules = store_1.RULES_FILE) => `Before any UI work, read \`${rules}\` — the design decisions this project has already made. Follow them; don't re-decide them. Record new ones with the \`arbiter\` skill. ` +
38
43
  `If the request, or the design system (DESIGN.md, design-system or pattern docs, component guidelines, or the shared components), goes against a decision, don't build yet: ask first, the way the \`arbiter\` skill shows. A decision written as an exception ("Exception to the design system: …") beats the design system without asking: follow it and say so. ${AGENTS_MARKER}`;
44
+ exports.agentsLine = agentsLine;
45
+ exports.AGENTS_LINE = (0, exports.agentsLine)();
39
46
  exports.PKG_ROOT = node_path_1.default.join(__dirname, '..', '..');
40
47
  const SKILL_TEMPLATE = node_path_1.default.join(exports.PKG_ROOT, 'templates', 'SKILL.md');
41
48
  /** The version of the package that's running. */
@@ -59,49 +66,38 @@ async function init(opts = {}) {
59
66
  const paths = (0, store_1.resolvePaths)(root);
60
67
  const existing = (0, store_1.readConfig)(paths);
61
68
  const steps = [];
62
- const ask = opts.yes ? null : new prompt_1.Prompter();
69
+ // Nobody at the terminal (an agent ran this, or --yes): nothing is asked, or even printed as a
70
+ // question. The closing lines hand the check-in question to the agent instead.
71
+ const ask = opts.yes || !(opts.interactive ?? !!process.stdin.isTTY) ? null : new prompt_1.Prompter();
72
+ // Before anything is asked or written: a project whose names are all taken stops here, untouched.
73
+ const rulesFile = (0, store_1.chooseRulesFile)(root, existing);
63
74
  try {
64
- // ── Question 1 (only if ambiguous): which client? ────────────────────
75
+ if (opts.checkin !== undefined && !setup_1.CHECKINS.includes(opts.checkin))
76
+ throw new Error(`--checkin must be one of ${setup_1.CHECKINS.join(' | ')}`);
65
77
  let client = opts.client ?? existing?.client;
66
- if (!client) {
67
- const detected = detectClient(root);
68
- if (detected.length === 1) {
69
- client = detected[0];
70
- console.log(`Detected ${label(client)}.`);
71
- }
72
- else if (ask) {
73
- const hint = detected.length ? 'both found' : 'neither found';
74
- const a = (await ask.question(`Which agent client? (${hint}) [claude-code/cursor] (claude-code): `)).trim();
75
- client = a === 'cursor' ? 'cursor' : 'claude-code';
76
- }
77
- else {
78
- client = 'claude-code';
79
- }
80
- }
81
- // ── Question 2: who holds the pen? ───────────────────────────────────
82
- let author = opts.author ?? existing?.author;
83
- if (!author) {
84
- const guess = (0, store_1.gitUserName)(root) ?? node_os_1.default.userInfo().username;
85
- if (ask) {
86
- const a = (await ask.question(`Who decides rules? (the author when git has no user.name) (${guess}): `)).trim();
87
- author = a || guess;
88
- }
89
- else {
90
- author = guess;
91
- }
92
- }
93
- // ── Question 3: how Arbiter checks in while you work ─────────────────
94
- // Asked once, here, so no /arbiter has to. Nobody at the terminal (an agent ran this, or
95
- // --yes): it stays unanswered, and the closing lines hand the question to the agent.
78
+ const detected = client ? [] : detectClient(root);
79
+ if (!client && detected.length === 1)
80
+ client = detected[0];
81
+ const askClient = !client && !!ask;
82
+ const askCheckinNow = !existing?.onboarded && opts.checkin === undefined && !!ask;
83
+ const questions = Number(askClient) + Number(askCheckinNow);
84
+ if (questions)
85
+ process.stdout.write(`Arbiter is installed. ${questions === 1 ? 'One question' : 'Two questions'} before you start:\n`);
86
+ // ── Which agent (only when the project doesn't say) ──────────────────
87
+ if (!client)
88
+ client = askClient ? await askClientQuestion(ask) : 'claude-code';
89
+ // ── Who holds the pen: git's user.name, as the record already prefers; never asked ──
90
+ const author = opts.author ?? existing?.author ?? (0, store_1.gitUserName)(root) ?? node_os_1.default.userInfo().username;
91
+ // ── How Arbiter checks in while you work ─────────────────────────────
92
+ // Asked once, here, so no /arbiter has to. Nobody at the terminal: it stays unanswered, and the
93
+ // closing lines hand the question to the agent.
96
94
  let checkin = existing?.checkin;
97
95
  let onboarded = existing?.onboarded;
98
96
  if (opts.checkin !== undefined) {
99
- if (!setup_1.CHECKINS.includes(opts.checkin))
100
- throw new Error(`--checkin must be one of ${setup_1.CHECKINS.join(' | ')}`);
101
97
  checkin = opts.checkin;
102
98
  onboarded ??= (0, store_1.now)();
103
99
  }
104
- else if (!onboarded && ask) {
100
+ else if (askCheckinNow) {
105
101
  const picked = await askCheckin(ask);
106
102
  if (picked) {
107
103
  checkin = picked;
@@ -119,6 +115,7 @@ async function init(opts = {}) {
119
115
  ...(opts.destination && { destination: opts.destination }),
120
116
  ...(checkin && { checkin }),
121
117
  ...(onboarded && { onboarded }),
118
+ ...(rulesFile !== store_1.RULES_FILE && { decisions: rulesFile }),
122
119
  };
123
120
  if (!existing) {
124
121
  (0, store_1.writeConfig)(paths, config);
@@ -131,40 +128,56 @@ async function init(opts = {}) {
131
128
  else {
132
129
  steps.push({ file: 'arbiter.json', outcome: 'unchanged' });
133
130
  }
134
- // ── DECISIONS.md — never overwritten once it exists ──────────────────
135
- if (node_fs_1.default.existsSync(paths.decisions)) {
136
- steps.push({ file: 'DECISIONS.md', outcome: 'unchanged' });
131
+ // ── The rules file — never overwritten once it exists ────────────────
132
+ // Resolved again: arbiter.json may only now say where the rules go.
133
+ const rules = { ...paths, decisions: node_path_1.default.join(root, rulesFile) };
134
+ if (rulesFile !== store_1.RULES_FILE && node_fs_1.default.existsSync(node_path_1.default.join(root, store_1.RULES_FILE))) {
135
+ steps.push({ file: store_1.RULES_FILE, outcome: 'unchanged', note: 'yours, so Arbiter leaves it alone' });
136
+ }
137
+ if (node_fs_1.default.existsSync(rules.decisions)) {
138
+ steps.push({ file: rulesFile, outcome: 'unchanged' });
137
139
  }
138
140
  else {
139
- (0, store_1.writeActive)(paths, [], config.activeCap ?? store_1.ACTIVE_CAP);
140
- steps.push({ file: 'DECISIONS.md', outcome: 'created' });
141
+ (0, store_1.writeActive)(rules, [], config.activeCap ?? store_1.ACTIVE_CAP);
142
+ steps.push({ file: rulesFile, outcome: 'created', ...(rulesFile !== store_1.RULES_FILE && { note: 'your design rules go here' }) });
141
143
  }
142
144
  // ── .arbiter/archive.md ──────────────────────────────────────────────
143
145
  node_fs_1.default.mkdirSync(paths.archiveDir, { recursive: true });
144
- steps.push(writeIfChanged(root, node_path_1.default.join('.arbiter', '.gitignore'), 'hosted.token\n'));
146
+ // Never committed: the publish token, what the board hands this machine's agent and what it was told
147
+ // (a teammate's agent mustn't make it), and the lock a write holds for a moment. Lines already there
148
+ // stay, so a re-run never un-ignores anything.
149
+ const ignore = node_path_1.default.join(paths.archiveDir, '.gitignore');
150
+ const had = node_fs_1.default.existsSync(ignore) ? node_fs_1.default.readFileSync(ignore, 'utf8').split(/\r?\n/).filter(Boolean) : [];
151
+ const lines = [...had, ...['hosted.token', handoff_1.FILE, handoff_1.SEEN, lock_1.LOCK].filter((x) => !had.includes(x))];
152
+ steps.push(writeIfChanged(root, node_path_1.default.join('.arbiter', '.gitignore'), lines.join('\n') + '\n'));
145
153
  if (node_fs_1.default.existsSync(paths.archive)) {
146
154
  steps.push({ file: '.arbiter/archive.md', outcome: 'unchanged' });
147
155
  }
148
156
  else {
149
- node_fs_1.default.writeFileSync(paths.archive, (0, format_1.archiveHeader)());
157
+ node_fs_1.default.writeFileSync(paths.archive, (0, format_1.archiveHeader)(rulesFile));
150
158
  steps.push({ file: '.arbiter/archive.md', outcome: 'created' });
151
159
  }
160
+ // ── Local dev dependency ─────────────────────────────────────────────
161
+ // First, so what's written next can say how this project runs Arbiter: `npx arbiter` only once it's in package.json.
162
+ const install = opts.skipInstall ? { file: 'package.json', outcome: 'skipped', note: '--skip-install' } : installSelf(root);
163
+ const command = (0, store_1.arbiterCommand)(root);
152
164
  // ── Skill file ───────────────────────────────────────────────────────
153
- const skill = skillFor(client);
165
+ const skill = skillFor(client, rulesFile, command);
154
166
  steps.push(writeIfChanged(root, skill.file, skill.content));
155
167
  // ── AGENTS.md — merge one line, never overwrite ──────────────────────
156
- steps.push(mergeAgentsLine(root, 'AGENTS.md', true));
168
+ steps.push(mergeAgentsLine(root, 'AGENTS.md', true, (0, exports.agentsLine)(rulesFile)));
157
169
  // ── Client-specific entry points ─────────────────────────────────────
158
170
  if (client === 'claude-code') {
159
171
  // Claude Code's own context file. Same line, same marker; created if missing so injection has a path that's certain to load.
160
- steps.push(mergeAgentsLine(root, 'CLAUDE.md', true));
172
+ steps.push(mergeAgentsLine(root, 'CLAUDE.md', true, (0, exports.agentsLine)(rulesFile)));
173
+ // The hook that hands the agent what you judged on the board, with your next message.
174
+ steps.push(...(0, hook_1.installHook)(root, rulesFile, command));
161
175
  }
162
176
  else {
163
177
  // Cursor has no skill-invoked slash commands; give it a command file that does what `/arbiter` does.
164
- steps.push(writeIfChanged(root, node_path_1.default.join('.cursor', 'commands', 'arbiter.md'), CURSOR_COMMAND));
178
+ steps.push(writeIfChanged(root, node_path_1.default.join('.cursor', 'commands', 'arbiter.md'), (0, store_1.withCommand)(CURSOR_COMMAND, command)));
165
179
  }
166
- // ── Local dev dependency ─────────────────────────────────────────────
167
- steps.push(opts.skipInstall ? { file: 'package.json', outcome: 'skipped', note: '--skip-install' } : installSelf(root));
180
+ steps.push(install);
168
181
  }
169
182
  finally {
170
183
  ask?.close();
@@ -179,13 +192,25 @@ function detectClient(root) {
179
192
  out.push('cursor');
180
193
  return out;
181
194
  }
182
- const label = (c) => (c === 'cursor' ? 'Cursor' : 'Claude Code');
195
+ /** Only asked when the project has signs of both, or of neither. */
196
+ async function askClientQuestion(ask) {
197
+ let q = '\nWhich agent do you use in this project?\n 1. Claude Code\n 2. Cursor\nPick 1 or 2 (Enter for 1): ';
198
+ for (;;) {
199
+ const a = await ask.answer(q);
200
+ const t = (a ?? '').trim().toLowerCase();
201
+ if (a === null || !t || t === '1' || t === 'claude-code' || t === 'claude code')
202
+ return 'claude-code';
203
+ if (t === '2' || t === 'cursor')
204
+ return 'cursor';
205
+ q = 'Pick 1 or 2 (Enter for 1): ';
206
+ }
207
+ }
183
208
  /** The one preference Arbiter asks for. The skill asks the same, in the same words, when install couldn't. */
184
- const CHECKIN_QUESTION = 'When should Arbiter check in about decisions while you work?';
209
+ const CHECKIN_QUESTION = 'How should Arbiter check in while you work?';
185
210
  const CHECKIN_OPTIONS = [
186
- { mode: 'feature', label: 'A line after big work (recommended)', detail: 'When a feature-sized piece settles, one sentence saying what changed. Every 5 changes waiting, a yes/no on reviewing. Never mid-iteration.' },
187
- { mode: 'quiet', label: 'Nothing until I ask', detail: 'Saved silently. Asks only when something clashes with a rule. /arbiter whenever you want to see it.' },
188
- { mode: 'every', label: 'A line after everything', detail: 'One sentence every time a piece of work settles, big or small. Every 5 changes waiting, a yes/no on reviewing.' },
211
+ { mode: 'feature', label: 'A line after big work (recommended)', detail: 'When a feature settles, one sentence on what changed.' },
212
+ { mode: 'quiet', label: 'Nothing until I ask', detail: 'Quiet, unless something clashes with a rule.' },
213
+ { mode: 'every', label: 'A line after everything', detail: 'One sentence every time a piece of work settles.' },
189
214
  ];
190
215
  /**
191
216
  * The check-in question at the terminal. Enter takes the recommended one. Null when input ended
@@ -193,7 +218,7 @@ const CHECKIN_OPTIONS = [
193
218
  */
194
219
  async function askCheckin(ask) {
195
220
  const menu = CHECKIN_OPTIONS.map((o, i) => ` ${i + 1}. ${o.label}. ${o.detail}`).join('\n');
196
- let q = `\n${CHECKIN_QUESTION}\n${menu}\n(1): `;
221
+ let q = `\n${CHECKIN_QUESTION}\n${menu}\nPick 1, 2 or 3 (Enter for 1): `;
197
222
  for (;;) {
198
223
  const a = await ask.answer(q);
199
224
  if (a === null)
@@ -206,28 +231,106 @@ async function askCheckin(ask) {
206
231
  return CHECKIN_OPTIONS[n - 1].mode;
207
232
  if (setup_1.CHECKINS.includes(t))
208
233
  return t;
209
- q = 'Pick 1, 2 or 3 (1): ';
234
+ q = 'Pick 1, 2 or 3 (Enter for 1): ';
235
+ }
236
+ }
237
+ const YOURE_SET = "You're set. Start a new agent session and build as usual.\nWhen you're ready to review what you've built, type /arbiter.";
238
+ /** Long lines broken at spaces, for a terminal. */
239
+ function wrap(text, width = 84) {
240
+ const out = [];
241
+ let line = '';
242
+ for (const word of text.split(' ')) {
243
+ if (line && line.length + 1 + word.length > width) {
244
+ out.push(line);
245
+ line = word;
246
+ }
247
+ else
248
+ line = line ? `${line} ${word}` : word;
210
249
  }
250
+ return [...out, line].join('\n');
211
251
  }
252
+ const and = (xs) => (xs.length < 2 ? xs.join('') : `${xs.slice(0, -1).join(', ')} and ${xs[xs.length - 1]}`);
212
253
  /**
213
- * Install's closing lines when nobody at the terminal answered the check-in question. Usually an
214
- * agent ran it: it asks the user in chat, on its own, then saves the answer. Bundled with review
215
- * questions it got dismissed with them and came back on every /arbiter.
254
+ * What install prints after its question: what it did in a sentence or two, anything that needs the
255
+ * person, and what to do next. The file-by-file list only with --verbose. A re-run says what changed.
216
256
  */
217
- function checkinHandoff() {
257
+ function installReport(root, steps, opts = {}) {
258
+ const config = (0, store_1.readConfig)((0, store_1.resolvePaths)(root));
259
+ const rules = config?.decisions ?? store_1.RULES_FILE;
260
+ const fresh = steps.some((s) => s.file === 'arbiter.json' && s.outcome === 'created');
261
+ const theirs = steps.some((s) => s.file === store_1.RULES_FILE && s.note?.startsWith('yours'));
262
+ const changed = (f) => steps.some((s) => s.file === f && (s.outcome === 'created' || s.outcome === 'updated'));
263
+ const out = [];
264
+ if (opts.verbose) {
265
+ const w = Math.max(...steps.map((s) => s.file.length));
266
+ out.push(steps.map((s) => ` ${s.file.padEnd(w)} ${s.outcome}${s.note ? ` — ${s.note}` : ''}`).join('\n'), '');
267
+ }
268
+ if (theirs && changed(rules))
269
+ out.push(wrap((0, store_1.rulesMovedLine)(rules)), '');
270
+ if (fresh) {
271
+ const told = ['CLAUDE.md', 'AGENTS.md'].filter(changed);
272
+ const where = config?.client === 'cursor'
273
+ ? "Arbiter's rule and /arbiter command are in .cursor/."
274
+ : "Arbiter's skill and hook are in .claude/.";
275
+ out.push(wrap(`Added ${rules} for your design rules and .arbiter/ for the record. ${told.length ? `Your agent's instructions (${and(told)}) got one line telling it to read your rules before UI work, and ${where}` : where}`), '');
276
+ }
277
+ else {
278
+ const updated = steps.filter((s) => (s.outcome === 'created' || s.outcome === 'updated') && !s.attention).map((s) => s.file);
279
+ out.push(updated.length ? wrap(`Updated: ${and(updated)}.`) : 'Already set up. Nothing changed.', '');
280
+ }
281
+ const needs = steps.filter((s) => s.attention);
282
+ if (needs.length) {
283
+ const w = Math.max(...needs.map((s) => s.file.length));
284
+ out.push('Needs you:', ...needs.map((s) => ` ${s.file.padEnd(w)} ${s.note ?? s.outcome}`), '');
285
+ }
286
+ // An agent's hand-off ends with the same words for it to say; printing them here as well would say it twice.
287
+ if (opts.closing === false) { /* the hand-off has it */ }
288
+ else if (fresh)
289
+ out.push(YOURE_SET);
290
+ else if (steps.some((s) => !s.attention && (s.outcome === 'created' || s.outcome === 'updated')))
291
+ out.push('Start a new agent session so your agent picks this up.');
292
+ return out.join('\n').replace(/\n+$/, '') + '\n';
293
+ }
294
+ /**
295
+ * Install's closing lines when an agent ran it: nobody at the terminal saw anything, so the agent says
296
+ * it in chat, in the same words a person at the terminal gets. The check-in question, when it's still
297
+ * unanswered, goes on its own: bundled with review questions it got dismissed with them and came back
298
+ * on every /arbiter. `rulesNote`: the project had its own DECISIONS.md.
299
+ */
300
+ function checkinHandoff(rulesNote, askQuestion = true) {
218
301
  const w = Math.max(...setup_1.CHECKINS.map((c) => c.length));
302
+ const say = ['Arbiter is installed.', ...(rulesNote ? [rulesNote] : []), ...(askQuestion ? [`One question before you start: ${CHECKIN_QUESTION[0].toLowerCase()}${CHECKIN_QUESTION.slice(1)}`] : [])].join(' ');
219
303
  return [
220
304
  '',
221
- `One question left, asked once. ${CHECKIN_QUESTION}`,
222
- ...CHECKIN_OPTIONS.map((o) => ` ${o.mode.padEnd(w)} ${o.label}. ${o.detail}`),
223
- 'Save the answer: npx arbiter setup --checkin feature (or quiet, or every)',
224
- 'Agent: ask the user now, in chat, as one pick-one question on its own, then save their answer. No answer means feature.',
305
+ 'Agent: nobody saw this at a terminal. Tell the user now, in chat, in these words:',
306
+ ` "${say}"`,
307
+ ...(askQuestion
308
+ ? [
309
+ 'Then ask it as one pick-one question on its own:',
310
+ ...CHECKIN_OPTIONS.map((o) => ` ${o.mode.padEnd(w)} ${o.label}. ${o.detail}`),
311
+ 'Save their answer: npx arbiter setup --checkin feature (or quiet, or every). No answer means feature.',
312
+ ]
313
+ : []),
314
+ `Then: "You're set. Start a new session and build as usual. When you're ready to review what you've built, type /arbiter."`,
225
315
  '',
226
316
  ].join('\n');
227
317
  }
228
- function skillFor(client) {
318
+ /**
319
+ * A template that names the rules file, naming this project's. The templates say DECISIONS.md,
320
+ * and every mention of it is the rules file.
321
+ */
322
+ const withRulesFile = (text, rules) => (rules === store_1.RULES_FILE ? text : text.split(store_1.RULES_FILE).join(rules));
323
+ exports.withRulesFile = withRulesFile;
324
+ /** Said in the skill when Arbiter isn't in a package.json here, so its commands carry the full name. */
325
+ const FULL_NAME_NOTE = 'In this project the command is `npx arbiterdesign`: Arbiter isn\'t in a package.json here, and `npx arbiter` would fetch a different package that has nothing to do with Arbiter. Every command below already says `npx arbiterdesign`. When a reply from it names `npx arbiter`, run that as `npx arbiterdesign`.\n\n';
326
+ function skillFor(client, rules, command = 'npx arbiter') {
229
327
  // A Windows checkout with autocrlf hands us CRLF; the frontmatter regex and the marker line assume LF.
230
- const template = node_fs_1.default.readFileSync(SKILL_TEMPLATE, 'utf8').replace(/\r\n/g, '\n');
328
+ let template = (0, store_1.withCommand)((0, exports.withRulesFile)(node_fs_1.default.readFileSync(SKILL_TEMPLATE, 'utf8').replace(/\r\n/g, '\n'), rules), command);
329
+ // The first /arbiter's intro says where the rules go; when that isn't their DECISIONS.md, it says theirs is safe.
330
+ if (rules !== store_1.RULES_FILE)
331
+ template = template.split(`Rules go into \`${rules}\`, and I read them`).join(`Rules go into \`${rules}\` (your own ${store_1.RULES_FILE} stays as it is), and I read them`);
332
+ if (command !== 'npx arbiter')
333
+ template = template.replace('\n## Before UI work\n', `\n${FULL_NAME_NOTE}## Before UI work\n`);
231
334
  const m = /^---\n([\s\S]*?)\n---\n/.exec(template);
232
335
  // The version marker is the first body line, under the frontmatter, so both clients carry it.
233
336
  const body = (0, exports.skillMarker)(selfVersion()) + '\n' + template.slice(m?.[0].length ?? 0);
@@ -251,28 +354,50 @@ function writeIfChanged(root, rel, content) {
251
354
  node_fs_1.default.writeFileSync(abs, content);
252
355
  return { file: name, outcome: before === null ? 'created' : 'updated' };
253
356
  }
254
- function mergeAgentsLine(root, file, createIfMissing) {
357
+ function mergeAgentsLine(root, file, createIfMissing, line = exports.AGENTS_LINE) {
255
358
  const abs = node_path_1.default.join(root, file);
256
359
  if (!node_fs_1.default.existsSync(abs)) {
257
360
  if (!createIfMissing)
258
361
  return { file, outcome: 'skipped', note: 'not present' };
259
- node_fs_1.default.writeFileSync(abs, `# Agent instructions\n\n${exports.AGENTS_LINE}\n`);
362
+ node_fs_1.default.writeFileSync(abs, `# Agent instructions\n\n${line}\n`);
260
363
  return { file, outcome: 'created' };
261
364
  }
262
365
  const before = node_fs_1.default.readFileSync(abs, 'utf8');
263
366
  if (before.includes(AGENTS_MARKER)) {
264
367
  // The marked line is Arbiter's: an older Arbiter wrote different words, so swap in these.
265
368
  // Only that line — whatever else the file says, and where the line sits in it, stays.
266
- const after = before.replace(/^.*<!-- arbiter -->.*$/m, () => exports.AGENTS_LINE);
369
+ const after = before.replace(/^.*<!-- arbiter -->.*$/m, () => line);
267
370
  if (after === before)
268
371
  return { file, outcome: 'unchanged' };
269
372
  node_fs_1.default.writeFileSync(abs, after);
270
373
  return { file, outcome: 'updated', note: 'Arbiter line refreshed' };
271
374
  }
272
375
  const sep = before.endsWith('\n') ? (before.endsWith('\n\n') ? '' : '\n') : '\n\n';
273
- node_fs_1.default.writeFileSync(abs, before + sep + exports.AGENTS_LINE + '\n');
376
+ node_fs_1.default.writeFileSync(abs, before + sep + line + '\n');
274
377
  return { file, outcome: 'updated', note: 'one line appended' };
275
378
  }
379
+ /**
380
+ * Everything that tells the agent where the rules are, pointed at `rules`: the line in AGENTS.md and
381
+ * CLAUDE.md, the skill and the board hook. Only what install already wrote is touched. For when the
382
+ * rules move to a file of their own after install (store.ts claimRulesFile).
383
+ */
384
+ function pointAgentsAt(root, client, rules) {
385
+ const steps = [];
386
+ for (const f of ['AGENTS.md', 'CLAUDE.md']) {
387
+ const abs = node_path_1.default.join(root, f);
388
+ if (node_fs_1.default.existsSync(abs) && node_fs_1.default.readFileSync(abs, 'utf8').includes(AGENTS_MARKER))
389
+ steps.push(mergeAgentsLine(root, f, false, (0, exports.agentsLine)(rules)));
390
+ }
391
+ for (const c of ['claude-code', 'cursor']) {
392
+ if (node_fs_1.default.existsSync(node_path_1.default.join(root, skillPath(c)))) {
393
+ const skill = skillFor(c, rules, (0, store_1.arbiterCommand)(root));
394
+ steps.push(writeIfChanged(root, skill.file, skill.content));
395
+ }
396
+ }
397
+ if (client !== 'cursor' && node_fs_1.default.existsSync(node_path_1.default.join(root, '.claude', 'hooks', 'arbiter-board.cjs')))
398
+ steps.push(...(0, hook_1.installHook)(root, rules, (0, store_1.arbiterCommand)(root)));
399
+ return steps;
400
+ }
276
401
  const CURSOR_COMMAND = `# Arbiter — review queued design decisions
277
402
 
278
403
  Run \`npx arbiter rules --pending --json\` and present every queued decision, grouped by dimension, one line each with what it was chosen over. Ask the user to reply per number: confirm · rule · skip · or type what it should be. Then judge each with \`npx arbiter record P-xxxx --as accept|rule|skip|fix --to "…"\`. If the user wrote something after the command, treat it as "record that" and run \`npx arbiter record\` with it as a rule. Follow the arbiter rule file for the full protocol.
@@ -305,7 +430,7 @@ function installSelf(root) {
305
430
  const self = JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(exports.PKG_ROOT, 'package.json'), 'utf8'));
306
431
  const hostPkgPath = node_path_1.default.join(root, 'package.json');
307
432
  if (!node_fs_1.default.existsSync(hostPkgPath)) {
308
- return { file: 'package.json', outcome: 'skipped', note: `no package.json here — add ${self.name} as a dev dependency yourself` };
433
+ return { file: 'package.json', outcome: 'skipped', attention: true, note: `no package.json here, so in this project Arbiter's command is npx ${self.name}, not npx arbiter. Your agent has been told.` };
309
434
  }
310
435
  const host = JSON.parse(node_fs_1.default.readFileSync(hostPkgPath, 'utf8'));
311
436
  // Arbiter's own repo, dogfooding: `npx arbiter` already resolves to the package itself.
@@ -324,5 +449,5 @@ function installSelf(root) {
324
449
  if (add(exports.PKG_ROOT)) {
325
450
  return { file: 'package.json', outcome: 'updated', note: `${self.name} added from ${exports.PKG_ROOT} (registry unavailable)` };
326
451
  }
327
- return { file: 'package.json', outcome: 'skipped', note: `could not install — run: ${pm} ${pm === 'npm' ? 'install --save-dev' : 'add -D'} ${self.name}` };
452
+ return { file: 'package.json', outcome: 'skipped', attention: true, note: `couldn't install it. Run: ${pm} ${pm === 'npm' ? 'install --save-dev' : 'add -D'} ${self.name}` };
328
453
  }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ /**
3
+ * `arbiter invite` — the admin's invites to Arbiter Team, which is in early access, by invitation.
4
+ *
5
+ * arbiter invite "Sam at Acme" a code good for 1 board, shown once (--boards 3 for more)
6
+ * arbiter invite --list every invite: who it's for, boards made and left
7
+ * arbiter invite --off <id> it makes no more boards; the boards it made stay up
8
+ *
9
+ * Needs the server's admin token in ARBITER_ADMIN_TOKEN, as a takedown does. Needs no project, and
10
+ * changes nothing in one. Left out of --help: it's only for whoever runs the server.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.invite = invite;
14
+ const hosted_1 = require("../hosted");
15
+ const publish_1 = require("./publish");
16
+ const day = (iso) => new Date(iso).toLocaleDateString('en-GB', { day: 'numeric', month: 'short' });
17
+ async function invite(note, opts = {}) {
18
+ const base = (opts.to ?? publish_1.DEFAULT_HOST).replace(/\/$/, '');
19
+ const admin = process.env[hosted_1.ADMIN_ENV]?.trim();
20
+ if (!admin)
21
+ return { ok: false, out: `Set ${hosted_1.ADMIN_ENV} to the admin token of ${base} first.` };
22
+ try {
23
+ if (opts.off) {
24
+ const r = await (0, hosted_1.switchOffInvite)(base, admin, opts.off);
25
+ if (opts.json)
26
+ return { ok: true, out: JSON.stringify({ id: opts.off, ...r }, null, 2) };
27
+ return { ok: true, out: r.already ? 'That invite was already off.' : `Switched off${r.note ? `: ${r.note}` : ''}. It makes no more boards; the boards it made stay up.` };
28
+ }
29
+ if (opts.list) {
30
+ const all = await (0, hosted_1.listInvites)(base, admin);
31
+ if (opts.json)
32
+ return { ok: true, out: JSON.stringify({ invites: all }, null, 2) };
33
+ return { ok: true, out: listed(base, all) };
34
+ }
35
+ const boards = opts.boards === undefined ? undefined : Number(opts.boards);
36
+ if (boards !== undefined && (!Number.isInteger(boards) || boards < 1))
37
+ return { ok: false, out: '--boards: a whole number, 1 or more.' };
38
+ const made = await (0, hosted_1.makeInvite)(base, admin, { note: note?.trim(), boards });
39
+ if (opts.json)
40
+ return { ok: true, out: JSON.stringify(made, null, 2) };
41
+ // @latest, so an older Arbiter in their project, which doesn't know --invite, isn't the one that runs.
42
+ return {
43
+ ok: true,
44
+ out: [
45
+ `Invite${made.note ? ` for ${made.note}` : ''}, good for ${made.boards} board${made.boards === 1 ? '' : 's'}. This is the only time the code is shown:`,
46
+ '',
47
+ ` ${made.code}`,
48
+ '',
49
+ 'Send them this line, to run in their project:',
50
+ '',
51
+ ` npx arbiterdesign@latest publish --invite ${made.code}`,
52
+ ].join('\n'),
53
+ };
54
+ }
55
+ catch (e) {
56
+ return { ok: false, out: e.message };
57
+ }
58
+ }
59
+ function listed(base, all) {
60
+ if (!all.length)
61
+ return `No invites on ${base} yet. Make one: npx arbiter invite "who it's for"`;
62
+ const lines = all.map((i) => {
63
+ const use = `${i.made} board${i.made === 1 ? '' : 's'} made, ${i.off ? `off since ${day(i.off)}` : `${i.boardsLeft} left`}`;
64
+ return ` ${(i.note || '(no note)').padEnd(24)} ${use.padEnd(28)} ${day(i.created).padEnd(6)} ${i.id}`;
65
+ });
66
+ return [`${all.length} invite${all.length === 1 ? '' : 's'} on ${base}`, '', ...lines].join('\n');
67
+ }
@@ -52,7 +52,7 @@ async function publish(opts = {}) {
52
52
  if (to) {
53
53
  const password = opts.password === undefined ? undefined : opts.password === false ? null : opts.password === true ? (0, hosted_1.newPassword)() : opts.password;
54
54
  try {
55
- const r = await (0, hosted_1.publishHosted)(paths, to, { admin: opts.admin, password });
55
+ const r = await (0, hosted_1.publishHosted)(paths, to, { admin: opts.admin, password, invite: opts.invite });
56
56
  if (r.created)
57
57
  done('project', `created on ${to} — link in .arbiter/hosted.json (commit it); token in .arbiter/hosted.token (git-ignored — teammates set ARBITER_PUBLISH_TOKEN)`);
58
58
  // A made-up password is printed once, here: the service keeps only a hash. One you chose isn't echoed.
@@ -178,7 +178,7 @@ function onPush(root, paths) {
178
178
  }
179
179
  const branch = git(root, ['rev-parse', '--abbrev-ref', 'HEAD']) || 'main';
180
180
  const file = node_path_1.default.join(root, exports.WORKFLOW_FILE);
181
- const content = workflow(branch, (0, init_1.selfVersion)());
181
+ const content = workflow(branch, (0, init_1.selfVersion)(), (0, store_1.rulesName)(paths));
182
182
  if (!node_fs_1.default.existsSync(file)) {
183
183
  node_fs_1.default.mkdirSync(node_path_1.default.dirname(file), { recursive: true });
184
184
  node_fs_1.default.writeFileSync(file, content);
@@ -208,7 +208,7 @@ function onPush(root, paths) {
208
208
  }
209
209
  return steps;
210
210
  }
211
- function workflow(branch, version) {
211
+ function workflow(branch, version, rules) {
212
212
  return [
213
213
  '# Written by `npx arbiter publish --on-push`. Republishes the board when decisions land.',
214
214
  '# Needs one repository secret, ARBITER_PUBLISH_TOKEN: the contents of .arbiter/hosted.token.',
@@ -219,7 +219,7 @@ function workflow(branch, version) {
219
219
  ` branches: [${branch}]`,
220
220
  ' paths:',
221
221
  " - '.arbiter/**'",
222
- " - 'DECISIONS.md'",
222
+ ` - '${rules}'`,
223
223
  " - 'CANDIDATES.md'",
224
224
  'concurrency:',
225
225
  ' group: arbiter-publish',