@babylonjs-toolkit/agent 1.2.2 → 1.2.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 +17 -9
- package/package.json +1 -1
- package/skills/bt-execute/SKILL.md +30 -14
- package/skills/bt-execute/scripts/dashboard.mjs +447 -26
- package/skills/bt-execute/templates/dashboard/dashboard.html +139 -9
- package/skills/bt-execute/templates/dashboard/data-schema.md +24 -15
- package/skills/bt-spec/SKILL.md +2 -0
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Babylon Toolkit Desktop Agent (1.2.
|
|
1
|
+
# Babylon Toolkit Desktop Agent (1.2.4)
|
|
2
2
|
|
|
3
3
|
The desktop agent owns the entire pipeline end to end — frontend and UI design, gameplay code, shaders, generated art and audio, 3D models in headless Blender, whole game levels and prefabs in a terminal-driven Unity Editor, the interactive glTF export, the web build, the dev server, and visual QA by screenshotting both Unity and the running browser.
|
|
4
4
|
|
|
@@ -311,20 +311,28 @@ start without a spec:
|
|
|
311
311
|
`dashboard.html` is a live dashboard for the whole feature. `bt-plan` writes it as a roadmap (every
|
|
312
312
|
phase and task pending, with the time estimate); `bt-execute` updates it **task by task**, not phase
|
|
313
313
|
by phase: a *Now* banner says which task is being worked on and what is happening this minute (the
|
|
314
|
-
dashboard helper rewrites a small live-status file each time a task starts, is built, is being verified
|
|
315
|
-
|
|
314
|
+
dashboard helper rewrites a small live-status file each time a task starts, is built, is being verified,
|
|
315
|
+
fails into a fix round or is done, and each time a snapshot is added; between those the agents write it
|
|
316
|
+
before anything slow, never 15 minutes apart, and a background watchdog writes a heartbeat naming the
|
|
317
|
+
latest file that changed after 10 quiet minutes), and each task's result appears the moment it is built. An open tab keeps itself current: it
|
|
316
318
|
re-reads its data in the background (every 10 s during a run, every 30 s otherwise) and refreshes
|
|
317
319
|
only when something changed — a task result, a finished run, the next run starting, or a plan
|
|
318
320
|
reopened because you added a task after it was complete (the dashboard drops back to *paused* and
|
|
319
321
|
the After Action Report is revised when the new work is done). A `check` at every phase boundary and
|
|
320
322
|
at run end fails if anything was skipped — a plan without its dashboard, tasks that differ from the plan,
|
|
321
|
-
a *complete* that is not, a visual task with no snapshot,
|
|
323
|
+
a *complete* that is not, a visual task with no snapshot, frames saved to `snapshots/` that never reached
|
|
324
|
+
the page, a ticked task with no verifier result. Phase by
|
|
322
325
|
phase and task by task it shows what was actually done, files, tests, verifier verdicts, attempts,
|
|
323
|
-
decisions, deferrals and follow-ups.
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
326
|
+
decisions, deferrals and follow-ups. Follow-ups are numbered `F1`, `F2` … and each comes with a
|
|
327
|
+
`/bt-spec Fix F1 from @…/documents/<slug>_followups.md` command to copy (tick several to spec them together),
|
|
328
|
+
the same way bt-profile hands its fixes to bt-spec. The snapshots tell the story of the build, taken from the captures
|
|
329
|
+
the work already makes (never an extra session just for a picture): a plan-wide "before" ahead of T1;
|
|
330
|
+
for every visual task a **progression** from the same camera as each meaningful layer lands (a terrain:
|
|
331
|
+
heightmap → textures → roads → trees → foliage → lighting) — the builder's before, milestone and built
|
|
332
|
+
frames, then the verifier's verified frames — played back as a storyboard, plus before/after sliders and
|
|
333
|
+
stills where those prove the point, and one plan-wide before/after in the After Action Report. They reach
|
|
334
|
+
the page while the task is being built: the helper refuses to mark a task built while a frame saved for it
|
|
335
|
+
is not on the dashboard, or a visual task built with no frame at all. When later work
|
|
328
336
|
revises an earlier result, the earlier entry is marked **Updated** with who changed it and why —
|
|
329
337
|
nothing is rewritten silently.
|
|
330
338
|
|
package/package.json
CHANGED
|
@@ -25,8 +25,10 @@ Run tasks from a plan: build each with its tests, have an independent verifier c
|
|
|
25
25
|
|
|
26
26
|
- **TIME MATTERS** (default): follow *Work fast*, take the direct route, never re-read. Print `⏱️ [bt-execute] TIME MATTERS` (or `⏱️ [bt-execute] No time limit`) and start every subagent prompt with `TIME MATTERS.` unless it is off. Speed never relaxes tests, the verifier, live checks or "tick only on PASS".
|
|
27
27
|
- **Never commit** — no git commit, stage, stash, reset, checkout, push or branch switch, in any mode. Changes stay in the working tree.
|
|
28
|
+
- **Snapshots tell the story — ENFORCED.** The dashboard's snapshots are the chronicle of how the plan came together, read long after the run; a row of "No snapshot" loses that record for good. Every visual task leaves its progression on the page *as it is built*, through `dashboard.mjs snapshot` only (*Snapshots tell the story*, below). Speed, TIME MATTERS and `--auto-pilot` never thin it.
|
|
28
29
|
- **Scope:** only the selected tasks. Ambiguous, or blocked by an unfinished task → stop and tell the user *(auto-pilot: decide, log it)*.
|
|
29
|
-
- **Open the run first** — before docs, code or pre-flight: take the clock, append `⏱ Run <n> start`, do *Run start
|
|
30
|
+
- **Open the run first** — before docs, code or pre-flight: take the clock, append `⏱ Run <n> start`, do *Run start* and launch the watchdog, so a refreshed dashboard shows the run within a minute.
|
|
31
|
+
- **Never let the dashboard go silent — ENFORCED.** *Current run activity* is how the user knows the run is alive; a "no update for 28 min" while work goes on reads as a hung run. Keep the live file current between status changes and run the watchdog behind it (*The live file*, below).
|
|
30
32
|
- **Read the docs once:** for Babylon work, the Agent Reference (https://raw.githubusercontent.com/babylontoolkit/agent/main/reference.md) once per session plus only the sub-documents the tasks need, searched — the authority on conventions and API. Unreadable → stop and tell the user *(auto-pilot: retry 3×, carry on, log it)*. Read the checklist and the `SPEC.md` parts the tasks touch; re-read after a compaction.
|
|
31
33
|
- **SPEC.md** constrains the build. It disagrees with the code → stop and tell the user *(auto-pilot: decide, fix SPEC.md in that task, log it)*. Changes to architecture, systems, conventions or dependencies leave SPEC.md matching (the plan's `Update SPEC.md` task, or anyway), per its "How to update this spec". **Write the product, never the procedure** — no capture protocols, tool lists, ledgers or gates, which would bind every later feature.
|
|
32
34
|
- **Say what you are doing** in one line at each boundary.
|
|
@@ -47,10 +49,10 @@ Work in **phases**: the plan's `### Phase N` groups, else up to 3 consecutive ta
|
|
|
47
49
|
- **Tracks** (`Track: <letter>`): one builder subagent per track, all at once, each given its owned files from the plan's *Tracks and owned files* and the *Parallel rules*. A `Track: integration` task is the closing step you run once the phase's tracks are built. The phase verifier starts when all of it is built; the next phase may build meanwhile unless it depends on this one.
|
|
48
50
|
- **No tracks:** one builder subagent per phase, tasks in order, kept for its fix loop.
|
|
49
51
|
|
|
50
|
-
1. **Build** to the Agent Reference's **Coding Practices — ENFORCED** (clean code in the project's language, full-word names, maintainable structure; JSDoc always, never a fail reason) and, for HUDs and overlays, **Game UI Performance — ENFORCED** (per-frame values through refs and one frame loop, never React state, props, a store or per-frame EventBus messages). Write the tests `Tests:` names (else meaningful Acceptance and edge cases) in the feature folder's `tests/`, in the repo's runner and style; get them green — fix the code, not the test, unless the test is wrong; nothing testable → say so.
|
|
52
|
+
1. **Build** to the Agent Reference's **Coding Practices — ENFORCED** (clean code in the project's language, full-word names, maintainable structure; JSDoc always, never a fail reason) and, for HUDs and overlays, **Game UI Performance — ENFORCED** (per-frame values through refs and one frame loop, never React state, props, a store or per-frame EventBus messages). Write the tests `Tests:` names (else meaningful Acceptance and edge cases) in the feature folder's `tests/`, in the repo's runner and style; get them green — fix the code, not the test, unless the test is wrong; nothing testable → say so. A visual task **saves its progression as it builds** (*Snapshots tell the story*): a "before" frame before its first change, a frame each time a meaningful layer lands, and its built frame, kept from the captures it takes to iterate, from the same camera, and added with `dashboard.mjs snapshot` **before** its `built` write. It checks its own work with **one quick look** (a capture at one viewport, or a scripted probe) and never runs the Acceptance's live proof; that is the verifier's.
|
|
51
53
|
2. **Verify** with an **independent verifier** subagent (charter below) given the changed files — one per phase (`--strict`: per task), the only live checker, returning PASS/FAIL per task with evidence.
|
|
52
54
|
3. **Tick** each passed task `- [x]` at once, unless it depends on one that failed this phase. Never tick partial, skipped or unverified work.
|
|
53
|
-
4. **Fix loop:** the task's builder fixes it and re-runs its tests; then **resume the same verifier** (`SendMessage` or equivalent) with only the failed items and the fix — never a fresh verifier (`--strict`: a fresh adversarial verifier re-checks the whole task). Records-only slips (a stale number or note) you fix and re-check. 3 attempts (`--strict`: 5), each changing something material; stop early when two fail alike with no new idea. Still failing → unticked; stop and report *(auto-pilot: defer, continue)*.
|
|
55
|
+
4. **Fix loop:** write the FAIL first (`task <feature-folder> T<n> --set '{"status":"in-progress","attempts":<n>}'`), so the dashboard shows the fix round instead of a task stuck at `verifying`; the task's builder fixes it and re-runs its tests; then **resume the same verifier** (`SendMessage` or equivalent) with only the failed items and the fix — never a fresh verifier (`--strict`: a fresh adversarial verifier re-checks the whole task). Records-only slips (a stale number or note) you fix and re-check. 3 attempts (`--strict`: 5), each changing something material; stop early when two fail alike with no new idea. Still failing → unticked; stop and report *(auto-pilot: defer, continue)*.
|
|
54
56
|
5. **Report:** tasks done (range, completed/total, plan finished?), files changed, tests (`tests: 4 passed (builder) · verifier-checked`), `verified (independent subagent)` or `verified (self)`, the dashboard path, the plan summary path if written, the next task id.
|
|
55
57
|
|
|
56
58
|
### Parallel rules — in every track builder's brief
|
|
@@ -62,11 +64,11 @@ Work in **phases**: the plan's `### Phase N` groups, else up to 3 consecutive ta
|
|
|
62
64
|
|
|
63
65
|
### The verifier's charter
|
|
64
66
|
|
|
65
|
-
*"Confirm each task's Acceptance is met and run its `Verify` commands against their expected output. Re-run the tests and the relevant suite once; tests that miss the Acceptance or named edge cases, or could not fail, are a FAIL. Read the diff for real defects: logic errors, broken callers, unhandled named edge cases, documented behavior dropped or inverted, a sibling-skill template re-implemented instead of copied. FAIL a touched code file that breaks Coding Practices — ENFORCED: not in the project's language; needless `any`; one- or two-letter names, cryptic abbreviations or code-golf tricks (loop counters, axis/`uv` names, toolkit aliases and exported-data names excepted); dead code, unused imports, leftover `console.log`; structure a newcomer cannot maintain. FAIL a HUD, overlay or GUI file that breaks Game UI Performance — ENFORCED: a per-frame value (speed, needles, timers, bars) through React state, props, context, a store or a per-frame EventBus post; a setter, `dispatch(` or `EventBus.PostMessage(` inside `requestAnimationFrame`, a frame-loop hook, a render observable or `update()`; `width` / `height` / `top` / `left` / `innerHTML` / SVG geometry written, or layout read, per frame; a Babylon GUI control assigned every frame without a changed-value check; a frame loop on a menu, pause or results screen, splash, preloader or landing page, or doing what CSS could (a 3D or scroll-scrubbed hero that pauses off-screen is fine); a HUD loop writing while hidden or paused; a CSS `transition` on a property the loop writes. Quote the lines. JSDoc is never a FAIL — list gaps under non-blocking `JSDoc notes`. You are the only live checker: check live (browser through `bt-cdp.mjs`, Unity where relevant) every task whose correctness shows only at runtime — rendering, UI, interaction, Unity↔Babylon parity — and the plan's final end-to-end check, judging the running result as a user would, beside any reference image; unit tests never substitute. One session per phase on the running dev server, exporting only as *Work fast* allows.
|
|
67
|
+
*"Confirm each task's Acceptance is met and run its `Verify` commands against their expected output. Re-run the tests and the relevant suite once; tests that miss the Acceptance or named edge cases, or could not fail, are a FAIL. Read the diff for real defects: logic errors, broken callers, unhandled named edge cases, documented behavior dropped or inverted, a sibling-skill template re-implemented instead of copied. FAIL a touched code file that breaks Coding Practices — ENFORCED: not in the project's language; needless `any`; one- or two-letter names, cryptic abbreviations or code-golf tricks (loop counters, axis/`uv` names, toolkit aliases and exported-data names excepted); dead code, unused imports, leftover `console.log`; structure a newcomer cannot maintain. FAIL a HUD, overlay or GUI file that breaks Game UI Performance — ENFORCED: a per-frame value (speed, needles, timers, bars) through React state, props, context, a store or a per-frame EventBus post; a setter, `dispatch(` or `EventBus.PostMessage(` inside `requestAnimationFrame`, a frame-loop hook, a render observable or `update()`; `width` / `height` / `top` / `left` / `innerHTML` / SVG geometry written, or layout read, per frame; a Babylon GUI control assigned every frame without a changed-value check; a frame loop on a menu, pause or results screen, splash, preloader or landing page, or doing what CSS could (a 3D or scroll-scrubbed hero that pauses off-screen is fine); a HUD loop writing while hidden or paused; a CSS `transition` on a property the loop writes. Quote the lines. JSDoc is never a FAIL — list gaps under non-blocking `JSDoc notes`. You are the only live checker: check live (browser through `bt-cdp.mjs`, Unity where relevant) every task whose correctness shows only at runtime — rendering, UI, interaction, Unity↔Babylon parity — and the plan's final end-to-end check, judging the running result as a user would, beside any reference image; unit tests never substitute. One session per phase on the running dev server, exporting only as *Work fast* allows. Save the frames from that session that show each visual task's verified result to `[SNAPSHOTS]` as `T<n>-<NN>-<stage>.png`: the same camera or viewport as the builder's progression, plus any angle or comparison (Unity beside browser, before beside after, running beside reference) that proves the Acceptance. Add each to its task with `dashboard.mjs snapshot` and return each path with its one-line caption. Snapshots never add a page session or an export of their own, but inside your session a capture costs seconds, so take it. Set each task `verifying` as you start it, and write the live file (`dashboard.mjs live`) before each slow step — an export, a capture pass across tracks or scenes, a long test run — so it is never 15 minutes silent. A test count in the plan means 'named tests pass, no new failures'. Resumed after a fix, re-check only the failed items and what the fix touched. [SCOPE] Return PASS/FAIL per task with evidence, one line on what you ran live and where (or `none — tests only`), and records-only slips separately."*
|
|
66
68
|
|
|
67
|
-
`[SCOPE]` — **standard:** *"Do not add mutation testing, fuzzing, restarts or audits of untouched files unless something you found points there; aim for about 25 tool calls and report rather than expand."* **`--strict`:** *"Be adversarial: actively look for any reason the Acceptance is NOT met — mutation checks against the tests, randomized inputs, re-deriving values from the plan's Decisions and Design Reference, live QA of every rendered or exported surface."* For a task built on a sibling skill (e.g. bt-design's 3D-Hero-Scroll), give the verifier its relevant part — its documented options are Acceptance.
|
|
69
|
+
`[SNAPSHOTS]` is the feature folder's `snapshots/` path. `[SCOPE]` — **standard:** *"Do not add mutation testing, fuzzing, restarts or audits of untouched files unless something you found points there; aim for about 25 tool calls and report rather than expand."* **`--strict`:** *"Be adversarial: actively look for any reason the Acceptance is NOT met — mutation checks against the tests, randomized inputs, re-deriving values from the plan's Decisions and Design Reference, live QA of every rendered or exported surface."* For a task built on a sibling skill (e.g. bt-design's 3D-Hero-Scroll), give the verifier its relevant part — its documented options are Acceptance.
|
|
68
70
|
|
|
69
|
-
**Every subagent gets a brief, not homework:** its task blocks with the Decisions / Design Reference entries they cite, the SPEC.md parts touched, the Reference excerpts needed with links (**always the full Coding Practices — ENFORCED**), its owned files (track builders: plus the *Parallel rules*), the test command, the `wait.mjs` and `bt-cdp.mjs` paths, its exact `dashboard.mjs` lines with the folder filled in (`task`, `snapshot`; `--verbose`: its `details` fields), the project's agent instructions, *Work fast*, and: *"Do not read the Agent Reference or SPEC.md in full — the parts you need are here, and this overrides any standing instruction to read it first. Read one sub-document (search it, never the whole file) only if you hit an API this brief does not cover, and say which."*
|
|
71
|
+
**Every subagent gets a brief, not homework:** its task blocks with the Decisions / Design Reference entries they cite, the SPEC.md parts touched, the Reference excerpts needed with links (**always the full Coding Practices — ENFORCED**), its owned files (track builders: plus the *Parallel rules*), the test command, the `wait.mjs` and `bt-cdp.mjs` paths, its exact `dashboard.mjs` lines with the folder filled in (`task`, `snapshot`, `live`; `--verbose`: its `details` fields), **builders and verifiers: the whole *Snapshots tell the story* section and the *live file* rule**, the project's agent instructions, *Work fast*, and: *"Do not read the Agent Reference or SPEC.md in full — the parts you need are here, and this overrides any standing instruction to read it first. Read one sub-document (search it, never the whole file) only if you hit an API this brief does not cover, and say which."*
|
|
70
72
|
|
|
71
73
|
## Feature folder and dashboard
|
|
72
74
|
|
|
@@ -79,6 +81,7 @@ Work in **phases**: the plan's `### Phase N` groups, else up to 3 consecutive ta
|
|
|
79
81
|
documents/<slug>_dashboard.js the dashboard's data
|
|
80
82
|
documents/<slug>_live.js what is happening now (written by the helper)
|
|
81
83
|
documents/<slug>_summary.html the plain-language summary, once complete (+ _summary.js)
|
|
84
|
+
documents/<slug>_followups.md the follow-ups in full, for bt-spec (written by the helper)
|
|
82
85
|
snapshots/ tests/ recon/
|
|
83
86
|
```
|
|
84
87
|
|
|
@@ -86,17 +89,30 @@ Work in **phases**: the plan's `### Phase N` groups, else up to 3 consecutive ta
|
|
|
86
89
|
|
|
87
90
|
The page, starter data and live file come from `templates/dashboard/` *(skills loaded through a tool: `load_skill` + `read_skill_resource`; as files: this skill's folder)*; `dashboard.html` is copied with `{{slug}}` replaced, never edited. **`data-schema.md` documents every field, status and snapshot shape — read it once per run; brief each role on its parts.** bt-plan writes all three; create any that is missing. **Every write goes through `scripts/dashboard.mjs`** (atomic, shape-checked; options in its header; no Node → `data-schema.md`'s fallback).
|
|
88
91
|
|
|
89
|
-
- **Three writes per task** (`task <feature-folder> T7 --set '{…}'`): `in-progress` at start (you, launching its builder, or a builder starting its next task); `built` by the builder once green
|
|
90
|
-
- **The
|
|
91
|
-
- **
|
|
92
|
-
-
|
|
92
|
+
- **Three writes per task** (`task <feature-folder> T7 --set '{…}'`): `in-progress` at start (you, launching its builder, or a builder starting its next task); `built` by the builder once green **and its frames are on the dashboard**, with `summary` (what was done, anything surprising), `files`, `tests`; `done` by you at the tick, with `verifier`, `attempts`, `doneAt`, `DECISION` lines and `checkedLive` (what ran live and where, or `""`). The verifier adds `verifying`; a FAIL is `in-progress` with `attempts` + 1; a deferral `deferred` with `deferredReason`.
|
|
93
|
+
- **The live file — never 15 minutes silent.** The helper rewrites it on every `task` status change, every `snapshot` and every `status` write. Between those, whoever is working writes it: `live <feature-folder> --task T7 --role implementer|verifier|orchestrator --activity "<one plain sentence on what is happening now>" --step "…"`. Write it at each milestone inside a task, **before anything slow** (a build, an export, a bake, a live session, a test run), at each fix attempt, and as the verifier moves to each task, track or scene. Never let it go 15 minutes without a write during active work; the page flags a 20-minute silence.
|
|
94
|
+
- **The watchdog is the safety net, never the substitute.** At run start, launch `node <skills>/bt-execute/scripts/dashboard.mjs watch <feature-folder> --watch <the project's source folder> --watch <your scratch folder>` in the background, adding `--watch` for any other folder the work writes (exports, logs, captures). After 10 quiet minutes it writes a heartbeat naming the latest file that changed ("still working — latest activity: snapshots/T2-03-fix.png at 16:42"). After 30 with no file change either, it says the run may be stalled. It exits by itself once the status is no longer `in-progress` (or after 12 hours). A host that cannot run a background process skips it and keeps the live writes tighter.
|
|
95
|
+
- **Snapshots are the chronicle — ENFORCED**, added only with `snapshot <feature-folder> <T<n>|P<N>|plan> --src snapshots/… --caption "…"` (`--before … --after …`: comparison; `--frame "src|stage|caption"` repeated: progression; target `comparison` with `--before`/`--after`: the plan-wide before/after), never snapshot JSON. Who takes which frames, and when: *Snapshots tell the story*, below.
|
|
96
|
+
- **`check <feature-folder>` is the gate** at every phase boundary and run end; nothing closes while it fails. It catches snapshots that cannot show and skipped deliverables: a missing page or data file, tasks unlike the plan's checklist, a false or summary-less `complete`, a visual task `done` without a snapshot, frames left in `snapshots/` that no entry shows, a ticked task without a verifier result.
|
|
93
97
|
- **A record, never a gate on a task.** Never silently rewrite an earlier result: change it and add `{ at, by: "T<n>", note }` to its `updates` (`--note "…" --by T<n>`), badged **Updated**; superseded snapshots stay.
|
|
94
98
|
|
|
99
|
+
### Snapshots tell the story — ENFORCED
|
|
100
|
+
|
|
101
|
+
The snapshots are how a human sees what was built and how it came together. Choose them for meaning, not coverage, and never just one before and one after per task: show **the story of the build**.
|
|
102
|
+
|
|
103
|
+
- **Progressions first.** For a task with visible output, capture a frame each time a meaningful layer of the work lands, from the **same camera or viewport** every time so the frames line up, and caption each with what that stage added. A terrain: heightmap → splat textures → road network → trees → foliage → baked lighting. A UI: layout → styling → states → motion. A shader: base colour → each lighting term → final. A level: blockout → props → lighting → post. A fix: the fault → the fix. A progression can span several tasks; record it on the phase (`P<N>`), each frame's `task` set.
|
|
104
|
+
- **Then whatever proves the point.** A comparison when a change is best seen side by side (a fix, the state before the phase, Unity beside the browser for parity); a second angle when one view hides it (overview, ground level, close detail); a still when one image proves one thing.
|
|
105
|
+
- **As many frames as the build has meaningful stages:** usually 3–8 for a visual task, none for a task with nothing to see. No near-duplicates and no frame per iteration; a failed attempt only when it explains a decision (say so in the caption).
|
|
106
|
+
- **Who takes them.** *You:* before T1 of the first run changes anything, the **plan-wide "before"** (`snapshots/plan-before.png`) from the camera or viewport that will best show the finished feature. That is the starting state, even if it is an empty scene or the old page; skip it only when the plan has nothing to see. At run end, the plan-wide "after" from the same camera. *The builder:* a "before" frame before the first change of a visual task, milestone frames as each layer lands, and its built frame. It is already capturing to iterate, so it keeps the meaningful frames instead of discarding them, and adds them **before** its `built` write. *The verifier:* the verified frames from its live session. *You* pick, order and caption them into the phase's progression, and add any frame a subagent returned without adding.
|
|
107
|
+
- **Cheap, never extra.** Frames come from the sessions and exports the work already runs, never an extra page session or re-export just for a picture. Inside a session that is open anyway, a capture costs seconds: take it.
|
|
108
|
+
- **The helper holds the line.** `snapshots/` holds only frames worth showing; iteration captures go to scratch. A task cannot move to `built`, `verifying` or `done` while a `snapshots/T<n>-…` frame of its own is on no dashboard entry. A visual task (kind `live`, `game` or `unity`) cannot be `built` with no snapshot at all; `--no-frame "<why>"` is only for a task that truly has nothing to show yet, and the reason lands in the activity log. `check` also fails on a closed phase's unshown `P<N>-…` frames and, once a run has ended, on a `plan-before` the After Action Report does not use. A refusal is fixed by adding the frames, never by moving or deleting them.
|
|
109
|
+
- **Files.** `snapshots/T<n>-<NN>-<stage>.png` (phase-level `P<N>-<NN>-<stage>.png`; plan-wide `plan-before` / `plan-after`), at most about 1600 px wide; JPEG or WebP for large scenes. Unity frames come through the bridge's camera capture, browser frames through `bt-cdp.mjs`. Every frame reaches the page only through `dashboard.mjs snapshot`; a subagent that cannot run it returns paths and captions for you to add.
|
|
110
|
+
|
|
95
111
|
### Run start, phases, run end
|
|
96
112
|
|
|
97
|
-
- **Run start:** create any missing `.agents/specs/`, `complete/`, `archived/`, `profile/`, `recon/` (each with an empty `.gitkeep`); re-copy `dashboard.html` and an existing `documents/<slug>_summary.html` from their templates; **sync the dashboard with the plan** — add missing phases and tasks in plan order as `pending` with an `updates` note (`Added to the plan after <phase 2 ran / it was complete> — <why>`), remove dropped ones with an `activity` line. Then `status <feature-folder> in-progress`, `runs` + 1, the run-log link, an `activity` line
|
|
98
|
-
- **Each phase, after its ticks:** status, times and minutes (its `⏱` line), verifier result, a 2–3 sentence summary,
|
|
99
|
-
- **Run end — the After Action Report.** Status from **re-reading the checkboxes**: all `- [x]` → `complete`; all ticked or ⏭️ DEFERRED → `incomplete`; else `paused` — never `in-progress`.
|
|
113
|
+
- **Run start:** create any missing `.agents/specs/`, `complete/`, `archived/`, `profile/`, `recon/` (each with an empty `.gitkeep`); re-copy `dashboard.html` and an existing `documents/<slug>_summary.html` from their templates; **sync the dashboard with the plan** — add missing phases and tasks in plan order as `pending` with an `updates` note (`Added to the plan after <phase 2 ran / it was complete> — <why>`), remove dropped ones with an `activity` line. Then `status <feature-folder> in-progress`, `runs` + 1, the run-log link, an `activity` line, and **the watchdog launched in the background**; in git, add `.agents/*/*/documents/*_live.js` to `.gitignore` once. Before T1 of the first run changes anything, save `snapshots/plan-before.png`, the plan-wide "before" (*Snapshots tell the story*).
|
|
114
|
+
- **Each phase, after its ticks:** status, times and minutes (its `⏱` line), verifier result, a 2–3 sentence summary, the phase's progression (its tasks' frames in build order from one camera, `snapshot P<N> --frame …`) when it spans tasks, `decisions`, `activeTime` (all runs: each `⏱ Run <n> end` line's `active` plus this run's), an `activity` line, a "so far" `outcome`, and `check` passing.
|
|
115
|
+
- **Run end — the After Action Report.** Status from **re-reading the checkboxes**: all `- [x]` → `complete`; all ticked or ⏭️ DEFERRED → `incomplete`; else `paused` — never `in-progress`. **Follow-ups:** add each with `followup <feature-folder> --title "<one line>" --detail "…" --source "T<n> <role>" [--file <path>]…` — one per thing a human should look at next (a pre-existing problem the run logged, work outside the plan's scope, a gap no check covered), never a note about what went well. Each carries enough to be specced on its own: what is wrong, the evidence (numbers, where it showed), where to look, what fixing it involves. The helper numbers them `F1`, `F2` …, writes `documents/<slug>_followups.md`, and the dashboard offers a `/bt-spec Fix F<n> from …` command for each, and for any ticked together. A later run revises one with `--id F2 … --note "why"`, never by rewriting it. Then write `afterAction` (fields in `data-schema.md`): headline, body, highlights, **one plan-wide before/after** (`snapshot <feature-folder> comparison --before snapshots/plan-before.png --after snapshots/plan-after.png --caption "…"`), the "after" from the same camera in the final end-to-end session; the key progression in `afterAction.snapshots` if it tells the story best; and every run `afterAction.testing` — each suite the plan touched re-run **once in full** (one `suites` entry each, never summed from tasks), a `summary` and `gaps`. An early end writes it too (*Interim* while `paused`; revised next run with an `updates` entry); finishing a reopened plan rewrites it, notes the change and retakes the "after". Then open `dashboard.html` headless once: every snapshot shows.
|
|
100
116
|
- **Plan summary, only when `complete`:** copy `templates/summary/summary.html` to `documents/<slug>_summary.html` (`{{slug}}` replaced) and write `documents/<slug>_summary.js` per **`summary-guide.md`** and its worked example `summary.template.js` — the plan for people who never see the code, on-screen names in **bold**, real values, no file names, task IDs or test counts. Set `afterAction.planSummary`. A reopened plan keeps its summary until it completes again; then rewrite it, add the date to `stamp` (`Fixed on 2026-10-19; updated on 2026-11-02`) and say in the lead what changed.
|
|
101
117
|
- **`--verbose`** changes what is written, never what is done: `detail: "verbose"`, each task's `details` from whoever has the facts (the builder at `built`, the verifier as it checks, you in fix rounds), and at run end `afterAction.sections` — fields and card order in `data-schema.md`. Later runs never thin it.
|
|
102
118
|
|
|
@@ -106,7 +122,7 @@ The page, starter data and live file come from `templates/dashboard/` *(skills l
|
|
|
106
122
|
- **Export minimally:** only the Unity project under test, the task's scenes, and only when the change alters that export; never widen a plan's export step.
|
|
107
123
|
- **Never sleep** — wait only with `node https://raw.githubusercontent.com/babylontoolkit/agent/main/references/scripts/wait.mjs port|url|file|log|cmd … --timeout <s>`, or run a long command in the foreground with a generous timeout. Drive pages only by importing `https://raw.githubusercontent.com/babylontoolkit/agent/main/references/scripts/bt-cdp.mjs` (its own headless Chrome and DevTools port) — never the user's browser or a harness of your own.
|
|
108
124
|
- **Judge visuals by looking**; numeric gates only when the plan asks.
|
|
109
|
-
- **Keep evidence light:** the project's tools; no one-off tools, ledgers, md5 or environment records, archives or capture trees unless the plan asks.
|
|
125
|
+
- **Keep evidence light:** the project's tools; no one-off tools, ledgers, md5 or environment records, archives or capture trees unless the plan asks. The dashboard's snapshots are the exception: they are the record a human reads, alongside the run log, and are never cut for speed.
|
|
110
126
|
- **Someone else's red is not your task:** another feature's failing test you did not touch is logged as pre-existing.
|
|
111
127
|
|
|
112
128
|
## Auto-pilot (`--auto-pilot`)
|
|
@@ -7,10 +7,14 @@
|
|
|
7
7
|
* renamed over the original), so the page can never load a half-written file and no hand edit can break it.
|
|
8
8
|
*
|
|
9
9
|
* node dashboard.mjs live <feature-folder> --task T19 --role implementer --activity "…" [--phase 7] [--step "…"]… [--reset] [--title "…"]
|
|
10
|
-
* node dashboard.mjs task <feature-folder> <task-id> --set '{"status":"built","summary":"…"}' [--note "why an earlier result changed" --by T21]
|
|
10
|
+
* node dashboard.mjs task <feature-folder> <task-id> --set '{"status":"built","summary":"…"}' [--note "why an earlier result changed" --by T21] [--no-frame "why a visual task has no built frame"]
|
|
11
11
|
* node dashboard.mjs snapshot <feature-folder> <T7|P2|plan> --src snapshots/T7-01-stage.png --caption "…" [--title "…"] [--source unity]
|
|
12
12
|
* (comparison: --before snapshots/a.png --after snapshots/b.png [--before-caption …] [--after-caption …];
|
|
13
13
|
* progression: --frame "snapshots/x.png|stage|caption" repeated)
|
|
14
|
+
* node dashboard.mjs snapshot <feature-folder> comparison --before snapshots/plan-before.png --after snapshots/plan-after.png --caption "…"
|
|
15
|
+
* (the After Action Report's one plan-wide before/after — replaces the previous one)
|
|
16
|
+
* node dashboard.mjs followup <feature-folder> --title "…" --detail "…" [--source "T2 verifier"] [--file path]…
|
|
17
|
+
* (revise one: --id F2 [--title …] [--detail …] [--file …] --note "why it changed" [--by T4])
|
|
14
18
|
* node dashboard.mjs activity <feature-folder> "Phase 2 verified — T4–T6 PASS"
|
|
15
19
|
* node dashboard.mjs status <feature-folder> in-progress|paused|complete|incomplete
|
|
16
20
|
* node dashboard.mjs check <feature-folder>
|
|
@@ -18,25 +22,38 @@
|
|
|
18
22
|
*
|
|
19
23
|
* <feature-folder> is .agents/specs/<slug>. Timestamps come from this machine's local clock.
|
|
20
24
|
*
|
|
21
|
-
* The live file (`documents/<slug>_live.js`) is
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* records the run starting or ending. A `--set` without `status` leaves it untouched.
|
|
25
|
-
* write
|
|
25
|
+
* The live file (`documents/<slug>_live.js`) is how the page shows the run is alive. Every `task --set` that changes a
|
|
26
|
+
* task's `status` rewrites it from that change (the task, its phase, the role its status implies, one sentence on its
|
|
27
|
+
* new state plus the summary's first sentence, and a step in its log), every `snapshot` adds a step, and every
|
|
28
|
+
* `status` write records the run starting or ending. A `--set` without `status` leaves it untouched. Between those,
|
|
29
|
+
* agents write `live` at each meaningful step (before anything slow, at each fix attempt), and `watch` — the
|
|
30
|
+
* watchdog bt-execute launches in the background at run start — writes a heartbeat after 10 quiet minutes.
|
|
26
31
|
*
|
|
27
32
|
* Snapshots go in only through `snapshot`. `task --set` and `check` refuse any snapshot entry the page cannot show —
|
|
28
33
|
* an image under `path` (or `file`, `image`, …) instead of `src`, or a `src` that is not a file under the feature
|
|
29
34
|
* folder — because such an entry renders as "No snapshot".
|
|
30
35
|
*
|
|
36
|
+
* The snapshots are the story of how the plan was built, so frames are never left behind. A `task --set` that moves
|
|
37
|
+
* a task to `built`, `verifying` or `done` is refused while `snapshots/` holds a `<task-id>-…` image no dashboard entry
|
|
38
|
+
* shows — add each with `snapshot` first. Moving a visual task (kind live, game or unity) to `built` with no snapshot
|
|
39
|
+
* at all is refused too, unless `--no-frame "<reason>"` records why it has nothing to show yet.
|
|
40
|
+
*
|
|
41
|
+
* Follow-ups — what a human should look at next — are added with `followup`, which numbers them `F1`, `F2`, … and
|
|
42
|
+
* rewrites `documents/<slug>_followups.md`: each follow-up in full, the document bt-spec reads when the dashboard's
|
|
43
|
+
* `/bt-spec Fix F1 and F3 from @…_followups.md` command is run. A follow-up written as plain text is repaired into
|
|
44
|
+
* one with an id by every write, and `check` rewrites the document.
|
|
45
|
+
*
|
|
31
46
|
* `check` is the gate at every phase boundary and at run end. Beyond the snapshots it fails, listing every problem in
|
|
32
47
|
* one message, when a deliverable was skipped: a `documents/<slug>_plan.md` without `dashboard.html`, the dashboard
|
|
33
48
|
* data or the live file; dashboard tasks that differ from the plan's checklist (ids or order); a `complete` status
|
|
34
49
|
* while the plan has an unticked box or without `documents/<slug>_summary.html`; a visual task (kind live, game or
|
|
35
50
|
* unity) that is `done` with no snapshot of its own or progression frame tagged with its id; a task ticked in the plan
|
|
36
|
-
* whose dashboard entry has no verifier result. With no plan in the folder, the plan checks are skipped.
|
|
51
|
+
* whose dashboard entry has no verifier result. With no plan in the folder, the plan checks are skipped. It also
|
|
52
|
+
* fails on frames left behind in `snapshots/`: a built or finished task's `T<n>-…` images, a closed phase's `P<N>-…`
|
|
53
|
+
* images and — once a run has ended — a `plan-before` image that no dashboard entry shows.
|
|
37
54
|
*/
|
|
38
55
|
import { existsSync, readFileSync, readdirSync, renameSync, statSync, writeFileSync } from 'node:fs';
|
|
39
|
-
import { basename, join, relative } from 'node:path';
|
|
56
|
+
import { basename, join, relative, resolve } from 'node:path';
|
|
40
57
|
|
|
41
58
|
/** How many entries a task's live step log keeps. */
|
|
42
59
|
const MAXIMUM_LIVE_STEPS = 12;
|
|
@@ -44,8 +61,26 @@ const MAXIMUM_LIVE_STEPS = 12;
|
|
|
44
61
|
const LIVE_PREFIX = 'window.FEATURE_LIVE';
|
|
45
62
|
/** Who is working on a task in each status — the live file's `role` after a `task` write; anything else is the orchestrator. */
|
|
46
63
|
const ROLE_FOR_TASK_STATUS = { 'in-progress': 'implementer', built: 'implementer', verifying: 'verifier' };
|
|
64
|
+
/** How the live file names a snapshot target that is not a task or phase id. */
|
|
65
|
+
const SNAPSHOT_OWNER_NAMES = { plan: 'the After Action Report', comparison: 'the plan-wide before/after' };
|
|
47
66
|
/** Task kinds whose result is seen on screen, so a `done` task of this kind must have a snapshot. */
|
|
48
67
|
const VISUAL_TASK_KINDS = new Set(['live', 'game', 'unity']);
|
|
68
|
+
/** Task statuses that mean its builder is finished, so every frame saved for it belongs on the dashboard. */
|
|
69
|
+
const BUILT_TASK_STATUSES = new Set(['built', 'verifying', 'done']);
|
|
70
|
+
/** Phase statuses that mean a phase is closed, so every `P<N>-…` frame saved for it belongs on the dashboard. */
|
|
71
|
+
const CLOSED_PHASE_STATUSES = new Set(['done', 'partial', 'deferred']);
|
|
72
|
+
/** Run statuses that mean a run has ended and written its After Action Report. */
|
|
73
|
+
const RUN_ENDED_STATUSES = new Set(['paused', 'complete', 'incomplete']);
|
|
74
|
+
/** A follow-up id: `F1`, `F12`. */
|
|
75
|
+
const FOLLOW_UP_ID = /^F(\d+)$/;
|
|
76
|
+
/** A follow-up written as plain text that starts with its id: `"F3 — The banner stays up"`. */
|
|
77
|
+
const FOLLOW_UP_TEXT_WITH_ID = /^(F\d+)\s+[—–-]\s+([\s\S]*)$/;
|
|
78
|
+
/** The longest title a follow-up repaired from plain text keeps; the whole text stays in its detail. */
|
|
79
|
+
const MAXIMUM_FOLLOW_UP_TITLE = 100;
|
|
80
|
+
/** Image files a snapshot can show. */
|
|
81
|
+
const SNAPSHOT_IMAGE_FILE = /\.(png|jpe?g|webp|gif|avif)$/i;
|
|
82
|
+
/** The plan-wide "before" frame, saved before T1 of the first run. */
|
|
83
|
+
const PLAN_BEFORE_FILE = /^plan-before\.(png|jpe?g|webp|gif|avif)$/i;
|
|
49
84
|
/** A plan checklist line: `- [ ] **T3.1** — …` or `- [x] T4 …`; captures the tick mark and the task id. */
|
|
50
85
|
const PLAN_CHECKLIST_LINE = /^\s*[-*]\s+\[([ xX])\]\s+(?:\*\*)?(T\d+(?:\.\d+)*)\b/;
|
|
51
86
|
/** Folders the watchdog never descends into when looking for signs of work. */
|
|
@@ -110,6 +145,7 @@ function writeData(path, prefix, data) {
|
|
|
110
145
|
// reads) can never reach the page as "No snapshot", whoever wrote it.
|
|
111
146
|
if (data && Array.isArray(data.phases)) repairSnapshots(data);
|
|
112
147
|
if (data && Array.isArray(data.decisions)) repairDecisions(data);
|
|
148
|
+
if (data && Array.isArray(data.followUps)) repairFollowUps(data);
|
|
113
149
|
const temporaryPath = `${path}.${process.pid}.tmp`;
|
|
114
150
|
writeFileSync(temporaryPath, `${prefix} = ${JSON.stringify(data, null, 2)};\n`, 'utf8');
|
|
115
151
|
renameSync(temporaryPath, path);
|
|
@@ -255,6 +291,32 @@ function writeLiveForTask(folder, phaseNumber, task, summary) {
|
|
|
255
291
|
});
|
|
256
292
|
}
|
|
257
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Records a snapshot just added as a step in the live file, so the page sees the work moving between status changes
|
|
296
|
+
* (frames are added as they are saved). The task, phase and role stay as they were.
|
|
297
|
+
* @param {string} folder The feature folder.
|
|
298
|
+
* @param {string} target The snapshot's target: a task, a phase, `plan` or `comparison`.
|
|
299
|
+
* @param {string} caption The snapshot's caption.
|
|
300
|
+
*/
|
|
301
|
+
function writeLiveForSnapshot(folder, target, caption) {
|
|
302
|
+
const { livePath } = dataPaths(folder);
|
|
303
|
+
const { prefix, data: live } = readLive(livePath);
|
|
304
|
+
const now = localTime();
|
|
305
|
+
const owner = SNAPSHOT_OWNER_NAMES[target] || target;
|
|
306
|
+
const activity = caption ? `Added a snapshot to ${owner} — ${caption}` : `Added a snapshot to ${owner}.`;
|
|
307
|
+
const steps = Array.isArray(live.steps) ? live.steps : [];
|
|
308
|
+
steps.push({ at: now.clock, text: activity });
|
|
309
|
+
writeData(livePath, prefix, {
|
|
310
|
+
...live,
|
|
311
|
+
updatedAt: now.stamp,
|
|
312
|
+
task: live.task || '',
|
|
313
|
+
role: live.role || 'orchestrator',
|
|
314
|
+
activity,
|
|
315
|
+
steps: steps.slice(-MAXIMUM_LIVE_STEPS),
|
|
316
|
+
source: 'agent',
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
|
|
258
320
|
/**
|
|
259
321
|
* Rewrites the live file when the run's status changes: a run starting clears the last run's task and steps; a run
|
|
260
322
|
* ending says so (the page hides the live file once the status is no longer in-progress).
|
|
@@ -306,7 +368,8 @@ function findTask(dashboard, taskId) {
|
|
|
306
368
|
|
|
307
369
|
/**
|
|
308
370
|
* Merges fields into one task, optionally recording why an earlier result changed. A change that sets `status` also
|
|
309
|
-
* rewrites the live file (see `writeLiveForTask`); any other change leaves it as it was.
|
|
371
|
+
* rewrites the live file (see `writeLiveForTask`); any other change leaves it as it was. A move to `built`,
|
|
372
|
+
* `verifying` or `done` is refused while the task's frames are left behind (see `frameHandOffProblem`).
|
|
310
373
|
* @param {string} folder The feature folder.
|
|
311
374
|
* @param {string[]} argumentList The task id and options.
|
|
312
375
|
*/
|
|
@@ -328,16 +391,57 @@ function writeTask(folder, argumentList) {
|
|
|
328
391
|
if (problems.length) throw new Error(snapshotRefusal(problems));
|
|
329
392
|
}
|
|
330
393
|
Object.assign(task, changes);
|
|
394
|
+
const noFrameReason = typeof options['no-frame'] === 'string' ? options['no-frame'] : '';
|
|
395
|
+
const handOffProblem = frameHandOffProblem(folder, data, task, changes.status, noFrameReason);
|
|
396
|
+
if (handOffProblem) throw new Error(handOffProblem);
|
|
331
397
|
const now = localTime();
|
|
332
398
|
if (typeof options.note === 'string') {
|
|
333
399
|
task.updates = Array.isArray(task.updates) ? task.updates : [];
|
|
334
400
|
task.updates.push({ at: now.stamp, by: typeof options.by === 'string' ? options.by : taskId, note: options.note });
|
|
335
401
|
}
|
|
402
|
+
if (noFrameReason && changes.status === 'built') {
|
|
403
|
+
data.activity = Array.isArray(data.activity) ? data.activity : [];
|
|
404
|
+
data.activity.push({ at: now.stamp, text: `${taskId} built with no frame yet — ${noFrameReason}` });
|
|
405
|
+
}
|
|
336
406
|
data.updatedAt = now.stamp;
|
|
337
407
|
writeData(dashboardPath, prefix, data);
|
|
338
408
|
if (typeof changes.status === 'string') writeLiveForTask(folder, phase.number, task, changes.summary);
|
|
339
409
|
}
|
|
340
410
|
|
|
411
|
+
/**
|
|
412
|
+
* Why a status change must wait for the task's frames, or `''` when it may go ahead. The snapshots are the story of
|
|
413
|
+
* the build, so a task never moves past its builder while a frame saved for it (`snapshots/<task-id>-…`) is on no
|
|
414
|
+
* dashboard entry, and a visual task is not `built` until its built frame is on the page — unless the builder gives
|
|
415
|
+
* a reason it has nothing to show yet.
|
|
416
|
+
* @param {string} folder The feature folder.
|
|
417
|
+
* @param {any} dashboard The dashboard data, with the change already merged.
|
|
418
|
+
* @param {any} task The task, with the change already merged.
|
|
419
|
+
* @param {string | undefined} newStatus The status being written, if any.
|
|
420
|
+
* @param {string} noFrameReason The `--no-frame` reason, or `''`.
|
|
421
|
+
* @returns {string} The refusal message, or `''`.
|
|
422
|
+
*/
|
|
423
|
+
function frameHandOffProblem(folder, dashboard, task, newStatus, noFrameReason) {
|
|
424
|
+
if (!BUILT_TASK_STATUSES.has(newStatus)) return '';
|
|
425
|
+
const leftBehind = framesNamedFor(unshownSnapshotFiles(folder, dashboard), task.id);
|
|
426
|
+
if (leftBehind.length) {
|
|
427
|
+
return [
|
|
428
|
+
`refused — ${task.id} cannot be "${newStatus}" while its frames are on disk but not on the dashboard (the snapshots tell the story of the build):`,
|
|
429
|
+
...leftBehind.map((name) => ` snapshots/${name}`),
|
|
430
|
+
'Add them first, then repeat this write — a progression from one camera, or a still each:',
|
|
431
|
+
` node dashboard.mjs snapshot ${folder} ${task.id} --frame "snapshots/${leftBehind[0]}|<stage>|<what this stage added>" … --caption "…"`,
|
|
432
|
+
` node dashboard.mjs snapshot ${folder} ${task.id} --src snapshots/${leftBehind[0]} --caption "…"`,
|
|
433
|
+
].join('\n');
|
|
434
|
+
}
|
|
435
|
+
const isVisual = VISUAL_TASK_KINDS.has(task.kind);
|
|
436
|
+
if (newStatus !== 'built' || !isVisual || noFrameReason || taskIdsWithSnapshots(dashboard).has(task.id)) return '';
|
|
437
|
+
return [
|
|
438
|
+
`refused — ${task.id} (kind ${task.kind}) is visual and has no snapshot, so the dashboard would show nothing of what was built.`,
|
|
439
|
+
`Save its built frame (and the before / milestone frames you took) to snapshots/${task.id}-<NN>-<stage>.png, add them with`,
|
|
440
|
+
` node dashboard.mjs snapshot ${folder} ${task.id} --src snapshots/${task.id}-01-<stage>.png --caption "…"`,
|
|
441
|
+
'then repeat this write. Only when it truly has nothing to show yet, add --no-frame "<why>" to this write.',
|
|
442
|
+
].join('\n');
|
|
443
|
+
}
|
|
444
|
+
|
|
341
445
|
/**
|
|
342
446
|
* Refuses a change that would give a task field the wrong shape (a list replaced by a string, …), which would
|
|
343
447
|
* break the page.
|
|
@@ -428,15 +532,20 @@ function snapshotListFor(dashboard, target) {
|
|
|
428
532
|
/**
|
|
429
533
|
* Appends one snapshot — a still (`--src`), a comparison (`--before` and `--after`) or a progression (`--frame`,
|
|
430
534
|
* repeated, each `src|stage|caption`) — to a task, a phase or the plan, building the shape the page renders and
|
|
431
|
-
* refusing an image that is not on disk.
|
|
535
|
+
* refusing an image that is not on disk. The target `comparison` instead sets the After Action Report's one
|
|
536
|
+
* plan-wide before/after. This is the way to add snapshots: nobody writes snapshot JSON by hand.
|
|
432
537
|
* @param {string} folder The feature folder.
|
|
433
538
|
* @param {string[]} argumentList The target and options.
|
|
434
539
|
*/
|
|
435
540
|
function writeSnapshot(folder, argumentList) {
|
|
436
541
|
const { options, positional } = parseOptions(argumentList, ['frame']);
|
|
437
542
|
const [target] = positional;
|
|
438
|
-
const usage = 'usage: snapshot <feature-folder> <T3|P1|plan> (--src snapshots/x.png | --before snapshots/a.png --after snapshots/b.png | --frame "snapshots/x.png|stage|caption"…) --caption "…" [--title "…"] [--source browser|unity|blender|reference] [--before-caption "…"] [--after-caption "…"] [--task T3]';
|
|
543
|
+
const usage = 'usage: snapshot <feature-folder> <T3|P1|plan|comparison> (--src snapshots/x.png | --before snapshots/a.png --after snapshots/b.png | --frame "snapshots/x.png|stage|caption"…) --caption "…" [--title "…"] [--source browser|unity|blender|reference] [--before-caption "…"] [--after-caption "…"] [--task T3]';
|
|
439
544
|
if (!target) throw new Error(usage);
|
|
545
|
+
const isPlanComparison = target === 'comparison';
|
|
546
|
+
if (isPlanComparison && !(typeof options.before === 'string' && typeof options.after === 'string')) {
|
|
547
|
+
throw new Error('the plan-wide comparison takes --before snapshots/plan-before.png --after snapshots/plan-after.png');
|
|
548
|
+
}
|
|
440
549
|
const caption = typeof options.caption === 'string' ? options.caption : '';
|
|
441
550
|
const snapshot = { title: typeof options.title === 'string' ? options.title : caption, caption, source: typeof options.source === 'string' ? options.source : 'browser' };
|
|
442
551
|
if (typeof options.src === 'string') {
|
|
@@ -458,9 +567,15 @@ function writeSnapshot(folder, argumentList) {
|
|
|
458
567
|
if (problems.length) throw new Error(snapshotRefusal(problems));
|
|
459
568
|
const { dashboardPath } = dataPaths(folder);
|
|
460
569
|
const { prefix, data } = readData(dashboardPath);
|
|
461
|
-
|
|
570
|
+
if (isPlanComparison) {
|
|
571
|
+
data.afterAction = data.afterAction && typeof data.afterAction === 'object' ? data.afterAction : {};
|
|
572
|
+
data.afterAction.comparison = snapshot;
|
|
573
|
+
} else {
|
|
574
|
+
snapshotListFor(data, target).push(snapshot);
|
|
575
|
+
}
|
|
462
576
|
data.updatedAt = localTime().stamp;
|
|
463
577
|
writeData(dashboardPath, prefix, data);
|
|
578
|
+
writeLiveForSnapshot(folder, target, caption);
|
|
464
579
|
}
|
|
465
580
|
|
|
466
581
|
/**
|
|
@@ -565,6 +680,175 @@ function repairDecisions(dashboard) {
|
|
|
565
680
|
return repairs;
|
|
566
681
|
}
|
|
567
682
|
|
|
683
|
+
/**
|
|
684
|
+
* The next free follow-up id: one past the highest `F<n>` in the list, so ids never repeat after one is revised.
|
|
685
|
+
* @param {any[]} followUps The follow-ups so far.
|
|
686
|
+
* @param {Set<string>} [alsoTaken] Ids claimed by entries not yet in the list.
|
|
687
|
+
* @returns {string}
|
|
688
|
+
*/
|
|
689
|
+
function nextFollowUpId(followUps, alsoTaken = new Set()) {
|
|
690
|
+
const taken = [...followUps.map((followUp) => followUp && followUp.id), ...alsoTaken];
|
|
691
|
+
const highest = taken.reduce((maximum, id) => {
|
|
692
|
+
const match = FOLLOW_UP_ID.exec(String(id || ''));
|
|
693
|
+
return match ? Math.max(maximum, Number(match[1])) : maximum;
|
|
694
|
+
}, 0);
|
|
695
|
+
return `F${highest + 1}`;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* A short title from a follow-up written as one block of text: its first sentence, cut at a word near
|
|
700
|
+
* `MAXIMUM_FOLLOW_UP_TITLE` characters when longer. A sentence ends only where the next word starts with a capital,
|
|
701
|
+
* so "the GO! banner" stays whole.
|
|
702
|
+
* @param {string} text The follow-up's text.
|
|
703
|
+
* @returns {string}
|
|
704
|
+
*/
|
|
705
|
+
function followUpTitleFrom(text) {
|
|
706
|
+
const trimmed = String(text || '').trim();
|
|
707
|
+
const sentenceMatch = /^[\s\S]*?[.!?](?=\s+[A-Z]|$)/.exec(trimmed);
|
|
708
|
+
const sentence = sentenceMatch ? sentenceMatch[0] : trimmed;
|
|
709
|
+
if (sentence.length <= MAXIMUM_FOLLOW_UP_TITLE) return sentence;
|
|
710
|
+
const cut = sentence.lastIndexOf(' ', MAXIMUM_FOLLOW_UP_TITLE);
|
|
711
|
+
return `${sentence.slice(0, cut > 0 ? cut : MAXIMUM_FOLLOW_UP_TITLE).replace(/[\s,;:—–-]+$/, '')}…`;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* The ids the follow-ups already carry — an entry's `id`, or the `F3 — ` a plain-text one starts with — so a repair
|
|
716
|
+
* never hands out an id that a later entry in the list already has.
|
|
717
|
+
* @param {any[]} followUps The follow-ups, possibly mixed with plain text.
|
|
718
|
+
* @returns {Set<string>}
|
|
719
|
+
*/
|
|
720
|
+
function claimedFollowUpIds(followUps) {
|
|
721
|
+
const ids = followUps.map((followUp) => {
|
|
722
|
+
if (followUp && typeof followUp === 'object') return followUp.id;
|
|
723
|
+
const match = FOLLOW_UP_TEXT_WITH_ID.exec(String(followUp));
|
|
724
|
+
return match ? match[1] : '';
|
|
725
|
+
});
|
|
726
|
+
return new Set(ids.filter(Boolean));
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Repairs the follow-ups in place, so each has the id the dashboard's bt-spec commands name: a follow-up written as
|
|
731
|
+
* plain text becomes `{ "id": "F3", "title", "detail", … }` (its own `F3 — ` prefix kept as the id, else the next free
|
|
732
|
+
* one), and an entry without an id gets the next free one. Lists and `updates` are made lists.
|
|
733
|
+
* @param {any} dashboard The dashboard data.
|
|
734
|
+
* @returns {string[]} One line per repair made.
|
|
735
|
+
*/
|
|
736
|
+
function repairFollowUps(dashboard) {
|
|
737
|
+
const repairs = [];
|
|
738
|
+
if (!Array.isArray(dashboard.followUps)) return repairs;
|
|
739
|
+
const claimed = claimedFollowUpIds(dashboard.followUps);
|
|
740
|
+
dashboard.followUps = dashboard.followUps.map((followUp, index) => {
|
|
741
|
+
if (typeof followUp === 'string') {
|
|
742
|
+
const match = FOLLOW_UP_TEXT_WITH_ID.exec(followUp);
|
|
743
|
+
const text = match ? match[2] : followUp;
|
|
744
|
+
const id = match ? match[1] : nextFollowUpId([], claimed);
|
|
745
|
+
claimed.add(id);
|
|
746
|
+
const title = followUpTitleFrom(text);
|
|
747
|
+
repairs.push(`followUps[${index}]: plain text → { "id": "${id}", "title", "detail" }`);
|
|
748
|
+
return { id, title, detail: title === text ? '' : text, source: '', files: [], at: '', updates: [] };
|
|
749
|
+
}
|
|
750
|
+
if (!followUp || typeof followUp !== 'object') return followUp;
|
|
751
|
+
if (!followUp.id) {
|
|
752
|
+
followUp.id = nextFollowUpId([], claimed);
|
|
753
|
+
claimed.add(followUp.id);
|
|
754
|
+
repairs.push(`followUps[${index}]: no id → "${followUp.id}"`);
|
|
755
|
+
}
|
|
756
|
+
if (!Array.isArray(followUp.files)) followUp.files = [];
|
|
757
|
+
if (!Array.isArray(followUp.updates)) followUp.updates = [];
|
|
758
|
+
return followUp;
|
|
759
|
+
}).filter((followUp) => followUp && typeof followUp === 'object');
|
|
760
|
+
return repairs;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* This feature's folder as a path from the project root (`.agents/specs/<slug>`, or wherever the user moved it),
|
|
765
|
+
* for the bt-spec commands. The helper runs from the project root, so a folder under it is named as it is.
|
|
766
|
+
* @param {string} folder The feature folder.
|
|
767
|
+
* @returns {string}
|
|
768
|
+
*/
|
|
769
|
+
function featureFolderFromRoot(folder) {
|
|
770
|
+
const fromRoot = relative(process.cwd(), resolve(folder)).split('\\').join('/');
|
|
771
|
+
return fromRoot.startsWith('.agents/') ? fromRoot : `.agents/specs/${dataPaths(folder).slug}`;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Joins follow-up ids the way the bt-spec commands read: `F1`, `F1 and F2`, `F1, F2 and F3`.
|
|
776
|
+
* @param {string[]} ids The ids.
|
|
777
|
+
* @returns {string}
|
|
778
|
+
*/
|
|
779
|
+
function joinFollowUpIds(ids) {
|
|
780
|
+
if (ids.length <= 1) return ids.join('');
|
|
781
|
+
return `${ids.slice(0, -1).join(', ')} and ${ids[ids.length - 1]}`;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* The follow-ups document bt-spec reads: the feature it came from, the commands that spec its follow-ups, and every
|
|
786
|
+
* follow-up in full under its id.
|
|
787
|
+
* @param {string} folder The feature folder.
|
|
788
|
+
* @param {any} dashboard The dashboard data, follow-ups repaired.
|
|
789
|
+
* @returns {string} Markdown.
|
|
790
|
+
*/
|
|
791
|
+
function followUpsDocument(folder, dashboard) {
|
|
792
|
+
const { slug } = dataPaths(folder);
|
|
793
|
+
const featureTitle = (dashboard.feature && dashboard.feature.title) || slug;
|
|
794
|
+
const source = `@${featureFolderFromRoot(folder)}/documents/${slug}_followups.md`;
|
|
795
|
+
const ids = dashboard.followUps.map((followUp) => followUp.id);
|
|
796
|
+
const documents = (Array.isArray(dashboard.documents) ? dashboard.documents : [])
|
|
797
|
+
.filter((document) => document && document.path && !/follow/i.test(document.label || ''))
|
|
798
|
+
.map((document) => `${String(document.label).toLowerCase()} \`${document.path}\``);
|
|
799
|
+
const lines = [
|
|
800
|
+
`# Follow-ups — ${featureTitle}`,
|
|
801
|
+
'',
|
|
802
|
+
`What the bt-execute runs of **${featureTitle}** left for a human to look at next. Spec any of them on its own, or several together, with bt-spec:`,
|
|
803
|
+
'',
|
|
804
|
+
'```',
|
|
805
|
+
`/bt-spec Fix ${ids[0]} from ${source}`,
|
|
806
|
+
...(ids.length > 1 ? [`/bt-spec Fix ${joinFollowUpIds(ids)} from ${source}`] : []),
|
|
807
|
+
'```',
|
|
808
|
+
'',
|
|
809
|
+
`Where they came from: this feature's ${documents.length ? documents.join(', ') : 'plan and run log'} (paths relative to \`${featureFolderFromRoot(folder)}/\`).`,
|
|
810
|
+
'',
|
|
811
|
+
`> Written by bt-execute's dashboard helper from \`${slug}_dashboard.js\`. Add or revise a follow-up with \`dashboard.mjs followup\`, never by editing this file.`,
|
|
812
|
+
];
|
|
813
|
+
for (const followUp of dashboard.followUps) {
|
|
814
|
+
const raised = [followUp.at, followUp.source].filter(Boolean).join(' · ');
|
|
815
|
+
lines.push('', `## ${followUp.id} — ${followUp.title || 'Untitled follow-up'}`, '');
|
|
816
|
+
if (raised) lines.push(`- **Raised:** ${raised}`);
|
|
817
|
+
if (followUp.files.length) lines.push(`- **Files:** ${followUp.files.map((file) => `\`${file}\``).join(', ')}`);
|
|
818
|
+
for (const update of followUp.updates) lines.push(`- **Revised ${update.at || ''}${update.by ? ` by ${update.by}` : ''}:** ${update.note || ''}`);
|
|
819
|
+
if (raised || followUp.files.length || followUp.updates.length) lines.push('');
|
|
820
|
+
lines.push(followUp.detail || followUp.title || '');
|
|
821
|
+
}
|
|
822
|
+
return `${lines.join('\n')}\n`;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* Lists the follow-ups document among the dashboard's documents, once, so the page links it.
|
|
827
|
+
* @param {string} folder The feature folder.
|
|
828
|
+
* @param {any} dashboard The dashboard data.
|
|
829
|
+
* @returns {boolean} Whether the list changed.
|
|
830
|
+
*/
|
|
831
|
+
function linkFollowUpsDocument(folder, dashboard) {
|
|
832
|
+
const path = `documents/${dataPaths(folder).slug}_followups.md`;
|
|
833
|
+
dashboard.documents = Array.isArray(dashboard.documents) ? dashboard.documents : [];
|
|
834
|
+
if (dashboard.documents.some((document) => document && document.path === path)) return false;
|
|
835
|
+
dashboard.documents.push({ label: 'Follow-ups', path });
|
|
836
|
+
return true;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Rewrites the follow-ups document from the dashboard data, atomically; nothing is written while there are none.
|
|
841
|
+
* @param {string} folder The feature folder.
|
|
842
|
+
* @param {any} dashboard The dashboard data, follow-ups repaired.
|
|
843
|
+
*/
|
|
844
|
+
function writeFollowUpsDocument(folder, dashboard) {
|
|
845
|
+
if (!Array.isArray(dashboard.followUps) || !dashboard.followUps.length) return;
|
|
846
|
+
const path = join(folder, 'documents', `${dataPaths(folder).slug}_followups.md`);
|
|
847
|
+
const temporaryPath = `${path}.${process.pid}.tmp`;
|
|
848
|
+
writeFileSync(temporaryPath, followUpsDocument(folder, dashboard), 'utf8');
|
|
849
|
+
renameSync(temporaryPath, path);
|
|
850
|
+
}
|
|
851
|
+
|
|
568
852
|
/**
|
|
569
853
|
* Every snapshot entry in the dashboard with where it sits: the After Action Report, each phase and each task.
|
|
570
854
|
* @param {any} dashboard The dashboard data.
|
|
@@ -585,6 +869,53 @@ function allSnapshots(dashboard) {
|
|
|
585
869
|
return entries;
|
|
586
870
|
}
|
|
587
871
|
|
|
872
|
+
/**
|
|
873
|
+
* The images one snapshot entry shows: a progression's frames, a comparison's two sides, or the still itself.
|
|
874
|
+
* @param {any} snapshot A still, comparison or progression.
|
|
875
|
+
* @returns {any[]} Objects that carry a `src`.
|
|
876
|
+
*/
|
|
877
|
+
function snapshotImages(snapshot) {
|
|
878
|
+
if (!snapshot || typeof snapshot !== 'object') return [];
|
|
879
|
+
if (Array.isArray(snapshot.frames)) return snapshot.frames;
|
|
880
|
+
if (snapshot.before !== undefined || snapshot.after !== undefined) return [snapshot.before, snapshot.after];
|
|
881
|
+
return [snapshot];
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* The images in the feature folder's `snapshots/` that no dashboard entry shows — frames a builder or verifier saved
|
|
886
|
+
* that never reached the page, so the story of the build is missing them.
|
|
887
|
+
* @param {string} folder The feature folder.
|
|
888
|
+
* @param {any} dashboard The dashboard data.
|
|
889
|
+
* @returns {string[]} File names inside `snapshots/`, e.g. `T1-02-lit.png`.
|
|
890
|
+
*/
|
|
891
|
+
function unshownSnapshotFiles(folder, dashboard) {
|
|
892
|
+
const snapshotsFolder = join(folder, 'snapshots');
|
|
893
|
+
if (!existsSync(snapshotsFolder)) return [];
|
|
894
|
+
const shownPaths = new Set(
|
|
895
|
+
allSnapshots(dashboard)
|
|
896
|
+
.flatMap(({ snapshot }) => snapshotImages(snapshot))
|
|
897
|
+
.map((image) => (image && typeof image.src === 'string' ? image.src : ''))
|
|
898
|
+
.filter((source) => source && !/^[a-z]+:/i.test(source))
|
|
899
|
+
.map((source) => resolve(folder, source)),
|
|
900
|
+
);
|
|
901
|
+
return readdirSync(snapshotsFolder)
|
|
902
|
+
.filter((name) => SNAPSHOT_IMAGE_FILE.test(name))
|
|
903
|
+
.filter((name) => !shownPaths.has(resolve(snapshotsFolder, name)))
|
|
904
|
+
.sort();
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* The file names saved for one task or phase: those named `<id>-…` (`T7-02-lit.png`, `P2-01-blockout.png`).
|
|
909
|
+
* `T1-` never matches `T10-…` or `T1.2-…`.
|
|
910
|
+
* @param {string[]} fileNames File names inside `snapshots/`.
|
|
911
|
+
* @param {string} ownerId A task id (`T7`, `T3.1`) or phase id (`P2`).
|
|
912
|
+
* @returns {string[]}
|
|
913
|
+
*/
|
|
914
|
+
function framesNamedFor(fileNames, ownerId) {
|
|
915
|
+
const prefix = `${ownerId}-`.toLowerCase();
|
|
916
|
+
return fileNames.filter((name) => name.toLowerCase().startsWith(prefix));
|
|
917
|
+
}
|
|
918
|
+
|
|
588
919
|
/**
|
|
589
920
|
* Appends one milestone to the activity log.
|
|
590
921
|
* @param {string} folder The feature folder.
|
|
@@ -602,6 +933,49 @@ function writeActivity(folder, argumentList) {
|
|
|
602
933
|
writeData(dashboardPath, prefix, data);
|
|
603
934
|
}
|
|
604
935
|
|
|
936
|
+
/**
|
|
937
|
+
* Adds a follow-up with the next free id (`F1`, `F2`, …), or revises one (`--id F2 … --note "why"`), then rewrites
|
|
938
|
+
* the follow-ups document bt-spec reads. The dashboard offers `/bt-spec Fix F2 from @…_followups.md` for each, so a
|
|
939
|
+
* follow-up carries enough to be specced alone: what is wrong, the evidence, where to look, what fixing it involves.
|
|
940
|
+
* @param {string} folder The feature folder.
|
|
941
|
+
* @param {string[]} argumentList Follow-up options.
|
|
942
|
+
*/
|
|
943
|
+
function writeFollowUp(folder, argumentList) {
|
|
944
|
+
const { options } = parseOptions(argumentList, ['file']);
|
|
945
|
+
const usage = 'usage: followup <feature-folder> --title "…" --detail "…" [--source "T2 verifier"] [--file path]… (revise: --id F2 [--title …] [--detail …] [--file …] --note "why it changed" [--by T4])';
|
|
946
|
+
const { dashboardPath } = dataPaths(folder);
|
|
947
|
+
const { prefix, data } = readData(dashboardPath);
|
|
948
|
+
data.followUps = Array.isArray(data.followUps) ? data.followUps : [];
|
|
949
|
+
repairFollowUps(data);
|
|
950
|
+
const now = localTime();
|
|
951
|
+
const fields = {
|
|
952
|
+
...(typeof options.title === 'string' ? { title: options.title } : {}),
|
|
953
|
+
...(typeof options.detail === 'string' ? { detail: options.detail } : {}),
|
|
954
|
+
...(typeof options.source === 'string' ? { source: options.source } : {}),
|
|
955
|
+
...(options.file.length ? { files: options.file.map(String) } : {}),
|
|
956
|
+
};
|
|
957
|
+
const isRevision = typeof options.id === 'string';
|
|
958
|
+
let followUpId;
|
|
959
|
+
if (isRevision) {
|
|
960
|
+
const followUp = data.followUps.find((candidate) => candidate.id === options.id);
|
|
961
|
+
if (!followUp) throw new Error(`no follow-up "${options.id}" — the dashboard has ${data.followUps.map((candidate) => candidate.id).join(', ') || 'none'}`);
|
|
962
|
+
if (typeof options.note !== 'string') throw new Error('revising a follow-up needs --note "why it changed" — an earlier result is never rewritten silently');
|
|
963
|
+
Object.assign(followUp, fields);
|
|
964
|
+
followUp.updates.push({ at: now.stamp, by: typeof options.by === 'string' ? options.by : followUp.id, note: options.note });
|
|
965
|
+
followUpId = followUp.id;
|
|
966
|
+
} else {
|
|
967
|
+
if (!fields.title || !fields.detail) throw new Error(usage);
|
|
968
|
+
followUpId = nextFollowUpId(data.followUps);
|
|
969
|
+
data.followUps.push({ id: followUpId, title: '', detail: '', source: '', files: [], at: now.stamp, updates: [], ...fields });
|
|
970
|
+
}
|
|
971
|
+
linkFollowUpsDocument(folder, data);
|
|
972
|
+
data.updatedAt = now.stamp;
|
|
973
|
+
writeData(dashboardPath, prefix, data);
|
|
974
|
+
writeFollowUpsDocument(folder, data);
|
|
975
|
+
const followUpsSource = `@${featureFolderFromRoot(folder)}/documents/${dataPaths(folder).slug}_followups.md`;
|
|
976
|
+
console.log(`${isRevision ? 'revised' : 'added'} ${followUpId} — spec it with: /bt-spec Fix ${followUpId} from ${followUpsSource}`);
|
|
977
|
+
}
|
|
978
|
+
|
|
605
979
|
/**
|
|
606
980
|
* Sets the dashboard's run status, and records the run starting or ending in the live file.
|
|
607
981
|
* @param {string} folder The feature folder.
|
|
@@ -703,24 +1077,63 @@ function planProblems(folder, dashboard, planTasks) {
|
|
|
703
1077
|
}
|
|
704
1078
|
|
|
705
1079
|
/**
|
|
706
|
-
*
|
|
707
|
-
*
|
|
1080
|
+
* The ids of tasks that have something on the page: a snapshot of their own, or a phase or After Action Report
|
|
1081
|
+
* progression frame tagged with their id.
|
|
708
1082
|
* @param {any} dashboard The dashboard data.
|
|
709
|
-
* @returns {string
|
|
1083
|
+
* @returns {Set<string>}
|
|
710
1084
|
*/
|
|
711
|
-
function
|
|
1085
|
+
function taskIdsWithSnapshots(dashboard) {
|
|
712
1086
|
const sharedLists = [dashboard.afterAction && dashboard.afterAction.snapshots, ...(dashboard.phases || []).map((phase) => phase.snapshots)];
|
|
713
|
-
const
|
|
1087
|
+
const taskIds = new Set(
|
|
714
1088
|
sharedLists
|
|
715
1089
|
.flatMap((list) => (Array.isArray(list) ? list : []))
|
|
716
1090
|
.flatMap((snapshot) => (snapshot && Array.isArray(snapshot.frames) ? snapshot.frames : []))
|
|
717
1091
|
.map((frame) => frame && frame.task),
|
|
718
1092
|
);
|
|
1093
|
+
for (const task of (dashboard.phases || []).flatMap((phase) => phase.tasks || [])) {
|
|
1094
|
+
if (Array.isArray(task.snapshots) && task.snapshots.length) taskIds.add(task.id);
|
|
1095
|
+
}
|
|
1096
|
+
return taskIds;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
* Visual tasks marked `done` with nothing to show for it: no snapshot of their own and no phase or After Action
|
|
1101
|
+
* Report progression frame tagged with their id.
|
|
1102
|
+
* @param {any} dashboard The dashboard data.
|
|
1103
|
+
* @returns {string[]} One line per task.
|
|
1104
|
+
*/
|
|
1105
|
+
function visualTaskProblems(dashboard) {
|
|
1106
|
+
const taskIds = taskIdsWithSnapshots(dashboard);
|
|
719
1107
|
return (dashboard.phases || [])
|
|
720
1108
|
.flatMap((phase) => phase.tasks || [])
|
|
721
|
-
.filter((task) => task.status === 'done' && VISUAL_TASK_KINDS.has(task.kind))
|
|
722
|
-
.
|
|
723
|
-
|
|
1109
|
+
.filter((task) => task.status === 'done' && VISUAL_TASK_KINDS.has(task.kind) && !taskIds.has(task.id))
|
|
1110
|
+
.map((task) => `${task.id} (kind ${task.kind}) is done with no snapshot — add the builder's frames and the verifier's comparison with \`dashboard.mjs snapshot\``);
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
/**
|
|
1114
|
+
* Frames left behind in `snapshots/`: a built or finished task's `T<n>-…` images, a closed phase's `P<N>-…` images,
|
|
1115
|
+
* and — once a run has ended — a `plan-before` image, that no dashboard entry shows.
|
|
1116
|
+
* @param {string} folder The feature folder.
|
|
1117
|
+
* @param {any} dashboard The dashboard data.
|
|
1118
|
+
* @returns {string[]} One line per task, phase or plan-wide frame.
|
|
1119
|
+
*/
|
|
1120
|
+
function unshownFrameProblems(folder, dashboard) {
|
|
1121
|
+
const unshown = unshownSnapshotFiles(folder, dashboard);
|
|
1122
|
+
if (!unshown.length) return [];
|
|
1123
|
+
const problems = [];
|
|
1124
|
+
const report = (ownerId, names) => {
|
|
1125
|
+
if (names.length) problems.push(`${ownerId} has frames on disk that no dashboard entry shows: ${names.map((name) => `snapshots/${name}`).join(', ')} — add each to ${ownerId} with \`dashboard.mjs snapshot\``);
|
|
1126
|
+
};
|
|
1127
|
+
for (const phase of dashboard.phases || []) {
|
|
1128
|
+
for (const task of (phase.tasks || []).filter((candidate) => BUILT_TASK_STATUSES.has(candidate.status))) report(task.id, framesNamedFor(unshown, task.id));
|
|
1129
|
+
if (CLOSED_PHASE_STATUSES.has(phase.status)) report(`P${phase.number}`, framesNamedFor(unshown, `P${phase.number}`));
|
|
1130
|
+
}
|
|
1131
|
+
if (RUN_ENDED_STATUSES.has(dashboard.status)) {
|
|
1132
|
+
for (const name of unshown.filter((candidate) => PLAN_BEFORE_FILE.test(candidate))) {
|
|
1133
|
+
problems.push(`snapshots/${name} is not in the After Action Report — make it the plan-wide "before": \`dashboard.mjs snapshot <feature-folder> comparison --before snapshots/${name} --after snapshots/plan-after.png --caption "…"\``);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
return problems;
|
|
724
1137
|
}
|
|
725
1138
|
|
|
726
1139
|
/**
|
|
@@ -749,16 +1162,23 @@ function checkData(folder) {
|
|
|
749
1162
|
if (existsSync(livePath)) readData(livePath);
|
|
750
1163
|
const repairs = repairSnapshots(data);
|
|
751
1164
|
const decisionRepairs = repairDecisions(data);
|
|
752
|
-
|
|
1165
|
+
const followUpRepairs = repairFollowUps(data);
|
|
1166
|
+
const hasFollowUps = Array.isArray(data.followUps) && data.followUps.length > 0;
|
|
1167
|
+
const linkedFollowUps = hasFollowUps && linkFollowUpsDocument(folder, data);
|
|
1168
|
+
if (repairs.length || decisionRepairs.length || followUpRepairs.length || linkedFollowUps) writeData(dashboardPath, prefix, data);
|
|
1169
|
+
if (hasFollowUps) writeFollowUpsDocument(folder, data);
|
|
753
1170
|
if (repairs.length) {
|
|
754
1171
|
console.log(`repaired ${repairs.length} snapshot entr${repairs.length === 1 ? 'y' : 'ies'} the page could not show:\n ${repairs.join('\n ')}`);
|
|
755
1172
|
}
|
|
756
1173
|
if (decisionRepairs.length) {
|
|
757
1174
|
console.log(`repaired ${decisionRepairs.length} decision${decisionRepairs.length === 1 ? '' : 's'} written as plain text:\n ${decisionRepairs.join('\n ')}`);
|
|
758
1175
|
}
|
|
1176
|
+
if (followUpRepairs.length) {
|
|
1177
|
+
console.log(`repaired ${followUpRepairs.length} follow-up${followUpRepairs.length === 1 ? '' : 's'} without an id:\n ${followUpRepairs.join('\n ')}`);
|
|
1178
|
+
}
|
|
759
1179
|
const snapshots = allSnapshots(data);
|
|
760
1180
|
const problems = snapshots.flatMap(({ snapshot, where }) => snapshotProblems(folder, snapshot, where));
|
|
761
|
-
const deliverables = [...missing, ...visualTaskProblems(data), ...(planTasks ? planProblems(folder, data, planTasks) : [])];
|
|
1181
|
+
const deliverables = [...missing, ...visualTaskProblems(data), ...unshownFrameProblems(folder, data), ...(planTasks ? planProblems(folder, data, planTasks) : [])];
|
|
762
1182
|
const refusals = [problems.length ? snapshotRefusal(problems) : '', deliverables.length ? deliverableRefusal(deliverables) : ''].filter(Boolean);
|
|
763
1183
|
if (refusals.length) throw new Error(refusals.join('\n'));
|
|
764
1184
|
const planNote = planTasks ? `; the dashboard matches the plan's ${planTasks.length} tasks` : '';
|
|
@@ -812,8 +1232,9 @@ function parseStamp(stamp) {
|
|
|
812
1232
|
}
|
|
813
1233
|
|
|
814
1234
|
/**
|
|
815
|
-
* The watchdog —
|
|
816
|
-
*
|
|
1235
|
+
* The watchdog — bt-execute launches it in the background at run start, as the safety net behind the agents' own
|
|
1236
|
+
* live writes, so the page never shows a long silence while work goes on. While the dashboard says a run is in
|
|
1237
|
+
* progress it checks the live status every interval:
|
|
817
1238
|
* - the live status names a task that is already finished while another task is active → it points the live
|
|
818
1239
|
* status at the active task (the agent working on it has not written yet);
|
|
819
1240
|
* - nothing has been written for `quiet-minutes` → it writes a heartbeat naming the latest file that changed in
|
|
@@ -935,10 +1356,10 @@ function checkLive(dashboard, livePath, roots, projectRoot, quietMinutes, stallM
|
|
|
935
1356
|
console.log(`watchdog ${clock}: ${activity}`);
|
|
936
1357
|
}
|
|
937
1358
|
|
|
938
|
-
const commands = { live: writeLive, task: writeTask, snapshot: writeSnapshot, activity: writeActivity, status: writeStatus, check: checkData, watch };
|
|
1359
|
+
const commands = { live: writeLive, task: writeTask, snapshot: writeSnapshot, followup: writeFollowUp, activity: writeActivity, status: writeStatus, check: checkData, watch };
|
|
939
1360
|
|
|
940
1361
|
if (!commands[command] || !featureFolder) {
|
|
941
|
-
console.error('usage: node dashboard.mjs <live|task|snapshot|activity|status|check|watch> <feature-folder> [options] — see the header of this file');
|
|
1362
|
+
console.error('usage: node dashboard.mjs <live|task|snapshot|followup|activity|status|check|watch> <feature-folder> [options] — see the header of this file');
|
|
942
1363
|
process.exit(2);
|
|
943
1364
|
}
|
|
944
1365
|
try {
|
|
@@ -756,6 +756,15 @@
|
|
|
756
756
|
.row:first-child { border-top: 0; }
|
|
757
757
|
.row-key { font: 600 12.5px/1.6 var(--font-mono); color: var(--accent); overflow-wrap: anywhere; }
|
|
758
758
|
.row-source { margin-top: 4px; color: var(--text-faint); font-size: 12.5px; }
|
|
759
|
+
/* A follow-up: a tick box to spec several together, its id, then its text and its own bt-spec command. */
|
|
760
|
+
.row.follow-up { grid-template-columns: 22px 56px minmax(0, 1fr); gap: 12px; }
|
|
761
|
+
.follow-up-pick { padding-top: 2px; }
|
|
762
|
+
.follow-up-pick input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
|
|
763
|
+
.follow-up-detail { margin-top: 4px; color: var(--text-muted); font-size: 13.5px; }
|
|
764
|
+
.follow-up .run-copy { margin-top: 10px; }
|
|
765
|
+
.follow-up-bar { display: grid; gap: 10px; padding: 16px 22px 18px; border-top: 1px solid var(--line); }
|
|
766
|
+
.follow-up-bar-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: baseline; justify-content: space-between; }
|
|
767
|
+
.follow-up-bar .copy-command:disabled { opacity: 0.45; cursor: default; }
|
|
759
768
|
.timeline { position: relative; margin: 0; padding: 4px 0 4px 26px; list-style: none; }
|
|
760
769
|
.timeline::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
|
|
761
770
|
.timeline li { position: relative; padding: 8px 0; }
|
|
@@ -820,6 +829,9 @@
|
|
|
820
829
|
.task-tags { grid-column: 2 / -1; justify-content: flex-start; }
|
|
821
830
|
.task-body { padding: 0 14px 16px; }
|
|
822
831
|
.row { grid-template-columns: 1fr; gap: 4px; padding: 12px 16px; }
|
|
832
|
+
.row.follow-up { grid-template-columns: 22px minmax(0, 1fr); gap: 4px 10px; }
|
|
833
|
+
.row.follow-up > div:last-child { grid-column: 2; }
|
|
834
|
+
.follow-up-bar { padding: 14px 16px 16px; }
|
|
823
835
|
.after-action { padding: 18px; }
|
|
824
836
|
.after-action-columns { grid-template-columns: 1fr; }
|
|
825
837
|
.route-label { display: none; }
|
|
@@ -874,6 +886,10 @@
|
|
|
874
886
|
{ key: 'noTimeLimit', flag: '--no-time-limit', label: 'No time limit', hint: 'Turns off the default TIME MATTERS mode' },
|
|
875
887
|
];
|
|
876
888
|
const planChoice = { heavy: false, parity: false, noTimeLimit: false, brief: '' };
|
|
889
|
+
// The follow-ups ticked to spec together, kept when the page refreshes; one the page has not shown before arrives ticked.
|
|
890
|
+
const followUpChoice = { selected: new Set(), seen: new Set() };
|
|
891
|
+
/** The longest title a follow-up written as plain text shows; the whole text stays below it — the helper's rule. */
|
|
892
|
+
const MAXIMUM_FOLLOW_UP_TITLE = 100;
|
|
877
893
|
// A verifier result that names a live check: "live two-tab race in headless Chrome", "end-to-end on WebGPU".
|
|
878
894
|
const LIVE_CHECK_WORDS = /\blive\b|chrome|browser|webgl|webgpu|unity editor|play ?mode/i;
|
|
879
895
|
/** Where the Babylon Toolkit Desktop Agent, whose skills generate this dashboard, is published. */
|
|
@@ -1617,20 +1633,60 @@
|
|
|
1617
1633
|
</section>`;
|
|
1618
1634
|
}
|
|
1619
1635
|
|
|
1636
|
+
/**
|
|
1637
|
+
* Deferred tasks (finished by running the plan again), then the follow-ups — each with its own bt-spec command, and
|
|
1638
|
+
* tick boxes to spec several together, like bt-profile's fixes.
|
|
1639
|
+
*/
|
|
1620
1640
|
function renderFollowUps(allTasks) {
|
|
1621
1641
|
const deferredRows = allTasks
|
|
1622
1642
|
.filter((task) => task.status === 'deferred' || task.status === 'failed')
|
|
1623
1643
|
.map((task) => `<div class="row"><div class="row-key">${escapeHtml(task.id || '')}</div><div><strong>${escapeHtml(task.title || '')}</strong>${task.deferredReason ? `<div class="row-source">${formatInline(task.deferredReason)}</div>` : ''}</div></div>`);
|
|
1624
|
-
const
|
|
1625
|
-
|
|
1644
|
+
const followUps = report.followUps || [];
|
|
1645
|
+
const ids = followUps.map((followUp) => followUp.id);
|
|
1646
|
+
for (const id of ids.filter((candidate) => !followUpChoice.seen.has(candidate))) {
|
|
1647
|
+
followUpChoice.seen.add(id);
|
|
1648
|
+
followUpChoice.selected.add(id);
|
|
1649
|
+
}
|
|
1650
|
+
const followUpRows = followUps.map((followUp) => {
|
|
1651
|
+
const raised = [followUp.source, followUp.at].filter(Boolean).join(' · ');
|
|
1652
|
+
const files = followUp.files.length ? `Files: ${followUp.files.map((file) => `\`${file}\``).join(', ')}` : '';
|
|
1653
|
+
const where = [raised && `Raised by ${raised}`, files].filter(Boolean).join(' — ');
|
|
1654
|
+
return `
|
|
1655
|
+
<div class="row follow-up">
|
|
1656
|
+
<label class="follow-up-pick"><input type="checkbox" data-follow-up="${escapeAttribute(followUp.id)}"${followUpChoice.selected.has(followUp.id) ? ' checked' : ''} aria-label="Spec ${escapeAttribute(followUp.id)} together with the others ticked"></label>
|
|
1657
|
+
<div class="row-key">${escapeHtml(followUp.id)}</div>
|
|
1658
|
+
<div>
|
|
1659
|
+
<strong>${formatInline(followUp.title || '')}</strong> ${updatedBadge(followUp.updates)}
|
|
1660
|
+
${followUp.detail ? `<div class="follow-up-detail">${formatInline(followUp.detail)}</div>` : ''}
|
|
1661
|
+
${where ? `<div class="row-source">${formatInline(where)}</div>` : ''}
|
|
1662
|
+
${updateNotes(followUp.updates)}
|
|
1663
|
+
${copyableCommand(followUpSpecCommand([followUp.id]))}
|
|
1664
|
+
</div>
|
|
1665
|
+
</div>`;
|
|
1666
|
+
});
|
|
1667
|
+
const together = ids.length > 1 ? `
|
|
1668
|
+
<div class="follow-up-bar">
|
|
1669
|
+
<div class="follow-up-bar-head"><span class="run-builder-title">Spec the ticked follow ups together</span><button type="button" class="copy-command" data-copy="${escapeAttribute(followUpSpecCommand(ids))}" data-label="Copy all ${ids.length}" title="${escapeAttribute(followUpSpecCommand(ids))}">Copy all ${ids.length}</button></div>
|
|
1670
|
+
${selectedFollowUpsCommand()}
|
|
1671
|
+
</div>` : '';
|
|
1626
1672
|
const rows = deferredRows.concat(followUpRows).join('');
|
|
1673
|
+
const note = followUps.length ? 'What a human should look at next — copy a command to spec any of them with bt-spec' : 'What a human should look at next';
|
|
1627
1674
|
return `
|
|
1628
1675
|
<section id="follow-ups">
|
|
1629
|
-
<div class="section-head"><h2>
|
|
1630
|
-
${rows ? `<div class="card list-card">${rows}</div>` : '<div class="empty">Nothing deferred, nothing outstanding.</div>'}
|
|
1676
|
+
<div class="section-head"><h2>Follow ups</h2><span class="section-note">${note}</span></div>
|
|
1677
|
+
${rows ? `<div class="card list-card">${rows}${together}</div>` : '<div class="empty">Nothing deferred, nothing outstanding.</div>'}
|
|
1631
1678
|
</section>`;
|
|
1632
1679
|
}
|
|
1633
1680
|
|
|
1681
|
+
/** The command for the ticked follow-ups, or a disabled hint when none is ticked; redrawn as the boxes change. */
|
|
1682
|
+
function selectedFollowUpsCommand() {
|
|
1683
|
+
const ids = (report.followUps || []).map((followUp) => followUp.id).filter((id) => followUpChoice.selected.has(id));
|
|
1684
|
+
if (!ids.length) {
|
|
1685
|
+
return '<div class="run-copy" id="selected-follow-ups"><code class="run-command">Tick the follow ups to spec together</code><button type="button" class="copy-command" disabled>Copy</button></div>';
|
|
1686
|
+
}
|
|
1687
|
+
return `<div id="selected-follow-ups">${copyableCommand(followUpSpecCommand(ids))}</div>`;
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1634
1690
|
function renderUpdateLog(allUpdates) {
|
|
1635
1691
|
const rows = allUpdates
|
|
1636
1692
|
.slice()
|
|
@@ -1756,7 +1812,7 @@
|
|
|
1756
1812
|
data.decisions = asList(data.decisions).map(asDecision)
|
|
1757
1813
|
.filter((decision) => decision && typeof decision === 'object')
|
|
1758
1814
|
.map((decision) => Object.assign(decision, { updates: asUpdates(decision.updates) }));
|
|
1759
|
-
data.followUps = asList(data.followUps);
|
|
1815
|
+
data.followUps = asFollowUps(asList(data.followUps));
|
|
1760
1816
|
data.activity = asList(data.activity);
|
|
1761
1817
|
if (data.afterAction && typeof data.afterAction === 'object') {
|
|
1762
1818
|
const afterAction = data.afterAction;
|
|
@@ -1806,6 +1862,42 @@
|
|
|
1806
1862
|
if (typeof value === 'string') return value ? [value] : [];
|
|
1807
1863
|
return asList(value).filter((item) => item !== null && item !== undefined && item !== '');
|
|
1808
1864
|
}
|
|
1865
|
+
|
|
1866
|
+
/**
|
|
1867
|
+
* Follow-ups as objects with the ids the bt-spec commands name. One written as plain text (an older dashboard)
|
|
1868
|
+
* gets its own `F3 — ` prefix as the id, else the next free one, and a short title — the helper's repair, so the
|
|
1869
|
+
* page and `documents/<slug>_followups.md` name the same F-numbers.
|
|
1870
|
+
*/
|
|
1871
|
+
function asFollowUps(list) {
|
|
1872
|
+
const textId = (text) => (/^(F\d+)\s+[—–-]\s+/.exec(text) || [])[1] || '';
|
|
1873
|
+
const claimed = new Set(list.map((item) => (item && typeof item === 'object' ? item.id : textId(String(item)))).filter(Boolean));
|
|
1874
|
+
const nextId = () => {
|
|
1875
|
+
const highest = [...claimed].reduce((maximum, id) => Math.max(maximum, Number((/^F(\d+)$/.exec(id) || [])[1] || 0)), 0);
|
|
1876
|
+
const id = `F${highest + 1}`;
|
|
1877
|
+
claimed.add(id);
|
|
1878
|
+
return id;
|
|
1879
|
+
};
|
|
1880
|
+
return list.map((item) => {
|
|
1881
|
+
if (typeof item === 'string') {
|
|
1882
|
+
const id = textId(item) || nextId();
|
|
1883
|
+
const text = item.replace(/^F\d+\s+[—–-]\s+/, '');
|
|
1884
|
+
const title = followUpTitleFrom(text);
|
|
1885
|
+
return { id, title, detail: title === text ? '' : text, source: '', files: [], updates: [] };
|
|
1886
|
+
}
|
|
1887
|
+
if (!item || typeof item !== 'object') return null;
|
|
1888
|
+
return Object.assign(item, { id: item.id || nextId(), files: asTextList(item.files), updates: asUpdates(item.updates) });
|
|
1889
|
+
}).filter(Boolean);
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
/** A short title from a follow-up written as one block of text: its first sentence, cut at a word when long. */
|
|
1894
|
+
function followUpTitleFrom(text) {
|
|
1895
|
+
const trimmed = String(text || '').trim();
|
|
1896
|
+
const sentenceMatch = /^[\s\S]*?[.!?](?=\s+[A-Z]|$)/.exec(trimmed);
|
|
1897
|
+
const sentence = sentenceMatch ? sentenceMatch[0] : trimmed;
|
|
1898
|
+
if (sentence.length <= MAXIMUM_FOLLOW_UP_TITLE) return sentence;
|
|
1899
|
+
const cut = sentence.lastIndexOf(' ', MAXIMUM_FOLLOW_UP_TITLE);
|
|
1900
|
+
return `${sentence.slice(0, cut > 0 ? cut : MAXIMUM_FOLLOW_UP_TITLE).replace(/[\s,;:—–-]+$/, '')}…`;
|
|
1809
1901
|
}
|
|
1810
1902
|
|
|
1811
1903
|
/* ===================== Updated notifications ===================== */
|
|
@@ -1985,24 +2077,62 @@
|
|
|
1985
2077
|
return runCommand(RUN_OPTIONS.filter((option) => runChoice[option.key]).map((option) => option.flag), runChoice.tasks);
|
|
1986
2078
|
}
|
|
1987
2079
|
|
|
1988
|
-
|
|
1989
|
-
|
|
2080
|
+
/**
|
|
2081
|
+
* This feature's folder from the project root. Read from the page's own address when it sits under `.agents/`,
|
|
2082
|
+
* so a feature the user moved to `complete/` or `archived/` still gets commands that resolve; else the usual
|
|
2083
|
+
* `.agents/specs/<slug>`.
|
|
2084
|
+
*/
|
|
2085
|
+
function featureFolderPath() {
|
|
2086
|
+
const slug = (report.feature && report.feature.slug) || '';
|
|
2087
|
+
const pagePath = decodeURIComponent(window.location.pathname || '');
|
|
2088
|
+
const agentsAt = pagePath.lastIndexOf('/.agents/');
|
|
2089
|
+
const pageName = '/dashboard.html';
|
|
2090
|
+
if (agentsAt >= 0 && pagePath.endsWith(pageName)) return pagePath.slice(agentsAt + 1, pagePath.length - pageName.length);
|
|
2091
|
+
return `.agents/specs/${slug}`;
|
|
2092
|
+
}
|
|
2093
|
+
|
|
2094
|
+
/** The follow-ups document as bt-spec takes it: `@.agents/specs/<slug>/documents/<slug>_followups.md`. */
|
|
2095
|
+
function followUpsReference() {
|
|
2096
|
+
const slug = (report.feature && report.feature.slug) || '';
|
|
2097
|
+
const listed = (report.documents || []).find((document) => /follow/i.test(document.label || '') && document.path);
|
|
2098
|
+
const relativePath = listed ? String(listed.path).replace(/^\.?\//, '') : `documents/${slug}_followups.md`;
|
|
2099
|
+
return `@${featureFolderPath()}/${relativePath}`;
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
/** The bt-spec command for some follow-ups, worded like bt-profile's: `/bt-spec Fix F1, F2 and F4 from @…`. */
|
|
2103
|
+
function followUpSpecCommand(ids) {
|
|
2104
|
+
const joined = ids.length <= 1 ? ids.join('') : `${ids.slice(0, -1).join(', ')} and ${ids[ids.length - 1]}`;
|
|
2105
|
+
return `/bt-spec Fix ${joined} from ${followUpsReference()}`;
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
function copyableCommand(command, id = '', label = 'Copy') {
|
|
2109
|
+
return `<div class="run-copy"><code class="run-command"${id ? ` id="${id}"` : ''}>${escapeHtml(command)}</code><button type="button" class="copy-command" data-copy="${escapeAttribute(command)}" data-label="${escapeAttribute(label)}">${escapeHtml(label)}</button></div>`;
|
|
1990
2110
|
}
|
|
1991
2111
|
|
|
1992
2112
|
/** Copy buttons and the command builder; delegated, so they keep working after the page redraws. */
|
|
1993
2113
|
function wireRunCommands() {
|
|
1994
2114
|
document.addEventListener('click', (event) => {
|
|
1995
2115
|
const button = event.target.closest('.copy-command');
|
|
1996
|
-
if (!button) return;
|
|
2116
|
+
if (!button || button.disabled) return;
|
|
1997
2117
|
const text = button.getAttribute('data-copy') || '';
|
|
2118
|
+
const label = button.getAttribute('data-label') || 'Copy';
|
|
1998
2119
|
const copied = () => {
|
|
1999
2120
|
button.textContent = 'Copied';
|
|
2000
2121
|
button.classList.add('is-copied');
|
|
2001
|
-
setTimeout(() => { button.textContent =
|
|
2122
|
+
setTimeout(() => { button.textContent = label; button.classList.remove('is-copied'); }, 1500);
|
|
2002
2123
|
};
|
|
2003
2124
|
if (navigator.clipboard && navigator.clipboard.writeText) navigator.clipboard.writeText(text).then(copied, () => { copyWithSelection(text); copied(); });
|
|
2004
2125
|
else { copyWithSelection(text); copied(); }
|
|
2005
2126
|
});
|
|
2127
|
+
document.addEventListener('change', (event) => {
|
|
2128
|
+
const box = event.target.closest('[data-follow-up]');
|
|
2129
|
+
if (!box) return;
|
|
2130
|
+
const id = box.getAttribute('data-follow-up');
|
|
2131
|
+
if (box.checked) followUpChoice.selected.add(id);
|
|
2132
|
+
else followUpChoice.selected.delete(id);
|
|
2133
|
+
const output = document.getElementById('selected-follow-ups');
|
|
2134
|
+
if (output) output.outerHTML = selectedFollowUpsCommand();
|
|
2135
|
+
});
|
|
2006
2136
|
const updateBuilt = (event) => {
|
|
2007
2137
|
const control = event.target.closest('[data-run-choice], [data-plan-choice]');
|
|
2008
2138
|
if (!control) return;
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
| File | Holds | Written |
|
|
6
6
|
|---|---|---|
|
|
7
7
|
| `<slug>_dashboard.js` | the feature's record — status, phases, tasks and their results, decisions, snapshots, the After Action Report | bt-spec creates it from `dashboard.template.js` (`specified`), bt-plan fills in the plan (`planned`), bt-execute writes it at every task boundary; a Quick Plan creates it at bt-plan |
|
|
8
|
-
| `<slug>_live.js` | what is happening this minute — the current task, one sentence, its step log | by bt-execute's helper
|
|
8
|
+
| `<slug>_live.js` | what is happening this minute — the current task, one sentence, its step log | by bt-execute's helper: every `dashboard.mjs task` write that changes a task's status, every `snapshot` and every `status` write; between them every `live` write an agent makes at a meaningful step, and the watchdog's heartbeat after 10 quiet minutes (bt-plan creates it from `live.template.js`) |
|
|
9
|
+
| `<slug>_followups.md` | every follow-up in full under its id, and the bt-spec commands that spec them — the document the dashboard's `/bt-spec Fix F1 from @…` commands point at | by bt-execute's helper, from `followUps`: every `followup` write and every `check` (never by hand) |
|
|
9
10
|
|
|
10
11
|
They are **data, not code.** Each file is exactly one line of prefix and one strict-JSON value:
|
|
11
12
|
|
|
@@ -21,11 +22,11 @@ The status of the plan itself lives in the plan file's checkboxes; the dashboard
|
|
|
21
22
|
|
|
22
23
|
## Updating a data file
|
|
23
24
|
|
|
24
|
-
Use bt-execute's helper — `node <skills>/bt-execute/scripts/dashboard.mjs task|snapshot|activity|status|check <feature-folder> …`
|
|
25
|
-
(every option is in its header). It parses, checks field shapes and writes atomically. Its `task` and
|
|
26
|
-
commands also rewrite the live file
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
Use bt-execute's helper — `node <skills>/bt-execute/scripts/dashboard.mjs task|snapshot|followup|live|activity|status|check <feature-folder> …`
|
|
26
|
+
(every option is in its header). It parses, checks field shapes and writes atomically. Its `task`, `snapshot` and
|
|
27
|
+
`status` commands also rewrite the live file; between them agents write it with `live` at each meaningful step, never
|
|
28
|
+
15 minutes apart. `watch` is the watchdog bt-execute launches in the background at run start: a heartbeat into the
|
|
29
|
+
live file when nothing has been written for 10 minutes, naming the latest file that changed.
|
|
29
30
|
|
|
30
31
|
### Fallback — parse, change, write back
|
|
31
32
|
|
|
@@ -82,9 +83,12 @@ instead of a blank page if something still cannot render — it keeps checking a
|
|
|
82
83
|
milestones); `paused`, `complete` and `incomplete` show *Execution debrief* (the After Action Report card, marked
|
|
83
84
|
*Interim* while paused), with *Continue this plan* — the commands that pick up where it stopped — above it.
|
|
84
85
|
- **Cadence is per task — three writes**, each with `dashboard.mjs task`: when it starts (`in-progress`), the moment
|
|
85
|
-
it is built (`built` — summary, files and tests filled in right then
|
|
86
|
-
attempts, done time, `checkedLive`). The verifier
|
|
87
|
-
`in-progress` with `attempts` + 1. Each status write
|
|
86
|
+
it is built (`built` — summary, files and tests filled in right then, after its frames were added with
|
|
87
|
+
`dashboard.mjs snapshot`) and when it passes (`done` — verifier, attempts, done time, `checkedLive`). The verifier
|
|
88
|
+
adds `verifying` while it checks; a FAIL sends the task back to `in-progress` with `attempts` + 1. Each status write
|
|
89
|
+
also updates the live file. A move to `built`, `verifying` or `done` is refused while a `snapshots/T<n>-…` frame of
|
|
90
|
+
that task is on no dashboard entry, and a visual task's move to `built` is refused with no snapshot at all unless
|
|
91
|
+
`--no-frame "<why>"` says it has nothing to show yet.
|
|
88
92
|
|
|
89
93
|
## `<slug>_dashboard.js` fields
|
|
90
94
|
|
|
@@ -104,7 +108,7 @@ Top level:
|
|
|
104
108
|
| `afterAction` | the After Action Report (below) |
|
|
105
109
|
| `phases` | the plan's phases, each with its tasks (below) |
|
|
106
110
|
| `decisions` | `[{ "id": "D1" \| "T7", "text", "source", "updates" }]` — objects, never plain `"D1 — …"` strings (the page and `check` repair one, but it is a slip) |
|
|
107
|
-
| `followUps` |
|
|
111
|
+
| `followUps` | what a human should look at next: `[{ "id": "F1", "title", "detail", "source", "files": [], "at", "updates": [] }]`, added with `dashboard.mjs followup` (it numbers them and writes `documents/<slug>_followups.md`; `--id F2 … --note` revises one). `title` is one line; `detail` carries enough to spec it alone — what is wrong, the evidence, where to look, what fixing it involves; `source` names who raised it (`T2 verifier`). The page gives each a `/bt-spec Fix F1 from @…_followups.md` command, plus one for those ticked together. A plain string (older dashboards) is repaired into an entry with the next free id |
|
|
108
112
|
| `activity` | `[{ "at", "text" }]`, oldest first — the milestones (the page shows newest first) |
|
|
109
113
|
|
|
110
114
|
`afterAction` — empty while planned; written by bt-execute at the end of every run:
|
|
@@ -115,7 +119,7 @@ Top level:
|
|
|
115
119
|
| `headline` | one sentence: what the plan delivered |
|
|
116
120
|
| `body` | 2–4 paragraphs: what was built, how it was proven, what surprised |
|
|
117
121
|
| `highlights` | the results worth remembering |
|
|
118
|
-
| `comparison` | ONE before/after for the plan as a whole — "before" captured before T1 started, "after" at the end, from the same camera or viewport: `{ "title", "caption", "source", "before": { "src", "caption" }, "after": { "src", "caption" } }`; `null` when the plan has nothing to see |
|
|
122
|
+
| `comparison` | ONE before/after for the plan as a whole — "before" captured before T1 started, "after" at the end, from the same camera or viewport: `{ "title", "caption", "source", "before": { "src", "caption" }, "after": { "src", "caption" } }`, written with `dashboard.mjs snapshot <feature-folder> comparison --before snapshots/plan-before.png --after snapshots/plan-after.png --caption "…"`; `null` when the plan has nothing to see |
|
|
119
123
|
| `snapshots` | optional: the plan's key progression, or the end-to-end proof |
|
|
120
124
|
| `testing` | how the plan was tested — every run, not only `--verbose` (below) |
|
|
121
125
|
| `sections` | `--verbose` only: `[{ "title", "body": [paragraphs], "items": [bullets] }]`, in this order where they apply — Architecture · Phase by phase · Problems and resolutions · Deviations from the plan · Known limitations · Lessons learned · Estimate vs actual · Recommended next steps |
|
|
@@ -181,7 +185,7 @@ Each task:
|
|
|
181
185
|
|
|
182
186
|
## Snapshot shapes
|
|
183
187
|
|
|
184
|
-
**Add snapshots with `node <skills>/bt-execute/scripts/dashboard.mjs snapshot <feature-folder> <T3|P1|plan> --src snapshots/… --caption "…"`** (`--before`/`--after` for a comparison, `--frame "src|stage|caption"` repeated for a progression) — never by writing the JSON yourself. The image key is **`src`**, relative to the feature folder; an entry with `path` (or `file`, `image`, `url`, `href`) instead would render as "No snapshot", so every helper write repairs it to `src` (and an unknown `source` to `"browser"`), `check` repairs any already in the file, and the page reads those keys too. An image that is not on disk is refused — `check` fails on it. **The snapshots are the chronicle of the build: `check` passing is part of every phase boundary and of run end.**
|
|
188
|
+
**Add snapshots with `node <skills>/bt-execute/scripts/dashboard.mjs snapshot <feature-folder> <T3|P1|plan> --src snapshots/… --caption "…"`** (`--before`/`--after` for a comparison, `--frame "src|stage|caption"` repeated for a progression) — never by writing the JSON yourself. The image key is **`src`**, relative to the feature folder; an entry with `path` (or `file`, `image`, `url`, `href`) instead would render as "No snapshot", so every helper write repairs it to `src` (and an unknown `source` to `"browser"`), `check` repairs any already in the file, and the page reads those keys too. An image that is not on disk is refused — `check` fails on it. **The snapshots are the chronicle of the build — they tell the story of how the plan came together: `check` passing is part of every phase boundary and of run end.** Every visual task (`kind` `live`, `game` or `unity`) leaves a progression from one camera as it is built — a before frame, a frame per meaningful layer, the built frame (the builder, added before its `built` write) and the verified frames (the verifier), usually 3–8 in all — plus any comparison or angle that proves the point; a task with nothing to see needs none. The plan as a whole gets `snapshots/plan-before.png` before T1 and one plan-wide before/after (target `comparison`) at run end. Frames come from the sessions and exports the work already runs, never an extra page session or re-export just for a picture; inside an open session a capture costs seconds, so take it. Who takes which frame: bt-execute's *Snapshots tell the story*.
|
|
185
189
|
|
|
186
190
|
Any list of snapshots may mix them. `source` names where the image came from: `"browser"`, `"unity"`,
|
|
187
191
|
`"blender"`, `"reference"`.
|
|
@@ -198,8 +202,10 @@ Any list of snapshots may mix them. `source` names where the image came from: `"
|
|
|
198
202
|
whole from each change it makes: a `task` write that sets a status names the task, its phase, the role the status
|
|
199
203
|
implies (`in-progress` / `built` → implementer, `verifying` → verifier, otherwise orchestrator), one sentence on the
|
|
200
204
|
new state plus the first sentence of the summary written with it, and appends that sentence to the task's step log;
|
|
201
|
-
a `status` write records the run starting or ending. A `task` write
|
|
202
|
-
|
|
205
|
+
a `snapshot` adds a step naming the frame; a `status` write records the run starting or ending. A `task` write
|
|
206
|
+
without a status leaves it untouched. Between those, the agent doing the work writes it with `dashboard.mjs live` at
|
|
207
|
+
each milestone, before anything slow and at each fix attempt, never 15 minutes apart, and the watchdog writes a
|
|
208
|
+
heartbeat after 10 quiet minutes. A 20-minute silence shows as a warning. The page shows it only while `status` is
|
|
203
209
|
`in-progress`.
|
|
204
210
|
|
|
205
211
|
| Field | Meaning |
|
|
@@ -210,7 +216,7 @@ agents never write it. A 20-minute silence shows as a warning. The page shows it
|
|
|
210
216
|
| `title` | only when there is no task: `"Verifying phase 1"`, `"Closing phase 1"` |
|
|
211
217
|
| `role` | `implementer` · `verifier` · `orchestrator` |
|
|
212
218
|
| `activity` | one plain-language sentence on what is happening this minute |
|
|
213
|
-
| `source` | `agent` (the helper, from an agent's write) or `watchdog` (a heartbeat from the
|
|
219
|
+
| `source` | `agent` (the helper, from an agent's write) or `watchdog` (a heartbeat from the watchdog bt-execute launches at run start — the page tags it) |
|
|
214
220
|
| `steps` | `[{ "at": "HH:MM", "text" }]` — the current task's log, oldest first; fresh for each task, the last 12 kept. Plain language a non-developer follows, which is why a task's `summary` leads with a plain first sentence |
|
|
215
221
|
|
|
216
222
|
## `check` — the gate
|
|
@@ -225,6 +231,9 @@ every problem in one message — when a snapshot cannot show its image or a deli
|
|
|
225
231
|
- `status` is `complete` while the plan has an unticked box, or without `documents/<slug>_summary.html`;
|
|
226
232
|
- a visual task (`kind` `live`, `game` or `unity`) is `done` with no snapshot of its own and no phase or After Action
|
|
227
233
|
Report progression frame whose `task` is its id;
|
|
234
|
+
- frames were left behind in `snapshots/`: a `T<n>-…` image of a `built`, `verifying` or `done` task, a `P<N>-…` image
|
|
235
|
+
of a closed phase (`done`, `partial`, `deferred`) or — once the run has ended (`paused`, `complete`, `incomplete`) —
|
|
236
|
+
a `plan-before` image, that no dashboard entry shows. Fix it by adding the frames, never by moving or deleting them;
|
|
228
237
|
- a task ticked in the plan has no `verifier` result.
|
|
229
238
|
|
|
230
239
|
With no plan in the folder (a legacy flat plan) the plan checks are skipped.
|
package/skills/bt-spec/SKILL.md
CHANGED
|
@@ -13,6 +13,7 @@ Turn a short feature idea into a spec file that `bt-plan` can plan from. Follow
|
|
|
13
13
|
/bt-spec --grill-me "add a settings toggle to mute all game audio" # interview first, then spec
|
|
14
14
|
/bt-spec --parity "port the Unity water shader and match it to within 2% in the browser" # numeric parity bars allowed (slow — hours become days)
|
|
15
15
|
/bt-spec --no-time-limit "redesign the save system" # turn off the default TIME MATTERS mode
|
|
16
|
+
/bt-spec Fix F1 and F3 from @.agents/specs/<slug>/documents/<slug>_followups.md # a finished feature's follow-ups (its dashboard's copy buttons)
|
|
16
17
|
```
|
|
17
18
|
|
|
18
19
|
- `--grill-me` — interview the user, one question at a time, before writing (Step 4).
|
|
@@ -41,6 +42,7 @@ From the flag-stripped brief derive `feature_title` (Title Case), `feature_slug`
|
|
|
41
42
|
- **`DESIGN.md`** (only if the feature has UI): it is the single source of truth for design — never Figma or invented values. Cite the tokens and shared components the feature uses in 3–8 bullets. Missing → note `"No DESIGN.md design system found — follow the existing UI conventions already in the codebase."` No UI → say no design tokens apply. When the feature has a HUD, overlay, menu, splash or landing page, add one bullet naming its live values and their cadence under the Agent Reference's **Game UI Performance — ENFORCED** (state on events, telemetry through the frame loop, throttled readouts, decorative motion in CSS, no frame loop on menus / splash / landing pages), so the plan builds it that way.
|
|
42
43
|
- **Recon docs (`.agents/recon/*_recon.md`, written by bt-recon):** if any recon's `scope` covers a system this feature touches, read its Summary, Architecture, the relevant Feature Inventory / UI Reference / External Interfaces sections, Known Issues and Extension Points — it is the grounding for code nobody else documented, so build on it instead of re-deriving it. Cite it in `## Research Notes`. If its `commit:` is well behind HEAD for the files this feature touches, note the drift there and suggest `bt-recon --refresh`.
|
|
43
44
|
- **Recons the brief cites (`… using @<path>_recon.md`):** bt-profile's fix commands cite the recon of the code behind the fixes, kept in the profile's own folder (`.agents/profile/<slug>/recon/`) or in `.agents/recon/`. Always read a cited recon in full, whatever its scope says. It is the map of the code the fix changes: callers, invariants, tests, extension points. Turn what it says must not break into Acceptance Criteria or named test cases. **Copy each cited recon into this feature's `recon/` folder** and cite the copy in `## Research Notes`. The feature folder then holds everything it rests on, and still works after the profile is archived or moved. A cited recon that does not exist yet: say so, give the `/bt-recon` command that makes it (the profile report's **Copy recon command**), and carry on with your own research.
|
|
45
|
+
- **Follow-ups the brief cites (`Fix F1 and F3 from @<feature-folder>/documents/<slug>_followups.md`):** a finished feature's dashboard offers this command for what its bt-execute runs left for a human to look at next. Read each cited follow-up in full: it is the brief (what is wrong, the evidence, where to look, what fixing it involves). Then read what it points at in the source feature: its plan's Decisions, the run-log lines and files it names, and the source feature's `recon/` copies when it touches that code. Spec only the cited follow-ups, as **one new feature** with its own slug, named for what they fix (`network-hud-banner-fix`), never `fix-f1` and never the source feature's slug. Cite the source feature folder and the follow-up ids in `## Research Notes`, and say there which follow-ups the spec covers. A cited id the file does not have: list the ids it does have, and stop.
|
|
44
46
|
- **Research the codebase, sized to the feature.** Find the closest existing feature to mirror, the real conventions, and the integration points. For a `small` feature do this inline; fan out to up to 3 **read-only** subagents only for `medium` / `large` (they report findings and file paths, never draft the spec; if a finding contradicts SPEC.md, raise it with the user rather than resolving it silently). Record the result in the spec's `## Research Notes` so bt-plan starts from it.
|
|
45
47
|
|
|
46
48
|
## Step 3. Sibling-skill patterns
|