1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! Assembly strategy trait for language-specific context bundling.
//!
//! This module defines the core abstraction for context assembly strategies.
//! Different programming languages have different patterns for code organization,
//! testing, and dependencies, so we use the strategy pattern to customize
//! context selection based on the language being worked with.
use Result;
use async_trait;
use ;
/// Strategy for assembling context bundles with language-specific intelligence.
///
/// Each strategy implementation decides:
/// - How to allocate the token budget across context pieces
/// - What related code to include (tests, dependencies, configs)
/// - How to detect and include language-specific patterns
/// - How to prioritize context pieces when budget is limited
///
/// # Examples
///
/// ```ignore
/// use maproom::context::strategy::AssemblyStrategy;
/// use maproom::context::types::{ContextBundle, ExpandOptions};
/// use maproom::db::create_pool;
///
/// #[tokio::main]
/// async fn main() -> anyhow::Result<()> {
/// let pool = create_pool().await?;
///
/// // Use the default strategy
/// let strategy = maproom::context::strategies::DefaultAssemblyStrategy::new(pool);
///
/// let bundle = strategy.assemble(
/// 12345, // chunk_id
/// 6000, // budget_tokens
/// ExpandOptions::with_common()
/// ).await?;
///
/// println!("Assembled {} items, {} tokens", bundle.items.len(), bundle.total_tokens);
/// Ok(())
/// }
/// ```