Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(gate): make the bootstrap-ordering guard actually scan the pages it claims

nirholas5e1ff1b47921
diff --git a/scripts/check-tdz-bootstrap.mjs b/scripts/check-tdz-bootstrap.mjs
index dde4e6add..594bd0d97 100644
--- a/scripts/check-tdz-bootstrap.mjs
+++ b/scripts/check-tdz-bootstrap.mjs
@@ -61,10 +61,18 @@ const ROOT = resolve(new URL('..', import.meta.url).pathname);
// (mount -> boot -> injectStyles), so a depth of 1 would have missed it.
const MAX_CALL_DEPTH = 4;
-function tracked(patterns) {
- return execFileSync('git', ['ls-files', ...patterns], { cwd: ROOT, encoding: 'utf8' })
+// Tracked files AND new ones git does not know about yet (`--others`), minus
+// anything gitignored (`--exclude-standard`). A bare `git ls-files` cannot see a
+// module that was just written, which is precisely when a new page is most
+// likely to carry this ordering bug.
+export function tracked(dirs) {
+ // Directory pathspecs, not globs: git's `src/**/*.js` does NOT match a direct
+ // child like src/avatar-page.js, so a glob silently skipped every top-level
+ // page module, which is exactly where this bug class lives. Filter by
+ // extension here instead, where the semantics are ours.
+ return execFileSync('git', ['ls-files', '--cached', '--others', '--exclude-standard', '--', ...dirs], { cwd: ROOT, encoding: 'utf8' })
.split('\n')
- .filter(Boolean)
+ .filter((p) => p.endsWith('.js') || p.endsWith('.mjs'))
.map((p) => resolve(ROOT, p));
}
@@ -259,7 +267,7 @@ const argv = process.argv.slice(2);
const pathsFlag = argv.indexOf('--paths');
const files = pathsFlag !== -1
? argv.slice(pathsFlag + 1).filter((a) => !a.startsWith('--')).map((p) => resolve(ROOT, p))
- : tracked(['src/**/*.js', 'public/**/*.js']);
+ : tracked(['src', 'public']);
const all = [];
for (const file of files) {
diff --git a/tests/check-tdz-bootstrap.test.js b/tests/check-tdz-bootstrap.test.js
index a5fe9a5e1..c57dbd3d8 100644
--- a/tests/check-tdz-bootstrap.test.js
+++ b/tests/check-tdz-bootstrap.test.js
@@ -14,7 +14,7 @@
*/
import { describe, it, expect } from 'vitest';
-import { analyze } from '../scripts/check-tdz-bootstrap.mjs';
+import { analyze, tracked } from '../scripts/check-tdz-bootstrap.mjs';
const names = (src) => analyze('t.js', src).map((f) => f.name).sort();
@@ -144,3 +144,21 @@ describe('the shipped browser modules stay clean', () => {
expect(analyze('src/avatar-page.js', src)).toEqual([]);
});
});
+
+describe('the sweep actually reaches the pages it claims to cover', () => {
+ // git's `src/**/*.js` pathspec does NOT match a direct child, so an earlier
+ // version of this guard scanned only nested modules and silently skipped
+ // every top-level page, including the one whose regression it was written
+ // for. A count alone would not have caught that; naming the file does.
+ it('includes top-level page modules, not just nested ones', () => {
+ const files = tracked(['src', 'public']).map((f) => f.replace(/^.*\/three\.ws\//, ''));
+ expect(files).toContain('src/avatar-page.js');
+ expect(files).toContain('src/three-tier-page.js');
+ expect(files).toContain('public/forever.js');
+ expect(files.filter((f) => /^src\/[^/]+\.js$/.test(f)).length).toBeGreaterThan(100);
+ });
+
+ it('only enumerates JavaScript', () => {
+ expect(tracked(['src', 'public']).every((f) => f.endsWith('.js') || f.endsWith('.mjs'))).toBe(true);
+ });
+});