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
|
@@ -77,7 +77,7 @@ function promote(id, opts = {}) {
|
|
|
77
77
|
}
|
|
78
78
|
// Full: the rules there, so one can be picked for this to replace without leaving the page.
|
|
79
79
|
if (active.length >= cap)
|
|
80
|
-
return { exitCode: 3, output: { status: 'cap', cap, active: active.map((d) => ({ id: d.id, decision: d.decision })), errors: [
|
|
80
|
+
return { exitCode: 3, output: { status: 'cap', cap, active: active.map((d) => ({ id: d.id, decision: d.decision })), errors: [`${(0, store_1.rulesName)(paths)} is full (${cap} rules). Remove one first, or raise the limit in Preferences.`] } };
|
|
81
81
|
const rule = { ...entry, verdict: 'rule', ...(opts.supersedes ? { supersedes: opts.supersedes } : {}) };
|
|
82
82
|
(0, store_1.writeArchive)(paths, archive.map((d) => (d.id === id ? rule : d)));
|
|
83
83
|
(0, store_1.writeActive)(paths, [...active, rule], cap);
|
package/dist/commands/export.js
CHANGED
|
@@ -71,7 +71,7 @@ function exportBoard(opts = {}) {
|
|
|
71
71
|
// Read-only: `live: false` keeps the review pages, Done and the team board buttons out of it.
|
|
72
72
|
const board = { ...manifest, candidates: cards, requests: [] };
|
|
73
73
|
// The folders as you made them, so the copy's side nav reads the same as yours. Nobody can move them in it.
|
|
74
|
-
const data = { board, comments: [], waiting: {}, queued: {}, pending: 0, hosted: null, version: null, live: false, arrangement: (0, areas_1.readArrangement)(paths), settings: null };
|
|
74
|
+
const data = { board, comments: [], waiting: {}, queued: {}, pending: 0, hosted: null, version: null, live: false, arrangement: (0, areas_1.readArrangement)(paths), settings: null, rulesFile: (0, store_1.rulesName)(paths) };
|
|
75
75
|
// In a <script>, so nothing in a name can close the tag or run.
|
|
76
76
|
const json = JSON.stringify(data).replace(/</g, '\\u003c').split(LINE_SEP).join('\\u2028').split(PARA_SEP).join('\\u2029');
|
|
77
77
|
// Functions, not strings: a `$&` in someone's decision would otherwise be read as a pattern.
|
package/dist/commands/init.js
CHANGED
|
@@ -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"));
|
|
@@ -37,8 +39,10 @@ const AGENTS_MARKER = '<!-- arbiter -->';
|
|
|
37
39
|
* Without it the decision won 17 times in 20; with it the design system won 20 in 20, and an
|
|
38
40
|
* exception won 20 in 20 (clash study, Opus 5.5, October 2026).
|
|
39
41
|
*/
|
|
40
|
-
|
|
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. ` +
|
|
41
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)();
|
|
42
46
|
exports.PKG_ROOT = node_path_1.default.join(__dirname, '..', '..');
|
|
43
47
|
const SKILL_TEMPLATE = node_path_1.default.join(exports.PKG_ROOT, 'templates', 'SKILL.md');
|
|
44
48
|
/** The version of the package that's running. */
|
|
@@ -62,49 +66,38 @@ async function init(opts = {}) {
|
|
|
62
66
|
const paths = (0, store_1.resolvePaths)(root);
|
|
63
67
|
const existing = (0, store_1.readConfig)(paths);
|
|
64
68
|
const steps = [];
|
|
65
|
-
|
|
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);
|
|
66
74
|
try {
|
|
67
|
-
|
|
75
|
+
if (opts.checkin !== undefined && !setup_1.CHECKINS.includes(opts.checkin))
|
|
76
|
+
throw new Error(`--checkin must be one of ${setup_1.CHECKINS.join(' | ')}`);
|
|
68
77
|
let client = opts.client ?? existing?.client;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
//
|
|
85
|
-
let author = opts.author ?? existing?.author;
|
|
86
|
-
if (!author) {
|
|
87
|
-
const guess = (0, store_1.gitUserName)(root) ?? node_os_1.default.userInfo().username;
|
|
88
|
-
if (ask) {
|
|
89
|
-
const a = (await ask.question(`Who decides rules? (the author when git has no user.name) (${guess}): `)).trim();
|
|
90
|
-
author = a || guess;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
author = guess;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
// ── Question 3: how Arbiter checks in while you work ─────────────────
|
|
97
|
-
// Asked once, here, so no /arbiter has to. Nobody at the terminal (an agent ran this, or
|
|
98
|
-
// --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.
|
|
99
94
|
let checkin = existing?.checkin;
|
|
100
95
|
let onboarded = existing?.onboarded;
|
|
101
96
|
if (opts.checkin !== undefined) {
|
|
102
|
-
if (!setup_1.CHECKINS.includes(opts.checkin))
|
|
103
|
-
throw new Error(`--checkin must be one of ${setup_1.CHECKINS.join(' | ')}`);
|
|
104
97
|
checkin = opts.checkin;
|
|
105
98
|
onboarded ??= (0, store_1.now)();
|
|
106
99
|
}
|
|
107
|
-
else if (
|
|
100
|
+
else if (askCheckinNow) {
|
|
108
101
|
const picked = await askCheckin(ask);
|
|
109
102
|
if (picked) {
|
|
110
103
|
checkin = picked;
|
|
@@ -122,6 +115,7 @@ async function init(opts = {}) {
|
|
|
122
115
|
...(opts.destination && { destination: opts.destination }),
|
|
123
116
|
...(checkin && { checkin }),
|
|
124
117
|
...(onboarded && { onboarded }),
|
|
118
|
+
...(rulesFile !== store_1.RULES_FILE && { decisions: rulesFile }),
|
|
125
119
|
};
|
|
126
120
|
if (!existing) {
|
|
127
121
|
(0, store_1.writeConfig)(paths, config);
|
|
@@ -134,13 +128,18 @@ async function init(opts = {}) {
|
|
|
134
128
|
else {
|
|
135
129
|
steps.push({ file: 'arbiter.json', outcome: 'unchanged' });
|
|
136
130
|
}
|
|
137
|
-
// ──
|
|
138
|
-
|
|
139
|
-
|
|
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' });
|
|
140
139
|
}
|
|
141
140
|
else {
|
|
142
|
-
(0, store_1.writeActive)(
|
|
143
|
-
steps.push({ file:
|
|
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' }) });
|
|
144
143
|
}
|
|
145
144
|
// ── .arbiter/archive.md ──────────────────────────────────────────────
|
|
146
145
|
node_fs_1.default.mkdirSync(paths.archiveDir, { recursive: true });
|
|
@@ -155,27 +154,30 @@ async function init(opts = {}) {
|
|
|
155
154
|
steps.push({ file: '.arbiter/archive.md', outcome: 'unchanged' });
|
|
156
155
|
}
|
|
157
156
|
else {
|
|
158
|
-
node_fs_1.default.writeFileSync(paths.archive, (0, format_1.archiveHeader)());
|
|
157
|
+
node_fs_1.default.writeFileSync(paths.archive, (0, format_1.archiveHeader)(rulesFile));
|
|
159
158
|
steps.push({ file: '.arbiter/archive.md', outcome: 'created' });
|
|
160
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);
|
|
161
164
|
// ── Skill file ───────────────────────────────────────────────────────
|
|
162
|
-
const skill = skillFor(client);
|
|
165
|
+
const skill = skillFor(client, rulesFile, command);
|
|
163
166
|
steps.push(writeIfChanged(root, skill.file, skill.content));
|
|
164
167
|
// ── AGENTS.md — merge one line, never overwrite ──────────────────────
|
|
165
|
-
steps.push(mergeAgentsLine(root, 'AGENTS.md', true));
|
|
168
|
+
steps.push(mergeAgentsLine(root, 'AGENTS.md', true, (0, exports.agentsLine)(rulesFile)));
|
|
166
169
|
// ── Client-specific entry points ─────────────────────────────────────
|
|
167
170
|
if (client === 'claude-code') {
|
|
168
171
|
// Claude Code's own context file. Same line, same marker; created if missing so injection has a path that's certain to load.
|
|
169
|
-
steps.push(mergeAgentsLine(root, 'CLAUDE.md', true));
|
|
172
|
+
steps.push(mergeAgentsLine(root, 'CLAUDE.md', true, (0, exports.agentsLine)(rulesFile)));
|
|
170
173
|
// The hook that hands the agent what you judged on the board, with your next message.
|
|
171
|
-
steps.push(...(0, hook_1.installHook)(root));
|
|
174
|
+
steps.push(...(0, hook_1.installHook)(root, rulesFile, command));
|
|
172
175
|
}
|
|
173
176
|
else {
|
|
174
177
|
// Cursor has no skill-invoked slash commands; give it a command file that does what `/arbiter` does.
|
|
175
|
-
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)));
|
|
176
179
|
}
|
|
177
|
-
|
|
178
|
-
steps.push(opts.skipInstall ? { file: 'package.json', outcome: 'skipped', note: '--skip-install' } : installSelf(root));
|
|
180
|
+
steps.push(install);
|
|
179
181
|
}
|
|
180
182
|
finally {
|
|
181
183
|
ask?.close();
|
|
@@ -190,13 +192,25 @@ function detectClient(root) {
|
|
|
190
192
|
out.push('cursor');
|
|
191
193
|
return out;
|
|
192
194
|
}
|
|
193
|
-
|
|
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
|
+
}
|
|
194
208
|
/** The one preference Arbiter asks for. The skill asks the same, in the same words, when install couldn't. */
|
|
195
|
-
const CHECKIN_QUESTION = '
|
|
209
|
+
const CHECKIN_QUESTION = 'How should Arbiter check in while you work?';
|
|
196
210
|
const CHECKIN_OPTIONS = [
|
|
197
|
-
{ mode: 'feature', label: 'A line after big work (recommended)', detail: 'When a feature
|
|
198
|
-
{ mode: 'quiet', label: 'Nothing until I ask', detail: '
|
|
199
|
-
{ mode: 'every', label: 'A line after everything', detail: 'One sentence every time a piece of work settles
|
|
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.' },
|
|
200
214
|
];
|
|
201
215
|
/**
|
|
202
216
|
* The check-in question at the terminal. Enter takes the recommended one. Null when input ended
|
|
@@ -204,7 +218,7 @@ const CHECKIN_OPTIONS = [
|
|
|
204
218
|
*/
|
|
205
219
|
async function askCheckin(ask) {
|
|
206
220
|
const menu = CHECKIN_OPTIONS.map((o, i) => ` ${i + 1}. ${o.label}. ${o.detail}`).join('\n');
|
|
207
|
-
let q = `\n${CHECKIN_QUESTION}\n${menu}\
|
|
221
|
+
let q = `\n${CHECKIN_QUESTION}\n${menu}\nPick 1, 2 or 3 (Enter for 1): `;
|
|
208
222
|
for (;;) {
|
|
209
223
|
const a = await ask.answer(q);
|
|
210
224
|
if (a === null)
|
|
@@ -217,28 +231,106 @@ async function askCheckin(ask) {
|
|
|
217
231
|
return CHECKIN_OPTIONS[n - 1].mode;
|
|
218
232
|
if (setup_1.CHECKINS.includes(t))
|
|
219
233
|
return t;
|
|
220
|
-
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;
|
|
221
249
|
}
|
|
250
|
+
return [...out, line].join('\n');
|
|
222
251
|
}
|
|
252
|
+
const and = (xs) => (xs.length < 2 ? xs.join('') : `${xs.slice(0, -1).join(', ')} and ${xs[xs.length - 1]}`);
|
|
223
253
|
/**
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
* 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.
|
|
227
256
|
*/
|
|
228
|
-
function
|
|
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) {
|
|
229
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(' ');
|
|
230
303
|
return [
|
|
231
304
|
'',
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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."`,
|
|
236
315
|
'',
|
|
237
316
|
].join('\n');
|
|
238
317
|
}
|
|
239
|
-
|
|
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') {
|
|
240
327
|
// A Windows checkout with autocrlf hands us CRLF; the frontmatter regex and the marker line assume LF.
|
|
241
|
-
|
|
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`);
|
|
242
334
|
const m = /^---\n([\s\S]*?)\n---\n/.exec(template);
|
|
243
335
|
// The version marker is the first body line, under the frontmatter, so both clients carry it.
|
|
244
336
|
const body = (0, exports.skillMarker)(selfVersion()) + '\n' + template.slice(m?.[0].length ?? 0);
|
|
@@ -262,28 +354,50 @@ function writeIfChanged(root, rel, content) {
|
|
|
262
354
|
node_fs_1.default.writeFileSync(abs, content);
|
|
263
355
|
return { file: name, outcome: before === null ? 'created' : 'updated' };
|
|
264
356
|
}
|
|
265
|
-
function mergeAgentsLine(root, file, createIfMissing) {
|
|
357
|
+
function mergeAgentsLine(root, file, createIfMissing, line = exports.AGENTS_LINE) {
|
|
266
358
|
const abs = node_path_1.default.join(root, file);
|
|
267
359
|
if (!node_fs_1.default.existsSync(abs)) {
|
|
268
360
|
if (!createIfMissing)
|
|
269
361
|
return { file, outcome: 'skipped', note: 'not present' };
|
|
270
|
-
node_fs_1.default.writeFileSync(abs, `# Agent instructions\n\n${
|
|
362
|
+
node_fs_1.default.writeFileSync(abs, `# Agent instructions\n\n${line}\n`);
|
|
271
363
|
return { file, outcome: 'created' };
|
|
272
364
|
}
|
|
273
365
|
const before = node_fs_1.default.readFileSync(abs, 'utf8');
|
|
274
366
|
if (before.includes(AGENTS_MARKER)) {
|
|
275
367
|
// The marked line is Arbiter's: an older Arbiter wrote different words, so swap in these.
|
|
276
368
|
// Only that line — whatever else the file says, and where the line sits in it, stays.
|
|
277
|
-
const after = before.replace(/^.*<!-- arbiter -->.*$/m, () =>
|
|
369
|
+
const after = before.replace(/^.*<!-- arbiter -->.*$/m, () => line);
|
|
278
370
|
if (after === before)
|
|
279
371
|
return { file, outcome: 'unchanged' };
|
|
280
372
|
node_fs_1.default.writeFileSync(abs, after);
|
|
281
373
|
return { file, outcome: 'updated', note: 'Arbiter line refreshed' };
|
|
282
374
|
}
|
|
283
375
|
const sep = before.endsWith('\n') ? (before.endsWith('\n\n') ? '' : '\n') : '\n\n';
|
|
284
|
-
node_fs_1.default.writeFileSync(abs, before + sep +
|
|
376
|
+
node_fs_1.default.writeFileSync(abs, before + sep + line + '\n');
|
|
285
377
|
return { file, outcome: 'updated', note: 'one line appended' };
|
|
286
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
|
+
}
|
|
287
401
|
const CURSOR_COMMAND = `# Arbiter — review queued design decisions
|
|
288
402
|
|
|
289
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.
|
|
@@ -316,7 +430,7 @@ function installSelf(root) {
|
|
|
316
430
|
const self = JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(exports.PKG_ROOT, 'package.json'), 'utf8'));
|
|
317
431
|
const hostPkgPath = node_path_1.default.join(root, 'package.json');
|
|
318
432
|
if (!node_fs_1.default.existsSync(hostPkgPath)) {
|
|
319
|
-
return { file: 'package.json', outcome: 'skipped', note: `no package.json here
|
|
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.` };
|
|
320
434
|
}
|
|
321
435
|
const host = JSON.parse(node_fs_1.default.readFileSync(hostPkgPath, 'utf8'));
|
|
322
436
|
// Arbiter's own repo, dogfooding: `npx arbiter` already resolves to the package itself.
|
|
@@ -335,5 +449,5 @@ function installSelf(root) {
|
|
|
335
449
|
if (add(exports.PKG_ROOT)) {
|
|
336
450
|
return { file: 'package.json', outcome: 'updated', note: `${self.name} added from ${exports.PKG_ROOT} (registry unavailable)` };
|
|
337
451
|
}
|
|
338
|
-
return { file: 'package.json', outcome: 'skipped', note: `
|
|
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}` };
|
|
339
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
|
+
}
|
package/dist/commands/publish.js
CHANGED
|
@@ -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
|
-
|
|
222
|
+
` - '${rules}'`,
|
|
223
223
|
" - 'CANDIDATES.md'",
|
|
224
224
|
'concurrency:',
|
|
225
225
|
' group: arbiter-publish',
|
package/dist/commands/record.js
CHANGED
|
@@ -311,7 +311,7 @@ function unretire(r, opts = {}) {
|
|
|
311
311
|
return fail([`${later.id} has changed ${r.rule.id} since, so it can't come back`]);
|
|
312
312
|
const cap = (0, store_1.readConfig)(paths)?.activeCap ?? store_1.ACTIVE_CAP;
|
|
313
313
|
if (active.length >= cap)
|
|
314
|
-
return fail([
|
|
314
|
+
return fail([`${(0, store_1.rulesName)(paths)} is full (${cap} rules), so ${r.rule.id} can't come back until one goes`]);
|
|
315
315
|
(0, store_1.writeArchive)(paths, archive.filter((d) => d.id !== r.id));
|
|
316
316
|
(0, store_1.writeActive)(paths, [...active, r.rule], cap);
|
|
317
317
|
if (r.rule.candidate)
|
|
@@ -359,7 +359,7 @@ function reword(ruleId, to, opts = {}) {
|
|
|
359
359
|
id: ruleId,
|
|
360
360
|
decision: next,
|
|
361
361
|
was: rule.decision,
|
|
362
|
-
wrote: opts.dryRun ? [] : [
|
|
362
|
+
wrote: opts.dryRun ? [] : [(0, store_1.rulesName)(paths), '.arbiter/archive.md'],
|
|
363
363
|
},
|
|
364
364
|
};
|
|
365
365
|
}
|
|
@@ -555,7 +555,7 @@ function recordInput(input, opts = {}) {
|
|
|
555
555
|
options: [
|
|
556
556
|
...overlaps.map((o) => ({
|
|
557
557
|
flag: `--supersedes ${o.id}${again}`,
|
|
558
|
-
effect: `${o.id} leaves
|
|
558
|
+
effect: `${o.id} leaves ${(0, store_1.rulesName)(paths)} and stays in the archive; the new rule records supersedes: ${o.id}`,
|
|
559
559
|
})),
|
|
560
560
|
{ flag: `--keep-both${again}`, effect: 'both rules stay active' },
|
|
561
561
|
],
|
|
@@ -569,7 +569,7 @@ function recordInput(input, opts = {}) {
|
|
|
569
569
|
output: {
|
|
570
570
|
status: 'cap',
|
|
571
571
|
cap,
|
|
572
|
-
message:
|
|
572
|
+
message: `${(0, store_1.rulesName)(paths)} holds ${nextActive.length} of ${cap} rules. Nothing was written. Supersede an existing rule with --supersedes <id> to make room.`,
|
|
573
573
|
candidate: input,
|
|
574
574
|
active: nextActive.map((d) => ({ id: d.id, decision: d.decision, scope: d.scope })),
|
|
575
575
|
},
|
|
@@ -607,7 +607,7 @@ function recordInput(input, opts = {}) {
|
|
|
607
607
|
candidate: entry.candidate,
|
|
608
608
|
...(entry.against && { against: entry.against }),
|
|
609
609
|
active: `${nextActive.length} of ${cap}`,
|
|
610
|
-
wrote: opts.dryRun ? [] : entry.verdict === 'rule' || entry.verdict === 'retire' ? ['.arbiter/archive.md',
|
|
610
|
+
wrote: opts.dryRun ? [] : entry.verdict === 'rule' || entry.verdict === 'retire' ? ['.arbiter/archive.md', (0, store_1.rulesName)(paths)] : ['.arbiter/archive.md'],
|
|
611
611
|
...(request && { request: { id: request.id, status: opts.dryRun ? request.status : 'applied', author: request.author } }),
|
|
612
612
|
...(sweepSummary && { sweep: sweepSummary }),
|
|
613
613
|
...picture(paths, entry),
|
package/dist/commands/remove.js
CHANGED
|
@@ -93,7 +93,7 @@ function removeDecision(id, opts) {
|
|
|
93
93
|
...(replaced ? { note: `${replaced.id} — which ${id} replaced — is still inactive. Record it again if it should apply.` } : {}),
|
|
94
94
|
...(reopened.length ? { requests: `${reopened.join(', ')} ${reopened.length === 1 ? 'is' : 'are'} open again — nothing on record makes ${reopened.length === 1 ? 'that change' : 'those changes'} now, so ${reopened.length === 1 ? 'it needs' : 'they need'} a fresh answer` } : {}),
|
|
95
95
|
...(reused ? { idReuse: `${id} was the newest, so the next decision recorded will take that id again. If this board is published, comments on the old ${id} will read as if they were about the new one — republish after recording.` } : {}),
|
|
96
|
-
wrote: ['.arbiter/archive.md', ...(isActive ? [
|
|
96
|
+
wrote: ['.arbiter/archive.md', ...(isActive ? [(0, store_1.rulesName)(paths)] : []), ...touched, ...(detached.length ? ['.arbiter/requests.json'] : [])],
|
|
97
97
|
// Printed in full so it can be put back by hand — not everyone has git.
|
|
98
98
|
removed: (0, format_1.formatEntry)(entry).trimEnd(),
|
|
99
99
|
},
|
package/dist/commands/rename.js
CHANGED
|
@@ -71,7 +71,7 @@ function renameWork(from, to, opts = {}) {
|
|
|
71
71
|
}
|
|
72
72
|
if (active.some(mine)) {
|
|
73
73
|
(0, store_1.writeActive)(paths, rename(active));
|
|
74
|
-
wrote.push(
|
|
74
|
+
wrote.push((0, store_1.rulesName)(paths));
|
|
75
75
|
}
|
|
76
76
|
if (newId !== oldId) {
|
|
77
77
|
// Merged: its pictures join the other's, in the order they were taken.
|
package/dist/commands/review.js
CHANGED
|
@@ -96,7 +96,8 @@ function review(opts = {}) {
|
|
|
96
96
|
bytes += st.size;
|
|
97
97
|
latest = Math.max(latest, st.mtimeMs);
|
|
98
98
|
};
|
|
99
|
-
|
|
99
|
+
// The rules file as arbiter.json names it now: it can move while the board is open.
|
|
100
|
+
for (const f of [(0, store_1.resolvePaths)(root).decisions, paths.archiveDir, paths.config])
|
|
100
101
|
visit(f);
|
|
101
102
|
return `${files}.${bytes}.${latest}`;
|
|
102
103
|
};
|
|
@@ -196,8 +197,10 @@ function review(opts = {}) {
|
|
|
196
197
|
}
|
|
197
198
|
// DECISIONS.md as it is, for Download on Design rules: the file the agent reads, not a copy of it.
|
|
198
199
|
if (req.method === 'GET' && url.pathname === '/api/decisions') {
|
|
199
|
-
|
|
200
|
-
|
|
200
|
+
// Resolved now, not at start-up: the rules may have moved to a file of their own since.
|
|
201
|
+
const now = (0, store_1.resolvePaths)(root);
|
|
202
|
+
const text = node_fs_1.default.existsSync(now.decisions) ? node_fs_1.default.readFileSync(now.decisions, 'utf8') : '';
|
|
203
|
+
res.writeHead(200, { 'content-type': 'text/markdown; charset=utf-8', 'content-disposition': `attachment; filename="${(0, store_1.rulesName)(now)}"`, 'cache-control': 'no-store' });
|
|
201
204
|
res.end(text);
|
|
202
205
|
return;
|
|
203
206
|
}
|