* 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.
zodJsonSchema throws for z.custom, z.instanceof, z.symbol, BigInt defaults and
duplicate meta({ id }). The throw escaped both plugin loops and the
ToolRegistry state constructor, so the registry yielded zero tools and every
prompt in the session failed with "Unexpected server error".
Wrap each plugin tool registration in Result.try so a failure is contained to
that tool: it is logged and skipped, every other tool still registers.
v2 already has this boundary (packages/core/src/tool.ts registrationError).
Replace the includeIgnored tool parameter and boolean setting with experimental.glob_include_ignored, a list of gitignore-style folder or file patterns that glob should search even when ignored or hidden.
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
Add an experimental.code_mode config key that routes MCP tool calls
through the confined CodeMode runtime, exposing a single execute tool
with on-demand tool discovery instead of every MCP tool definition.
Expose it as Programmatic Tool Calling in the VS Code Experimental
settings, alongside the existing KILO_EXPERIMENTAL_CODE_MODE env flag,
and add the setting translations for all locales.
Resolve message roles through a covering recall index instead of reading
message rows, pass session ids as one json_each parameter per page, detect
non-ASCII candidates by character against byte length instead of a GLOB
pattern, and cache the per-directory scope check during a search.
Rank whole-word matches above matches inside longer words, return flagged
partial matches with their missing terms when no session contains every
term, and match small typos against session titles only.
Keep reservations through prompt intake, runner completion, and shell cleanup. Report cancellation after the parent turn has ended without emitting another turn close.
Keep disposal bookkeeping in Kilo-owned code and consolidate regression fixtures without dropping the required coverage.
Route drain requests and CLI output through the session owner directory. Simplify notification holds and completion waiters while preserving disposal safety. Cover local, attached, and daemon cross-directory runs.
The task tool picked the last text part of the subagent's final message as
its result. Subagents that ran with memory context get a synthetic, ignored,
empty text part (the memory marker) appended after their answer, so findLast
surfaced an empty <task_result> to the parent agent. The extractor now skips
synthetic, ignored, and empty text parts, and background jobs no longer let
an empty run overwrite an earlier non-empty result on extend.
Fixes#13469
- Add kilocode_change markers to all shared upstream files touched
- Log MCP callTool failures instead of silently swallowing them
- Remove redundant type casts on the callTool result
- Make ReadResourcePayload.server required (schema-level validation)
and drop the now-dead BadRequest guard
- Remove unused meta field from ReadResourceContent schema
- Add KILO_EXPERIMENTAL_MCP_APPS runtime flag
- Expose clientName on McpTool interface and populate it during tool listing
- Add POST /experimental/resource/read and POST /experimental/mcp/call-tool HTTP endpoints
- Gate both endpoints behind experimentalMcpApps flag
- Propagate mcpApp UI metadata (resourceUri, serverId) in tool call results
when tools advertise _meta.ui.resourceUri in their definition
- Add docs/kilo-headless-embedding.md for headless and embedding capabilities
- Fix test fixtures to include clientName in McpTool mocks
- narrow the retry gate to active scenarios (TodoScenario has no reset field)
and type the retry accumulator as Result; both surfaced only in the PR
typecheck job because the scenario union changed in the main merge
- annotate every changed line in shared upstream files with kilocode_change
markers (websearch Env migration, exerciser isolation/retry, pty deadline,
storage layer-injection tests)
- drop duplicate .inProject({ git: true }) calls on the worktree scenarios
left behind by the main merge (main and this branch each added one)
Closes#12996. Part of #12986.
- websearch resolves KILO_WEBSEARCH_PROVIDER, EXA_API_KEY and
PARALLEL_API_KEY through Env.Service in the tool body and threads
them into the pure helpers; selectWebSearchProvider takes the
override as a parameter.
- mcp-websearch no longer snapshots EXA_API_KEY into a module-level
URL at import time; exaUrl(key) derives it per call, so BYOK keys
set or cleared after startup are honored.
- Tool registry provides Env.node.
- kilo-tool-process-env allowlist is now empty; check:architecture
drops from 15 to 9 classified ratchet sites.
- Transform/model tests confirmed running in-process via plain
bun test (455 tests, <1s), the other half of #12996.
warpgrep.ts, the third file in the original ratchet, was already
removed on main.
* fix: make tool invalid-arguments errors clearly actionable to the model
* fix: address kilo-code-bot review on schema error formatting
Return a jargon-free actionable message when the schema formatter yields no issues (instead of the raw SchemaError), and match Effect's missing-key message case-insensitively so it survives library wording changes.
Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
* Address review: cap rendered issues, isolate Kilo logic, harden the fallbacks
- Move formatter/format/path/reason out of the shared upstream tool.ts into
packages/opencode/src/kilocode/tool/tool.ts.
- Cap output at 20 issues / 4 KiB with an '...and N more' suffix, since
validation fails before the normal output truncation.
- Return a readable message when the formatter yields zero issues instead of
falling back to SchemaError jargon.
- Match missing-key messages with a regex instead of an exact string compare.
- Rewrite the changeset around the user-visible outcome.
* chore: annotate the reformatted decode call with kilocode_change markers
The multi-line reformat left lines 122-125 unannotated in a shared upstream
file. Wrap the whole statement in a start/end block instead of per-line inline
markers, and drop the two now-redundant inline ones. Comments only.
---------
Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Christiaan Arnoldus <christiaan.arnoldus@outlook.com>
* feat: add signal-to-noise controls to grep tool
Add configurable options to reduce noise in grep results:
- context: show N lines before/after each match
- limit: bound maximum matches (default 100) with early termination
- literal: treat pattern as plain text instead of regex
- ignoreCase: case-insensitive matching
These controls help models avoid overwhelming context windows with too
many matches and provide clear guidance when results are truncated.
Implementation preserves upstream ripgrep structure with minimal Kilo
hooks for additive behavior only. Shared-file changes reduced from 183
to 60 lines compared to initial implementation.
* test(core): tolerate PTY event publication race
* fix(cli): count grep matches independently of context