@babylonjs-toolkit/agent 1.2.1 → 1.2.2

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Feature dashboard helper for bt-execute: the one way agents write a feature's dashboard data, plus the
4
- * watchdog that keeps the live status honest while an agent is busy with a long task.
3
+ * Feature dashboard helper for bt-execute: the one way agents write a feature's dashboard data, the writer of the
4
+ * live status, the gate that catches a skipped deliverable, and a watchdog for manual use.
5
5
  *
6
6
  * Every write reads the data file, parses its strict JSON, changes it and writes it back atomically (a temp file
7
7
  * renamed over the original), so the page can never load a half-written file and no hand edit can break it.
@@ -18,15 +18,36 @@
18
18
  *
19
19
  * <feature-folder> is .agents/specs/<slug>. Timestamps come from this machine's local clock.
20
20
  *
21
+ * The live file (`documents/<slug>_live.js`) is written by this helper, not by agents: every `task --set` that
22
+ * changes a task's `status` rewrites it from that change (the task, its phase, the role its status implies, one
23
+ * sentence on its new state plus the summary's first sentence, and a step in its log), and every `status` write
24
+ * records the run starting or ending. A `--set` without `status` leaves it untouched. `live` remains for a hand
25
+ * write; `watch` is a manual tool — no skill launches it.
26
+ *
21
27
  * Snapshots go in only through `snapshot`. `task --set` and `check` refuse any snapshot entry the page cannot show —
22
28
  * an image under `path` (or `file`, `image`, …) instead of `src`, or a `src` that is not a file under the feature
23
29
  * folder — because such an entry renders as "No snapshot".
30
+ *
31
+ * `check` is the gate at every phase boundary and at run end. Beyond the snapshots it fails, listing every problem in
32
+ * one message, when a deliverable was skipped: a `documents/<slug>_plan.md` without `dashboard.html`, the dashboard
33
+ * data or the live file; dashboard tasks that differ from the plan's checklist (ids or order); a `complete` status
34
+ * while the plan has an unticked box or without `documents/<slug>_summary.html`; a visual task (kind live, game or
35
+ * 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.
24
37
  */
25
38
  import { existsSync, readFileSync, readdirSync, renameSync, statSync, writeFileSync } from 'node:fs';
26
39
  import { basename, join, relative } from 'node:path';
27
40
 
28
41
  /** How many entries a task's live step log keeps. */
29
42
  const MAXIMUM_LIVE_STEPS = 12;
43
+ /** The prefix a live file starts with when the helper creates it. */
44
+ const LIVE_PREFIX = 'window.FEATURE_LIVE';
45
+ /** Who is working on a task in each status — the live file's `role` after a `task` write; anything else is the orchestrator. */
46
+ const ROLE_FOR_TASK_STATUS = { 'in-progress': 'implementer', built: 'implementer', verifying: 'verifier' };
47
+ /** Task kinds whose result is seen on screen, so a `done` task of this kind must have a snapshot. */
48
+ const VISUAL_TASK_KINDS = new Set(['live', 'game', 'unity']);
49
+ /** A plan checklist line: `- [ ] **T3.1** — …` or `- [x] T4 …`; captures the tick mark and the task id. */
50
+ const PLAN_CHECKLIST_LINE = /^\s*[-*]\s+\[([ xX])\]\s+(?:\*\*)?(T\d+(?:\.\d+)*)\b/;
30
51
  /** Folders the watchdog never descends into when looking for signs of work. */
31
52
  const IGNORED_FOLDERS = new Set(['node_modules', '.git', 'Library', 'Temp', 'Logs', 'obj', 'dist', 'build', '.cache', 'profile']);
32
53
  /** How deep the watchdog looks inside each watched folder. */
@@ -129,6 +150,15 @@ function parseOptions(argumentList, repeatable = []) {
129
150
  return { options, positional };
130
151
  }
131
152
 
153
+ /**
154
+ * Reads the live file, or an empty one when it does not exist yet (the next write creates it).
155
+ * @param {string} livePath The live file.
156
+ * @returns {{ prefix: string, data: any }}
157
+ */
158
+ function readLive(livePath) {
159
+ return existsSync(livePath) ? readData(livePath) : { prefix: LIVE_PREFIX, data: {} };
160
+ }
161
+
132
162
  /**
133
163
  * Rewrites the live status: what is happening this minute.
134
164
  * @param {string} folder The feature folder.
@@ -137,7 +167,7 @@ function parseOptions(argumentList, repeatable = []) {
137
167
  function writeLive(folder, argumentList) {
138
168
  const { options } = parseOptions(argumentList, ['step']);
139
169
  const { livePath } = dataPaths(folder);
140
- const existing = existsSync(livePath) ? readData(livePath) : { prefix: 'window.FEATURE_LIVE', data: {} };
170
+ const existing = readLive(livePath);
141
171
  const live = existing.data;
142
172
  const now = localTime();
143
173
  const taskChanged = options.task !== undefined && options.task !== live.task;
@@ -157,21 +187,126 @@ function writeLive(folder, argumentList) {
157
187
  }
158
188
 
159
189
  /**
160
- * Finds a task anywhere in the dashboard data.
190
+ * The first sentence of a text — up to the first `.`, `!` or `?` followed by a space or the end.
191
+ * @param {string} [text] The text, e.g. a task summary.
192
+ * @returns {string} The sentence, trimmed; the whole text when it has no sentence end; `""` for no text.
193
+ */
194
+ function firstSentence(text) {
195
+ const trimmed = String(text || '').trim();
196
+ const match = /^[\s\S]*?[.!?](?=\s|$)/.exec(trimmed);
197
+ return match ? match[0] : trimmed;
198
+ }
199
+
200
+ /**
201
+ * One plain-language sentence on a task's state, for the live file.
202
+ * @param {any} task The task, after the change (its `status`, `title`, `attempts`, `deferredReason`).
203
+ * @returns {string}
204
+ */
205
+ function taskStatusSentence(task) {
206
+ const name = task.title ? `${task.id} — ${task.title}` : task.id;
207
+ const attempt = Number(task.attempts) || 1;
208
+ const reason = String(task.deferredReason || '').trim().replace(/[.!?]+$/, '');
209
+ switch (task.status) {
210
+ case 'in-progress':
211
+ return attempt > 1 ? `Fixing ${name} after a failed check (attempt ${attempt}).` : `Building ${name}.`;
212
+ case 'built':
213
+ return `${task.id} is built and its tests pass — waiting for the verifier.`;
214
+ case 'verifying':
215
+ return `The verifier is checking ${name}.`;
216
+ case 'done':
217
+ return `${task.id} passed verification and is done.`;
218
+ case 'deferred':
219
+ return reason ? `${task.id} was deferred: ${reason}.` : `${task.id} was deferred.`;
220
+ case 'failed':
221
+ return `${task.id} failed verification.`;
222
+ case 'pending':
223
+ return `${name} is waiting to start.`;
224
+ default:
225
+ return `${task.id} is now ${task.status}.`;
226
+ }
227
+ }
228
+
229
+ /**
230
+ * Rewrites the live file from a task's status change: its phase, the task, the role its status implies, one sentence
231
+ * on its new state (plus the first sentence of the summary written with it), and that sentence appended to the task's
232
+ * step log — a fresh log when the live file named another task. Creates the live file when it is missing.
233
+ * @param {string} folder The feature folder.
234
+ * @param {number} phaseNumber The number of the phase holding the task.
235
+ * @param {any} task The task, after the change.
236
+ * @param {string} [summary] The summary written in the same change, if any.
237
+ */
238
+ function writeLiveForTask(folder, phaseNumber, task, summary) {
239
+ const { livePath } = dataPaths(folder);
240
+ const { prefix, data: live } = readLive(livePath);
241
+ const now = localTime();
242
+ const summarySentence = firstSentence(summary);
243
+ const activity = summarySentence ? `${taskStatusSentence(task)} ${summarySentence}` : taskStatusSentence(task);
244
+ const steps = live.task === task.id && Array.isArray(live.steps) ? live.steps : [];
245
+ steps.push({ at: now.clock, text: activity });
246
+ writeData(livePath, prefix, {
247
+ updatedAt: now.stamp,
248
+ phase: phaseNumber,
249
+ task: task.id,
250
+ title: '',
251
+ role: ROLE_FOR_TASK_STATUS[task.status] || 'orchestrator',
252
+ activity,
253
+ steps: steps.slice(-MAXIMUM_LIVE_STEPS),
254
+ source: 'agent',
255
+ });
256
+ }
257
+
258
+ /**
259
+ * Rewrites the live file when the run's status changes: a run starting clears the last run's task and steps; a run
260
+ * ending says so (the page hides the live file once the status is no longer in-progress).
261
+ * @param {string} folder The feature folder.
262
+ * @param {string} status The dashboard's new status.
263
+ */
264
+ function writeLiveForRun(folder, status) {
265
+ const { livePath } = dataPaths(folder);
266
+ const { prefix, data: live } = readLive(livePath);
267
+ const now = localTime();
268
+ const starting = status === 'in-progress';
269
+ const title = starting ? 'Run started — preparing the first task' : `Run ended — the plan is ${status}`;
270
+ writeData(livePath, prefix, {
271
+ updatedAt: now.stamp,
272
+ phase: live.phase,
273
+ task: '',
274
+ title,
275
+ role: 'orchestrator',
276
+ activity: `${title}.`,
277
+ steps: [{ at: now.clock, text: `${title}.` }],
278
+ source: 'agent',
279
+ });
280
+ }
281
+
282
+ /**
283
+ * Finds a task anywhere in the dashboard data, with the phase that holds it.
161
284
  * @param {any} dashboard The dashboard data.
162
285
  * @param {string} taskId The task id, e.g. `T12.2`.
163
- * @returns {any | undefined}
286
+ * @returns {{ phase: any, task: any } | undefined}
164
287
  */
165
- function findTask(dashboard, taskId) {
288
+ function findTaskWithPhase(dashboard, taskId) {
166
289
  for (const phase of dashboard.phases || []) {
167
290
  const task = (phase.tasks || []).find((candidate) => candidate.id === taskId);
168
- if (task) return task;
291
+ if (task) return { phase, task };
169
292
  }
170
293
  return undefined;
171
294
  }
172
295
 
173
296
  /**
174
- * Merges fields into one task, optionally recording why an earlier result changed.
297
+ * Finds a task anywhere in the dashboard data.
298
+ * @param {any} dashboard The dashboard data.
299
+ * @param {string} taskId The task id, e.g. `T12.2`.
300
+ * @returns {any | undefined}
301
+ */
302
+ function findTask(dashboard, taskId) {
303
+ const found = findTaskWithPhase(dashboard, taskId);
304
+ return found ? found.task : undefined;
305
+ }
306
+
307
+ /**
308
+ * 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.
175
310
  * @param {string} folder The feature folder.
176
311
  * @param {string[]} argumentList The task id and options.
177
312
  */
@@ -181,8 +316,9 @@ function writeTask(folder, argumentList) {
181
316
  if (!taskId || typeof options.set !== 'string') throw new Error('usage: task <feature-folder> <task-id> --set \'{"status":"built"}\'');
182
317
  const { dashboardPath } = dataPaths(folder);
183
318
  const { prefix, data } = readData(dashboardPath);
184
- const task = findTask(data, taskId);
185
- if (!task) throw new Error(`task ${taskId} is not in ${dashboardPath} — sync the dashboard with the plan first`);
319
+ const found = findTaskWithPhase(data, taskId);
320
+ if (!found) throw new Error(`task ${taskId} is not in ${dashboardPath} — sync the dashboard with the plan first`);
321
+ const { phase, task } = found;
186
322
  const changes = JSON.parse(options.set);
187
323
  checkTaskShape(changes);
188
324
  if (Array.isArray(changes.snapshots)) {
@@ -199,6 +335,7 @@ function writeTask(folder, argumentList) {
199
335
  }
200
336
  data.updatedAt = now.stamp;
201
337
  writeData(dashboardPath, prefix, data);
338
+ if (typeof changes.status === 'string') writeLiveForTask(folder, phase.number, task, changes.summary);
202
339
  }
203
340
 
204
341
  /**
@@ -466,7 +603,7 @@ function writeActivity(folder, argumentList) {
466
603
  }
467
604
 
468
605
  /**
469
- * Sets the dashboard's run status.
606
+ * Sets the dashboard's run status, and records the run starting or ending in the live file.
470
607
  * @param {string} folder The feature folder.
471
608
  * @param {string[]} argumentList The new status.
472
609
  */
@@ -479,16 +616,135 @@ function writeStatus(folder, argumentList) {
479
616
  data.status = status;
480
617
  data.updatedAt = localTime().stamp;
481
618
  writeData(dashboardPath, prefix, data);
619
+ if (status !== 'planned') writeLiveForRun(folder, status);
620
+ }
621
+
622
+ /**
623
+ * Reads a plan's checklist: every `- [ ]` / `- [x]` line that starts with a task id, in file order, skipping fenced
624
+ * code blocks (a plan may quote a checklist as an example).
625
+ * @param {string} planPath The plan file.
626
+ * @returns {{ id: string, ticked: boolean }[]}
627
+ */
628
+ function readPlanChecklist(planPath) {
629
+ const tasks = [];
630
+ let insideFence = false;
631
+ for (const line of readFileSync(planPath, 'utf8').split(/\r?\n/)) {
632
+ if (/^\s*(```|~~~)/.test(line)) {
633
+ insideFence = !insideFence;
634
+ continue;
635
+ }
636
+ const match = insideFence ? null : PLAN_CHECKLIST_LINE.exec(line);
637
+ if (match) tasks.push({ id: match[2], ticked: match[1] !== ' ' });
638
+ }
639
+ return tasks;
482
640
  }
483
641
 
484
642
  /**
485
- * Confirms both data files parse and every snapshot entry will show its image; fails listing each one that would
486
- * show "No snapshot".
643
+ * The feature-folder files a written plan must have beside it.
487
644
  * @param {string} folder The feature folder.
488
- * @throws {Error} When a file does not parse or a snapshot entry is broken.
645
+ * @returns {string[]} One problem per missing file.
646
+ */
647
+ function missingDeliverables(folder) {
648
+ const { slug } = dataPaths(folder);
649
+ const required = [
650
+ ['dashboard.html', `copy it from bt-execute's templates/dashboard/ with {{slug}} replaced`],
651
+ [join('documents', `${slug}_dashboard.js`), 'create it from templates/dashboard/dashboard.template.js and the plan'],
652
+ [join('documents', `${slug}_live.js`), 'create it from templates/dashboard/live.template.js'],
653
+ ];
654
+ return required
655
+ .filter(([file]) => !existsSync(join(folder, file)))
656
+ .map(([file, remedy]) => `the plan has no ${file} — ${remedy}`);
657
+ }
658
+
659
+ /**
660
+ * Compares the dashboard's tasks with the plan's checklist: tasks missing on either side, or the same tasks in a
661
+ * different order.
662
+ * @param {string[]} planIds The plan's task ids, in plan order.
663
+ * @param {string[]} dashboardIds The dashboard's task ids, in page order.
664
+ * @returns {string[]} One problem per kind of mismatch.
665
+ */
666
+ function taskListProblems(planIds, dashboardIds) {
667
+ const missing = planIds.filter((id) => !dashboardIds.includes(id));
668
+ const extra = dashboardIds.filter((id) => !planIds.includes(id));
669
+ const problems = [];
670
+ if (missing.length) problems.push(`plan tasks missing from the dashboard: ${missing.join(', ')} — sync the dashboard with the plan`);
671
+ if (extra.length) problems.push(`dashboard tasks the plan does not have: ${extra.join(', ')} — sync the dashboard with the plan`);
672
+ if (problems.length) return problems;
673
+ const position = planIds.findIndex((id, index) => dashboardIds[index] !== id);
674
+ if (position >= 0) {
675
+ problems.push(`the dashboard lists the tasks in a different order from the plan (position ${position + 1}: plan ${planIds[position]}, dashboard ${dashboardIds[position]}) — sync the dashboard with the plan`);
676
+ }
677
+ return problems;
678
+ }
679
+
680
+ /**
681
+ * The plan checks: the dashboard's tasks match the checklist, a `complete` status is true and has its plan summary,
682
+ * and every ticked task has a verifier result.
683
+ * @param {string} folder The feature folder.
684
+ * @param {any} dashboard The dashboard data.
685
+ * @param {{ id: string, ticked: boolean }[]} planTasks The plan's checklist.
686
+ * @returns {string[]} One line per problem.
687
+ */
688
+ function planProblems(folder, dashboard, planTasks) {
689
+ const { slug } = dataPaths(folder);
690
+ const dashboardTasks = (dashboard.phases || []).flatMap((phase) => phase.tasks || []);
691
+ const problems = taskListProblems(planTasks.map((task) => task.id), dashboardTasks.map((task) => task.id));
692
+ if (dashboard.status === 'complete') {
693
+ const unticked = planTasks.filter((task) => !task.ticked).map((task) => task.id);
694
+ if (unticked.length) problems.push(`status is complete but the plan still has unticked tasks: ${unticked.join(', ')} — set paused or incomplete`);
695
+ const summaryFile = join('documents', `${slug}_summary.html`);
696
+ if (!existsSync(join(folder, summaryFile))) problems.push(`status is complete but ${summaryFile} is missing — write the plan summary`);
697
+ }
698
+ for (const planTask of planTasks.filter((task) => task.ticked)) {
699
+ const dashboardTask = dashboardTasks.find((task) => task.id === planTask.id);
700
+ if (dashboardTask && !dashboardTask.verifier) problems.push(`${planTask.id} is ticked in the plan but has no verifier result on the dashboard`);
701
+ }
702
+ return problems;
703
+ }
704
+
705
+ /**
706
+ * Visual tasks marked `done` with nothing to show for it: no snapshot of their own and no phase or After Action
707
+ * Report progression frame tagged with their id.
708
+ * @param {any} dashboard The dashboard data.
709
+ * @returns {string[]} One line per task.
710
+ */
711
+ function visualTaskProblems(dashboard) {
712
+ const sharedLists = [dashboard.afterAction && dashboard.afterAction.snapshots, ...(dashboard.phases || []).map((phase) => phase.snapshots)];
713
+ const taggedTaskIds = new Set(
714
+ sharedLists
715
+ .flatMap((list) => (Array.isArray(list) ? list : []))
716
+ .flatMap((snapshot) => (snapshot && Array.isArray(snapshot.frames) ? snapshot.frames : []))
717
+ .map((frame) => frame && frame.task),
718
+ );
719
+ return (dashboard.phases || [])
720
+ .flatMap((phase) => phase.tasks || [])
721
+ .filter((task) => task.status === 'done' && VISUAL_TASK_KINDS.has(task.kind))
722
+ .filter((task) => !(Array.isArray(task.snapshots) && task.snapshots.length) && !taggedTaskIds.has(task.id))
723
+ .map((task) => `${task.id} (kind ${task.kind}) is done with no snapshot — add the builder's built frame and the verifier's comparison with \`dashboard.mjs snapshot\``);
724
+ }
725
+
726
+ /**
727
+ * Builds the refusal message for skipped deliverables.
728
+ * @param {string[]} problems What is missing or false, one line each.
729
+ * @returns {string}
730
+ */
731
+ function deliverableRefusal(problems) {
732
+ return `refused — ${problems.length} deliverable problem${problems.length === 1 ? '' : 's'}:\n ${problems.join('\n ')}`;
733
+ }
734
+
735
+ /**
736
+ * The gate at every phase boundary and at run end. Confirms both data files parse and every snapshot entry will show
737
+ * its image, and — when the folder holds the plan — that no deliverable was skipped (see the header). Fails listing
738
+ * every problem in one message.
739
+ * @param {string} folder The feature folder.
740
+ * @throws {Error} When a file does not parse, a snapshot entry is broken or a deliverable is missing or false.
489
741
  */
490
742
  function checkData(folder) {
491
- const { dashboardPath, livePath } = dataPaths(folder);
743
+ const { slug, dashboardPath, livePath } = dataPaths(folder);
744
+ const planPath = join(folder, 'documents', `${slug}_plan.md`);
745
+ const planTasks = existsSync(planPath) ? readPlanChecklist(planPath) : null;
746
+ const missing = planTasks ? missingDeliverables(folder) : [];
747
+ if (missing.length && !existsSync(dashboardPath)) throw new Error(deliverableRefusal(missing));
492
748
  const { prefix, data } = readData(dashboardPath);
493
749
  if (existsSync(livePath)) readData(livePath);
494
750
  const repairs = repairSnapshots(data);
@@ -502,8 +758,11 @@ function checkData(folder) {
502
758
  }
503
759
  const snapshots = allSnapshots(data);
504
760
  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`);
761
+ const deliverables = [...missing, ...visualTaskProblems(data), ...(planTasks ? planProblems(folder, data, planTasks) : [])];
762
+ const refusals = [problems.length ? snapshotRefusal(problems) : '', deliverables.length ? deliverableRefusal(deliverables) : ''].filter(Boolean);
763
+ if (refusals.length) throw new Error(refusals.join('\n'));
764
+ const planNote = planTasks ? `; the dashboard matches the plan's ${planTasks.length} tasks` : '';
765
+ console.log(`ok: ${dashboardPath}${existsSync(livePath) ? ` and ${livePath}` : ''} parse; ${snapshots.length} snapshot entries all show an image${planNote}`);
507
766
  }
508
767
 
509
768
  /**
@@ -526,7 +785,7 @@ function latestChange(roots) {
526
785
  if (depth < MAXIMUM_SCAN_DEPTH && !IGNORED_FOLDERS.has(entry.name)) visit(path, depth + 1);
527
786
  continue;
528
787
  }
529
- // The dashboard's own data files are written by agents and the watchdog itself — not a sign of work.
788
+ // The dashboard's own data files are written by this helper and the watchdog itself — not a sign of work.
530
789
  if (!entry.isFile() || entry.name.endsWith('.tmp') || /_(dashboard|live)\.js$/.test(entry.name)) continue;
531
790
  try {
532
791
  const modified = statSync(path).mtimeMs;
@@ -553,7 +812,8 @@ function parseStamp(stamp) {
553
812
  }
554
813
 
555
814
  /**
556
- * The watchdog. While the dashboard says a run is in progress it checks the live status every interval:
815
+ * The watchdog — a manual tool (no skill launches it; `task` and `status` keep the live file current). While the
816
+ * dashboard says a run is in progress it checks the live status every interval:
557
817
  * - the live status names a task that is already finished while another task is active → it points the live
558
818
  * status at the active task (the agent working on it has not written yet);
559
819
  * - nothing has been written for `quiet-minutes` → it writes a heartbeat naming the latest file that changed in
@@ -5,7 +5,7 @@
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 | at every meaningful step of a run (from `live.template.js`) |
8
+ | `<slug>_live.js` | what is happening this minute — the current task, one sentence, its step log | by bt-execute's helper, never by an agent: every `dashboard.mjs task` write that changes a task's status, and every `status` write (bt-plan creates it from `live.template.js`) |
9
9
 
10
10
  They are **data, not code.** Each file is exactly one line of prefix and one strict-JSON value:
11
11
 
@@ -21,9 +21,11 @@ The status of the plan itself lives in the plan file's checkboxes; the dashboard
21
21
 
22
22
  ## Updating a data file
23
23
 
24
- Use bt-execute's helper — `node <skills>/bt-execute/scripts/dashboard.mjs live|task|activity|status|check|watch <feature-folder> …`
25
- (every option is in its header). It parses, checks field shapes and writes atomically. Its `watch` command is the
26
- watchdog that writes a heartbeat into the live file when an agent has been quiet for 10 minutes.
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 `status`
26
+ commands also rewrite the live file, so agents never write it. `live` remains for a hand write, and `watch` is an
27
+ optional watchdog for manual use (a heartbeat into the live file when nothing has been written for 10 minutes) —
28
+ no skill launches it.
27
29
 
28
30
  ### Fallback — parse, change, write back
29
31
 
@@ -79,9 +81,10 @@ instead of a blank page if something still cannot render — it keeps checking a
79
81
  - The status picks the page's top slot: `specified` shows *Plan this feature* (the `bt-plan` commands to copy, and a builder for its options and a brief); `planned` shows *Start this plan* (the `bt-execute` commands, and a builder for any task range and its options); `in-progress` shows *Current run activity* (the live file and the
80
82
  milestones); `paused`, `complete` and `incomplete` show *Execution debrief* (the After Action Report card, marked
81
83
  *Interim* while paused), with *Continue this plan* — the commands that pick up where it stopped — above it.
82
- - **Cadence is per task.** A task's entry changes the moment it starts (`in-progress`), the moment it is built
83
- (`built` — summary, files, tests and snapshots filled in right then), while the verifier checks it
84
- (`verifying`) and when it passes (`done` — verifier, done time).
84
+ - **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) and when it passes (`done` — verifier,
86
+ attempts, done time, `checkedLive`). The verifier adds `verifying` while it checks; a FAIL sends the task back to
87
+ `in-progress` with `attempts` + 1. Each status write also updates the live file.
85
88
 
86
89
  ## `<slug>_dashboard.js` fields
87
90
 
@@ -178,7 +181,7 @@ Each task:
178
181
 
179
182
  ## Snapshot shapes
180
183
 
181
- **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, the watchdog repairs one written around the helper within a minute, 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.**
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.** Frames come only from captures the work already takes, never an extra page session, export or capture just for a picture. Every visual task (`kind` `live`, `game` or `unity`) keeps at least the builder's quick-look frame (its built state) and the verifier's running-vs-reference comparison, plus any milestone frames the builder captured anyway, as a progression; a task with nothing to see needs none.
182
185
 
183
186
  Any list of snapshots may mix them. `source` names where the image came from: `"browser"`, `"unity"`,
184
187
  `"blender"`, `"reference"`.
@@ -191,11 +194,13 @@ Any list of snapshots may mix them. `source` names where the image came from: `"
191
194
 
192
195
  ## `<slug>_live.js` fields
193
196
 
194
- "What are you doing right now?" — answered on the page without asking. Whoever is doing the work rewrites
195
- this file whole: the implementer while it builds, the verifier while it checks, the orchestrator between them —
196
- at every meaningful step (starting a task, each milestone inside it, before a build / export / bake / capture /
197
- test run, a fix attempt, the hand-over to the verifier, the phase closing). A 20-minute silence shows as a warning.
198
- The page shows it only while `status` is `in-progress`.
197
+ "What are you doing right now?" — answered on the page without asking. bt-execute's helper rewrites this file
198
+ whole from each change it makes: a `task` write that sets a status names the task, its phase, the role the status
199
+ implies (`in-progress` / `built` → implementer, `verifying` → verifier, otherwise orchestrator), one sentence on the
200
+ 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 without a status leaves it untouched, and
202
+ agents never write it. A 20-minute silence shows as a warning. The page shows it only while `status` is
203
+ `in-progress`.
199
204
 
200
205
  | Field | Meaning |
201
206
  |---|---|
@@ -205,5 +210,21 @@ The page shows it only while `status` is `in-progress`.
205
210
  | `title` | only when there is no task: `"Verifying phase 1"`, `"Closing phase 1"` |
206
211
  | `role` | `implementer` · `verifier` · `orchestrator` |
207
212
  | `activity` | one plain-language sentence on what is happening this minute |
208
- | `source` | `agent` (an agent wrote it) or `watchdog` (a heartbeat written because the agent was quiet — the page tags it) |
209
- | `steps` | `[{ "at": "HH:MM", "text" }]` — the current task's log, oldest first; start fresh for each task, keep the last 12. Plain language a non-developer follows: "Painting the road mask from the spline", not "edit RoadNetwork.ts L120" |
213
+ | `source` | `agent` (the helper, from an agent's write) or `watchdog` (a heartbeat from the manual watchdog — the page tags it) |
214
+ | `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
+
216
+ ## `check` — the gate
217
+
218
+ `node <skills>/bt-execute/scripts/dashboard.mjs check <feature-folder>` runs at every phase boundary, at run end and
219
+ as bt-plan's last step. It repairs the slips it can (snapshot image keys, plain-text decisions), then fails — listing
220
+ every problem in one message — when a snapshot cannot show its image or a deliverable was skipped:
221
+
222
+ - `documents/<slug>_plan.md` exists without `dashboard.html`, `documents/<slug>_dashboard.js` or `documents/<slug>_live.js`;
223
+ - the dashboard's task ids differ from the plan's checklist (`- [ ]` / `- [x]` lines that start with a task id) in
224
+ membership or order;
225
+ - `status` is `complete` while the plan has an unticked box, or without `documents/<slug>_summary.html`;
226
+ - a visual task (`kind` `live`, `game` or `unity`) is `done` with no snapshot of its own and no phase or After Action
227
+ Report progression frame whose `task` is its id;
228
+ - a task ticked in the plan has no `verifier` result.
229
+
230
+ With no plan in the folder (a legacy flat plan) the plan checks are skipped.