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:
@@ -17,6 +17,13 @@ pub enum Command {
|
||||
#[arg(long)]
|
||||
json: bool,
|
||||
},
|
||||
/// One-time, read-only import of the official kimi-cli configuration
|
||||
/// (~/.kimi): MCP servers, custom model providers, default model
|
||||
ImportKimi {
|
||||
/// Print what would be imported without writing anything.
|
||||
#[arg(long)]
|
||||
dry_run: bool,
|
||||
},
|
||||
/// Manage running leader processes
|
||||
Leader(LeaderMgmtArgs),
|
||||
/// Sign out and clear cached credentials
|
||||
@@ -1208,6 +1215,23 @@ mod tests {
|
||||
.expect("both effort flag names parse (reverse order)");
|
||||
assert_eq!(reverse.reasoning_effort.as_deref(), Some("low"));
|
||||
}
|
||||
/// PRD F7: `import-kimi` parses with and without `--dry-run`.
|
||||
#[test]
|
||||
fn import_kimi_parses_with_and_without_dry_run() {
|
||||
let args = PagerArgs::try_parse_from(["kigi", "import-kimi", "--dry-run"])
|
||||
.expect("import-kimi --dry-run parses");
|
||||
assert!(matches!(
|
||||
args.command,
|
||||
Some(Command::ImportKimi { dry_run: true })
|
||||
));
|
||||
let args =
|
||||
PagerArgs::try_parse_from(["kigi", "import-kimi"]).expect("bare import-kimi parses");
|
||||
assert!(matches!(
|
||||
args.command,
|
||||
Some(Command::ImportKimi { dry_run: false })
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn agent_args_effort_alias_parses() {
|
||||
let args = PagerArgs::try_parse_from(["grok", "agent", "--effort", "max", "stdio"])
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user