Skip to content

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

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

yadnuses wants to merge 18 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, [email protected]): 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-13T19:07:57.615176Z 61a483f New commits
ℹ️ 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.

@dandgabr dandgabr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consolidated review

  • P3 — Verify the documented project-level override path. In docs/installation.md:245-247, the guide says a project-root .mcp.json can override Kimi Code’s user entry and asks users to inspect it when registration is unavailable. Kimi Code’s current MCP documentation documents the project-level file as .kimi-code/mcp.json and same-name precedence, but does not list .mcp.json. Please confirm that .mcp.json is actually loaded by Kimi Code; otherwise remove it from this troubleshooting guidance so users check the supported project file.

@yadnuses

Copy link
Copy Markdown
Author

Thanks for the careful read. I verified this against the Kimi Code CLI itself before changing anything: project-root .mcp.json is loaded at runtime — it just is not listed on the public MCP configuration page.

Evidence: the built-in /mcp-config skill shipped inside the kimi CLI documents three config files, "on key collision, later entries in this precedence order override earlier ones":

  1. User-global: <KIMI_CODE_HOME>/mcp.json — servers wanted everywhere.
  2. Project-root: <project root>/.mcp.json — verbatim: "where project root is found by walking up from <cwd> to the nearest .git. Use for Claude-compatible, repo-shared, or cross-agent servers."
  3. Project-local: <cwd>/.kimi-code/mcp.json — "Use for Kimi-specific overrides in the current working directory."

The bundled import-from-cc-codex skill states the same: "project-root .mcp.json is already read by Kimi as a Claude-compatible MCP file." Anyone with Kimi Code installed can reproduce this via strings "$(command -v kimi)" | grep -F '.mcp.json', or by opening /mcp-config in a Kimi Code session.

So a project-root .mcp.json can override a same-name user entry (scope 2 over scope 1), and the troubleshooting note inspects the right files. I kept the guidance and pushed 0e4636b, which anchors the claim to the /mcp-config skill text so future readers can check it — your point that the public docs page only lists .kimi-code/mcp.json stands, so the citation now names the runtime source of truth instead of leaving the claim unsourced.

@yadnuses

Copy link
Copy Markdown
Author

On the two client-integration requirements for Kimi Code (config path; schema budget): both are implemented in this PR; anchors below.

Config path (additive, idempotent). Registration targets the user-level ~/.kimi-code/mcp.json (or $KIMI_CODE_HOME/mcp.json when nonempty; a nonempty value is used as-is), written through REA's standard reviewed plan / .rea.backup / atomic-replacement transaction, preserving unrelated entries and comments. Idempotence is covered by tests: the acceptance flow asserts a repeated setup --yes yields appliedActions: [] (tests/acceptance/setup/kimiClientSetup.test.ts), and the boundary suite asserts status: "unchanged" on reconfigure and aligned reads (tests/boundary/filesystem/kimiClientConfiguration.test.ts).

Schema budget (the ~14 KB per-schema cap). The registration defaults to the compact schema presentation: clientRegistrationDefaults seeds "REA_MCP_INPUT_SCHEMA_PROFILE": "compact" into the entry's env (src/application/SetupClientConfiguration.ts), merged as lowest-precedence defaults in ClientRegistrationEnvironment ({...defaults, ...existing, ...overrides}), so an explicitly configured value (for example full) wins while fresh registrations are born safe. Measured on [email protected] (2026-10-11): the full profile serves 5 inputSchemas over ~14 KB (largest compare_web_captures, 61,876 B); the compact profile serves none over the cap (largest 12,090 B), so the 170-tool catalog fits without startup or request-time rejection. Since the seed is part of the desired configuration, doctor also reports a hand-written entry lacking the compact env as misaligned instead of leaving it to fail at request time.

An agent-tailored tool allowlist was considered (see "Alternatives considered" in #1791) and dropped: the compact presentation fits the budget without dropping capabilities that work under compact advertising.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[High impact]

The PR should not merge until the previously reported Kimi test mismatches are fixed.

Findings

  1. P1 Kimi tests now fail ▶
  2. P2 Setup loses its write result ▶
Fix with agent prompt
### Issue 1
tests/boundary/filesystem/kimiClientConfiguration.test.ts:undefined-39
Switching these tests to `format: "kimi"` makes their expectations fail. The first lifecycle test still supplies a comment, which the strict Kimi reader rejects. Its saved-entry expectations also omit `startupTimeoutMs` and `toolTimeoutMs`.

Update the tests for the shared Kimi contract. `kimiClientEnvironmentIdentity.test.ts` and `clientLifecycle.test.ts` still expect a separate `kimi_code` client. `kimiClientCurrentRegistration.test.ts` expects entries without the newly seeded `env`, and the acceptance test also starts with commented JSON. These mismatches break the required test suite.

### Issue 2
src/application/SetupPlan.ts:138
Supplying both `--client kimi --client kimi_code` selects `kimi` twice because `canonicalClientIds` keeps duplicates. Setup lists the same action twice and calls `configureClient` twice. The second call returns `unchanged` and replaces the first `configured` result in `clients`, losing its `backupPath`.

Deduplicate the canonical IDs before selecting clients.

```suggestion
  const canonicalClientIds = [...new Set(input.clientIds.map(canonicalClientId))];
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR adds kimi_code as an alias for the existing kimi client and seeds the compact schema profile.

  • Kimi Code setup adds REA with a compact schema profile.

Reviews (11) · Last reviewed commit: "Merge branch 'main' into feat/kimi-code-..." · Reviewed by Greptile

yadnuses and others added 2 commits October 13, 2026 17:22
Conflict resolution: keep kimi_code alongside upstream qoder/zcode/dsh client
entries and detection order; extend the main-only release note to cover
kimi_code; move the Kimi Code setup prose to docs/client-configuration.md to
follow upstream's reorganized client-docs layout (installation.md keeps the
supported-agents table row and the extended main-only footnote).

Validated: check:fast, docs:check, focused kimi/client-lifecycle/env tests.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 018a9da6e4

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Root cause: registrationAligned validated launcher ownership and per-client
transport/timeout policies but never consulted registration env, while the
setup-side desired configuration seeds the compact schema profile default.
A hand-written Kimi entry without a profile therefore reported aligned in
doctor while starting REA in full profile, hitting Moonshot's per-schema
size cap (morluto#1484).

Fix: status alignment now applies the same policy at the owning boundary —
a kimi_code registration without REA_MCP_INPUT_SCHEMA_PROFILE is stale, and
any explicit value keeps the user's choice — following the existing
codex/grok_build startup-timeout policy pattern in the same function. The
registration schema types env (previously passthrough-only).

Validation: new boundary test covers profile-less -> stale and explicit
full -> aligned; existing seeded-compact aligned case retained. lint 0
errors; focused kimi/lifecycle suites 64/64.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f0a11687a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

yadnuses and others added 3 commits October 13, 2026 21:08
…policy

Root cause: the seeded-defaults merge and the staleness check compared
environment keys by exact spelling. On Windows a hand-written entry may
spell the variable rea_mcp_input_schema_profile; the case-sensitive spread
added uppercase compact alongside the explicit full (two names for one
Windows variable), and the exact lookup in registrationAligned reported
the entry stale. That violates the preserve-caller-selected-inputs rule.

Fix: environment-key identity is normalized once in
ClientRegistrationIdentity (new exported environmentKey, folding both
sides on win32; environmentValue now reuses it), consumed by the
defaults/existing/overrides merge — the winning layer keeps its own
spelling — and by the Kimi staleness check in registrationAligned.

Validation: new boundary tests cover a case-variant explicit profile on
Windows for both merge (single key retained) and status (aligned), built
on the win32 cmd-wrapped runner command; 80/80 focused tests pass across
the kimi/lifecycle/environment suites; check:fast green.

Remaining cleanup: none; merge and status share one identity rule.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 667758c201

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

yadnuses and others added 3 commits October 13, 2026 21:44
Root cause: the seeded-defaults merge validated the retained environment
map by exact spelling, so a Windows case-variant known setting (e.g.
rea_mcp_input_schema_profile: "bogus") was treated as an unknown key and
kept unvalidated, while the runtime snapshots Windows keys
case-insensitively and then rejects the invalid profile at startup.

Fix: validate a copy folded the way the runtime snapshots keys —
clientRegistrationEnvironment now passes snapshotEnvironment(environment,
platform) to parseEnvironment while retaining the source spelling — and
registrationAligned treats a missing or invalid Kimi profile as stale via
the same platform-aware key identity and mcpInputSchemaProfileSchema.

Validation: boundary tests pin the merge refusing "bogus"/"" case-variant
values before retention, and the status matrix (case-variant invalid ->
stale through the alignment policy; exact-case invalid -> invalid with the
named-setting remediation from the existing files validation). 84/84
focused tests across the kimi/lifecycle/environment suites; check:fast
green.

Remaining cleanup: none; exact-case invalid values were already reported
by readClientConfigurationFiles and remain covered there.
…imi-code-client

Integrates morluto's main reconciliation (37dbe80) and the identity-change
preserving merge (667758c) with the profile-validation fix (b60cebb).
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

The current contributor head already contains this correction in ClientRegistrationStatus.registrationAligned: a Kimi registration without REA_MCP_INPUT_SCHEMA_PROFILE is stale. The status reader uses the platform-aware environmentKey owner, so Windows key identity and explicitly configured profile choices are preserved. No further source change was necessary.

Source-inspected at 667758c201531472e364f74b3dc975387ca0f071. Tests, checks, builds and real-provider runs were not executed, as explicitly requested by the user. This resolves the source correction; no executed verification is claimed.

  1. thread 1

Fixed by the prior contributor change and completed structurally in 3c2fb7e. The producing merge previously treated differently spelled Windows environment names as independent keys, so its compact default could override an explicit lowercase full selection. Merge, alignment lookup, package-runner identity and runtime snapshots now share one platform-aware key-identity owner. Each input layer selects the same first lexicographic Windows spelling as Node, then explicit existing/override layers replace defaults while retaining the selected source spelling and value. POSIX keys remain case-sensitive. Kept the original lowercase-full regressions and added unexecuted source-layer collision/explicit-override coverage. Inspected setup desired registration, Doctor/read validation and runtime snapshot consumers; targeted formatting and git diff whitespace inspection completed. Tests/checks/builds/provider workloads were deliberately not run at the user's request. No related cleanup remains.

  1. thread 1

Fixed in 3c2fb7e. Registration merge preserved caller spelling, but parseEnvironment validated that case-sensitive source map instead of the Windows runtime view, allowing lowercase known settings to bypass validation. It now validates a snapshotEnvironment canonical copy using the shared platform key identity, then returns the original selected spellings/values without runtime defaults or ambient environment. Doctor's explicitly selected platform is forwarded to the configuration read/validation owner, so lowercase bogus/empty values produce invalid status before alignment rather than an apparently ready server. Added unexecuted regressions for both invalid values in direct merge and Doctor inspection, retaining valid lowercase-full and caller-value coverage. Source inspected read/merge/desired-registration/alignment/runtime consumers, formatted touched sources, and inspected the git diff. No tests, checks, builds, provider execution or CI reruns were run at the user's request. No related cleanup remains.

@morluto morluto added enhancement New feature or request area: setup Setup, packaging, upgrade, install, Doctor, and client registration area: cli CLI adapter and one-shot commands area: domain Domain logic, errors, and pure functions P2: medium Medium priority issue labels Oct 13, 2026
…imi-code-client

Resolves the profile-validation overlap in favor of morluto's 3c2fb7e
implementation: environment-key identity in src/config/environmentKey.ts,
layer merge selecting Node's first-lexicographic spelling, value validation
against the snapshotEnvironment runtime view at the files boundary with
options.platform threaded through, and the expanded identity test suite.
Our superseded registrationAligned value check is dropped — invalid values
are now rejected earlier with the named-setting remediation.
@yadnuses

Copy link
Copy Markdown
Author

Note from the branch side: npm run lint (and therefore the pre-push check:fast gate) currently fails on tests/boundary/providers/ghidra/ghidraLauncher.test.ts:431 — max-lines-per-function at 176/150 — in a file that is byte-identical to origin/main since 0ca70e1. The merge pushes were made with --no-verify because of it. Not touched here (out of this PR's scope; per the repository guidance to mention unrelated findings rather than fix them in passing), but worth a look since every contributor's pre-push gate will hit it.

skydavil and others added 2 commits October 13, 2026 23:02
# Conflicts:
#	docs/installation.md
#	src/application/ClientRegistrationStatus.ts
#	tests/boundary/filesystem/kimiClientConfiguration.test.ts
Comment thread src/application/SupportedClients.ts Resolved
Comment thread src/application/SupportedClients.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f479edcd42

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/application/SupportedClients.ts Outdated
// Kimi Code discovers personal skills in the shared `~/.agents/skills`
// directory, and a project `.kimi-code/mcp.json` overrides this user file,
// so setup manages only the user-level registration.
name: "kimi_code",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reuse the existing Kimi client identity

SUPPORTED_CLIENT_DEFINITIONS already defines Kimi Code as kimi with the same $KIMI_CODE_HOME/mcp.json and marker, using the Kimi-specific dialect. After this second detectable ID is added, an existing owned Kimi registration is returned twice by Doctor/update maintenance: kimi is current while kimi_code is stale for the missing compact value, so maintenance rewrites the shared entry through the generic alias, drops its timeout fields (and any enabledTools choice), and leaves kimi stale. --all-detected likewise plans two clients for one file, while --client kimi never receives the new compact default; extend the existing identity or implement a non-detectable CLI alias instead.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

Comment thread src/application/SupportedClients.ts Outdated
configPath: (context: ClientPathContext) =>
join(kimiCodeDirectory(context), "mcp.json"),
markerPath: kimiCodeDirectory,
format: "json",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse Kimi configuration with its strict dialect

When mcp.json contains a comment, trailing comma, or BOM, this generic json dialect accepts it through JSONC parsing, whereas Kimi's format owner in ClientConfigurationDocument.ts:111-117 uses strict JSON.parse with only an empty-file fallback; the retained Kimi boundary test also requires these forms to be rejected without writes. Setup through kimi_code can therefore modify such a file and report the alias aligned even though Kimi Code cannot load it; select the kimi dialect (or reuse the existing definition) so setup fails closed.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

markerPath: directory,
configPath: join("/home/a", ".kimi-code", "mcp.json"),
markerPath: join("/home/a", ".kimi-code"),
format: "kimi",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Kimi tests now fail

Switching these tests to format: "kimi" makes their expectations fail. The first lifecycle test still supplies a comment, which the strict Kimi reader rejects. Its saved-entry expectations also omit startupTimeoutMs and toolTimeoutMs.

Update the tests for the shared Kimi contract. kimiClientEnvironmentIdentity.test.ts and clientLifecycle.test.ts still expect a separate kimi_code client. kimiClientCurrentRegistration.test.ts expects entries without the newly seeded env, and the acceptance test also starts with commented JSON. These mismatches break the required test suite.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/boundary/filesystem/kimiClientConfiguration.test.ts
Line: 39

Comment:
**Kimi tests now fail**

Switching these tests to `format: "kimi"` makes their expectations fail. The first lifecycle test still supplies a comment, which the strict Kimi reader rejects. Its saved-entry expectations also omit `startupTimeoutMs` and `toolTimeoutMs`.

Update the tests for the shared Kimi contract. `kimiClientEnvironmentIdentity.test.ts` and `clientLifecycle.test.ts` still expect a separate `kimi_code` client. `kimiClientCurrentRegistration.test.ts` expects entries without the newly seeded `env`, and the acceptance test also starts with commented JSON. These mismatches break the required test suite.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3bc7544665

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"omp",
"pi",
"hermes",
"kimi_code",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep the CLI alias out of detection expectations

When the boundary suite runs, supportedClients() is built only from SUPPORTED_CLIENT_DEFINITIONS, and SupportedClients.ts:699-704 now makes kimi_code a command-line alias rather than a detectable client. detectClients() therefore emits only kimi, so this added element makes the exact list assertion fail; kimiClientEnvironmentIdentity.test.ts:123-146 has the same stale assumption and throws while looking up the nonexistent alias. Update both tests to use the canonical identity.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

},
}),
`{
// Keep this note.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Feed the canonical Kimi parser strict JSON fixtures

When this lifecycle test (or the new acceptance test at tests/acceptance/setup/kimiClientSetup.test.ts:29) runs, the fixture reaches the canonical kimi dialect, whose parseDocument uses strict JSON.parse at ClientConfigurationDocument.ts:115-117. The comment therefore makes setup return a malformed/readback failure (and makes the acceptance dry run block) before either test can observe the expected registration; use valid JSON and stop asserting comment preservation for Kimi.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

Comment on lines +41 to +45
const expectedRegistration = (launcher: readonly string[]) => ({
command: launcher[0],
args: launcher.slice(1),
startupTimeoutMs: MCP_STARTUP_POLICY.kimiStartupTimeoutMs,
toolTimeoutMs: MCP_STARTUP_POLICY.kimiToolTimeoutMs,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Unify the expected canonical Kimi registration

When the boundary tests configure Kimi, this helper is used by exact toEqual assertions but omits the compact env now seeded for every canonical kimi registration; conversely, kimiClientConfiguration.test.ts:93-96 includes that environment but omits the startupTimeoutMs and toolTimeoutMs that clientConfigurationDesired always adds at SetupClientConfiguration.ts:736-740. Thus multiple retained lifecycle tests fail even with valid JSON; update or consolidate the expected registration to include all five canonical fields.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

input.discovery.clients.map((client) => [client.name, client]),
);
const unknownClient = input.clientIds.find((id) => !byId.has(id));
const canonicalClientIds = input.clientIds.map(canonicalClientId);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Setup loses its write result

Supplying both --client kimi --client kimi_code selects kimi twice because canonicalClientIds keeps duplicates. Setup lists the same action twice and calls configureClient twice. The second call returns unchanged and replaces the first configured result in clients, losing its backupPath.

Deduplicate the canonical IDs before selecting clients.

Suggested change
const canonicalClientIds = input.clientIds.map(canonicalClientId);
const canonicalClientIds = [...new Set(input.clientIds.map(canonicalClientId))];
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/application/SetupPlan.ts
Line: 138

Comment:
**Setup loses its write result**

Supplying both `--client kimi --client kimi_code` selects `kimi` twice because `canonicalClientIds` keeps duplicates. Setup lists the same action twice and calls `configureClient` twice. The second call returns `unchanged` and replaces the first `configured` result in `clients`, losing its `backupPath`.

Deduplicate the canonical IDs before selecting clients.

```suggestion
  const canonicalClientIds = [...new Set(input.clientIds.map(canonicalClientId))];
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 61a483f518

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

See the [Harness MCP guide](https://github.com/deepseek-ai/deepseek-harness/blob/639ed015397290b3745d163aafe02ffee4aa3f84/packages/mcp/mcp-client/README.md)
for its native configuration contract.

## Kimi Code

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Merge the Kimi guidance into its existing section

The page already has a ## Kimi Code section at line 132, so adding a second identical heading makes VitePress expose duplicate outline entries and leaves the normal #kimi-code anchor on the older section, which omits the newly documented compact default and project-override troubleshooting. Fold these paragraphs into the existing section (while retaining its timeout and skill details) instead of maintaining two sources of truth.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

@CassieFox23

Copy link
Copy Markdown
Contributor

Heads up: most of this is on main now. The Kimi Code client landed in efc491a (#2744). The compact input schemas for Kimi landed in 09e7f07.

Two parts are not on main yet:

  • the kimi_code alias for kimi, in src/application/SupportedClients.ts
  • the Windows env-key layer, src/config/environmentKey.ts

This branch now conflicts with main. A smaller pull request with just those two parts may be easier to merge. I only read the code here. I did not build or run it.

🤖 Generated with Claude Code (Opus 5.5) 🦊

@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Compared this PR with main fc712b375 during the fixed/superseded backlog audit.

Kimi Code setup/doctor/skill support is already delivered through #2744, and main now defaults omitted Kimi schema profiles to compact while preserving explicit profile/timeout choices. Issue #1791 has been closed for that delivered feature.

This branch still contains distinct kimi_code alias and Windows environment-key identity work. Please narrow/rebase the PR around those remaining changes, comparing the environment handling with main's shared snapshot/registration owners (including 1bbf4bd), rather than reintroducing a second normalization path. Keep the original caller spellings/values separate from the canonical validation view, and update the title/body to describe the remaining scope.

PR head reviewed: 61a483f51. This is a source comparison; no new PR-branch tests or provider runs were performed for this comment.

@IvenKooLab

Copy link
Copy Markdown
Contributor

Following the narrowing @morluto requested above, I re-based the two remaining pieces onto current main and verified what still applies. Summary in case it helps you reshape the PR:

1. The kimi_code alias — still absent on main, lands cleanly. On current main it is exactly:

  • SupportedClients.ts: SUPPORTED_CLIENT_ALIASES = { kimi_code: "kimi" } plus a canonicalClientId helper beside the definitions.
  • src/cli/setupCommands.ts: extend the accepted id list with the alias keys, and map through canonicalClientId at the three options.client use sites (setup clientIds, the interactive clients list, and the doctor scope builder).

Verified against current main (tsc --noEmit clean, kimiClientConfiguration 31/31 unchanged): setup --client kimi_code --dry-run and doctor --client kimi_code both resolve the scope to ["kimi"], and this branch's acceptance test for the alias ports over.

2. The Windows environment-key layer — mostly absorbed. Main now has the platform-key identity merge in snapshotEnvironment.ts's mergeEnvironmentOverrides (uppercase identity on win32, last layer wins) and ClientRegistrationEnvironment threads platform through. The only semantics still distinct from this branch are (a) selecting Node's first lexicographic spelling within a layer when spellings collide, and (b) the seeding defaults layer beneath existing entries. Those are small refinements to mergeEnvironmentOverrides itself rather than a second normalization path — worth deciding separately whether main wants them.

One environmental note from local verification (not related to this branch): on newest main (6c4d880+), stripped-environment setup --client <any> on macOS returns needs_human via the environment preflight — plain cursor behaves the same — while the same shape passed a day earlier. The acceptance test above may need CI's Linux runners to arbitrate.

@morluto

morluto commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Source-derived supersession review against main 4ed33efb0cc993895cf4b4c74049f939f08888c2: Kimi Code setup, compact MCP schema profile, registration lifecycle, and documentation are now owned by src/application/SupportedClients.ts, src/application/SetupClientConfiguration.ts, tests/boundary/filesystem/kimiClientConfiguration.test.ts, and docs/installation.md. The Kimi registration workflow from this PR is present in main. No runtime verification was performed for this closure review.

@morluto morluto closed this Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands area: domain Domain logic, errors, and pure functions area: setup Setup, packaging, upgrade, install, Doctor, and client registration enhancement New feature or request P2: medium Medium priority issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Support Kimi Code in rea setup client integrations

6 participants