(providers: &mut Vec<Arc<dyn ContextProvider>>, workspace: &Path)
| 285 | } |
| 286 | |
| 287 | fn push_agents_md_context(providers: &mut Vec<Arc<dyn ContextProvider>>, workspace: &Path) { |
| 288 | let agents_md_path = workspace.join("AGENTS.md"); |
| 289 | if !agents_md_path.exists() || !agents_md_path.is_file() { |
| 290 | return; |
| 291 | } |
| 292 | |
| 293 | match std::fs::read_to_string(&agents_md_path) { |
| 294 | Ok(content) if !content.trim().is_empty() => { |
| 295 | tracing::info!( |
| 296 | path = %agents_md_path.display(), |
| 297 | "Auto-loaded AGENTS.md from workspace root" |
| 298 | ); |
| 299 | let token_count = content.split_whitespace().count().max(1); |
| 300 | let item = ContextItem::new( |
| 301 | "agents_md", |
| 302 | ContextType::Resource, |
| 303 | format!("# Project Instructions (AGENTS.md)\n\n{}", content), |
| 304 | ) |
| 305 | .with_source(format!("file://{}", agents_md_path.display())) |
| 306 | .with_provenance("workspace_instructions") |
| 307 | .with_priority(0.95) |
| 308 | .with_trust(0.95) |
| 309 | .with_freshness(1.0) |
| 310 | .with_relevance(0.95) |
| 311 | .with_token_count(token_count); |
| 312 | |
| 313 | providers.push(Arc::new( |
| 314 | StaticContextProvider::new("agents_md").with_item(item), |
| 315 | )); |
| 316 | } |
| 317 | Ok(_) => { |
| 318 | tracing::debug!( |
| 319 | path = %agents_md_path.display(), |
| 320 | "AGENTS.md exists but is empty - skipping" |
| 321 | ); |
| 322 | } |
| 323 | Err(e) => { |
| 324 | tracing::warn!( |
| 325 | path = %agents_md_path.display(), |
| 326 | error = %e, |
| 327 | "Failed to read AGENTS.md - skipping" |
| 328 | ); |
| 329 | } |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | fn push_skill_catalog_context( |
| 334 | providers: &mut Vec<Arc<dyn ContextProvider>>, |
no test coverage detected