MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / seed_from_intent

Method seed_from_intent

atomic-cli/src/commands/vault/context.rs:333–381  ·  view source on GitHub ↗

Seed query terms and graph-neighbor candidates from an intent.

(
        &self,
        repo: &Repository,
        intent_id: &str,
        seed_terms: &mut Vec<String>,
        candidates: &mut HashMap<String, CandidateScore>,
    )

Source from the content-addressed store, hash-verified

331
332 /// Seed query terms and graph-neighbor candidates from an intent.
333 fn seed_from_intent(
334 &self,
335 repo: &Repository,
336 intent_id: &str,
337 seed_terms: &mut Vec<String>,
338 candidates: &mut HashMap<String, CandidateScore>,
339 ) -> CliResult<()> {
340 let manifest = repo.vault_manifest().map_err(CliError::Repository)?;
341 let (resolved_id, summary) = manifest
342 .intents
343 .iter()
344 .find(|(id, _)| id.eq_ignore_ascii_case(intent_id))
345 .ok_or_else(|| CliError::VaultEntityNotFound {
346 kind: "intent",
347 id: intent_id.to_string(),
348 hint: None,
349 })?;
350
351 seed_terms.push(summary.title.clone());
352
353 // Legacy manifest entries may not have `vault_path`. Reuse the same
354 // path resolution fallback as the rest of the Intent API rather than
355 // querying an empty path and the meaningless `intent:` KG node.
356 let intent_path = repo
357 .vault_intent_path(resolved_id)
358 .map_err(CliError::Repository)?
359 .ok_or_else(|| CliError::VaultEntityNotFound {
360 kind: "intent",
361 id: intent_id.to_string(),
362 hint: None,
363 })?;
364
365 if let Some(entry) = repo
366 .vault_retrieve(&intent_path)
367 .map_err(CliError::Repository)?
368 {
369 seed_terms.extend(frontmatter_labels(&entry.frontmatter_json));
370 let body = String::from_utf8_lossy(&entry.content_bytes);
371 let body = truncate_chars(body.trim(), INTENT_BODY_SEED_CHARS);
372 if !body.is_empty() {
373 seed_terms.push(body);
374 }
375 }
376
377 let node_id = intent_path_to_node_id(&intent_path);
378 // Intent -> referenced file/domain -> memory is commonly two hops.
379 add_memory_neighbors(repo, &node_id, 2, candidates)?;
380 Ok(())
381 }
382
383 fn has_explicit_seeds(&self) -> bool {
384 self.query.iter().any(|q| !q.trim().is_empty())

Callers 1

gather_candidatesMethod · 0.80

Calls 12

frontmatter_labelsFunction · 0.85
truncate_charsFunction · 0.85
intent_path_to_node_idFunction · 0.85
add_memory_neighborsFunction · 0.85
vault_manifestMethod · 0.80
vault_intent_pathMethod · 0.80
vault_retrieveMethod · 0.80
extendMethod · 0.80
iterMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected