sylwester-liljegren a76dc77380 fix(vscode): support filenames with spaces and unicode in @mentions (#11977)
* fix(vscode): support filenames with spaces and unicode in @mentions

Two bugs prevented @mentions from working correctly when filenames
contained spaces or non-ASCII characters:

1. Sent-message highlighting broke for paths with spaces.
   buildFileAttachments did not set source.text position data on
   file attachments, so the renderer fell back to MENTION_RE which
   uses [\w./-] and stops at whitespace. Now source.text is computed
   via text.indexOf and included in the attachment. The renderer's
   resolve() path uses source.value with indexOf, which handles
   spaces and any Unicode correctly.

2. Server read failed with 'File not found' for paths with spaces.
   VS Code's webview (Chromium) does not percent-encode spaces when
   setting url.pathname on a file:// URL. The resulting literal space
   in url.href caused Bun's fileURLToPath to truncate the resolved
   path at the first space. Spaces are now pre-encoded as %20 before
   assignment.

Additionally, MENTION_RE in message-highlight.ts is updated to
match filenames that include space-separated segments (e.g.
'org data.xlsx') as a fallback for messages that pre-date this fix
and therefore lack source.text data.

* chore: add changeset for file mention spaces/unicode fix

* fix(vscode): address review feedback on mention highlighting

Two issues flagged by review:

1. The broadened MENTION_RE fallback regex over-matched ordinary prose.
   A pattern permissive enough to span space-separated path segments
   also swallows text following any unrelated @mention up to the next
   dotted/versioned token (e.g. '@agent check report for v1.2 details'
   highlighted the entire span through 'v1.2'). Reverted MENTION_RE to
   its original conservative form; the primary fix for space/unicode
   filenames does not depend on it; it now relies on source.text data
   computed in buildFileAttachments and resolved via exact text search.

2. Repeated mentions of the same path in one message only highlighted
   the first occurrence. mentionedPaths is a Set, so buildFileAttachments
   produces exactly one ref per unique path regardless of how many times
   it appears in the text. Once that ref carries source.text, resolve()
   was used instead of the old regex-based detect() fallback, which
   used to independently highlight every occurrence via a global regex
   scan. resolve() now also searches the remaining text for exact repeats
   of each ref's resolved mention value, so every occurrence of a path
   stays highlighted, not just the first.

Added tests covering: over-matching prevention, repeated plain mentions,
and repeated mentions containing a space.

* fix(vscode): require boundary match for repeated mention detection

The repeat-mention search added in 44bea9196e used a plain substring
indexOf, which let a shorter mention's value match as a literal prefix
of a longer, distinct mention that starts the same way (e.g. '@a.ts'
matches inside '@a.tsx'). This truncated the longer mention's highlight
to just its prefix and dropped its own ref from being located.

Repeats are now only accepted when flanked by whitespace or a string
edge on both sides, matching the same token-boundary convention already
used elsewhere (syncMentionedPaths' (?:^|\\s)@path(?:\\s|$) pattern).

Added a regression test for the exact a.ts/a.tsx collision case.

* fix(vscode): relax repeat-mention boundary check to allow punctuation

The whitespace-only boundary check added in 55c58791f0 to prevent
'@a.ts' from falsely matching inside '@a.tsx' was stricter than
necessary: it required literal whitespace on both sides, so a repeated
mention directly followed by ordinary punctuation (a trailing comma,
sentence-ending period, or closing paren) silently lost its highlight.

Replaced the whitespace check with a path-continuation check matching
MENTION_RE's own character class (word chars, dot, slash, hyphen).
A repeat is now rejected only when the adjacent character could extend
it into a longer, different path. The dot is handled with one
character of lookahead: it counts as a continuation only when another
word character follows (e.g. '@report.csv' + '.bak'), so a lone
trailing sentence period does not block highlighting, while a genuine
compound-extension collision still correctly does.

Added tests for: repeat followed by a comma, a sentence-ending period,
a closing paren, and a compound-extension collision that must still
be rejected (@report.csv inside @report.csv.bak).

* fix(vscode): make repeat-mention boundary check Unicode-aware

PATH_CONTINUATION and continuesPath used \w, which in JavaScript regex
matches ASCII letters/digits only. A Cyrillic or CJK mention (e.g.
'@файл') was therefore not recognized as continuing into a longer,
distinct mention that starts the same way (e.g. '@файлы'), silently
reintroducing the same collision the check exists to prevent (the
@a.ts/@a.tsx case) specifically for the non-ASCII paths this PR is
meant to support.

Replaced \w with Unicode property escapes (\p{L}, \p{N} with the u
flag), which correctly recognize any Unicode letter or digit as a
continuation character, not just ASCII ones.

Added regression tests for a Cyrillic prefix collision (@файл inside
@файлы) and a CJK one (@文件 inside @文件夹), both verified to fail
against the prior ASCII-only implementation.

* fix(vscode): fix mention truncation when reverting and resending

Reverting to a message with a space-containing @mention, then resending
the same text, reproduced the 'File not found' truncation error even
after the buildFileAttachments/URL-encoding fix, because the revert path
uses a different, unrelated mechanism to reconstruct known mention paths.

Revert restores the original message's text into the input via a
setChatBoxMessage window message, which PromptInput handles by calling
seedFromText(text). seedFromText re-derives candidate mention paths from
raw text with a regex (the same conservative, space-free pattern as
MENTION_RE) — for '@mention-test/my quarterly report.txt' its slash
alternative matches only 'mention-test/my', stopping at the first space.
That truncated candidate is then added to knownPaths and, critically,
passes syncMentionedPaths' own boundary check too: a real space genuinely
follows 'my' in the full filename, so the truncated candidate looks like
a complete, validly-bounded mention from the regex's perspective. The
truncated path then ends up in mentionedPaths alongside the real one, and
buildFileAttachments builds a second, broken attachment for it, producing
the same truncated 'File not found: ...\mention-test\my' error alongside
a correct read of the real file.

Fix: revertSession() now also extracts the reverted message's file parts'
exact source.path values (recorded by the earlier buildFileAttachments
fix) and sends them alongside the restored text. PromptInput's
setChatBoxMessage handler seeds these exact paths directly via a new
seedFromParts() function instead of falling back to seedFromText's regex
re-derivation, when they're available. seedFromParts skips the flawed
candidate-discovery step entirely and just prunes the known-good paths
against the current text, so it can't reintroduce the truncation.

seedFromText itself is left unchanged and still used as a fallback for
callers without exact path data (native undo restoring a draft, or
messages sent before source.path existed) — broadening its regex to
handle spaces was already tried and reverted elsewhere in this PR because
it causes ordinary prose to be over-matched.

Added tests: a regression test locking in seedFromText's known limitation
(so future refactors don't silently 'fix' it in a way that goes
unnoticed), and coverage for seedFromParts handling a space-containing
path correctly, pruning stale paths, and seeding multiple paths.

* fix(vscode): address review feedback on mention repeats and percent-encoding

- Rework message-highlight.ts's resolve()/repeats() to locate each ref
  independently and track claimed ranges, instead of threading a single
  moving cursor through every ref. Fixes an interleaved-mentions bug where
  locating a later repeat of one mention (e.g. the second `@a.ts` in
  `@a.ts @b.ts @a.ts`) could advance past and hide a distinct mention
  (`@b.ts`) that sits between the repeats.
- Reject a repeat match when it is a literal prefix of another known ref's
  exact mention text, not just when the following character looks like a
  generic path-continuation character. A trailing space can no longer be
  assumed to end a mention now that paths may contain spaces, so
  `@a.txt @a.txt backup.txt` no longer truncates the second, longer mention.
- Escape literal percent characters (in addition to spaces) before assigning
  to the file:// URL's pathname in buildFileAttachments, so a real filename
  like "100%20real.txt" round-trips correctly instead of being decoded as
  "100 real.txt" server-side.

* fix(vscode): fix stale-path collision in syncMentionedPaths for space-containing paths

syncMentionedPaths tested each known path independently with a boundary
regex that treated any whitespace after "@path" as proof the mention ends
there. That assumption broke once paths can contain spaces: a stale,
unrelated "a.txt" from an earlier mention would incorrectly survive
pruning whenever the current text also mentions the longer, distinct
"a.txt backup.txt", since a real space genuinely follows "a.txt" as part
of that longer path. The stale path would then get re-attached via
buildFileAttachments, silently reading the wrong file's contents.

Track already-accepted (longest-first) matches and reject a candidate
occurrence when it's a literal prefix of one of them at the same text
position, mirroring the same fix already applied to message-highlight.ts's
repeat-mention detection.

---------

Co-authored-by: Sylwester Liljegren <sylwester.liljegren@softronic.se>
2026-07-15 19:42:04 +02:00
2026-04-13 10:07:46 -04:00
2026-07-13 18:00:35 +02:00
2026-05-06 12:13:06 +02:00
2026-07-13 16:17:50 +00:00
2026-07-13 18:00:35 +02:00
2026-07-15 10:29:22 +00:00
2026-07-13 18:00:35 +02:00
2026-02-02 18:32:22 -03:00
2026-07-13 18:00:35 +02:00
2026-07-13 18:00:35 +02:00
2026-07-13 18:00:35 +02:00
2026-07-15 10:29:22 +00:00
2026-07-13 18:00:35 +02:00
2026-07-13 18:00:35 +02:00
2026-04-28 14:40:59 -03:00
2026-06-15 21:08:16 -03:00
2026-06-11 12:10:47 +02:00
2026-07-15 10:29:22 +00:00
2025-09-27 04:10:56 -04:00

English | 简体中文 | 繁體中文 | 한국어 | Deutsch | Español | Français | Italiano | Dansk | 日本語 | Polski | Русский | Bosanski | العربية | Norsk | Português (Brasil) | ไทย | Türkçe | Українська | বাংলা | Ελληνικά | Tiếng Việt

Kilo Code logo

The open source coding agent for building with AI in VS Code, JetBrains, or the CLI.

VS Code Marketplace npm X (Twitter) Blog Discord Reddit

Kilo-in-VS-Code-and-CLI


Kilo Code is an AI coding agent that meets you everywhere you work: VS Code, JetBrains, and the CLI. It's open source with open pricing. You pick from 500+ models, switch between them mid-task, and pay the model provider's rate with zero markup. No API keys required to start.

Installation

Pick where you want to run Kilo.

VS Code

Install the Kilo Code extension directly, or grab it from the VS Code Marketplace. Create an account and you'll have access to 500+ models including GPT-5.5, Claude Opus 4.7, Claude Sonnet 4.6, and Gemini 3.1 Pro Preview, all at provider pricing.

CLI
# npm
npm install -g @kilocode/cli

# curl
curl -fsSL https://kilo.ai/cli/install | bash

# pnpm
pnpm add -g @kilocode/cli

# bun
bun add -g @kilocode/cli

# Homebrew (macOS / Linux)
brew install Kilo-Org/tap/kilo

# Arch Linux (AUR)
paru -S kilo-bin

Then run kilo in any project directory to start.

JetBrains

Install the Kilo Code plugin from the JetBrains Marketplace, or search "Kilo Code" in Settings → Plugins inside any JetBrains IDE.

Cloud Agent

Run Kilo from the web, no local machine needed, at app.kilo.ai/cloud.

Code Reviews

Set up automated AI code reviews on your pull requests at app.kilo.ai/code-reviews.

KiloClaw

Spin up your always-on AI agent at app.kilo.ai/claw.

Install the CLI from GitHub Releases (binaries)

Download the latest binary from the Releases page.

Platform Asset
Windows (most PCs) kilo-windows-x64.zip
macOS (Apple Silicon) kilo-darwin-arm64.zip
macOS (Intel) kilo-darwin-x64.zip
Linux x64 kilo-linux-x64.tar.gz
Linux ARM kilo-linux-arm64.tar.gz

Notes: x64-baseline is a compatibility build for older CPUs without AVX. musl is the statically linked build for Alpine or minimal Docker images without glibc. kilo-vscode-*.vsix is the VS Code extension package, not the CLI. Source code archives are for building from source.

Agents

Kilo ships with specialized agents you switch between depending on the task. You can also build your own custom agents.

  • Code - The default. Implements and edits code from natural language.
  • Plan - Designs architecture and writes implementation plans before any code gets written.
  • Ask - Answers questions about your codebase without touching any files.
  • Debug - Troubleshoots and traces issues.
  • Review - Reviews your changes and surfaces issues across performance, security, style, and test coverage.

Learn more about agents and custom agents.

What it does

  • Code generation from natural language, across multiple files.
  • Inline autocomplete with ghost-text suggestions and tab to accept.
  • Self-checking so the agent reviews and corrects its own work.
  • Terminal and browser control to run commands and automate the web.
  • MCP marketplace to find and wire up MCP servers that extend what the agent can do.
  • 500+ models with mid-task switching, so you can match latency, cost, and reasoning to the job.

Autonomous Mode (CI/CD)

Run kilo run with --auto for fully autonomous operation with no prompts, built for CI/CD pipelines:

kilo run --auto "run tests and fix any failures"

--auto disables all permission prompts and lets the agent execute any action without confirmation. Only use it in trusted environments.

Documentation

For configuration and everything else, head over to the docs.

Contributing

Contributions are welcome from developers, writers, and everyone in between. Start with the Contributing Guide for environment setup, coding standards, and how to open a pull request. See RELEASING.md for the VS Code extension and CLI release process, and packages/kilo-jetbrains/RELEASING.md for the JetBrains plugin.

Please review our Code of Conduct before getting involved.

License

MIT. You're free to use, modify, and distribute this code, including commercially, as long as you keep the attribution and license notices. See License.

FAQ

Where did Kilo CLI come from?

Kilo CLI is a fork of OpenCode, enhanced to work within the Kilo agentic engineering platform.


Join the community Discord | X | Reddit

S
Description
Kilo is the all-in-one agentic engineering platform. Build, ship, and iterate faster with the most popular open source coding agent. #1 coding agent on OpenRouter. 1.5M+ Kilo Coders. 25T+ tokens processed
Readme MIT 1.3 GiB
Languages
TypeScript 81.2%
Kotlin 12.5%
CSS 3.1%
JavaScript 2.6%
HTML 0.3%
Other 0.2%