kodegen_bundler_autoconfig/
lib.rs1pub mod clients;
2pub mod config;
3pub mod install;
4pub mod watcher;
5
6use std::path::{Path, PathBuf};
8
9use anyhow::Result;
10pub use config::ConfigMerger;
11pub use install::{InstallResult, install_all_clients};
12use serde::{Deserialize, Serialize};
13
14pub trait ClientConfigPlugin: Send + Sync {
16 fn client_id(&self) -> &str;
18
19 fn client_name(&self) -> &str;
21
22 fn watch_paths(&self) -> Vec<PathBuf>;
24
25 fn config_paths(&self) -> Vec<ConfigPath>;
27
28 fn is_installed(&self, path: &Path) -> bool;
30
31 fn inject_kodegen(&self, config_content: &str, format: ConfigFormat) -> Result<String>;
37
38 fn config_format(&self) -> ConfigFormat;
40}
41
42#[derive(Debug, Clone)]
43pub struct ConfigPath {
44 pub path: PathBuf,
45 pub format: ConfigFormat,
46 pub platform: Platform,
47}
48
49#[derive(Debug, Clone, Copy, PartialEq, Eq)]
50pub enum ConfigFormat {
51 Json,
52 Toml,
53 Yaml,
54 Plist,
55}
56
57#[derive(Debug, Clone, Copy, PartialEq, Eq)]
58pub enum Platform {
59 Windows,
60 MacOS,
61 Linux,
62 All,
63}
64
65impl Platform {
66 #[must_use]
67 pub const fn current() -> Self {
68 #[cfg(target_os = "windows")]
69 return Self::Windows;
70
71 #[cfg(target_os = "macos")]
72 return Self::MacOS;
73
74 #[cfg(target_os = "linux")]
75 return Self::Linux;
76
77 #[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))]
78 return Self::All;
79 }
80}
81
82#[derive(Debug, Serialize, Deserialize, Clone)]
84pub struct KodegenConfig {
85 pub command: String,
86 pub args: Vec<String>,
87 #[serde(skip_serializing_if = "Option::is_none")]
88 pub env: Option<serde_json::Value>,
89}
90
91impl Default for KodegenConfig {
92 fn default() -> Self {
93 Self {
94 command: "kodegen".to_string(),
95 args: vec!["--stdio".to_string()],
96 env: None,
97 }
98 }
99}
100
101#[derive(Debug, Serialize, Deserialize, Clone)]
103pub struct KodegenHttpConfig {
104 #[serde(rename = "type")]
105 pub transport_type: String,
106 pub url: String,
107}
108
109impl Default for KodegenHttpConfig {
110 fn default() -> Self {
111 Self {
112 transport_type: "streamable-http".to_string(),
113 url: "https://kodegen.kodegen.dev:8443".to_string(),
114 }
115 }
116}