arbiterdesign 0.1.9 → 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.
- package/README.md +288 -223
- package/dist/commands/decision.js +1 -1
- package/dist/commands/export.js +1 -1
- package/dist/commands/init.js +187 -73
- package/dist/commands/invite.js +67 -0
- package/dist/commands/publish.js +4 -4
- package/dist/commands/record.js +5 -5
- package/dist/commands/remove.js +1 -1
- package/dist/commands/rename.js +1 -1
- package/dist/commands/review.js +6 -3
- package/dist/commands/rules.js +17 -3
- package/dist/commands/update.js +5 -0
- package/dist/format.js +112 -7
- package/dist/handoff.js +4 -1
- package/dist/hook.js +5 -3
- package/dist/hosted.js +40 -2
- package/dist/index.js +43 -17
- package/dist/localboard.js +1 -1
- package/dist/settings.js +1 -1
- package/dist/store.js +162 -7
- package/package.json +1 -1
- package/templates/SKILL.md +36 -20
- package/templates/board/board.css +2 -2
- package/templates/board/board.js +25 -25
- package/templates/fonts/OFL.txt +92 -92
- package/templates/hooks/arbiter-board.cjs +50 -50
package/dist/commands/rules.js
CHANGED
|
@@ -20,6 +20,7 @@ const requests_1 = require("../requests");
|
|
|
20
20
|
const update_1 = require("./update");
|
|
21
21
|
const overlap_1 = require("../overlap");
|
|
22
22
|
const handoff_1 = require("../handoff");
|
|
23
|
+
const lock_1 = require("../lock");
|
|
23
24
|
function rules(id, opts = {}) {
|
|
24
25
|
const paths = (0, store_1.resolvePaths)((0, store_1.findRoot)(opts.cwd));
|
|
25
26
|
opts = { ...opts, config: (0, store_1.readConfig)(paths) };
|
|
@@ -79,11 +80,24 @@ function pendingList(pending, opts, paths) {
|
|
|
79
80
|
// A Review Board sitting nobody was waiting on: its fixes and approved requests are still to make.
|
|
80
81
|
// Handed over as it is now: once it's made, `done` clears this much, and keeps anything judged since.
|
|
81
82
|
const lastReview = (0, handoff_1.takeHandoff)(paths);
|
|
83
|
+
// The intro, once, at the first /arbiter: until it's been handed out, and while nothing has been judged.
|
|
84
|
+
// Judged decisions mean someone has been through a review, whatever arbiter.json says: the stamp
|
|
85
|
+
// lives in a committed file, and a branch that never merged takes it along.
|
|
86
|
+
const firstRun = !opts.config?.introduced && !archiveAll.length && !active.length;
|
|
87
|
+
// Read again under the lock: a record running at the same time may have just written arbiter.json
|
|
88
|
+
// (where the rules moved to, say), and writing back the copy read earlier would undo it.
|
|
89
|
+
if (firstRun && opts.config) {
|
|
90
|
+
(0, lock_1.withLock)(paths, () => {
|
|
91
|
+
const fresh = (0, store_1.readConfig)(paths);
|
|
92
|
+
if (fresh && !fresh.introduced)
|
|
93
|
+
(0, store_1.writeConfig)(paths, { ...fresh, introduced: (0, store_1.now)() });
|
|
94
|
+
});
|
|
95
|
+
}
|
|
82
96
|
return JSON.stringify({
|
|
83
97
|
...(lastReview && { lastReview: { ...lastReview, file: handoff_1.HANDOFF_FILE, done: 'npx arbiter review --done' } }),
|
|
84
|
-
|
|
85
|
-
//
|
|
86
|
-
|
|
98
|
+
firstRun,
|
|
99
|
+
// Install couldn't ask (an agent ran it, and the question never got relayed): ask it after the intro.
|
|
100
|
+
askCheckin: !opts.config?.onboarded,
|
|
87
101
|
checkin: opts.config?.checkin ?? 'feature',
|
|
88
102
|
...(0, update_1.updateNotice)(paths),
|
|
89
103
|
requests: { open, approved },
|
package/dist/commands/update.js
CHANGED
|
@@ -74,6 +74,7 @@ async function update(opts = {}) {
|
|
|
74
74
|
fail('package', `${pm} could not install arbiterdesign@latest — check the network, then re-run`);
|
|
75
75
|
}
|
|
76
76
|
// 2. the skill — from the copy that was just installed, so a new template lands, not this one's
|
|
77
|
+
const rulesBefore = (0, store_1.readConfig)(paths)?.decisions;
|
|
77
78
|
try {
|
|
78
79
|
if (installed && installed.version !== (0, init_1.selfVersion)()) {
|
|
79
80
|
(0, node_child_process_1.execFileSync)(process.execPath, [installed.bin, 'init', '--yes', '--skip-install'], { cwd: root, stdio: ['ignore', 'ignore', 'pipe'] });
|
|
@@ -87,6 +88,10 @@ async function update(opts = {}) {
|
|
|
87
88
|
catch (e) {
|
|
88
89
|
fail('skill', `init failed: ${e.message.split('\n')[0]}`);
|
|
89
90
|
}
|
|
91
|
+
// An install from before 0.1.10 took the project's own DECISIONS.md as the rules file; init moves the rules out.
|
|
92
|
+
const rulesAfter = (0, store_1.readConfig)((0, store_1.resolvePaths)(root))?.decisions;
|
|
93
|
+
if (rulesAfter && rulesAfter !== rulesBefore)
|
|
94
|
+
done('rules', (0, store_1.rulesMovedLine)(rulesAfter, true));
|
|
90
95
|
// 3. the publish workflow, if publish --on-push wrote one: it pins a version
|
|
91
96
|
const wf = node_path_1.default.join(root, publish_1.WORKFLOW_FILE);
|
|
92
97
|
if (node_fs_1.default.existsSync(wf)) {
|
package/dist/format.js
CHANGED
|
@@ -25,6 +25,9 @@ exports.formatEntry = formatEntry;
|
|
|
25
25
|
exports.formatGrouped = formatGrouped;
|
|
26
26
|
exports.parseEntries = parseEntries;
|
|
27
27
|
exports.activeHeader = activeHeader;
|
|
28
|
+
exports.isRulesFile = isRulesFile;
|
|
29
|
+
exports.notesOf = notesOf;
|
|
30
|
+
exports.formatActive = formatActive;
|
|
28
31
|
exports.archiveHeader = archiveHeader;
|
|
29
32
|
exports.pendingHeader = pendingHeader;
|
|
30
33
|
const schema_1 = require("./schema");
|
|
@@ -95,7 +98,8 @@ function parseEntries(md) {
|
|
|
95
98
|
cur = null;
|
|
96
99
|
};
|
|
97
100
|
for (const raw of lines) {
|
|
98
|
-
|
|
101
|
+
// Trailing spaces too (an editor's, or a "- **Rejected:** " typed by hand), as notesOf reads it.
|
|
102
|
+
const line = raw.replace(/\s+$/, '');
|
|
99
103
|
const h = HEADING.exec(line);
|
|
100
104
|
if (h) {
|
|
101
105
|
flush();
|
|
@@ -230,9 +234,13 @@ function complete(p) {
|
|
|
230
234
|
reworded: p.reworded ?? [],
|
|
231
235
|
};
|
|
232
236
|
}
|
|
237
|
+
const HEADER_TITLE = '# Decisions';
|
|
238
|
+
const HEADER_COUNT = /^Active design rules for this project/;
|
|
239
|
+
/** The header's last line starts this way in every version, so a rewrite finds where it ends. */
|
|
240
|
+
const HEADER_LAST = 'Add entries with `npx arbiter record`.';
|
|
233
241
|
function activeHeader(count, cap) {
|
|
234
242
|
return [
|
|
235
|
-
|
|
243
|
+
HEADER_TITLE,
|
|
236
244
|
'',
|
|
237
245
|
`Active design rules for this project — ${count} of ${cap}.`,
|
|
238
246
|
'',
|
|
@@ -241,27 +249,124 @@ function activeHeader(count, cap) {
|
|
|
241
249
|
'what lost, and why; `Trigger` is the case that prompted it. Superseded rules drop out of',
|
|
242
250
|
'here and stay in `.arbiter/archive.md`.',
|
|
243
251
|
'',
|
|
244
|
-
|
|
252
|
+
`${HEADER_LAST} Edit by hand if you must: the format round-trips, and notes of your own are kept.`,
|
|
245
253
|
'',
|
|
246
254
|
].join('\n');
|
|
247
255
|
}
|
|
248
|
-
|
|
256
|
+
/**
|
|
257
|
+
* Whether a rules file is Arbiter's to rewrite: empty, or carrying Arbiter's header or an entry it
|
|
258
|
+
* can read. Anything else (a project's own decision log, say) belongs to someone else.
|
|
259
|
+
*/
|
|
260
|
+
function isRulesFile(md) {
|
|
261
|
+
if (!md.trim())
|
|
262
|
+
return true;
|
|
263
|
+
if (md.replace(/\r\n/g, '\n').split('\n').some((l) => HEADER_COUNT.test(l)))
|
|
264
|
+
return true;
|
|
265
|
+
try {
|
|
266
|
+
return parseEntries(md).length > 0;
|
|
267
|
+
}
|
|
268
|
+
catch {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/** A field an entry carries, as it's written. These are re-written from the entry; any other line in it is a note. */
|
|
273
|
+
const ENTRY_LINE = /^- \*\*(Change|Rationale|Rejected|Reworded|Trigger|Scope|Author|Ref|Files|Paths|Expect):\*\*/;
|
|
274
|
+
const DIMENSION_HEADING = new RegExp(`^## (${Object.values(exports.DIMENSION_LABELS).join('|')})$`);
|
|
275
|
+
const ANY_HEADING = /^#{1,6} /;
|
|
276
|
+
/** The lines of Arbiter's header, as every version wrote them. Written fresh, so never kept as notes. */
|
|
277
|
+
const HEADER_LINES = new Set(activeHeader(0, 0).split('\n').filter((l) => l.trim()));
|
|
278
|
+
const isHeaderLine = (l) => HEADER_LINES.has(l) || HEADER_COUNT.test(l) || l.startsWith(HEADER_LAST);
|
|
279
|
+
/**
|
|
280
|
+
* What a person wrote in the rules file, so a rewrite can put it back word for word. It reads the file
|
|
281
|
+
* the way parseEntries does: an entry runs from its heading to the next heading. Its fields are written
|
|
282
|
+
* fresh from the entry; any other line inside it (a remark, a wrapped line, a comment) is a note and
|
|
283
|
+
* moves below the rules, so it can never be read into another rule. Text above the first rule stays
|
|
284
|
+
* above, wherever it sits around Arbiter's header; anything after one goes below. Left out: Arbiter's
|
|
285
|
+
* own header lines, its `## <Dimension>` headings and the entries.
|
|
286
|
+
*/
|
|
287
|
+
function notesOf(md) {
|
|
288
|
+
const lines = md.replace(/^/, '').replace(/\r\n/g, '\n').split('\n');
|
|
289
|
+
const top = [];
|
|
290
|
+
const bottom = [];
|
|
291
|
+
let afterRules = false;
|
|
292
|
+
let inEntry = false;
|
|
293
|
+
// An indented item belongs to an entry only under its Rejected or Reworded line, as parseEntries reads it.
|
|
294
|
+
let inList = false;
|
|
295
|
+
let inNotes = false;
|
|
296
|
+
for (let i = 0; i < lines.length; i++) {
|
|
297
|
+
const raw = lines[i];
|
|
298
|
+
const line = raw.replace(/\s+$/, '');
|
|
299
|
+
if (HEADING.test(line)) {
|
|
300
|
+
inEntry = true;
|
|
301
|
+
inList = false;
|
|
302
|
+
afterRules = true;
|
|
303
|
+
inNotes = false;
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
if (ANY_HEADING.test(line)) {
|
|
307
|
+
inEntry = false;
|
|
308
|
+
inList = false;
|
|
309
|
+
if (DIMENSION_HEADING.test(line)) {
|
|
310
|
+
// Only Arbiter's own: one with a rule under it. A person's "## Content" over their notes stays theirs.
|
|
311
|
+
const next = lines.slice(i + 1).find((l) => l.trim());
|
|
312
|
+
if (next !== undefined && HEADING.test(next.replace(/\s+$/, ''))) {
|
|
313
|
+
afterRules = true;
|
|
314
|
+
inNotes = false;
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
if (!afterRules && isHeaderLine(line))
|
|
320
|
+
continue;
|
|
321
|
+
const into = afterRules ? bottom : top;
|
|
322
|
+
if (inEntry && line) {
|
|
323
|
+
if (ENTRY_LINE.test(line)) {
|
|
324
|
+
inList = line === '- **Rejected:**' || line === '- **Reworded:**';
|
|
325
|
+
inNotes = false;
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
if (inList && LIST_ITEM.test(line))
|
|
329
|
+
continue;
|
|
330
|
+
inList = false;
|
|
331
|
+
}
|
|
332
|
+
if (!line) {
|
|
333
|
+
if (inNotes)
|
|
334
|
+
into.push('');
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
// Notes from two places between the rules come out as two paragraphs, not run together.
|
|
338
|
+
if (!inNotes && into.length && into[into.length - 1] !== '')
|
|
339
|
+
into.push('');
|
|
340
|
+
into.push(raw);
|
|
341
|
+
inNotes = true;
|
|
342
|
+
}
|
|
343
|
+
const trim = (a) => a.join('\n').replace(/^\n+|\n+$/g, '');
|
|
344
|
+
return { top: trim(top), bottom: trim(bottom) };
|
|
345
|
+
}
|
|
346
|
+
/** The rules file as written: header, notes above the rules, the rules, notes below. No notes: as it always was. */
|
|
347
|
+
function formatActive(decisions, cap, notes = { top: '', bottom: '' }) {
|
|
348
|
+
return activeHeader(decisions.length, cap)
|
|
349
|
+
+ (notes.top ? '\n' + notes.top + '\n' : '')
|
|
350
|
+
+ '\n' + formatGrouped(decisions)
|
|
351
|
+
+ (notes.bottom ? (decisions.length ? '\n' : '') + notes.bottom + '\n' : '');
|
|
352
|
+
}
|
|
353
|
+
function archiveHeader(rules = 'DECISIONS.md') {
|
|
249
354
|
return [
|
|
250
355
|
'# Decision archive',
|
|
251
356
|
'',
|
|
252
357
|
'Every decision ever recorded, in order. A decision you changed your mind about is superseded,',
|
|
253
358
|
'never rewritten; only `npx arbiter remove` takes an entry out, for a record of something that',
|
|
254
|
-
|
|
359
|
+
`never happened. Active rules live in \`${rules}\`; this file is for traceability and is never`,
|
|
255
360
|
'loaded into agent context.',
|
|
256
361
|
'',
|
|
257
362
|
].join('\n');
|
|
258
363
|
}
|
|
259
|
-
function pendingHeader() {
|
|
364
|
+
function pendingHeader(rules = 'DECISIONS.md') {
|
|
260
365
|
return [
|
|
261
366
|
'# Pending decisions',
|
|
262
367
|
'',
|
|
263
368
|
'Queued by the agent, not yet judged. Review with `npx arbiter review` or `/arbiter` in chat.',
|
|
264
|
-
|
|
369
|
+
`Judged entries move to \`.arbiter/archive.md\` (and \`${rules}\` if made a rule); skipped`,
|
|
265
370
|
'entries are dropped. Nothing here is in agent context.',
|
|
266
371
|
'',
|
|
267
372
|
].join('\n');
|
package/dist/handoff.js
CHANGED
|
@@ -154,7 +154,10 @@ function mergeHandoffs(earlier, h) {
|
|
|
154
154
|
*/
|
|
155
155
|
function saveHandoff(paths, h) {
|
|
156
156
|
node_fs_1.default.mkdirSync(paths.archiveDir, { recursive: true });
|
|
157
|
-
|
|
157
|
+
// The next step names the rules file as DECISIONS.md; a project whose rules are elsewhere hears its own.
|
|
158
|
+
const rules = node_path_1.default.basename(paths.decisions);
|
|
159
|
+
const named = rules === 'DECISIONS.md' || !h.next ? h : { ...h, next: h.next.split('DECISIONS.md').join(rules) };
|
|
160
|
+
(0, lock_1.writeAtomic)(node_path_1.default.join(paths.archiveDir, exports.FILE), JSON.stringify(named, null, 2) + '\n');
|
|
158
161
|
const gi = node_path_1.default.join(paths.archiveDir, '.gitignore');
|
|
159
162
|
const lines = (node_fs_1.default.existsSync(gi) ? node_fs_1.default.readFileSync(gi, 'utf8') : '').split(/\r?\n/).filter(Boolean);
|
|
160
163
|
const missing = [exports.FILE, exports.SEEN].filter((x) => !lines.includes(x));
|
package/dist/hook.js
CHANGED
|
@@ -40,10 +40,12 @@ function hookInstalled(root) {
|
|
|
40
40
|
* Write the script, and add the entry to .claude/settings.json beside whatever is there. A
|
|
41
41
|
* settings file that isn't plain JSON is left alone: rewriting it could lose what someone wrote.
|
|
42
42
|
*/
|
|
43
|
-
function installHook(root) {
|
|
43
|
+
function installHook(root, rules = 'DECISIONS.md', command = 'npx arbiter') {
|
|
44
44
|
const steps = [];
|
|
45
45
|
const script = node_path_1.default.join(root, SCRIPT);
|
|
46
|
-
|
|
46
|
+
// What it tells the agent names the rules file and the command as this project has them.
|
|
47
|
+
const named = node_fs_1.default.readFileSync(TEMPLATE, 'utf8').replace(/\r\n/g, '\n').split('DECISIONS.md').join(rules);
|
|
48
|
+
const content = command === 'npx arbiter' ? named : named.replace(/npx arbiter(?![A-Za-z])/g, command);
|
|
47
49
|
const before = node_fs_1.default.existsSync(script) ? node_fs_1.default.readFileSync(script, 'utf8') : null;
|
|
48
50
|
if (before === content)
|
|
49
51
|
steps.push({ file: '.claude/hooks/arbiter-board.cjs', outcome: 'unchanged' });
|
|
@@ -60,7 +62,7 @@ function installHook(root) {
|
|
|
60
62
|
settings = JSON.parse(node_fs_1.default.readFileSync(file, 'utf8'));
|
|
61
63
|
}
|
|
62
64
|
catch {
|
|
63
|
-
steps.push({ file: '.claude/settings.json', outcome: 'skipped', note: `not plain JSON, so left alone. Add a UserPromptSubmit hook
|
|
65
|
+
steps.push({ file: '.claude/settings.json', outcome: 'skipped', attention: true, note: `not plain JSON, so Arbiter left it alone. Add a UserPromptSubmit hook that runs: ${exports.HOOK_COMMAND}` });
|
|
64
66
|
return steps;
|
|
65
67
|
}
|
|
66
68
|
}
|
package/dist/hosted.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.PASSWORD_MIN = exports.publishable = exports.ADMIN_ENV = exports.TOKEN_ENV = exports.writeComments = exports.readComments = void 0;
|
|
15
|
+
exports.PASSWORD_MIN = exports.publishable = exports.INVITE_ENV = exports.ADMIN_ENV = exports.TOKEN_ENV = exports.writeComments = exports.readComments = void 0;
|
|
16
16
|
exports.readLinkOrNull = readLinkOrNull;
|
|
17
17
|
exports.readLink = readLink;
|
|
18
18
|
exports.writeLink = writeLink;
|
|
@@ -25,6 +25,9 @@ exports.pullHosted = pullHosted;
|
|
|
25
25
|
exports.unpublishHosted = unpublishHosted;
|
|
26
26
|
exports.parseBoardLink = parseBoardLink;
|
|
27
27
|
exports.takedownHosted = takedownHosted;
|
|
28
|
+
exports.makeInvite = makeInvite;
|
|
29
|
+
exports.listInvites = listInvites;
|
|
30
|
+
exports.switchOffInvite = switchOffInvite;
|
|
28
31
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
29
32
|
const node_path_1 = __importDefault(require("node:path"));
|
|
30
33
|
const node_crypto_1 = require("node:crypto");
|
|
@@ -50,6 +53,8 @@ const LINK_FILE = 'hosted.json';
|
|
|
50
53
|
const TOKEN_FILE = 'hosted.token';
|
|
51
54
|
exports.TOKEN_ENV = 'ARBITER_PUBLISH_TOKEN';
|
|
52
55
|
exports.ADMIN_ENV = 'ARBITER_ADMIN_TOKEN';
|
|
56
|
+
/** An invite code for the first publish, instead of --invite. */
|
|
57
|
+
exports.INVITE_ENV = 'ARBITER_INVITE';
|
|
53
58
|
const IMAGE_TYPES = { '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.gif': 'image/gif' };
|
|
54
59
|
function readLink(paths) {
|
|
55
60
|
const f = node_path_1.default.join(paths.archiveDir, LINK_FILE);
|
|
@@ -211,6 +216,8 @@ function newPassword() {
|
|
|
211
216
|
* readable without it. Keeps every request under Vercel's 4.5 MB body cap however many screens there are.
|
|
212
217
|
*
|
|
213
218
|
* `password`: a string sets it, null takes it off, left out leaves it as it is.
|
|
219
|
+
* `invite`: the code a new board needs while the service is invite-only. Only the first publish sends
|
|
220
|
+
* it; after that the publish token does, so it's never saved.
|
|
214
221
|
*/
|
|
215
222
|
async function publishHosted(paths, serviceUrl, opts = {}) {
|
|
216
223
|
const base = serviceUrl.replace(/\/$/, '');
|
|
@@ -223,9 +230,16 @@ async function publishHosted(paths, serviceUrl, opts = {}) {
|
|
|
223
230
|
throw new Error(`no .arbiter/hosted.json for ${base} — publish once from a laptop and commit that file, so CI updates the existing board instead of creating a new one`);
|
|
224
231
|
}
|
|
225
232
|
const admin = opts.admin ?? process.env[exports.ADMIN_ENV];
|
|
226
|
-
const
|
|
233
|
+
const invite = (opts.invite ?? process.env[exports.INVITE_ENV])?.trim() || undefined;
|
|
234
|
+
const r = await api(`${base}/api/projects`, { method: 'POST', body: JSON.stringify({ name: node_path_1.default.basename(paths.root), ...(invite ? { invite } : {}) }), admin });
|
|
227
235
|
if (r.status === 401)
|
|
228
236
|
throw new Error(`${base} only lets an admin create boards. Ask whoever runs it for the token, then: npx arbiter publish --to ${base} --admin-token <token>`);
|
|
237
|
+
// Invite-only: the service says why, and where to ask. Asked without a code, say how to use one.
|
|
238
|
+
if (r.status === 403 && typeof r.body.error === 'string') {
|
|
239
|
+
// A self-hosted server is named again in the line, so the command works as typed.
|
|
240
|
+
const to = base === 'https://arbiter.design' ? '' : ` --to ${base}`;
|
|
241
|
+
throw new Error(r.body.invite === 'required' ? `${r.body.error}\n With an invite code: npx arbiter publish --invite <code>${to}` : r.body.error);
|
|
242
|
+
}
|
|
229
243
|
// The service says which limit it was: this network's, or everyone's.
|
|
230
244
|
if (r.status === 429)
|
|
231
245
|
throw new Error(typeof r.body.error === 'string' ? r.body.error : `${base} is busy right now — try again in an hour`);
|
|
@@ -371,3 +385,27 @@ async function takedownHosted(link, admin) {
|
|
|
371
385
|
throw new Error(`delete failed: ${r.body.error ?? r.status}. Nothing was deleted.`);
|
|
372
386
|
return { shareUrl: board.shareUrl, pictures: Number(r.body.pictures ?? 0), comments: Number(r.body.comments ?? 0) };
|
|
373
387
|
}
|
|
388
|
+
async function inviteCall(base, admin, route, init = {}) {
|
|
389
|
+
const r = await api(`${base}${route}`, { ...init, admin });
|
|
390
|
+
if (r.status === 401)
|
|
391
|
+
throw new Error(`${base} refused the admin token (${exports.ADMIN_ENV})`);
|
|
392
|
+
// An older service has no invites at all: Next answers its unknown routes with a 404 page, not JSON.
|
|
393
|
+
if (r.status === 404 && typeof r.body.error !== 'string')
|
|
394
|
+
throw new Error(`${base} doesn't do invites yet: it runs an older Arbiter than this one`);
|
|
395
|
+
if (!r.ok)
|
|
396
|
+
throw new Error(String(r.body.error ?? r.status));
|
|
397
|
+
return r.body;
|
|
398
|
+
}
|
|
399
|
+
/** A new invite. Its code comes back this once; the service keeps only a hash. */
|
|
400
|
+
async function makeInvite(base, admin, opts = {}) {
|
|
401
|
+
const b = await inviteCall(base, admin, '/api/invites', { method: 'POST', body: JSON.stringify({ note: opts.note ?? '', ...(opts.boards !== undefined ? { boards: opts.boards } : {}) }) });
|
|
402
|
+
return { id: String(b.id), code: String(b.code), note: String(b.note ?? ''), boards: Number(b.boards) };
|
|
403
|
+
}
|
|
404
|
+
async function listInvites(base, admin) {
|
|
405
|
+
return ((await inviteCall(base, admin, '/api/invites')).invites ?? []);
|
|
406
|
+
}
|
|
407
|
+
/** It makes no more boards. Boards it made stay up. */
|
|
408
|
+
async function switchOffInvite(base, admin, id) {
|
|
409
|
+
const b = await inviteCall(base, admin, `/api/invites/${encodeURIComponent(id)}`, { method: 'DELETE' });
|
|
410
|
+
return { note: typeof b.note === 'string' ? b.note : null, already: !!b.already };
|
|
411
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ const update_1 = require("./commands/update");
|
|
|
25
25
|
const remove_1 = require("./commands/remove");
|
|
26
26
|
const autopublish_1 = require("./autopublish");
|
|
27
27
|
const hosted_1 = require("./hosted");
|
|
28
|
+
const invite_1 = require("./commands/invite");
|
|
28
29
|
const store_1 = require("./store");
|
|
29
30
|
const hook_1 = require("./hook");
|
|
30
31
|
const lock_1 = require("./lock");
|
|
@@ -104,7 +105,7 @@ program
|
|
|
104
105
|
}
|
|
105
106
|
result = (0, record_1.oneOffGate)(input) ?? locked(opts.cwd, () => (opts.pending ? (0, record_1.queue)(input, opts) : (0, record_1.record)(input, opts)));
|
|
106
107
|
}
|
|
107
|
-
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
108
|
+
process.stdout.write(JSON.stringify(withNotices(result.output), null, 2) + '\n');
|
|
108
109
|
// Queueing never reaches the board — work cards are built from judged decisions.
|
|
109
110
|
if (result.exitCode === 0 && !opts.pending)
|
|
110
111
|
await boardUpdated(opts.cwd);
|
|
@@ -119,15 +120,17 @@ program
|
|
|
119
120
|
.option('--checkin <mode>', 'how Arbiter checks in while you work: feature | quiet | every (default: asked)')
|
|
120
121
|
.option('-y, --yes', 'no questions — use detected values')
|
|
121
122
|
.option('--skip-install', 'do not add the package to devDependencies')
|
|
123
|
+
.option('--verbose', 'list every file install wrote or left alone')
|
|
122
124
|
.action(async (opts) => {
|
|
125
|
+
const root = process.cwd();
|
|
123
126
|
const steps = await (0, init_1.init)(opts);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
// An agent ran it: nobody saw any of this, so the agent says it in chat, and asks what install couldn't.
|
|
128
|
+
const config = (0, store_1.readConfig)((0, store_1.resolvePaths)(root));
|
|
129
|
+
const rules = (0, store_1.rulesName)((0, store_1.resolvePaths)(root));
|
|
130
|
+
const theirs = steps.some((s) => s.file === 'DECISIONS.md' && s.note?.startsWith('yours')) && steps.some((s) => s.file === rules && s.outcome === 'created');
|
|
131
|
+
const handoff = !config?.onboarded ? (0, init_1.checkinHandoff)(theirs ? (0, store_1.rulesMovedLine)(rules) : undefined)
|
|
132
|
+
: theirs && !process.stdin.isTTY ? (0, init_1.checkinHandoff)((0, store_1.rulesMovedLine)(rules), false) : '';
|
|
133
|
+
process.stdout.write('\n' + (0, init_1.installReport)(root, steps, { verbose: !!opts.verbose, closing: !handoff }) + handoff);
|
|
131
134
|
if (opts.destination === 'git') {
|
|
132
135
|
process.stdout.write([
|
|
133
136
|
'',
|
|
@@ -164,7 +167,7 @@ program
|
|
|
164
167
|
.option('--app <url>', 'where the app runs, for screenshots: http://localhost:3000 or a staging address (on its own, saves only this)')
|
|
165
168
|
.action((opts) => {
|
|
166
169
|
const result = locked(opts.cwd, () => (0, setup_1.setup)(opts));
|
|
167
|
-
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
170
|
+
process.stdout.write(JSON.stringify(withNotices(result.output), null, 2) + '\n');
|
|
168
171
|
process.exit(result.exitCode);
|
|
169
172
|
});
|
|
170
173
|
program
|
|
@@ -174,7 +177,7 @@ program
|
|
|
174
177
|
.option('--capture', 'macOS: drag-select a region of the screen')
|
|
175
178
|
.action(async (work, opts) => {
|
|
176
179
|
const result = locked(opts.cwd, () => (0, snapshot_1.snapshotWork)(work, opts));
|
|
177
|
-
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
180
|
+
process.stdout.write(JSON.stringify(withNotices(result.output), null, 2) + '\n');
|
|
178
181
|
if (result.exitCode === 0)
|
|
179
182
|
await boardUpdated(opts.cwd);
|
|
180
183
|
process.exit(result.exitCode);
|
|
@@ -193,7 +196,7 @@ program
|
|
|
193
196
|
.option('--author <name>', 'override the author')
|
|
194
197
|
.action(async (idOrAdd, name, opts) => {
|
|
195
198
|
const result = locked(opts.cwd, () => (idOrAdd === 'add' ? (0, candidate_1.addCandidate)(name ?? '', opts) : (0, candidate_1.updateCandidate)(idOrAdd, opts)));
|
|
196
|
-
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
199
|
+
process.stdout.write(JSON.stringify(withNotices(result.output), null, 2) + '\n');
|
|
197
200
|
if (result.exitCode === 0)
|
|
198
201
|
await boardUpdated(opts.cwd);
|
|
199
202
|
process.exit(result.exitCode);
|
|
@@ -227,8 +230,9 @@ program
|
|
|
227
230
|
});
|
|
228
231
|
program
|
|
229
232
|
.command('publish')
|
|
230
|
-
.description('Put the board online at arbiter.design and print the link. --to <url> for your own hosted Arbiter; --to pages for GitHub Pages (git destination, export, commit, push).
|
|
233
|
+
.description('Put the board online at arbiter.design and print the link. Arbiter Team is in early access, by invitation: a new board\'s first publish needs --invite <code> (arbiter.design/plans). For a read-only copy anyone can open, use export. --to <url> for your own hosted Arbiter; --to pages for GitHub Pages (git destination, export, commit, push).')
|
|
231
234
|
.option('--to <url|pages>', 'where to publish: a hosted Arbiter (default arbiter.design), or `pages` for GitHub Pages')
|
|
235
|
+
.option('--invite <code>', `your invite code, for the first publish only (or set ${hosted_1.INVITE_ENV}); later publishes don't need it`)
|
|
232
236
|
.option('--admin-token <token>', 'only for a self-hosted Arbiter that gates board creation')
|
|
233
237
|
.option('--no-push', 'GitHub Pages mode: do everything except push')
|
|
234
238
|
.option('--on-push', 'also write a GitHub Actions workflow that republishes on every push, and set its secret')
|
|
@@ -237,7 +241,7 @@ program
|
|
|
237
241
|
.option('--password [password]', 'the board asks for a password before showing anything; leave the value out to get a strong one made up. Once: later publishes keep it')
|
|
238
242
|
.option('--no-password', 'take the password off: anyone with the link can see the board')
|
|
239
243
|
.action(async (opts) => {
|
|
240
|
-
const r = await (0, publish_1.publish)({ noPush: opts.push === false, to: opts.to, admin: opts.adminToken, onPush: opts.onPush, auto: opts.auto === undefined ? undefined : !!opts.auto, password: opts.password });
|
|
244
|
+
const r = await (0, publish_1.publish)({ noPush: opts.push === false, to: opts.to, admin: opts.adminToken, invite: opts.invite, onPush: opts.onPush, auto: opts.auto === undefined ? undefined : !!opts.auto, password: opts.password });
|
|
241
245
|
printSteps(r.steps);
|
|
242
246
|
if (r.url)
|
|
243
247
|
process.stdout.write(`\n${r.ok ? 'Live in about a minute' : 'Once the failed step is fixed'}: ${r.url}\n`);
|
|
@@ -253,6 +257,20 @@ program
|
|
|
253
257
|
printSteps(r.steps);
|
|
254
258
|
process.exit(r.ok ? 0 : 1);
|
|
255
259
|
});
|
|
260
|
+
// Only for whoever runs the server, so it stays out of --help.
|
|
261
|
+
program
|
|
262
|
+
.command('invite [note]', { hidden: true })
|
|
263
|
+
.description(`Make an invite to Arbiter Team, which is in early access, by invitation: a code good for 1 board, shown once. Needs the server's admin token in ${hosted_1.ADMIN_ENV}.`)
|
|
264
|
+
.option('--boards <n>', 'how many boards it can make (default 1)')
|
|
265
|
+
.option('--list', 'every invite: who it is for, boards made and left')
|
|
266
|
+
.option('--off <id>', 'switch an invite off: it makes no more boards; the boards it made stay up')
|
|
267
|
+
.option('--to <url>', 'the server (default arbiter.design)')
|
|
268
|
+
.option('--json', 'print JSON')
|
|
269
|
+
.action(async (note, opts) => {
|
|
270
|
+
const r = await (0, invite_1.invite)(note, opts);
|
|
271
|
+
(r.ok ? process.stdout : process.stderr).write(r.out + '\n');
|
|
272
|
+
process.exit(r.ok ? 0 : 1);
|
|
273
|
+
});
|
|
256
274
|
program
|
|
257
275
|
.command('areas')
|
|
258
276
|
.description('Where everything sits on the board: folders, the areas in them, and the changes in each. Read it before naming new work, so it joins an area that is already there. --save writes folders, once the person has said yes to them.')
|
|
@@ -260,7 +278,7 @@ program
|
|
|
260
278
|
.option('--save <json>', 'replace the folders: {"folders":[{"name":"Local board","areas":["Review inbox","Change page"]}]}')
|
|
261
279
|
.action((opts) => {
|
|
262
280
|
const result = opts.save ? locked(undefined, () => (0, areas_1.areasCommand)({ json: opts.json, save: opts.save })) : (0, areas_1.areasCommand)({ json: opts.json, save: opts.save });
|
|
263
|
-
process.stdout.write(result.exitCode !== 0 || opts.json ? JSON.stringify(result.output, null, 2) + '\n' : `${result.text}\n`);
|
|
281
|
+
process.stdout.write(result.exitCode !== 0 || opts.json ? JSON.stringify(withNotices(result.output), null, 2) + '\n' : `${result.text}\n`);
|
|
264
282
|
process.exit(result.exitCode);
|
|
265
283
|
});
|
|
266
284
|
program
|
|
@@ -269,7 +287,7 @@ program
|
|
|
269
287
|
.option('--merge', 'the new name is a piece of work that already exists: this one joins it, decisions, pictures and comments')
|
|
270
288
|
.action(async (work, newName, opts) => {
|
|
271
289
|
const result = locked(opts.cwd, () => (0, rename_1.renameWork)(work, newName, opts));
|
|
272
|
-
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
290
|
+
process.stdout.write(JSON.stringify(withNotices(result.output), null, 2) + '\n');
|
|
273
291
|
if (result.exitCode === 0)
|
|
274
292
|
await boardUpdated(opts.cwd);
|
|
275
293
|
process.exit(result.exitCode);
|
|
@@ -309,7 +327,7 @@ program
|
|
|
309
327
|
.option('--force', 'with a screen: unlink the decisions on it rather than refusing')
|
|
310
328
|
.action(async (id, opts) => {
|
|
311
329
|
const result = locked(opts.cwd, () => (opts.snapshot ? (0, remove_1.removeSnapshot)(opts.snapshot, opts) : (0, remove_1.remove)(id ?? '', opts)));
|
|
312
|
-
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
330
|
+
process.stdout.write(JSON.stringify(withNotices(result.output), null, 2) + '\n');
|
|
313
331
|
if (result.exitCode === 0)
|
|
314
332
|
await boardUpdated(opts.cwd);
|
|
315
333
|
process.exit(result.exitCode);
|
|
@@ -319,7 +337,7 @@ program
|
|
|
319
337
|
.description('Detach decisions from the screen they were recorded against. The decisions stay exactly as they are.')
|
|
320
338
|
.action(async (ids, opts) => {
|
|
321
339
|
const result = locked(opts.cwd, () => (0, remove_1.unlink)(ids, opts));
|
|
322
|
-
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
340
|
+
process.stdout.write(JSON.stringify(withNotices(result.output), null, 2) + '\n');
|
|
323
341
|
if (result.exitCode === 0)
|
|
324
342
|
await boardUpdated(opts.cwd);
|
|
325
343
|
process.exit(result.exitCode);
|
|
@@ -367,6 +385,14 @@ program.parseAsync(process.argv).catch((e) => {
|
|
|
367
385
|
function locked(cwd, fn) {
|
|
368
386
|
return (0, lock_1.withLock)((0, store_1.resolvePaths)((0, store_1.findRoot)(cwd)), fn);
|
|
369
387
|
}
|
|
388
|
+
/**
|
|
389
|
+
* A command's JSON, with what the agent has to pass on: when this command found the project's own
|
|
390
|
+
* DECISIONS.md and moved the rules to a file of their own, `rulesFile.say` is the line to tell the user.
|
|
391
|
+
*/
|
|
392
|
+
function withNotices(output) {
|
|
393
|
+
const moved = (0, store_1.takeRulesMoved)();
|
|
394
|
+
return moved ? { ...output, rulesFile: moved } : output;
|
|
395
|
+
}
|
|
370
396
|
/** `publish` and `unpublish` report one line per step: name, outcome, why. */
|
|
371
397
|
function printSteps(steps) {
|
|
372
398
|
const w = Math.max(...steps.map((s) => s.step.length));
|
package/dist/localboard.js
CHANGED
|
@@ -161,7 +161,7 @@ function liveBoard(paths) {
|
|
|
161
161
|
(lines[card] ??= []).push({ id: d.id, change: d.change ?? null, decision: d.decision, dimension: d.dimension, scope: d.scope, date: d.date });
|
|
162
162
|
}
|
|
163
163
|
const link = (0, hosted_1.readLinkOrNull)(paths);
|
|
164
|
-
return { board, comments: (0, comments_1.readComments)(paths), waiting, queued: lines, pending: queued.filter((d) => d.level !== 'polish').length, hosted: link?.shareUrl ?? null, version: link?.boardVersion ?? null, live: true, arrangement: (0, areas_1.readArrangement)(paths), settings: (0, settings_1.settingsOf)(paths) };
|
|
164
|
+
return { board, comments: (0, comments_1.readComments)(paths), waiting, queued: lines, pending: queued.filter((d) => d.level !== 'polish').length, hosted: link?.shareUrl ?? null, version: link?.boardVersion ?? null, live: true, arrangement: (0, areas_1.readArrangement)(paths), settings: (0, settings_1.settingsOf)(paths), rulesFile: (0, store_1.rulesName)(paths), command: (0, store_1.arbiterCommand)(paths.root) };
|
|
165
165
|
}
|
|
166
166
|
/** What `/api/state` sends: the review queue. */
|
|
167
167
|
/** The last picture taken before `date`, when a newer one was taken since: the before to this decision's now. */
|
package/dist/settings.js
CHANGED
|
@@ -78,7 +78,7 @@ function saveSettings(paths, raw) {
|
|
|
78
78
|
if (typeof n !== 'number' || !Number.isInteger(n) || n < 1 || n > exports.MAX_CAP)
|
|
79
79
|
errors.push(`Design rules must be a whole number from 1 to ${exports.MAX_CAP}`);
|
|
80
80
|
else if (n < have)
|
|
81
|
-
errors.push(
|
|
81
|
+
errors.push(`${(0, store_1.rulesName)(paths)} has ${have} rules, so it can't hold fewer. Remove some first.`);
|
|
82
82
|
else
|
|
83
83
|
cap = next.activeCap = n;
|
|
84
84
|
}
|