Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
import { execFileSync } from "node:child_process";
import { createRequire } from "node:module";
import { readdirSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const electronDirectory = fileURLToPath(new URL("../electron/", import.meta.url));
const require = createRequire(import.meta.url);
const electronExecutable = require("electron");
/** Every module the app can load at startup, including `app-install/` and `fixtures/`: main.mjs and the installer import
* them, so a syntax error there is a crash, not a test failure. `vendor/` is somebody else's code. */
function modulesIn(directory) {
return readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
if (entry.isDirectory()) return entry.name === "vendor" ? [] : modulesIn(path.join(directory, entry.name));
return entry.isFile() && /\.(?:cjs|mjs)$/.test(entry.name) ? [path.join(directory, entry.name)] : [];
});
}
const modules = modulesIn(electronDirectory).sort();
if (modules.length === 0) throw new Error("No Electron modules were found to syntax-check");
for (const modulePath of modules) {
execFileSync(electronExecutable, ["--check", modulePath], {
env: { ...process.env, ELECTRON_RUN_AS_NODE: "1" },
stdio: "inherit",
});
}
console.log(`Syntax-checked ${modules.length} Electron modules.`);