unreferencedPlates: an explicit artifact joins the source corpus instead of replacing it

Greptile's follow-up P1 on #599: with --artifact set, only that HTML file was read, so a plate referenced exclusively from a linked stylesheet still read as unused. The bounded source walk now runs either way.

AI-assisted (Claude Code).
This commit is contained in:
Paul Bakaus
2026-08-28 15:17:09 -07:00
parent 09ddc1758e
commit 18e8c287b5
2 changed files with 8 additions and 1 deletions
+4 -1
View File
@@ -341,7 +341,10 @@ function sourceFiles(root = '.', limit = 400) {
export function unreferencedPlates(spec, artifact = null) {
const plates = (spec?.regions || []).filter((r) => r.medium === 'raster' && r.plate);
if (!plates.length) return [];
const files = artifact && fs.existsSync(artifact) ? [artifact] : sourceFiles();
// The artifact narrows nothing: a plate may be referenced only from a
// stylesheet the artifact links (assets/hero.css), so the source walk runs
// either way and the artifact is simply guaranteed a seat in the corpus.
const files = [...new Set([...(artifact && fs.existsSync(artifact) ? [artifact] : []), ...sourceFiles()])];
let corpus = '';
for (const f of files) { try { corpus += fs.readFileSync(f, 'utf8') + '\n'; } catch { /* skip */ } }
const missing = [];