Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
// Every source file over 1,000 lines is listed here with its line count, and
// a count may only go down: a PR that grows one of these files, or adds a new
// file over 1,000 lines, fails here. A PR that shrinks a file leaves its number
// alone: scripts/tighten-ratchets.mjs lowers the numbers (and drops files under
// 1,000 lines) at each release, so two such PRs never conflict here. The split program
// (server/host/README.md) moves server/index.ts into modules of under 1,500
// lines; nothing new may exceed HARD_CAP, and the files listed above the cap
// are the ones that program takes apart. Tests, fixtures, goldens and
// vendored code are not counted.
import { readFileSync } from "node:fs";
import { execFileSync } from "node:child_process";
import { describe, expect, it } from "vitest";
const ROOT = new URL("../../", import.meta.url);
const HARD_CAP = 2000;
const LISTED_FROM = 1000;
const LINES: Record<string, number> = {
"server/index.ts": 15157,
"src/state/store.tsx": 3258,
"electron/main.mjs": 3117,
"server/store.ts": 2251,
"src/components/Sidebar.tsx": 1651,
"server/drivers/claude.ts": 1954,
"server/drivers/acp/core.ts": 1538,
"server/drivers/codex.ts": 1573,
"server/routines.ts": 1553,
"src/components/ComputerPanel.tsx": 1782,
"src/components/RoutineCalendarPage.tsx": 1485,
"server/config.ts": 1192,
"src/components/ChatView.tsx": 1180,
"server/routine-requests.ts": 1467,
"src/components/LocalComputerSection.tsx": 1437,
"src/components/CursorAvatar.tsx": 1064,
"server/skills.ts": 1379,
"server/vps-computer.ts": 1280,
"scripts/mcp-server.ts": 1403,
"server/boat.ts": 1242,
"server/plan-usage.ts": 1022,
"server/container-computer.ts": 1150,
"src/components/ModelPicker.tsx": 1016,
"src/components/PhoneSetupFlow.tsx": 1085,
"server/cli.ts": 1052,
"src/components/AttachmentPreview.tsx": 1016,
"server/meetings/meetbot.ts": 1047,
"electron/data-dir-lease.node-test.mjs": 846, // the data-folder lease's own tests: many platform cases (Windows probes in data-dir-lease-windows.node-test.mjs)
};
function sourceFiles(): string[] {
const out = execFileSync("git", ["ls-files", "server", "shared", "packages", "src", "scripts", "evals", "electron", "companion"], { cwd: ROOT, encoding: "utf8" });
return out.split("\n").filter((file) => /\.(ts|tsx|mjs|cjs)$/.test(file))
.filter((file) => !file.includes(".test.") && !file.includes("/testing/") && !file.includes("goldens") && !file.startsWith("electron/vendor/"));
}
const count = (file: string) => readFileSync(new URL(file, ROOT), "utf8").split("\n").length - 1;
describe("source files stay a readable size", () => {
it("no listed file grows, and no new file over 1,000 lines goes unlisted", () => {
const problems: string[] = [];
const seen = new Set<string>();
for (const file of sourceFiles()) {
const lines = count(file);
const pinned = LINES[file];
if (pinned !== undefined) {
seen.add(file);
if (lines > pinned) problems.push(`${file} grew to ${lines} lines (listed at ${pinned}): move code out, do not add here`);
} else if (lines > LISTED_FROM) {
problems.push(lines > HARD_CAP
? `${file} is ${lines} lines, over the ${HARD_CAP}-line cap: split it`
: `${file} is ${lines} lines: a new file over ${LISTED_FROM} lines needs a line here and a reason in the PR`);
}
}
expect(problems, "See server/host/README.md").toEqual([]);
});
});