lean_ctx/core/providers/
mod.rs1pub mod cache;
2pub mod config;
3pub mod gitlab;
4pub mod provider_trait;
5
6pub use provider_trait::{ContextPacket, ContextProvider, ProviderParams};
7
8use serde::{Deserialize, Serialize};
9
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct ProviderResult {
12 pub provider: String,
13 pub resource_type: String,
14 pub items: Vec<ProviderItem>,
15 pub total_count: Option<usize>,
16 pub truncated: bool,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize)]
20pub struct ProviderItem {
21 pub id: String,
22 pub title: String,
23 pub state: Option<String>,
24 pub author: Option<String>,
25 pub created_at: Option<String>,
26 pub updated_at: Option<String>,
27 pub url: Option<String>,
28 pub labels: Vec<String>,
29 pub body: Option<String>,
30}
31
32impl ProviderResult {
33 pub fn format_compact(&self) -> String {
34 let mut out = format!(
35 "{} {} ({}{}):\n",
36 self.provider,
37 self.resource_type,
38 self.items.len(),
39 if self.truncated { "+" } else { "" }
40 );
41 for item in &self.items {
42 let state = item.state.as_deref().unwrap_or("");
43 let labels = if item.labels.is_empty() {
44 String::new()
45 } else {
46 format!(" [{}]", item.labels.join(","))
47 };
48 out.push_str(&format!(
49 " #{} {} ({}){}\n",
50 item.id, item.title, state, labels
51 ));
52 }
53 out
54 }
55}