Skip to main content

lean_ctx/core/providers/
mod.rs

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