[PR #1804] [CLOSED] feat(setup): register Kimi Code client with compact schema profile #4826

Closed
opened 2026-10-31 00:55:29 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1804
Author: @yadnuses
Created: 10/11/2026
Status: ❌ Closed

Base: main ← Head: feat/kimi-code-client


📝 Commits (10+)

  • 20abd98 feat(clients): register Kimi Code during setup
  • 6edbcda test(clients): cover Kimi Code registration lifecycle
  • ac955f5 docs(installation): document the Kimi Code client
  • 0e4636b docs(installation): cite Kimi Code /mcp-config scopes for .mcp.json
  • 7106326 Merge remote-tracking branch 'origin/main' into feat/kimi-code-client
  • 018a9da fix: reconcile latest main for PR #1804
  • 5f0a116 fix(clients): treat profile-less Kimi registrations as stale
  • 3c6fd0e fix(clients): honor Windows environment-key identity in Kimi profile policy
  • 37dbe80 fix(setup): reconcile Kimi client branch with current main
  • 667758c fix(setup): preserve newer Kimi environment identity changes

📊 Changes

17 files changed (+951 additions, -312 deletions)

View changed files

📝 docs/client-configuration.md (+27 -0)
📝 docs/installation.md (+6 -4)
📝 src/application/ClientConfigurationFiles.ts (+7 -1)
📝 src/application/ClientRegistrationEnvironment.ts (+33 -3)
📝 src/application/ClientRegistrationIdentity.ts (+9 -8)
📝 src/application/ClientRegistrationStatus.ts (+17 -0)
📝 src/application/SetupClientConfiguration.ts (+14 -0)
📝 src/application/SetupPlan.ts (+6 -2)
📝 src/application/SupportedClients.ts (+8 -0)
📝 src/cli/setupCommands.ts (+11 -4)
➕ src/config/environmentKey.ts (+20 -0)
📝 src/process/snapshotEnvironment.ts (+3 -1)
➕ tests/acceptance/setup/kimiClientSetup.test.ts (+98 -0)
📝 tests/boundary/filesystem/clientLifecycle.test.ts (+1 -0)
📝 tests/boundary/filesystem/kimiClientConfiguration.test.ts (+157 -289)
➕ tests/boundary/filesystem/kimiClientCurrentRegistration.test.ts (+384 -0)
➕ tests/boundary/filesystem/kimiClientEnvironmentIdentity.test.ts (+150 -0)

📄 Description

Summary

Kimi Code (kimi-cli, Moonshot's coding agent) is the one major local MCP client with no rea setup integration, so its users hand-write mcpServers.rea into ~/.kimi-code/mcp.json (the exact path #1484's reproduction uses). That leaves setup detection, doctor, and uninstall blind to the registration, rea update never re-pins it, and a naive entry reproduces the Moonshot per-schema 400s of #1484 on current releases. This PR registers Kimi Code as a supported client and seeds the compact schema presentation into its entry so the first prompt after setup works. Fixes #1791.

Problem and expected behavior

  • Use case: A Kimi Code user runs npx rea-agents setup and gets a Kimi Code checkbox the way OMP (#1257 → #1301) and Qwen Code (#1409) did, then loads both the MCP server and the reverse-engineer-anything workflow with no manual file edits.
  • Observable outcome: rea setup --client kimi_code writes a pinned mcpServers.rea entry to user-level ~/.kimi-code/mcp.json with "env": { "REA_MCP_INPUT_SCHEMA_PROFILE": "compact" }; doctor --client kimi_code reports the registration; uninstall --client kimi_code removes it. No #1484-style 400 cascade on the first prompt.

Change and scope

  • SupportedClients.ts — kimi_code definition (configPath mcp.json under the Kimi home, markerPath the same directory, format: "json"). The existing JSON dialect writes exactly the mcpServers.<name> → {command, args, env} shape Kimi Code loads; no new dialect.
  • Home resolution honors KIMI_CODE_HOME with codex-style semantics (non-empty override used as-is, empty falls back to ~/.kimi-code, no tilde expansion) — matched to Kimi's own resolution and pinned by tests.
  • ClientRegistrationEnvironment.ts — the existing environment-retention merge gains a lowest-precedence defaults layer ({...defaults, ...existing, ...overrides}), so seeded values never clobber explicitly configured ones (preserves the "explicitly configured server settings" invariant).
  • SetupClientConfiguration.ts — clientRegistrationDefaults(client) returns the compact profile seed for kimi_code (empty map otherwise) at the single clientConfigurationDesired convergence point, so register/inspect/aligned/update all seed it and stay idempotent.
  • SetupSkill.ts — unchanged: Kimi Code discovers the shared ~/.agents/skills, the existing fallback destination; no client skill family needed (simpler than #1409's Qwen case).
  • Tests + docs/installation.md (table row, Kimi Code section, restart note).
  • Intentionally not included: a verify:kimi-client script, project-level config writes, tool-contract changes, Windows Kimi verification.

Contract and boundary impact

  • Semantic owner and earliest changed stage: setup client registration (application layer: SetupClientConfiguration / ClientRegistrationEnvironment).
  • CLI and MCP/tool-catalog contract: none — REA_MCP_INPUT_SCHEMA_PROFILE is presentation-only advertising; canonical schemas and server-side validation are untouched (catalog still 170 tools).
  • Provider, bridge, target-format, or platform compatibility: none — no provider changes. Windows Kimi Code path behavior untested (same code shape as codex/qwen).
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Process execution, authorization, cleanup, or containment impact: setup writes only user-level client config through the existing reviewed plan/backup/atomic-replacement transaction; no process execution added.
  • Generated metadata, package, or installation impact: setup_clients client metadata derives from SUPPORTED_CLIENT_DEFINITIONS (CI-generated; nothing committed); npm pack --dry-run and verify:package pass; docs/installation.md updated.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/filesystem/kimiClientConfiguration.test.ts (9 tests: path resolution on linux/darwin, KIMI_CODE_HOME semantics incl. empty/~//relative cases, register → preserve-unrelated → aligned-read → idempotent-reconfigure → uninstall round trip, compact seed + explicit full precedence + provider-key stacking); tests/acceptance/setup/kimiClientSetup.test.ts (CLI dry-run plan → --yes apply → .rea.backup → compact env → doctor --skill → idempotent re-run → uninstall, under KIMI_CODE_HOME); clientLifecycle.test.ts detection-order list; clientEnvironment.ts fixture.
  • Base reproduction or other evidence: on the base revision no kimi_code client exists in SUPPORTED_CLIENT_DEFINITIONS (setup multi-select and --client have no Kimi Code option); #1484 documents the schema-cap failure mode. Schema-size table in #1791 (2026-10-11, rea-agents@6.4.0): full profile 5 inputSchemas over ~14 KB (largest 61,876 B); compact profile 0 over (largest 12,090 B).
  • User-visible CLI/MCP output: dry-run plan lists the Kimi Code registration action; doctor --client kimi_code covers it like other clients; docs section shows the written entry shape.
  • Remaining proof gaps: no live Kimi Code session round trip against the MCP server (no verify:kimi-client lane here); Moonshot cap behavior measured previously, not re-triggered from this host; Windows unverified; full test:acceptance/test:integration and docs:build not run; dev toolchain is Node 24.14.0 vs .nvmrc 24.18.0 (nvm unavailable on the host).

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm ci — pass
  • npm run test:focused -- tests/boundary/filesystem/kimiClientConfiguration.test.ts tests/acceptance/setup/kimiClientSetup.test.ts (plus clientLifecycle, qwen, clientConfigurationEnvironment, productCatalog) — 6 files / 90 tests pass
  • npm run check:fast — pass (typecheck + lint incl. module boundaries)
  • npm run verify:test-discovery — pass (821 test files, each discovered once)
  • npm run verify:package — pass (setup planned→idempotent, backupReadback, skill, mcpTools=170)
  • npm pack --dry-run — pass (1162 files, no artifacts written)
  • npm run docs:check — pass
  • npm run test:fast — 4298 passed / 7 skipped
  • npm run test:boundary — 27 failed / 3039 passed; the failing set is identical on the main baseline of this host (missing ibtool, hdiutil behavior, Ghidra MCP fixture, JS inspector fixture); one additional 30 s timeout flake passes standalone 8/8. Unrelated to this change; no assertion weakened.
  • Real Hopper/Ghidra, browser, or OS coverage: not run — registration-only change; no provider lanes on this host.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Fresh kimi_code registrations seed the compact profile; explicitly configured REA_MCP_INPUT_SCHEMA_PROFILE values keep precedence over the seed. Existing manual entries are only touched if the user runs setup for kimi_code (standard reviewed transaction).
  • Real Hopper/Ghidra, browser, or OS coverage: unavailable on this host (see above).
  • Package or release metadata impact: adds one client to derived setup metadata; release via the usual Release Please flow.
  • Security, privacy, process, or containment review: writes one user-level config file via the existing backup/atomic transaction; no credentials, no new process execution; the env seed is a presentation hint, not a capability change.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked (Fixes #1791).
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1804 **Author:** [@yadnuses](https://github.com/yadnuses) **Created:** 10/11/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/kimi-code-client` --- ### 📝 Commits (10+) - [`20abd98`](https://github.com/morluto/rea/commit/20abd989284817754bd3f64ebf037c6807f8afd5) feat(clients): register Kimi Code during setup - [`6edbcda`](https://github.com/morluto/rea/commit/6edbcda1fcfddf3fae1a9841a84b8a377bc911d7) test(clients): cover Kimi Code registration lifecycle - [`ac955f5`](https://github.com/morluto/rea/commit/ac955f58ff0afd77f2d6c8a77bc8015fec3abcca) docs(installation): document the Kimi Code client - [`0e4636b`](https://github.com/morluto/rea/commit/0e4636bb37928b05ef09c52458374b95dc337939) docs(installation): cite Kimi Code /mcp-config scopes for .mcp.json - [`7106326`](https://github.com/morluto/rea/commit/71063263de52ff4149994d4353212cd46ed8d804) Merge remote-tracking branch 'origin/main' into feat/kimi-code-client - [`018a9da`](https://github.com/morluto/rea/commit/018a9da6e4398b185ac223131c1b6561d7d8e53b) fix: reconcile latest main for PR #1804 - [`5f0a116`](https://github.com/morluto/rea/commit/5f0a11687a83639b0738a7586acd91546399f0e6) fix(clients): treat profile-less Kimi registrations as stale - [`3c6fd0e`](https://github.com/morluto/rea/commit/3c6fd0efa2e7378928fd84194dd2f869879eb193) fix(clients): honor Windows environment-key identity in Kimi profile policy - [`37dbe80`](https://github.com/morluto/rea/commit/37dbe80ef2c00daf13f71a067d1d6473e0275101) fix(setup): reconcile Kimi client branch with current main - [`667758c`](https://github.com/morluto/rea/commit/667758c201531472e364f74b3dc975387ca0f071) fix(setup): preserve newer Kimi environment identity changes ### 📊 Changes **17 files changed** (+951 additions, -312 deletions) <details> <summary>View changed files</summary> 📝 `docs/client-configuration.md` (+27 -0) 📝 `docs/installation.md` (+6 -4) 📝 `src/application/ClientConfigurationFiles.ts` (+7 -1) 📝 `src/application/ClientRegistrationEnvironment.ts` (+33 -3) 📝 `src/application/ClientRegistrationIdentity.ts` (+9 -8) 📝 `src/application/ClientRegistrationStatus.ts` (+17 -0) 📝 `src/application/SetupClientConfiguration.ts` (+14 -0) 📝 `src/application/SetupPlan.ts` (+6 -2) 📝 `src/application/SupportedClients.ts` (+8 -0) 📝 `src/cli/setupCommands.ts` (+11 -4) ➕ `src/config/environmentKey.ts` (+20 -0) 📝 `src/process/snapshotEnvironment.ts` (+3 -1) ➕ `tests/acceptance/setup/kimiClientSetup.test.ts` (+98 -0) 📝 `tests/boundary/filesystem/clientLifecycle.test.ts` (+1 -0) 📝 `tests/boundary/filesystem/kimiClientConfiguration.test.ts` (+157 -289) ➕ `tests/boundary/filesystem/kimiClientCurrentRegistration.test.ts` (+384 -0) ➕ `tests/boundary/filesystem/kimiClientEnvironmentIdentity.test.ts` (+150 -0) </details> ### 📄 Description <!-- PR title: type(optional-scope): imperative outcome --> <!-- Title: feat(setup): register Kimi Code client with compact schema profile --> ## Summary Kimi Code (kimi-cli, Moonshot's coding agent) is the one major local MCP client with no `rea setup` integration, so its users hand-write `mcpServers.rea` into `~/.kimi-code/mcp.json` (the exact path #1484's reproduction uses). That leaves setup detection, `doctor`, and `uninstall` blind to the registration, `rea update` never re-pins it, and a naive entry reproduces the Moonshot per-schema 400s of #1484 on current releases. This PR registers Kimi Code as a supported client and seeds the compact schema presentation into its entry so the first prompt after setup works. Fixes #1791. ## Problem and expected behavior - **Use case**: A Kimi Code user runs `npx rea-agents setup` and gets a Kimi Code checkbox the way OMP (#1257 → #1301) and Qwen Code (#1409) did, then loads both the MCP server and the `reverse-engineer-anything` workflow with no manual file edits. - **Observable outcome**: `rea setup --client kimi_code` writes a pinned `mcpServers.rea` entry to user-level `~/.kimi-code/mcp.json` with `"env": { "REA_MCP_INPUT_SCHEMA_PROFILE": "compact" }`; `doctor --client kimi_code` reports the registration; `uninstall --client kimi_code` removes it. No #1484-style 400 cascade on the first prompt. ## Change and scope - `SupportedClients.ts` — `kimi_code` definition (`configPath` `mcp.json` under the Kimi home, `markerPath` the same directory, `format: "json"`). The existing JSON dialect writes exactly the `mcpServers.<name>` → `{command, args, env}` shape Kimi Code loads; no new dialect. - Home resolution honors `KIMI_CODE_HOME` with codex-style semantics (non-empty override used as-is, empty falls back to `~/.kimi-code`, no tilde expansion) — matched to Kimi's own resolution and pinned by tests. - `ClientRegistrationEnvironment.ts` — the existing environment-retention merge gains a lowest-precedence `defaults` layer (`{...defaults, ...existing, ...overrides}`), so seeded values never clobber explicitly configured ones (preserves the "explicitly configured server settings" invariant). - `SetupClientConfiguration.ts` — `clientRegistrationDefaults(client)` returns the compact profile seed for `kimi_code` (empty map otherwise) at the single `clientConfigurationDesired` convergence point, so register/inspect/aligned/update all seed it and stay idempotent. - `SetupSkill.ts` — unchanged: Kimi Code discovers the shared `~/.agents/skills`, the existing fallback destination; no client skill family needed (simpler than #1409's Qwen case). - Tests + `docs/installation.md` (table row, Kimi Code section, restart note). - Intentionally not included: a `verify:kimi-client` script, project-level config writes, tool-contract changes, Windows Kimi verification. ## Contract and boundary impact - Semantic owner and earliest changed stage: setup client registration (application layer: `SetupClientConfiguration` / `ClientRegistrationEnvironment`). - CLI and MCP/tool-catalog contract: none — `REA_MCP_INPUT_SCHEMA_PROFILE` is presentation-only advertising; canonical schemas and server-side validation are untouched (catalog still 170 tools). - Provider, bridge, target-format, or platform compatibility: none — no provider changes. Windows Kimi Code path behavior untested (same code shape as codex/qwen). - Evidence, artifact, provenance, or reconstruction contract: none. - Process execution, authorization, cleanup, or containment impact: setup writes only user-level client config through the existing reviewed plan/backup/atomic-replacement transaction; no process execution added. - Generated metadata, package, or installation impact: `setup_clients` client metadata derives from `SUPPORTED_CLIENT_DEFINITIONS` (CI-generated; nothing committed); `npm pack --dry-run` and `verify:package` pass; `docs/installation.md` updated. ## Evidence and regression coverage - Tests added or updated: `tests/boundary/filesystem/kimiClientConfiguration.test.ts` (9 tests: path resolution on linux/darwin, `KIMI_CODE_HOME` semantics incl. empty/`~/`/relative cases, register → preserve-unrelated → aligned-read → idempotent-reconfigure → uninstall round trip, compact seed + explicit `full` precedence + provider-key stacking); `tests/acceptance/setup/kimiClientSetup.test.ts` (CLI dry-run plan → `--yes` apply → `.rea.backup` → compact env → `doctor --skill` → idempotent re-run → uninstall, under `KIMI_CODE_HOME`); `clientLifecycle.test.ts` detection-order list; `clientEnvironment.ts` fixture. - Base reproduction or other evidence: on the base revision no `kimi_code` client exists in `SUPPORTED_CLIENT_DEFINITIONS` (setup multi-select and `--client` have no Kimi Code option); #1484 documents the schema-cap failure mode. Schema-size table in #1791 (2026-10-11, `rea-agents@6.4.0`): full profile 5 `inputSchema`s over ~14 KB (largest 61,876 B); compact profile 0 over (largest 12,090 B). - User-visible CLI/MCP output: dry-run plan lists the Kimi Code registration action; `doctor --client kimi_code` covers it like other clients; docs section shows the written entry shape. - Remaining proof gaps: no live Kimi Code session round trip against the MCP server (no `verify:kimi-client` lane here); Moonshot cap behavior measured previously, not re-triggered from this host; Windows unverified; full `test:acceptance`/`test:integration` and `docs:build` not run; dev toolchain is Node 24.14.0 vs `.nvmrc` 24.18.0 (nvm unavailable on the host). For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm ci` — pass - `npm run test:focused -- tests/boundary/filesystem/kimiClientConfiguration.test.ts tests/acceptance/setup/kimiClientSetup.test.ts` (plus clientLifecycle, qwen, clientConfigurationEnvironment, productCatalog) — 6 files / 90 tests pass - `npm run check:fast` — pass (typecheck + lint incl. module boundaries) - `npm run verify:test-discovery` — pass (821 test files, each discovered once) - `npm run verify:package` — pass (setup planned→idempotent, backupReadback, skill, mcpTools=170) - `npm pack --dry-run` — pass (1162 files, no artifacts written) - `npm run docs:check` — pass - `npm run test:fast` — 4298 passed / 7 skipped - `npm run test:boundary` — 27 failed / 3039 passed; the failing set is identical on the `main` baseline of this host (missing `ibtool`, `hdiutil` behavior, Ghidra MCP fixture, JS inspector fixture); one additional 30 s timeout flake passes standalone 8/8. Unrelated to this change; no assertion weakened. - Real Hopper/Ghidra, browser, or OS coverage: not run — registration-only change; no provider lanes on this host. ## Compatibility, safety, and release - Breaking changes or migration steps: none. Fresh `kimi_code` registrations seed the compact profile; explicitly configured `REA_MCP_INPUT_SCHEMA_PROFILE` values keep precedence over the seed. Existing manual entries are only touched if the user runs setup for `kimi_code` (standard reviewed transaction). - Real Hopper/Ghidra, browser, or OS coverage: unavailable on this host (see above). - Package or release metadata impact: adds one client to derived setup metadata; release via the usual Release Please flow. - Security, privacy, process, or containment review: writes one user-level config file via the existing backup/atomic transaction; no credentials, no new process execution; the env seed is a presentation hint, not a capability change. ## Review checklist - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked (`Fixes #1791`). - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:55:29 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#4826
No description provided.