fix(forensics): use GSD_VERSION env var instead of package.json path traversal
Extensions run from ~/.gsd/agent/extensions/gsd/ at runtime, not from the package install directory. The previous code traversed 4 levels up from import.meta.url to find package.json, which resolves to ~/package.json at runtime — wrong on every system. The loader already sets process.env.GSD_VERSION at startup, which is how every other extension reads the version. Use that instead.
This commit is contained in:
parent
d10412bb1e
commit
359deb6c23
1 changed files with 4 additions and 8 deletions
|
|
@ -178,14 +178,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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue