@babylonjs-toolkit/agent 1.1.86 → 1.1.99
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 +5 -6
- package/package.json +1 -1
- package/skills/bt-execute/SKILL.md +17 -15
- package/skills/bt-execute/scripts/dashboard.mjs +297 -5
- package/skills/bt-execute/templates/dashboard/dashboard.html +29 -3
- package/skills/bt-execute/templates/dashboard/dashboard.template.js +1 -2
- package/skills/bt-execute/templates/dashboard/data-schema.md +8 -6
- package/skills/bt-gauntlet/references/spec-composition.md +3 -1
- package/skills/bt-plan/SKILL.md +2 -2
- package/skills/bt-profile/SKILL.md +21 -1
- package/skills/bt-profile/scripts/analyze.mjs +160 -0
- package/skills/bt-profile/scripts/lib/probe.mjs +119 -2
- package/skills/bt-profile/scripts/report.mjs +46 -1
- package/skills/bt-spec/SKILL.md +7 -7
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Babylon Toolkit Desktop Agent (1.1.
|
|
1
|
+
# Babylon Toolkit Desktop Agent (1.1.99)
|
|
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
|
|
|
@@ -268,7 +268,7 @@ pair or schedule the bridge.
|
|
|
268
268
|
|
|
269
269
|
| Skill | Command | What it does |
|
|
270
270
|
|-------|---------|--------------|
|
|
271
|
-
| [`bt-spec`](skills/bt-spec/SKILL.md) | `/bt-spec` | Turn a short idea into a feature spec file on
|
|
271
|
+
| [`bt-spec`](skills/bt-spec/SKILL.md) | `/bt-spec` | Turn a short idea into a feature spec file (on whatever branch you have checked out — no skill creates branches or commits), plus the feature's dashboard with the `bt-plan` commands to copy. Add `--grill-me` to be interviewed first, `--parity` to allow numeric parity bars in the acceptance criteria. Runs in `TIME MATTERS` mode by default; `--no-time-limit` turns it off. |
|
|
272
272
|
| [`bt-plan`](skills/bt-plan/SKILL.md) | `/bt-plan` | Produce a detailed, task-checklist technical plan from a spec. Add `--heavy` for a decision-complete plan that keeps a long, fresh-context-per-task run cohesive, and `--parity` for numeric parity gates instead of the default functional proof. Runs in `TIME MATTERS` mode by default; `--no-time-limit` turns it off. |
|
|
273
273
|
| [`bt-execute`](skills/bt-execute/SKILL.md) | `/bt-execute` | Implement one task, a range (`T3-T7`, `T12-`, `NEXT:3`) or all remaining tasks from a plan/spec; with no task id it runs the next unchecked task. Add `--auto-pilot` for an unattended overnight run that never stops for human input, `--strict` for an adversarial verifier on every task, and `--verbose` for an in-depth write-up of every task and the After Action Report on the dashboard. Runs in `TIME MATTERS` mode by default; `--no-time-limit` turns it off. |
|
|
274
274
|
| [`bt-recon`](skills/bt-recon/SKILL.md) | `/bt-recon` | Deep-dive existing code — a subsystem named in a brief, or the whole codebase — and write an evidence-cited technical grounding spec (`.agents/recon/<slug>_recon.md`) plus, when it has UI, a plain-language user guide (`.agents/recon/<slug>_guide.md`). Built for taking over undocumented code; `bt-spec` and `bt-plan` read the recon as grounding. Includes an observe-only live pass when the brief gives a URL; `--refresh` updates a recon after code changes. |
|
|
@@ -317,7 +317,7 @@ the After Action Report is revised when the new work is done). A watchdog runs a
|
|
|
317
317
|
when an agent has written nothing for 10 minutes it writes a heartbeat naming the latest file the work
|
|
318
318
|
changed (or warns that the run may be stalled), and it corrects a status that still names a finished
|
|
319
319
|
task — so the dashboard never sits silent or wrong while a long task is running. Phase by phase and task by task it shows what was actually done, files, tests,
|
|
320
|
-
verifier verdicts, attempts,
|
|
320
|
+
verifier verdicts, attempts, decisions, deferrals and follow-ups. The snapshots tell the
|
|
321
321
|
story of the build: **progressions** captured from the same camera each time a meaningful layer
|
|
322
322
|
lands (a terrain: heightmap → textures → roads → trees → foliage → lighting), played back as a
|
|
323
323
|
storyboard, plus before/after sliders and stills where those prove the point. When later work
|
|
@@ -407,9 +407,8 @@ bad range, a stop point named in the brief, or you telling it to stop. Nothing i
|
|
|
407
407
|
and goes through an independent verifier, and a box only flips on a genuine PASS.
|
|
408
408
|
What changes is that a failure never halts the run: a failing task gets a bounded fix loop (3
|
|
409
409
|
attempts, 5 under `--strict`), is then marked `⏭️ DEFERRED (auto-pilot): <reason>` in the plan, and the run moves
|
|
410
|
-
on; deferred tasks get one more pass at the end.
|
|
411
|
-
|
|
412
|
-
ever pushed), and a `<slug>_autopilot.md` run log next to the plan records every task outcome,
|
|
410
|
+
on; deferred tasks get one more pass at the end. Nothing is ever committed, staged, branched or
|
|
411
|
+
pushed: every change stays in your working tree, and you commit when you choose. A `<slug>_autopilot.md` run log next to the plan records every task outcome,
|
|
413
412
|
decision and deferral for you to read in the morning, plus clock times per phase and per task
|
|
414
413
|
(interactive runs log the clock times too) so bt-plan's time estimates can be recalibrated from
|
|
415
414
|
real runs. Re-running the same command resumes and re-attempts anything deferred.
|
package/package.json
CHANGED
|
@@ -32,6 +32,8 @@ Run tasks from a plan: build each one with its tests, have an independent verifi
|
|
|
32
32
|
## Ground rules
|
|
33
33
|
|
|
34
34
|
- **TIME MATTERS** — on by default; `--no-time-limit` turns it off. Treat the arguments as ending with `TIME MATTERS`: the user is waiting on this run, so finish quickly — follow the *Work fast* rules below to the letter, take the direct route to each task's Acceptance, and do not re-read what you already have. Begin every implementer and verifier prompt with `TIME MATTERS.` Print `⏱️ [bt-execute] TIME MATTERS` at the start (`--no-time-limit`: print `⏱️ [bt-execute] No time limit`, and do not add it). Speed never relaxes tests, the independent verifier, live checks, or "tick only on PASS".
|
|
35
|
+
- **Snapshots — ENFORCED.** The dashboard's snapshots are the chronicle of how the feature was built; a row of "No snapshot" loses that record for good. Every snapshot reaches the dashboard **only** through `node <skills>/bt-execute/scripts/dashboard.mjs snapshot <feature-folder> <T<n>|P<N>|plan> --src snapshots/… --caption "…"` (`--before … --after …` for a comparison, `--frame "src|stage|caption"` repeated for a progression). Never write or brief a snapshot JSON shape — every brief carries that exact command line with the paths filled in, and a subagent that cannot run it returns paths and captions for you to add. `dashboard.mjs check <feature-folder>` is a gate, not a courtesy: run it at every phase boundary and at run end, and never close a phase or end the run while it fails. Then open `dashboard.html` headless and look: every snapshot slot shows its image.
|
|
36
|
+
- **Never commit.** No git commit, stage, stash, push or branch switch, in any mode (`--auto-pilot` included); it works on whatever branch is checked out. The user commits when they choose; every change this skill makes stays in the working tree.
|
|
35
37
|
- **Scope.** Implement only the selected task(s). No "while I'm here" work on other tasks. Ambiguous, or blocked by an unfinished task → stop and tell the user *(auto-pilot: decide and log it)*.
|
|
36
38
|
- **Open the run before anything else.** The first actions of every run — before reading docs, reading code, checking the repo or any other pre-flight work — are, in order: take the clock; append the `⏱ Run <n> start` line to the run log; sync the dashboard with the plan and set `status: "in-progress"` (*Run start* under *Feature folder and dashboard*); write the live file (`role: "orchestrator"`, `title: "Starting run <n> — <what you are checking first>"`); and launch the watchdog in the background (*Never let the dashboard go stale*). From then on the pre-flight work is narrated in the live file like any other step. Until the run is opened the dashboard still shows the last run's end state — a user who restarts a run and refreshes must see it running within a minute, not after the pre-flight is over.
|
|
37
39
|
- **Read the docs once.** For Babylon work, if you have not read the Agent Reference this session, read it once — https://raw.githubusercontent.com/babylontoolkit/agent/main/reference.md — plus only the sub-documents the plan's tasks need, searching a large one for the part you need rather than reading it whole. It is the authority for conventions and API. Cannot be read → stop and tell the user *(auto-pilot: retry 3×, then continue on what you know and log it)*. Read the plan's checklist and the parts of `SPEC.md` the tasks touch; re-read after a context compaction.
|
|
@@ -50,17 +52,17 @@ Work in **phases**: a `### Phase N` group in the plan, or — if the plan has no
|
|
|
50
52
|
|
|
51
53
|
1. **Build** each task in the phase, in order, **following the Agent Reference's Coding Practices — ENFORCED** (clean, professional TypeScript or JavaScript in the project's own language; meaningful full-word names, never one- or two-letter names or obfuscation; well-structured, readable, maintainable code for human developers; meaningful JSDoc on every class, function, method and public member — always written, never a reason to fail a task), and every HUD or overlay **following Game UI Performance — ENFORCED** (per-frame values reach the screen through refs and one frame loop, never React state, props, a store or a per-frame EventBus message; only changed values written, with cheap properties), **with its tests**: the cases the plan's `Tests:` names (or, with none, meaningful cases for its Acceptance and edge cases), in the feature folder's `tests/` (`.agents/specs/<slug>/tests/` — never a root `tests/` folder), using the repo's test runner and style. Get them green — fix the code, not the test, unless the test is wrong. No testable surface (config, docs, assets) → say so. A task with visible output also **saves its progression snapshots** as it builds (*Snapshots tell the story*, below). The implementer keeps the **dashboard current task by task** — the live file at every step, the task's entry at start and the moment it is built — so the user never waits for the phase to end to see progress. Boxes stay unticked.
|
|
52
54
|
2. **Verify** the phase with a fresh **independent verifier** subagent (charter below), giving it the list of files changed. It returns PASS/FAIL per task, with evidence, and marks each task `verifying` on the dashboard (and the live file) as it checks it.
|
|
53
|
-
3. **Tick** `- [ ]` → `- [x]` for every task that passed, immediately — except a task that depends on one that failed in the same phase, which waits for it. Never tick partial, skipped or unverified work. Mark each ticked task `done` on the dashboard as you tick it, then write the phase's dashboard entry
|
|
55
|
+
3. **Tick** `- [ ]` → `- [x]` for every task that passed, immediately — except a task that depends on one that failed in the same phase, which waits for it. Never tick partial, skipped or unverified work. Mark each ticked task `done` on the dashboard as you tick it, then write the phase's dashboard entry.
|
|
54
56
|
4. **Fix loop** for a task that failed: fix the code in the context that wrote it; re-run its tests; re-verify with a **fresh** verifier given only the failed items and the evidence (`--strict`: the whole task). A records-only slip (a stale number or note) is fixed directly and re-checked by you. 3 attempts (`--strict`: 5), each changing something material; stop early if two attempts fail the same way with no new idea. Still failing → leave it unticked, stop and report *(auto-pilot: defer and continue)*.
|
|
55
57
|
5. **Report:** tasks done (for `ALL` / ranges: the range asked for, completed/total, and whether the plan is now finished; if fewer than `n` tasks remained for `NEXT:<n>`, say so), files changed, tests run (`tests: 4 passed (implementer) · verifier-checked`), verifier result (`verified (independent subagent)` or `verified (self)`), the dashboard path (`.agents/specs/<slug>/dashboard.html` — open it in a browser), the plan summary path when this run wrote it (`.agents/specs/<slug>/documents/<slug>_summary.html`), and the next task id — for reference only.
|
|
56
58
|
|
|
57
|
-
**The verifier is told:** *"Confirm each task's Acceptance is genuinely met and run its `Verify` commands against the stated expected output. Re-run the tests and the relevant suite once; check they really cover the Acceptance and named edge cases and could fail — missing or vacuous tests are a FAIL. Read the diff for real defects: logic errors, broken callers, unhandled edge cases the plan names, a documented behavior dropped or inverted, a sibling-skill template re-implemented instead of copied. Check every code file the task created or changed against the Agent Reference's Coding Practices — ENFORCED: clean, professional TypeScript or JavaScript in the language the project already uses (never converted to the other unasked); strict types with no needless `any` in TypeScript; meaningful full-word names for every class, method, property, variable and parameter (one- or two-letter names, cryptic abbreviations and code-golf tricks are violations, except the allowed loop counters, axis/`uv` names and toolkit aliases, and names that bind to exported data); no dead code, unused imports or leftover `console.log`; well-structured code a developer new to the project can read and maintain. Any violation is a FAIL for that task — quote the offending lines. Check every HUD, overlay or GUI file the task created or changed against the Agent Reference's Game UI Performance — ENFORCED: a value that changes every frame (speed, RPM, needles, timers, bars, markers) set through React state, props, context or a store, or posted on the EventBus per frame; a state setter, `dispatch(`, store update or `EventBus.PostMessage(` inside `requestAnimationFrame`, a frame-loop hook, a render observable or a component's `update()`; `width` / `height` / `top` / `left` / `innerHTML` / SVG geometry written per frame, or layout read in the loop; a Babylon GUI control assigned every frame without a changed-value check; a frame loop (`requestAnimationFrame`, `useFrameLoop`, `setInterval`, an animation-library tick) on a menu, pause / settings / results screen, splash, preloader or landing page, or driving motion CSS could do (a real-time 3D / canvas / scroll-scrubbed hero is allowed when it pauses off-screen and writes nothing at rest); a HUD loop that keeps writing while its HUD is hidden, behind a modal or the game is paused; a CSS `transition` on a property the frame loop writes. Any of these is a FAIL for that task — quote the offending lines. JSDoc is never a FAIL: missing, thin or stale JSDoc (including JavaScript type tags) never fails a test, a verification or an Acceptance item — list it under a separate non-blocking `JSDoc notes` heading. For any task whose correctness shows only at runtime — rendering, UI, interaction, Unity↔Babylon parity — check it live in the browser (and Unity where relevant) whether or not the plan marks it `live`, and do the plan's final end-to-end check live: look at the running result, beside the reference image when there is one, and judge it as a user would; passing unit tests never substitute. Do all of a phase's live checks in one session on the already-running dev server, and re-export from Unity only if the phase changed that scene's export — then only the project and the scenes the phase works on. Save the frames from your live session that show each visual task's verified result to `[SNAPSHOTS]` as `T<n>-<NN>-<stage>.png` — the same camera or viewport as the implementer's progression frames, plus any angle or comparison (Unity beside browser, before beside after) that proves the Acceptance — and
|
|
59
|
+
**The verifier is told:** *"Confirm each task's Acceptance is genuinely met and run its `Verify` commands against the stated expected output. Re-run the tests and the relevant suite once; check they really cover the Acceptance and named edge cases and could fail — missing or vacuous tests are a FAIL. Read the diff for real defects: logic errors, broken callers, unhandled edge cases the plan names, a documented behavior dropped or inverted, a sibling-skill template re-implemented instead of copied. Check every code file the task created or changed against the Agent Reference's Coding Practices — ENFORCED: clean, professional TypeScript or JavaScript in the language the project already uses (never converted to the other unasked); strict types with no needless `any` in TypeScript; meaningful full-word names for every class, method, property, variable and parameter (one- or two-letter names, cryptic abbreviations and code-golf tricks are violations, except the allowed loop counters, axis/`uv` names and toolkit aliases, and names that bind to exported data); no dead code, unused imports or leftover `console.log`; well-structured code a developer new to the project can read and maintain. Any violation is a FAIL for that task — quote the offending lines. Check every HUD, overlay or GUI file the task created or changed against the Agent Reference's Game UI Performance — ENFORCED: a value that changes every frame (speed, RPM, needles, timers, bars, markers) set through React state, props, context or a store, or posted on the EventBus per frame; a state setter, `dispatch(`, store update or `EventBus.PostMessage(` inside `requestAnimationFrame`, a frame-loop hook, a render observable or a component's `update()`; `width` / `height` / `top` / `left` / `innerHTML` / SVG geometry written per frame, or layout read in the loop; a Babylon GUI control assigned every frame without a changed-value check; a frame loop (`requestAnimationFrame`, `useFrameLoop`, `setInterval`, an animation-library tick) on a menu, pause / settings / results screen, splash, preloader or landing page, or driving motion CSS could do (a real-time 3D / canvas / scroll-scrubbed hero is allowed when it pauses off-screen and writes nothing at rest); a HUD loop that keeps writing while its HUD is hidden, behind a modal or the game is paused; a CSS `transition` on a property the frame loop writes. Any of these is a FAIL for that task — quote the offending lines. JSDoc is never a FAIL: missing, thin or stale JSDoc (including JavaScript type tags) never fails a test, a verification or an Acceptance item — list it under a separate non-blocking `JSDoc notes` heading. For any task whose correctness shows only at runtime — rendering, UI, interaction, Unity↔Babylon parity — check it live in the browser (and Unity where relevant) whether or not the plan marks it `live`, and do the plan's final end-to-end check live: look at the running result, beside the reference image when there is one, and judge it as a user would; passing unit tests never substitute. Do all of a phase's live checks in one session on the already-running dev server, and re-export from Unity only if the phase changed that scene's export — then only the project and the scenes the phase works on. Save the frames from your live session that show each visual task's verified result to `[SNAPSHOTS]` as `T<n>-<NN>-<stage>.png` — the same camera or viewport as the implementer's progression frames, plus any angle or comparison (Unity beside browser, before beside after) that proves the Acceptance — and add each one to its task with `node <skills>/bt-execute/scripts/dashboard.mjs snapshot <feature-folder> T<n> --src snapshots/… --caption "…"` (never snapshot JSON), returning each path with its one-line caption. Snapshots never add a page session or an export of their own. Keep the dashboard current as you go: set each task `verifying` when you start checking it, and rewrite the live file at each check (what you are checking, on what) — never 15 minutes without a write. Treat an absolute count in the plan as 'named tests pass, no new failures'. [SCOPE] Return PASS/FAIL per task with evidence and one line on what you ran live and where (or `none — tests only`), listing records-only slips separately."*
|
|
58
60
|
|
|
59
61
|
`[SNAPSHOTS]` is the feature folder's `snapshots/` path (`.agents/specs/<slug>/snapshots/`). `[SCOPE]` is one of two sentences. **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, using whatever you judge worthwhile — 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."*
|
|
60
62
|
|
|
61
63
|
For a task built on a sibling skill (e.g. bt-design's 3D-Hero-Scroll), give the verifier the relevant part of that skill *(where skills load through a tool: `load_skill` + `read_skill_resource`; where they are files: the skills directory this skill was loaded from, e.g. `~/.claude/skills/`, `~/.agents/skills/` or the project's equivalent)* — its documented options (e.g. `sweep: page` really reaches the document bottom) are part of Acceptance.
|
|
62
64
|
|
|
63
|
-
**Every subagent gets a brief, not homework:** the task block(s), the plan Decisions / Design Reference entries they cite, the SPEC.md parts touched, the Agent Reference excerpts needed (with their links) — **always including the full `Coding Practices — ENFORCED` section**, since implementers write to it and verifiers fail work that breaks it — the test command and the feature folder's `tests/` path, the `snapshots/` path and *Snapshots tell the story* (for any phase with visible output), the dashboard and live file paths with the per-task update rules from *Feature folder and dashboard* (with `--verbose`, the `details` fields that role writes), the project's agent instructions, the *Work fast* rules below, 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 for the API, never the whole file) only if you hit an API this brief does not cover, and say which."*
|
|
65
|
+
**Every subagent gets a brief, not homework:** the task block(s), the plan Decisions / Design Reference entries they cite, the SPEC.md parts touched, the Agent Reference excerpts needed (with their links) — **always including the full `Coding Practices — ENFORCED` section**, since implementers write to it and verifiers fail work that breaks it — the test command and the feature folder's `tests/` path, the `snapshots/` path and *Snapshots tell the story* (for any phase with visible output), the dashboard and live file paths with the per-task update rules from *Feature folder and dashboard* (with `--verbose`, the `details` fields that role writes) and **the exact `dashboard.mjs snapshot` command line with the feature folder filled in** — never a snapshot JSON shape of your own (a hand-written `{path, caption}` entry has twice reached a dashboard as a row of "No snapshot"), the project's agent instructions, the *Work fast* rules below, 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 for the API, never the whole file) only if you hit an API this brief does not cover, and say which."*
|
|
64
66
|
|
|
65
67
|
## Feature folder and dashboard
|
|
66
68
|
|
|
@@ -93,17 +95,17 @@ Every feature lives in one folder, created by bt-spec (or by bt-plan for a Quick
|
|
|
93
95
|
2. **Hand-off writes.** Before you launch any implementer or verifier, set its task(s) `in-progress` (implementer) or `verifying` (verifier) and point the live file at it (`--task T19 --role implementer --activity "Implementer started on T19 — <its first step>" --reset`); when it returns, write what it reported. The live file must never still name the previous task while a new one is being worked on.
|
|
94
96
|
3. **Long commands are narrated.** Before any command that may run more than a few minutes (a full test chain, an export or bake, a multi-race or multi-scene browser run), write a step saying what it is and roughly how long it takes; run it in the background where the host allows, and write a step at each milestone its output shows ("race 2 of 4 reached results"). A long run is exactly when the user is watching.
|
|
95
97
|
|
|
96
|
-
- **The live file — at every meaningful step.** Rewrite `documents/<slug>_live.js` whole (it is small) when a task starts, at each milestone inside it, before anything slow (a build, an export, a bake, a capture, a test run), at each fix attempt, at the hand-over to the verifier and while it checks each task, and
|
|
97
|
-
- **The dashboard data — at every task boundary:** a task becomes `in-progress` when it starts; `built` the moment it is built and its tests are green — with its summary of what was actually done (and anything surprising), files, tests and snapshots filled in **right then**, not at the phase end; `verifying` while the verifier checks it; `done` when it passes (verifier result, attempts,
|
|
98
|
-
- **Every write goes through this skill's `scripts/dashboard.mjs` — never hand-edited.** Each data file is one `window.… =` prefix and one strict-JSON value (the prefix only lets a page opened from disk load it); the helper parses it, changes it, checks the shapes and writes it back atomically, so the page never sees a half-written or malformed file. Use it, not a one-off script of your own: `node <skills>/bt-execute/scripts/dashboard.mjs live <feature-folder> --task T7 --role implementer --activity "…" --step "…"` · `task <feature-folder> T7 --set '{"status":"built","summary":"…"}'` · `activity <feature-folder> "…"` · `status <feature-folder> in-progress` · `check <feature-folder>` (all options in the script's header). Only where Node cannot run, fall back to the parse-and-write-back recipe in `data-schema.md`. Keep each field its documented shape too — a list stays a list (`updates`, `snapshots`, `files`, `decisions`, `notes` …: append, never assign a string); a helper script you give subagents checks the shapes before it writes.
|
|
98
|
+
- **The live file — at every meaningful step.** Rewrite `documents/<slug>_live.js` whole (it is small) when a task starts, at each milestone inside it, before anything slow (a build, an export, a bake, a capture, a test run), at each fix attempt, at the hand-over to the verifier and while it checks each task, and when the phase closes: the phase, the task, the role, one plain-language sentence on what is happening now, and the task's step log. Never let it go 15 minutes without a write during active work — the page flags a 20-minute silence. Between tasks, `task: ""` and a `title` (`Verifying phase 2`, `Closing phase 2`).
|
|
99
|
+
- **The dashboard data — at every task boundary:** a task becomes `in-progress` when it starts; `built` the moment it is built and its tests are green — with its summary of what was actually done (and anything surprising), files, tests and snapshots filled in **right then**, not at the phase end; `verifying` while the verifier checks it; `done` when it passes (verifier result, attempts, done time, its `DECISION` lines, and `checkedLive` — one line on what the verifier ran live and where, for every task it checked in the browser or Unity whatever the plan's verify level, `""` when tests alone proved it); back to `in-progress` with `attempts` + 1 on a FAIL. Each change also adds an `activity` line and refreshes `updatedAt`.
|
|
100
|
+
- **Every write goes through this skill's `scripts/dashboard.mjs` — never hand-edited.** Each data file is one `window.… =` prefix and one strict-JSON value (the prefix only lets a page opened from disk load it); the helper parses it, changes it, checks the shapes and writes it back atomically, so the page never sees a half-written or malformed file. Use it, not a one-off script of your own: `node <skills>/bt-execute/scripts/dashboard.mjs live <feature-folder> --task T7 --role implementer --activity "…" --step "…"` · `task <feature-folder> T7 --set '{"status":"built","summary":"…"}'` · `snapshot <feature-folder> T7 --src snapshots/T7-01-stage.png --caption "…"` (or `--before … --after …`, or `--frame "src|stage|caption"` repeated) · `activity <feature-folder> "…"` · `status <feature-folder> in-progress` · `check <feature-folder>` (all options in the script's header). **Snapshots go in only through `snapshot`** — it builds the shape the page renders and refuses an image that is not on disk. As a backstop, every helper write repairs an entry the page could not show (an image under `path`, `file`, `image`, `url` or `href` moves to `src`; an unknown `source` becomes `browser`), `check` repairs any already in the file, and the watchdog repairs one written around the helper within a minute; an image that is not on disk is still refused. Run `check` at every phase boundary and at run end; a failure there is fixed before the phase closes. Only where Node cannot run, fall back to the parse-and-write-back recipe in `data-schema.md`. Keep each field its documented shape too — a list stays a list (`updates`, `snapshots`, `files`, `decisions`, `notes` …: append, never assign a string); a helper script you give subagents checks the shapes before it writes.
|
|
99
101
|
|
|
100
102
|
On top of the per-task updates:
|
|
101
103
|
|
|
102
|
-
- **Run start — the first thing the run does** (*Open the run before anything else*): make sure the default `.agents` folders exist — `.agents/specs/`, `.agents/complete/`, `.agents/archived/`, `.agents/profile/` and `.agents/recon/`, each with an empty `.gitkeep` (write only the ones missing); **refresh `dashboard.html`** — copy it again from the template with `{{slug}}` replaced (it is never edited, so this is always safe, and it is how layout fixes reach dashboards created by older versions), and `documents/<slug>_summary.html` the same way from `templates/summary/summary.html` when the feature already has one; then **sync the dashboard with the plan file** — re-read its checklist and add any phase or task (including sub-tasks like `T3.1`) the dashboard lacks, in plan order, as `pending`, with an `updates` note on it (`Added to the plan after <the plan was complete / phase 2 ran> — <why, if the plan says>`); a task the plan no longer has is removed with an `activity` line saying so. Then `status: "in-progress"`, `runs` + 1, the run-log document link, an `activity` line, the first live-file write, and the watchdog launched in the background. In a git repository, check `.gitignore` has `.agents/*/*/documents/*_live.js` and append it once if not — the live file is never
|
|
103
|
-
- **Each phase, after its ticks
|
|
104
|
+
- **Run start — the first thing the run does** (*Open the run before anything else*): make sure the default `.agents` folders exist — `.agents/specs/`, `.agents/complete/`, `.agents/archived/`, `.agents/profile/` and `.agents/recon/`, each with an empty `.gitkeep` (write only the ones missing); **refresh `dashboard.html`** — copy it again from the template with `{{slug}}` replaced (it is never edited, so this is always safe, and it is how layout fixes reach dashboards created by older versions), and `documents/<slug>_summary.html` the same way from `templates/summary/summary.html` when the feature already has one; then **sync the dashboard with the plan file** — re-read its checklist and add any phase or task (including sub-tasks like `T3.1`) the dashboard lacks, in plan order, as `pending`, with an `updates` note on it (`Added to the plan after <the plan was complete / phase 2 ran> — <why, if the plan says>`); a task the plan no longer has is removed with an `activity` line saying so. Then `status: "in-progress"`, `runs` + 1, the run-log document link, an `activity` line, the first live-file write, and the watchdog launched in the background. In a git repository, check `.gitignore` has `.agents/*/*/documents/*_live.js` and append it once if not — the live file is never worth committing; `<slug>_dashboard.js` and `snapshots/` are, when the user commits.
|
|
105
|
+
- **Each phase, after its ticks:** the phase's status, times and minutes (from its `⏱` line), its verifier result and a two-or-three-sentence summary of what it delivered; the phase-level snapshots (a progression spanning several tasks — below), each added with `dashboard.mjs snapshot`, and `dashboard.mjs check` passing; `decisions`; `activeTime` — the plan's total across **every run so far** (each finished run's `active` from its `⏱ Run <n> end` line, plus this run's so far), never this run alone; an `activity` line; and a current "so far" `outcome` headline.
|
|
104
106
|
- **A deferral:** the task's `status: "deferred"` and `deferredReason`, an `activity` line.
|
|
105
107
|
- **Run end — the After Action Report.** **decide the status by re-reading the plan file's checkboxes, never from memory:** `complete` when every task in the plan is `- [x]`; `incomplete` when every task is either ticked or marked ⏭️ DEFERRED; otherwise `paused` (the run covered only a slice, or tasks were added). The page refuses a `complete` it can see is false — it shows the plan as paused with a warning — but the plan file is the authority; never leave `in-progress` behind, because the status picks the page's top slot: `in-progress` shows *Current run activity* (the live file and the milestones), any other run-ended status shows the After Action Report in its place. Write `followUps` for a human, and `afterAction` — the whole plan's execution, start to finish: a one-sentence headline of what the plan delivered; two to four paragraphs on what was built, how it was proven and what surprised; highlights; and **one before/after for the plan as a whole** (`comparison`) — the plan-wide "before" frame beside a final "after" taken now from the same camera or viewport (the end-to-end check's session supplies it). Add the plan's key progression to `afterAction.snapshots` if one tells the story better than any single phase. Write `afterAction.testing` on every run, not only `--verbose`: run every test suite the plan touched **once more, in full, at run end** and record each as a `suites` entry (name, command, passed, failed, how many tests this plan added, and a `note` for any failure that pre-dates the plan) — never add up the tasks' counts, which re-count the same suite once per task; a `summary` of how the plan was tested (unit tests, the verifier's re-runs, what was checked live and on what, the end-to-end check); and `gaps` — what no test or live check covers. The page builds the task-by-task table and the list of test cases from the tasks. The figures (tasks, tests, retries, time) are computed by the page — never type them in. A run that ends before the plan is finished writes it too; the page marks it *Interim* while `paused`, and the next run revises it with an `updates` entry. **A reopened plan** (tasks added after it was complete) works the same way: the run that finishes the added tasks rewrites the After Action Report to cover them, notes the change in its `updates` (`Revised — T7 added after completion: <why>`), and retakes the plan-wide "after" from the same camera so the comparison shows the plan as it now stands.
|
|
106
|
-
- **Run end — the plan summary, only when the plan is `complete`.** Write the feature's plan summary, a formatted page that opens straight from disk. It is the plan told to people who never see the code: what it delivered, what it means for existing users and content, what was wrong, what changed, what did not, and how it was checked. Use on-screen names in **bold** and real values. Leave out file names, task IDs and test counts. Like the dashboard, the page is a fixed template and the content is data, both from this skill's `templates/summary/`. Copy `summary.html` to `documents/<slug>_summary.html` with `{{slug}}` replaced and nothing else edited; only `dashboard.html` sits at the feature root. Write `documents/<slug>_summary.js` beside it, whole as strict JSON behind `window.PLAN_SUMMARY =`. **`summary-guide.md` has the audience, the fields and the section order, and `summary.template.js` is a worked example. Read both.** **Leave out any section that does not apply to this plan**, and adapt a heading's wording where the default does not fit (a feature has *Why it was needed* in place of *What was wrong*). Then set `afterAction.planSummary: "documents/<slug>_summary.html"` so the After Action Report links to the page. A `paused` or `incomplete` run writes no summary. **A reopened plan** keeps its existing summary while the added tasks run. The run that completes them rewrites the data to cover the plan as it now stands, adds the new date to `stamp` (`Fixed on 2026-10-19; updated on 2026-11-02`) and says in the lead what the update added.
|
|
108
|
+
- **Run end — the plan summary, only when the plan is `complete`.** Write the feature's plan summary, a formatted page that opens straight from disk. It is the plan told to people who never see the code: what it delivered, what it means for existing users and content, what was wrong, what changed, what did not, and how it was checked. Use on-screen names in **bold** and real values. Leave out file names, task IDs and test counts. Like the dashboard, the page is a fixed template and the content is data, both from this skill's `templates/summary/`. Copy `summary.html` to `documents/<slug>_summary.html` with `{{slug}}` replaced and nothing else edited; only `dashboard.html` sits at the feature root. Write `documents/<slug>_summary.js` beside it, whole as strict JSON behind `window.PLAN_SUMMARY =`. **`summary-guide.md` has the audience, the fields and the section order, and `summary.template.js` is a worked example. Read both.** **Leave out any section that does not apply to this plan**, and adapt a heading's wording where the default does not fit (a feature has *Why it was needed* in place of *What was wrong*). Then set `afterAction.planSummary: "documents/<slug>_summary.html"` so the After Action Report links to the page. A `paused` or `incomplete` run writes no summary. **A reopened plan** keeps its existing summary while the added tasks run. The run that completes them rewrites the data to cover the plan as it now stands, adds the new date to `stamp` (`Fixed on 2026-10-19; updated on 2026-11-02`) and says in the lead what the update added.
|
|
107
109
|
- **`--verbose` — the same work, written up in depth.** It changes what is written, never what is done: tests, the verifier, live checks and snapshot captures are exactly as without it, and TIME MATTERS still holds (the extra cost is writing, not checking). Set `detail: "verbose"` at run start. Each task gets a `details` write-up (fields in `data-schema.md`), filled in by whoever has the facts, at the same per-task moments as everything else:
|
|
108
110
|
- **the implementer, when the task is built:** `approach` (how it was built, how the pieces fit together, why this way and not the alternatives it weighed); `changes` — every file touched, with what changed in it and why; `testCases` — every named case with its expected and actual result, the result leading with `PASS` or `FAIL` (`"PASS — 0→74 km/h on held W"`); `problems` — each failed attempt or dead end, with what failed, the root cause and the fix; `notes` for a future maintainer; `timing.build`;
|
|
109
111
|
- **the verifier, while it checks:** `acceptance` — every Acceptance item with its verdict and the evidence it rests on (command output, the screenshot, the line read); `liveCheck` — what it looked at, on which engine, at what resolution, and how it judged it; `timing.verify`;
|
|
@@ -121,7 +123,7 @@ The snapshots are how a human sees what was built, so choose them for meaning, n
|
|
|
121
123
|
- **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.
|
|
122
124
|
- **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, no frame per iteration, and a failed attempt only when it explains a decision (say so in the caption).
|
|
123
125
|
- **Who takes them.** At the start of the first run, before T1 changes anything, take the **plan-wide "before"** (`snapshots/plan-before.png`) from the camera or viewport that will best show the finished feature — the starting state, even if that is an empty scene or the old page; skip it only when the plan has nothing to see. The implementer saves a "before" frame before the first change of a visual phase, and saves milestone frames while it builds — it is already capturing to iterate, so it keeps the meaningful ones instead of discarding them. The verifier adds the verified final frames from its live session. You pick and order them into the dashboard. Frames come from sessions and exports the work already runs — never an extra page session or re-export just for a picture.
|
|
124
|
-
- **Files.** `snapshots/T<n>-<NN>-<stage>.png` (phase-level: `P<N>-<NN>-<stage>.png`), at most about 1600 px wide; prefer JPEG or WebP for large scenes. Unity frames come through the bridge's camera capture, browser frames through the browser tool.
|
|
126
|
+
- **Files.** `snapshots/T<n>-<NN>-<stage>.png` (phase-level: `P<N>-<NN>-<stage>.png`), at most about 1600 px wide; prefer JPEG or WebP for large scenes. Unity frames come through the bridge's camera capture, browser frames through the browser tool. Each frame reaches the dashboard through `dashboard.mjs snapshot` (task `T<n>`, phase `P<N>` or `plan`); a subagent without the helper returns its paths and captions and you add them.
|
|
125
127
|
|
|
126
128
|
## Work fast
|
|
127
129
|
|
|
@@ -151,7 +153,7 @@ An unattended run: **nobody is there to answer, and nothing waits for anyone's a
|
|
|
151
153
|
### Never stop
|
|
152
154
|
|
|
153
155
|
- **The run ends only when the work queue is empty** — every task in it `- [x]` or deferred. The queue is the range asked for (`T3-T7`, `T12-`, `NEXT:<n>`), or every remaining task for `ALL` or no task id. Before ending, re-read the plan: an unticked, undeferred task in the queue means you are not done.
|
|
154
|
-
- **Ending your turn is stopping.** A finished task or phase, a
|
|
156
|
+
- **Ending your turn is stopping.** A finished task or phase, a milestone worth reporting, a long session, many tasks done, a compaction, a tool error, an ambiguity, a hard external blocker — none of these ends the turn. Narrate the boundary in one console line and start the next phase in the same turn. The only mid-queue turn end is waiting on a background job or subagent that will notify you, and that message is one status line (`waiting on T9 verifier`), never a question or a summary inviting a reply.
|
|
155
157
|
- **The only early exits — exactly four:** the plan file is missing; a range endpoint does not exist or is reversed (a typo the user must fix — say so and end); the brief names a stop point (`stop after T5`, `stop before the Unity tasks`) — stop there; the user tells you to stop during the run. Nothing else. An Agent Reference that cannot be read → retry 3×, then continue on what you know and log it. A missing Pro license, an account, a credential or a sign-in only the user has → defer the tasks that need it and keep running every task that does not.
|
|
156
158
|
- After a compaction, re-read the plan and the run log and continue from the first unticked, undeferred task.
|
|
157
159
|
|
|
@@ -162,7 +164,7 @@ An unattended run: **nobody is there to answer, and nothing waits for anyone's a
|
|
|
162
164
|
- **Permission denied:** a tool call the host's permission mode refuses is respected, never worked around — log it, defer only that step with `permission denied: <action>`, and continue with everything else. The README's non-prompting permission mode is how the user avoids these.
|
|
163
165
|
- **Defer, don't stall.** A task that cannot pass keeps `- [ ]` and gets ` ⏭️ DEFERRED (auto-pilot): <reason>` appended to its line; continue. A dependent that cannot proceed is deferred `blocked by T<n>`. When the queue is done, make one more pass over the deferred tasks; one that now passes loses the marker and gets its tick.
|
|
164
166
|
- **Safety.** Never push, force-push, deploy, publish, spend money, or delete/overwrite anything outside the plan's scope unless the plan explicitly says so — defer that step instead. Asset generation the plan or spec explicitly calls for (images, textures, audio, video, 3D through the documented generation tools) is in scope: do it. Never `git init`.
|
|
165
|
-
- **
|
|
166
|
-
- **Context.** Implement each phase in a fresh implementer subagent (it builds and tests; keep it for that phase's fix loop), so you only orchestrate: read plan → implementer → verifier → tick →
|
|
167
|
-
- **Run log** — `documents/<slug>_autopilot.md` beside the plan, appended per run: the `⏱` lines from *Clock every run* and completed/total; one line per task (outcome, attempts, tests, verifier, files,
|
|
168
|
-
- **Exit report** — only once the queue is empty: tasks completed, completed/total, deferred tasks with reasons, decisions logged and the run-log path, the dashboard path,
|
|
167
|
+
- **No commits.** Never commit, stage, stash, switch branches or push — not per task, not per phase, not at run end. Every change stays in the working tree for the user, who commits when they choose. Uncommitted changes that are not yours → leave them untouched; never ask about them.
|
|
168
|
+
- **Context.** Implement each phase in a fresh implementer subagent (it builds and tests; keep it for that phase's fix loop), so you only orchestrate: read plan → implementer → verifier → tick → log → next phase. The plan's checkboxes and the run log are the only state — re-read them at each phase boundary and after a compaction.
|
|
169
|
+
- **Run log** — `documents/<slug>_autopilot.md` beside the plan, appended per run: the `⏱` lines from *Clock every run* and completed/total; one line per task (outcome, attempts, tests, verifier, files, done time); one line per decision; deferred tasks with what a human should look at first. Narrate the same boundaries to the console: `▶ [auto-pilot] T12/50 — <title>`, `✅ … verified`, `⏭️ … deferred — <reason>`.
|
|
170
|
+
- **Exit report** — only once the queue is empty: tasks completed, completed/total, deferred tasks with reasons, decisions logged and the run-log path, the dashboard path, that every change is left uncommitted for the user, whether the plan is done. It states results; it asks nothing. Re-running the same command resumes and re-attempts deferred tasks.
|
|
@@ -8,12 +8,19 @@
|
|
|
8
8
|
*
|
|
9
9
|
* node dashboard.mjs live <feature-folder> --task T19 --role implementer --activity "…" [--phase 7] [--step "…"]… [--reset] [--title "…"]
|
|
10
10
|
* node dashboard.mjs task <feature-folder> <task-id> --set '{"status":"built","summary":"…"}' [--note "why an earlier result changed" --by T21]
|
|
11
|
+
* node dashboard.mjs snapshot <feature-folder> <T7|P2|plan> --src snapshots/T7-01-stage.png --caption "…" [--title "…"] [--source unity]
|
|
12
|
+
* (comparison: --before snapshots/a.png --after snapshots/b.png [--before-caption …] [--after-caption …];
|
|
13
|
+
* progression: --frame "snapshots/x.png|stage|caption" repeated)
|
|
11
14
|
* node dashboard.mjs activity <feature-folder> "Phase 2 verified — T4–T6 PASS"
|
|
12
15
|
* node dashboard.mjs status <feature-folder> in-progress|paused|complete|incomplete
|
|
13
16
|
* node dashboard.mjs check <feature-folder>
|
|
14
17
|
* node dashboard.mjs watch <feature-folder> [--watch <folder>]… [--interval-seconds 60] [--quiet-minutes 10] [--stall-minutes 30] [--max-hours 12]
|
|
15
18
|
*
|
|
16
19
|
* <feature-folder> is .agents/specs/<slug>. Timestamps come from this machine's local clock.
|
|
20
|
+
*
|
|
21
|
+
* Snapshots go in only through `snapshot`. `task --set` and `check` refuse any snapshot entry the page cannot show —
|
|
22
|
+
* an image under `path` (or `file`, `image`, …) instead of `src`, or a `src` that is not a file under the feature
|
|
23
|
+
* folder — because such an entry renders as "No snapshot".
|
|
17
24
|
*/
|
|
18
25
|
import { existsSync, readFileSync, readdirSync, renameSync, statSync, writeFileSync } from 'node:fs';
|
|
19
26
|
import { basename, join, relative } from 'node:path';
|
|
@@ -30,6 +37,17 @@ const TASK_LIST_FIELDS = ['files', 'decisions', 'snapshots', 'updates'];
|
|
|
30
37
|
const TASK_OBJECT_FIELDS = ['tests', 'details'];
|
|
31
38
|
/** Statuses that mean a task is being worked on right now. */
|
|
32
39
|
const ACTIVE_TASK_STATUSES = new Set(['in-progress', 'built', 'verifying']);
|
|
40
|
+
/** Where a snapshot's image may come from. */
|
|
41
|
+
const SNAPSHOT_SOURCES = ['browser', 'unity', 'blender', 'reference'];
|
|
42
|
+
/** Keys agents reach for instead of `src`; the page reads none of them, so the image never shows. */
|
|
43
|
+
const WRONG_IMAGE_KEYS = ['path', 'file', 'image', 'url', 'href'];
|
|
44
|
+
/** The three snapshot shapes, quoted in every refusal so the writer can fix the entry in one go. */
|
|
45
|
+
const SNAPSHOT_SHAPES_HELP = [
|
|
46
|
+
'still { "title", "caption", "source", "src": "snapshots/T3-01-stage.png", "updates": [] }',
|
|
47
|
+
'comparison { "title", "caption", "source", "before": { "src", "caption" }, "after": { "src", "caption" }, "updates": [] }',
|
|
48
|
+
'progression { "title", "caption", "source", "frames": [{ "src", "stage", "caption", "task", "at" }], "updates": [] }',
|
|
49
|
+
'Easier: node dashboard.mjs snapshot <feature-folder> <T3|P1|plan> --src snapshots/… --caption "…" builds the entry for you.',
|
|
50
|
+
].join('\n ');
|
|
33
51
|
|
|
34
52
|
const [command, featureFolder, ...rest] = process.argv.slice(2);
|
|
35
53
|
|
|
@@ -67,6 +85,10 @@ function readData(path) {
|
|
|
67
85
|
* @param {any} data The value to write.
|
|
68
86
|
*/
|
|
69
87
|
function writeData(path, prefix, data) {
|
|
88
|
+
// Every dashboard write repairs snapshot entries first, so an image filed under `path` (or any key the page never
|
|
89
|
+
// reads) can never reach the page as "No snapshot", whoever wrote it.
|
|
90
|
+
if (data && Array.isArray(data.phases)) repairSnapshots(data);
|
|
91
|
+
if (data && Array.isArray(data.decisions)) repairDecisions(data);
|
|
70
92
|
const temporaryPath = `${path}.${process.pid}.tmp`;
|
|
71
93
|
writeFileSync(temporaryPath, `${prefix} = ${JSON.stringify(data, null, 2)};\n`, 'utf8');
|
|
72
94
|
renameSync(temporaryPath, path);
|
|
@@ -163,6 +185,12 @@ function writeTask(folder, argumentList) {
|
|
|
163
185
|
if (!task) throw new Error(`task ${taskId} is not in ${dashboardPath} — sync the dashboard with the plan first`);
|
|
164
186
|
const changes = JSON.parse(options.set);
|
|
165
187
|
checkTaskShape(changes);
|
|
188
|
+
if (Array.isArray(changes.snapshots)) {
|
|
189
|
+
const repairs = repairSnapshotList(changes.snapshots, `${taskId}.snapshots`);
|
|
190
|
+
repairs.forEach((repair) => console.log(`repaired ${repair}`));
|
|
191
|
+
const problems = changes.snapshots.flatMap((snapshot, index) => snapshotProblems(folder, snapshot, `${taskId}.snapshots[${index}]`));
|
|
192
|
+
if (problems.length) throw new Error(snapshotRefusal(problems));
|
|
193
|
+
}
|
|
166
194
|
Object.assign(task, changes);
|
|
167
195
|
const now = localTime();
|
|
168
196
|
if (typeof options.note === 'string') {
|
|
@@ -188,6 +216,238 @@ function checkTaskShape(changes) {
|
|
|
188
216
|
}
|
|
189
217
|
}
|
|
190
218
|
|
|
219
|
+
/**
|
|
220
|
+
* Lists what is wrong with one snapshot entry: an unknown shape, an image under a key the page never reads
|
|
221
|
+
* (`path` instead of `src` — the page then shows "No snapshot"), or an image file that is not on disk.
|
|
222
|
+
* @param {string} folder The feature folder; `src` paths are relative to it.
|
|
223
|
+
* @param {any} snapshot The entry.
|
|
224
|
+
* @param {string} where Where the entry sits, for the message, e.g. `T3.snapshots[0]`.
|
|
225
|
+
* @returns {string[]} One line per problem; empty when the entry renders.
|
|
226
|
+
*/
|
|
227
|
+
function snapshotProblems(folder, snapshot, where) {
|
|
228
|
+
if (!snapshot || typeof snapshot !== 'object' || Array.isArray(snapshot)) return [`${where} is not an object`];
|
|
229
|
+
const problems = [];
|
|
230
|
+
const checkImage = (image, imageWhere) => {
|
|
231
|
+
if (!image || typeof image !== 'object') {
|
|
232
|
+
problems.push(`${imageWhere} is missing`);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const wrongKey = WRONG_IMAGE_KEYS.find((key) => key in image);
|
|
236
|
+
if (wrongKey) problems.push(`${imageWhere} has "${wrongKey}" — the page reads only "src"; rename it`);
|
|
237
|
+
if (typeof image.src !== 'string' || !image.src) {
|
|
238
|
+
if (!wrongKey) problems.push(`${imageWhere} has no "src"`);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (/^[a-z]+:/i.test(image.src)) return;
|
|
242
|
+
if (!existsSync(join(folder, image.src))) problems.push(`${imageWhere}.src "${image.src}" is not a file under ${folder}`);
|
|
243
|
+
};
|
|
244
|
+
if (Array.isArray(snapshot.frames)) {
|
|
245
|
+
if (!snapshot.frames.length) problems.push(`${where}.frames is empty`);
|
|
246
|
+
snapshot.frames.forEach((frame, index) => checkImage(frame, `${where}.frames[${index}]`));
|
|
247
|
+
} else if (snapshot.before !== undefined || snapshot.after !== undefined) {
|
|
248
|
+
checkImage(snapshot.before, `${where}.before`);
|
|
249
|
+
checkImage(snapshot.after, `${where}.after`);
|
|
250
|
+
} else {
|
|
251
|
+
checkImage(snapshot, where);
|
|
252
|
+
}
|
|
253
|
+
if (snapshot.source !== undefined && !SNAPSHOT_SOURCES.includes(snapshot.source)) {
|
|
254
|
+
problems.push(`${where}.source "${snapshot.source}" must be one of ${SNAPSHOT_SOURCES.join(', ')}`);
|
|
255
|
+
}
|
|
256
|
+
if (snapshot.updates !== undefined && !Array.isArray(snapshot.updates)) problems.push(`${where}.updates must be a list`);
|
|
257
|
+
return problems;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Builds the refusal message for bad snapshot entries, quoting the shapes the page renders.
|
|
262
|
+
* @param {string[]} problems What is wrong, one line each.
|
|
263
|
+
* @returns {string}
|
|
264
|
+
*/
|
|
265
|
+
function snapshotRefusal(problems) {
|
|
266
|
+
return `refused — these snapshots would show "No snapshot" on the page:\n ${problems.join('\n ')}\nThe shapes:\n ${SNAPSHOT_SHAPES_HELP}`;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Finds the snapshot list a target names: a task (`T3`, `T12.2`), a phase (`P2`) or the plan-wide After Action
|
|
271
|
+
* Report (`plan`).
|
|
272
|
+
* @param {any} dashboard The dashboard data.
|
|
273
|
+
* @param {string} target The target.
|
|
274
|
+
* @returns {any[]} The live list inside `dashboard`, created when it was missing.
|
|
275
|
+
*/
|
|
276
|
+
function snapshotListFor(dashboard, target) {
|
|
277
|
+
if (target === 'plan') {
|
|
278
|
+
dashboard.afterAction = dashboard.afterAction && typeof dashboard.afterAction === 'object' ? dashboard.afterAction : {};
|
|
279
|
+
if (!Array.isArray(dashboard.afterAction.snapshots)) dashboard.afterAction.snapshots = [];
|
|
280
|
+
return dashboard.afterAction.snapshots;
|
|
281
|
+
}
|
|
282
|
+
const phaseMatch = /^P(\d+)$/i.exec(target);
|
|
283
|
+
const owner = phaseMatch
|
|
284
|
+
? (dashboard.phases || []).find((phase) => phase.number === Number(phaseMatch[1]))
|
|
285
|
+
: findTask(dashboard, target);
|
|
286
|
+
if (!owner) throw new Error(`no ${phaseMatch ? 'phase' : 'task'} "${target}" in the dashboard — sync it with the plan first`);
|
|
287
|
+
if (!Array.isArray(owner.snapshots)) owner.snapshots = [];
|
|
288
|
+
return owner.snapshots;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Appends one snapshot — a still (`--src`), a comparison (`--before` and `--after`) or a progression (`--frame`,
|
|
293
|
+
* repeated, each `src|stage|caption`) — to a task, a phase or the plan, building the shape the page renders and
|
|
294
|
+
* refusing an image that is not on disk. This is the way to add snapshots: nobody writes snapshot JSON by hand.
|
|
295
|
+
* @param {string} folder The feature folder.
|
|
296
|
+
* @param {string[]} argumentList The target and options.
|
|
297
|
+
*/
|
|
298
|
+
function writeSnapshot(folder, argumentList) {
|
|
299
|
+
const { options, positional } = parseOptions(argumentList, ['frame']);
|
|
300
|
+
const [target] = positional;
|
|
301
|
+
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]';
|
|
302
|
+
if (!target) throw new Error(usage);
|
|
303
|
+
const caption = typeof options.caption === 'string' ? options.caption : '';
|
|
304
|
+
const snapshot = { title: typeof options.title === 'string' ? options.title : caption, caption, source: typeof options.source === 'string' ? options.source : 'browser' };
|
|
305
|
+
if (typeof options.src === 'string') {
|
|
306
|
+
snapshot.src = options.src;
|
|
307
|
+
} else if (typeof options.before === 'string' && typeof options.after === 'string') {
|
|
308
|
+
snapshot.before = { src: options.before, caption: typeof options['before-caption'] === 'string' ? options['before-caption'] : 'Before' };
|
|
309
|
+
snapshot.after = { src: options.after, caption: typeof options['after-caption'] === 'string' ? options['after-caption'] : 'After' };
|
|
310
|
+
} else if (options.frame.length) {
|
|
311
|
+
const now = localTime();
|
|
312
|
+
snapshot.frames = options.frame.map((frame) => {
|
|
313
|
+
const [src, stage = '', frameCaption = ''] = String(frame).split('|');
|
|
314
|
+
return { src, stage, caption: frameCaption, task: typeof options.task === 'string' ? options.task : target, at: now.clock };
|
|
315
|
+
});
|
|
316
|
+
} else {
|
|
317
|
+
throw new Error(usage);
|
|
318
|
+
}
|
|
319
|
+
snapshot.updates = [];
|
|
320
|
+
const problems = snapshotProblems(folder, snapshot, target);
|
|
321
|
+
if (problems.length) throw new Error(snapshotRefusal(problems));
|
|
322
|
+
const { dashboardPath } = dataPaths(folder);
|
|
323
|
+
const { prefix, data } = readData(dashboardPath);
|
|
324
|
+
snapshotListFor(data, target).push(snapshot);
|
|
325
|
+
data.updatedAt = localTime().stamp;
|
|
326
|
+
writeData(dashboardPath, prefix, data);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Moves an image filed under a key the page never reads (`path`, `file`, `image`, `url`, `href`) to `src`.
|
|
331
|
+
* @param {any} image A still, or a comparison's `before` / `after`, or a progression frame.
|
|
332
|
+
* @param {string} where Where the image sits, for the repair report.
|
|
333
|
+
* @returns {string[]} One line per repair made.
|
|
334
|
+
*/
|
|
335
|
+
function repairImage(image, where) {
|
|
336
|
+
if (!image || typeof image !== 'object' || Array.isArray(image)) return [];
|
|
337
|
+
const wrongKey = WRONG_IMAGE_KEYS.find((key) => typeof image[key] === 'string' && image[key]);
|
|
338
|
+
if (!wrongKey) return [];
|
|
339
|
+
if (typeof image.src !== 'string' || !image.src) image.src = image[wrongKey];
|
|
340
|
+
WRONG_IMAGE_KEYS.forEach((key) => delete image[key]);
|
|
341
|
+
return [`${where}: "${wrongKey}" → "src"`];
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Repairs every entry of one snapshot list in place, so each renders an image: a bare path string becomes a still,
|
|
346
|
+
* an image under a wrong key moves to `src`, and an unknown `source` becomes `browser`.
|
|
347
|
+
* @param {any[]} list The snapshot list.
|
|
348
|
+
* @param {string} owner Where the list sits, e.g. `T3.snapshots`.
|
|
349
|
+
* @returns {string[]} One line per repair made.
|
|
350
|
+
*/
|
|
351
|
+
function repairSnapshotList(list, owner) {
|
|
352
|
+
const repairs = [];
|
|
353
|
+
list.forEach((snapshot, index) => {
|
|
354
|
+
const where = `${owner}[${index}]`;
|
|
355
|
+
if (typeof snapshot === 'string' && snapshot) {
|
|
356
|
+
list[index] = { title: '', caption: '', source: 'browser', src: snapshot, updates: [] };
|
|
357
|
+
repairs.push(`${where}: a bare path → a still`);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
repairs.push(...repairSnapshot(snapshot, where));
|
|
361
|
+
});
|
|
362
|
+
return repairs;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Repairs one snapshot entry in place (see `repairSnapshotList`).
|
|
367
|
+
* @param {any} snapshot A still, comparison or progression.
|
|
368
|
+
* @param {string} where Where it sits.
|
|
369
|
+
* @returns {string[]} One line per repair made.
|
|
370
|
+
*/
|
|
371
|
+
function repairSnapshot(snapshot, where) {
|
|
372
|
+
if (!snapshot || typeof snapshot !== 'object' || Array.isArray(snapshot)) return [];
|
|
373
|
+
const repairs = [];
|
|
374
|
+
if (Array.isArray(snapshot.frames)) {
|
|
375
|
+
snapshot.frames.forEach((frame, index) => repairs.push(...repairImage(frame, `${where}.frames[${index}]`)));
|
|
376
|
+
} else if (snapshot.before !== undefined || snapshot.after !== undefined) {
|
|
377
|
+
repairs.push(...repairImage(snapshot.before, `${where}.before`), ...repairImage(snapshot.after, `${where}.after`));
|
|
378
|
+
} else {
|
|
379
|
+
repairs.push(...repairImage(snapshot, where));
|
|
380
|
+
}
|
|
381
|
+
if (snapshot.source !== undefined && !SNAPSHOT_SOURCES.includes(snapshot.source)) {
|
|
382
|
+
repairs.push(`${where}.source "${snapshot.source}" → "browser"`);
|
|
383
|
+
snapshot.source = 'browser';
|
|
384
|
+
}
|
|
385
|
+
return repairs;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Repairs every snapshot in the dashboard in place: the After Action Report's list and comparison, each phase's and
|
|
390
|
+
* each task's list.
|
|
391
|
+
* @param {any} dashboard The dashboard data.
|
|
392
|
+
* @returns {string[]} One line per repair made.
|
|
393
|
+
*/
|
|
394
|
+
function repairSnapshots(dashboard) {
|
|
395
|
+
const repairs = [];
|
|
396
|
+
const repairList = (list, owner) => {
|
|
397
|
+
if (Array.isArray(list)) repairs.push(...repairSnapshotList(list, owner));
|
|
398
|
+
};
|
|
399
|
+
if (dashboard.afterAction && typeof dashboard.afterAction === 'object') {
|
|
400
|
+
repairList(dashboard.afterAction.snapshots, 'afterAction.snapshots');
|
|
401
|
+
repairs.push(...repairSnapshot(dashboard.afterAction.comparison, 'afterAction.comparison'));
|
|
402
|
+
}
|
|
403
|
+
for (const phase of dashboard.phases || []) {
|
|
404
|
+
repairList(phase.snapshots, `P${phase.number}.snapshots`);
|
|
405
|
+
for (const task of phase.tasks || []) repairList(task.snapshots, `${task.id}.snapshots`);
|
|
406
|
+
}
|
|
407
|
+
return repairs;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Repairs the plan-level decisions in place: a decision written as plain text (`"D3 — The filter is …"`) renders as
|
|
412
|
+
* an empty row, so it becomes `{ "id": "D3", "text": "The filter is …", "updates": [] }`. A leading parenthesis after
|
|
413
|
+
* the id (`"D9 (confirmed by the user) — …"`) stays in the text; text with no leading id keeps an empty id.
|
|
414
|
+
* @param {any} dashboard The dashboard data.
|
|
415
|
+
* @returns {string[]} One line per repair made.
|
|
416
|
+
*/
|
|
417
|
+
function repairDecisions(dashboard) {
|
|
418
|
+
const repairs = [];
|
|
419
|
+
if (!Array.isArray(dashboard.decisions)) return repairs;
|
|
420
|
+
dashboard.decisions = dashboard.decisions.map((decision, index) => {
|
|
421
|
+
if (typeof decision !== 'string') return decision;
|
|
422
|
+
const match = decision.match(/^([A-Z]+\d+[a-z]?)(\s*\([^)]*\))?\s+[—–-]\s+([\s\S]*)$/);
|
|
423
|
+
const id = match ? match[1] : '';
|
|
424
|
+
const text = match ? `${match[2] ? `${match[2].trim()} ` : ''}${match[3]}` : decision;
|
|
425
|
+
repairs.push(`decisions[${index}]: plain text → { "id": "${id}", "text" }`);
|
|
426
|
+
return { id, text, updates: [] };
|
|
427
|
+
});
|
|
428
|
+
return repairs;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Every snapshot entry in the dashboard with where it sits: the After Action Report, each phase and each task.
|
|
433
|
+
* @param {any} dashboard The dashboard data.
|
|
434
|
+
* @returns {{ snapshot: any, where: string }[]}
|
|
435
|
+
*/
|
|
436
|
+
function allSnapshots(dashboard) {
|
|
437
|
+
const entries = [];
|
|
438
|
+
const collect = (list, owner) => (Array.isArray(list) ? list : []).forEach((snapshot, index) => entries.push({ snapshot, where: `${owner}.snapshots[${index}]` }));
|
|
439
|
+
if (dashboard.afterAction) {
|
|
440
|
+
collect(dashboard.afterAction.snapshots, 'afterAction');
|
|
441
|
+
const comparison = dashboard.afterAction.comparison;
|
|
442
|
+
if (comparison) entries.push({ snapshot: comparison, where: 'afterAction.comparison' });
|
|
443
|
+
}
|
|
444
|
+
for (const phase of dashboard.phases || []) {
|
|
445
|
+
collect(phase.snapshots, `P${phase.number}`);
|
|
446
|
+
for (const task of phase.tasks || []) collect(task.snapshots, task.id);
|
|
447
|
+
}
|
|
448
|
+
return entries;
|
|
449
|
+
}
|
|
450
|
+
|
|
191
451
|
/**
|
|
192
452
|
* Appends one milestone to the activity log.
|
|
193
453
|
* @param {string} folder The feature folder.
|
|
@@ -222,14 +482,28 @@ function writeStatus(folder, argumentList) {
|
|
|
222
482
|
}
|
|
223
483
|
|
|
224
484
|
/**
|
|
225
|
-
* Confirms both data files parse
|
|
485
|
+
* Confirms both data files parse and every snapshot entry will show its image; fails listing each one that would
|
|
486
|
+
* show "No snapshot".
|
|
226
487
|
* @param {string} folder The feature folder.
|
|
488
|
+
* @throws {Error} When a file does not parse or a snapshot entry is broken.
|
|
227
489
|
*/
|
|
228
490
|
function checkData(folder) {
|
|
229
491
|
const { dashboardPath, livePath } = dataPaths(folder);
|
|
230
|
-
readData(dashboardPath);
|
|
492
|
+
const { prefix, data } = readData(dashboardPath);
|
|
231
493
|
if (existsSync(livePath)) readData(livePath);
|
|
232
|
-
|
|
494
|
+
const repairs = repairSnapshots(data);
|
|
495
|
+
const decisionRepairs = repairDecisions(data);
|
|
496
|
+
if (repairs.length || decisionRepairs.length) writeData(dashboardPath, prefix, data);
|
|
497
|
+
if (repairs.length) {
|
|
498
|
+
console.log(`repaired ${repairs.length} snapshot entr${repairs.length === 1 ? 'y' : 'ies'} the page could not show:\n ${repairs.join('\n ')}`);
|
|
499
|
+
}
|
|
500
|
+
if (decisionRepairs.length) {
|
|
501
|
+
console.log(`repaired ${decisionRepairs.length} decision${decisionRepairs.length === 1 ? '' : 's'} written as plain text:\n ${decisionRepairs.join('\n ')}`);
|
|
502
|
+
}
|
|
503
|
+
const snapshots = allSnapshots(data);
|
|
504
|
+
const problems = snapshots.flatMap(({ snapshot, where }) => snapshotProblems(folder, snapshot, where));
|
|
505
|
+
if (problems.length) throw new Error(snapshotRefusal(problems));
|
|
506
|
+
console.log(`ok: ${dashboardPath}${existsSync(livePath) ? ` and ${livePath}` : ''} parse; ${snapshots.length} snapshot entries all show an image`);
|
|
233
507
|
}
|
|
234
508
|
|
|
235
509
|
/**
|
|
@@ -316,6 +590,7 @@ async function watch(folder, argumentList) {
|
|
|
316
590
|
console.log(`watchdog: dashboard status is "${dashboard.status}" — the run is over, exiting`);
|
|
317
591
|
return;
|
|
318
592
|
}
|
|
593
|
+
if (dashboard) repairWrittenSnapshots(dashboardPath);
|
|
319
594
|
if (dashboard && existsSync(livePath)) {
|
|
320
595
|
try {
|
|
321
596
|
checkLive(dashboard, livePath, roots, projectRoot, quietMinutes, stallMinutes);
|
|
@@ -327,6 +602,23 @@ async function watch(folder, argumentList) {
|
|
|
327
602
|
}
|
|
328
603
|
}
|
|
329
604
|
|
|
605
|
+
/**
|
|
606
|
+
* Watchdog repair: a snapshot or decision an agent wrote around the helper (a hand edit, its own script) is repaired
|
|
607
|
+
* within a minute, re-read just before the write so nothing the agent wrote meanwhile is lost.
|
|
608
|
+
* @param {string} dashboardPath The dashboard data file.
|
|
609
|
+
*/
|
|
610
|
+
function repairWrittenSnapshots(dashboardPath) {
|
|
611
|
+
try {
|
|
612
|
+
const { prefix, data } = readData(dashboardPath);
|
|
613
|
+
const repairs = [...repairSnapshots(data), ...repairDecisions(data)];
|
|
614
|
+
if (!repairs.length) return;
|
|
615
|
+
writeData(dashboardPath, prefix, data);
|
|
616
|
+
console.log(`watchdog: repaired ${repairs.length} entr${repairs.length === 1 ? 'y' : 'ies'} — ${repairs.join('; ')}`);
|
|
617
|
+
} catch (error) {
|
|
618
|
+
console.log(`watchdog: snapshot repair skipped a round — ${error.message}`);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
330
622
|
/**
|
|
331
623
|
* One watchdog round (see `watch`).
|
|
332
624
|
* @param {any} dashboard The dashboard data.
|
|
@@ -383,10 +675,10 @@ function checkLive(dashboard, livePath, roots, projectRoot, quietMinutes, stallM
|
|
|
383
675
|
console.log(`watchdog ${clock}: ${activity}`);
|
|
384
676
|
}
|
|
385
677
|
|
|
386
|
-
const commands = { live: writeLive, task: writeTask, activity: writeActivity, status: writeStatus, check: checkData, watch };
|
|
678
|
+
const commands = { live: writeLive, task: writeTask, snapshot: writeSnapshot, activity: writeActivity, status: writeStatus, check: checkData, watch };
|
|
387
679
|
|
|
388
680
|
if (!commands[command] || !featureFolder) {
|
|
389
|
-
console.error('usage: node dashboard.mjs <live|task|activity|status|check|watch> <feature-folder> [options] — see the header of this file');
|
|
681
|
+
console.error('usage: node dashboard.mjs <live|task|snapshot|activity|status|check|watch> <feature-folder> [options] — see the header of this file');
|
|
390
682
|
process.exit(2);
|
|
391
683
|
}
|
|
392
684
|
try {
|