feat(cli): setup-roo — configure Roo Code for OmniRoute (import JSON + autoImport + UI) - #4292
Conversation
…+ autoImport + UI) 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.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Code Review
This pull request introduces the setup-roo CLI command to configure Roo Code for OmniRoute, along with associated documentation and unit tests. The feedback highlights critical improvements for robustness and cross-platform compatibility: preventing potential data loss by throwing an error if the VS Code settings.json fails to parse, wrapping the settings update in a try-catch block, and dynamically resolving the VS Code settings path for macOS and Windows instead of hardcoding the Linux path.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| function readJson(path) { | ||
| try { | ||
| if (existsSync(path)) return JSON.parse(readFileSync(path, "utf8")); | ||
| } catch { | ||
| /* corrupt/missing */ | ||
| } | ||
| return {}; | ||
| } |
There was a problem hiding this comment.
Returning {} when a file exists but fails to parse is extremely dangerous. VS Code settings.json files often contain comments or trailing commas, which cause JSON.parse to throw. If we return {} here, the caller will merge the new setting into {} and overwrite the user's entire settings.json file, causing complete data loss of their VS Code configuration. We should throw an error if the file exists but cannot be parsed.
| function readJson(path) { | |
| try { | |
| if (existsSync(path)) return JSON.parse(readFileSync(path, "utf8")); | |
| } catch { | |
| /* corrupt/missing */ | |
| } | |
| return {}; | |
| } | |
| function readJson(path) { | |
| if (!existsSync(path)) return {}; | |
| try { | |
| return JSON.parse(readFileSync(path, "utf8")); | |
| } catch (err) { | |
| throw new Error(`Malformed JSON or unsupported comments/trailing commas: ${err.message}`); | |
| } | |
| } |
| if (vscodeExists) { | ||
| const merged = buildRooVscodeAutoImport(readJson(vscodePath), importPath); | ||
| writeFileSync(vscodePath, JSON.stringify(merged, null, 2) + "\n", "utf8"); | ||
| printSuccess(`Set roo-cline.autoImportSettingsPath in ${vscodePath}`); | ||
| } |
There was a problem hiding this comment.
Wrap the VS Code settings update in a try-catch block. If readJson throws an error (e.g., due to parsing failure of a file with comments), we must catch it and abort the write operation to prevent overwriting and destroying the user's VS Code settings.
if (vscodeExists) {
try {
const merged = buildRooVscodeAutoImport(readJson(vscodePath), importPath);
writeFileSync(vscodePath, JSON.stringify(merged, null, 2) + "\n", "utf8");
printSuccess(`Set roo-cline.autoImportSettingsPath in ${vscodePath}`);
} catch (err) {
printError(`Skipped updating VS Code settings to prevent data loss: ${err.message}`);
}
}| const vscodePath = | ||
| opts.vscodeSettings ?? opts["vscode-settings"] ?? join(os.homedir(), ".config", "Code", "User", "settings.json"); |
There was a problem hiding this comment.
The default VS Code settings path is hardcoded to the Linux path (~/.config/Code/User/settings.json). This will fail to locate the settings file on macOS (which uses ~/Library/Application Support/Code/User/settings.json) and Windows (which uses %APPDATA%\\Code\\User\\settings.json). We should resolve this path dynamically based on the operating system platform.
| const vscodePath = | |
| opts.vscodeSettings ?? opts["vscode-settings"] ?? join(os.homedir(), ".config", "Code", "User", "settings.json"); | |
| const defaultVscodePath = | |
| os.platform() === "win32" | |
| ? join(process.env.APPDATA || join(os.homedir(), "AppData", "Roaming"), "Code", "User", "settings.json") | |
| : os.platform() === "darwin" | |
| ? join(os.homedir(), "Library", "Application Support", "Code", "User", "settings.json") | |
| : join(os.homedir(), ".config", "Code", "User", "settings.json"); | |
| const vscodePath = opts.vscodeSettings ?? opts["vscode-settings"] ?? defaultVscodePath; |
…+ autoImport + UI) (diegosouzapw#4292) CLI diegosouzapw#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.
What
CLI #8.
omniroute setup-rooconfigures Roo Code (RooVeterinaryInc.roo-cline, a Cline fork) for OmniRoute. Roo's live settings are opaque VS Code globalStorage, but it supports Settings Import +roo-cline.autoImportSettingsPath.~/.omniroute/roo-settings.json(provider profile:apiProvider=openai,openAiBaseUrlWITH/v1, key, model).roo-cline.autoImportSettingsPathin VS Code settings.json when present (preserves other settings).Validation
setup-roo --remote --dry-run --model glm/glm-5-turbo→ correct import doc./v1/chat/completions) already validated → "OK". 5 unit tests;check:cli-i18n✓.Series: …Continue #4289 · Cursor #4291 · Roo (this). Next: Crush, Goose, Qwen Code, Gemini CLI, Aider.
🤖 Generated with Claude Code