From 7fa69ff7df4ddfd65090dc5542bcefd1c6b9de76 Mon Sep 17 00:00:00 2001 From: John Myers Date: Tue, 31 Mar 2026 13:50:59 -0700 Subject: [PATCH] fix(cli): add missing Copilot variant to CliProviderType enum PR #476 added Copilot as a supported provider but missed adding the Copilot variant to the CliProviderType enum, causing --provider copilot to fail at CLI argument parsing. Also adds a parity test to prevent future drift between CliProviderType and ProviderRegistry. Closes #707 --- crates/openshell-cli/src/main.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/crates/openshell-cli/src/main.rs b/crates/openshell-cli/src/main.rs index 4f4d4969..5f10ef90 100644 --- a/crates/openshell-cli/src/main.rs +++ b/crates/openshell-cli/src/main.rs @@ -597,6 +597,7 @@ enum CliProviderType { Claude, Opencode, Codex, + Copilot, Generic, Openai, Anthropic, @@ -627,6 +628,7 @@ impl CliProviderType { Self::Claude => "claude", Self::Opencode => "opencode", Self::Codex => "codex", + Self::Copilot => "copilot", Self::Generic => "generic", Self::Openai => "openai", Self::Anthropic => "anthropic", @@ -3137,4 +3139,29 @@ mod tests { other => panic!("expected settings delete command, got: {other:?}"), } } + + /// Ensure every provider registered in `ProviderRegistry` has a + /// corresponding `CliProviderType` variant (and vice-versa). + /// This test would have caught the missing `Copilot` variant from #707. + #[test] + fn cli_provider_types_match_registry() { + let registry = openshell_providers::ProviderRegistry::new(); + let registry_types: std::collections::BTreeSet<&str> = + registry.known_types().into_iter().collect(); + + let cli_types: std::collections::BTreeSet<&str> = + ::value_variants() + .iter() + .map(CliProviderType::as_str) + .collect(); + + assert_eq!( + cli_types, + registry_types, + "CliProviderType variants must match ProviderRegistry.known_types(). \ + CLI-only: {:?}, Registry-only: {:?}", + cli_types.difference(®istry_types).collect::>(), + registry_types.difference(&cli_types).collect::>(), + ); + } }