| 304 | |
| 305 | #[cfg(feature = "ahp")] |
| 306 | pub(super) fn injected_context_to_results( |
| 307 | injected: crate::ahp::InjectedContext, |
| 308 | ) -> Vec<crate::context::ContextResult> { |
| 309 | use crate::context::{ContextItem, ContextType}; |
| 310 | |
| 311 | let mut results = Vec::new(); |
| 312 | |
| 313 | let fact_items = injected |
| 314 | .facts |
| 315 | .into_iter() |
| 316 | .map(|fact| { |
| 317 | let token_count = estimate_tokens(&fact.content); |
| 318 | ContextItem::new( |
| 319 | uuid::Uuid::new_v4().to_string(), |
| 320 | ContextType::Resource, |
| 321 | fact.content, |
| 322 | ) |
| 323 | .with_source(fact.source) |
| 324 | .with_provenance("ahp_fact") |
| 325 | .with_priority(0.75) |
| 326 | .with_trust(fact.confidence) |
| 327 | .with_freshness(0.85) |
| 328 | .with_relevance(fact.confidence) |
| 329 | .with_token_count(token_count) |
| 330 | }) |
| 331 | .collect::<Vec<_>>(); |
| 332 | if let Some(result) = ahp_context_result(fact_items) { |
| 333 | results.push(result); |
| 334 | } |
| 335 | |
| 336 | if let Some(file_contents) = injected.file_contents { |
| 337 | let file_items = file_contents |
| 338 | .into_iter() |
| 339 | .map(|file| { |
| 340 | let token_count = estimate_tokens(&file.snippet); |
| 341 | ContextItem::new( |
| 342 | uuid::Uuid::new_v4().to_string(), |
| 343 | ContextType::Resource, |
| 344 | file.snippet, |
| 345 | ) |
| 346 | .with_source(file.path) |
| 347 | .with_provenance("ahp_file_snippet") |
| 348 | .with_priority(0.8) |
| 349 | .with_trust(0.8) |
| 350 | .with_freshness(0.8) |
| 351 | .with_relevance(file.relevance_score) |
| 352 | .with_token_count(token_count) |
| 353 | }) |
| 354 | .collect::<Vec<_>>(); |
| 355 | if let Some(result) = ahp_context_result(file_items) { |
| 356 | results.push(result); |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | if let Some(summary) = injected.project_summary { |
| 361 | let mut lines = vec![ |
| 362 | format!("Project: {}", summary.project_name), |
| 363 | summary.structure_description, |