arbiterdesign 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -37
- package/dist/area-names.js +120 -0
- package/dist/areas.js +131 -0
- package/dist/board-types.js +9 -0
- package/dist/candidates.js +7 -1
- package/dist/commands/areas.js +153 -0
- package/dist/commands/candidate.js +4 -2
- package/dist/commands/decision.js +100 -0
- package/dist/commands/export.js +88 -125
- package/dist/commands/init.js +12 -1
- package/dist/commands/record.js +129 -4
- package/dist/commands/rename.js +24 -10
- package/dist/commands/review.js +455 -78
- package/dist/commands/rules.js +5 -0
- package/dist/commands/setup.js +1 -0
- package/dist/commands/snapshot.js +24 -2
- package/dist/commands/sweep.js +1 -1
- package/dist/comments.js +24 -0
- package/dist/handoff.js +283 -0
- package/dist/hook.js +80 -0
- package/dist/hosted.js +11 -16
- package/dist/index.js +57 -21
- package/dist/localboard.js +219 -0
- package/dist/lock.js +134 -0
- package/dist/overlap.js +16 -0
- package/dist/pictures.js +4 -0
- package/dist/settings.js +107 -0
- package/dist/store.js +5 -4
- package/dist/verify.js +4 -2
- package/dist/work.js +110 -1
- package/package.json +3 -2
- package/templates/SKILL.md +110 -31
- package/templates/board/board.css +2 -0
- package/templates/board/board.js +25 -0
- package/templates/board/index.html +15 -0
- package/templates/fonts/OFL.txt +92 -92
- package/templates/hooks/arbiter-board.cjs +50 -0
- package/templates/review.html +0 -757
package/dist/commands/rules.js
CHANGED
|
@@ -19,6 +19,7 @@ const hosted_1 = require("../hosted");
|
|
|
19
19
|
const requests_1 = require("../requests");
|
|
20
20
|
const update_1 = require("./update");
|
|
21
21
|
const overlap_1 = require("../overlap");
|
|
22
|
+
const handoff_1 = require("../handoff");
|
|
22
23
|
function rules(id, opts = {}) {
|
|
23
24
|
const paths = (0, store_1.resolvePaths)((0, store_1.findRoot)(opts.cwd));
|
|
24
25
|
opts = { ...opts, config: (0, store_1.readConfig)(paths) };
|
|
@@ -75,7 +76,11 @@ function pendingList(pending, opts, paths) {
|
|
|
75
76
|
if (opts.json) {
|
|
76
77
|
const active = (0, store_1.readActive)(paths);
|
|
77
78
|
const ignore = opts.config?.overlap?.ignore;
|
|
79
|
+
// A Review Board sitting nobody was waiting on: its fixes and approved requests are still to make.
|
|
80
|
+
// Handed over as it is now: once it's made, `done` clears this much, and keeps anything judged since.
|
|
81
|
+
const lastReview = (0, handoff_1.takeHandoff)(paths);
|
|
78
82
|
return JSON.stringify({
|
|
83
|
+
...(lastReview && { lastReview: { ...lastReview, file: handoff_1.HANDOFF_FILE, done: 'npx arbiter review --done' } }),
|
|
79
84
|
// Judged decisions mean someone has been through a review, whatever arbiter.json says: the
|
|
80
85
|
// stamp lives in a committed file, and a branch that never merged takes it along.
|
|
81
86
|
firstRun: !opts.config?.onboarded && !archiveAll.length && !active.length,
|
package/dist/commands/setup.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.CHECKINS = void 0;
|
|
13
13
|
exports.setup = setup;
|
|
14
|
+
exports.appUrl = appUrl;
|
|
14
15
|
const store_1 = require("../store");
|
|
15
16
|
exports.CHECKINS = ['feature', 'quiet', 'every'];
|
|
16
17
|
function setup(opts) {
|
|
@@ -9,6 +9,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.snapshotWork = snapshotWork;
|
|
12
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
12
13
|
const node_path_1 = __importDefault(require("node:path"));
|
|
13
14
|
const store_1 = require("../store");
|
|
14
15
|
const hosted_1 = require("../hosted");
|
|
@@ -30,9 +31,19 @@ function snapshotWork(name, opts) {
|
|
|
30
31
|
const judged = archive.some((d) => mine(d) && (0, hosted_1.publishable)(d));
|
|
31
32
|
const queued = pending.filter((d) => mine(d) && d.level !== 'polish').length;
|
|
32
33
|
const polish = [...archive, ...pending].some((d) => mine(d) && d.level === 'polish' && d.verdict !== 'retire');
|
|
34
|
+
// The picture it had becomes an earlier version, so the board can show how the work got here. The same
|
|
35
|
+
// picture attached again isn't a new version.
|
|
36
|
+
const cur = (0, work_1.workSnapshot)(paths, id);
|
|
37
|
+
const same = !opts.capture && !!cur && sameFile(cur, node_path_1.default.resolve(root, opts.file));
|
|
38
|
+
const moved = same ? null : (0, work_1.keepEarlier)(paths, id);
|
|
33
39
|
const r = opts.capture ? (0, work_1.captureImage)((0, work_1.workDir)(paths), id) : (0, work_1.copyImage)(root, (0, work_1.workDir)(paths), id, opts.file);
|
|
34
|
-
if (!r.ok)
|
|
40
|
+
if (!r.ok) {
|
|
41
|
+
(0, work_1.restoreEarlier)(moved);
|
|
35
42
|
return { exitCode: 1, output: { status: 'failed', error: r.error } };
|
|
43
|
+
}
|
|
44
|
+
// Dated when it was attached: a copy keeps the source file's own time on some systems.
|
|
45
|
+
const now = new Date();
|
|
46
|
+
node_fs_1.default.utimesSync(node_path_1.default.join((0, work_1.workDir)(paths), r.file), now, now);
|
|
36
47
|
const note = judged
|
|
37
48
|
? null
|
|
38
49
|
: queued
|
|
@@ -42,6 +53,17 @@ function snapshotWork(name, opts) {
|
|
|
42
53
|
: `no decisions mention "${trigger}" yet — the picture shows once some do`;
|
|
43
54
|
return {
|
|
44
55
|
exitCode: 0,
|
|
45
|
-
output: { status: 'saved', work: trigger, id, file: node_path_1.default.relative(root, node_path_1.default.join((0, work_1.workDir)(paths), r.file)), ...(note ? { note } : {}) },
|
|
56
|
+
output: { status: 'saved', work: trigger, id, file: node_path_1.default.relative(root, node_path_1.default.join((0, work_1.workDir)(paths), r.file)), ...(moved ? { earlier: node_path_1.default.relative(root, moved.to) } : {}), ...(note ? { note } : {}) },
|
|
46
57
|
};
|
|
47
58
|
}
|
|
59
|
+
/** Byte for byte the same image. */
|
|
60
|
+
function sameFile(a, b) {
|
|
61
|
+
try {
|
|
62
|
+
if (node_fs_1.default.statSync(a).size !== node_fs_1.default.statSync(b).size)
|
|
63
|
+
return false;
|
|
64
|
+
return node_fs_1.default.readFileSync(a).equals(node_fs_1.default.readFileSync(b));
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
package/dist/commands/sweep.js
CHANGED
package/dist/comments.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The team board's comments, as `arbiter pull` keeps them: .arbiter/comments.json, committed. Pull
|
|
4
|
+
* writes the file (src/hosted.ts); requests and the local board read it. Kept here, apart from the
|
|
5
|
+
* publish code, so reading them doesn't mean depending on it.
|
|
6
|
+
*/
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.readComments = readComments;
|
|
12
|
+
exports.writeComments = writeComments;
|
|
13
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
14
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
15
|
+
const COMMENTS_FILE = 'comments.json';
|
|
16
|
+
function readComments(paths) {
|
|
17
|
+
const f = node_path_1.default.join(paths.archiveDir, COMMENTS_FILE);
|
|
18
|
+
return node_fs_1.default.existsSync(f) ? JSON.parse(node_fs_1.default.readFileSync(f, 'utf8')) : [];
|
|
19
|
+
}
|
|
20
|
+
/** Every comment on file, minus email addresses: nothing here needs them, and the file is committed. */
|
|
21
|
+
function writeComments(paths, comments) {
|
|
22
|
+
const kept = comments.map(({ author_email: _email, ...c }) => c);
|
|
23
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(paths.archiveDir, COMMENTS_FILE), JSON.stringify(kept, null, 2) + '\n');
|
|
24
|
+
}
|
package/dist/handoff.js
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The handoff: what you decided on the local board, for the agent to act on.
|
|
4
|
+
*
|
|
5
|
+
* The page records each answer as you give it. What it can't do is change code, so a Fix, a
|
|
6
|
+
* "Follow D-0009" and an approved request wait on the agent, in .arbiter/last-review.json, added to
|
|
7
|
+
* as you go. So does a rule edited or removed on Design rules, since the agent may have read
|
|
8
|
+
* DECISIONS.md before you changed it. The agent takes it with your next message in Claude Code (a
|
|
9
|
+
* hook tells it: see templates/hooks), or at the next /arbiter anywhere. What it was told is kept
|
|
10
|
+
* beside it (last-review.seen.json), and once it's made, `arbiter review --done` clears just that:
|
|
11
|
+
* anything you judged while it worked stays for next time. An agent waiting on the page
|
|
12
|
+
* (`review --json`) gets it when the last tab closes instead.
|
|
13
|
+
*/
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.HANDOFF_NAME = exports.HANDOFF_FILE = exports.decidedAnything = exports.SEEN = exports.FILE = void 0;
|
|
19
|
+
exports.summarize = summarize;
|
|
20
|
+
exports.handoffLine = handoffLine;
|
|
21
|
+
exports.mergeHandoffs = mergeHandoffs;
|
|
22
|
+
exports.saveHandoff = saveHandoff;
|
|
23
|
+
exports.takeHandoff = takeHandoff;
|
|
24
|
+
exports.handoffDone = handoffDone;
|
|
25
|
+
exports.saveAnswer = saveAnswer;
|
|
26
|
+
exports.withdrawAnswer = withdrawAnswer;
|
|
27
|
+
exports.withdrawRemoval = withdrawRemoval;
|
|
28
|
+
exports.clearHandoff = clearHandoff;
|
|
29
|
+
exports.readHandoff = readHandoff;
|
|
30
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
31
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
32
|
+
const lock_1 = require("./lock");
|
|
33
|
+
exports.FILE = 'last-review.json';
|
|
34
|
+
/** What the agent was told, as it was told it: what `review --done` clears, and nothing judged since. */
|
|
35
|
+
exports.SEEN = 'last-review.seen.json';
|
|
36
|
+
function summarize(answers, finished, at = new Date().toISOString()) {
|
|
37
|
+
const h = { finished, at, confirmed: [], rules: [], fixed: [], skipped: [], declined: [], options: [], reworded: [], removed: [], renamed: [], todo: [], next: '' };
|
|
38
|
+
for (const a of answers) {
|
|
39
|
+
if (a.kind === 'option')
|
|
40
|
+
h.options.push({ id: a.id, name: a.name, state: a.state });
|
|
41
|
+
else if (a.kind === 'rename')
|
|
42
|
+
h.renamed = renames(h.renamed ?? [], [{ from: a.from, to: a.to }]);
|
|
43
|
+
// A rule back in DECISIONS.md after the agent heard it was gone is in force again, as a new one is.
|
|
44
|
+
else if (a.kind === 'restore' || a.kind === 'rule')
|
|
45
|
+
h.rules.push(a.id);
|
|
46
|
+
else if (a.kind === 'reword' || a.kind === 'retire')
|
|
47
|
+
rulesChanged(h, a.kind === 'reword' ? [{ id: a.id, to: a.to }] : [], a.kind === 'retire' ? [{ id: a.id, rule: a.rule, why: a.why }] : []);
|
|
48
|
+
else if (a.kind === 'request') {
|
|
49
|
+
if (a.status === 'declined')
|
|
50
|
+
h.declined.push({ id: a.id, author: a.author, reason: a.reason ?? '' });
|
|
51
|
+
else
|
|
52
|
+
h.todo.push({ kind: 'request', id: a.id, author: a.author, screen: a.screenName, do: a.do ?? '' });
|
|
53
|
+
}
|
|
54
|
+
else if (a.as === 'skip')
|
|
55
|
+
h.skipped.push(a.pending);
|
|
56
|
+
else if (a.as === 'accept')
|
|
57
|
+
h.confirmed.push(a.id ?? a.pending);
|
|
58
|
+
else if (a.as === 'rule')
|
|
59
|
+
h.rules.push(a.id ?? a.pending);
|
|
60
|
+
else {
|
|
61
|
+
h.fixed.push(a.id ?? a.pending);
|
|
62
|
+
const id = a.id ?? a.pending;
|
|
63
|
+
if (a.follows)
|
|
64
|
+
h.todo.push({ kind: 'follow', id, rule: a.follows, to: a.to ?? '' });
|
|
65
|
+
else
|
|
66
|
+
h.todo.push({ kind: 'fix', id, change: a.change ?? '', to: a.to ?? '' });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
h.next = nextStep(h);
|
|
70
|
+
return h;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Only a rule's latest words count, and none for a rule removed since. Those go with the removal,
|
|
74
|
+
* so a removal put back brings them back too.
|
|
75
|
+
*/
|
|
76
|
+
function rulesChanged(h, reworded, removed) {
|
|
77
|
+
const was = h.reworded ?? [];
|
|
78
|
+
const later = new Set([...reworded, ...removed].map((r) => r.id));
|
|
79
|
+
h.reworded = [...was.filter((r) => !later.has(r.id)), ...reworded];
|
|
80
|
+
// Made a rule and removed again: the removal is what's true now.
|
|
81
|
+
h.rules = h.rules.filter((id) => !removed.some((r) => r.id === id));
|
|
82
|
+
h.removed = [...(h.removed ?? []), ...removed.map((r) => {
|
|
83
|
+
const edited = was.find((x) => x.id === r.id)?.to;
|
|
84
|
+
return edited ? { ...r, edited } : r;
|
|
85
|
+
})];
|
|
86
|
+
}
|
|
87
|
+
/** Renamed twice, A to B then B to C: one rename, A to C. Renamed back: none. */
|
|
88
|
+
function renames(was, next) {
|
|
89
|
+
let out = [...was];
|
|
90
|
+
for (const r of next) {
|
|
91
|
+
const before = out.find((x) => x.to === r.from);
|
|
92
|
+
out = out.filter((x) => x !== before);
|
|
93
|
+
const from = before ? before.from : r.from;
|
|
94
|
+
if (from !== r.to)
|
|
95
|
+
out.push({ from, to: r.to });
|
|
96
|
+
}
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
function nextStep(h) {
|
|
100
|
+
const rules = (h.reworded?.length || h.removed?.length ? ' Rules were edited or removed on Design rules: follow DECISIONS.md as it is now.' : '')
|
|
101
|
+
+ (h.renamed?.length ? ' Work was renamed on the board: use each new name as the trigger from now on.' : '');
|
|
102
|
+
if (!h.todo.length)
|
|
103
|
+
return `Nothing to change in the code.${rules}`;
|
|
104
|
+
return `Make each change in todo. They're recorded already, so don't judge or record them again. An approved request is the exception: record its change with --request <id> once it's made.${rules}`;
|
|
105
|
+
}
|
|
106
|
+
/** Anything decided at all. A sitting where nothing was answered hands nothing over. */
|
|
107
|
+
const decidedAnything = (h) => !!(h.confirmed.length || h.rules.length || h.fixed.length || h.skipped.length || h.declined.length || h.options.length || h.reworded?.length || h.removed?.length || h.renamed?.length || h.todo.length);
|
|
108
|
+
exports.decidedAnything = decidedAnything;
|
|
109
|
+
/** One line for the person at the terminal, when nobody's waiting on the JSON. `when` is when the agent hears of it. */
|
|
110
|
+
function handoffLine(h, when = 'at the next /arbiter') {
|
|
111
|
+
if (!(0, exports.decidedAnything)(h))
|
|
112
|
+
return null;
|
|
113
|
+
const parts = [
|
|
114
|
+
h.confirmed.length && `${h.confirmed.length} confirmed`,
|
|
115
|
+
h.rules.length && `${h.rules.length} made ${h.rules.length === 1 ? 'a rule' : 'rules'}`,
|
|
116
|
+
h.fixed.length && `${h.fixed.length} fixed`,
|
|
117
|
+
h.skipped.length && `${h.skipped.length} skipped`,
|
|
118
|
+
h.reworded?.length && `${h.reworded.length} ${h.reworded.length === 1 ? 'rule' : 'rules'} edited`,
|
|
119
|
+
h.removed?.length && `${h.removed.length} ${h.removed.length === 1 ? 'rule' : 'rules'} removed`,
|
|
120
|
+
h.renamed?.length && `${h.renamed.length} renamed`,
|
|
121
|
+
].filter(Boolean);
|
|
122
|
+
const said = parts.length ? `Recorded: ${parts.join(', ')}.` : 'Recorded.';
|
|
123
|
+
if (!h.todo.length)
|
|
124
|
+
return said;
|
|
125
|
+
return `${said} ${h.todo.length} ${h.todo.length === 1 ? 'change waits' : 'changes wait'} for your agent, which picks ${h.todo.length === 1 ? 'it' : 'them'} up ${when}.`;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* An earlier sitting nobody acted on, then this one: a second sitting adds to the first rather
|
|
129
|
+
* than replacing it, so nothing waiting on the agent is lost.
|
|
130
|
+
*/
|
|
131
|
+
function mergeHandoffs(earlier, h) {
|
|
132
|
+
if (!earlier)
|
|
133
|
+
return h;
|
|
134
|
+
const merged = {
|
|
135
|
+
...h,
|
|
136
|
+
confirmed: [...earlier.confirmed, ...h.confirmed],
|
|
137
|
+
rules: [...earlier.rules, ...h.rules],
|
|
138
|
+
fixed: [...earlier.fixed, ...h.fixed],
|
|
139
|
+
skipped: [...earlier.skipped, ...h.skipped],
|
|
140
|
+
declined: [...earlier.declined, ...h.declined],
|
|
141
|
+
options: [...earlier.options, ...h.options],
|
|
142
|
+
reworded: earlier.reworded ?? [],
|
|
143
|
+
removed: earlier.removed ?? [],
|
|
144
|
+
renamed: renames(earlier.renamed ?? [], h.renamed ?? []),
|
|
145
|
+
todo: [...earlier.todo, ...h.todo],
|
|
146
|
+
};
|
|
147
|
+
rulesChanged(merged, h.reworded ?? [], h.removed ?? []);
|
|
148
|
+
merged.next = nextStep(merged);
|
|
149
|
+
return merged;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Saved for the next /arbiter, which reads it with the queue. Kept out of git: it's one person's
|
|
153
|
+
* sitting, and a teammate's agent mustn't make it.
|
|
154
|
+
*/
|
|
155
|
+
function saveHandoff(paths, h) {
|
|
156
|
+
node_fs_1.default.mkdirSync(paths.archiveDir, { recursive: true });
|
|
157
|
+
(0, lock_1.writeAtomic)(node_path_1.default.join(paths.archiveDir, exports.FILE), JSON.stringify(h, null, 2) + '\n');
|
|
158
|
+
const gi = node_path_1.default.join(paths.archiveDir, '.gitignore');
|
|
159
|
+
const lines = (node_fs_1.default.existsSync(gi) ? node_fs_1.default.readFileSync(gi, 'utf8') : '').split(/\r?\n/).filter(Boolean);
|
|
160
|
+
const missing = [exports.FILE, exports.SEEN].filter((x) => !lines.includes(x));
|
|
161
|
+
if (missing.length)
|
|
162
|
+
node_fs_1.default.writeFileSync(gi, [...lines, ...missing].join('\n') + '\n');
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* What's waiting, handed to the agent: kept as it was given (SEEN), so `review --done` clears that and
|
|
166
|
+
* no more. The Claude Code hook keeps the same copy when it speaks.
|
|
167
|
+
*/
|
|
168
|
+
function takeHandoff(paths) {
|
|
169
|
+
const h = readHandoff(paths);
|
|
170
|
+
if (h)
|
|
171
|
+
(0, lock_1.writeAtomic)(node_path_1.default.join(paths.archiveDir, exports.SEEN), JSON.stringify(h, null, 2) + '\n');
|
|
172
|
+
return h;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The agent has made what it was told: that comes out of the file. Anything judged on the board since
|
|
176
|
+
* stays, for the hook to say at the next message. Nothing handed over yet: nothing is cleared.
|
|
177
|
+
*/
|
|
178
|
+
function handoffDone(paths) {
|
|
179
|
+
const h = readHandoff(paths);
|
|
180
|
+
const seenFile = node_path_1.default.join(paths.archiveDir, exports.SEEN);
|
|
181
|
+
let seen = null;
|
|
182
|
+
try {
|
|
183
|
+
seen = JSON.parse(node_fs_1.default.readFileSync(seenFile, 'utf8'));
|
|
184
|
+
}
|
|
185
|
+
catch { /* never handed over */ }
|
|
186
|
+
if (!h) {
|
|
187
|
+
node_fs_1.default.rmSync(seenFile, { force: true });
|
|
188
|
+
return { status: 'nothing', left: 0 };
|
|
189
|
+
}
|
|
190
|
+
if (!seen)
|
|
191
|
+
return { status: 'not-taken', left: h.todo.length, errors: ['Nothing was handed over yet, so nothing was cleared: read it first with npx arbiter rules --pending --json'] };
|
|
192
|
+
const key = (x) => JSON.stringify(x);
|
|
193
|
+
const minus = (now, was) => {
|
|
194
|
+
const gone = new Set((was ?? []).map(key));
|
|
195
|
+
return (now ?? []).filter((x) => !gone.has(key(x)));
|
|
196
|
+
};
|
|
197
|
+
const { told: _told, ...rest } = h;
|
|
198
|
+
const left = {
|
|
199
|
+
...rest,
|
|
200
|
+
confirmed: minus(h.confirmed, seen.confirmed),
|
|
201
|
+
rules: minus(h.rules, seen.rules),
|
|
202
|
+
fixed: minus(h.fixed, seen.fixed),
|
|
203
|
+
skipped: minus(h.skipped, seen.skipped),
|
|
204
|
+
declined: minus(h.declined, seen.declined),
|
|
205
|
+
options: minus(h.options, seen.options),
|
|
206
|
+
reworded: minus(h.reworded, seen.reworded),
|
|
207
|
+
removed: minus(h.removed, seen.removed),
|
|
208
|
+
renamed: minus(h.renamed, seen.renamed),
|
|
209
|
+
todo: minus(h.todo, seen.todo),
|
|
210
|
+
};
|
|
211
|
+
left.next = nextStep(left);
|
|
212
|
+
if ((0, exports.decidedAnything)(left))
|
|
213
|
+
saveHandoff(paths, left);
|
|
214
|
+
else
|
|
215
|
+
clearHandoff(paths);
|
|
216
|
+
node_fs_1.default.rmSync(seenFile, { force: true });
|
|
217
|
+
return { status: 'done', left: left.todo.length };
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* One answer, added to what's already waiting. Added, never rewritten from the sitting: the agent
|
|
221
|
+
* may have taken the file and made it while the board was still open, and a rewrite would hand
|
|
222
|
+
* those changes over a second time.
|
|
223
|
+
*/
|
|
224
|
+
function saveAnswer(paths, a) {
|
|
225
|
+
const h = mergeHandoffs(readHandoff(paths), summarize([a], 'closed'));
|
|
226
|
+
if ((0, exports.decidedAnything)(h))
|
|
227
|
+
saveHandoff(paths, h);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* An answer taken back on the page: out of what's waiting, so the agent never acts on it. False when
|
|
231
|
+
* the agent has taken it already, and may have made the change.
|
|
232
|
+
*/
|
|
233
|
+
function withdrawAnswer(paths, a) {
|
|
234
|
+
const h = readHandoff(paths);
|
|
235
|
+
const id = a.as === 'skip' ? a.pending : a.id ?? a.pending;
|
|
236
|
+
const list = a.as === 'skip' ? 'skipped' : a.as === 'accept' ? 'confirmed' : a.as === 'rule' ? 'rules' : 'fixed';
|
|
237
|
+
if (!h?.[list].includes(id))
|
|
238
|
+
return false;
|
|
239
|
+
// Rewritten as it is otherwise, `told` and all: taking one back is nothing new for the hook to say.
|
|
240
|
+
const next = { ...h, [list]: h[list].filter((x) => x !== id), todo: h.todo.filter((t) => t.kind === 'request' || t.id !== id) };
|
|
241
|
+
next.next = nextStep(next);
|
|
242
|
+
if ((0, exports.decidedAnything)(next))
|
|
243
|
+
saveHandoff(paths, next);
|
|
244
|
+
else
|
|
245
|
+
clearHandoff(paths);
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
/** A removal put back on the page: out of what's waiting. False when the agent has heard of it already. */
|
|
249
|
+
function withdrawRemoval(paths, id) {
|
|
250
|
+
const h = readHandoff(paths);
|
|
251
|
+
const gone = h?.removed?.find((r) => r.id === id);
|
|
252
|
+
if (!h || !gone)
|
|
253
|
+
return false;
|
|
254
|
+
const next = {
|
|
255
|
+
...h,
|
|
256
|
+
removed: h.removed.filter((r) => r.id !== id),
|
|
257
|
+
...(gone.edited && { reworded: [...(h.reworded ?? []), { id, to: gone.edited }] }),
|
|
258
|
+
};
|
|
259
|
+
next.next = nextStep(next);
|
|
260
|
+
if ((0, exports.decidedAnything)(next))
|
|
261
|
+
saveHandoff(paths, next);
|
|
262
|
+
else
|
|
263
|
+
clearHandoff(paths);
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
/** Handed over: the agent has it, so the next /arbiter mustn't make it a second time. */
|
|
267
|
+
function clearHandoff(paths) {
|
|
268
|
+
node_fs_1.default.rmSync(node_path_1.default.join(paths.archiveDir, exports.FILE), { force: true });
|
|
269
|
+
node_fs_1.default.rmSync(node_path_1.default.join(paths.archiveDir, exports.SEEN), { force: true });
|
|
270
|
+
}
|
|
271
|
+
function readHandoff(paths) {
|
|
272
|
+
const f = node_path_1.default.join(paths.archiveDir, exports.FILE);
|
|
273
|
+
if (!node_fs_1.default.existsSync(f))
|
|
274
|
+
return null;
|
|
275
|
+
try {
|
|
276
|
+
return JSON.parse(node_fs_1.default.readFileSync(f, 'utf8'));
|
|
277
|
+
}
|
|
278
|
+
catch {
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
exports.HANDOFF_FILE = `.arbiter/${exports.FILE}`;
|
|
283
|
+
exports.HANDOFF_NAME = exports.FILE;
|
package/dist/hook.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The Claude Code hook. Before each message you send, it tells the agent what you've judged on
|
|
4
|
+
* the local board since its last turn that needs the code changed, so the agent makes it then,
|
|
5
|
+
* without waiting for /arbiter. A script in .claude/hooks/ (templates/hooks/arbiter-board.cjs),
|
|
6
|
+
* run by a UserPromptSubmit entry in .claude/settings.json. Claude Code only: Cursor and Codex
|
|
7
|
+
* have no such hook, and pick it up at /arbiter.
|
|
8
|
+
*
|
|
9
|
+
* The script is plain node with nothing to install, since it runs before every message: it reads
|
|
10
|
+
* one file and, nearly always, finds nothing to say.
|
|
11
|
+
*/
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.HOOK_COMMAND = void 0;
|
|
17
|
+
exports.hookInstalled = hookInstalled;
|
|
18
|
+
exports.installHook = installHook;
|
|
19
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
20
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
21
|
+
const SCRIPT = node_path_1.default.join('.claude', 'hooks', 'arbiter-board.cjs');
|
|
22
|
+
const SETTINGS = node_path_1.default.join('.claude', 'settings.json');
|
|
23
|
+
const TEMPLATE = node_path_1.default.join(__dirname, '..', 'templates', 'hooks', 'arbiter-board.cjs');
|
|
24
|
+
/** Claude Code sets the project's root in this; the script finds the board's files from there. */
|
|
25
|
+
exports.HOOK_COMMAND = 'node "$CLAUDE_PROJECT_DIR/.claude/hooks/arbiter-board.cjs"';
|
|
26
|
+
const ours = (e) => (e.hooks ?? []).some((h) => h.command?.includes('arbiter-board.cjs'));
|
|
27
|
+
/** Both halves in place: the script, and the entry that runs it. */
|
|
28
|
+
function hookInstalled(root) {
|
|
29
|
+
if (!node_fs_1.default.existsSync(node_path_1.default.join(root, SCRIPT)))
|
|
30
|
+
return false;
|
|
31
|
+
try {
|
|
32
|
+
const s = JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(root, SETTINGS), 'utf8'));
|
|
33
|
+
return (s.hooks?.UserPromptSubmit ?? []).some(ours);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Write the script, and add the entry to .claude/settings.json beside whatever is there. A
|
|
41
|
+
* settings file that isn't plain JSON is left alone: rewriting it could lose what someone wrote.
|
|
42
|
+
*/
|
|
43
|
+
function installHook(root) {
|
|
44
|
+
const steps = [];
|
|
45
|
+
const script = node_path_1.default.join(root, SCRIPT);
|
|
46
|
+
const content = node_fs_1.default.readFileSync(TEMPLATE, 'utf8').replace(/\r\n/g, '\n');
|
|
47
|
+
const before = node_fs_1.default.existsSync(script) ? node_fs_1.default.readFileSync(script, 'utf8') : null;
|
|
48
|
+
if (before === content)
|
|
49
|
+
steps.push({ file: '.claude/hooks/arbiter-board.cjs', outcome: 'unchanged' });
|
|
50
|
+
else {
|
|
51
|
+
node_fs_1.default.mkdirSync(node_path_1.default.dirname(script), { recursive: true });
|
|
52
|
+
node_fs_1.default.writeFileSync(script, content);
|
|
53
|
+
steps.push({ file: '.claude/hooks/arbiter-board.cjs', outcome: before === null ? 'created' : 'updated' });
|
|
54
|
+
}
|
|
55
|
+
const file = node_path_1.default.join(root, SETTINGS);
|
|
56
|
+
const exists = node_fs_1.default.existsSync(file);
|
|
57
|
+
let settings = {};
|
|
58
|
+
if (exists) {
|
|
59
|
+
try {
|
|
60
|
+
settings = JSON.parse(node_fs_1.default.readFileSync(file, 'utf8'));
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
steps.push({ file: '.claude/settings.json', outcome: 'skipped', note: `not plain JSON, so left alone. Add a UserPromptSubmit hook running: ${exports.HOOK_COMMAND}` });
|
|
64
|
+
return steps;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const entries = settings.hooks?.UserPromptSubmit ?? [];
|
|
68
|
+
const mine = entries.find(ours);
|
|
69
|
+
if (mine?.hooks?.some((h) => h.command === exports.HOOK_COMMAND)) {
|
|
70
|
+
steps.push({ file: '.claude/settings.json', outcome: 'unchanged' });
|
|
71
|
+
return steps;
|
|
72
|
+
}
|
|
73
|
+
const entry = { hooks: [{ type: 'command', command: exports.HOOK_COMMAND }] };
|
|
74
|
+
const next = mine ? entries.map((e) => (e === mine ? entry : e)) : [...entries, entry];
|
|
75
|
+
settings = { ...settings, hooks: { ...settings.hooks, UserPromptSubmit: next } };
|
|
76
|
+
node_fs_1.default.mkdirSync(node_path_1.default.dirname(file), { recursive: true });
|
|
77
|
+
node_fs_1.default.writeFileSync(file, JSON.stringify(settings, null, 2) + '\n');
|
|
78
|
+
steps.push({ file: '.claude/settings.json', outcome: exists ? 'updated' : 'created' });
|
|
79
|
+
return steps;
|
|
80
|
+
}
|
package/dist/hosted.js
CHANGED
|
@@ -12,14 +12,12 @@ 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 = void 0;
|
|
15
|
+
exports.PASSWORD_MIN = exports.publishable = 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;
|
|
19
19
|
exports.readToken = readToken;
|
|
20
20
|
exports.writeToken = writeToken;
|
|
21
|
-
exports.readComments = readComments;
|
|
22
|
-
exports.writeComments = writeComments;
|
|
23
21
|
exports.buildManifest = buildManifest;
|
|
24
22
|
exports.newPassword = newPassword;
|
|
25
23
|
exports.publishHosted = publishHosted;
|
|
@@ -34,6 +32,7 @@ const candidates_1 = require("./candidates");
|
|
|
34
32
|
const store_1 = require("./store");
|
|
35
33
|
const work_1 = require("./work");
|
|
36
34
|
const requests_1 = require("./requests");
|
|
35
|
+
const comments_1 = require("./comments");
|
|
37
36
|
/** The link for places that only want to know about the board, where a broken hosted.json shouldn't stop the command. */
|
|
38
37
|
function readLinkOrNull(paths) {
|
|
39
38
|
try {
|
|
@@ -43,9 +42,12 @@ function readLinkOrNull(paths) {
|
|
|
43
42
|
return null;
|
|
44
43
|
}
|
|
45
44
|
}
|
|
45
|
+
// Pulled comments live in their own module; pull writes them, and these names stay here for it.
|
|
46
|
+
var comments_2 = require("./comments");
|
|
47
|
+
Object.defineProperty(exports, "readComments", { enumerable: true, get: function () { return comments_2.readComments; } });
|
|
48
|
+
Object.defineProperty(exports, "writeComments", { enumerable: true, get: function () { return comments_2.writeComments; } });
|
|
46
49
|
const LINK_FILE = 'hosted.json';
|
|
47
50
|
const TOKEN_FILE = 'hosted.token';
|
|
48
|
-
const COMMENTS_FILE = 'comments.json';
|
|
49
51
|
exports.TOKEN_ENV = 'ARBITER_PUBLISH_TOKEN';
|
|
50
52
|
exports.ADMIN_ENV = 'ARBITER_ADMIN_TOKEN';
|
|
51
53
|
const IMAGE_TYPES = { '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.gif': 'image/gif' };
|
|
@@ -84,15 +86,6 @@ function writeToken(paths, token) {
|
|
|
84
86
|
lines.push(TOKEN_FILE);
|
|
85
87
|
node_fs_1.default.writeFileSync(gi, lines.join('\n') + '\n');
|
|
86
88
|
}
|
|
87
|
-
function readComments(paths) {
|
|
88
|
-
const f = node_path_1.default.join(paths.archiveDir, COMMENTS_FILE);
|
|
89
|
-
return node_fs_1.default.existsSync(f) ? JSON.parse(node_fs_1.default.readFileSync(f, 'utf8')) : [];
|
|
90
|
-
}
|
|
91
|
-
/** Every comment on file, minus email addresses: nothing here needs them, and the file is committed. */
|
|
92
|
-
function writeComments(paths, comments) {
|
|
93
|
-
const kept = comments.map(({ author_email: _email, ...c }) => c);
|
|
94
|
-
node_fs_1.default.writeFileSync(node_path_1.default.join(paths.archiveDir, COMMENTS_FILE), JSON.stringify(kept, null, 2) + '\n');
|
|
95
|
-
}
|
|
96
89
|
const publishable = (d) => d.verdict !== 'pending' && d.verdict !== 'retire' && d.level !== 'polish';
|
|
97
90
|
exports.publishable = publishable;
|
|
98
91
|
const wire = (d) => ({ id: d.id, change: d.change, decision: d.decision, rejected: d.rejected, verdict: d.verdict, dimension: d.dimension, scope: d.scope, ref: d.ref });
|
|
@@ -101,6 +94,8 @@ const wire = (d) => ({ id: d.id, change: d.change, decision: d.decision, rejecte
|
|
|
101
94
|
* candidate rides with that screen; the rest are grouped by the piece of work they came from
|
|
102
95
|
* (`trigger`) and become a card each — no picture, state `recorded`. Most work is one direction,
|
|
103
96
|
* iterated; the board shouldn't be empty for it.
|
|
97
|
+
*
|
|
98
|
+
* Only for the team board. The local board builds its own from the same files (src/localboard.ts).
|
|
104
99
|
*/
|
|
105
100
|
function buildManifest(paths, opts = {}) {
|
|
106
101
|
const skipped = [];
|
|
@@ -155,7 +150,7 @@ function buildManifest(paths, opts = {}) {
|
|
|
155
150
|
// Work has no product area of its own; it joins one only when the trigger names an existing one.
|
|
156
151
|
id, name: trigger, feature: areas.get(trigger.toLowerCase()) ?? null, state: 'recorded', work: true,
|
|
157
152
|
author: last.author, date: last.date, reason: null, notes: '', supersededBy: null, url: null, snapshot,
|
|
158
|
-
decisions: ds.map(wire),
|
|
153
|
+
decisions: ds.filter(exports.publishable).map(wire),
|
|
159
154
|
});
|
|
160
155
|
}
|
|
161
156
|
// The day each became a rule, for the board's Design rules page.
|
|
@@ -303,14 +298,14 @@ async function pullHosted(paths) {
|
|
|
303
298
|
// What's on file keeps its words, but takes the board's card: a renamed piece of work's comments
|
|
304
299
|
// move there at publish, and a copy pulled before that would still point at the old card.
|
|
305
300
|
const onBoard = new Map(current.map((c) => [c.id, c]));
|
|
306
|
-
const existing = readComments(paths).map((c) => {
|
|
301
|
+
const existing = (0, comments_1.readComments)(paths).map((c) => {
|
|
307
302
|
const now = onBoard.get(c.id);
|
|
308
303
|
return now && now.candidate_id !== c.candidate_id ? { ...c, candidate_id: now.candidate_id } : c;
|
|
309
304
|
});
|
|
310
305
|
const seen = new Set(existing.map((c) => c.id));
|
|
311
306
|
const fresh = current.filter((c) => !seen.has(c.id));
|
|
312
307
|
const merged = [...existing, ...fresh].sort((a, b) => String(a.created_at ?? '').localeCompare(String(b.created_at ?? '')));
|
|
313
|
-
writeComments(paths, merged);
|
|
308
|
+
(0, comments_1.writeComments)(paths, merged);
|
|
314
309
|
// hosted.json is committed: rewrite it only when the board has moved on, or every pull on every
|
|
315
310
|
// machine would leave it changed, and two of them would conflict.
|
|
316
311
|
const boardVersion = r.body.board_version ?? link.boardVersion ?? null;
|