Skip to content

feat: add Kilo Code support (CLI, VS Code and JetBrains) - #2495

Open
vasiliy-mikhailov wants to merge 10 commits into
git-ai-project:mainfrom
vasiliy-mikhailov:feat/kilo-code
Open

vasiliy-mikhailov wants to merge 10 commits into
git-ai-project:mainfrom
vasiliy-mikhailov:feat/kilo-code

Conversation

@vasiliy-mikhailov

@vasiliy-mikhailov vasiliy-mikhailov commented Nov 24, 2026 •

Copy link
Copy Markdown

Stacked on #2494. GitHub can't base a PR on a fork branch, so this PR targets main and also contains #2494's commits. Please review only the commits after #2494: feat: add Kilo Code support and the review fixes fix(kilo): …, fix(opencode): remove the pre-XDG default plugin…, fix(opencode): keep the active plugin when XDG_CONFIG_HOME aliases ~/.config, fix(kilo,opencode): isolate tests from XDG_CONFIG_HOME, tighten Kilo detection, fix(opencode): don't let an undeletable old plugin block install, fix(kilo): find the JetBrains plugin in every per-user IDE config dir and fix(jetbrains): follow symlinked IDE version dirs in the plugin scan. The PR shrinks to those once #2494 merges.

Summary

Adds Kilo Code by reusing the OpenCode integration, as suggested on #1254 (this supersedes the earlier attempts #762, #1254 and #1466). Kilo is an OpenCode fork: its CLI, its VS Code extension (spawns a bundled kilo serve) and its JetBrains plugin (downloads a pinned CLI and runs kilo serve) all load global plugins from ~/.config/kilo/plugins/ through the OpenCode V1 plugin API and keep sessions in an OpenCode-schema SQLite DB under ~/.local/share/kilo.

  • Preset: kilo = the OpenCode preset with KILO_FAMILY (tool kilo, kilo.db / kilo-<channel>.db, GIT_AI_KILO_STORAGE_PATH). The CLI and the JetBrains backend write channel DBs (kilo-rc.db); the VS Code extension forces kilo.db.
  • Installer: KiloInstaller (83 lines incl. tests) implements OpenCodePluginAgent and writes the shared plugin with preset kilo to ~/.config/kilo/plugins/git-ai.ts. Detection: kilo binary, ~/.config/kilo, ~/.local/share/kilo, .kilo/.kilocode, or the kilocode.kilo-code-* extension in VS Code-family editors.
  • Transcripts: kilo uses the OpenCode reader. Recovery: Kilo commit-agent markers.

Tests (TDD)

  • Unit: preset records tool kilo, bash classification, kilo.db resolution, installer install/check/uninstall and extension-only detection.
  • Integration (tests/integration/kilo.rs): direct checkpoints attribute lines to kilo with the session's model; the installer-generated plugin through the V1 hook API; the CLI's channel DB; an AI insert above known-human lines keeps them human.

Locally: cargo test --lib (2559 passed), integration opencode kilo install attribution_recovery bash_tool streams_e2e e2e_user_scenarios simple_additions (335 passed), cargo fmt --check, cargo clippy --all-targets -D warnings (Rust 1.93).

End-to-end (real model, real IDEs, in Docker)

DeepSeek-V4.1-Flash through an OpenAI-compatible gateway; a human types in the IDE, Kilo edits through its own UI, then git ai blame / git ai stats are checked per line:

Setup Human only AI only Human + AI in one commit
VS Code 1.146 + Kilo Code 7.8.28 ✅ ✅ kilo::deepseek-v4.1-flash ⚠️ see note
IntelliJ IDEA 2026.3 + Kilo Code for JetBrains 7.1.12 ✅ ✅ kilo::deepseek-v4.1-flash ✅ human lines h_…, Kilo lines s_…
kilo run (CLI 7.8.28) – ✅ –
OpenCode CLI 1.19.6 (regression) ✅ ✅ opencode::deepseek-v4.1-flash ⚠️ see note

Note: in those runs the human's lines had no known-human checkpoint and sat right after the AI block at EOF, so post-commit edge recovery (docs/bash-attribution-recovery-plan.md) credited them to the AI, as designed. With a known-human checkpoint (JetBrains run, and the new integration test) they stay human.

Also seen, pre-existing and unrelated to this PR: Kilo 7.8.x and OpenCode 1.19.6 log [git-ai opencode] failed to initialize plugin: … 'ctx.tool.hook' from the plugin's V2 setup() path; the V1 hooks still fire, so attribution works.

🤖 Generated with Claude Code


Devin Review

… agents; find sessions in channel DBs

Prepare the OpenCode integration for OpenCode forks (Kilo Code) that load the
same plugin and use the same SQLite schema under different names:

- presets/opencode.rs: per-agent names and paths move into `OpenCodeFamily`
  (tool, data dir, DB file name, storage env var); the preset parses through
  `parse_family`. Behavior for OpenCode is unchanged.
- The SQLite lookup now also considers per-channel DBs (`opencode-<channel>.db`)
  next to `opencode.db` and picks the one containing the session, so builds
  that write channel DBs no longer record the model as "unknown". Cost is one
  directory listing plus one indexed query per candidate DB, in the checkpoint
  process only (no git calls, nothing on the daemon ingestion path).
- agent-support/opencode/git-ai.ts: new `__GIT_AI_PRESET__` placeholder. A copy
  that only substitutes the binary path keeps working as the OpenCode plugin.
- mdm/agents/opencode.rs: `OpenCodePluginAgent` trait (name, id, process names,
  detection, legacy plugin paths) with one shared HookInstaller impl;
  OpenCodeInstaller keeps its legacy ~/.config/opencode/plugin/ cleanup.

Tests: channel-DB model resolution (integration), preset substitution and
default (plugin test), installer placeholder substitution (unit).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CLAassistant

CLAassistant commented Nov 24, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

devin-ai-integration[bot]

This comment was marked as resolved.

vasiliy-mikhailov and others added 3 commits November 25, 2026 07:26
A binary path containing the preset token kept its literal text only
if the path is substituted last.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Kilo Code is an OpenCode fork: its CLI, its VS Code extension (which spawns a
bundled `kilo serve`) and its JetBrains plugin (which downloads a pinned CLI
and runs `kilo serve`) all load global plugins from ~/.config/kilo/plugins/
through the OpenCode V1 plugin API and store sessions in an OpenCode-schema
SQLite DB under ~/.local/share/kilo. So Kilo reuses the OpenCode integration:

- presets: `kilo` preset = the OpenCode preset with KILO_FAMILY (tool "kilo",
  kilo.db / kilo-<channel>.db, GIT_AI_KILO_STORAGE_PATH). The CLI and the
  JetBrains backend write channel DBs; the VS Code extension forces kilo.db.
- mdm: KiloInstaller implements OpenCodePluginAgent, writing the shared plugin
  with preset "kilo" to ~/.config/kilo/plugins/git-ai.ts. Detected via the kilo
  binary, its config/data dirs, .kilo/.kilocode, or the Kilo Code extension in
  VS Code-family editors.
- streams: "kilo" uses the OpenCode transcript reader.
- attribution_recovery: Kilo commit-agent markers.

Tests: preset parsing and bash classification, kilo.db resolution, installer
install/check/uninstall and extension-only detection, plus integration tests for
direct checkpoints with model, the installed plugin through the V1 hook API,
the CLI's channel DB, and an AI insert above known-human lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d legacy and KILO_DB databases

- Install, check and uninstall the plugin under $XDG_CONFIG_HOME/<agent>,
  where Kilo and OpenCode load it (xdg-basedir), falling back to ~/.config.
- Detect Kilo Code for JetBrains from its plugin dir, before its managed
  kilo backend first runs.
- Read Kilo sessions from a KILO_DB override and from a pre-rename
  opencode-<channel>.db in Kilo's data dir, as Kilo itself does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
devin-ai-integration[bot]

This comment was marked as resolved.

Older releases wrote ~/.config/opencode/plugins/git-ai.ts regardless of
XDG_CONFIG_HOME. Treat that copy as a legacy path: check reports it as
installed but outdated, install removes it, and uninstall removes and
reports it alongside the current plugin.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
devin-ai-integration[bot]

This comment was marked as resolved.

vasiliy-mikhailov and others added 2 commits November 25, 2026 10:52
….config

Legacy cleanup compared raw paths, so a symlinked XDG dir made the active
plugin look like a leftover copy and install unlinked it. Compare file
names and resolved parent dirs instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…detection

- Installer tests clear and restore XDG_CONFIG_HOME, so they never write to
  or delete from the real config dir; drop a test that read the live env.
- Detect the Kilo Code extension only from 7.0, the first version built on
  the Kilo CLI that loads plugins; stop treating `.kilocode` as a Kilo install.
- Find Kilo's data dir with the preset's resolver, which honors XDG_DATA_HOME.
- Install reports the leftover plugin files it removes (dry run included)
  instead of "already up to date"; install and uninstall share the removal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
devin-ai-integration[bot]

This comment was marked as resolved.

vasiliy-mikhailov and others added 2 commits November 25, 2026 12:39
Install's cleanup of old plugin copies is best effort again: a copy that
can't be removed (e.g. in a read-only dotfiles dir) is logged and left
alone, and the active plugin is still written. Uninstall still fails loudly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Kilo detection only checked the plugins dirs of IDEs found in the standard
install locations, so an IDE unpacked elsewhere (e.g. ~/apps/idea) was
missed. List the per-user JetBrains/Google config dirs directly instead,
reusing the existing per-platform plugins-dir layout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
devin-ai-integration[bot]

This comment was marked as resolved.

`DirEntry::file_type` doesn't follow links, so a version dir moved to
another drive and linked back was skipped. Use `Path::is_dir`, which
follows links and still drops plain files and broken links.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vasiliy-mikhailov

Copy link
Copy Markdown
Author

Hi! Could a maintainer please approve the workflow runs for #2495 (Kilo Code support)? It's from a fork, so CI is waiting on "Approve and run" (all runs show action_required on head 4c268e5).

What's already checked:

  • Devin review: all 8 threads resolved on the current head.
  • Local, Rust 1.93.0: cargo fmt --check and clippy -D warnings are clean. The Kilo and OpenCode integration tests pass (6 and 39). The full suite passes except for flaky daemon_mode timing tests, which fail the same way on main.
  • E2E in Docker with real VS Code + Kilo Code against DeepSeek: human-only, AI-only, and mixed human+AI scenarios all attribute correctly.

The PR builds on #2494 (OpenCode-family refactor), which also needs approval. Thanks!

@vasiliy-mikhailov

Copy link
Copy Markdown
Author

@svarlamov @acunniffe could one of you approve the workflow runs for #2495 and #2494 when you have a moment? Both are from a fork, so CI is waiting on "Approve and run". Thanks!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants