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>,
)
| 297 | |
| 298 | /// Seed query terms and graph-neighbor candidates from an intent. |
| 299 | fn seed_from_intent( |
| 300 | &self, |
| 301 | repo: &Repository, |
| 302 | intent_id: &str, |
| 303 | seed_terms: &mut Vec<String>, |
| 304 | candidates: &mut HashMap<String, CandidateScore>, |
| 305 | ) -> CliResult<()> { |
| 306 | let manifest = repo.vault_manifest().map_err(CliError::Repository)?; |
| 307 | let (resolved_id, summary) = manifest |
| 308 | .intents |
| 309 | .iter() |
| 310 | .find(|(id, _)| id.eq_ignore_ascii_case(intent_id)) |
| 311 | .ok_or_else(|| CliError::InvalidArgument { |
| 312 | message: format!("Intent not found: {}", intent_id), |
| 313 | })?; |
| 314 | |
| 315 | seed_terms.push(summary.title.clone()); |
| 316 | |
| 317 | // Legacy manifest entries may not have `vault_path`. Reuse the same |
| 318 | // path resolution fallback as the rest of the Intent API rather than |
| 319 | // querying an empty path and the meaningless `intent:` KG node. |
| 320 | let intent_path = repo |
| 321 | .vault_intent_path(resolved_id) |
| 322 | .map_err(CliError::Repository)? |
| 323 | .ok_or_else(|| CliError::InvalidArgument { |
| 324 | message: format!("Intent not found: {}", intent_id), |
| 325 | })?; |
| 326 | |
| 327 | if let Some(entry) = repo |
| 328 | .vault_retrieve(&intent_path) |
| 329 | .map_err(CliError::Repository)? |
| 330 | { |
| 331 | seed_terms.extend(frontmatter_labels(&entry.frontmatter_json)); |
| 332 | let body = String::from_utf8_lossy(&entry.content_bytes); |
| 333 | let body = truncate_chars(body.trim(), INTENT_BODY_SEED_CHARS); |
| 334 | if !body.is_empty() { |
| 335 | seed_terms.push(body); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | let node_id = intent_path_to_node_id(&intent_path); |
| 340 | // Intent -> referenced file/domain -> memory is commonly two hops. |
| 341 | add_memory_neighbors(repo, &node_id, 2, candidates)?; |
| 342 | Ok(()) |
| 343 | } |
| 344 | |
| 345 | fn has_explicit_seeds(&self) -> bool { |
| 346 | self.query.iter().any(|q| !q.trim().is_empty()) |
no test coverage detected