arbiterdesign 0.1.3 → 0.1.4
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 +34 -2
- package/dist/autopublish.js +81 -0
- package/dist/commands/publish.js +21 -4
- package/dist/commands/remove.js +232 -0
- package/dist/commands/review.js +18 -1
- package/dist/commands/snapshot.js +10 -2
- package/dist/format.js +4 -3
- package/dist/index.js +42 -3
- package/dist/store.js +10 -0
- package/package.json +1 -1
- package/templates/SKILL.md +74 -9
package/README.md
CHANGED
|
@@ -42,10 +42,13 @@ arbiter snapshot "<work>" --file x.png a picture for a piece of work (or --cap
|
|
|
42
42
|
arbiter record walk through a decision at the terminal
|
|
43
43
|
arbiter record '<json>' record now (what the agent calls)
|
|
44
44
|
arbiter record --pending '<json>' queue for later
|
|
45
|
-
arbiter record P-0003 --as rule judge a queued one: accept | rule | skip | fix --to "…"
|
|
45
|
+
arbiter record P-0003 --as rule judge a queued one: accept | rule | skip | fix --to "…" [--candidate C-0001]
|
|
46
46
|
arbiter record --all --as accept judge every queued item [--level polish] [--trigger "Settings build"]
|
|
47
47
|
arbiter record --findings f.json queue a scanner's findings for verdicts
|
|
48
48
|
arbiter record --retire D-0003 --why "…" drop a rule with no replacement
|
|
49
|
+
arbiter remove D-0004 take out a record that was never real: a decision, a screen (C-0001),
|
|
50
|
+
or a picture (--snapshot "<work>")
|
|
51
|
+
arbiter unlink D-0004 detach a decision from the screen it was recorded against
|
|
49
52
|
arbiter review judge the queue in a browser page
|
|
50
53
|
arbiter verify [id] re-check a decision's claim against its files
|
|
51
54
|
arbiter sweep D-0004 [--queue] find existing violations of a mechanical rule
|
|
@@ -56,6 +59,7 @@ arbiter export static folder of the board for people withou
|
|
|
56
59
|
arbiter publish board online at arbiter.design, with comments; prints the share link. Nothing to set up.
|
|
57
60
|
arbiter publish --to <url|pages> your own hosted Arbiter, or GitHub Pages (git destination + export + commit + push)
|
|
58
61
|
arbiter publish --on-push also write a GitHub Actions workflow that republishes on every push, and set its secret
|
|
62
|
+
arbiter publish --auto republish whenever the record changes — no GitHub, no CI, no repository needed
|
|
59
63
|
arbiter pull bring comments and "looks good" reactions down into .arbiter/comments.json
|
|
60
64
|
arbiter drift deviations per screen: accepts, unverified claims, rules broken
|
|
61
65
|
arbiter rules active rules [--dimension <name>] [--json]
|
|
@@ -67,6 +71,30 @@ arbiter update newest Arbiter: install it, refresh the skil
|
|
|
67
71
|
|
|
68
72
|
`record` exit codes: `0` recorded · `1` invalid · `2` overlap — re-run with `--supersedes <id>` or `--keep-both` · `3` cap reached · `4` contradicted — the named files don't match the claim.
|
|
69
73
|
|
|
74
|
+
## Screenshots
|
|
75
|
+
|
|
76
|
+
The agent takes one picture per piece of work, when the work settles and it changed how a specific screen looks. Size isn't the test — a polish fix usually lives on one screen and earns a picture; a font or token change has no single screen to point at and doesn't. Motion and anything behavioural can't be carried by a still, so they don't either.
|
|
77
|
+
|
|
78
|
+
The agent's own screenshot tool hands it an image, not a file, so it renders to disk with a headless browser (`chrome --headless --screenshot=…`) and attaches that. When it can't — no browser, app not running, screen behind a login — it says so once, naming the reason, whatever the check-in setting. `--capture` is the manual fallback and is macOS only; elsewhere, save a screenshot and pass `--file`.
|
|
79
|
+
|
|
80
|
+
Name a piece of work after the screen it changed where the work splits that way — `Settings — billing` rather than one `Settings build` across four routes — and one picture per piece of work is one per screen.
|
|
81
|
+
|
|
82
|
+
## Taking something out
|
|
83
|
+
|
|
84
|
+
Three acts, and only one is a removal.
|
|
85
|
+
|
|
86
|
+
| | What it means | Command |
|
|
87
|
+
|---|---|---|
|
|
88
|
+
| **Retire** | It was real, it's over | `arbiter record --retire D-0003 --why "…"` |
|
|
89
|
+
| **Remove** | It was never real | `arbiter remove D-0004` |
|
|
90
|
+
| **Unlink** | Real, attached to the wrong screen | `arbiter unlink D-0004` |
|
|
91
|
+
|
|
92
|
+
The archive is append-only for judgments: a call you changed your mind about is superseded, and that history is the point. It isn't append-only for mistakes. A test entry, an agent misfire, or a screen invented to work around a bug is a record that says something false, and keeping it forever makes the archive less trustworthy, not more.
|
|
93
|
+
|
|
94
|
+
So `remove` deletes — from the archive, from `DECISIONS.md`, from the candidate files — and prints the full record it removed, because git holds the history only for people who have a repo. It refuses while anything still points at the record: an active rule (retire it), a decision another one supersedes, or a screen with decisions still linked (`--force` unlinks them in one go).
|
|
95
|
+
|
|
96
|
+
`arbiter remove --snapshot "<work>"` takes only the picture; the work and its decisions stay, and the board keeps the old image until the next publish.
|
|
97
|
+
|
|
70
98
|
## Verification
|
|
71
99
|
|
|
72
100
|
A mechanical decision can name `files` and an `expect` — literal strings that must be `present` in / `absent` from them (write `regex:<pattern>` for a pattern, e.g. `regex:#[0-9a-fA-F]{6}\b` for any hex colour). Arbiter reads only those files, never the repo. A claim that doesn't hold is refused. `accept` verdicts are never checked: an exception is a deviation by definition.
|
|
@@ -96,7 +124,11 @@ The scan set is the rule's `paths` (directories or files) if it names any, else
|
|
|
96
124
|
|
|
97
125
|
The hosted board at [arbiter.design](https://arbiter.design) serves a board at a share link and lets people comment or say "looks good" after a magic-link sign-in. Git stays the record: the service holds one board version per project and the comments, nothing else. `npx arbiter publish` uploads; `npx arbiter pull` brings comments back, where `arbiter review` shows them beside each screen. Only `publish` and `pull` ever touch the network. The service itself is a separate, private codebase.
|
|
98
126
|
|
|
99
|
-
|
|
127
|
+
Two ways to keep the board current without anyone remembering.
|
|
128
|
+
|
|
129
|
+
`npx arbiter publish --auto` is the one that works anywhere. It sets `hosted.auto` in `arbiter.json`, and from then on the board republishes whenever the record changes — after judging, after a screen changes state, after a picture is attached or removed. No GitHub, no CI, no git repository. Queueing decisions doesn't trigger it, since the queue is never published. If a republish fails — offline, service down — the command still succeeds and says the board is behind; the record is already written, and git is what holds it. `--no-auto` turns it off.
|
|
130
|
+
|
|
131
|
+
`npx arbiter publish --on-push` is the GitHub route, and it writes `.github/workflows/arbiter.yml`, which runs `publish` when decisions land on the default branch, and sets the `ARBITER_PUBLISH_TOKEN` repository secret through `gh` if it's signed in (otherwise it prints the one-line instruction). Commit the workflow together with `.arbiter/hosted.json`. Under CI, `publish` only ever updates the board that file names — it refuses to create one, so a repo where the file wasn't committed can't mint orphan boards on every push.
|
|
100
132
|
|
|
101
133
|
## Candidates
|
|
102
134
|
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Keeping a board current without GitHub, CI, or even a git repository.
|
|
4
|
+
*
|
|
5
|
+
* `publish --on-push` needs GitHub Actions, which needs GitHub. A git hook would at least need a
|
|
6
|
+
* repository. Plenty of projects have neither — local only, or deployed straight to a server — and
|
|
7
|
+
* for them the board goes stale the moment someone forgets to publish.
|
|
8
|
+
*
|
|
9
|
+
* The board changes when the record changes, so that's the moment to republish: after judging,
|
|
10
|
+
* after a screen changes state, after a picture is attached or removed. `hosted.auto` in
|
|
11
|
+
* arbiter.json turns it on. Nothing watches anything; this runs inside a command the user ran.
|
|
12
|
+
*
|
|
13
|
+
* Still only two things touch the network — publish and pull — and this is publish, switched on
|
|
14
|
+
* deliberately in a committed file where everyone on the project can see it.
|
|
15
|
+
*/
|
|
16
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
19
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
20
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
21
|
+
}
|
|
22
|
+
Object.defineProperty(o, k2, desc);
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
28
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
29
|
+
}) : function(o, v) {
|
|
30
|
+
o["default"] = v;
|
|
31
|
+
});
|
|
32
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
33
|
+
var ownKeys = function(o) {
|
|
34
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
35
|
+
var ar = [];
|
|
36
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
37
|
+
return ar;
|
|
38
|
+
};
|
|
39
|
+
return ownKeys(o);
|
|
40
|
+
};
|
|
41
|
+
return function (mod) {
|
|
42
|
+
if (mod && mod.__esModule) return mod;
|
|
43
|
+
var result = {};
|
|
44
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
45
|
+
__setModuleDefault(result, mod);
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
})();
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.autoPublishOn = autoPublishOn;
|
|
51
|
+
exports.autoPublish = autoPublish;
|
|
52
|
+
const hosted_1 = require("./hosted");
|
|
53
|
+
const store_1 = require("./store");
|
|
54
|
+
/** Off unless arbiter.json says `hosted.auto` and the project has been published once. */
|
|
55
|
+
function autoPublishOn(cwd) {
|
|
56
|
+
const paths = (0, store_1.resolvePaths)((0, store_1.findRoot)(cwd));
|
|
57
|
+
return !!(0, store_1.readConfig)(paths)?.hosted?.auto && !!(0, hosted_1.readLink)(paths);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Republish, if it's on. Returns a line to print, or null. Never throws and never changes an exit
|
|
61
|
+
* code: a board that failed to update is worth a sentence, not a failed command — the record is
|
|
62
|
+
* already written, and git is what actually holds it.
|
|
63
|
+
*/
|
|
64
|
+
async function autoPublish(cwd) {
|
|
65
|
+
if (!autoPublishOn(cwd))
|
|
66
|
+
return null;
|
|
67
|
+
const link = (0, hosted_1.readLink)((0, store_1.resolvePaths)((0, store_1.findRoot)(cwd)));
|
|
68
|
+
const { publish } = await Promise.resolve().then(() => __importStar(require('./commands/publish')));
|
|
69
|
+
try {
|
|
70
|
+
// Always the board this project is already linked to. Falling through to the default host
|
|
71
|
+
// would create a second, empty board somewhere else entirely.
|
|
72
|
+
const r = await publish({ cwd, to: link.url });
|
|
73
|
+
if (r.ok && r.url)
|
|
74
|
+
return `Board updated — ${r.url}`;
|
|
75
|
+
const failed = r.steps.find((s) => s.outcome === 'failed');
|
|
76
|
+
return `Board not updated: ${failed?.note ?? 'publish failed'} — run \`npx arbiter publish\` when you can.`;
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
return `Board not updated: ${e.message} — run \`npx arbiter publish\` when you can.`;
|
|
80
|
+
}
|
|
81
|
+
}
|
package/dist/commands/publish.js
CHANGED
|
@@ -50,6 +50,13 @@ async function publish(opts = {}) {
|
|
|
50
50
|
if (opts.onPush)
|
|
51
51
|
for (const s of onPush(root, paths))
|
|
52
52
|
steps.push(s);
|
|
53
|
+
if (opts.auto !== undefined) {
|
|
54
|
+
const config = (0, store_1.readConfig)(paths) ?? { version: 1, destination: 'local' };
|
|
55
|
+
(0, store_1.writeConfig)(paths, { ...config, hosted: { ...config.hosted, auto: opts.auto } });
|
|
56
|
+
done('auto', opts.auto
|
|
57
|
+
? 'on — the board republishes whenever the record changes (arbiter.json, commit it)'
|
|
58
|
+
: 'off — publish by hand from now on');
|
|
59
|
+
}
|
|
53
60
|
return { ok: steps.every((s) => s.outcome !== 'failed'), steps, url: r.link.shareUrl };
|
|
54
61
|
}
|
|
55
62
|
catch (e) {
|
|
@@ -127,6 +134,20 @@ async function publish(opts = {}) {
|
|
|
127
134
|
*/
|
|
128
135
|
function onPush(root, paths) {
|
|
129
136
|
const steps = [];
|
|
137
|
+
// A GitHub Actions file is worthless anywhere but GitHub, and writing one anyway used to report
|
|
138
|
+
// success for automation that could never run. Say what will actually work here instead.
|
|
139
|
+
const inRepo = !!git(root, ['rev-parse', '--is-inside-work-tree']);
|
|
140
|
+
const remote = inRepo ? git(root, ['remote', 'get-url', 'origin']) : null;
|
|
141
|
+
const gh = remote && /github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?$/.exec(remote);
|
|
142
|
+
if (!gh) {
|
|
143
|
+
const why = !inRepo ? 'this project is not a git repository' : !remote ? 'there is no remote named origin' : `${remote.replace(/^.*@/, '')} is not GitHub`;
|
|
144
|
+
steps.push({
|
|
145
|
+
step: 'on-push',
|
|
146
|
+
outcome: 'skipped',
|
|
147
|
+
note: `${why}, and --on-push writes a GitHub Actions workflow. For a board that keeps itself current without GitHub: npx arbiter publish --auto`,
|
|
148
|
+
});
|
|
149
|
+
return steps;
|
|
150
|
+
}
|
|
130
151
|
const branch = git(root, ['rev-parse', '--abbrev-ref', 'HEAD']) || 'main';
|
|
131
152
|
const file = node_path_1.default.join(root, exports.WORKFLOW_FILE);
|
|
132
153
|
const content = workflow(branch, (0, init_1.selfVersion)());
|
|
@@ -142,13 +163,9 @@ function onPush(root, paths) {
|
|
|
142
163
|
steps.push({ step: 'workflow', outcome: 'skipped', note: `${exports.WORKFLOW_FILE} exists and differs — leaving your edits` });
|
|
143
164
|
}
|
|
144
165
|
const token = (0, hosted_1.readToken)(paths);
|
|
145
|
-
const remote = git(root, ['remote', 'get-url', 'origin']);
|
|
146
|
-
const gh = remote && /github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?$/.exec(remote);
|
|
147
166
|
const manual = `once, on github.com: Settings → Secrets and variables → Actions → New repository secret → ${hosted_1.TOKEN_ENV} = the contents of .arbiter/hosted.token`;
|
|
148
167
|
if (!token)
|
|
149
168
|
steps.push({ step: 'secret', outcome: 'skipped', note: `no publish token here — ${manual}` });
|
|
150
|
-
else if (!gh)
|
|
151
|
-
steps.push({ step: 'secret', outcome: 'skipped', note: `no GitHub remote named origin — ${manual}` });
|
|
152
169
|
else if (!has('gh') || !ghOk(root))
|
|
153
170
|
steps.push({ step: 'secret', outcome: 'skipped', note: `gh not ${has('gh') ? 'signed in' : 'installed'} — ${manual}` });
|
|
154
171
|
else {
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `arbiter remove` and `arbiter unlink` — the exits Arbiter was missing.
|
|
4
|
+
*
|
|
5
|
+
* Three verbs, and they mean different things:
|
|
6
|
+
*
|
|
7
|
+
* retire it was real, it's over → the rule leaves DECISIONS.md, the archive keeps it
|
|
8
|
+
* remove it was never real → it leaves the record entirely
|
|
9
|
+
* unlink it was real, wrongly attached → the decision stays, its screen doesn't
|
|
10
|
+
*
|
|
11
|
+
* Append-only is right for judgments: a call you changed your mind about is superseded, and that
|
|
12
|
+
* history is the point. It's wrong for mistakes. A test entry, an agent misfire, or a screen
|
|
13
|
+
* invented to work around a bug isn't history — it's a record that says something false, and
|
|
14
|
+
* keeping it forever makes the archive less trustworthy, not more.
|
|
15
|
+
*
|
|
16
|
+
* So `remove` deletes. Git holds the history for anyone who has it, and the output prints what
|
|
17
|
+
* went, in full, for anyone who doesn't. Nothing is removed while something still points at it.
|
|
18
|
+
*/
|
|
19
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
20
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.remove = remove;
|
|
24
|
+
exports.removeSnapshot = removeSnapshot;
|
|
25
|
+
exports.unlink = unlink;
|
|
26
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
27
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
28
|
+
const schema_1 = require("../schema");
|
|
29
|
+
const format_1 = require("../format");
|
|
30
|
+
const store_1 = require("../store");
|
|
31
|
+
const candidates_1 = require("../candidates");
|
|
32
|
+
const destination_1 = require("../destination");
|
|
33
|
+
const work_1 = require("../work");
|
|
34
|
+
const fail = (errors) => ({ exitCode: 1, output: { status: 'invalid', errors } });
|
|
35
|
+
// ── remove ─────────────────────────────────────────────────────────────────
|
|
36
|
+
function remove(id, opts = {}) {
|
|
37
|
+
const raw = id?.trim() ?? '';
|
|
38
|
+
if (schema_1.DECISION_ID.test(raw))
|
|
39
|
+
return removeDecision(raw, opts);
|
|
40
|
+
if (schema_1.CANDIDATE_ID.test(raw))
|
|
41
|
+
return removeCandidate(raw, opts);
|
|
42
|
+
if (/^P-\d{4,}$/.test(raw))
|
|
43
|
+
return fail([`${raw} is still in the queue — drop it with: npx arbiter record ${raw} --as skip`]);
|
|
44
|
+
return fail([`not something that can be removed: ${raw} (a decision like D-0004, a candidate like C-0001, or a piece of work by name)`]);
|
|
45
|
+
}
|
|
46
|
+
function removeDecision(id, opts) {
|
|
47
|
+
const paths = (0, store_1.resolvePaths)((0, store_1.findRoot)(opts.cwd));
|
|
48
|
+
const archive = (0, store_1.readArchive)(paths);
|
|
49
|
+
const entry = archive.find((d) => d.id === id);
|
|
50
|
+
if (!entry)
|
|
51
|
+
return fail([`${id} is not in the archive`]);
|
|
52
|
+
const active = (0, store_1.readActive)(paths);
|
|
53
|
+
const isActive = active.some((d) => d.id === id);
|
|
54
|
+
if (isActive && !opts.force) {
|
|
55
|
+
return fail([
|
|
56
|
+
`${id} is an active rule. If the rule is real and simply over, retiring keeps it in the record: npx arbiter record --retire ${id} --why "<reason>"`,
|
|
57
|
+
`If it was never a real rule, take it out of both: npx arbiter remove ${id} --force`,
|
|
58
|
+
]);
|
|
59
|
+
}
|
|
60
|
+
const later = archive.find((d) => d.supersedes === id);
|
|
61
|
+
if (later) {
|
|
62
|
+
return fail([`${later.id} supersedes ${id} — removing it would leave ${later.id} pointing at nothing. Remove ${later.id} first if neither is real.`]);
|
|
63
|
+
}
|
|
64
|
+
(0, store_1.writeArchive)(paths, archive.filter((d) => d.id !== id));
|
|
65
|
+
if (isActive) {
|
|
66
|
+
const config = (0, store_1.readConfig)(paths);
|
|
67
|
+
(0, store_1.writeActive)(paths, active.filter((d) => d.id !== id), config?.activeCap ?? store_1.ACTIVE_CAP);
|
|
68
|
+
}
|
|
69
|
+
const touched = refreshLinked(paths, entry.candidate);
|
|
70
|
+
// Removing a rule doesn't bring back the one it replaced: that one may have been real, and
|
|
71
|
+
// guessing would put a rule back the user never re-confirmed. Say so rather than lose it quietly.
|
|
72
|
+
const replaced = entry.supersedes && archive.find((d) => d.id === entry.supersedes);
|
|
73
|
+
// Ids come from the highest in the file, so taking the last one out frees it for the next
|
|
74
|
+
// decision. Locally that's harmless; on a board already published, comments point at the id.
|
|
75
|
+
const reused = archive.every((d) => d.id <= id) ? id : null;
|
|
76
|
+
return {
|
|
77
|
+
exitCode: 0,
|
|
78
|
+
output: {
|
|
79
|
+
status: 'removed',
|
|
80
|
+
id,
|
|
81
|
+
decision: entry.decision,
|
|
82
|
+
...(replaced ? { note: `${replaced.id} — which ${id} replaced — is still inactive. Record it again if it should apply.` } : {}),
|
|
83
|
+
...(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.` } : {}),
|
|
84
|
+
wrote: ['.arbiter/archive.md', ...(isActive ? ['DECISIONS.md'] : []), ...touched],
|
|
85
|
+
// Printed in full so it can be put back by hand — not everyone has git.
|
|
86
|
+
removed: (0, format_1.formatEntry)(entry).trimEnd(),
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function removeCandidate(id, opts) {
|
|
91
|
+
const root = (0, store_1.findRoot)(opts.cwd);
|
|
92
|
+
const paths = (0, store_1.resolvePaths)(root);
|
|
93
|
+
const all = (0, candidates_1.readCandidates)(paths);
|
|
94
|
+
const c = all.find((x) => x.id === id);
|
|
95
|
+
if (!c)
|
|
96
|
+
return fail([`${id} is not a candidate here`]);
|
|
97
|
+
const by = all.find((x) => x.supersededBy === id);
|
|
98
|
+
if (by)
|
|
99
|
+
return fail([`${by.id} says it was superseded by ${id} — clear that first: npx arbiter candidate ${by.id} --state generated`]);
|
|
100
|
+
const archive = (0, store_1.readArchive)(paths);
|
|
101
|
+
const pending = (0, store_1.readPending)(paths);
|
|
102
|
+
const linked = [...archive, ...pending].filter((d) => d.candidate === id);
|
|
103
|
+
if (linked.length && !opts.force) {
|
|
104
|
+
return fail([
|
|
105
|
+
`${linked.length} decision${linked.length === 1 ? '' : 's'} still linked to ${id}: ${linked.map((d) => d.id).join(', ')}.`,
|
|
106
|
+
`Detach them and keep them: npx arbiter unlink ${linked.map((d) => d.id).join(' ')}`,
|
|
107
|
+
`Or remove the screen and detach them in one go: npx arbiter remove ${id} --force`,
|
|
108
|
+
]);
|
|
109
|
+
}
|
|
110
|
+
if (linked.length)
|
|
111
|
+
unlinkAll(paths, linked.map((d) => d.id));
|
|
112
|
+
const file = (0, candidates_1.candidateFile)(paths, id);
|
|
113
|
+
const shot = c.snapshot ? node_path_1.default.join((0, candidates_1.candidatesDir)(paths), c.snapshot) : null;
|
|
114
|
+
const before = node_fs_1.default.existsSync(file) ? node_fs_1.default.readFileSync(file, 'utf8') : '';
|
|
115
|
+
node_fs_1.default.rmSync(file, { force: true });
|
|
116
|
+
if (shot)
|
|
117
|
+
node_fs_1.default.rmSync(shot, { force: true });
|
|
118
|
+
const config = (0, store_1.readConfig)(paths);
|
|
119
|
+
const delivered = (0, destination_1.deliver)(paths, config, [], `remove ${id}`);
|
|
120
|
+
return {
|
|
121
|
+
exitCode: 0,
|
|
122
|
+
output: {
|
|
123
|
+
status: 'removed',
|
|
124
|
+
id,
|
|
125
|
+
name: c.name,
|
|
126
|
+
...(linked.length ? { unlinked: linked.map((d) => d.id) } : {}),
|
|
127
|
+
...(all.every((x) => x.id <= id) ? { idReuse: `${id} was the newest, so the next screen added will take that id again.` } : {}),
|
|
128
|
+
wrote: [node_path_1.default.relative(root, file), ...(shot ? [node_path_1.default.relative(root, shot)] : [])].map((p) => p.split(node_path_1.default.sep).join('/')),
|
|
129
|
+
removed: before.trimEnd(),
|
|
130
|
+
...(delivered.destination === 'git' ? { destination: 'git', committed: delivered.committed } : {}),
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/** `arbiter remove --snapshot "<piece of work>"` — the picture goes, the work stays. */
|
|
135
|
+
function removeSnapshot(name, opts = {}) {
|
|
136
|
+
const root = (0, store_1.findRoot)(opts.cwd);
|
|
137
|
+
const paths = (0, store_1.resolvePaths)(root);
|
|
138
|
+
const trigger = name?.trim() ?? '';
|
|
139
|
+
if (!trigger)
|
|
140
|
+
return fail(['name the piece of work, as the decisions did: npx arbiter remove --snapshot "Settings — billing"']);
|
|
141
|
+
// A candidate's picture belongs to the candidate; take it off there.
|
|
142
|
+
const cand = (0, candidates_1.readCandidates)(paths).find((c) => c.id === trigger || c.name === trigger);
|
|
143
|
+
if (cand) {
|
|
144
|
+
if (!cand.snapshot)
|
|
145
|
+
return fail([`${cand.id} has no picture`]);
|
|
146
|
+
const shot = node_path_1.default.join((0, candidates_1.candidatesDir)(paths), cand.snapshot);
|
|
147
|
+
node_fs_1.default.rmSync(shot, { force: true });
|
|
148
|
+
(0, candidates_1.writeCandidate)(paths, { ...cand, snapshot: null });
|
|
149
|
+
const delivered = (0, destination_1.deliver)(paths, (0, store_1.readConfig)(paths), [{ ...cand, snapshot: null }], `remove snapshot ${cand.id}`);
|
|
150
|
+
return {
|
|
151
|
+
exitCode: 0,
|
|
152
|
+
output: { status: 'removed', id: cand.id, wrote: [node_path_1.default.relative(root, shot).split(node_path_1.default.sep).join('/')], ...(delivered.destination === 'git' ? { committed: delivered.committed } : {}) },
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const id = (0, work_1.workId)(trigger);
|
|
156
|
+
const file = (0, work_1.workSnapshot)(paths, id);
|
|
157
|
+
if (!file)
|
|
158
|
+
return fail([`no picture attached to "${trigger}"`]);
|
|
159
|
+
node_fs_1.default.rmSync(file, { force: true });
|
|
160
|
+
return {
|
|
161
|
+
exitCode: 0,
|
|
162
|
+
output: {
|
|
163
|
+
status: 'removed',
|
|
164
|
+
work: trigger,
|
|
165
|
+
id,
|
|
166
|
+
wrote: [node_path_1.default.relative(root, file).split(node_path_1.default.sep).join('/')],
|
|
167
|
+
note: 'the board keeps the old picture until the next `npx arbiter publish`',
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
// ── unlink ─────────────────────────────────────────────────────────────────
|
|
172
|
+
/** Detach recorded decisions from their screen. The decisions stay exactly as they are. */
|
|
173
|
+
function unlink(ids, opts = {}) {
|
|
174
|
+
const paths = (0, store_1.resolvePaths)((0, store_1.findRoot)(opts.cwd));
|
|
175
|
+
const wanted = (ids ?? []).map((i) => i.trim()).filter(Boolean);
|
|
176
|
+
if (!wanted.length)
|
|
177
|
+
return fail(['name at least one decision: npx arbiter unlink D-0004']);
|
|
178
|
+
const bad = wanted.filter((i) => !schema_1.DECISION_ID.test(i) && !/^P-\d{4,}$/.test(i));
|
|
179
|
+
if (bad.length)
|
|
180
|
+
return fail([`not decision ids: ${bad.join(', ')} (D-0004, or P-0003 while queued)`]);
|
|
181
|
+
const archive = (0, store_1.readArchive)(paths);
|
|
182
|
+
const pending = (0, store_1.readPending)(paths);
|
|
183
|
+
const known = new Map([...archive, ...pending].map((d) => [d.id, d]));
|
|
184
|
+
const missing = wanted.filter((i) => !known.has(i));
|
|
185
|
+
if (missing.length)
|
|
186
|
+
return fail([`not found: ${missing.join(', ')}`]);
|
|
187
|
+
const unattached = wanted.filter((i) => !known.get(i).candidate);
|
|
188
|
+
if (unattached.length === wanted.length)
|
|
189
|
+
return fail([`already attached to no screen: ${unattached.join(', ')}`]);
|
|
190
|
+
const changed = wanted.filter((i) => known.get(i).candidate);
|
|
191
|
+
const from = new Set(changed.map((i) => known.get(i).candidate));
|
|
192
|
+
unlinkAll(paths, changed);
|
|
193
|
+
return {
|
|
194
|
+
exitCode: 0,
|
|
195
|
+
output: {
|
|
196
|
+
status: 'unlinked',
|
|
197
|
+
ids: changed,
|
|
198
|
+
from: [...from],
|
|
199
|
+
...(unattached.length ? { alreadyLoose: unattached } : {}),
|
|
200
|
+
wrote: ['.arbiter/archive.md', ...refreshMany(paths, from)],
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
// ── shared ─────────────────────────────────────────────────────────────────
|
|
205
|
+
/** Clear `candidate` on the named decisions, wherever they live, and refresh the screens they left. */
|
|
206
|
+
function unlinkAll(paths, ids) {
|
|
207
|
+
const set = new Set(ids);
|
|
208
|
+
const archive = (0, store_1.readArchive)(paths);
|
|
209
|
+
if (archive.some((d) => set.has(d.id))) {
|
|
210
|
+
(0, store_1.writeArchive)(paths, archive.map((d) => (set.has(d.id) ? { ...d, candidate: null } : d)));
|
|
211
|
+
}
|
|
212
|
+
const pending = (0, store_1.readPending)(paths);
|
|
213
|
+
if (pending.some((d) => set.has(d.id))) {
|
|
214
|
+
(0, store_1.writePending)(paths, pending.map((d) => (set.has(d.id) ? { ...d, candidate: null } : d)));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/** A screen's file lists its decisions, so it has to be rewritten when that list changes. */
|
|
218
|
+
function refreshLinked(paths, candidate) {
|
|
219
|
+
if (!candidate)
|
|
220
|
+
return [];
|
|
221
|
+
return refreshMany(paths, new Set([candidate]));
|
|
222
|
+
}
|
|
223
|
+
function refreshMany(paths, ids) {
|
|
224
|
+
const wrote = [];
|
|
225
|
+
for (const c of (0, candidates_1.readCandidates)(paths)) {
|
|
226
|
+
if (!ids.has(c.id))
|
|
227
|
+
continue;
|
|
228
|
+
(0, candidates_1.writeCandidate)(paths, c);
|
|
229
|
+
wrote.push(`.arbiter/candidates/${c.id}.md`);
|
|
230
|
+
}
|
|
231
|
+
return wrote;
|
|
232
|
+
}
|
package/dist/commands/review.js
CHANGED
|
@@ -20,6 +20,7 @@ const candidate_1 = require("./candidate");
|
|
|
20
20
|
const candidates_1 = require("../candidates");
|
|
21
21
|
const hosted_1 = require("../hosted");
|
|
22
22
|
const store_1 = require("../store");
|
|
23
|
+
const autopublish_1 = require("../autopublish");
|
|
23
24
|
const PAGE = node_path_1.default.join(__dirname, '..', '..', 'templates', 'review.html');
|
|
24
25
|
function review(opts = {}) {
|
|
25
26
|
const root = (0, store_1.findRoot)(opts.cwd);
|
|
@@ -44,6 +45,9 @@ function review(opts = {}) {
|
|
|
44
45
|
cap: (0, store_1.readConfig)(paths)?.activeCap ?? store_1.ACTIVE_CAP,
|
|
45
46
|
};
|
|
46
47
|
};
|
|
48
|
+
// Judging twenty items shouldn't mean twenty publishes, so the board is updated once, at the
|
|
49
|
+
// end. The page writes the same files the CLI does, but doesn't go through its handlers.
|
|
50
|
+
let changed = false;
|
|
47
51
|
return new Promise((resolve) => {
|
|
48
52
|
const server = node_http_1.default.createServer(async (req, res) => {
|
|
49
53
|
const url = new URL(req.url ?? '/', 'http://127.0.0.1');
|
|
@@ -59,12 +63,16 @@ function review(opts = {}) {
|
|
|
59
63
|
if (req.method === 'POST' && url.pathname === '/api/judge') {
|
|
60
64
|
const body = JSON.parse(await readBody(req));
|
|
61
65
|
const result = (0, record_1.judge)(body.id, { as: body.as, to: body.to, supersedes: body.supersedes, keepBoth: body.keepBoth, cwd });
|
|
66
|
+
if (result.exitCode === 0)
|
|
67
|
+
changed = true;
|
|
62
68
|
json(res, 200, { exitCode: result.exitCode, ...result.output });
|
|
63
69
|
return;
|
|
64
70
|
}
|
|
65
71
|
if (req.method === 'POST' && url.pathname === '/api/judge-all') {
|
|
66
72
|
const body = JSON.parse(await readBody(req));
|
|
67
73
|
const result = (0, record_1.judgeAll)({ as: body.as, level: body.level, trigger: body.trigger, cwd });
|
|
74
|
+
if (result.exitCode === 0)
|
|
75
|
+
changed = true;
|
|
68
76
|
json(res, 200, { exitCode: result.exitCode, ...result.output });
|
|
69
77
|
return;
|
|
70
78
|
}
|
|
@@ -84,6 +92,8 @@ function review(opts = {}) {
|
|
|
84
92
|
if (req.method === 'POST' && url.pathname === '/api/candidate') {
|
|
85
93
|
const body = JSON.parse(await readBody(req));
|
|
86
94
|
const result = (0, candidate_1.updateCandidate)(body.id, { state: body.state, why: body.why, keepOthers: body.keepOthers, cwd });
|
|
95
|
+
if (result.exitCode === 0)
|
|
96
|
+
changed = true;
|
|
87
97
|
json(res, 200, { exitCode: result.exitCode, ...result.output });
|
|
88
98
|
return;
|
|
89
99
|
}
|
|
@@ -105,7 +115,14 @@ function review(opts = {}) {
|
|
|
105
115
|
});
|
|
106
116
|
// Browsers keep connections alive; close() alone would wait on them forever.
|
|
107
117
|
const stop = () => {
|
|
108
|
-
server.close(() =>
|
|
118
|
+
server.close(async () => {
|
|
119
|
+
if (changed) {
|
|
120
|
+
const line = await (0, autopublish_1.autoPublish)(cwd);
|
|
121
|
+
if (line)
|
|
122
|
+
process.stdout.write(line + '\n');
|
|
123
|
+
}
|
|
124
|
+
resolve();
|
|
125
|
+
});
|
|
109
126
|
server.closeAllConnections();
|
|
110
127
|
};
|
|
111
128
|
process.on('SIGINT', stop);
|
|
@@ -21,12 +21,20 @@ function snapshotWork(name, opts) {
|
|
|
21
21
|
if (!opts.file && !opts.capture)
|
|
22
22
|
return { exitCode: 1, output: { status: 'invalid', errors: ['pass --file <image> or --capture'] } };
|
|
23
23
|
const id = (0, work_1.workId)(trigger);
|
|
24
|
-
|
|
24
|
+
// A work card is built from judged decisions only, so a picture for work still in the queue has
|
|
25
|
+
// nothing to hang on yet. Counting the queue here would report success for a board that stays empty.
|
|
26
|
+
const judged = (0, store_1.readArchive)(paths).some((d) => (0, work_1.workId)(d.trigger) === id && d.verdict !== 'retire');
|
|
27
|
+
const queued = (0, store_1.readPending)(paths).filter((d) => (0, work_1.workId)(d.trigger) === id).length;
|
|
25
28
|
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);
|
|
26
29
|
if (!r.ok)
|
|
27
30
|
return { exitCode: 1, output: { status: 'failed', error: r.error } };
|
|
31
|
+
const note = judged
|
|
32
|
+
? null
|
|
33
|
+
: queued
|
|
34
|
+
? `"${trigger}" has ${queued} decision${queued === 1 ? '' : 's'} still in the queue — the picture shows on the board once they're judged (/arbiter, or npx arbiter review)`
|
|
35
|
+
: `no decisions mention "${trigger}" yet — the picture shows once some do`;
|
|
28
36
|
return {
|
|
29
37
|
exitCode: 0,
|
|
30
|
-
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)), ...(
|
|
38
|
+
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 } : {}) },
|
|
31
39
|
};
|
|
32
40
|
}
|
package/dist/format.js
CHANGED
|
@@ -229,9 +229,10 @@ function archiveHeader() {
|
|
|
229
229
|
return [
|
|
230
230
|
'# Decision archive',
|
|
231
231
|
'',
|
|
232
|
-
'Every decision ever recorded, in order.
|
|
233
|
-
'
|
|
234
|
-
'
|
|
232
|
+
'Every decision ever recorded, in order. A decision you changed your mind about is superseded,',
|
|
233
|
+
'never rewritten; only `npx arbiter remove` takes an entry out, for a record of something that',
|
|
234
|
+
'never happened. Active rules live in `DECISIONS.md`; this file is for traceability and is never',
|
|
235
|
+
'loaded into agent context.',
|
|
235
236
|
'',
|
|
236
237
|
].join('\n');
|
|
237
238
|
}
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,8 @@ const rules_1 = require("./commands/rules");
|
|
|
17
17
|
const init_1 = require("./commands/init");
|
|
18
18
|
const review_1 = require("./commands/review");
|
|
19
19
|
const update_1 = require("./commands/update");
|
|
20
|
+
const remove_1 = require("./commands/remove");
|
|
21
|
+
const autopublish_1 = require("./autopublish");
|
|
20
22
|
const program = new commander_1.Command();
|
|
21
23
|
program
|
|
22
24
|
.name('arbiter')
|
|
@@ -79,6 +81,9 @@ program
|
|
|
79
81
|
result = opts.pending ? (0, record_1.queue)(input, opts) : (0, record_1.record)(input, opts);
|
|
80
82
|
}
|
|
81
83
|
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
84
|
+
// Queueing never reaches the board — work cards are built from judged decisions.
|
|
85
|
+
if (result.exitCode === 0 && !opts.pending)
|
|
86
|
+
await boardUpdated(opts.cwd);
|
|
82
87
|
process.exit(result.exitCode);
|
|
83
88
|
});
|
|
84
89
|
program
|
|
@@ -139,9 +144,11 @@ program
|
|
|
139
144
|
.description('Attach a picture to a piece of work, named as its decisions named it: snapshot "Settings build" --file shot.png')
|
|
140
145
|
.option('--file <image>', 'screenshot to keep beside the work')
|
|
141
146
|
.option('--capture', 'macOS: drag-select a region of the screen')
|
|
142
|
-
.action((work, opts) => {
|
|
147
|
+
.action(async (work, opts) => {
|
|
143
148
|
const result = (0, snapshot_1.snapshotWork)(work, opts);
|
|
144
149
|
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
150
|
+
if (result.exitCode === 0)
|
|
151
|
+
await boardUpdated(opts.cwd);
|
|
145
152
|
process.exit(result.exitCode);
|
|
146
153
|
});
|
|
147
154
|
program
|
|
@@ -156,9 +163,11 @@ program
|
|
|
156
163
|
.option('--by <id>', 'with --state superseded: the candidate that replaced it')
|
|
157
164
|
.option('--keep-others', "approving doesn't supersede sibling directions")
|
|
158
165
|
.option('--author <name>', 'override the author')
|
|
159
|
-
.action((idOrAdd, name, opts) => {
|
|
166
|
+
.action(async (idOrAdd, name, opts) => {
|
|
160
167
|
const result = idOrAdd === 'add' ? (0, candidate_1.addCandidate)(name ?? '', opts) : (0, candidate_1.updateCandidate)(idOrAdd, opts);
|
|
161
168
|
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
169
|
+
if (result.exitCode === 0)
|
|
170
|
+
await boardUpdated(opts.cwd);
|
|
162
171
|
process.exit(result.exitCode);
|
|
163
172
|
});
|
|
164
173
|
program
|
|
@@ -195,8 +204,10 @@ program
|
|
|
195
204
|
.option('--admin-token <token>', 'only for a self-hosted Arbiter that gates board creation')
|
|
196
205
|
.option('--no-push', 'GitHub Pages mode: do everything except push')
|
|
197
206
|
.option('--on-push', 'also write a GitHub Actions workflow that republishes on every push, and set its secret')
|
|
207
|
+
.option('--auto', 'republish whenever the record changes — no GitHub, no CI, no repository needed')
|
|
208
|
+
.option('--no-auto', 'stop republishing automatically')
|
|
198
209
|
.action(async (opts) => {
|
|
199
|
-
const r = await (0, publish_1.publish)({ noPush: opts.push === false, to: opts.to, admin: opts.adminToken, onPush: opts.onPush });
|
|
210
|
+
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 });
|
|
200
211
|
const w = Math.max(...r.steps.map((s) => s.step.length));
|
|
201
212
|
for (const s of r.steps)
|
|
202
213
|
process.stdout.write(` ${s.step.padEnd(w)} ${s.outcome}${s.note ? ` — ${s.note}` : ''}\n`);
|
|
@@ -218,6 +229,28 @@ program
|
|
|
218
229
|
.action(async (opts) => {
|
|
219
230
|
await (0, review_1.review)(opts);
|
|
220
231
|
});
|
|
232
|
+
program
|
|
233
|
+
.command('remove [id]')
|
|
234
|
+
.description('Take a record out that was never real: a decision (D-0004), a screen (C-0001), or a picture (--snapshot "<work>"). A rule that is simply over is `record --retire` instead.')
|
|
235
|
+
.option('--snapshot <work>', 'remove the picture attached to a piece of work or a screen, keeping the record')
|
|
236
|
+
.option('--force', 'with a screen: unlink the decisions on it rather than refusing')
|
|
237
|
+
.action(async (id, opts) => {
|
|
238
|
+
const result = opts.snapshot ? (0, remove_1.removeSnapshot)(opts.snapshot, opts) : (0, remove_1.remove)(id ?? '', opts);
|
|
239
|
+
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
240
|
+
if (result.exitCode === 0)
|
|
241
|
+
await boardUpdated(opts.cwd);
|
|
242
|
+
process.exit(result.exitCode);
|
|
243
|
+
});
|
|
244
|
+
program
|
|
245
|
+
.command('unlink <ids...>')
|
|
246
|
+
.description('Detach decisions from the screen they were recorded against. The decisions stay exactly as they are.')
|
|
247
|
+
.action(async (ids, opts) => {
|
|
248
|
+
const result = (0, remove_1.unlink)(ids, opts);
|
|
249
|
+
process.stdout.write(JSON.stringify(result.output, null, 2) + '\n');
|
|
250
|
+
if (result.exitCode === 0)
|
|
251
|
+
await boardUpdated(opts.cwd);
|
|
252
|
+
process.exit(result.exitCode);
|
|
253
|
+
});
|
|
221
254
|
program
|
|
222
255
|
.command('update')
|
|
223
256
|
.description('Bring this project up to the newest Arbiter: install it, refresh the skill file, re-pin the publish workflow. Settings and decisions untouched.')
|
|
@@ -254,6 +287,12 @@ program.parseAsync(process.argv).catch((e) => {
|
|
|
254
287
|
process.stderr.write(`arbiter: ${e.message}\n`);
|
|
255
288
|
process.exit(1);
|
|
256
289
|
});
|
|
290
|
+
/** With `hosted.auto`, the board follows the record. Prints a line when it does, or why it didn't. */
|
|
291
|
+
async function boardUpdated(cwd) {
|
|
292
|
+
const line = await (0, autopublish_1.autoPublish)(cwd);
|
|
293
|
+
if (line)
|
|
294
|
+
process.stdout.write(line + '\n');
|
|
295
|
+
}
|
|
257
296
|
function readStdin() {
|
|
258
297
|
if (process.stdin.isTTY)
|
|
259
298
|
return Promise.resolve('');
|
package/dist/store.js
CHANGED
|
@@ -16,6 +16,7 @@ exports.readActive = readActive;
|
|
|
16
16
|
exports.writeActive = writeActive;
|
|
17
17
|
exports.readArchive = readArchive;
|
|
18
18
|
exports.appendArchive = appendArchive;
|
|
19
|
+
exports.writeArchive = writeArchive;
|
|
19
20
|
exports.readPending = readPending;
|
|
20
21
|
exports.writePending = writePending;
|
|
21
22
|
exports.nextPendingId = nextPendingId;
|
|
@@ -79,6 +80,15 @@ function appendArchive(paths, d) {
|
|
|
79
80
|
const prefix = exists ? '\n' : (0, format_1.archiveHeader)() + '\n';
|
|
80
81
|
node_fs_1.default.appendFileSync(paths.archive, prefix + (0, format_1.formatEntry)(d));
|
|
81
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Rewrites the archive in full. Only `remove` and `unlink` use this: the archive is append-only
|
|
85
|
+
* for judgments — a decision you changed your mind about is superseded, never rewritten — but a
|
|
86
|
+
* record of something that never happened is noise, not history, and has to be able to leave.
|
|
87
|
+
*/
|
|
88
|
+
function writeArchive(paths, decisions) {
|
|
89
|
+
node_fs_1.default.mkdirSync(paths.archiveDir, { recursive: true });
|
|
90
|
+
node_fs_1.default.writeFileSync(paths.archive, (0, format_1.archiveHeader)() + '\n' + decisions.map(format_1.formatEntry).join('\n'));
|
|
91
|
+
}
|
|
82
92
|
function readPending(paths) {
|
|
83
93
|
if (!node_fs_1.default.existsSync(paths.pending))
|
|
84
94
|
return [];
|
package/package.json
CHANGED
package/templates/SKILL.md
CHANGED
|
@@ -40,7 +40,7 @@ A count on every reply gets ignored; a sentence about what changed, only after s
|
|
|
40
40
|
The output may also carry `update` — this skill file was written by an older Arbiter than the one installed (`update.skill` vs `update.cli`), so the protocol you're following is behind. Once per session, add one line, whatever `checkin` says:
|
|
41
41
|
|
|
42
42
|
```
|
|
43
|
-
Arbiter's skill file is from 0.1.
|
|
43
|
+
Arbiter's skill file is from 0.1.3 (the CLI is 0.1.4) — say "update arbiter" and I'll refresh it.
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
Never run it unasked. When they say yes — or say *"update arbiter"* unprompted — run the command `update.command` names and relay what it prints. It leaves `DECISIONS.md`, the archive and the settings alone.
|
|
@@ -89,6 +89,8 @@ npx arbiter record P-0003 --as skip # typed "skip" in Other
|
|
|
89
89
|
npx arbiter record P-0003 --as fix --to "<what they typed>"
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
+
If the decision belongs to a screen you tracked as a candidate, add `--candidate C-0001` to any of those — it links at the moment it's judged, and the screen's page picks it up. That's the only moment linking is free; afterwards it takes `npx arbiter unlink` and a re-record.
|
|
93
|
+
|
|
92
94
|
Bulk answers are one command, not a loop:
|
|
93
95
|
|
|
94
96
|
```
|
|
@@ -103,7 +105,7 @@ npx arbiter record --all --as accept --trigger "Settings build" # one piece
|
|
|
103
105
|
|
|
104
106
|
### What counts as a decision
|
|
105
107
|
|
|
106
|
-
A point where
|
|
108
|
+
A point where the UI could have gone more than one way and went one way — whether you weighed the options or the user named the one they wanted — and that isn't **already covered by `DECISIONS.md`**. Look along these dimensions:
|
|
107
109
|
|
|
108
110
|
| Dimension | What to look for |
|
|
109
111
|
|---|---|
|
|
@@ -121,7 +123,9 @@ For each decision, note what it was chosen **over**. Rejected alternatives come
|
|
|
121
123
|
2. **Options you weighed and didn't build.** You considered tabs, went with a single page. Tabs are rejected, with your reason.
|
|
122
124
|
3. **Corrections.** Whatever you did that the user then changed is rejected; what they asked for is the decision.
|
|
123
125
|
|
|
124
|
-
|
|
126
|
+
**Any visual change that stays in the UI counts too**: colour, spacing, type, radii, icons, what's shown or hidden. That holds even when no alternative was weighed, and even when the user asked for it. The version it replaced is the rejected alternative. A visual change that would repeat on other screens is a `pattern`. A one-off is `polish`.
|
|
127
|
+
|
|
128
|
+
Skip mechanical necessities (imports, prop plumbing, file placement), and non-visual things the user told you to do.
|
|
125
129
|
|
|
126
130
|
**Size every decision.** A 7px height fix and a new settings architecture are not the same kind of call, and the review must not treat them the same. Set `level`:
|
|
127
131
|
|
|
@@ -283,15 +287,57 @@ If violations are more than zero, add one line and offer a selection — never s
|
|
|
283
287
|
|
|
284
288
|
Judgment rules never sweep. Don't offer it for them.
|
|
285
289
|
|
|
286
|
-
## Screenshots —
|
|
290
|
+
## Screenshots — when the work changed a screen
|
|
291
|
+
|
|
292
|
+
**When a piece of work settles and it changed how a specific screen looks, take one picture of that screen.** Not after every iteration — once, when the work settles. Without asking.
|
|
293
|
+
|
|
294
|
+
Size is not the test. A polish fix usually lives on one screen and deserves a picture; a feature-level change is often systemic and may not have one. The test is: **can you point at a screen where this shows?**
|
|
295
|
+
|
|
296
|
+
- **No single screen to point at** — a font, a token, a global rule — no picture. The rule statement is the record, and `scope` already says how far it reaches. The exception is a change that alters how everything looks, like a spacing scale, a palette, or a nav that appears on every page: take one screen, set `scope` to `global` or `pattern:<name>` so the record says where it applies, and open the `change` line with "Across every screen," so nobody reads the picture as the whole story.
|
|
297
|
+
- **A still can't carry it** — motion, transitions, focus order, anything behavioural — no picture.
|
|
298
|
+
- **A state** — empty, loading, error, modal — only if you were already looking at it. Don't force a state to photograph it.
|
|
299
|
+
|
|
300
|
+
A picture isn't evidence of the change; there's one image and nothing to compare it against. It's a record of what the screen looks like now. That's why small cosmetic work earns one and a font swap doesn't.
|
|
301
|
+
|
|
302
|
+
**Name the piece of work after the screen it changed**, where the work honestly splits that way: `Settings — billing`, `Settings — profile`, rather than one `Settings build` covering four routes. One picture per piece of work is then one per screen, and the review reads screen by screen instead of one lump. Work that shouldn't be split — a flow across three steps, a nav change touching every page — stays one piece of work and gets one representative picture.
|
|
303
|
+
|
|
304
|
+
### Taking it
|
|
305
|
+
|
|
306
|
+
Your own screenshot tool hands the image back to you in the conversation; `arbiter snapshot` needs a **file on disk**. So write one:
|
|
307
|
+
|
|
308
|
+
```
|
|
309
|
+
chrome --headless --disable-gpu --screenshot=/abs/path/shot.png --window-size=1280,900 "http://localhost:3000/settings"
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
`chrome` may be `google-chrome`, `chromium`, or Edge (`msedge`) — one of them is on nearly every machine. If the project already uses Playwright or Puppeteer, use that instead; it's configured for this app already. Then attach it, naming the work exactly as its decisions named it (the `trigger`):
|
|
313
|
+
|
|
314
|
+
```
|
|
315
|
+
npx arbiter snapshot "Settings — billing" --file /abs/path/shot.png
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
Delete the temporary file afterwards. Never attach a picture of a blank page, a spinner, or an error screen — no picture is better than a wrong one.
|
|
319
|
+
|
|
320
|
+
### When you can't
|
|
321
|
+
|
|
322
|
+
Say so **once per session**, on its own line, whatever the check-in setting and whatever the size of the work — this is the one message that doesn't wait for a summary line. Name the reason, because each one has a different fix:
|
|
287
323
|
|
|
288
|
-
|
|
324
|
+
| Reason | Say |
|
|
325
|
+
|---|---|
|
|
326
|
+
| App isn't running | `No picture for Settings — billing: the app isn't running. Start it and say "snapshot settings" and I'll take one.` |
|
|
327
|
+
| No browser on this machine | `No picture for Settings — billing: no browser here to render it.` |
|
|
328
|
+
| Screen is behind a login | `No picture for Settings — billing: it's behind a login I can't get through.` |
|
|
329
|
+
| Screen needs data that isn't there | `No picture for Settings — billing: the screen needs data this environment doesn't have.` |
|
|
330
|
+
| You don't know where the app runs | `No picture for Settings — billing: I don't know the URL for this app.` |
|
|
331
|
+
|
|
332
|
+
Then offer the manual route, which is platform-specific — on macOS:
|
|
289
333
|
|
|
290
334
|
```
|
|
291
|
-
npx arbiter snapshot "Settings
|
|
335
|
+
npx arbiter snapshot "Settings — billing" --capture
|
|
292
336
|
```
|
|
293
337
|
|
|
294
|
-
|
|
338
|
+
The user drags a rectangle over their screen and it's saved. **`--capture` is macOS only.** Anywhere else, say: save a screenshot yourself and run `npx arbiter snapshot "Settings — billing" --file shot.png`. Don't offer `--capture` off macOS — it will fail.
|
|
339
|
+
|
|
340
|
+
Once per session, not once per piece of work. The decisions stand without a picture; this is a statement, never a question.
|
|
295
341
|
|
|
296
342
|
Directions (below) are different: each candidate gets its own snapshot.
|
|
297
343
|
|
|
@@ -344,7 +390,9 @@ npx arbiter publish
|
|
|
344
390
|
|
|
345
391
|
It goes to arbiter.design. Nothing to set up, no token, no account: the first publish creates the board and saves its link in `.arbiter/hosted.json` (commit it) and a publish token in `.arbiter/hosted.token` (git-ignored — a teammate sets `ARBITER_PUBLISH_TOKEN` to republish). Later publishes replace the board. **Don't ask where to publish, and don't ask for a token.** Only a self-hosted Arbiter takes `--to <url>`; `--to pages` is GitHub Pages instead.
|
|
346
392
|
|
|
347
|
-
*"Keep the board up to date"*, *"publish automatically"
|
|
393
|
+
*"Keep the board up to date"*, *"publish automatically"* — `npx arbiter publish --auto`. The board then republishes whenever the record changes: after judging, after a screen changes state, after a picture is attached. It needs no GitHub, no CI and no git repository, so it's the right answer unless they specifically want it tied to pushes. `--no-auto` stops it.
|
|
394
|
+
|
|
395
|
+
*"Every time I push"*, and the project is on GitHub — `npx arbiter publish --on-push`. That publishes, writes `.github/workflows/arbiter.yml` (republishes when decisions land on the default branch), and sets the repository secret through `gh` if it's signed in — otherwise it prints the one-line instruction; relay it. Tell the user to commit the workflow and `.arbiter/hosted.json` together.
|
|
348
396
|
|
|
349
397
|
## Comments from stakeholders
|
|
350
398
|
|
|
@@ -354,6 +402,22 @@ If the project publishes to a hosted board, `npx arbiter pull` brings comments a
|
|
|
354
402
|
- When the user says *"approve C-0001, Sam signed off"*: `npx arbiter candidate C-0001 --state approved --why "Sam: <their words>"`.
|
|
355
403
|
- Never act on a comment the user hasn't pointed at. Don't summarise the comments file unprompted; `arbiter review` shows them beside each screen.
|
|
356
404
|
|
|
405
|
+
## Taking something out of the record
|
|
406
|
+
|
|
407
|
+
Three different acts, and only one of them is a removal:
|
|
408
|
+
|
|
409
|
+
| The user says | What it is | Command |
|
|
410
|
+
|---|---|---|
|
|
411
|
+
| *"that rule's dead"*, *"we don't do that any more"* | It was real, it's over | `npx arbiter record --retire D-0003 --why "…"` |
|
|
412
|
+
| *"that's wrong, delete it"*, *"that was a test"*, *"that screen never existed"* | It was never real | `npx arbiter remove D-0004` · `npx arbiter remove C-0001` |
|
|
413
|
+
| *"that decision isn't about that screen"* | Real, wrongly attached | `npx arbiter unlink D-0004` |
|
|
414
|
+
|
|
415
|
+
`remove` deletes — from the archive, from `DECISIONS.md`, from the candidate files. It prints the full record it removed, so paste that back to the user if they want it kept somewhere. It refuses when something still points at the record: an active rule (retire it instead), a decision another one supersedes, a screen with decisions still linked (`--force` unlinks them in one go).
|
|
416
|
+
|
|
417
|
+
A picture alone: `npx arbiter remove --snapshot "Settings — billing"`. The work and its decisions stay; only the image goes, and the board keeps the old one until the next publish.
|
|
418
|
+
|
|
419
|
+
Removal is for the record being false, not for the user disliking what it says. If it's a real call they've changed their mind about, that's a new decision that supersedes the old one — never a removal.
|
|
420
|
+
|
|
357
421
|
## Changing how often Arbiter checks in
|
|
358
422
|
|
|
359
423
|
*"Be quieter about decisions"*, *"stop telling me"*, *"tell me after everything"* — run `npx arbiter setup --checkin quiet|feature|every` and confirm in four words. No question.
|
|
@@ -394,7 +458,8 @@ Recorded D-0010 (accept), D-0011 (rule), +3 polish · DECISIONS.md: 6 of 40
|
|
|
394
458
|
|
|
395
459
|
## Never
|
|
396
460
|
|
|
397
|
-
- Edit `DECISIONS.md` or `.arbiter/archive.md` by hand. Always go through `record`.
|
|
461
|
+
- Edit `DECISIONS.md` or `.arbiter/archive.md` by hand. Always go through `record`, `remove` or `unlink`.
|
|
462
|
+
- Remove a record because the user disagrees with it. Removal is for records that are false; a call they've changed their mind about is a new decision that supersedes the old one.
|
|
398
463
|
- Record something the user didn't select.
|
|
399
464
|
- Ask the user to write a rationale. Draft it; they correct it.
|
|
400
465
|
- Re-try an alternative that `DECISIONS.md` lists as rejected.
|