Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(setup): select compact input schemas for Kimi registrations

morluto09e7f0710832
diff --git a/docs/client-configuration.md b/docs/client-configuration.md
index b661983c9..5ffb19f99 100644
--- a/docs/client-configuration.md
+++ b/docs/client-configuration.md
@@ -142,6 +142,18 @@ Setup registers `rea` in `~/.kimi-code/mcp.json`, or
creating a `.rea.backup` before updating an existing file. Kimi Code infers
stdio from the `command` entry, so setup does not add a `type` field. The
registration includes `startupTimeoutMs = 30000` and `toolTimeoutMs = 120000`.
+Setup selects the compact input-schema advertisement for new or refreshed Kimi
+registrations unless their stored configuration or setup environment explicitly
+selects `REA_MCP_INPUT_SCHEMA_PROFILE=full` or `compact`. This keeps REA's
+canonical tool validation unchanged while avoiding a Moonshot Kimi Code 2.2.0
+failure observed with the full catalog: its request was rejected because a
+single tool schema exceeded the provider's size limit. The limit is
+provider-specific and not an MCP protocol limit. `rea doctor --client kimi`
+reports an older registration with no explicit profile as stale. To restore the
+compact profile, run `rea setup --client kimi` or add
+`REA_MCP_INPUT_SCHEMA_PROFILE=compact` to the registration's `env`, then restart
+Kimi Code. An explicit `full` profile remains respected and can still exceed
+Moonshot's limit.
Kimi Code also discovers personal skills in `~/.agents/skills` and project-local
`.agents/skills`, so no separate skill root is required; setup still installs
and verifies the matching skill files through the normal shared-skill flow.
diff --git a/src/application/ClientRegistrationStatus.ts b/src/application/ClientRegistrationStatus.ts
index 0fc37ff13..e3aa4ea18 100644
--- a/src/application/ClientRegistrationStatus.ts
+++ b/src/application/ClientRegistrationStatus.ts
@@ -28,6 +28,7 @@ import {
import type { SetupClient } from "./SupportedClients.js";
import { compareUnicodeCodePoints } from "../domain/unicodeCodePointOrder.js";
import { dshDocument } from "./DshCordisPatch.js";
+import { clientRegistrationEnvironment } from "./ClientRegistrationEnvironment.js";
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
interface ClientRegistrationStatusBase {
@@ -215,6 +216,12 @@ export const readClientRegistrationInspections = async (
}
: client;
const registration = parseRegistration(raw, effectiveClient);
+ const registrationEnvironment =
+ client.name === "kimi"
+ ? clientRegistrationEnvironment(parsed)
+ : undefined;
+ if (registrationEnvironment !== undefined && !registrationEnvironment.ok)
+ throw registrationEnvironment.error;
const command: RegistrationCommand = [
registration.command,
...registration.args,
@@ -225,12 +232,16 @@ export const readClientRegistrationInspections = async (
const packageVersionDrift =
packageVersion !== undefined &&
packageVersion !== PRODUCT_IDENTITY.packageVersion;
- const alignment = registrationAligned(
+ const alignment = registrationAligned({
registration,
- effectiveClient,
+ client: effectiveClient,
currentCommandPath,
- options.platform ?? process.platform,
- );
+ platform: options.platform ?? process.platform,
+ kimiInputSchemaProfileSelected:
+ registrationEnvironment?.ok === true &&
+ registrationEnvironment.value.REA_MCP_INPUT_SCHEMA_PROFILE !==
+ undefined,
+ });
record(
configuredStatus(
effectiveClient,
@@ -284,12 +295,19 @@ const registrationActivation = (
? "disabled"
: "enabled";
-const registrationAligned = (
- registration: z.output<typeof registrationSchema>,
- client: SetupClient,
- currentCommandPath: string | undefined,
- platform: NodeJS.Platform,
-): "aligned" | "stale" | "unknown" => {
+const registrationAligned = ({
+ registration,
+ client,
+ currentCommandPath,
+ platform,
+ kimiInputSchemaProfileSelected,
+}: {
+ readonly registration: z.output<typeof registrationSchema>;
+ readonly client: SetupClient;
+ readonly currentCommandPath: string | undefined;
+ readonly platform: NodeJS.Platform;
+ readonly kimiInputSchemaProfileSelected: boolean;
+}): "aligned" | "stale" | "unknown" => {
const command = [registration.command, ...registration.args];
const identity = classifyClientRegistrationCommand(
command,
@@ -310,6 +328,7 @@ const registrationAligned = (
registration.toolTimeoutMs !== MCP_STARTUP_POLICY.kimiToolTimeoutMs)
)
return "stale";
+ if (client.name === "kimi" && !kimiInputSchemaProfileSelected) return "stale";
if (
(client.format === "kimi" ||
client.format === "omp" ||
diff --git a/src/application/SetupClientConfiguration.ts b/src/application/SetupClientConfiguration.ts
index 0af9702ab..104daf968 100644
--- a/src/application/SetupClientConfiguration.ts
+++ b/src/application/SetupClientConfiguration.ts
@@ -683,10 +683,18 @@ const clientConfigurationDesired = (
"fragment",
);
if (!environment.ok) throw environment.error;
+ const registrationEnvironment =
+ client.name === "kimi" &&
+ environment.value.REA_MCP_INPUT_SCHEMA_PROFILE === undefined
+ ? {
+ ...environment.value,
+ REA_MCP_INPUT_SCHEMA_PROFILE: "compact",
+ }
+ : environment.value;
const registration = clientRegistrationEntry(
format,
launcher,
- environment.value,
+ registrationEnvironment,
);
const previous = parsed?.servers[PRODUCT_IDENTITY.mcpServerKey];
if (
diff --git a/tests/boundary/filesystem/kimiClientConfiguration.test.ts b/tests/boundary/filesystem/kimiClientConfiguration.test.ts
index 0ed6397d2..7a96c512d 100644
--- a/tests/boundary/filesystem/kimiClientConfiguration.test.ts
+++ b/tests/boundary/filesystem/kimiClientConfiguration.test.ts
@@ -38,9 +38,13 @@ const exists = async (path: string): Promise<boolean> => {
}
};
-const expectedRegistration = (launcher: readonly string[]) => ({
+const expectedRegistration = (
+ launcher: readonly string[],
+ profile = "compact",
+) => ({
command: launcher[0],
args: launcher.slice(1),
+ env: { REA_MCP_INPUT_SCHEMA_PROFILE: profile },
startupTimeoutMs: MCP_STARTUP_POLICY.kimiStartupTimeoutMs,
toolTimeoutMs: MCP_STARTUP_POLICY.kimiToolTimeoutMs,
});
@@ -159,6 +163,132 @@ describe("Kimi Code registration lifecycle", () => {
});
});
+describe("Kimi Code input-schema profile selection", () => {
+ const kimiClient = async () => {
+ const home = await createTestTempDirectory("rea-kimi-schema-profile-");
+ const client = kimiPath(home, process.platform, {});
+ if (client?.markerPath === undefined)
+ throw new Error("missing Kimi Code client");
+ await mkdir(client.markerPath, { recursive: true });
+ return { home, client };
+ };
+
+ it("preserves an explicitly stored full profile", async () => {
+ const { home, client } = await kimiClient();
+ await writeFile(
+ client.configPath,
+ JSON.stringify({
+ mcpServers: {
+ rea: {
+ command: "old-rea",
+ args: ["mcp"],
+ env: { REA_MCP_INPUT_SCHEMA_PROFILE: "full" },
+ },
+ },
+ }),
+ );
+
+ expect(
+ (await configureClientConfiguration(client, {}, command)).status,
+ ).toBe("configured");
+ expect(
+ JSON.parse(await readFile(client.configPath, "utf8")).mcpServers.rea,
+ ).toEqual(expectedRegistration(command, "full"));
+ expect(
+ (
+ await readClientRegistrationStatuses(home, undefined, {
+ environment: {},
+ })
+ ).find(({ client: name }) => name === "kimi"),
+ ).toMatchObject({ state: "aligned", command });
+ });
+
+ it.each(["full", "compact"] as const)(
+ "uses the caller's explicit %s profile",
+ async (profile) => {
+ const { client } = await kimiClient();
+ expect(
+ (
+ await configureClientConfiguration(
+ client,
+ { REA_MCP_INPUT_SCHEMA_PROFILE: profile },
+ command,
+ )
+ ).status,
+ ).toBe("configured");
+ expect(
+ JSON.parse(await readFile(client.configPath, "utf8")).mcpServers.rea,
+ ).toEqual(expectedRegistration(command, profile));
+ },
+ );
+
+ it.each([
+ ["full", "compact"],
+ ["compact", "full"],
+ ] as const)(
+ "lets explicit setup %s replace stored %s",
+ async (overrideProfile, storedProfile) => {
+ const { client } = await kimiClient();
+ await writeFile(
+ client.configPath,
+ JSON.stringify({
+ mcpServers: {
+ rea: {
+ command: "old-rea",
+ args: ["mcp"],
+ env: { REA_MCP_INPUT_SCHEMA_PROFILE: storedProfile },
+ },
+ },
+ }),
+ );
+
+ expect(
+ (
+ await configureClientConfiguration(
+ client,
+ { REA_MCP_INPUT_SCHEMA_PROFILE: overrideProfile },
+ command,
+ )
+ ).status,
+ ).toBe("configured");
+ expect(
+ JSON.parse(await readFile(client.configPath, "utf8")).mcpServers.rea,
+ ).toEqual(expectedRegistration(command, overrideProfile));
+ },
+ );
+
+ it("reports an omitted-profile registration stale until setup adds compact", async () => {
+ const { home, client } = await kimiClient();
+ await writeFile(
+ client.configPath,
+ JSON.stringify({
+ mcpServers: {
+ rea: {
+ command: command[0],
+ args: command.slice(1),
+ startupTimeoutMs: MCP_STARTUP_POLICY.kimiStartupTimeoutMs,
+ toolTimeoutMs: MCP_STARTUP_POLICY.kimiToolTimeoutMs,
+ },
+ },
+ }),
+ );
+
+ expect(
+ (
+ await readClientRegistrationStatuses(home, undefined, {
+ environment: {},
+ })
+ ).find(({ client: name }) => name === "kimi"),
+ ).toMatchObject({ state: "stale", command });
+ expect(
+ (await configureClientConfiguration(client, {}, command)).status,
+ ).toBe("configured");
+ expect(
+ JSON.parse(await readFile(client.configPath, "utf8")).mcpServers.rea,
+ ).toEqual(expectedRegistration(command));
+ });
+});
+
describe("Kimi Code package launchers", () => {
const kimiClient = async () => {
const home = await createTestTempDirectory("rea-kimi-launcher-");