1use serde::{Deserialize, Serialize};
10use std::collections::BTreeMap;
11use std::path::PathBuf;
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
15#[serde(rename_all = "snake_case")]
16pub enum ResourceKind {
17 Extension,
19 Skill,
21 Prompt,
23 Theme,
25}
26
27impl std::fmt::Display for ResourceKind {
28 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29 match self {
30 ResourceKind::Extension => write!(f, "extension"),
31 ResourceKind::Skill => write!(f, "skill"),
32 ResourceKind::Prompt => write!(f, "prompt"),
33 ResourceKind::Theme => write!(f, "theme"),
34 }
35 }
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
42pub struct PackageManifest {
43 pub name: String,
45 pub version: String,
47 #[serde(default)]
49 pub extensions: Vec<String>,
50 #[serde(default)]
52 pub skills: Vec<String>,
53 #[serde(default)]
55 pub prompts: Vec<String>,
56 #[serde(default)]
58 pub themes: Vec<String>,
59 #[serde(default)]
61 pub description: Option<String>,
62 #[serde(default)]
64 pub dependencies: BTreeMap<String, String>,
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69pub struct DiscoveredResource {
70 pub kind: ResourceKind,
72 pub path: PathBuf,
74 pub relative_path: String,
76}
77
78#[derive(Debug, Clone, Serialize, Deserialize)]
80pub struct PathMetadata {
81 pub source: String,
83 pub scope: SourceScope,
85 pub origin: ResourceOrigin,
87 pub base_dir: Option<PathBuf>,
89}
90
91#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
93#[serde(rename_all = "snake_case")]
94pub enum ResourceOrigin {
95 Package,
97 TopLevel,
99}
100
101#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
103#[serde(rename_all = "snake_case")]
104pub enum SourceScope {
105 User,
107 Project,
109}
110
111impl std::fmt::Display for SourceScope {
112 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
113 match self {
114 SourceScope::User => write!(f, "user"),
115 SourceScope::Project => write!(f, "project"),
116 }
117 }
118}
119
120#[derive(Debug, Clone, Serialize, Deserialize)]
122pub struct ResolvedResource {
123 pub path: PathBuf,
125 pub enabled: bool,
127 pub metadata: PathMetadata,
129}
130
131#[derive(Debug, Clone, Default, Serialize, Deserialize)]
133pub struct ResolvedPaths {
134 pub extensions: Vec<ResolvedResource>,
136 pub skills: Vec<ResolvedResource>,
138 pub prompts: Vec<ResolvedResource>,
140 pub themes: Vec<ResolvedResource>,
142}
143
144#[derive(Debug, Clone, Serialize, Deserialize)]
146pub struct ProgressEvent {
147 pub event_type: ProgressEventType,
149 pub action: ProgressAction,
151 pub source: String,
153 pub message: Option<String>,
155}
156
157#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
159#[serde(rename_all = "snake_case")]
160pub enum ProgressEventType {
161 Start,
163 Progress,
165 Complete,
167 Error,
169}
170
171#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
173#[serde(rename_all = "snake_case")]
174pub enum ProgressAction {
175 Install,
177 Remove,
179 Update,
181 Clone,
183 Pull,
185}
186
187impl std::fmt::Display for ProgressAction {
188 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
189 match self {
190 ProgressAction::Install => write!(f, "install"),
191 ProgressAction::Remove => write!(f, "remove"),
192 ProgressAction::Update => write!(f, "update"),
193 ProgressAction::Clone => write!(f, "clone"),
194 ProgressAction::Pull => write!(f, "pull"),
195 }
196 }
197}
198
199pub type ProgressCallback = Box<dyn Fn(ProgressEvent) + Send + Sync>;
201
202#[derive(Debug, Clone, Serialize, Deserialize)]
204pub struct PackageUpdateInfo {
205 pub source: String,
207 pub display_name: String,
209 pub source_type: String, pub scope: SourceScope,
213}
214
215#[derive(Debug, Clone, Serialize, Deserialize)]
217pub struct ConfiguredPackage {
218 pub source: String,
220 pub scope: SourceScope,
222 pub filtered: bool,
224 pub installed_path: Option<PathBuf>,
226}