1#[allow(clippy::wildcard_imports)]
7use super::*;
8
9#[derive(Debug, Default)]
11pub struct AgentSetupResult {
12 pub mcp_ok: bool,
13 pub mcp_skipped: bool,
16 pub rules: crate::rules_inject::InjectResult,
17 pub skill_installed: bool,
18 pub errors: Vec<String>,
19}
20
21pub fn setup_single_agent(
24 agent_name: &str,
25 global: bool,
26 mode: crate::hooks::HookMode,
27) -> AgentSetupResult {
28 let home = crate::core::home::resolve_home_dir().unwrap_or_default();
31 let mut result = AgentSetupResult::default();
32
33 crate::hooks::install_agent_hook_respecting_rules_off(agent_name, global, mode);
34
35 if crate::core::config::Config::load()
39 .setup
40 .should_update_mcp()
41 {
42 match configure_agent_mcp(agent_name) {
43 Ok(()) => result.mcp_ok = true,
44 Err(e) => result.errors.push(format!("MCP config: {e}")),
45 }
46 } else {
47 result.mcp_skipped = true;
48 }
49
50 result.rules = crate::rules_inject::inject_rules_for_agent(&home, agent_name);
51
52 if let Ok(path) = crate::rules_inject::install_skill_for_agent(&home, agent_name) {
53 result.skill_installed = path.exists();
54 }
55
56 result
57}
58
59pub fn configure_agent_mcp(agent: &str) -> Result<(), String> {
60 let allow_rule_steering = crate::core::config::Config::load().rules_injection_effective()
61 != crate::core::config::RulesInjection::Off;
62
63 configure_agent_mcp_with_rule_steering(agent, allow_rule_steering)
64}
65
66pub(crate) fn configure_agent_mcp_with_rule_steering(
67 agent: &str,
68 allow_rule_steering: bool,
69) -> Result<(), String> {
70 let home = crate::core::home::resolve_home_dir()
72 .ok_or_else(|| "Cannot determine home directory".to_string())?;
73 let binary = resolve_portable_binary();
74
75 let targets = agent_mcp_targets(agent, &home)?;
76
77 let mut errors = Vec::new();
78 for t in &targets {
79 if let Err(e) = crate::core::editor_registry::write_config_with_options_and_rule_steering(
80 t,
81 &binary,
82 WriteOptions {
83 overwrite_invalid: true,
84 },
85 allow_rule_steering,
86 ) {
87 eprintln!(
88 "\x1b[33m⚠\x1b[0m Could not configure {}: {}",
89 t.config_path.display(),
90 e
91 );
92 errors.push(e);
93 }
94 }
95
96 if agent == "kiro" && allow_rule_steering {
97 install_kiro_steering(&home);
98 }
99
100 if (agent == "vscode" || agent == "copilot")
101 && let Err(e) = crate::core::editor_registry::plan_mode::write_vscode_plan_settings()
102 {
103 eprintln!("\x1b[33m⚠\x1b[0m VS Code plan mode: {e}");
104 }
105 if (agent == "claude" || agent == "claude-code")
106 && let Err(e) =
107 crate::core::editor_registry::plan_mode::write_claude_code_plan_permissions()
108 {
109 eprintln!("\x1b[33m⚠\x1b[0m Claude Code plan mode: {e}");
110 }
111 if agent == "codebuddy"
112 && let Err(e) =
113 crate::core::editor_registry::plan_mode::write_claude_code_plan_permissions()
114 {
115 eprintln!("\x1b[33m⚠\x1b[0m CodeBuddy plan mode: {e}");
116 }
117
118 if errors.is_empty() {
119 Ok(())
120 } else {
121 Err(format!(
122 "{} config(s) could not be written. See warnings above.",
123 errors.len()
124 ))
125 }
126}
127
128pub(crate) fn agent_mcp_targets(
129 agent: &str,
130 home: &std::path::Path,
131) -> Result<Vec<EditorTarget>, String> {
132 let mut targets = Vec::<EditorTarget>::new();
133
134 let push = |targets: &mut Vec<EditorTarget>,
135 name: &'static str,
136 config_path: PathBuf,
137 config_type: ConfigType| {
138 targets.push(EditorTarget {
139 name,
140 agent_key: agent.to_string(),
141 detect_path: PathBuf::from("/nonexistent"), config_path,
143 config_type,
144 });
145 };
146
147 match agent {
148 "cursor" => push(
149 &mut targets,
150 "Cursor",
151 home.join(".cursor/mcp.json"),
152 ConfigType::McpJson,
153 ),
154 "claude" | "claude-code" => push(
155 &mut targets,
156 "Claude Code",
157 crate::core::editor_registry::claude_mcp_json_path(home),
158 ConfigType::McpJson,
159 ),
160 "codebuddy" => push(
161 &mut targets,
162 "CodeBuddy",
163 crate::core::editor_registry::codebuddy_mcp_json_path(home),
164 ConfigType::McpJson,
165 ),
166 "commandcode" => push(
167 &mut targets,
168 "Command Code",
169 home.join(".commandcode/mcp.json"),
170 ConfigType::CommandCode,
171 ),
172 "augment" => {
173 push(
174 &mut targets,
175 "Augment CLI",
176 crate::core::editor_registry::augment_cli_settings_path(home),
177 ConfigType::McpJson,
178 );
179 push(
180 &mut targets,
181 "Augment (VS Code)",
182 crate::core::editor_registry::augment_vscode_mcp_path(home),
183 ConfigType::AugmentVsCode,
184 );
185 }
186 "windsurf" => push(
187 &mut targets,
188 "Windsurf",
189 home.join(".codeium/windsurf/mcp_config.json"),
190 ConfigType::McpJson,
191 ),
192 "codex" => push(
193 &mut targets,
194 "Codex CLI",
195 crate::core::home::resolve_codex_config_path()
196 .unwrap_or_else(|| home.join(".codex/config.toml")),
197 ConfigType::Codex,
198 ),
199 "grok" => push(
200 &mut targets,
201 "Grok",
202 home.join(".grok/config.toml"),
203 ConfigType::Codex,
204 ),
205 "gemini" => {
206 push(
207 &mut targets,
208 "Gemini CLI",
209 home.join(".gemini/settings.json"),
210 ConfigType::GeminiSettings,
211 );
212 push(
213 &mut targets,
214 "Antigravity IDE",
215 home.join(".gemini/antigravity/mcp_config.json"),
216 ConfigType::McpJson,
217 );
218 push(
219 &mut targets,
220 "Antigravity CLI",
221 home.join(".gemini/antigravity-cli/mcp_config.json"),
222 ConfigType::McpJson,
223 );
224 }
225 "antigravity" => push(
226 &mut targets,
227 "Antigravity IDE",
228 home.join(".gemini/antigravity/mcp_config.json"),
229 ConfigType::McpJson,
230 ),
231 "antigravity-cli" => push(
232 &mut targets,
233 "Antigravity CLI",
234 home.join(".gemini/antigravity-cli/mcp_config.json"),
235 ConfigType::McpJson,
236 ),
237 "copilot" => push(
238 &mut targets,
239 "Copilot CLI",
240 home.join(".copilot/mcp-config.json"),
241 ConfigType::CopilotCli,
242 ),
243 "crush" => push(
244 &mut targets,
245 "Crush",
246 home.join(".config/crush/crush.json"),
247 ConfigType::Crush,
248 ),
249 "qoder" => {
250 for path in crate::core::editor_registry::qoder_all_mcp_paths(home) {
251 push(&mut targets, "Qoder", path, ConfigType::QoderSettings);
252 }
253 }
254 "qoderwork" => push(
255 &mut targets,
256 "QoderWork",
257 crate::core::editor_registry::qoderwork_mcp_path(home),
258 ConfigType::McpJson,
259 ),
260 "qodercli" => push(
261 &mut targets,
262 "Qoder CLI",
263 crate::core::editor_registry::qodercli_settings_path(home),
264 ConfigType::QoderSettings,
265 ),
266 "cline" => push(
267 &mut targets,
268 "Cline",
269 crate::core::editor_registry::cline_mcp_path(),
270 ConfigType::McpJson,
271 ),
272 "cline-cli" => push(
273 &mut targets,
274 "Cline CLI",
275 crate::core::editor_registry::cline_cli_mcp_settings_path(),
276 ConfigType::ClineCli,
277 ),
278 "omp" => push(
279 &mut targets,
280 "Oh My Pi",
281 crate::core::editor_registry::omp_mcp_path(home),
282 ConfigType::OmpMcp,
283 ),
284 "roo" => push(
285 &mut targets,
286 "Roo Code",
287 crate::core::editor_registry::roo_mcp_path(),
288 ConfigType::McpJson,
289 ),
290 "kiro" => push(
291 &mut targets,
292 "AWS Kiro",
293 home.join(".kiro/settings/mcp.json"),
294 ConfigType::McpJson,
295 ),
296 "verdent" => push(
297 &mut targets,
298 "Verdent",
299 home.join(".verdent/mcp.json"),
300 ConfigType::McpJson,
301 ),
302 "pi" | "jetbrains" | "amp" | "openclaw" => {
308 }
311 "qwen" => push(
312 &mut targets,
313 "Qwen Code",
314 home.join(".qwen/settings.json"),
315 ConfigType::McpJson,
316 ),
317 "trae" => push(
318 &mut targets,
319 "Trae",
320 home.join(".trae/mcp.json"),
321 ConfigType::McpJson,
322 ),
323 "codewhale" => push(
326 &mut targets,
327 "CodeWhale",
328 crate::core::editor_registry::codewhale_mcp_json_path(home),
329 ConfigType::CodeWhale,
330 ),
331 "amazonq" => push(
332 &mut targets,
333 "Amazon Q Developer",
334 home.join(".aws/amazonq/default.json"),
335 ConfigType::McpJson,
336 ),
337 "opencode" => {
338 let opencode_path = crate::core::opencode_config::resolve(home).path;
341 push(
342 &mut targets,
343 "OpenCode",
344 opencode_path,
345 ConfigType::OpenCode,
346 );
347 }
348 "hermes" => push(
349 &mut targets,
350 "Hermes Agent",
351 home.join(".hermes/config.yaml"),
352 ConfigType::HermesYaml,
353 ),
354 "vscode" => push(
355 &mut targets,
356 "VS Code",
357 crate::core::editor_registry::vscode_mcp_path(),
358 ConfigType::VsCodeMcp,
359 ),
360 "vscode-insiders" => push(
361 &mut targets,
362 "VS Code Insiders",
363 crate::core::editor_registry::vscode_insiders_mcp_path(),
364 ConfigType::VsCodeMcp,
365 ),
366 "zed" => push(
367 &mut targets,
368 "Zed",
369 crate::core::editor_registry::zed_settings_path(home),
370 ConfigType::Zed,
371 ),
372 "aider" => push(
373 &mut targets,
374 "Aider",
375 home.join(".aider/mcp.json"),
376 ConfigType::McpJson,
377 ),
378 "continue" => push(
379 &mut targets,
380 "Continue",
381 home.join(".continue/mcp.json"),
382 ConfigType::McpJson,
383 ),
384 "neovim" => push(
385 &mut targets,
386 "Neovim (mcphub.nvim)",
387 home.join(".config/mcphub/servers.json"),
388 ConfigType::McpJson,
389 ),
390 "emacs" => push(
391 &mut targets,
392 "Emacs (mcp.el)",
393 home.join(".emacs.d/mcp.json"),
394 ConfigType::McpJson,
395 ),
396 "sublime" => push(
397 &mut targets,
398 "Sublime Text",
399 home.join(".config/sublime-text/mcp.json"),
400 ConfigType::McpJson,
401 ),
402 _ => {
403 return Err(format!("Unknown agent '{agent}'"));
404 }
405 }
406
407 Ok(targets)
408}
409
410pub fn disable_agent_mcp(agent: &str, overwrite_invalid: bool) -> Result<(), String> {
411 let home = crate::core::home::resolve_home_dir()
413 .ok_or_else(|| "Cannot determine home directory".to_string())?;
414
415 let mut targets = Vec::<EditorTarget>::new();
416
417 let push = |targets: &mut Vec<EditorTarget>,
418 name: &'static str,
419 config_path: PathBuf,
420 config_type: ConfigType| {
421 targets.push(EditorTarget {
422 name,
423 agent_key: agent.to_string(),
424 detect_path: PathBuf::from("/nonexistent"),
425 config_path,
426 config_type,
427 });
428 };
429
430 let pi_cfg = home.join(".pi").join("agent").join("mcp.json");
431
432 match agent {
433 "cursor" => push(
434 &mut targets,
435 "Cursor",
436 home.join(".cursor/mcp.json"),
437 ConfigType::McpJson,
438 ),
439 "claude" | "claude-code" => push(
440 &mut targets,
441 "Claude Code",
442 crate::core::editor_registry::claude_mcp_json_path(&home),
443 ConfigType::McpJson,
444 ),
445 "codebuddy" => push(
446 &mut targets,
447 "CodeBuddy",
448 crate::core::editor_registry::codebuddy_mcp_json_path(&home),
449 ConfigType::McpJson,
450 ),
451 "commandcode" => push(
452 &mut targets,
453 "Command Code",
454 home.join(".commandcode/mcp.json"),
455 ConfigType::CommandCode,
456 ),
457 "augment" => {
458 push(
459 &mut targets,
460 "Augment CLI",
461 crate::core::editor_registry::augment_cli_settings_path(&home),
462 ConfigType::McpJson,
463 );
464 push(
465 &mut targets,
466 "Augment (VS Code)",
467 crate::core::editor_registry::augment_vscode_mcp_path(&home),
468 ConfigType::AugmentVsCode,
469 );
470 }
471 "windsurf" => push(
472 &mut targets,
473 "Windsurf",
474 home.join(".codeium/windsurf/mcp_config.json"),
475 ConfigType::McpJson,
476 ),
477 "codex" => push(
478 &mut targets,
479 "Codex CLI",
480 crate::core::home::resolve_codex_config_path()
481 .unwrap_or_else(|| home.join(".codex/config.toml")),
482 ConfigType::Codex,
483 ),
484 "grok" => push(
485 &mut targets,
486 "Grok",
487 home.join(".grok/config.toml"),
488 ConfigType::Codex,
489 ),
490 "gemini" => {
491 push(
492 &mut targets,
493 "Gemini CLI",
494 home.join(".gemini/settings.json"),
495 ConfigType::GeminiSettings,
496 );
497 push(
498 &mut targets,
499 "Antigravity IDE",
500 home.join(".gemini/antigravity/mcp_config.json"),
501 ConfigType::McpJson,
502 );
503 push(
504 &mut targets,
505 "Antigravity CLI",
506 home.join(".gemini/antigravity-cli/mcp_config.json"),
507 ConfigType::McpJson,
508 );
509 }
510 "antigravity" => push(
511 &mut targets,
512 "Antigravity IDE",
513 home.join(".gemini/antigravity/mcp_config.json"),
514 ConfigType::McpJson,
515 ),
516 "antigravity-cli" => push(
517 &mut targets,
518 "Antigravity CLI",
519 home.join(".gemini/antigravity-cli/mcp_config.json"),
520 ConfigType::McpJson,
521 ),
522 "copilot" => push(
523 &mut targets,
524 "Copilot CLI",
525 home.join(".copilot/mcp-config.json"),
526 ConfigType::CopilotCli,
527 ),
528 "crush" => push(
529 &mut targets,
530 "Crush",
531 home.join(".config/crush/crush.json"),
532 ConfigType::Crush,
533 ),
534 "pi" => push(&mut targets, "Pi Coding Agent", pi_cfg, ConfigType::McpJson),
535 "qoder" => {
536 for path in crate::core::editor_registry::qoder_all_mcp_paths(&home) {
537 push(&mut targets, "Qoder", path, ConfigType::QoderSettings);
538 }
539 }
540 "qoderwork" => push(
541 &mut targets,
542 "QoderWork",
543 crate::core::editor_registry::qoderwork_mcp_path(&home),
544 ConfigType::McpJson,
545 ),
546 "qodercli" => push(
547 &mut targets,
548 "Qoder CLI",
549 crate::core::editor_registry::qodercli_settings_path(&home),
550 ConfigType::QoderSettings,
551 ),
552 "cline" => push(
553 &mut targets,
554 "Cline",
555 crate::core::editor_registry::cline_mcp_path(),
556 ConfigType::McpJson,
557 ),
558 "cline-cli" => push(
559 &mut targets,
560 "Cline CLI",
561 crate::core::editor_registry::cline_cli_mcp_settings_path(),
562 ConfigType::ClineCli,
563 ),
564 "omp" => push(
565 &mut targets,
566 "Oh My Pi",
567 crate::core::editor_registry::omp_mcp_path(&home),
568 ConfigType::OmpMcp,
569 ),
570 "roo" => push(
571 &mut targets,
572 "Roo Code",
573 crate::core::editor_registry::roo_mcp_path(),
574 ConfigType::McpJson,
575 ),
576 "kiro" => push(
577 &mut targets,
578 "AWS Kiro",
579 home.join(".kiro/settings/mcp.json"),
580 ConfigType::McpJson,
581 ),
582 "verdent" => push(
583 &mut targets,
584 "Verdent",
585 home.join(".verdent/mcp.json"),
586 ConfigType::McpJson,
587 ),
588 "jetbrains" | "amp" | "openclaw" => {
589 }
591 "qwen" => push(
592 &mut targets,
593 "Qwen Code",
594 home.join(".qwen/settings.json"),
595 ConfigType::McpJson,
596 ),
597 "trae" => push(
598 &mut targets,
599 "Trae",
600 home.join(".trae/mcp.json"),
601 ConfigType::McpJson,
602 ),
603 "codewhale" => push(
606 &mut targets,
607 "CodeWhale",
608 crate::core::editor_registry::codewhale_mcp_json_path(home.as_ref()),
609 ConfigType::CodeWhale,
610 ),
611 "amazonq" => push(
612 &mut targets,
613 "Amazon Q Developer",
614 home.join(".aws/amazonq/default.json"),
615 ConfigType::McpJson,
616 ),
617 "opencode" => {
618 let opencode_path = crate::core::opencode_config::resolve(home.as_ref()).path;
621 push(
622 &mut targets,
623 "OpenCode",
624 opencode_path,
625 ConfigType::OpenCode,
626 );
627 }
628 "hermes" => push(
629 &mut targets,
630 "Hermes Agent",
631 home.join(".hermes/config.yaml"),
632 ConfigType::HermesYaml,
633 ),
634 "vscode" => push(
635 &mut targets,
636 "VS Code",
637 crate::core::editor_registry::vscode_mcp_path(),
638 ConfigType::VsCodeMcp,
639 ),
640 "vscode-insiders" => push(
641 &mut targets,
642 "VS Code Insiders",
643 crate::core::editor_registry::vscode_insiders_mcp_path(),
644 ConfigType::VsCodeMcp,
645 ),
646 "zed" => push(
647 &mut targets,
648 "Zed",
649 crate::core::editor_registry::zed_settings_path(&home),
650 ConfigType::Zed,
651 ),
652 "aider" => push(
653 &mut targets,
654 "Aider",
655 home.join(".aider/mcp.json"),
656 ConfigType::McpJson,
657 ),
658 "continue" => push(
659 &mut targets,
660 "Continue",
661 home.join(".continue/mcp.json"),
662 ConfigType::McpJson,
663 ),
664 "neovim" => push(
665 &mut targets,
666 "Neovim (mcphub.nvim)",
667 home.join(".config/mcphub/servers.json"),
668 ConfigType::McpJson,
669 ),
670 "emacs" => push(
671 &mut targets,
672 "Emacs (mcp.el)",
673 home.join(".emacs.d/mcp.json"),
674 ConfigType::McpJson,
675 ),
676 "sublime" => push(
677 &mut targets,
678 "Sublime Text",
679 home.join(".config/sublime-text/mcp.json"),
680 ConfigType::McpJson,
681 ),
682 _ => {
683 return Err(format!("Unknown agent '{agent}'"));
684 }
685 }
686
687 for t in &targets {
688 crate::core::editor_registry::remove_lean_ctx_server(
689 t,
690 WriteOptions { overwrite_invalid },
691 )?;
692 }
693
694 Ok(())
695}
696
697#[cfg(test)]
698mod qodercli_tests {
699 use super::*;
700
701 struct CurrentDirGuard(std::path::PathBuf);
702
703 impl CurrentDirGuard {
704 fn set(path: &std::path::Path) -> Self {
705 let previous = std::env::current_dir().expect("current dir");
706 std::env::set_current_dir(path).expect("set current dir");
707 Self(previous)
708 }
709 }
710
711 impl Drop for CurrentDirGuard {
712 fn drop(&mut self) {
713 let _ = std::env::set_current_dir(&self.0);
714 }
715 }
716
717 #[test]
718 fn kiro_mcp_configuration_respects_rule_steering_policy() {
719 let _env_lock = crate::core::data_dir::test_env_lock();
720 let tmp = tempfile::tempdir().unwrap();
721 let home = tmp.path().join("home");
722 let project = tmp.path().join("project");
723
724 std::fs::create_dir_all(&home).unwrap();
725 std::fs::create_dir_all(&project).unwrap();
726
727 let _home_guard = crate::setup::EnvVarGuard::set("HOME", home.to_string_lossy().as_ref());
728 let _profile_guard =
729 crate::setup::EnvVarGuard::set("USERPROFILE", home.to_string_lossy().as_ref());
730 let _cwd_guard = CurrentDirGuard::set(&project);
731
732 configure_agent_mcp_with_rule_steering("kiro", false).unwrap();
733
734 assert!(
735 home.join(".kiro/settings/mcp.json").exists(),
736 "Kiro MCP registration must still be written when steering is disabled"
737 );
738
739 let steering = project.join(".kiro/steering/lean-ctx.md");
740
741 assert!(
742 !steering.exists(),
743 "steering-disabled Kiro setup must not create lean-ctx steering"
744 );
745
746 configure_agent_mcp_with_rule_steering("kiro", true).unwrap();
747
748 assert!(
749 steering.exists(),
750 "test precondition failed: steering-enabled Kiro setup should create its steering file"
751 );
752 }
753
754 #[test]
755 fn commandcode_agent_target_uses_command_code_schema() {
756 let home = std::path::Path::new("/home/tester");
757 let targets = agent_mcp_targets("commandcode", home).unwrap();
758
759 assert_eq!(targets.len(), 1);
760 assert_eq!(targets[0].name, "Command Code");
761 assert_eq!(targets[0].config_path, home.join(".commandcode/mcp.json"));
762 assert_eq!(targets[0].config_type, ConfigType::CommandCode);
763 }
764
765 #[test]
766 fn codewhale_agent_target_uses_codewhale_schema_and_current_path() {
767 let home = std::path::Path::new("/home/tester");
770 let targets = agent_mcp_targets("codewhale", home).unwrap();
771
772 assert_eq!(targets.len(), 1);
773 assert_eq!(targets[0].name, "CodeWhale");
774 assert_eq!(targets[0].agent_key, "codewhale");
775 assert_eq!(targets[0].config_type, ConfigType::CodeWhale);
776 assert_eq!(targets[0].config_path, home.join(".codewhale/mcp.json"));
777 }
778
779 #[test]
780 fn codewhale_agent_target_follows_legacy_deepseek_config_when_that_is_the_live_one() {
781 let tmp = tempfile::tempdir().unwrap();
782 let home = tmp.path();
783 std::fs::create_dir_all(home.join(".deepseek")).unwrap();
784 std::fs::write(home.join(".deepseek/mcp.json"), "{}").unwrap();
785
786 let targets = agent_mcp_targets("codewhale", home).unwrap();
787 assert_eq!(targets[0].config_path, home.join(".deepseek/mcp.json"));
788 }
789
790 #[test]
791 fn cline_cli_agent_target_uses_cline_cli_schema() {
792 let home = std::path::Path::new("/home/tester");
793 let targets = agent_mcp_targets("cline-cli", home).unwrap();
794
795 assert_eq!(targets.len(), 1);
796 assert_eq!(targets[0].name, "Cline CLI");
797 assert_eq!(targets[0].config_type, ConfigType::ClineCli);
798 }
799
800 #[test]
801 fn omp_agent_target_uses_the_native_agent_dir_and_schema() {
802 let home = std::path::Path::new("/home/tester");
803 let targets = agent_mcp_targets("omp", home).unwrap();
804
805 assert_eq!(targets.len(), 1);
806 assert_eq!(targets[0].name, "Oh My Pi");
807 assert_eq!(
808 targets[0].config_path,
809 crate::core::editor_registry::omp_mcp_path(home)
810 );
811 assert_eq!(targets[0].config_type, ConfigType::OmpMcp);
812 if std::env::var_os("PI_CODING_AGENT_DIR").is_none() {
815 assert_eq!(targets[0].config_path, home.join(".omp/agent/mcp.json"));
816 }
817 }
818
819 #[test]
820 fn omp_and_pi_stay_separate_setup_targets() {
821 let home = std::path::Path::new("/home/tester");
822 let omp = agent_mcp_targets("omp", home).unwrap();
823 let pi = agent_mcp_targets("pi", home).unwrap();
824 assert!(
825 pi.iter().all(|t| t.config_path != omp[0].config_path),
826 "Oh My Pi must not write into the stock Pi config"
827 );
828 }
829
830 #[test]
831 fn qodercli_agent_target_uses_settings_json() {
832 let home = std::path::Path::new("/home/tester");
833 let targets = agent_mcp_targets("qodercli", home).unwrap();
834
835 assert_eq!(targets.len(), 1);
836 assert_eq!(targets[0].name, "Qoder CLI");
837 assert_eq!(targets[0].config_path, home.join(".qoder/settings.json"));
838 }
839
840 #[test]
841 fn qodercli_agent_target_uses_qoder_settings_writer() {
842 let home = std::path::Path::new("/home/tester");
843 let targets = agent_mcp_targets("qodercli", home).unwrap();
844
845 assert_eq!(targets[0].agent_key, "qodercli");
846 assert_eq!(targets[0].config_type, ConfigType::QoderSettings);
847 }
848
849 #[test]
850 fn qodercli_agent_target_is_separate_from_qoder_ide_targets() {
851 let home = std::path::Path::new("/home/tester");
852 let cli = agent_mcp_targets("qodercli", home).unwrap();
853 let ide = agent_mcp_targets("qoder", home).unwrap();
854
855 assert!(
856 ide.iter()
857 .all(|target| target.config_path != cli[0].config_path)
858 );
859 }
860}