Skip to content

feat(cli): setup-kilo — configure Kilo Code for OmniRoute (CLI auth + VS Code settings) - #4284

Merged
diegosouzapw merged 1 commit into
release/v3.8.30from
feat/kilo-cli
Jun 19, 2026
Merged

diegosouzapw merged 1 commit into
release/v3.8.30from
feat/kilo-cli

Conversation

@diegosouzapw

Copy link
Copy Markdown
Owner

What

CLI #5. omniroute setup-kilo configures Kilo Code (kilocode.kilo-code, a Cline/Roo descendant) to use OmniRoute. Both surfaces (per the VS-code-extension strategy):

  • ~/.local/share/kilo/auth.json (CLI mode): auth["openai-compatible"] = { apiKey, baseUrl WITH /v1, model }.
  • VS Code settings.json (extension): kilocode.customProvider (name/baseURL/apiKey) + kilocode.defaultModel — only touched when the file already exists.

Remote-aware (--remote/--api-key → active context → localhost). Model via --model or an interactive pick from /v1/models. Prints the exact UI settings to paste. Both files merged (preserve existing).

Researched: Kilo's openAiBaseUrl needs /v1 (it appends /chat/completions) — unlike Cline (root). Matches the dashboard cli-tools/kilo-settings schema.

Validation

  • Remote (VPS v3.8.30): setup-kilo --remote --dry-run --model glm/glm-5-turbo → correct auth.json (+ VS Code skip when absent) + UI hints.
  • Kilo's wire (/v1/chat/completions) already validated → "OK".
  • 6 unit tests; check:cli-i18n ✓.

Series: Codex #4270 · Claude #4274 · OpenCode #4277 · hardening #4278 · Cline #4280 · Kilo (this). Next: Continue, Cursor, Roo, Crush, Goose, Qwen Code, Gemini CLI, Aider.

🤖 Generated with Claude Code

… VS Code settings)

CLI #5 of the series. `omniroute setup-kilo` configures Kilo Code
(kilocode.kilo-code, a Cline/Roo descendant) to use OmniRoute.

Two surfaces (both written, matching the dashboard cli-tools/kilo-settings):
- ~/.local/share/kilo/auth.json — CLI mode: auth["openai-compatible"] =
  { apiKey, baseUrl (WITH /v1 — Kilo appends /chat/completions), model }.
- VS Code settings.json — extension: kilocode.customProvider (name/baseURL/apiKey)
  + kilocode.defaultModel. Only touched when the file already exists.

Remote-aware (--remote/--api-key → active context → localhost). Model via --model
or an interactive pick from /v1/models (Kilo's extension has no auto-discovery).
Prints the exact UI settings to paste. Merges both files (preserves existing).

Researched against current Kilo docs: confirmed openAiBaseUrl needs /v1 (unlike
Cline's root url), the openai-compatible keys, and the export/import + CLI surfaces.
Kilo's wire (/v1/chat/completions) already validated → "OK".

Tests: buildKiloAuth (provider + /v1 + merge + key fallback), buildKiloVscodeSettings
(kilocode.* keys + preserve), resolveKiloTarget (/v1 ensure, key win). 6 unit tests;
check:cli-i18n green.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the setup-kilo command to configure Kilo Code for OmniRoute, along with corresponding documentation and unit tests. The review feedback identifies a critical issue where JSON parsing failures in readJson are silently swallowed, returning an empty object. This would cause the command to overwrite and wipe out existing user configurations. The reviewer suggests returning null on parse failures and handling this to abort or skip updates safely.

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.

Comment on lines +69 to +76
function readJson(path) {
try {
if (existsSync(path)) return JSON.parse(readFileSync(path, "utf8"));
} catch {
/* corrupt/missing */
}
return {};
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

If JSON.parse fails (which is very common for VS Code settings.json because it often contains comments or trailing commas), readJson silently returns {}. This causes the command to completely overwrite and wipe out the user's entire VS Code settings.json or Kilo auth.json with only the new keys, resulting in catastrophic data loss. Returning null on parse failure allows us to detect corrupt/invalid JSON and skip/abort writing to prevent data loss.

Suggested change
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 {
return null;
}
}

Comment on lines +123 to +129
const auth = buildKiloAuth(readJson(authPath), { apiKey, baseUrl, model });
// Only touch VS Code settings.json if it already exists (avoid creating a
// bogus one for users who don't use that VS Code variant).
const vscodeExists = existsSync(vscodePath);
const vscodeSettings = vscodeExists
? buildKiloVscodeSettings(readJson(vscodePath), { apiKey, baseUrl, model })
: null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

We must handle the case where readJson returns null (indicating a JSON parsing failure). If so, we should abort or skip the file update to prevent silently wiping out the user's existing configuration.

  const existingAuth = readJson(authPath);
  if (existingAuth === null) {
    printError("Failed to parse Kilo CLI auth file at " + authPath + ". Aborting to prevent data loss.");
    return 1;
  }
  const auth = buildKiloAuth(existingAuth, { apiKey, baseUrl, model });
  // Only touch VS Code settings.json if it already exists (avoid creating a
  // bogus one for users who don't use that VS Code variant).
  const vscodeExists = existsSync(vscodePath);
  let vscodeSettings = null;
  if (vscodeExists) {
    const existingVscode = readJson(vscodePath);
    if (existingVscode === null) {
      printError("Failed to parse VS Code settings at " + vscodePath + " (it may contain comments or trailing commas). Skipping VS Code settings update to prevent data loss.");
    } else {
      vscodeSettings = buildKiloVscodeSettings(existingVscode, { apiKey, baseUrl, model });
    }
  }

@diegosouzapw
diegosouzapw merged commit 70bd6fb into release/v3.8.30 Jun 19, 2026
4 checks passed
@diegosouzapw
diegosouzapw deleted the feat/kilo-cli branch June 19, 2026 15:57
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
… VS Code settings) (diegosouzapw#4284)

CLI diegosouzapw#5 of the series. `omniroute setup-kilo` configures Kilo Code
(kilocode.kilo-code, a Cline/Roo descendant) to use OmniRoute.

Two surfaces (both written, matching the dashboard cli-tools/kilo-settings):
- ~/.local/share/kilo/auth.json — CLI mode: auth["openai-compatible"] =
  { apiKey, baseUrl (WITH /v1 — Kilo appends /chat/completions), model }.
- VS Code settings.json — extension: kilocode.customProvider (name/baseURL/apiKey)
  + kilocode.defaultModel. Only touched when the file already exists.

Remote-aware (--remote/--api-key → active context → localhost). Model via --model
or an interactive pick from /v1/models (Kilo's extension has no auto-discovery).
Prints the exact UI settings to paste. Merges both files (preserves existing).

Researched against current Kilo docs: confirmed openAiBaseUrl needs /v1 (unlike
Cline's root url), the openai-compatible keys, and the export/import + CLI surfaces.
Kilo's wire (/v1/chat/completions) already validated → "OK".

Tests: buildKiloAuth (provider + /v1 + merge + key fallback), buildKiloVscodeSettings
(kilocode.* keys + preserve), resolveKiloTarget (/v1 ensure, key win). 6 unit tests;
check:cli-i18n green.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant