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 force: bool,
49 pub config_path: Option<PathBuf>,
51}
52
53impl Default for SetupOptions {
54 fn default() -> Self {
55 Self {
56 scope: SetupScope::User,
57 force: false,
58 config_path: None,
59 }
60 }
61}
62
63#[derive(Debug, Serialize, Deserialize)]
65pub struct SetupResult {
66 pub success: bool,
68 pub message: String,
70 pub files_modified: Vec<PathBuf>,
72 pub connectivity_test: Option<ConnectivityResult>,
74}
75
76#[derive(Debug, Serialize, Deserialize)]
78pub struct ConnectivityResult {
79 pub passed: bool,
81 pub details: String,
83}
84
85pub trait SetupModule {
87 fn name(&self) -> &str;
89
90 fn setup(&self, opts: &SetupOptions) -> Result<SetupResult>;
92
93 fn test_connectivity(&self) -> Result<ConnectivityResult>;
95}