Igor Šćekić aa22680fee refactor(cli): shared-process remote sessions with safe per-session exit (#12327)
* refactor(cli): run remote sessions in one process with safe per-session exit

Consolidate remote session handling into a single CLI process instead of
spawning one process per remote-created session (addresses the PR review):

- restore in-process create_session (accepts an absent sessionId and targets
  the connection directory); remove the session spawner, the
  KILO_REMOTE_ATTACH_SESSION attach-on-boot path, the child-advertisement gate,
  and their tests
- retain instance advertisement and fire one immediate out-of-band heartbeat on
  (re)connect when advertising, so a headless `kilo remote` host is discoverable
  without delay

Make /exit (wire command exit_cli, unchanged for compatibility) detach only the
target session instead of terminating the CLI:

- AttachedState.detach with a presence-suppression tombstone; detach also clears
  the target's SessionStatus so the negative-containment heartbeat fence resolves
  deterministically for busy/retry/offline sessions
- exit_cli handler verifies ownership, cancels the active prompt, detaches and
  awaits the detach heartbeat, then ACKs; the interactive RemoteExit callback is
  invoked only after the ACK when the last owned session exits; a headless
  `kilo remote` host stays alive and advertising at zero sessions
- add an optional canExitSession boolean to the list_commands v1 catalog
  (always true, independent of exitAvailable) so clients can detect safe
  session-exit semantics

History and stored sessions are preserved on exit.

* fix(cli): break module-load cycle in remote session prompt-cancel

The K1 in-process exit_cli seam added a static `import { SessionPrompt }`
to kilo-sessions.ts. @/session/prompt evaluates KiloSessionPrompt at module
load, so the new static edge raced that init and left the namespace in TDZ,
crashing unrelated test files with 'undefined is not an object (evaluating
KiloSessionPrompt.shouldAskPlanFollowup)'. Defer to a dynamic import at the
single call site, mirroring remote-command.ts.

* fix(cli): correct AttachedState announce/detach concurrency and rollback

Address review findings on the shared-process session lifecycle:

- announce/detach no longer join the OPPOSITE in-flight operation. Joining
  detach's negative-containment fence made announce resolve success for a
  detached id (and vice versa: detach joined announce and resolved success
  while still attached, which exit_cli treats as license to ACK/close). Each
  path now joins only a same-kind in-flight op and, when the opposite op is
  in flight, awaits it to settle and then performs the real work.
- Failed-detach rollback now releases the suppression tombstone, so a
  still-attached session is not dropped by the next setPresence (the tombstone
  loop would otherwise remove the still-present id and never clear).
- Both catch/rollback branches now honor the lifecycle generation guard
  (mirroring the success path); a stale in-flight op that rejects after
  reset() no longer mutates the new lifecycle's presence/pending/suppressed
  sets (reset clears the same Set instances).

Adds regression tests for each fix, plus AC6f covering the remote-ws
detachSessionId negative-containment waiter.
2026-07-24 09:39:07 +02:00
2026-07-13 19:15:48 +02:00
2026-04-13 10:07:46 -04:00
2026-07-14 13:03:25 +02:00
2026-05-06 12:13:06 +02:00
2026-07-22 09:38:42 +00:00
2026-07-14 13:03:25 +02:00
2026-07-13 18:00:35 +02:00
2026-07-13 18:00:35 +02:00
2026-07-14 13:03:25 +02:00
2026-07-14 13:03:25 +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

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%