From c445f56ae39ad13016ef4511e4e95dd9e7adb86e Mon Sep 17 00:00:00 2001 From: Akshad Jogi <107343579+akshad-exe@users.noreply.github.com> Date: Sun, 22 Nov 2026 18:31:36 +0530 Subject: [PATCH] docs(setup): document Kilo Code registration and its config layers (#13413) * docs(setup): document Kilo Code registration and its config layers Add the missing Kilo Code section to the client configuration guide: the config root, the user-scope layer order Kilo loads, the last-present-layer write rule, the entry shape, and the legacy extension MCP files Kilo still merges at its lowest precedence, which REA does not inspect. Cover the Windows and macOS default file and a kilo.jsonc round trip that keeps comments, settings and other servers through setup and uninstall. Plan the default location with the row's platform path functions, as the other client helpers do, instead of appending file names with the host's. Co-Authored-By: Claude Opus 5.5 * docs(setup): say only rea mcp add keeps a disabled Kilo entry Setup's refresh treats enabled as a managed key and writes Kilo's default enabled: true; only rea mcp add preserves an existing enabled: false. Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- docs/getting-started/client-configuration.md | 23 +++++++ src/application/KiloClientLocation.ts | 8 ++- .../filesystem/kiloClientLocation.test.ts | 60 ++++++++++++++++++- 3 files changed, 87 insertions(+), 4 deletions(-) diff --git a/docs/getting-started/client-configuration.md b/docs/getting-started/client-configuration.md index 7f126db34d..ffb5421a04 100644 --- a/docs/getting-started/client-configuration.md +++ b/docs/getting-started/client-configuration.md @@ -935,6 +935,29 @@ relative additional entry depends on Goose's working directory, so REA refuses it. Goose reads its configuration at startup; restart it after setup. +## Kilo Code + +For [Kilo Code](https://kilo.ai/docs/automate/mcp/using-in-kilo-code), setup +and `rea mcp add` write `mcp.rea` into the last user-scope file Kilo loads. +Kilo's config root is `$XDG_CONFIG_HOME/kilo` when `XDG_CONFIG_HOME` is set, +otherwise `~/.config/kilo`, on every OS including Windows. Kilo reads that +root's `config.json`, `kilo.json`, `kilo.jsonc`, `opencode.json` and +`opencode.jsonc`, then the `KILO_CONFIG` file, then `~/.kilocode`, `~/.kilo` and +`KILO_CONFIG_DIR`, each for `kilo.jsonc`, `kilo.json`, `opencode.jsonc` and +`opencode.json`. When none of those files exists, setup creates `kilo.json` in +the root (or in an empty `KILO_CONFIG_DIR`). A relative Kilo path depends on +Kilo's working directory, so REA refuses it. The entry is +`{ "type": "local", "command": [exe, ...args], "enabled": true }`, plus +`environment` only when it is non-empty. `rea mcp add` preserves an existing +`enabled: false`; `rea setup` sets `enabled: true`. +`KILO_CONFIG_CONTENT` is Kilo's highest layer and is never edited (see +[installation](installation.md)); project registration with `rea mcp add` is in +the [CLI guide](cli.md). Kilo also reads its legacy extension MCP files +(`mcpServers` in the VS Code extension's `mcp_settings.json`, and the project +`.kilocode/mcp.json` and `.kilo/mcp.json`) at the lowest precedence, below any +`kilo.json` layer. REA neither inspects nor removes them, so a `rea` entry added +there by hand stays in effect after uninstall. + ## WorkBuddy For [WorkBuddy](https://www.workbuddy.cn/docs/workbuddy/From-Beginner-to-Expert-Guide/Function-Description/MCP-Guide), setup writes `mcpServers.rea` into the diff --git a/src/application/KiloClientLocation.ts b/src/application/KiloClientLocation.ts index a627b7f4cc..0f78f2f200 100644 --- a/src/application/KiloClientLocation.ts +++ b/src/application/KiloClientLocation.ts @@ -175,14 +175,16 @@ export const kiloDefaultLocation = ( const explicit = kiloExplicitFile(context); const custom = kiloExplicitDirectory(context); const homes = kiloHomePaths(context); + // The row is planned for its platform, which tests choose apart from the host. + const pathApi = context.root.platform === "win32" ? win32 : posix; return { - configPath: join(root, "kilo.json"), + configPath: pathApi.join(root, "kilo.json"), configPaths: [ - ...KILO_GLOBAL_FILES.map((name) => join(root, name)), + ...KILO_GLOBAL_FILES.map((name) => pathApi.join(root, name)), ...(explicit === undefined ? [] : [explicit]), ...[...homes, ...(custom === undefined ? [] : [custom])].flatMap( (directory) => - KILO_DIRECTORY_FILES.map((name) => join(directory, name)), + KILO_DIRECTORY_FILES.map((name) => pathApi.join(directory, name)), ), ], markerPath: root, diff --git a/tests/boundary/filesystem/kiloClientLocation.test.ts b/tests/boundary/filesystem/kiloClientLocation.test.ts index d0e1d3252c..9c19f8b9ae 100644 --- a/tests/boundary/filesystem/kiloClientLocation.test.ts +++ b/tests/boundary/filesystem/kiloClientLocation.test.ts @@ -1,7 +1,8 @@ import { registerMcpClientsOnHost } from "../../fixtures/mcpRegistration.js"; import { HOST_PLATFORM } from "../../../src/platform/HostPlatform.js"; import { mkdir, readFile, rm, writeFile } from "node:fs/promises"; -import { join } from "node:path"; +import { join, posix, win32 } from "node:path"; +import { parse as parseJsonc } from "jsonc-parser"; import { afterEach, beforeEach, expect, it, vi } from "vitest"; import { readEffectiveClientRegistrationConfiguration } from "../../../src/application/ClientConfigurationFiles.js"; @@ -66,6 +67,63 @@ it("writes Kilo's kilo.json in its config root until another layer exists", asyn }); }); +it.each([ + ["win32", "C:\\Users\\x", win32], + ["darwin", "/Users/x", posix], +] as const)( + "defaults Kilo's file to .config/kilo/kilo.json on %s without XDG_CONFIG_HOME", + (hostPlatform, home, pathModule) => { + const row = supportedClients(home, hostPlatform, {}).find( + ({ name }) => name === "kilo", + ); + expect(row?.configPath).toBe( + pathModule.join(home, ".config", "kilo", "kilo.json"), + ); + }, +); + +it("keeps comments, settings and other servers through setup and uninstall of kilo.jsonc", async () => { + const home = await createTestTempDirectory("rea-kilo-jsonc-"); + const root = join(home, ".config", "kilo"); + await mkdir(root, { recursive: true }); + const target = join(root, "kilo.jsonc"); + await writeFile( + target, + `{ + // line comment + "theme": "dark", /* block comment */ + "mcp": { "other": { "type": "local", "command": ["x"] } } +} +`, + ); + const row = await kiloRow(home); + if (row === undefined) throw new Error("Kilo row is missing"); + expect(row.configPath).toBe(target); + expect(await configureClientConfiguration(row, {}, command)).toMatchObject({ + status: "configured", + }); + const preserved = async () => { + const text = await readFile(target, "utf8"); + expect(text).toContain("// line comment"); + expect(text).toContain("/* block comment */"); + const parsed = parseJsonc(text) as { + theme?: string; + mcp: Record; + }; + expect(parsed.theme).toBe("dark"); + expect(parsed.mcp.other).toEqual({ type: "local", command: ["x"] }); + return parsed; + }; + expect((await preserved()).mcp.rea).toMatchObject({ + type: "local", + command, + enabled: true, + }); + const { kilo } = await uninstallKilo(home, {}); + expect(kilo?.status).toBe("removed"); + expect((await preserved()).mcp).not.toHaveProperty("rea"); +}); + it("selects the last present Kilo layer, as rea mcp add does", async () => { const home = await createTestTempDirectory("rea-kilo-layers-"); const root = join(home, ".config", "kilo");