fix(sf): gap-audit detects prompts loaded by direct filesystem read

Orphan-prompt detection only checked loadPrompt() callsites. Three
prompts (heal-skill, product-audit, review-migration) are loaded by
direct readFileSync of "<name>.md" — they got false-flagged as orphans.

Add a literal-filename check so any source file containing "<name>.md"
counts as a load. Cheap one-pass grep, same shape as the existing
loadPrompt patterns.

Verified with live runGapAudit: 0 new findings (was previously logging
the 3 false positives every session_start).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mikael Hugo 2026-05-02 17:29:44 +02:00
parent 617608347d
commit 8032ee6144

View file

@ -89,7 +89,12 @@ function findOrphanPrompts(): GapFinding[] {
grepImports(EXTENSION_SRC, `loadPrompt("${name}"`) ||
grepImports(EXTENSION_SRC, `loadPrompt('${name}'`) ||
grepImports(EXTENSION_SRC, `loadPrompt("${name}",`) ||
grepImports(EXTENSION_SRC, `loadPrompt('${name}',`);
grepImports(EXTENSION_SRC, `loadPrompt('${name}',`) ||
// Some prompts are loaded by direct filesystem read (skill-health.ts,
// migrate/command.ts, product-audit-tool.ts) rather than via loadPrompt.
// Check for the bare filename literal as a strong indicator of intent.
grepImports(EXTENSION_SRC, `"${name}.md"`) ||
grepImports(EXTENSION_SRC, `'${name}.md'`);
if (!loaded) {
findings.push({
kind: "orphan-prompt",