use serde::{Deserialize, Serialize};
use crate::model::MatchLine;
use super::{ExactShardSummary, IndexStateRecord, RepoRecord};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InitOutput {
pub ok: bool,
pub asr_home: String,
pub db_path: String,
pub created: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RepoAddOutput {
pub repo: RepoRecord,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RepoListOutput {
pub repos: Vec<RepoRecord>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RepoStatusOutput {
pub repo: String,
pub source_type: String,
pub local_path: String,
pub git_root: String,
pub branch: Option<String>,
pub head_commit: Option<String>,
pub dirty: bool,
pub untracked: bool,
pub modified: bool,
pub worktree_fingerprint: String,
pub status: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub index_state: Option<IndexStateRecord>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RepoIndexOutput {
pub repo: String,
pub git_root: String,
pub head_commit: Option<String>,
pub dirty: bool,
pub untracked: bool,
pub modified: bool,
pub worktree_fingerprint: String,
pub status: String,
pub indexed_files: usize,
pub total_chunks: usize,
pub languages: std::collections::BTreeMap<String, usize>,
pub content_hash: String,
pub indexed_at: String,
pub exact_shard: ExactShardSummary,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RepoIndexAllOutput {
pub ok: bool,
pub indexed: Vec<RepoIndexOutput>,
pub failures: Vec<RepoIndexFailure>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchOutput {
pub query: String,
pub repo: String,
pub top_k: usize,
pub index_state: SearchIndexState,
pub results: Vec<AsrSearchResult>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchIndexState {
pub status: String,
pub head_commit: Option<String>,
pub dirty: bool,
pub modified: bool,
pub untracked: bool,
pub worktree_fingerprint: String,
pub content_hash: Option<String>,
pub indexed_at: String,
pub stale: bool,
pub exact_shard: ExactShardSummary,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SourcePolicy {
pub mode: String,
pub snapshot_bound: bool,
pub live: bool,
pub stale: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub head_commit: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub worktree_fingerprint: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub index_state: Option<SearchIndexState>,
pub note: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AsrSearchResult {
pub path: String,
pub start_line: usize,
pub end_line: usize,
#[serde(skip_serializing_if = "Option::is_none")]
pub language: Option<String>,
pub score: f64,
pub reasons: Vec<String>,
#[serde(skip_serializing_if = "Vec::is_empty")]
pub match_lines: Vec<MatchLine>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContextOutput {
pub query: String,
pub repo: String,
pub budget: usize,
pub estimated_tokens: usize,
pub analysis_level: String,
pub selected: Vec<ContextSelection>,
pub related: Vec<ContextRelated>,
pub next_commands: Vec<String>,
pub index_state: SearchIndexState,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContextSelection {
pub path: String,
pub start_line: usize,
pub end_line: usize,
#[serde(skip_serializing_if = "Option::is_none")]
pub language: Option<String>,
pub estimated_tokens: usize,
pub score: f64,
pub reasons: Vec<String>,
#[serde(skip_serializing_if = "Vec::is_empty")]
pub match_lines: Vec<MatchLine>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContextRelated {
pub path: String,
pub reason: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReadOutput {
pub repo: String,
pub path: String,
pub source_policy: SourcePolicy,
pub start_line: usize,
pub end_line: usize,
pub requested_start_line: usize,
pub requested_end_line: usize,
pub total_lines: usize,
pub source_hash: String,
pub lines: Vec<ReadLine>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReadLine {
pub line: usize,
pub content: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DiffOutput {
pub repo: String,
pub base: String,
pub head: String,
pub source_policy: SourcePolicy,
pub hunk_count: usize,
pub changed_files: Vec<String>,
pub hunks: Vec<DiffHunkOutput>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DiffHunkOutput {
pub path: String,
pub old_start: usize,
pub old_lines: usize,
pub old_end: usize,
pub new_start: usize,
pub new_lines: usize,
pub new_end: usize,
pub added_lines: usize,
pub removed_lines: usize,
pub context_lines: usize,
pub summary: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub section: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DepsOutput {
pub repo: String,
pub path: String,
pub source_policy: SourcePolicy,
pub analysis_level: String,
pub symbols: Vec<GraphSymbolOutput>,
pub raw_imports: Vec<String>,
pub depends_on: Vec<String>,
pub dependents: Vec<String>,
pub graph_files: usize,
pub graph_edges: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ImpactOutput {
pub repo: String,
pub path: String,
pub source_policy: SourcePolicy,
pub analysis_level: String,
pub affected_count: usize,
pub affected: Vec<String>,
pub direct_dependents: Vec<String>,
pub graph_files: usize,
pub graph_edges: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GraphSymbolOutput {
pub name: String,
pub kind: String,
pub line: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VerifyOutput {
pub repo: String,
pub ok: bool,
pub index_state: SearchIndexState,
pub checks: Vec<VerifyCheck>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VerifyCheck {
pub name: String,
pub status: String,
pub message: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RepoIndexFailure {
pub repo: String,
pub code: String,
pub message: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub path: Option<String>,
}