@babylonjs-toolkit/agent 1.2.14 → 1.2.15

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 CHANGED
@@ -1,4 +1,4 @@
1
- # Babylon Toolkit Desktop Agent (1.2.14)
1
+ # Babylon Toolkit Desktop Agent (1.2.15)
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs-toolkit/agent",
3
- "version": "1.2.14",
3
+ "version": "1.2.15",
4
4
  "description": "Installs the Babylon Toolkit Desktop Agent for Claude Code, Codex, GitHub Copilot, Gemini CLI and Antigravity.",
5
5
  "keywords": [
6
6
  "babylonjs",
@@ -29,6 +29,10 @@
29
29
  * agents write `live` at each meaningful step (before anything slow, at each fix attempt), and `watch` — the
30
30
  * watchdog bt-execute launches in the background at run start — writes a heartbeat after 10 quiet minutes.
31
31
  *
32
+ * A task's `tests` keeps its documented shape: `task --set` refuses a `tests.files` that is not a list of path strings
33
+ * and a `passed` / `failed` that is not a number, and every write and `check` repairs one already in the file (the
34
+ * old value moves into `tests.note`), because a count written into `files` once stopped a dashboard drawing.
35
+ *
32
36
  * Snapshots go in only through `snapshot`. `task --set` and `check` refuse any snapshot entry the page cannot show —
33
37
  * an image under `path` (or `file`, `image`, …) instead of `src`, or a `src` that is not a file under the feature
34
38
  * folder — because such an entry renders as "No snapshot".
@@ -100,6 +104,13 @@ const MAXIMUM_SCAN_DEPTH = 5;
100
104
  const TASK_LIST_FIELDS = ['files', 'decisions', 'snapshots', 'updates'];
101
105
  /** Task fields that are an object or null. */
102
106
  const TASK_OBJECT_FIELDS = ['tests', 'details'];
107
+ /** Counts inside a task's `tests` that must be numbers when present. */
108
+ const TESTS_COUNT_FIELDS = ['passed', 'failed'];
109
+ /** The `tests` shape from data-schema.md, quoted in every refusal so the writer can fix the entry in one go. */
110
+ const TESTS_SHAPE_HELP = [
111
+ '"tests" is { "passed": <number>, "failed": <number>, "files": ["<test path from the project root>", …], "note": "<counts, suite names, commands>" } or null.',
112
+ '"files" holds paths only (the page links each one); a count, a suite name or a command goes in "note".',
113
+ ].join('\n');
103
114
  /** Statuses that mean a task is being worked on right now. */
104
115
  const ACTIVE_TASK_STATUSES = new Set(['in-progress', 'built', 'verifying']);
105
116
  /** Where a snapshot's image may come from. */
@@ -168,6 +179,7 @@ function writeData(path, prefix, data) {
168
179
  // Every dashboard write repairs snapshot entries first, so an image filed under `path` (or any key the page never
169
180
  // reads) can never reach the page as "No snapshot", whoever wrote it.
170
181
  if (data && Array.isArray(data.phases)) repairSnapshots(data);
182
+ if (data && Array.isArray(data.phases)) repairTaskTests(data);
171
183
  if (data && Array.isArray(data.decisions)) repairDecisions(data);
172
184
  if (data && Array.isArray(data.followUps)) repairFollowUps(data);
173
185
  const temporaryPath = `${path}.${process.pid}.tmp`;
@@ -479,6 +491,61 @@ function checkTaskShape(changes) {
479
491
  const value = changes[field];
480
492
  if (field in changes && value !== null && (typeof value !== 'object' || Array.isArray(value))) throw new Error(`"${field}" must be an object or null`);
481
493
  }
494
+ if (changes.tests) checkTestsShape(changes.tests);
495
+ }
496
+
497
+ /**
498
+ * Refuses a `tests` object the page cannot draw: a `files` that is not a list of path strings (a count written there
499
+ * once stopped a dashboard drawing), or a `passed` / `failed` that is present but not a number.
500
+ * @param {Record<string, any>} tests The task's `tests` object.
501
+ * @throws {Error} Naming the field and quoting the `tests` shape.
502
+ */
503
+ function checkTestsShape(tests) {
504
+ const hasFiles = tests.files !== undefined;
505
+ if (hasFiles && !isPathList(tests.files)) {
506
+ throw new Error(`"tests.files" must be a list of path strings, not ${JSON.stringify(tests.files)}\n${TESTS_SHAPE_HELP}`);
507
+ }
508
+ for (const field of TESTS_COUNT_FIELDS) {
509
+ const count = tests[field];
510
+ if (count !== undefined && typeof count !== 'number') {
511
+ throw new Error(`"tests.${field}" must be a number, not ${JSON.stringify(count)}\n${TESTS_SHAPE_HELP}`);
512
+ }
513
+ }
514
+ }
515
+
516
+ /**
517
+ * Whether a value is a list whose every entry is a string — the only `tests.files` the page can link.
518
+ * @param {any} value The value to test.
519
+ * @returns {boolean} True for an array of strings (an empty array included).
520
+ */
521
+ function isPathList(value) {
522
+ return Array.isArray(value) && value.every((entry) => typeof entry === 'string');
523
+ }
524
+
525
+ /**
526
+ * Repairs every task's `tests.files` in place so the page can draw it: a value that is not a list of path strings
527
+ * moves into `tests.note` (`files: 46`), and `files` keeps only the string entries of a mixed list, else becomes `[]`.
528
+ * @param {any} dashboard The dashboard data.
529
+ * @returns {string[]} One line per repair made.
530
+ */
531
+ function repairTaskTests(dashboard) {
532
+ const repairs = [];
533
+ for (const phase of dashboard.phases || []) {
534
+ for (const task of phase.tasks || []) {
535
+ const tests = task && task.tests;
536
+ if (!tests || typeof tests !== 'object' || Array.isArray(tests)) continue;
537
+ if (tests.files === undefined || isPathList(tests.files)) continue;
538
+ const oldFiles = tests.files;
539
+ const keptPaths = Array.isArray(oldFiles) ? oldFiles.filter((entry) => typeof entry === 'string') : [];
540
+ const movedValue = Array.isArray(oldFiles) ? oldFiles.filter((entry) => typeof entry !== 'string') : oldFiles;
541
+ const movedText = `files: ${typeof movedValue === 'string' ? movedValue : JSON.stringify(movedValue)}`;
542
+ const existingNote = typeof tests.note === 'string' ? tests.note.trim() : '';
543
+ tests.note = existingNote ? `${existingNote}; ${movedText}` : movedText;
544
+ tests.files = keptPaths;
545
+ repairs.push(`${task.id}.tests.files: ${JSON.stringify(oldFiles)} is not a list of paths → moved into tests.note, files ${JSON.stringify(keptPaths)}`);
546
+ }
547
+ }
548
+ return repairs;
482
549
  }
483
550
 
484
551
  /**
@@ -1377,17 +1444,21 @@ function checkData(folder) {
1377
1444
  const { prefix, data } = readData(dashboardPath);
1378
1445
  if (existsSync(livePath)) readData(livePath);
1379
1446
  const repairs = repairSnapshots(data);
1447
+ const testsRepairs = repairTaskTests(data);
1380
1448
  const decisionRepairs = repairDecisions(data);
1381
1449
  const followUpRepairs = repairFollowUps(data);
1382
1450
  const hasFollowUps = Array.isArray(data.followUps) && data.followUps.length > 0;
1383
1451
  const linkedFollowUps = hasFollowUps && linkFollowUpsDocument(folder, data);
1384
1452
  const linkedFromPlan = linkCitedFollowUps(folder, data);
1385
1453
  const sourceMoved = syncAddressedFollowUps(folder, data);
1386
- if (repairs.length || decisionRepairs.length || followUpRepairs.length || linkedFollowUps || linkedFromPlan || sourceMoved) writeData(dashboardPath, prefix, data);
1454
+ if (repairs.length || testsRepairs.length || decisionRepairs.length || followUpRepairs.length || linkedFollowUps || linkedFromPlan || sourceMoved) writeData(dashboardPath, prefix, data);
1387
1455
  if (hasFollowUps) writeFollowUpsDocument(folder, data);
1388
1456
  if (repairs.length) {
1389
1457
  console.log(`repaired ${repairs.length} snapshot entr${repairs.length === 1 ? 'y' : 'ies'} the page could not show:\n ${repairs.join('\n ')}`);
1390
1458
  }
1459
+ if (testsRepairs.length) {
1460
+ console.log(`repaired ${testsRepairs.length} task test record${testsRepairs.length === 1 ? '' : 's'} the page could not draw:\n ${testsRepairs.join('\n ')}`);
1461
+ }
1391
1462
  if (decisionRepairs.length) {
1392
1463
  console.log(`repaired ${decisionRepairs.length} decision${decisionRepairs.length === 1 ? '' : 's'} written as plain text:\n ${decisionRepairs.join('\n ')}`);
1393
1464
  }
@@ -1502,14 +1573,14 @@ async function watch(folder, argumentList) {
1502
1573
  }
1503
1574
 
1504
1575
  /**
1505
- * Watchdog repair: a snapshot or decision an agent wrote around the helper (a hand edit, its own script) is repaired
1576
+ * Watchdog repair: a snapshot, task test record or decision an agent wrote around the helper (a hand edit, its own script) is repaired
1506
1577
  * within a minute, re-read just before the write so nothing the agent wrote meanwhile is lost.
1507
1578
  * @param {string} dashboardPath The dashboard data file.
1508
1579
  */
1509
1580
  function repairWrittenSnapshots(dashboardPath) {
1510
1581
  try {
1511
1582
  const { prefix, data } = readData(dashboardPath);
1512
- const repairs = [...repairSnapshots(data), ...repairDecisions(data)];
1583
+ const repairs = [...repairSnapshots(data), ...repairTaskTests(data), ...repairDecisions(data)];
1513
1584
  if (!repairs.length) return;
1514
1585
  writeData(dashboardPath, prefix, data);
1515
1586
  console.log(`watchdog: repaired ${repairs.length} entr${repairs.length === 1 ? 'y' : 'ies'} — ${repairs.join('; ')}`);
@@ -1472,7 +1472,7 @@
1472
1472
  hasTests(task)
1473
1473
  ? `<span class="count count-pass">${escapeHtml(tests.passed ?? 0)} passed</span>${Number(tests.failed) ? `<div class="count count-fail">${escapeHtml(tests.failed)} failed</div>` : ''}`
1474
1474
  : `<span class="cell-note" title="${escapeAttribute(tests.note || '')}">${tests.note ? escapeHtml(tests.note) : '—'}</span>`,
1475
- (tests.files || []).length ? tests.files.map(fileLink).join('<br>') : '—',
1475
+ testFilesOf(tests).length ? testFilesOf(tests).map(fileLink).join('<br>') : '—',
1476
1476
  cases.length ? `${cases.length}${casesFailed ? `<div class="count count-fail">${casesFailed} failed</div>` : ''}` : '—',
1477
1477
  hasLiveCheck(task) ? `<span title="${escapeAttribute(liveCheckNote(task))}">Yes</span>` : '—',
1478
1478
  ];
@@ -1572,11 +1572,21 @@
1572
1572
  tests.passed != null ? `${escapeHtml(tests.passed)} passed` : '',
1573
1573
  tests.failed ? `${escapeHtml(tests.failed)} failed` : '',
1574
1574
  ].filter(Boolean).join(' · ');
1575
- const files = (tests.files || []).map(fileLink).join(' ');
1575
+ const files = testFilesOf(tests).map(fileLink).join(' ');
1576
1576
  const note = tests.note ? formatInline(tests.note) : '';
1577
1577
  return [counts, files, note].filter(Boolean).join('<br>');
1578
1578
  }
1579
1579
 
1580
+ /**
1581
+ * The test file paths of a task's tests record, read only when `files` is a list: a count or text written there
1582
+ * by hand (the helper refuses and repairs it) must never stop the page drawing.
1583
+ * @param {object} tests The task's `tests` record.
1584
+ * @returns {string[]} Its path entries; empty when `files` is not a list.
1585
+ */
1586
+ function testFilesOf(tests) {
1587
+ return Array.isArray(tests.files) ? tests.files.filter((entry) => typeof entry === 'string') : [];
1588
+ }
1589
+
1580
1590
  /**
1581
1591
  * Three snapshot shapes: a progression (`frames`) renders as a storyboard of the build stage by stage;
1582
1592
  * a before/after pair renders as a drag-to-compare slider; a single image renders as a zoomable still.