mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-02 05:12:11 +03:00
CLI #8 of the series. Roo Code (RooVeterinaryInc.roo-cline, a Cline fork) keeps live settings in opaque VS Code globalStorage, but supports Settings Import and an `roo-cline.autoImportSettingsPath` (VS Code settings.json) that loads a JSON at startup. `omniroute setup-roo`: - writes ~/.omniroute/roo-settings.json — a Roo provider profile (providerProfiles.apiConfigs.OmniRoute: apiProvider=openai, openAiBaseUrl WITH /v1 — Roo appends /chat/completions — openAiApiKey, openAiModelId). - sets roo-cline.autoImportSettingsPath in VS Code settings.json when present (preserves other settings). - prints the guaranteed UI path (Settings → Providers → OpenAI Compatible) + the "Import Settings" fallback. - remote-aware; model via --model or interactive pick. Researched against current Roo docs: OpenAI-compatible needs baseUrl WITH /v1 and native tool-calling (OmniRoute supports it). Roo's wire (/v1/chat/completions) already validated → "OK". Tests: resolveRooTarget (/v1, key), buildRooImport (provider profile + /v1 + key fallback), buildRooVscodeAutoImport (pointer + preserve). 5 unit tests; cli-i18n green.
27 lines
1.5 KiB
TypeScript
27 lines
1.5 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { resolveRooTarget, buildRooImport, buildRooVscodeAutoImport } from "../../../bin/cli/commands/setup-roo.mjs";
|
|
|
|
test("resolveRooTarget ensures /v1 on the base URL", () => {
|
|
assert.equal(resolveRooTarget({ remote: "http://vps:20128" }).baseUrl, "http://vps:20128/v1");
|
|
});
|
|
test("resolveRooTarget: explicit --api-key wins", () => {
|
|
assert.equal(resolveRooTarget({ remote: "http://x:20128", apiKey: "sk-x" }).apiKey, "sk-x");
|
|
});
|
|
test("buildRooImport produces an openai-compatible provider profile (baseUrl /v1, model)", () => {
|
|
const d = buildRooImport({ baseUrl: "http://vps:20128/v1", apiKey: "k", model: "glm/glm-5.2" });
|
|
const cfg = d.providerProfiles.apiConfigs.OmniRoute;
|
|
assert.equal(cfg.apiProvider, "openai");
|
|
assert.equal(cfg.openAiBaseUrl, "http://vps:20128/v1");
|
|
assert.equal(cfg.openAiModelId, "glm/glm-5.2");
|
|
assert.equal(d.providerProfiles.currentApiConfigName, "OmniRoute");
|
|
});
|
|
test("buildRooImport falls back to a placeholder key", () => {
|
|
assert.equal(buildRooImport({ baseUrl: "http://x/v1", apiKey: "", model: "m" }).providerProfiles.apiConfigs.OmniRoute.openAiApiKey, "sk_omniroute");
|
|
});
|
|
test("buildRooVscodeAutoImport sets the pointer, preserving other settings", () => {
|
|
const s = buildRooVscodeAutoImport({ "editor.tabSize": 2 }, "/home/u/.omniroute/roo-settings.json");
|
|
assert.equal(s["editor.tabSize"], 2);
|
|
assert.equal(s["roo-cline.autoImportSettingsPath"], "/home/u/.omniroute/roo-settings.json");
|
|
});
|