F7: one-time read-only import of the official kimi-cli configuration

New `kigi import-kimi` (with --dry-run) plus a one-time welcome-screen
hint when ~/.kimi/config.toml is present and unimported.

- Sources: ~/.kimi/config.toml (default_model, [models.*], [providers.*])
  and ~/.kimi/mcp.json ({"mcpServers": ...} — parsed by the existing
  McpConfig machinery). Shapes ported from kimi-cli 1.49.0 config.py with
  citations.
- Strictly read-only over ~/.kimi: plain reads only; the test suite pins
  byte-identical contents AND unchanged mtimes across scan+apply. Keyring
  credentials are never imported; KIMI_SHARE_DIR / any KIMI_* env var is
  never consulted (official dir hardcoded to ~/.kimi).
- Mapping: MCP servers merge into kigi [mcp_servers.*] without clobbering
  existing names; models on non-built-in providers become kigi [model.*]
  custom entries (base_url + api_key + context_window); providers that
  duplicate kigi's built-in Kimi/Moonshot platforms are skipped with a
  note; default_model maps to the imported alias or the managed catalog
  key and never overwrites an existing default.
- One-time marker ~/.kigi/kimi_import_done (claude-import convention);
  the startup hint and re-runs no-op once set. api_key values flow only
  into the user's own config.toml and are redacted in every summary.

Verified end-to-end with the real binary in a sandboxed home: dry-run,
apply, `kigi mcp list` shows both imported servers, second run no-ops,
~/.kimi mtimes unchanged. 8 unit tests + CLI parse test.
This commit is contained in:
2026-07-17 20:50:45 -04:00
parent a3f062b522
commit 913caed6d3
7 changed files with 1042 additions and 0 deletions
@@ -881,6 +881,19 @@ pub(crate) async fn run(
);
}
// F7: one-time offer to import the official kimi-cli configuration.
// Parallel to the Claude-import detection (`has_claude_import`), but
// deliberately lightweight: a welcome-screen system line pointing at the
// CLI command instead of a modal. Disappears once `kigi import-kimi` has
// run (marker file under ~/.kigi); the scan is read-only over ~/.kimi.
if kigi_shell::kimi_import::has_pending_kimi_import() {
app.startup_warnings.push(crate::startup::StartupWarning {
severity: crate::startup::WarningSeverity::Info,
message: "Found official kimi-cli settings in ~/.kimi.".to_string(),
action: Some("Run `kigi import-kimi` to import them (one-time).".to_string()),
});
}
// Apply initial config (may come from existing ~/.kigi/pager.toml).
let mut initial_config = config_watcher.current().clone();
// The cache holds the USER compact value; the render value is derived