Files
kilocode/packages/kilo-vscode/docs/nes-examples/02_pattern_continuation.py
T
Firas Trabelsi fe60a467d1 Add Mercury Next Edit (NES) routed through the kilo gateway
Addresses @markijbema's architectural feedback on #10536: moves the HTTP
edit-completion call to the gateway, removes the standalone API-key
setting, and aligns with the provider/model selection design introduced
in #10559.

Wire-level changes
------------------
* New `/kilo/edit` endpoint added to the opencode HttpApi contract
  (`packages/opencode/src/kilocode/server/httpapi/groups/kilo-gateway.ts`)
  and mirrored into `packages/kilo-gateway/src/server/routes.ts` for the
  hono surface. SDK regenerated; `client.kilo.edit({ content, provider,
  model, maxTokens })` is now available.
* `packages/kilo-gateway/src/edit.ts` — `EditTarget` resolver mirroring
  the FIM pattern. Only the Inception provider is wired today (Mistral
  doesn't expose a comparable surface); Kilo Gateway has a placeholder
  branch that returns 400 until a server-side proxy exists.
* `packages/kilo-gateway/src/server/edit.ts` — `createEditHandler` reads
  the Inception BYOK key from `Auth.get("inception")` and falls back to
  `INCEPTION_API_KEY` from env, exactly like the FIM handler.
* The gateway unwraps Mercury's triple-backtick fence (and any
  `<|code_to_edit|>` sentinels) server-side so the VSCode response is
  just the rewritten code.
* `AutocompleteModelDef` gains an optional `kind: "fim" | "edit"`
  discriminator; new entry `inception/mercury-next-edit` (label "Mercury
  Next Edit") sets `kind: "edit"` and shares the wire model
  `mercury-edit-2`.

VSCode-side
-----------
* `MercuryEditProvider` no longer does its own HTTP — it's now a thin
  wrapper around `client.kilo.edit(...)` via `KiloConnectionService`.
* Dropped `kilo-code.new.autocomplete.nextEdit.apiKey` and
  `.nextEdit.baseUrl` settings. Auth and routing live in the gateway.
* The `AutocompleteServiceManager` dispatch now switches on the model's
  `kind` field (set by `getAutocompleteModel(provider, model)`) instead
  of string-comparing a model id, matching Mark's provider+model split.
* The `NextEditInlineCompletionProvider`,
  `NextEditSuggestionManager`, prompt template, parser, editable-region
  selector, edit-history tracker, recently-viewed-snippets adapter, and
  decoration-based jump-to-edit UX remain in the VSCode extension since
  they need editor-specific APIs (`InlineCompletionItem`,
  `TextEditorDecorationType`, keybinding context keys).

Bot review nits resolved
------------------------
* `INLINE_COMPLETION_ACCEPTED_COMMAND` renamed `kilocode.*` →
  `kilo-code.*` to match the project convention.
* `kilo-code.next-edit.acceptOrJump` and `.dismiss` now declared in
  `contributes.commands` so VS Code can resolve them in the palette.
* `disposeLog()` wired into `AutocompleteServiceManager.dispose()` so
  the dedicated "Kilo Code · Next Edit" OutputChannel doesn't leak.
* Per-keystroke "skip — no API key resolved" log removed (the entire
  API-key code path is gone).

Tests
-----
* `bun run check-types:extension` clean
* `bun run lint src` clean
* `bun test src/services/autocomplete/next-edit/__tests__/` — 23/23
  pass

Docs
----
* The partner walkthrough at
  `packages/kilo-vscode/docs/mercury-next-edit-testing.html` and the
  20-test playground under
  `packages/kilo-vscode/docs/nes-examples/` survive from the prior
  iteration. The walkthrough's "Install the PR locally" section still
  applies (the model dropdown choice is now "Mercury Next Edit
  (Inception)" — the API-key step is gone since BYOK is plumbed through
  the gateway's Auth store).

Known follow-ups (not in this commit)
-------------------------------------
* `FileIgnoreController` plumbing through the NES context builder so
  `.env`-style files don't get sent. Hook point identified in
  `NextEditInlineCompletionProvider.buildRequestContext`.
* Settings UI changes in the webview to expose Mercury Next Edit as a
  selectable provider/model pair alongside the FIM entries.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 09:17:53 -07:00

4 lines
59 B
Python

COLOR_RED = "#ff0000"
COLOR_GREEN = "#00ff00"
COLOR_BLUE =