1pub mod selector;
8pub mod context;
9pub mod relevance;
10pub mod bundler;
11pub mod optimizer;
12pub mod quota;
13pub mod demotion;
14pub mod two_pass;
15pub mod bandit_router;
16pub mod ast_parser;
17
18pub use selector::{CodeSelector, SelectionCriteria, SelectionResult};
20pub use context::{ContextExtractor, ContextOptions, CodeContext};
21pub use relevance::{RelevanceScorer, RelevanceMetrics};
22pub use bundler::{CodeBundler, BundleOptions, CodeBundle};
23pub use quota::{QuotaManager, FileCategory, CategoryQuota, QuotaAllocation, QuotaScanResult, create_quota_manager};
24pub use demotion::{DemotionEngine, FidelityMode, DemotionResult, ChunkInfo, CodeChunker, SignatureExtractor};
25pub use two_pass::{TwoPassSelector, TwoPassConfig, TwoPassResult, CoverageGap, SelectionMetrics, SelectionRule, SelectionContext, FileInfo};
26pub use bandit_router::{BanditRouter, BanditConfig, SelectionStrategy, RoutingDecision, PerformanceFeedback, BanditStatistics, BanditState};
27pub use ast_parser::{AstParser, AstLanguage, AstChunk, AstSignature};
28
29use scribe_core::Result;
30
31pub struct SelectionEngine {
33 selector: CodeSelector,
34 context_extractor: ContextExtractor,
35 relevance_scorer: RelevanceScorer,
36 bundler: CodeBundler,
37}
38
39impl SelectionEngine {
40 pub fn new() -> Result<Self> {
42 Ok(Self {
43 selector: CodeSelector::new(),
44 context_extractor: ContextExtractor::new(),
45 relevance_scorer: RelevanceScorer::new()?,
46 bundler: CodeBundler::new(),
47 })
48 }
49
50 pub async fn select_code(
52 &self,
53 criteria: &SelectionCriteria
54 ) -> Result<SelectionResult> {
55 todo!("Implement selection logic")
57 }
58
59 pub async fn extract_context(
61 &self,
62 selection: &SelectionResult,
63 options: &ContextOptions
64 ) -> Result<CodeContext> {
65 self.context_extractor.extract(selection, options).await
66 }
67
68 pub async fn create_bundle(
70 &self,
71 context: &CodeContext,
72 options: &BundleOptions
73 ) -> Result<CodeBundle> {
74 self.bundler.bundle(context, options).await
75 }
76}
77
78impl Default for SelectionEngine {
79 fn default() -> Self {
80 Self::new().expect("Failed to create SelectionEngine")
81 }
82}
83
84#[cfg(test)]
85mod tests {
86 use super::*;
87
88 #[tokio::test]
89 async fn test_selection_engine_creation() {
90 let engine = SelectionEngine::new();
91 assert!(engine.is_ok());
92 }
93}