MCPcopy Create free account
hub / github.com/AI45Lab/Code / push_agents_md_context

Function push_agents_md_context

core/src/agent_api/capabilities.rs:287–331  ·  view source on GitHub ↗
(providers: &mut Vec<Arc<dyn ContextProvider>>, workspace: &Path)

Source from the content-addressed store, hash-verified

285}
286
287fn 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
333fn push_skill_catalog_context(
334 providers: &mut Vec<Arc<dyn ContextProvider>>,

Callers 1

build_context_providersFunction · 0.85

Calls 10

with_token_countMethod · 0.80
with_relevanceMethod · 0.80
with_freshnessMethod · 0.80
with_trustMethod · 0.80
with_provenanceMethod · 0.80
with_sourceMethod · 0.80
with_itemMethod · 0.80
existsMethod · 0.45
is_emptyMethod · 0.45
with_priorityMethod · 0.45

Tested by

no test coverage detected