feat(agents): add Kimi Code runtime support#522
Conversation
Greptile SummaryThis PR adds Kimi Code as a fully-supported runtime agent, wiring it into every layer of the stack: API contract, catalog, config auto-selection, CLI options, settings UI, onboarding carousel, and the PTY adapter pipeline. The two new core files (
Confidence Score: 3/5Safe to merge for adapter plumbing and catalog wiring; the TOML config generation has a defect that produces an invalid config file when a user hook carries a trailing line comment. The comma-insertion logic in ensureTomlArrayBodyTrailingComma appends to the full raw line including any trailing comment, making the comma invisible to the TOML parser. Any Kimi user whose config has a comment on the last hook will get a malformed generated config and Kimi will fail to load its hooks. All other changes are clean. src/terminal/kimi-config.ts — ensureTomlArrayBodyTrailingComma and findFirstTomlTableLineIndex. src/terminal/kimi-agent-config.ts — confirm the .yaml extension matches Kimi's --agent-file expectations.
|
| Filename | Overview |
|---|---|
| src/terminal/kimi-config.ts | New file: TOML config generator with hand-rolled bracket/quote scanner. Bug in trailing-comma insertion corrupts configs with commented hook entries. |
| src/terminal/kimi-agent-config.ts | New file: generates --agent-file content as JSON saved with .yaml extension. |
| src/terminal/agent-session-adapters.ts | Adds kimiAdapter with --continue, --yolo, --plan, --config-file, and --agent-file injection. |
| src/terminal/session-manager.ts | Adds trySendDeferredKimiStartupInput triggered on first non-empty terminal output. |
| src/core/agent-catalog.ts | Adds kimi catalog entry and launch-supported ID. |
| src/core/api-contract.ts | Extends runtimeAgentIdSchema to include kimi. |
| src/config/runtime-config.ts | Adds kimi to AUTO_SELECT_AGENT_PRIORITY and normalizeAgentId allowlist. |
| test/runtime/terminal/kimi-config.test.ts | Good coverage of TOML merging; missing test for trailing comment on last user hook. |
| web-ui/src/components/runtime-settings-dialog.tsx | Adds kimi to SETTINGS_AGENT_ORDER. |
| web-ui/src/components/task-start-agent-onboarding-carousel.tsx | Adds kimi to onboarding carousel with description and install link. |
Sequence Diagram
sequenceDiagram
participant SM as SessionManager
participant Adapter as kimiAdapter
participant KimiCfg as kimi-config.ts
participant KimiAgent as kimi-agent-config.ts
participant PTY as PtySession (kimi)
SM->>Adapter: prepare(input)
Adapter->>KimiAgent: ensureKimiKanbanAgentFile()
KimiAgent-->>Adapter: agentFilePath
Adapter->>KimiCfg: ensureKimiKanbanConfig()
KimiCfg->>KimiCfg: read ~/.kimi/config.toml
KimiCfg->>KimiCfg: strip old kanban region
KimiCfg->>KimiCfg: extract and re-merge user hooks
KimiCfg-->>Adapter: configPath
Adapter-->>SM: args env deferredStartupInput
SM->>PTY: spawn kimi with flags
PTY-->>SM: onData first output chunk
SM->>PTY: write bracketed-paste of task prompt
Prompt To Fix All With AI
Fix the following 3 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 3
src/terminal/kimi-config.ts:153-171
**Trailing TOML comment swallows separator comma**
`ensureTomlArrayBodyTrailingComma` appends `,` to the raw end of the line, including any trailing `# comment`. If a user's last hook entry has a trailing comment — e.g. `{ event = "Stop", command = "echo done", timeout = 5 } # stop hook` — the function produces `... # stop hook,` where the comma is inside the TOML comment and is therefore ignored by the parser. The next array element (the first Kanban hook) then has no preceding comma, making the generated `config.toml` invalid TOML and preventing Kimi from reading the hooks config at all.
A fix would strip (or scan past) any trailing comment before checking or appending the comma, using the same character-by-character quote-aware scan already present in `countTomlArrayBracketDelta`.
### Issue 2 of 3
src/terminal/kimi-agent-config.ts:14-28
**JSON content written to a `.yaml` file**
`buildKimiKanbanAgentFileContent` uses `JSON.stringify` to produce the file content, but the output path ends in `agent.yaml`. JSON is valid YAML 1.2, so most modern YAML parsers will accept it. However, if Kimi's `--agent-file` reader enforces YAML-specific syntax or schema-validates based on file extension, this could silently break. The accompanying test also uses `JSON.parse` directly, suggesting the intent is JSON — the file extension may be a mismatch worth confirming against Kimi's documented agent-file format.
### Issue 3 of 3
src/terminal/kimi-config.ts:110-112
**Regex may treat an indented inline-array line as a table header**
`/^\s*\[/` matches any line that starts with optional whitespace followed by `[`. An array element written on its own line (e.g. ` ["inner", "value"]` inside a top-level array key) would also match, causing `findFirstTomlTableLineIndex` to report a false table boundary and misplace the generated `hooks = [...]` block. Tightening to `^\s*\[(?!\[)\w` to require a word character after the bracket would reduce false-match risk.
Reviews (1): Last reviewed commit: "feat(agents): add Kimi Code runtime supp..." | Re-trigger Greptile
Summary
Adds Kimi Code as a supported Kanban runtime agent.
Changes
kimito the runtime agent catalog, API contract, CLI options, web settings, and onboarding UI--continue--yolo--planhooks = [...]array--agent-filethat extends the default Kimi agentKIMI_SHARE_DIRconfig location, with compatibility fallback forKIMI_CODE_HOMERelated
Related discussion: #521
Validation
npm run checknpm run build