Commit Graph

7413 Commits

Author SHA1 Message Date
Mark IJbema ecbbe7faeb fix: remove noisy next-edit hot-path logs 2026-05-27 11:28:03 +02:00
Firas Trabelsi 7437f77374 Move NES prompt templating to the gateway + wire FileIgnoreController
Addresses the two remaining points from @markijbema's review.

Prompt templating now lives in the gateway
-------------------------------------------
The Mercury sentinel-prompt assembly moved out of the VSCode extension
into packages/kilo-gateway/src/edit-prompt.ts. Clients now send
structured editor context (currentFileContent, cursor position,
editable region, recently-viewed snippets, edit-diff history) and the
gateway builds the sentinel-tagged prompt. This keeps the entire
Mercury contract — endpoint, auth, prompt format, response parsing — in
one place that VS Code, JetBrains, and the TUI can all share, instead
of each editor re-implementing the templating.

- New EditBody is the structured context (was: a pre-built `content`
  string). Updated the opencode HttpApi schema, the hono zod validator,
  both handlers, and regenerated the SDK.
- Deleted the VSCode-side mercuryPromptTemplate.ts (+ spec); the tests
  moved to packages/kilo-gateway/test/edit-prompt.test.ts.
- VSCode constants.ts now holds only the editable-region sizing; the
  sentinel tokens live in the gateway.

FileIgnoreController
--------------------
NES must not send ignored files (.env, secrets, anything matched by
.gitignore/.kilocodeignore) to the server. The NES provider now:
- skips the request entirely if the active document fails
  ignoreController.validateAccess(), and
- filters recently-viewed snippets through the same controller before
  they go into the prompt.
It reuses the classic provider's FileIgnoreController instance (now
public) rather than building a second one.

Also: dropped the implicit nextEdit.debug config read in log.ts (debug
is env-only via KILO_NES_DEBUG) so no VSCode autocomplete config is
added — per the "config should move to the backend" guidance.

Validation: typecheck clean across kilo-gateway, opencode, kilo-vscode;
lint clean; gateway 46 tests, vscode next-edit 10 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 17:04:07 -07:00
Firas Trabelsi ca2642438f Address review feedback: NES correctness, dedupe, tests
Two-agent review pass on the gateway-routed NES change. Fixes:

Correctness (🔴)
- MercuryEditProvider read the HTTP status off the parsed error body
  (`error.status`, always undefined), so 401/402 never reached
  onFatalError and NES had no credit-exhausted/auth backoff. Now reads
  `response.status` from the SDK result.
- NextEditSuggestionManager applied "insert" suggestions without the
  apply-time drift re-validation the "replace" path already had — edits
  between the anchor and insertion point could land the insert in the
  wrong place. Now re-checks the anchor line before inserting.
- The opencode Effect edit handler collapsed every upstream failure to
  HTTP 400; now passes the real status through (mirrors the FIM handler)
  so 401/402/429/5xx are distinguishable under the experimental backend.

Conciseness / DRY (🔴)
- Deleted dead module editCompletionParser.ts (+ spec): the gateway
  unwraps the fence server-side now, so the VSCode-side parser was unused.
- Hoisted the triplicated extractFencedBody into a single exported
  function in kilo-gateway/src/edit.ts; both the hono and Effect handlers
  import it. Added a shared EditUpstreamResponse type to replace three
  inline copies.

Robustness (🟡)
- extractFencedBody now keeps the body when the closing fence is missing
  (truncated/max_tokens output) instead of dropping the suggestion.
- EditHistoryTracker seeds snapshots on document open so the first edit
  in a freshly-opened file is captured (was previously dropped).
- Single-line inserts that span non-blank lines below the cursor (a
  multi-line→single-line collapse) now route to the decoration path
  instead of emitting a ghost item VSCode can't render.

Cleanup (🟡)
- Removed unused constants (MERCURY_EDIT_MODEL_ID, INCEPTION_API_BASE_URL,
  INCEPTION_EDIT_PATH).
- getProviderKey typed to DirectAutocompleteProviderID (matches FIM).
- resolveEditTarget keys on kind==="edit" defensively, so a future
  FIM-only Inception model can't resolve to the edit endpoint.
- AutocompleteModelDef doc comments made endpoint-neutral (not "FIM").
- Declared the internal accept command in contributes.commands.

Tests
- New packages/kilo-gateway/test/edit.test.ts: resolveEditTarget routing
  (incl. the mercury-edit-2 FIM model must NOT reach the edit endpoint)
  and extractFencedBody variants (lang tag, sentinels, truncation, blank
  lines, no-fence).
- typecheck clean across kilo-gateway, opencode, kilo-vscode; lint clean;
  all unit tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 16:14:29 -07:00
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
Catriel Müller 2ebdbb2fe5 Merge pull request #10413 from LifeJiggy/clean/windows-cli-6307
fix(cli): make bash tool description Windows-aware
2026-05-26 11:53:25 -03:00
Marius 59762f5842 Merge pull request #10581 from Kilo-Org/uncovered-salary
feat(vscode): enable voice input for signed-in Kilo users
2026-05-26 16:16:09 +02:00
marius-kilocode 722eb44d63 feat(vscode): enable voice input for signed-in Kilo users 2026-05-26 15:45:48 +02:00
Catriel Müller 784c12ab3d refactor: keep platform as OS and added kilomarkers 2026-05-26 14:05:55 +01:00
LifeJiggy b4a10bb0e2 fix(cli): port Windows-aware bash tool description to refactored prompt.ts 2026-05-26 14:05:55 +01:00
Mark IJbema 80f8781cbc refactor(gateway): make FimTarget a discriminated union
Replace `urls: string[]` with provider-specific shapes: kilo and inception
each carry a single `url`, mistral carries no urls (its dual-endpoint
fallback is encapsulated in requestMistralFim). Removes the non-null
assertion on `urls[0]` and the dead "No FIM endpoint configured" branch.
Also tightens `getProviderKey` to take `DirectAutocompleteProviderID`,
which now follows naturally from the narrowed union and prevents the
`DIRECT_FIM_ENV["kilo"]` undefined-lookup footgun.
2026-05-26 13:39:55 +02:00
Mark IJbema 80e39c29eb Merge branch 'main' into mark/direct-autocomplete-fim-providers 2026-05-26 13:25:04 +02:00
Mark IJbema 923d955c86 fix: address autocomplete FIM review findings 2026-05-26 13:08:19 +02:00
Imanol Maiztegui bacfa4ae62 Effect Migration for Kilo callsites (#10572)
* refactor(opencode): migrate agent promise helpers to kilocode module and adopt Effect-based tests

Remove legacy promise-based helpers (`get`, `list`, `defaultAgent`, `remove`)
from the core agent module and update callsites to use the dedicated
`@/kilocode/agent` module directly. Migrate kilocode-specific tests from
`WithInstance.provide` patterns to the `testEffect` helper with Effect
generators for cleaner, more idiomatic test code.

- Remove `makeRuntime` import and exported promise helpers from agent.ts
- Update HTTP API handlers to import from `@/kilocode/agent` instead of
  re-exported `Agent` namespace
- Rewrite agent tests to use `load()` helper or Effect service access
- Convert agent-global-config-dirs and agent-skill-permissions tests to
  `testEffect` pattern
- Reorder SDK type definitions (BackgroundProcessLogs/WorkspaceWarpError)

* chore(auth): remove legacy promise helpers and replace with direct Effect service access

Eliminate the exported promise-based convenience functions (`get`, `all`,
`set`, `remove`) from the Auth module and replace all callsites with
explicit `AppRuntime.runPromise` or `makeRuntime` invocations that access
`Auth.Service` directly through Effect's service pattern.

- Delete `makeRuntime`-backed promise helpers from auth/index.ts
- Update CLI entrypoint, kilo-sessions, indexing, and server instance to
  use `AppRuntime.runPromise(Auth.Service.use(...))` for auth access
- Inject `Auth.Service` as a dependency into the ModelsDev layer and
  consume it via Effect generator instead of promise wrapper
- Create a local `makeRuntime` instance in model-cache.ts for non-Effect
  callsites that still need promise-based auth access
- Rewrite tests to manipulate auth.json directly on disk with proper
  save/restore semantics instead of relying on removed helpers

* refactor(suggestion): convert suggest tool to Effect-native with injected Command dependency

Transform the suggestion tool from async/promise-based implementation to
idiomatic Effect generators with explicit dependency injection of the
Command service rather than importing and calling module-level helpers.

- Convert `resolvePrompt` from async function to Effect generator that
  accepts a `Command.Interface` parameter
- Refactor `SuggestTool` definition to yield `Command.Service` from the
  Effect context and thread it through to `resolvePrompt`
- Add `Command.Service` as a dependency to the tool registry layer and
  provide `Command.defaultLayer` in both production and test wiring
- Remove unused `makeRuntime` import and exported `get` helper from
  command/index.ts
- Add explicit type annotations to Auth delegate in server instance
- Rewrite suggestion tests to use `testEffect` helper with a mock
  `Command.Service` layer instead of spying on module exports

* feat(git): migrate WorktreeFamily to Effect service and wire Git.Service as dependency

Convert WorktreeFamily.list from an async function using legacy promise
helpers to an Effect generator that yields Git.Service from context,
eliminating the need for the removed `run` promise wrapper in git/index.

- Replace `WorktreeFamily.list()` async function with Effect.fn generator
  that obtains Git.Service and InstanceState from the Effect context
- Remove legacy `makeRuntime`/`run`/`runPromise` exports from git module
- Update RecallTool to thread Git.Service through to WorktreeFamily calls
  via EffectBridge
- Add Git.Service as a required dependency in tool registry and HTTP
  server route layers
- Update all test layers to provide Git.defaultLayer

* chore(mcp): replace legacy promise helpers with Effect-native AppRuntime calls

Remove exported promise-based `status`, `connect`, and `disconnect`
helpers from MCP module and convert the network recovery callsite in
SessionNetwork to use AppRuntime.runPromise with Effect.gen directly.

* refactor(auth): adopt makeRuntime helper for Auth service resolution in kilo modules

Replace AppRuntime.runPromise with locally scoped makeRuntime instances
in kilo-sessions and kilocode/indexing modules, removing the dependency
on the global AppRuntime singleton for Auth service access.

* fix(test): simplify cleanup error handling in provider test

Replace try-catch block with promise .catch() for file unlink operation
during test teardown.
2026-05-26 12:51:21 +02:00
Mark IJbema bbc57f6540 Merge branch 'main' into mark/direct-autocomplete-fim-providers 2026-05-26 12:29:21 +02:00
Mark IJbema d02145a549 refactor(gateway): simplify Mistral FIM endpoint cache 2026-05-26 11:44:13 +02:00
Mark IJbema c073dac91f refactor(gateway): clarify Mistral FIM endpoint helper 2026-05-26 11:25:32 +02:00
Mark IJbema 4ca226c83f fix(gateway): cache working Mistral FIM endpoint 2026-05-26 11:08:19 +02:00
Marius d00bdbf5df Merge pull request #10485 from Kilo-Org/fix-subagent-error-recovery
fix(cli): surface failed subagent task errors
2026-05-26 10:59:01 +02:00
Marius bcda744dfc Merge pull request #10443 from Kilo-Org/subagent-model-reasoning-config
feat: configure task subagent model defaults
2026-05-26 10:58:57 +02:00
marius-kilocode a416b40273 Merge remote-tracking branch 'origin/main' into fix-subagent-error-recovery
# Conflicts:
#	packages/opencode/src/tool/task.ts
#	packages/opencode/test/tool/task.test.ts
2026-05-26 10:42:07 +02:00
Mark IJbema e5b2bb8628 fix(gateway): preserve FIM gateway model passthrough 2026-05-26 10:22:16 +02:00
Mark IJbema 19719ba491 fix(gateway): use env keys for direct FIM providers 2026-05-26 10:20:55 +02:00
Mark IJbema 08124be60b Merge remote-tracking branch 'origin/main' into mark/direct-autocomplete-fim-providers
# Conflicts:
#	packages/kilo-gateway/src/server/routes.ts
#	packages/sdk/js/src/v2/gen/sdk.gen.ts
#	packages/sdk/js/src/v2/gen/types.gen.ts
2026-05-26 09:43:57 +02:00
kilo-maintainer[bot] 20675fdbeb release: v7.3.10 2026-05-26 07:28:31 +00:00
Catriel Müller 30dc7fdde7 Merge pull request #10302 from IamCoder18/fix/tui-export-all-messages
fix(cli): export all messages from TUI instead of truncated store
2026-05-25 17:41:25 -03:00
kirillk 936bb25f2a test(cli): annotate Windows skip call sites 2026-05-25 11:30:54 -04:00
kirillk 4c90e6f03b test(cli): skip Windows-incompatible opencode tests 2026-05-25 11:28:07 -04:00
Aarav d6dabdff62 Merge branch 'main' into fix/tui-export-all-messages 2026-05-25 07:09:05 -06:00
kilo-maintainer[bot] 0da40bad26 release: v7.3.9 2026-05-25 12:14:16 +00:00
Marian Alexandru Alecu 0ef52d5d5a Merge branch 'main' into local-review-base-picker 2026-05-25 11:05:47 +03:00
Joshua Lambert ea1479ccb0 Merge branch 'main' into rambunctious-chicory 2026-05-24 15:55:34 -04:00
Alex Alecu 57c291f68c fix(cli): keep workspace patch test scoped 2026-05-23 22:43:00 +03:00
Alex Alecu 6d8c9b1d4e fix(cli): make untracked patches portable on Windows 2026-05-23 11:00:22 +03:00
Alex Alecu 51ee32f286 fix(cli): stabilize workspace patch test on Windows 2026-05-23 10:36:10 +03:00
Aarav 01040890d5 Merge branch 'main' into fix/tui-export-all-messages 2026-05-22 17:24:27 -06:00
Aarav Sharma 27a4137496 fix(cli): prevent data-loss in TUI transcript copy/export on SDK error
Both the copy and export handlers now pass `{ throwOnError: true }` to
`sdk.client.session.messages()` and drop the `?? []` fallback, so a failed
fetch (404/400/network) throws into the existing catch block and surfaces an
error toast instead of silently writing/returning an empty transcript.
2026-05-22 16:43:58 -06:00
Alex Alecu d41324c084 Merge remote-tracking branch 'origin/main' into local-review-base-picker
# Conflicts:
#	packages/opencode/test/acp/agent-interface.test.ts
2026-05-22 22:44:11 +03:00
Alex Alecu f19d8ef6e5 fix(cli): harden local review suggestion handling 2026-05-22 22:14:53 +03:00
Catriel Müller b52a2115d3 Merge pull request #10513 from Kilo-Org/dynamic-department
Add background process support
2026-05-22 15:17:54 -03:00
Alex Alecu df786a7264 fix(cli): type ACP runtime methods 2026-05-22 19:39:23 +03:00
Alex Alecu 80f3d65e33 fix(cli): accept free-form local-review input 2026-05-22 19:35:37 +03:00
Catriel Müller b96bf3da31 fix: tests / gradle 2026-05-22 13:19:07 -03:00
Marian Alexandru Alecu 538960f420 Merge branch 'main' into local-review-base-picker 2026-05-22 19:16:55 +03:00
Catriel Müller 72854fab76 Merge pull request #10510 from Kilo-Org/dust-cork
fix(cli): reset terminal modes on TUI exit
2026-05-22 11:46:09 -03:00
Imanol Maiztegui 810905d99e Merge pull request #10517 from Kilo-Org/imanol/post-merge-fixes
chore: address post 1.14.41 merge review comments
2026-05-22 16:20:05 +02:00
Alex Alecu ab923c8ab5 fix(cli): focus local reviews on high-signal issues 2026-05-22 17:15:36 +03:00
Imanol Maiztegui fdc46ddfea chore: clean up post-merge artifacts and rebrand references
Remove accidentally committed Gradle build cache files from the
JetBrains package, add the .gradle directory to .gitignore, and
update user-facing strings from "opencode.json" to "kilo.json".
2026-05-22 15:58:59 +02:00
Marian Alexandru Alecu ccfec216a0 Merge pull request #10502 from Kilo-Org/track-accepted-suggestion-telemetry
feat: track accepted review suggestions
2026-05-22 16:56:27 +03:00
Catriel Müller 5696a1937e fix: test 2026-05-22 10:52:14 -03:00
Catriel Müller 2062335803 fix: fix test 2026-05-22 10:42:20 -03:00