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

Function intent_delete

atomic-cli/src/commands/rpc.rs:6326–6381  ·  view source on GitHub ↗

`atomic intent delete` over DeleteVaultEntity — the existence pre-check rides a GetVaultEntry (a read), the confirm prompt runs client-side, and the handler enforces the same unstarted-backlog guard.

(args: &super::intent::delete::IntentDelete)

Source from the content-addressed store, hash-verified

6324/// pre-check rides a GetVaultEntry (a read), the confirm prompt runs
6325/// client-side, and the handler enforces the same unstarted-backlog guard.
6326pub fn intent_delete(args: &super::intent::delete::IntentDelete) -> CliResult<bool> {
6327 // The existence pre-check before the prompt: the local body's
6328 // vault_intent_show read.
6329 {
6330 let Some(session) = Service::open()? else {
6331 return Ok(false);
6332 };
6333 let request = pb::GetVaultEntryRequest {
6334 repository: Some(session.reference.clone()),
6335 kind: Kind::Intent as i32,
6336 id: args.id.clone(),
6337 path: None,
6338 include_bundle: false,
6339 view: None,
6340 };
6341 session.get_vault_entry(request)?;
6342 }
6343 if !args.force {
6344 let prompt = format!(
6345 "Discard intent '{}'? This removes the unstarted draft from the vault.",
6346 args.id
6347 );
6348 let confirmed = dialoguer::Confirm::new()
6349 .with_prompt(&prompt)
6350 .default(false)
6351 .interact()
6352 .map_err(|e| CliError::Internal(anyhow::anyhow!("Prompt failed: {}", e)))?;
6353 if !confirmed {
6354 return Err(CliError::Cancelled);
6355 }
6356 }
6357 let Some(session) = Service::open()? else {
6358 return Ok(false);
6359 };
6360 let request = pb::DeleteVaultEntityRequest {
6361 repository: Some(session.reference.clone()),
6362 meta: request_meta(),
6363 kind: Kind::Intent as i32,
6364 id: args.id.clone(),
6365 view: None,
6366 expected_snapshot: None,
6367 };
6368 let response = session.delete_vault_entity(request)?;
6369 if args.json {
6370 let json = serde_json::json!({
6371 "id": response.id,
6372 "intent_file": response.vault_path.trim_start_matches(".vault/"),
6373 "deleted": true,
6374 });
6375 println!("{}", serde_json::to_string_pretty(&json).unwrap());
6376 } else {
6377 println!("Deleted intent: {}", response.id);
6378 println!(" file: {}", response.vault_path);
6379 }
6380 Ok(true)
6381}
6382
6383/// `atomic intent link` over LinkVaultEntities — the intent→goal link the

Callers 1

runMethod · 0.85

Calls 7

with_promptMethod · 0.80
request_metaFunction · 0.70
openFunction · 0.50
cloneMethod · 0.45
get_vault_entryMethod · 0.45
defaultMethod · 0.45
delete_vault_entityMethod · 0.45

Tested by

no test coverage detected