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

Method run

atomic-cli/src/commands/intent/list.rs:483–581  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

481
482impl Command for IntentList {
483 fn run(&self) -> CliResult<()> {
484 // Every form routes (the --json columns ride the wire; the kind
485 // filter validates and applies client-side).
486 if crate::commands::rpc::intent_list(self)? {
487 return Ok(());
488 }
489
490 let root = find_repository_root()?;
491 let repo =
492 crate::commands::open_readonly_repository(&root).map_err(CliError::Repository)?;
493
494 // Resolve the verifying identity ONCE (soft-fail to "no identity").
495 let verifier = resolve_verifier(&self.identity)?;
496
497 // Resolve + validate the kind filter (`--review` ⇒ `--kind review`). An
498 // unknown kind is a clean argument error rather than a silent empty list.
499 let filter = self.kind_filter();
500 if let Some(k) = &filter {
501 if !atomic_canonical::vocab::is_known_intent_kind(k) {
502 return Err(CliError::InvalidArgument {
503 message: format!(
504 "unknown intent kind '{}' (expected one of {:?})",
505 k,
506 atomic_canonical::vocab::INTENT_KIND
507 ),
508 });
509 }
510 }
511
512 // Enumerate via the SAME source `atomic vault intent list` uses; already
513 // sorted by id. Attestation entries are never in `manifest.intents`. The
514 // kind tag uses stored frontmatter with a manifest fallback.
515 let mut rows = build_rows(&repo, verifier.as_ref(), filter.as_deref())?;
516 sort_rows(&mut rows, self.sort, self.reverse);
517
518 if self.json {
519 let json: Vec<serde_json::Value> = rows
520 .iter()
521 .map(|r| {
522 serde_json::json!({
523 "id": r.human_key,
524 // Omitted entirely before, so every API consumer
525 // reported an intent's title as null however well
526 // the frontmatter named it.
527 "title": r.title,
528 "status": r.status,
529 "kind": r.kind,
530 "attested": r.attested.json(),
531 "verifies": r.verifies.json(),
532 })
533 })
534 .collect();
535 println!("{}", serde_json::to_string_pretty(&json).unwrap());
536 return Ok(());
537 }
538
539 if rows.is_empty() {
540 println!("No intents found.");

Callers

nothing calls this directly

Calls 13

intent_listFunction · 0.85
find_repository_rootFunction · 0.85
open_readonly_repositoryFunction · 0.85
is_known_intent_kindFunction · 0.85
build_rowsFunction · 0.85
kind_filterMethod · 0.80
as_refMethod · 0.80
resolve_verifierFunction · 0.70
sort_rowsFunction · 0.70
collectMethod · 0.45
iterMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected