Skip to main content

codewhale_command_contract/
config.rs

1//! Config-group command facets (FEAT-028 D3/D4).
2//!
3//! These traits let `/config`, `/settings`, `/mode`, `/theme`, `/verbose`,
4//! `/login`, `/logout`, `/pet` and `/trust` express their intent without naming
5//! `App`, a service locator, a callback, or any concrete host type. Hosts own
6//! persistence, services and I/O; the values here grant no terminal, TUI or
7//! runtime authority, and a missing facet must fail safely rather than panic.
8
9use crate::outcome::ConfigAction;
10use std::path::{Path, PathBuf};
11
12/// A message the host raises for the command to render.
13///
14/// The host never renders user-facing text for the config group: it returns a
15/// stable key plus named replacements (each replacement is itself a message,
16/// so a host never pre-renders a localized fragment), and the command resolves
17/// it through the `presentation` shape. Non-localized text (protocol/config/
18/// command names, computed values) stays a `Literal`.
19#[derive(Debug, Clone, PartialEq, Eq)]
20pub enum ConfigMessage {
21    /// Resolved by the presentation shape via its stable snake_case key.
22    Keyed {
23        key: String,
24        params: Vec<(String, ConfigMessage)>,
25    },
26    /// Non-localized text.
27    Literal(String),
28    /// A sequence rendered in order, for literal framing around keyed parts.
29    Concat(Vec<ConfigMessage>),
30}
31
32impl ConfigMessage {
33    pub fn keyed(key: impl Into<String>) -> Self {
34        Self::Keyed {
35            key: key.into(),
36            params: Vec::new(),
37        }
38    }
39    pub fn keyed_with(key: impl Into<String>, params: Vec<(String, ConfigMessage)>) -> Self {
40        Self::Keyed {
41            key: key.into(),
42            params,
43        }
44    }
45    pub fn literal(text: impl Into<String>) -> Self {
46        Self::Literal(text.into())
47    }
48    pub fn concat(parts: Vec<ConfigMessage>) -> Self {
49        Self::Concat(parts)
50    }
51}
52
53impl From<String> for ConfigMessage {
54    fn from(value: String) -> Self {
55        Self::Literal(value)
56    }
57}
58
59impl From<&str> for ConfigMessage {
60    fn from(value: &str) -> Self {
61        Self::Literal(value.to_string())
62    }
63}
64
65impl From<std::borrow::Cow<'_, str>> for ConfigMessage {
66    fn from(value: std::borrow::Cow<'_, str>) -> Self {
67        Self::Literal(value.into_owned())
68    }
69}
70
71/// Portable result of a config-group host operation.
72///
73/// The host raises a [`ConfigMessage`] and the single action the request
74/// implies; the command resolves the message through the presentation shape and
75/// maps the reply to `CommandResult<ConfigAction>` without touching `App`.
76#[derive(Debug, Clone, PartialEq, Eq)]
77pub struct ConfigReply {
78    pub message: Option<ConfigMessage>,
79    pub action: Option<ConfigAction>,
80    pub is_error: bool,
81}
82
83impl ConfigReply {
84    pub fn ok() -> Self {
85        Self {
86            message: None,
87            action: None,
88            is_error: false,
89        }
90    }
91    pub fn message(msg: impl Into<ConfigMessage>) -> Self {
92        Self {
93            message: Some(msg.into()),
94            action: None,
95            is_error: false,
96        }
97    }
98    pub fn error(msg: impl Into<ConfigMessage>) -> Self {
99        let msg = match msg.into() {
100            ConfigMessage::Literal(text) => ConfigMessage::Literal(format!("Error: {text}")),
101            other => other,
102        };
103        Self {
104            message: Some(msg),
105            action: None,
106            is_error: true,
107        }
108    }
109    pub fn action(action: ConfigAction) -> Self {
110        Self {
111            message: None,
112            action: Some(action),
113            is_error: false,
114        }
115    }
116    pub fn with_message_and_action(msg: impl Into<ConfigMessage>, action: ConfigAction) -> Self {
117        Self {
118            message: Some(msg.into()),
119            action: Some(action),
120            is_error: false,
121        }
122    }
123}
124
125/// One structured `/settings` row: the label, its column width and its value.
126#[derive(Debug, Clone, PartialEq, Eq)]
127pub struct CommandSettingsRow {
128    pub label: String,
129    pub value: String,
130    pub label_width: usize,
131}
132
133/// Typed `/settings text` report.
134///
135/// The host supplies display rows and the config-file path; the command owns
136/// the title, separator, footer and joining.
137#[derive(Debug, Clone, PartialEq, Eq)]
138pub struct CommandSettingsReport {
139    pub rows: Vec<CommandSettingsRow>,
140    pub config_file: String,
141    pub from_settings: Vec<String>,
142    pub session_overrides: Vec<String>,
143}
144
145/// Typed `/config subagents [status]` report.
146#[derive(Debug, Clone, PartialEq, Eq)]
147pub struct CommandSubagentsReport {
148    pub disabled_reason: Option<String>,
149    pub config_path: String,
150    pub provider_key: String,
151    pub provider_label: String,
152    pub explicit_enabled: Option<bool>,
153    pub limits: Vec<CommandSubagentsLimit>,
154    /// Per-provider override rows for the active provider, when configured.
155    pub provider_rows: Option<Vec<CommandSubagentsProviderRow>>,
156}
157
158/// One of the five sub-agent limits: raw, resolved global and active-provider.
159#[derive(Debug, Clone, PartialEq, Eq)]
160pub struct CommandSubagentsLimit {
161    pub key: &'static str,
162    pub raw: String,
163    pub global: String,
164    pub provider: String,
165}
166
167/// One per-provider override row (already display-formatted).
168#[derive(Debug, Clone, PartialEq, Eq)]
169pub struct CommandSubagentsProviderRow {
170    pub key: &'static str,
171    pub value: String,
172}
173
174/// One row of the `/config status` editability audit.
175///
176/// The host supplies typed facts; the command owns the table layout.
177#[derive(Debug, Clone, PartialEq, Eq)]
178pub struct CommandConfigAuditRow {
179    pub key: String,
180    pub current: String,
181    pub editability: String,
182    pub command: String,
183    /// Keyed when the note is localized, literal otherwise.
184    pub note: ConfigMessage,
185}
186
187/// Typed `/config status` audit: the resolved config path and its rows.
188#[derive(Debug, Clone, PartialEq, Eq)]
189pub struct CommandConfigAuditReport {
190    pub config_path: String,
191    pub rows: Vec<CommandConfigAuditRow>,
192}
193
194/// The complete reply contract for mutating config operations.
195///
196/// A mutating [`CommandConfigContext`] operation MUST return a [`ConfigReply`]
197/// whose keyed messages use only these keys, each with exactly these parameter
198/// names. The command validates every entry (and prepares the substituted
199/// template) *before* the effect, so rendering a mutating reply is pure
200/// substitution and never translates after the effect. A key or parameter set
201/// outside this contract is a host bug.
202pub const EFFECT_REPLY_TEMPLATES: &[(&str, &[&str])] = &[
203    ("config_command_invalid_value", &["key", "value", "choices"]),
204    ("config_notification_updated", &["key", "value", "scope"]),
205    ("config_notifications_set_hint", &[]),
206    ("config_prompt_suggestion_updated", &["value", "scope"]),
207    ("config_scope_saved", &[]),
208    ("config_scope_session", &[]),
209    ("config_search_updated", &["value", "scope"]),
210    ("contextual_tips_not_saved", &["error"]),
211    ("help_usage_label", &[]),
212    ("startup_default_not_saved", &["setting", "error"]),
213];
214
215/// Read/write configuration, presets, the editability audit, login state and
216/// the config-owned view/display commands (`/mode`, `/theme`, `/verbose`,
217/// `/fullscreen`, `/inline`, `/statusbar`, `/workbar`, `/import-claude`).
218///
219/// The host owns per-key validation, normalization, persistence and the exact
220/// message; the portable handler owns argument parsing and subcommand routing.
221/// A missing facet must fail safely rather than panic.
222pub trait CommandConfigContext {
223    /// Path of the active user configuration file, when one is resolved.
224    fn config_path(&self) -> Option<PathBuf>;
225    fn translation_enabled(&self) -> bool;
226    fn set_translation_enabled(&mut self, enabled: bool);
227
228    /// `/config status|audit|editability|editable` — typed audit rows.
229    fn audit(&mut self) -> Result<CommandConfigAuditReport, String>;
230    /// `/config workflow` / `/config goal` — typed effective facts.
231    fn workflow_summary(&mut self) -> CommandWorkflowSummary;
232    /// `/config subagents status` — typed subagent facts.
233    fn subagents_status(&mut self) -> Result<CommandSubagentsReport, String>;
234    /// `/config subagents <key>` — show one subagent setting.
235    fn subagent(&mut self, key: &str) -> ConfigReply;
236    /// `/config subagents <key> <value> [--save]`.
237    fn set_subagent(&mut self, key: &str, value: &str, persist: bool) -> ConfigReply;
238    /// `/config search.provider` — the current provider and source.
239    fn search_provider_status(&mut self) -> ConfigReply;
240    /// Accepted `search.provider` values, for the portable usage message.
241    fn search_provider_names(&self) -> &'static str;
242    /// `/config search.provider <value> [--save]`.
243    fn set_search_provider(&mut self, value: &str, persist: bool) -> ConfigReply;
244    /// `/config notifications` — the notifications report.
245    fn notifications_status(&mut self) -> ConfigReply;
246    /// `/config notifications <key>` — show one notification setting.
247    fn notification(&mut self, key: &str) -> ConfigReply;
248    /// `/config notifications <key> <value> [--save]`.
249    fn set_notification(&mut self, key: &str, value: &str, persist: bool) -> ConfigReply;
250    /// `/config preset <name> [--save]`.
251    fn apply_preset(&mut self, name: &str, persist: bool) -> ConfigReply;
252    /// `/config <key>` — show the current value.
253    fn get_value(&mut self, key: &str) -> ConfigReply;
254    /// `/config <key> <value> [--save]`.
255    fn set_value(&mut self, key: &str, value: &str, persist: bool) -> ConfigReply;
256    /// `/settings text` — typed settings facts.
257    fn show_settings(&mut self) -> Result<CommandSettingsReport, String>;
258    /// `/theme schema` — the user theme JSON schema.
259    fn theme_schema(&self) -> String;
260    /// `/theme path` — the user themes directory, rendered for display.
261    fn themes_dir(&self) -> Result<String, String>;
262    /// Current verbose-transcript flag.
263    fn verbose_enabled(&self) -> bool;
264    /// Set the verbose-transcript flag (the host also marks history updated).
265    fn set_verbose_enabled(&mut self, enabled: bool);
266    /// Current terminal screen mode, for `/fullscreen` and `/inline`.
267    fn screen_mode(&self) -> crate::types::CommandScreenMode;
268    /// `/import-claude` — build the plan from the host's home/workspace.
269    fn build_plan(&mut self) -> Option<CommandClaudePlan>;
270    /// `/import-claude` — persist the rendered report and optional bundle.
271    fn write_artifacts(&mut self, report: &str, bundle: Option<&str>) -> CommandClaudeArtifacts;
272    /// `/import-claude --apply` — carry over the standing instructions.
273    fn apply_import(
274        &mut self,
275        plan: &CommandClaudePlan,
276        report_path: &Path,
277        wrote_report: bool,
278    ) -> CommandClaudeApplyOutcome;
279    /// Host display form of a path.
280    fn display_path(&self, path: &Path) -> String;
281}
282
283/// Pet presence, mode, sound and habitat actions for `/pet`.
284///
285/// The command owns the verb parsing and message composition; the facet only
286/// observes and mutates the pet state and resolves the localized labels.
287#[derive(Debug, Clone, Copy, PartialEq, Eq)]
288pub enum CommandPetControl {
289    Sound,
290    Browser,
291    Window,
292    Select,
293    FocusAgents,
294    /// Body style and/or text language for `/pet style|language`.
295    Appearance {
296        body: Option<CommandPetBodyStyle>,
297        language: Option<CommandPetTextLanguage>,
298    },
299}
300
301/// Portable pet body style for `/pet style`.
302#[derive(Debug, Clone, Copy, PartialEq, Eq)]
303pub enum CommandPetBodyStyle {
304    Smooth,
305    Pixel,
306}
307
308impl CommandPetBodyStyle {
309    /// Canonical `pet_watch` token.
310    #[must_use]
311    pub fn as_str(self) -> &'static str {
312        match self {
313            Self::Smooth => "smooth",
314            Self::Pixel => "pixel",
315        }
316    }
317
318    #[must_use]
319    pub fn parse(value: &str) -> Option<Self> {
320        match value {
321            "smooth" => Some(Self::Smooth),
322            "pixel" => Some(Self::Pixel),
323            _ => None,
324        }
325    }
326}
327
328/// Portable pet text language for `/pet language`.
329#[derive(Debug, Clone, Copy, PartialEq, Eq)]
330pub enum CommandPetTextLanguage {
331    Auto,
332    En,
333    ZhHans,
334    ZhHant,
335    Ja,
336}
337
338impl CommandPetTextLanguage {
339    /// Canonical `pet_watch` token.
340    #[must_use]
341    pub fn as_str(self) -> &'static str {
342        match self {
343            Self::Auto => "auto",
344            Self::En => "en",
345            Self::ZhHans => "zh-hans",
346            Self::ZhHant => "zh-hant",
347            Self::Ja => "ja",
348        }
349    }
350
351    #[must_use]
352    pub fn parse(value: &str) -> Option<Self> {
353        match value {
354            "auto" => Some(Self::Auto),
355            "en" => Some(Self::En),
356            "zh-hans" => Some(Self::ZhHans),
357            "zh-hant" => Some(Self::ZhHant),
358            "ja" => Some(Self::Ja),
359            _ => None,
360        }
361    }
362}
363
364/// Localized pet labels the command composes into its messages.
365#[derive(Debug, Clone, Copy, PartialEq, Eq)]
366pub enum CommandPetLabel {
367    ModeOn,
368    ModeOff,
369    ModeOnLabel,
370    ModeOffLabel,
371    ViewOpen,
372    ViewClosed,
373    HabitatQueued,
374    ExportQueued,
375    ExportUnavailable,
376    SoundOn,
377    /// The habitat control could not be queued.
378    WatchUnavailable,
379}
380
381pub trait CommandPetContext {
382    fn enabled(&self) -> bool;
383    fn is_open(&self) -> bool;
384    fn status(&self) -> String;
385    fn avatar_choices(&self) -> String;
386    fn select_avatar(&mut self, key: &str) -> bool;
387    fn preview_avatar(&mut self, name: &str, view: bool) -> bool;
388    fn set_enabled(&mut self, enabled: bool, persist: bool);
389    fn set_sound(&mut self, enabled: bool);
390    fn sound_label(&self) -> String;
391    fn export(&mut self) -> bool;
392    fn open_habitat(&mut self);
393    /// Queue a habitat control; `false` when it could not be delivered.
394    fn queue(&mut self, control: CommandPetControl) -> bool;
395    fn label(&self, which: CommandPetLabel) -> String;
396}
397
398/// Account sign-in state for `/login`.
399#[derive(Debug, Clone, PartialEq, Eq)]
400pub enum CommandAccountState {
401    SignedOut,
402    Authenticated,
403    OfflineCached,
404    Expired,
405    Revoked,
406    Unavailable(String),
407}
408
409/// `/login` status projection (the command composes the report text).
410#[derive(Debug, Clone, PartialEq, Eq)]
411pub struct CommandLoginStatus {
412    pub account: CommandAccountState,
413    pub api_base: String,
414    pub provider: String,
415}
416
417/// `/logout` result; each entry is `Ok(true)` cleared, `Ok(false)` absent,
418/// `Err` the host error text.
419#[derive(Debug, Clone, PartialEq, Eq)]
420pub struct CommandLogoutOutcome {
421    pub provider: String,
422    pub account: Result<bool, String>,
423    pub legacy_sandbox: Result<bool, String>,
424}
425
426/// Failure to clear the active provider key during `/logout`.
427#[derive(Debug, Clone, PartialEq, Eq)]
428pub struct LogoutFailure {
429    pub provider: String,
430    pub error: String,
431}
432
433/// Account/provider session state for `/login` and `/logout`.
434pub trait CommandLoginContext {
435    fn login_status(&self) -> CommandLoginStatus;
436    fn logout(&mut self) -> Result<CommandLogoutOutcome, LogoutFailure>;
437    /// `/connect [<provider>]` — plugin provider sign-in.
438    fn connect(&mut self, provider: Option<&str>) -> ConfigReply;
439    /// `/disconnect <provider>` — plugin provider sign-out.
440    fn disconnect(&mut self, provider: &str) -> ConfigReply;
441}
442
443/// Workbar placement/panel observation and mutation for `/workbar`.
444pub trait CommandWorkSurfaceContext {
445    fn placement(&self) -> crate::types::CommandWorkSurfacePlacement;
446    fn panel(&self) -> crate::types::CommandRailPanel;
447    fn effective_placement(&self) -> crate::types::CommandWorkSurfacePlacement;
448    fn area_present(&self) -> bool;
449    fn panel_title(&self, panel: crate::types::CommandRailPanel) -> String;
450    /// Apply a placement; when `persist`, also writes the setting. The reply is
451    /// the key-engine result (ignored on success, returned on error).
452    fn set_placement(
453        &mut self,
454        placement: crate::types::CommandWorkSurfacePlacement,
455        persist: bool,
456    ) -> ConfigReply;
457    fn set_panel(&mut self, panel: crate::types::CommandRailPanel, persist: bool) -> ConfigReply;
458    fn mark_redraw(&mut self);
459}
460
461/// A path problem surfaced by `/trust add|remove`.
462#[derive(Debug, Clone, PartialEq, Eq)]
463pub enum TrustPathError {
464    /// The supplied path does not exist.
465    NotFound(PathBuf),
466    /// The allow-list could not be updated; carries the host error text.
467    UpdateFailed(String),
468}
469
470/// Workspace trust and the per-path allow-list for `/trust`.
471pub trait CommandTrustContext {
472    fn trust_mode(&self) -> bool;
473    fn trusted_paths(&self) -> Vec<PathBuf>;
474    /// Add a path (the host expands `~` and validates existence).
475    fn add_trusted_path(&mut self, raw: &str) -> Result<PathBuf, TrustPathError>;
476    /// Returns the resolved path and whether it was removed.
477    fn remove_trusted_path(&mut self, raw: &str) -> Result<(PathBuf, bool), TrustPathError>;
478    /// The localized `Usage:` label used by the `/trust on|off` usage error.
479    fn usage_label(&self) -> String;
480}
481
482// ---------------------------------------------------------------------------
483// Portable payloads for host effects that cross the config boundary (D5).
484//
485// The TUI conversion layer has no access to `App`, so engine-affecting actions
486// cannot be re-derived at conversion time. These mirrors carry the exact data
487// the host needs, and the host converts each direction faithfully.
488// ---------------------------------------------------------------------------
489
490/// Route capability fact, mirroring the config layer's `CapabilityState`.
491#[derive(Debug, Clone, Copy, PartialEq, Eq)]
492pub enum CommandCapabilityState {
493    Supported,
494    Unsupported,
495    Unknown,
496}
497
498/// Compaction configuration carried by `ConfigAction::CompactionChanged`.
499#[derive(Debug, Clone, PartialEq, Eq)]
500pub struct CommandCompactionConfig {
501    pub enabled: bool,
502    pub token_threshold: usize,
503    pub model: String,
504    pub image_input: CommandCapabilityState,
505    pub effective_context_window: Option<u32>,
506    pub cache_summary: bool,
507    pub focus: Option<String>,
508    pub runtime_cost_owner: Option<String>,
509    pub workspace: Option<PathBuf>,
510    pub summary_instructions: Option<String>,
511    pub retained_user_message_tokens: usize,
512}
513
514/// Subagent runtime configuration carried by `ConfigAction::SubagentRuntimeChanged`.
515#[derive(Debug, Clone, Copy, PartialEq, Eq)]
516pub struct CommandSubagentRuntimeConfig {
517    pub enabled: bool,
518    pub max_subagents: usize,
519    pub launch_concurrency: usize,
520    pub max_spawn_depth: u32,
521    pub api_timeout_secs: u64,
522    pub heartbeat_timeout_secs: u64,
523}
524
525/// Search provider carried by `ConfigAction::SearchProviderChanged`.
526#[derive(Debug, Clone, Copy, PartialEq, Eq)]
527pub enum CommandSearchProvider {
528    Bing,
529    DuckDuckGo,
530    Firecrawl,
531    Tavily,
532    Bocha,
533    Metaso,
534    Searxng,
535    Baidu,
536    Volcengine,
537    Sofya,
538    Serply,
539    DeepSeek,
540}
541
542/// Operator-notification delivery method.
543#[derive(Debug, Clone, Copy, PartialEq, Eq)]
544pub enum CommandNotificationMethod {
545    Auto,
546    Osc9,
547    Bel,
548    Kitty,
549    Ghostty,
550    Off,
551}
552
553/// Turn-completion sound choice.
554#[derive(Debug, Clone, Copy, PartialEq, Eq)]
555pub enum CommandCompletionSound {
556    Off,
557    Beep,
558    Bell,
559    Whale,
560    File,
561}
562
563/// When operator notifications are allowed.
564#[derive(Debug, Clone, Copy, PartialEq, Eq)]
565pub enum CommandNotificationCondition {
566    Always,
567    Unfocused,
568    Never,
569}
570
571/// Subagent-completion notification policy.
572#[derive(Debug, Clone, Copy, PartialEq, Eq)]
573pub enum CommandSubagentCompletion {
574    Always,
575    FinalOnly,
576    Off,
577}
578
579/// One notification event kind.
580#[derive(Debug, Clone, Copy, PartialEq, Eq)]
581pub enum CommandNotificationEvent {
582    TurnComplete,
583    SubagentTerminal,
584    ApprovalNeeded,
585    InputNeeded,
586    ElevationNeeded,
587    ModelNotify,
588}
589
590/// One validated notification edit, mirroring `NotificationConfigUpdate`.
591#[derive(Debug, Clone, PartialEq, Eq)]
592pub enum CommandNotificationUpdate {
593    Method(CommandNotificationMethod),
594    ThresholdSecs(u64),
595    IncludeSummary(bool),
596    Quiet(bool),
597    Sound(Option<CommandCompletionSound>),
598    Condition(CommandNotificationCondition),
599    CompletionSound(CommandCompletionSound),
600    SubagentCompletion(CommandSubagentCompletion),
601    SoundFile(PathBuf),
602    Event(CommandNotificationEvent, bool),
603    EventSoundEnabled(bool),
604    EventSoundEvents(Vec<String>),
605    EventSoundMinIntervalMs(u64),
606    EventSoundQuiet(bool),
607}
608
609// ---------------------------------------------------------------------------
610// `/import-claude` plan model (portable). The host builds the plan from the
611// Claude sources and performs the writes/apply; the command renders it.
612// ---------------------------------------------------------------------------
613
614/// Effective `[workflow]`/`[goal]` facts for `/config workflow`.
615#[derive(Debug, Clone, Copy, PartialEq, Eq)]
616pub struct CommandWorkflowSummary {
617    pub automatic: bool,
618    pub auto_start_read_only: bool,
619    pub require_approval_for_writes: bool,
620    pub max_children: u32,
621    pub max_concurrent: u32,
622    pub max_depth: u32,
623    pub default_token_budget: u64,
624    pub goal_max_continuations: u32,
625    pub goal_enforce_token_budget: bool,
626}
627
628/// Outcome of reading one Claude source file.
629#[derive(Debug, Clone, PartialEq, Eq)]
630pub enum CommandSourceStatus {
631    Found,
632    NotFound,
633    Oversize(u64),
634    InvalidJson,
635    Unreadable(String),
636}
637
638impl CommandSourceStatus {
639    /// The one-line provenance entry used by the rendered plan and report.
640    ///
641    /// `display_path` is the host's display projection (for example `~/...`),
642    /// so the portable layer never leaks an absolute home path.
643    #[must_use]
644    pub fn describe(&self, display_path: &str) -> String {
645        match self {
646            Self::Found => format!("found: {display_path}"),
647            Self::NotFound => format!("not found: {display_path}"),
648            Self::Oversize(bytes) => {
649                format!("skipped, too large ({bytes} bytes): {display_path}")
650            }
651            Self::InvalidJson => format!("invalid JSON: {display_path}"),
652            Self::Unreadable(error) => format!("unreadable: {display_path} ({error})"),
653        }
654    }
655}
656
657/// One MCP server discovered in the Claude sources.
658#[derive(Debug, Clone, PartialEq, Eq)]
659pub struct CommandMcpCandidate {
660    pub name: String,
661    pub summary: String,
662    pub hard_blocked: bool,
663}
664
665/// The full `/import-claude` plan. Pure data: building it mutates nothing.
666#[derive(Debug, Clone, Default, PartialEq, Eq)]
667pub struct CommandClaudePlan {
668    pub sources: Vec<(PathBuf, CommandSourceStatus)>,
669    pub mcp_candidates: Vec<CommandMcpCandidate>,
670    pub per_project_mcp: Vec<String>,
671    /// Safe env entries proposed for the portable bundle, key-sorted.
672    pub env_safe: Vec<(String, String)>,
673    pub env_skipped: Vec<String>,
674    pub permissions_default_mode: Option<String>,
675    pub permissions_allow: Vec<String>,
676    pub permissions_ask: Vec<String>,
677    pub permissions_deny: Vec<String>,
678    pub hook_events: Vec<String>,
679    pub has_claude_md: bool,
680    pub claude_projects: Vec<String>,
681}
682
683impl CommandClaudePlan {
684    #[must_use]
685    pub fn is_empty(&self) -> bool {
686        self.mcp_candidates.is_empty()
687            && self.per_project_mcp.is_empty()
688            && self.env_safe.is_empty()
689            && self.env_skipped.is_empty()
690            && self.permissions_default_mode.is_none()
691            && self.permissions_allow.is_empty()
692            && self.permissions_ask.is_empty()
693            && self.permissions_deny.is_empty()
694            && self.hook_events.is_empty()
695            && !self.has_claude_md
696            && self.claude_projects.is_empty()
697    }
698}
699
700/// One typed `/import-claude --apply` follow-up.
701///
702/// The host supplies the facts; the command composes the sentences.
703#[derive(Debug, Clone, PartialEq, Eq)]
704pub enum CommandImportFollowUp {
705    InstructionsCopied { destination: String },
706    InstructionsKeptExisting { destination: String, source: String },
707    InstructionsCopyFailed { source: String, destination: String },
708    HomeUnresolved,
709    McpBlocked { name: String },
710    McpNeedsReview { name: String },
711    HookEvents { count: usize },
712    PermissionRules,
713}
714
715/// Paths and write outcomes from persisting the report/bundle.
716#[derive(Debug, Clone, PartialEq, Eq)]
717pub struct CommandClaudeArtifacts {
718    pub report_path: PathBuf,
719    pub bundle_path: PathBuf,
720    pub wrote_report: bool,
721    pub wrote_bundle: bool,
722}
723
724/// Typed `--apply` outcome; the command composes the final message.
725#[derive(Debug, Clone, Default, PartialEq, Eq)]
726pub struct CommandClaudeApplyOutcome {
727    pub done: Vec<CommandImportFollowUp>,
728    pub manual: Vec<CommandImportFollowUp>,
729    pub report_path: PathBuf,
730    pub wrote_report: bool,
731}