mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 20:32:20 +03:00
* feat(cli): add Grok Build CLI tool setup (~/.grok/config.toml) Registers xAI's Grok Build TUI coding agent as a configurable CLI tool in /dashboard/cli-code, so OmniRoute can write itself in as a custom model provider in ~/.grok/config.toml. Mechanism: Grok Build reads a TOML config that can hold several user-defined [model.*] sections plus a [models].default pointer. Unlike the sibling Forge handler (which owns its whole config file and can full-replace it), this one surgically upserts ONLY the [model.omniroute] section and rewrites [models].default, leaving every other section byte-intact. Apply records the previous default in an `# omniroute-prev-default` marker comment so Reset can restore the user's original default instead of guessing. Built on OmniRoute's existing CLI-tools infrastructure rather than replaying the upstream shape: getCliRuntimeStatus() for detection (no ad-hoc `which grok` exec), Zod validation via cliModelConfigSchema, the write guard, createBackup(), the cliToolState DB module, and sanitizeErrorMessage() for every error path (Hard Rule #12). Security: GET reaches getCliRuntimeStatus(), which spawns a child process to locate and healthcheck the `grok` binary. That is the same transitive-spawn surface that classified /api/skills/collect/, so the route is registered in LOCAL_ONLY_API_PREFIXES and loopback-enforced before any auth check (Hard Rules #15 + #17). Writing a local CLI's config file is inherently a local-machine operation, so this costs no real capability. Co-authored-by: rixzkiye <rizkiyemubarok05@gmail.com> Inspired-by: https://github.com/decolua/9router/pull/2571 * chore(changelog): fragment for #7241 * fix(cli): shrink cliTools.ts/cliRuntime.ts under the file-size ratchet + fix stale catalog counts The grok-build registry/runtime entries pushed cliTools.ts (916->932) and cliRuntime.ts (1128->1137) past their frozen file-size caps. Extract the grok-build entries into cliToolsGrokBuild.ts (registry, typed) and cliRuntimeGrokBuild.ts (runtime metadata, deliberately untyped/no cliCatalog import so it doesn't drag that schema file into the typecheck:core curated allowlist's transitive graph). The amp runtime entry rides along in the same runtime file for the extra headroom needed to clear cliRuntime.ts's cap with zero slack. Also update the two catalog-cardinality canaries (cli-tools-schema.test.ts, cli-catalog-counts.test.ts) and EXPECTED_CODE_COUNT to include grok-build: 20->21 visible code entries, 24->25 total code entries, 32->33 grand total. Fixes CI reds on #7241 surviving a release/v3.8.49 merge: Fast Quality Gates (check:file-size) and Unit Tests fast-path (1/4, 2/4). * test(stryker): register grok-build route-guard test in tap.testFiles check:mutation-test-coverage --strict flagged tests/unit/route-guard-grok-build-settings-local-only.test.ts as a covering unit test for src/server/authz/routeGuard.ts missing from stryker.conf.json's tap.testFiles allowlist (only became reachable once the Fast Quality Gates job got past the file-size fix earlier in this branch). --------- Co-authored-by: rixzkiye <rizkiyemubarok05@gmail.com>
95 lines
3.3 KiB
TypeScript
95 lines
3.3 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
test("CLI_TOOLS registry contains all expected tools (plan 14 — 33 total + crush + codewhale + omp + letta + grok-build)", async () => {
|
|
const { CLI_TOOLS } = await import("../../src/shared/constants/cliTools.ts");
|
|
// windsurf and amp removed per plan 14 D17 (MITM backlog plan 11)
|
|
// New entries added: roo, jcode, deepseek-tui, smelt, pi, aider, forge,
|
|
// cursor-cli, goose, interpreter, warp, agent-deck (+ hermes-agent already existed)
|
|
// crush added — ported from upstream decolua/9router#1233
|
|
// codewhale added 2026-07-02 as a dual entry alongside deepseek-tui
|
|
// (CodeWhale is the actively-maintained successor to DeepSeek TUI).
|
|
// omp + letta added by #6318 (agent-category CLI integrations).
|
|
// grok-build added — xAI Grok Build TUI coding agent (ported from upstream decolua/9router#2571).
|
|
const expected = [
|
|
"claude",
|
|
"codex",
|
|
"droid",
|
|
"openclaw",
|
|
"cursor",
|
|
"cline",
|
|
"kilo",
|
|
"continue",
|
|
"antigravity",
|
|
"copilot",
|
|
"opencode",
|
|
"hermes",
|
|
"hermes-agent",
|
|
"kiro",
|
|
"qwen",
|
|
"custom",
|
|
"aider",
|
|
"forge",
|
|
"cursor-cli",
|
|
"roo",
|
|
"jcode",
|
|
"deepseek-tui",
|
|
"codewhale",
|
|
"smelt",
|
|
"pi",
|
|
"goose",
|
|
"interpreter",
|
|
"warp",
|
|
"omp",
|
|
"letta",
|
|
"agent-deck",
|
|
"crush",
|
|
"grok-build",
|
|
];
|
|
for (const id of expected) {
|
|
assert.ok(id in CLI_TOOLS, `Missing tool: ${id}`);
|
|
}
|
|
assert.equal(Object.keys(CLI_TOOLS).length, expected.length);
|
|
// Confirm removed entries are gone
|
|
assert.equal((CLI_TOOLS as Record<string, unknown>)["windsurf"], undefined);
|
|
assert.equal((CLI_TOOLS as Record<string, unknown>)["amp"], undefined);
|
|
});
|
|
|
|
test("Every tool has required fields: id, name, description, configType", async () => {
|
|
const { CLI_TOOLS } = await import("../../src/shared/constants/cliTools.ts");
|
|
for (const [key, tool] of Object.entries(CLI_TOOLS)) {
|
|
assert.equal(typeof tool.id, "string", `${key}.id must be string`);
|
|
assert.equal(tool.id, key, `${key}.id must match its registry key`);
|
|
assert.equal(typeof tool.name, "string", `${key}.name must be string`);
|
|
assert.ok(tool.name.length > 0, `${key}.name must be non-empty`);
|
|
assert.equal(typeof tool.description, "string", `${key}.description must be string`);
|
|
assert.equal(typeof tool.configType, "string", `${key}.configType must be string`);
|
|
}
|
|
});
|
|
|
|
test("listCliTools returns all tools as an array", async () => {
|
|
const { listCliTools, CLI_TOOLS } = await import("../../src/shared/constants/cliTools.ts");
|
|
const tools = listCliTools();
|
|
assert.ok(Array.isArray(tools));
|
|
assert.equal(tools.length, Object.keys(CLI_TOOLS).length);
|
|
for (const tool of tools) {
|
|
assert.equal(typeof tool.id, "string");
|
|
}
|
|
});
|
|
|
|
test("getCliTool returns correct tool by id", async () => {
|
|
const { getCliTool } = await import("../../src/shared/constants/cliTools.ts");
|
|
const claude = getCliTool("claude");
|
|
assert.ok(claude);
|
|
assert.equal(claude.id, "claude");
|
|
assert.equal(claude.name, "Claude Code");
|
|
|
|
const missing = getCliTool("nonexistent");
|
|
assert.equal(missing, undefined);
|
|
});
|
|
|
|
test("CLI tools registry does not export provider model mapping helper", async () => {
|
|
const registry = await import("../../src/shared/constants/cliTools.ts");
|
|
assert.equal("getProviderModelsForMapping" in registry, false);
|
|
});
|