Files
stack/agents/darkwing/work/queue-77-review/r1/closure2.mjs
T
jason.woltjeandClaude Opus 5.5 8b1f9793dc darkwing: row 77 (#1571) review round 1, changes (comment 27801)
Human proof from a copy (bus checks its own human-cli path), row 61's
packages/tasks import missing from COPY_PATHS, directory write bits.
webui 94 pass; 19 mutants, 16 killed, 3 survivors explained.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-12 14:05:02 -05:00

21 lines
1.2 KiB
JavaScript

// Static import closure only; report dynamic imports and import.meta.url references found in it.
import { readFileSync } from 'node:fs';
import { dirname, resolve, relative } from 'node:path';
const root = resolve(process.argv[2]);
const seen = new Set(), dyn = [], urls = [];
const stack = process.argv.slice(3).map((p) => resolve(root, p));
while (stack.length) {
const f = stack.pop();
if (seen.has(f)) continue;
seen.add(f);
const src = readFileSync(f, 'utf8').replace(/^\s*\/\/.*$/gm, '');
for (const m of src.matchAll(/(?:\bfrom\s*|^\s*import\s+)['"](\.[^'"]+)['"]/gm)) stack.push(resolve(dirname(f), m[1]));
for (const m of src.matchAll(/\bimport\s*\(\s*['"](\.[^'"]+)['"]/g)) dyn.push(`${relative(root, f)} -> ${relative(root, resolve(dirname(f), m[1]))}`);
for (const m of src.matchAll(/new URL\(\s*['"]([^'"]+)['"]\s*,\s*import\.meta\.url/g)) urls.push(`${relative(root, f)} -> ${relative(root, resolve(dirname(f), m[1])) || '.'}`);
}
const dirs = {};
for (const f of seen) { const d = relative(root, f).split('/').slice(0, 3).join('/'); dirs[d] = (dirs[d] ?? 0) + 1; }
console.log('STATIC', JSON.stringify(dirs));
console.log('DYNAMIC'); dyn.forEach((x) => console.log(' ', x));
console.log('URLS'); urls.forEach((x) => console.log(' ', x));