Merge pull request #754 from jeremymcs/fix/forensics-version-loading

fix(forensics): use GSD_VERSION env var instead of package.json path traversal
This commit is contained in:
TÂCHES 2026-03-16 18:42:09 -06:00 committed by GitHub
commit 4d78620ff1

View file

@ -183,14 +183,10 @@ async function buildForensicReport(basePath: string): Promise<ForensicReport> {
}
}
// 8. GSD version
let gsdVersion = "unknown";
try {
const pkgPath = join(dirname(fileURLToPath(import.meta.url)), "../../../../package.json");
if (existsSync(pkgPath)) {
gsdVersion = JSON.parse(readFileSync(pkgPath, "utf-8")).version ?? "unknown";
}
} catch { /* non-fatal */ }
// 8. GSD version — use GSD_VERSION env var set by the loader at startup.
// Extensions run from ~/.gsd/agent/extensions/gsd/ at runtime, so path-traversal
// from import.meta.url would resolve to ~/package.json (wrong on every system).
const gsdVersion = process.env.GSD_VERSION || "unknown";
// 9. Run anomaly detectors
if (metrics?.units) detectStuckLoops(metrics.units, anomalies);