Skip to content

Where agent teams gather. Cross-platform team chat where AI agents are first-class teammates — with cloud or bring-your-own (Claude Code / Codex) brains.

TypeScript

fix(ci): compare paths, not a hand-built file:// URL, for the CLI entry point

Xialie Zhuang7859e3519103
diff --git a/scripts/guard-engine-registry.mjs b/scripts/guard-engine-registry.mjs
index 7a88bca..10a1cfa 100644
--- a/scripts/guard-engine-registry.mjs
+++ b/scripts/guard-engine-registry.mjs
@@ -223,7 +223,14 @@ export function scanRepo() {
return problems
}
-if (import.meta.url === `file://${process.argv[1]}`) {
+// Compare filesystem paths, not a hand-built file:// URL. On Windows
+// process.argv[1] is `E:\...` while import.meta.url is `file:///E:/...`, so
+// the string form never matched and `npm run guard:engine-registry` exited 0
+// without ever calling scanRepo() — the guard silently becoming a no-op is the
+// exact failure this file exists to prevent. Same shape guard-big-brain.mjs
+// already used.
+const isMain = process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]
+if (isMain) {
const problems = scanRepo()
if (problems.length === 0) {
console.log('✅ engine registry guard: every engine in ENGINE_IDS is wired into all of its lists.')
diff --git a/server/src/__tests__/guard-engine-registry.test.ts b/server/src/__tests__/guard-engine-registry.test.ts
index 4546d4f..fa6130f 100644
--- a/server/src/__tests__/guard-engine-registry.test.ts
+++ b/server/src/__tests__/guard-engine-registry.test.ts
@@ -2,7 +2,8 @@ import { test } from 'node:test'
import assert from 'node:assert/strict'
// The guard is plain ESM tooling; tsx lets this .ts test import the .mjs.
import { scanRepo, engineIds, extract } from '../../../scripts/guard-engine-registry.mjs'
-import { readFileSync } from 'node:fs'
+import { execFileSync } from 'node:child_process'
+import { readFileSync, rmSync, writeFileSync } from 'node:fs'
import { join } from 'node:path'
// Making an engine runnable means adding its id to about ten hand-kept lists.
@@ -69,3 +70,46 @@ test('the spawn guard covers every engine BINARY, not every engine id', () => {
assert.ok(alt, 'anchor not found: the R4 engine-binary alternation')
assert.ok(alt.split('|').includes('cursor-agent'))
})
+
+// --- the script actually RUNS when launched as a CLI ---
+
+test('the CLI entry point reaches scanRepo, not just exits 0', () => {
+ // Every test above calls scanRepo() directly, so none of them can tell a
+ // working guard from one whose main-module check never fires. That is not
+ // hypothetical: the first version compared `import.meta.url` against a
+ // hand-built `file://${process.argv[1]}`, which never matches on Windows —
+ // `npm run guard:engine-registry` exited 0 having checked nothing.
+ const out = execFileSync(process.execPath, [join(ROOT, 'scripts', 'guard-engine-registry.mjs')], {
+ cwd: ROOT, encoding: 'utf8',
+ })
+ assert.match(out, /engine registry guard/, `the script printed nothing:\n${out}`)
+})
+
+test('the CLI exits non-zero when a list is half-wired', () => {
+ // The other half of the same property: a guard that always exits 0 is
+ // indistinguishable from a passing one until something is actually broken.
+ const script = readFileSync(join(ROOT, 'scripts', 'guard-engine-registry.mjs'), 'utf8')
+ // Point the BYOA_SOURCES check at a declaration that cannot contain any
+ // engine, so the run must fail. Written to a sibling file so the real script
+ // is never modified.
+ const sabotaged = script.replace(
+ "/export const BYOA_SOURCES = \\[([\\s\\S]*?)\\] as const/",
+ "/export const BYOA_SOURCE_SET = new Set<string>\\((BYOA_SOURCES)\\)/",
+ )
+ assert.notEqual(sabotaged, script, 'the BYOA_SOURCES anchor moved — update this test with it')
+ const tmp = join(ROOT, 'scripts', '.guard-entry-probe.mjs')
+ writeFileSync(tmp, sabotaged, 'utf8')
+ try {
+ let code = 0
+ let stdout = ''
+ try {
+ stdout = execFileSync(process.execPath, [tmp], { cwd: ROOT, encoding: 'utf8', stdio: 'pipe' })
+ } catch (e) {
+ code = (e as { status?: number }).status ?? 0
+ stdout = String((e as { stdout?: string }).stdout ?? '')
+ }
+ assert.equal(code, 1, `expected a failing exit, got ${code}; stdout was:\n${stdout}`)
+ } finally {
+ rmSync(tmp, { force: true })
+ }
+})