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 pub project_dir: Option<PathBuf>,
55}
56
57impl Default for SetupOptions {
58 fn default() -> Self {
59 Self {
60 scope: SetupScope::User,
61 dry_run: false,
62 force: false,
63 config_path: None,
64 project_dir: None,
65 }
66 }
67}
68
69#[derive(Debug, Serialize, Deserialize)]
71pub struct SetupResult {
72 pub success: bool,
74 pub message: String,
76 pub files_modified: Vec<PathBuf>,
78 pub connectivity_test: Option<ConnectivityResult>,
80}
81
82#[derive(Debug, Serialize, Deserialize)]
84pub struct ConnectivityResult {
85 pub passed: bool,
87 pub details: String,
89}
90
91#[derive(Debug, Serialize, Deserialize)]
93pub struct DiagnosisReport {
94 pub overall_status: bool,
96 pub checks: Vec<DiagnosisCheck>,
98 pub suggested_fixes: Vec<String>,
100}
101
102#[derive(Debug, Serialize, Deserialize)]
104pub struct DiagnosisCheck {
105 pub name: String,
107 pub passed: bool,
109 pub details: String,
111}
112
113pub trait SetupModule {
115 fn name(&self) -> &str;
117
118 fn setup(&self, opts: &SetupOptions) -> Result<SetupResult>;
120
121 fn diagnose(&self) -> Result<DiagnosisReport>;
123
124 fn test_connectivity(&self) -> Result<ConnectivityResult>;
126}