Commit Graph
481 Commits
Author SHA1 Message Date
Igor Šćekić 8045e72da2 fix(cli): apply permission rules to workflow and subagent tool calls (#16499)
* fix(cli): apply permission rules to workflow and subagent tool calls

* fix(cli): apply the edit and read permissions to their tool aliases

* fix(cli): keep a path-scoped rule from changing a tool's preapproval

* fix(cli): single-source the tool-to-permission map

The workflow tool gate and the disabled-tool check each carried their own
copy of the map from a tool name to the permission that governs it. The gate
read a local map and the check read two inline arrays, so a new alias, or a
changed one, could apply to only one of them.

Export one resolver from Permission and read it from both places, and extend
the gate test to the resource tools so a drift in their aliases fails.

* test(cli): cover the workflow tool and subagent delegation wiring

The gate and the task permission check had unit tests, but nothing exercised
the session wiring that installs them. Add two test files:

- workflow-attach: reaches the real workflow branch through a provider stub and
  drives the installed executor, so a whole-tool rule, an unoffered name, a
  path-scoped rule and each result shape are asserted against the code that
  runs them.
- named-agent-types: drives a real prompt turn whose message names a subagent,
  and asserts the turn delegates and creates the child session.

Both fail when the corresponding wiring changes.

* test(cli): resolve the session service through the test layer

The named-agent test created its session through the global runtime handle.
Dispose that handle in the test instead and let the compiled layer do the
work, matching the other session tests in this directory.

* test(cli): resolve the session and prompt services in one scope

The named-agent test created its session through a separate runtime, so the
database instance it wrote to was not the one the prompt read. Resolve both
services from the same layer and create the session inside that scope.

* fix(cli): keep the tool-to-permission lookup to its own entries

A name that the map does not define resolved to an inherited built-in
member instead of itself, so the gate handed a non-string to the wildcard
matcher and the call failed with a thrown error rather than the gate's
not-available answer. The map now answers only for the entries it
declares.

Also mark the removed wildcard import in the session runtime and pin the
scoped-rule ordering and the unknown-name answer in tests.

* docs(cli): state what the workflow preapproval list contains

The gate also lists a tool that no rule covers, and one whose matching
rule is scoped to a path. The comment now says that, so a later change
does not narrow the list by mistake.
2026-11-22 16:44:40 +01:00
Christiaan Arnoldus b11ecb4d71 fix(cli): settle Kilo charge from usage.cost, upstream cost only for BYOK (#16098) 2026-11-12 09:57:01 +01:00
webreflection 56df55386e fix(vscode): images not shown on kilo 2026-11-03 12:05:38 +01:00
Kirill Kalishev 7214bcc439 Merge pull request #14776 from Kilo-Org/merry-dolphin
fix: prevent a rejected attachment from discarding the prompt
2026-10-07 15:19:30 -04:00
kirillk 27eeb14206 fix(cli): relabel SVG attachments as text instead of sending them as images
An SVG prompt attachment was decoded into synthetic text, but the retained
file part kept mime image/svg+xml. message-v2 forwards every file part that
is not text/plain, so the model still received an image/svg+xml part that
providers reject -- and because the user message is persisted, every later
turn replayed it.

Relabel markup to text/plain once, before parts are resolved. The existing
text/plain paths then do the work: a data: URL yields its source as synthetic
text, a file:// URL goes through the real Read tool (gaining its numbering and
size/binary limits), and message-v2 skips the persisted part. This also lets
the two bespoke markup branches and the base64 cap special case go away, so
the shared prompt.ts delta shrinks.

Also fix three precheck regressions this branch introduced:

- An image whose declared mime is wrong but whose bytes decode (JPEG sent as
  image/png) was rejected. Photon decodes by content, so validate the sniffed
  format instead. Image.dimensions covers exactly the formats Photon handles,
  so it still rejects BMP, which Photon traps on.
- Line-wrapped base64 was rejected by a canonical round-trip comparison, even
  though Buffer.from decodes it fine.
- A malformed non-base64 data URL threw URIError out of decodeURIComponent and
  lost the message. Reject it for every mime, not just rasters: markup reaches
  the same decode.

Reported by @brunoagatao.
2026-10-07 13:09:24 -04:00
kirillk c58468b1c6 fix(cli): clear cached MCP status when a server is uninstalled
Removing an MCP server via the marketplace (or Settings) only wrote the
config file; it never told the live MCP service. status() resurrects a
removed server's last-known state from two in-memory caches that
disconnect() only partially clears and nothing else purges, so a
server that had reached needs_auth kept reporting that status forever,
even after the config entry, companion skill, and receipt were all
correctly removed from disk.

Add MCP.Interface.remove(name), which purges clients/defs/instructions/
status/config for a server (unlike disconnect, which only disables it).
MarketplaceInstaller.removeMcp now calls it after a successful removal,
via a new Services.mcp field threaded through from the kilocode HTTP
handlers rather than Effect context, so install()/remove() stay usable
from callers without the full MCP layer.

Verified against a real installed MCP server (config entry, companion
skill, and marketplace receipt) through both a direct Effect call and
the live /kilocode/marketplace/remove HTTP endpoint: the server no
longer reappears in status() or marketplace metadata after removal.

Also syncs bun.lock's stale kilo-jetbrains version entry (7.8.1) with
the already-bumped package.json (7.8.3).
2026-10-05 14:42:24 -04:00
kirillk 8c232de808 Merge remote-tracking branch 'origin/main' into merry-dolphin
# Conflicts:
#	packages/opencode/src/session/prompt.ts
2026-10-05 11:22:21 -04:00
kirillk 225c393f41 fix: prevent a rejected attachment from discarding the prompt
Attaching an SVG killed the entire request and permanently lost the
typed message. The prompt pipeline gated on a raw `mime.startsWith("image/")`
check and handed the bytes to Photon, a raster-only decoder, so an SVG
raised a fatal ImageDecodeError. Because the user message is persisted
last, that defect destroyed the text along with the attachment, and
prompt_async had already returned 204 and cleared the editor, leaving
nothing to recover.

Route non-raster image mimes away from the raster decoder, reusing the
existing isImageAttachment exclusions via a new classifier. SVG is now
decoded into readable source, matching how text attachments already work.

Reject an undecodable raster attachment synchronously in both prompt
routes so prompt_async can no longer promise acceptance and then fail,
and surface a readable message instead of a bunfs stack trace.

On the JetBrains side, stop claiming SVG and BMP are model-ingestible
images, keep the submitted text and attachments so a failed send can
restore them, and give a standalone error card a Dismiss action since it
has no transcript tail for Retry to continue.
2026-10-03 11:14:17 -04:00
kirillk 75847050ad Merge remote-tracking branch 'origin/main' into frosty-acorn 2026-10-02 17:35:41 -04:00
Caleb Norman 17a6a7cd6b fix(cli): tell the parent a subagent was cancelled by the user
A cancelled task result gave no reason, so a parent that needed the subagent's output treated it as a failure and immediately started a replacement subagent (7 of 7 live runs). Reporting 'Task cancelled by the user' stopped that (0 of 5) without instructing the model. Only an explicit stop or delete cancels a task while its parent is still awaiting it.
2026-10-02 10:55:33 -04:00
kirillk c9632e4951 feat: consolidate MCP OAuth in core
Move authentication-failure classification and browser ownership into the CLI protocol so clients no longer duplicate heuristics or open browsers on the backend machine. Add a non-destructive cancel endpoint, emit authorization URLs for client-driven flows, regenerate the SDK, and migrate VS Code to the typed contract while leaving the API ready for JetBrains adoption.
2026-10-02 09:54:42 -04:00
Caleb Norman 6dda4b78e5 refactor(cli): stop subagents from the TUI like the VS Code task card
Double Esc in the subagent view now sends the same tree-scoped abort as VS Code's task-card Stop, so the parent keeps running and receives the existing 'Task cancelled' result. Drops the server-side interruption message; packages/opencode only gains a test pinning that the parent is not aborted.
2026-10-01 12:32:20 -04:00
Caleb Norman d627b31855 feat(cli): interrupt a subagent from its view with double Esc
Double Esc in a subagent view aborts only that subagent (scope=session) while the parent keeps working. The parent's task tool reports the stop as a deliberate user interruption and is told not to relaunch the subagent on its own, keeping the task_id for a user-requested resume. Exit keys need a second press in the subagent view.
2026-09-30 17:21:32 -04:00
marius-kilocode a28b93b19e chore: merge main and reconcile Bun lockfile 2026-09-25 10:36:49 +02:00
marius-kilocode 17a62b88cc feat(vscode): stream tool input into pending tool rows
The CLI publishes live tool input deltas, and the extension host parses the partial arguments into throttled pending part updates. Pending rows now show the file path, command, and a live line count, and an open write card shows the last lines of the file as the model writes it.
2026-09-23 10:49:10 +02:00
marius-kilocode 74140de2f3 Merge remote-tracking branch 'origin/main' into marius-kilocode/kilo-opencode-v1.18.26 2026-09-22 19:44:00 +02:00
Igor Šćekić 5edf432c2f fix(session): keep the session when compaction returns an empty summary (#14318)
https://github.com/Kilo-Org/kilocode/pull/14318
2026-09-22 13:52:35 +02:00
marius-kilocode af64102498 Merge OpenCode v1.18.21 through v1.18.26
Upstream sync covering v1.18.21, v1.18.22, v1.18.23, v1.18.24, v1.18.25, and
v1.18.26. Conflicts resolved in favor of Kilo behavior where the fork
intentionally diverges:

- Azure plugin keeps Kilo's resource-name/base-url prompts while adopting
  upstream Microsoft Entra ID sign-in through the Azure CLI
- provider request headers keep Kilo's x-kilocode-mode and X-KILOCODE-* set
  alongside upstream's x-parent-session-id
- Bedrock reasoning replay filtering stays gated to Claude models
- retry keeps Kilo's behavior of not surfacing the OpenCode Go upsell
- config keeps Kilo normalization, warnings, and updateGlobal/update
  delegation while adopting upstream V2-compat lowering
- session tool context keeps Kilo's processor.metadata and askPermission

Merge repairs:

- restore the SDK ./permission export and the client ./promise and UI
  ./file-path, ./session-diff, ./pierre subpath exports
- keep the Kilo workspace dependency for @opencode-ai/client in session-ui
- restore the HttpServerRequest import required by Kilo's SSE stream
- keep Kilo-Org repository URLs in packages/http-recorder
- remove the upstream-only SST unlock workflow
- adapt upstream tests that assert upstream behavior for Kilo divergences
2026-09-22 11:31:51 +02:00
marius-kilocode 8995256c88 refactor: kilo compat for v1.18.26 2026-09-22 10:15:20 +02:00
marius-kilocode 2129ab2257 Merge remote-tracking branch 'origin/main' into johnnyeric/kilo-opencode-v1.18.20
# Conflicts:
#	bun.lock
#	packages/opencode/package.json
#	packages/opencode/src/cli/cmd/run.ts
#	packages/opencode/src/server/routes/instance/httpapi/handlers/provider.ts
#	packages/sdk/js/script/build.ts
2026-09-21 15:32:05 +02:00
marius-kilocode 93862bb100 Merge remote-tracking branch 'origin/main' into johnnyeric/kilo-opencode-v1.18.18
# Conflicts:
#	nix/hashes.json
2026-09-21 14:38:21 +02:00
marius-kilocode 9a74f1ad33 Merge remote-tracking branch 'origin/main' into johnnyeric/kilo-opencode-v1.18.15
# Conflicts:
#	package.json
2026-09-21 13:52:24 +02:00
marius-kilocode 1d187e857d refactor(cli): remove deprecated review command aliases
Remove the /local-review and /local-review-uncommitted aliases and their static notice paths. Keep /review and its scopes as the single review command.
2026-09-16 12:51:18 +02:00
Johnny Eric Amancio 7480a48f43 merge: reconcile latest v1.18.15 base into v1.18.18 2026-09-03 18:22:41 +02:00
Johnny Eric Amancio 0aff14dc16 Merge remote-tracking branch 'origin/main' into johnnyeric/kilo-opencode-v1.18.15
# Conflicts:
#	packages/opencode/src/session/session.ts
2026-09-03 15:42:39 +02:00
Igor Šćekić cf2127ef8e fix(opencode): share session status across worktree contexts (#13685)
* fix: fix-live-session-advertiseme-4533 patch delivery

* chore: annotate kilocode_change markers for the status store

* chore: avoid the AppRuntime token in the status test comment

* fix: address-the-automated-review-8a43 patch delivery

* Fix the failed cli verification gate (kwf address-the-automated-review-8a43/gr1)

* Drop the unrelated bun.lock reorder to keep the diff minimal (kwf address-the-automated-review-8a43/s1)

* chore: cover the set() closing brace in the kilocode_change block
2026-09-02 13:41:59 +02:00
f1330aceb5 fix(cli): surface real tool name when tool call repair fails (#13446)
* fix(cli): surface real tool name when tool call repair fails

When the model emits a malformed tool call that cannot be repaired by
case-insensitive matching, experimental_repairToolCall renamed the call
to the hidden "invalid" tool. That tool is excluded from activeTools,
so the AI SDK rejected it with a confusing "unavailable tool 'invalid'"
error that did not tell the model what it did wrong.

Return null instead so the original NoSuchToolError or
InvalidToolInputError surfaces with the actual tool name and the list of
available tools, letting the model self-correct.

Fixes #6905

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>

* refactor(tool): remove orphaned invalid tool

The experimental_repairToolCall fallback that produced tool calls named
"invalid" was replaced with null in this PR, so nothing generates
"invalid" tool calls anymore. Remove the now-orphaned InvalidTool
definition, its registry registration, and its TUI renderer, along with
the parameters test and snapshot that covered it.

Agent-Signature: kilo-auto/efficient-remove-orphaned-invalid-tool on behalf of maphew

* Revert "refactor(tool): remove orphaned invalid tool"

This reverts commit f6176d61f3.

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>

* ci: re-trigger pipeline (flaky background-process teardown on loaded shard)

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>

---------

Co-authored-by: maphew <486200+maphew@users.noreply.github.com>
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
2026-09-01 14:17:16 +02:00
Johnny Eric Amancio 6a7d6bc002 resolve merge conflicts 2026-08-27 15:13:58 +02:00
Johnny Eric Amancio 9563af96a0 refactor: kilo compat for v1.18.20 2026-08-27 13:50:27 +02:00
Johnny Eric Amancio dae08d08e0 fix: address upstream merge review findings 2026-08-25 13:16:53 +02:00
Johnny Eric Amancio 2f5410d9ed fix: address upstream merge review findings 2026-08-25 11:54:21 +02:00
Johnny Eric Amancio c9861e9548 resolve merge conflicts 2026-08-24 15:08:20 +02:00
Johnny Eric Amancio 6ef57a694e refactor: kilo compat for v1.18.18 2026-08-24 14:04:20 +02:00
Johnny Eric Amancio c14316a7d6 Merge remote-tracking branch 'origin/main' into johnnyeric/kilo-opencode-v1.18.15 2026-08-21 16:16:07 +02:00
chrarnoldusandkiloconnect[bot] 1663c27e7a fix(llm): preserve provider message alternation
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
2026-08-21 07:41:58 +00:00
chrarnoldusandkiloconnect[bot] 43c4491560 fix(cli): send max-step instruction as user message
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
2026-08-21 07:30:33 +00:00
Johnny Eric Amancio c50f6be6af Merge remote-tracking branch 'origin/main' into johnnyeric/kilo-opencode-v1.18.15
# Conflicts:
#	packages/opencode/src/tool/truncate.ts
#	packages/opencode/test/tool/truncation.test.ts
2026-08-19 14:25:26 +02:00
marius-kilocode da10638654 fix: remove agent requirements feature 2026-08-19 11:35:11 +02:00
Johnny Eric Amancio 3a10be340d resolve merge conflicts 2026-08-07 16:07:19 +02:00
Johnny Eric Amancio 7f36c5044a refactor: kilo compat for v1.18.15 2026-08-07 14:03:32 +02:00
Johnny Eric Amancio d99467fa02 resolve merge conflicts 2026-08-06 14:10:41 +02:00
Johnny Eric Amancio 4174457a0d Merge remote-tracking branch 'origin/main' into johnnyeric/kilo-opencode-v1.18.0
# Conflicts:
#	package.json
2026-08-06 14:02:04 +02:00
Johnny Eric Amancio cce22e608f merge: upstream v1.18.13 2026-08-06 00:31:20 +02:00
Johnny Eric Amancio 0fff61fa62 refactor: kilo compat for v1.18.13 2026-08-06 00:00:45 +02:00
Johnny Eric Amancio 88083fb5c5 resolve merge conflicts 2026-08-05 16:01:49 +02:00
Johnny Eric Amancio 76783409bf refactor: kilo compat for v1.18.0 2026-08-05 11:59:08 +02:00
kirillk 324291c3bf Merge remote-tracking branch 'origin/main' into jetbrains-pixel-icons
# Conflicts:
#	packages/opencode/src/snapshot/index.ts
2026-08-04 18:51:43 -04:00
kirillk ebebad02e7 feat(jetbrains): authoritative full-file editor diffs with local fallback
The diff editor tab now shows whole-file diffs (with collapsible unchanged
regions) for modified files, while inline session cards stay hunk-bounded.

diffSides resolves full before/after with a safe precedence:
1. Authoritative: query the CLI's snapshot diff (full=true&file=...), which
   reads the exact turn's before/after from snapshot commits via git show and
   is correct even for historical/reverted turns.
2. Fallback: reverse-apply the hunk patch onto the working-tree file locally,
   so it works against the current pinned CLI until the new one is released.
3. Hunk view: if neither yields full content (drift/binary/added/deleted),
   render the existing patch.

The CLI change is minimal and additive: full-content logic lives in the
kilo-owned diff-full.ts (DiffFull.detail); shared files only gain thin
kilocode_change hooks (FileDiff before/after, Snapshot.diffFile, the summary
full/file branch, and the diff query fields).
2026-08-04 18:13:55 -04:00
Johnny Eric Amancio 6c138449d5 Merge remote-tracking branch 'origin/main' into johnnyeric/kilo-opencode-v1.17.13
# Conflicts:
#	package.json
#	packages/core/schema.json
#	packages/core/src/command.ts
#	packages/core/src/config/plugin/command.ts
#	packages/core/src/database/schema.gen.ts
#	packages/core/src/session/sql.ts
#	packages/core/src/v1/session.ts
#	packages/kilo-docs/public/img/screenshot-tests/kilo-vscode/visual-regression/agentmanager/full-screen-diff-with-changes-chromium-linux.png
#	packages/kilo-docs/public/img/screenshot-tests/kilo-vscode/visual-regression/labs-tool-call-lab/search-previews-chromium-linux.png
#	packages/opencode/src/command/index.ts
#	packages/opencode/test/server/httpapi-ui.test.ts
#	packages/sdk/js/src/v2/gen/types.gen.ts
#	packages/sdk/openapi.json
#	packages/tui/src/routes/session/index.tsx
2026-08-04 12:57:20 +02:00
Igor Šćekić 1f3a3b2d83 feat(attachments): add remote CLI file delivery (#12747)
* fix(cli): clarify remote binary attachment notice

* feat(cli): add remote send_file tool

* docs(mobile): explain remote session attachments

* fix(cli): keep delivered files out of model context

* fix(cli): mark delivery filter as kilocode change

* fix(cli): preserve delivered image files

* test(cli): narrow delivery attachment state

* fix(send-file): preserve filesystem failures

* test(send-file): assert propagated file read error
2026-08-03 13:12:11 +02:00