-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-gstack.js
More file actions
58 lines (51 loc) · 1.94 KB
/
Copy pathtest-gstack.js
File metadata and controls
58 lines (51 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os from "os";
import fs from "fs";
import path from "path";
const checks = [];
function check(label, fn) {
try {
const result = fn();
checks.push({ ok: true, label, result });
} catch (err) {
checks.push({ ok: false, label, result: err.message });
}
}
// Runtime
check("Runtime", () => {
const isBun = typeof Bun !== "undefined";
return isBun ? `Bun ${Bun.version}` : `Node.js ${process.version}`;
});
check("Platform", () => `${os.type()} ${os.release()} (${os.arch()})`);
check("Hostname", () => os.hostname());
check("Uptime", () => `${Math.floor(os.uptime() / 3600)}h ${Math.floor((os.uptime() % 3600) / 60)}m`);
check("Free memory", () => `${Math.round(os.freemem() / 1024 / 1024)} MB / ${Math.round(os.totalmem() / 1024 / 1024)} MB`);
check("Working dir", () => process.cwd());
// Workspace files
const root = path.resolve(import.meta.dirname ?? process.cwd());
for (const f of ["AGENTS.md", "SOUL.md", "skills/gstack/CLAUDE.md", "skills/gstack/package.json"]) {
check(`File: ${f}`, () => {
const full = path.join(root, f);
if (!fs.existsSync(full)) throw new Error("missing");
return `${Math.round(fs.statSync(full).size / 1024)} KB`;
});
}
// Browse binary
check("Browse binary", () => {
const bin = path.join(root, "skills/gstack/browse/dist/browse");
if (!fs.existsSync(bin)) return "not built (run: bun run build)";
return "present";
});
// Print results
const width = Math.max(...checks.map((c) => c.label.length)) + 2;
console.log("\n=== gstack workspace health check ===");
console.log(`Timestamp: ${new Date().toISOString()}\n`);
for (const { ok, label, result } of checks) {
const status = ok ? "OK " : "ERR";
console.log(` [${status}] ${label.padEnd(width)} ${result}`);
}
const failed = checks.filter((c) => !c.ok);
console.log(`\n${checks.length - failed.length}/${checks.length} checks passed`);
if (failed.length) {
console.log("Failed:", failed.map((c) => c.label).join(", "));
process.exit(1);
}