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