Skip to content

feat(vscode,gateway): route Mercury Next Edit through Kilo Gateway#10644

Merged
markijbema merged 4 commits into
mainfrom
mark/nextedit-kilo-gateway
May 28, 2026
Merged

feat(vscode,gateway): route Mercury Next Edit through Kilo Gateway#10644
markijbema merged 4 commits into
mainfrom
mark/nextedit-kilo-gateway

Conversation

@markijbema
Copy link
Copy Markdown
Contributor

Summary

Adds Kilo Gateway routing for Mercury Next Edit. Companion to #10606 (which added Mercury Next Edit through the direct Inception provider) and cloud#3516 (the gateway endpoint).

A new "Mercury Next Edit via Kilo Gateway" autocomplete model lets users get Next Edit predictions through their Kilo account — no separate Inception API key required.

Changes

  • packages/kilo-gateway/src/autocomplete.ts: new kilo/inception/mercury-next-edit model entry (kind: "edit", providerID: kilo)
  • packages/kilo-gateway/src/edit.ts: resolveEditTarget now returns a real Kilo Gateway URL (/api/nextedit/completions) for kilo edit models
  • packages/kilo-gateway/src/server/edit.ts: handler proxies to the gateway with the standard kilo auth + X-KILOCODE-FEATURE: autocomplete headers, mirroring the FIM handler
  • packages/kilo-vscode/src/services/autocomplete/next-edit/MercuryEditProvider.ts + NextEditInlineCompletionProvider.ts: pass the configured provider/model through instead of hardcoding inception/mercury-next-edit
  • packages/kilo-vscode/package.json: add inception/mercury-next-edit to the autocomplete model enum

Test plan

  • New test in packages/kilo-gateway/test/edit.test.ts covering the kilo gateway target.
  • bun test (kilo-gateway), bun run test:unit (kilo-vscode), and bun turbo typecheck all pass.

Adds a new "Mercury Next Edit via Kilo Gateway" autocomplete model so
users can get Next Edit predictions through their Kilo account without
needing a separate Inception API key. The gateway proxies to the
new /api/nextedit/completions endpoint added in cloud#3516.
Matches the renamed endpoint on the cloud side.
@markijbema markijbema marked this pull request as ready for review May 28, 2026 12:34
"enumDescriptions": [
"Codestral via Kilo Gateway",
"Mercury Edit 2 via Kilo Gateway",
"Mercury Next Edit (multi-line edit predictions with jump-to-edit UX) via Kilo Gateway",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sounds fancy!

Comment thread packages/kilo-vscode/eslint.config.mjs
Comment thread packages/kilo-gateway/src/server/edit.ts
Comment thread packages/kilo-gateway/src/server/edit.ts
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented May 28, 2026

Code Review Summary

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 2
Issue Details (click to expand)

WARNING

File Line Issue
packages/kilo-vscode/eslint.config.mjs 41 max-lines cap for KiloProvider.ts raised from 3600→3700, violating the repo's explicit "do not raise caps; refactor instead" policy

SUGGESTION

File Line Issue
packages/kilo-gateway/src/server/edit.ts 42 !proxy?.auth guard checked after token derivation, inconsistent with FIM handler ordering; unrecognised auth type gives misleading error message
packages/kilo-gateway/src/server/edit.ts 65 Two separate kilo header spreads are slightly redundant — buildKiloHeaders already sets HEADER_FEATURE from env var which the next spread immediately overrides
Other Observations (not in diff)
  • packages/kilo-vscode/src/KiloProvider.ts is currently at 3603 lines — already exceeding the previous 3600 cap before this PR. The cap bump to 3700 is papering over a pre-existing violation. The right fix is to reduce KiloProvider.ts back under 3600 by extracting logic.
  • The getModelSelection callback in AutocompleteServiceManager.ts reads this.settings?.provider / this.settings?.model at request time. settings can be null before the first load() completes — getAutocompleteModel(undefined, undefined) gracefully falls back to the default (Kilo/Codestral FIM) rather than the kilo next-edit model, so this is safe, but the fallback model may not match user intent for a brief window at startup.
  • The new kilo/inception/mercury-next-edit model has label: "Mercury Next Edit" — same as the direct inception entry inception/mercury-next-edit. The provider field ("Kilo Gateway" vs "Inception") distinguishes them in the status bar, so there is no display collision, but it's worth confirming the UI selector surfaces both options clearly.
Files Reviewed (7 files)
  • .changeset/nextedit-via-kilo-gateway.md — no issues
  • packages/kilo-gateway/src/autocomplete.ts — no issues
  • packages/kilo-gateway/src/edit.ts — no issues
  • packages/kilo-gateway/src/server/edit.ts — 2 suggestions
  • packages/kilo-gateway/test/edit.test.ts — no issues
  • packages/kilo-vscode/eslint.config.mjs — 1 warning
  • packages/kilo-vscode/package.json — no issues
  • packages/kilo-vscode/src/services/autocomplete/AutocompleteServiceManager.ts — no issues
  • packages/kilo-vscode/src/services/autocomplete/next-edit/MercuryEditProvider.ts — no issues
  • packages/kilo-vscode/src/services/autocomplete/next-edit/NextEditInlineCompletionProvider.ts — no issues

Fix these issues in Kilo Cloud


Reviewed by claude-4.6-sonnet-20260217 · 903,454 tokens

Review guidance: REVIEW.md from base branch main

@markijbema markijbema merged commit f0eac50 into main May 28, 2026
16 of 18 checks passed
@markijbema markijbema deleted the mark/nextedit-kilo-gateway branch May 28, 2026 12:55
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.

2 participants