1use serde::{Deserialize, Serialize};
10use std::collections::BTreeMap;
11use std::path::PathBuf;
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
15#[serde(rename_all = "snake_case")]
16pub enum ResourceKind {
17 Extension,
19 Skill,
21 Prompt,
23 Theme,
25}
26impl ResourceKind {
27 pub const ALL: [ResourceKind; 4] = [
29 ResourceKind::Extension,
30 ResourceKind::Skill,
31 ResourceKind::Prompt,
32 ResourceKind::Theme,
33 ];
34}
35
36impl std::fmt::Display for ResourceKind {
37 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
38 match self {
39 ResourceKind::Extension => write!(f, "extension"),
40 ResourceKind::Skill => write!(f, "skill"),
41 ResourceKind::Prompt => write!(f, "prompt"),
42 ResourceKind::Theme => write!(f, "theme"),
43 }
44 }
45}
46
47#[derive(Debug, Clone, Serialize, Deserialize)]
51pub struct PackageManifest {
52 pub name: String,
54 pub version: String,
56 #[serde(default)]
58 pub extensions: Vec<String>,
59 #[serde(default)]
61 pub skills: Vec<String>,
62 #[serde(default)]
64 pub prompts: Vec<String>,
65 #[serde(default)]
67 pub themes: Vec<String>,
68 #[serde(default)]
70 pub description: Option<String>,
71 #[serde(default)]
73 pub dependencies: BTreeMap<String, String>,
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
78pub struct DiscoveredResource {
79 pub kind: ResourceKind,
81 pub path: PathBuf,
83 pub relative_path: String,
85}
86
87#[derive(Debug, Clone, Serialize, Deserialize)]
89pub struct PathMetadata {
90 pub source: String,
92 pub scope: SourceScope,
94 pub origin: ResourceOrigin,
96 pub base_dir: Option<PathBuf>,
98}
99
100#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
102#[serde(rename_all = "snake_case")]
103pub enum ResourceOrigin {
104 Package,
106 TopLevel,
108}
109
110#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
112#[serde(rename_all = "snake_case")]
113pub enum SourceScope {
114 User,
116 Project,
118}
119
120impl std::fmt::Display for SourceScope {
121 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
122 match self {
123 SourceScope::User => write!(f, "user"),
124 SourceScope::Project => write!(f, "project"),
125 }
126 }
127}
128
129#[derive(Debug, Clone, Serialize, Deserialize)]
131pub struct ResolvedResource {
132 pub path: PathBuf,
134 pub enabled: bool,
136 pub metadata: PathMetadata,
138}
139
140#[derive(Debug, Clone, Default, Serialize, Deserialize)]
142pub struct ResolvedPaths {
143 pub extensions: Vec<ResolvedResource>,
145 pub skills: Vec<ResolvedResource>,
147 pub prompts: Vec<ResolvedResource>,
149 pub themes: Vec<ResolvedResource>,
151}
152
153#[derive(Debug, Clone, Serialize, Deserialize)]
155pub struct ProgressEvent {
156 pub event_type: ProgressEventType,
158 pub action: ProgressAction,
160 pub source: String,
162 pub message: Option<String>,
164}
165
166#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
168#[serde(rename_all = "snake_case")]
169pub enum ProgressEventType {
170 Start,
172 Progress,
174 Complete,
176 Error,
178}
179
180#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
182#[serde(rename_all = "snake_case")]
183pub enum ProgressAction {
184 Install,
186 Remove,
188 Update,
190 Clone,
192 Pull,
194}
195
196impl std::fmt::Display for ProgressAction {
197 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
198 match self {
199 ProgressAction::Install => write!(f, "install"),
200 ProgressAction::Remove => write!(f, "remove"),
201 ProgressAction::Update => write!(f, "update"),
202 ProgressAction::Clone => write!(f, "clone"),
203 ProgressAction::Pull => write!(f, "pull"),
204 }
205 }
206}
207
208pub type ProgressCallback = Box<dyn Fn(ProgressEvent) + Send + Sync>;
210
211#[derive(Debug, Clone, Serialize, Deserialize)]
213pub struct PackageUpdateInfo {
214 pub source: String,
216 pub display_name: String,
218 pub source_type: String, pub scope: SourceScope,
222}
223
224#[derive(Debug, Clone, Serialize, Deserialize)]
226pub struct ConfiguredPackage {
227 pub source: String,
229 pub scope: SourceScope,
231 pub filtered: bool,
233 pub installed_path: Option<PathBuf>,
235}