Skip to content

feat(setup): register Kimi Code client with compact schema profile - #1804

Open
yadnuses wants to merge 3 commits into
morluto:mainfrom
yadnuses:feat/kimi-code-client
Open

yadnuses wants to merge 3 commits into
morluto:mainfrom
yadnuses:feat/kimi-code-client

Conversation

@yadnuses

Copy link
Copy Markdown

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

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 [Feature] Support Qwen Code in rea setup client integrations #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); [Bug] Moonshot clients reject every request while REA is connected: advertised tool schemas exceed the per-schema size cap (kimi-cli unusable) #1484 documents the schema-cap failure mode. Schema-size table in [Feature] Support Kimi Code in rea setup client integrations #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.

Add kimi_code to the supported setup clients with the JSON mcpServers dialect at ~/.kimi-code/mcp.json, following a nonempty KIMI_CODE_HOME and falling back when it is empty. Skills stay in the shared ~/.agents/skills destination, and a project .kimi-code/mcp.json can override the user entry, so setup writes user scope only.

Seed REA_MCP_INPUT_SCHEMA_PROFILE=compact through the existing registration environment merge: an explicitly configured profile in the entry still wins, and discovered provider settings still override their own keys. Moonshot's API rejects a whole request while one tool input schema exceeds its per-schema cap (morluto#1484); the full profile in 6.4.0 put five schemas over it, the compact profile put none.
Mirror the Qwen Code client tests: boundary coverage for path resolution (default home and KIMI_CODE_HOME), register -> aligned read -> idempotent reconfigure -> unregister, compact profile seeding with an explicit profile preserved, and an acceptance CLI plan/setup/doctor/uninstall pass asserting the seeded compact environment and shared skill. Extend the detected-client order with kimi_code.
Add the Kimi Code row to the supported agents table and a section covering the user-level mcp.json target, the KIMI_CODE_HOME override, project-level overrides, the seeded compact schema profile justified by the Moonshot per-schema cap (morluto#1484), and the session restart required after MCP changes. Scope the 17-client dry-run checkpoint sentence to the 6.4.0 release.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T11:37:58.916470Z ac955f5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

[Feature] Support Kimi Code in rea setup client integrations

1 participant