feat(agents): add kimi adapter#134
Conversation
Greptile SummaryThis PR adds the Kimi (Moonshot AI) CLI agent adapter as a Tier C harness, following the same structural pattern as the existing
Confidence Score: 5/5Safe to merge; the adapter is well-isolated, no-ops are clearly documented, and the change follows established patterns throughout the codebase. The new Kimi adapter is a straightforward addition with no impact on existing adapters or critical paths. Binary resolution, permission mapping, and session restore logic are all consistent with peer adapters. The one inconsistency — GetLaunchCommand skipping the early context guard — is a minor behavioral edge case that only surfaces when the binary is already cached on a cancelled context, not a data-loss or security concern. backend/internal/adapters/agent/kimi/kimi.go — specifically the missing ctx.Err() guard at the top of GetLaunchCommand. Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant Plugin as kimi.Plugin
participant Cache as resolvedBinary cache
participant Resolve as ResolveKimiBinary
Caller->>Plugin: GetLaunchCommand(ctx, cfg)
Plugin->>Cache: resolvedBinary set?
alt binary cached
Cache-->>Plugin: return cached path
else not cached
Plugin->>Resolve: ResolveKimiBinary(ctx)
Resolve-->>Plugin: binary path / error
Plugin->>Cache: store resolved path
end
Plugin->>Plugin: appendApprovalFlags(cmd, cfg.Permissions)
Plugin->>Plugin: append -p prompt (if set)
Plugin-->>Caller: "[]string{binary, [flags], -p, prompt}"
Caller->>Plugin: GetRestoreCommand(ctx, cfg)
Plugin->>Plugin: ctx.Err() check
Plugin->>Plugin: TrimSpace(agentSessionID)
alt no agentSessionID
Plugin-->>Caller: nil, false, nil
else has agentSessionID
Plugin->>Cache: resolvedBinary set?
Plugin->>Plugin: appendApprovalFlags + --session id
Plugin-->>Caller: "[]string{binary, [flags], --session, id}, true, nil"
end
Reviews (2): Last reviewed commit: "feat(agents): add kimi adapter" | Re-trigger Greptile |
Registers the kimi harness, stacked on the agent platform. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Kimi rejects `--prompt` combined with `--yolo`/`--auto`/`--plan`, and rejects `--yolo`/`--auto` combined with `--session`/`--continue` (non-interactive and resumed sessions inherit the auto permission policy). The previous mapping appended one of those flags before `-p` on every launch and before `--session` on every restore, so every non-interactive launch would fail at startup. The local binary (v1.37.0) additionally has no `--auto` option at all, which would fail even on otherwise-permissible paths. - GetLaunchCommand: emit approval flags only on the interactive path (no prompt). The `-p <prompt>` path is now bare. - GetRestoreCommand: never emit approval flags; resumed sessions inherit the original session's approval settings. - Tests assert no approval/plan flag leaks onto either path for any PermissionMode, and keep the interactive mapping unchanged. Refs: https://moonshotai.github.io/kimi-code/en/reference/kimi-command.html
There was a problem hiding this comment.
yyovil has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
Verified against upstream Kimi Code docs and shipped binary (v1.37.0), then pushed a fix on top of Findings re-verified (confirmed): Two flag-conflict rules from https://moonshotai.github.io/kimi-code/en/reference/kimi-command.html:
Binary-level check (
The previous adapter unconditionally prepended Changes (
Validation:
Pushed with |
Adds the kimi harness, stacked on #119 (agent platform). Adapter package +
Constructors()registration + resolver test.🤖 Generated with Claude Code
Stack