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>,
)
| 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::InvalidArgument { |
| 346 | message: format!("Intent not found: {}", intent_id), |
| 347 | })?; |
| 348 | |
| 349 | seed_terms.push(summary.title.clone()); |
| 350 | |
| 351 | // Legacy manifest entries may not have `vault_path`. Reuse the same |
| 352 | // path resolution fallback as the rest of the Intent API rather than |
| 353 | // querying an empty path and the meaningless `intent:` KG node. |
| 354 | let intent_path = repo |
| 355 | .vault_intent_path(resolved_id) |
| 356 | .map_err(CliError::Repository)? |
| 357 | .ok_or_else(|| CliError::InvalidArgument { |
| 358 | message: format!("Intent not found: {}", intent_id), |
| 359 | })?; |
| 360 | |
| 361 | if let Some(entry) = repo |
| 362 | .vault_retrieve(&intent_path) |
| 363 | .map_err(CliError::Repository)? |
| 364 | { |
| 365 | seed_terms.extend(frontmatter_labels(&entry.frontmatter_json)); |
| 366 | let body = String::from_utf8_lossy(&entry.content_bytes); |
| 367 | let body = truncate_chars(body.trim(), INTENT_BODY_SEED_CHARS); |
| 368 | if !body.is_empty() { |
| 369 | seed_terms.push(body); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | let node_id = intent_path_to_node_id(&intent_path); |
| 374 | // Intent -> referenced file/domain -> memory is commonly two hops. |
| 375 | add_memory_neighbors(repo, &node_id, 2, candidates)?; |
| 376 | Ok(()) |
| 377 | } |
| 378 | |
| 379 | fn has_explicit_seeds(&self) -> bool { |
| 380 | self.query.iter().any(|q| !q.trim().is_empty()) |
no test coverage detected