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

Function intent_delete

atomic-cli/src/commands/rpc.rs:6286–6341  ·  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

6284/// pre-check rides a GetVaultEntry (a read), the confirm prompt runs
6285/// client-side, and the handler enforces the same unstarted-backlog guard.
6286pub fn intent_delete(args: &super::intent::delete::IntentDelete) -> CliResult<bool> {
6287 // The existence pre-check before the prompt: the local body's
6288 // vault_intent_show read.
6289 {
6290 let Some(session) = Service::open()? else {
6291 return Ok(false);
6292 };
6293 let request = pb::GetVaultEntryRequest {
6294 repository: Some(session.reference.clone()),
6295 kind: Kind::Intent as i32,
6296 id: args.id.clone(),
6297 path: None,
6298 include_bundle: false,
6299 view: None,
6300 };
6301 session.get_vault_entry(request)?;
6302 }
6303 if !args.force {
6304 let prompt = format!(
6305 "Discard intent '{}'? This removes the unstarted draft from the vault.",
6306 args.id
6307 );
6308 let confirmed = dialoguer::Confirm::new()
6309 .with_prompt(&prompt)
6310 .default(false)
6311 .interact()
6312 .map_err(|e| CliError::Internal(anyhow::anyhow!("Prompt failed: {}", e)))?;
6313 if !confirmed {
6314 return Err(CliError::Cancelled);
6315 }
6316 }
6317 let Some(session) = Service::open()? else {
6318 return Ok(false);
6319 };
6320 let request = pb::DeleteVaultEntityRequest {
6321 repository: Some(session.reference.clone()),
6322 meta: request_meta(),
6323 kind: Kind::Intent as i32,
6324 id: args.id.clone(),
6325 view: None,
6326 expected_snapshot: None,
6327 };
6328 let response = session.delete_vault_entity(request)?;
6329 if args.json {
6330 let json = serde_json::json!({
6331 "id": response.id,
6332 "intent_file": response.vault_path.trim_start_matches(".vault/"),
6333 "deleted": true,
6334 });
6335 println!("{}", serde_json::to_string_pretty(&json).unwrap());
6336 } else {
6337 println!("Deleted intent: {}", response.id);
6338 println!(" file: {}", response.vault_path);
6339 }
6340 Ok(true)
6341}
6342
6343/// `atomic intent link` over LinkVaultEntities — the intent→goal link the

Callers 1

runMethod · 0.85

Calls 7

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

Tested by

no test coverage detected