intent_engine/setup/
mod.rs1use crate::error::{IntentError, Result};
7use serde::{Deserialize, Serialize};
8use std::path::PathBuf;
9use std::str::FromStr;
10
11pub mod claude_code;
12pub mod common;
13pub mod interactive;
14
15#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub enum SetupScope {
18 User,
20 Project,
22 Both,
24}
25
26impl FromStr for SetupScope {
27 type Err = IntentError;
28
29 fn from_str(s: &str) -> Result<Self> {
30 match s.to_lowercase().as_str() {
31 "user" => Ok(SetupScope::User),
32 "project" => Ok(SetupScope::Project),
33 "both" => Ok(SetupScope::Both),
34 _ => Err(IntentError::InvalidInput(format!(
35 "Invalid scope: {}. Must be 'user', 'project', or 'both'",
36 s
37 ))),
38 }
39 }
40}
41
42#[derive(Debug, Clone)]
44pub struct SetupOptions {
45 pub scope: SetupScope,
47 pub dry_run: bool,
49 pub force: bool,
51 pub config_path: Option<PathBuf>,
53}
54
55impl Default for SetupOptions {
56 fn default() -> Self {
57 Self {
58 scope: SetupScope::User,
59 dry_run: false,
60 force: false,
61 config_path: None,
62 }
63 }
64}
65
66#[derive(Debug, Serialize, Deserialize)]
68pub struct SetupResult {
69 pub success: bool,
71 pub message: String,
73 pub files_modified: Vec<PathBuf>,
75 pub connectivity_test: Option<ConnectivityResult>,
77}
78
79#[derive(Debug, Serialize, Deserialize)]
81pub struct ConnectivityResult {
82 pub passed: bool,
84 pub details: String,
86}
87
88#[derive(Debug, Serialize, Deserialize)]
90pub struct DiagnosisReport {
91 pub overall_status: bool,
93 pub checks: Vec<DiagnosisCheck>,
95 pub suggested_fixes: Vec<String>,
97}
98
99#[derive(Debug, Serialize, Deserialize)]
101pub struct DiagnosisCheck {
102 pub name: String,
104 pub passed: bool,
106 pub details: String,
108}
109
110pub trait SetupModule {
112 fn name(&self) -> &str;
114
115 fn setup(&self, opts: &SetupOptions) -> Result<SetupResult>;
117
118 fn diagnose(&self) -> Result<DiagnosisReport>;
120
121 fn test_connectivity(&self) -> Result<ConnectivityResult>;
123}