From 4bf993e1884f30c1eb8f67dd78189bb416f178bb Mon Sep 17 00:00:00 2001 From: Vincent Date: Thu, 18 Jun 2026 20:15:19 -0400 Subject: [PATCH 1/3] feat(vault): allow editing intent body via `intent update` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `atomic vault intent update` previously only updated frontmatter (status, assignee, priority, title); the Markdown body was always preserved unchanged. Filling in an intent's Problem / Acceptance Criteria / Scope / TODOs required editing the materialized file on disk and running `vault sync`. Add a `content` field to `IntentUpdateOptions` and two CLI flags so the body can be set directly: - `--body ` to replace the body inline - `--body-stdin` to pipe the body from a file (e.g. `cat plan.md | ...`) The flags are mutually exclusive. When neither is given, the body is left unchanged (existing behavior). Updating with no fields at all now returns a clear "nothing to update" error instead of a no-op. Mirrors the stdin pattern of `vault memory write`. No immutability gate is added — vault intents are editable work documents, consistent with the existing edit-on-disk + `vault sync` path. --- atomic-cli/src/commands/vault/intent.rs | 57 +++++++++++- .../src/repository/vault_intent.rs | 91 +++++++++++++++++-- 2 files changed, 140 insertions(+), 8 deletions(-) diff --git a/atomic-cli/src/commands/vault/intent.rs b/atomic-cli/src/commands/vault/intent.rs index c423f66e..df9d2919 100644 --- a/atomic-cli/src/commands/vault/intent.rs +++ b/atomic-cli/src/commands/vault/intent.rs @@ -38,6 +38,12 @@ //! # Update intent status //! atomic vault intent update PIMO-1 --status in-progress //! +//! # Replace the intent body inline +//! atomic vault intent update PIMO-1 --body "# Title\n\n## Problem\n..." +//! +//! # Replace the intent body from a file +//! cat plan.md | atomic vault intent update PIMO-1 --body-stdin +//! //! # Delete an accidental draft intent //! atomic vault intent delete PIMO-1 //! atomic vault intent delete PIMO-1 --force @@ -114,13 +120,17 @@ pub enum IntentCommands { /// Update an intent's fields. /// - /// Modifies the status, assignee, priority, or title of an existing intent. + /// Modifies the status, assignee, priority, title, or Markdown body + /// of an existing intent. The body can be set inline with `--body` + /// or piped via `--body-stdin`. /// /// # Examples /// /// ```text /// atomic vault intent update PIMO-1 --status in-progress /// atomic vault intent update PIMO-1 --assignee bob --priority critical + /// atomic vault intent update PIMO-1 --body "# Fix auth\n\n## Problem\n..." + /// cat plan.md | atomic vault intent update PIMO-1 --body-stdin /// ``` Update(IntentUpdate), @@ -370,6 +380,31 @@ pub struct IntentUpdate { /// New title. #[arg(long)] pub title: Option, + + /// New Markdown body content, provided inline. + #[arg(long, conflicts_with = "body_stdin")] + pub body: Option, + + /// Read the new Markdown body content from standard input. + #[arg(long)] + pub body_stdin: bool, +} + +impl IntentUpdate { + fn resolve_body(&self) -> CliResult> { + if let Some(ref body) = self.body { + return Ok(Some(body.clone())); + } + if self.body_stdin { + use std::io::Read; + let mut content = String::new(); + std::io::stdin() + .read_to_string(&mut content) + .map_err(CliError::Io)?; + return Ok(Some(content)); + } + Ok(None) + } } impl Command for IntentUpdate { @@ -377,6 +412,22 @@ impl Command for IntentUpdate { let root = find_repository_root()?; let repo = Repository::open(&root).map_err(CliError::Repository)?; + let content = self.resolve_body()?; + if self.status.is_none() + && self.assignee.is_none() + && self.priority.is_none() + && self.title.is_none() + && content.is_none() + { + return Err(CliError::InvalidArgument { + message: "Nothing to update. Provide at least one of \ + --status, --assignee, --priority, --title, --body, \ + or --body-stdin." + .to_string(), + }); + } + + let body_updated = content.is_some(); let info = repo .vault_intent_update( &self.id, @@ -385,6 +436,7 @@ impl Command for IntentUpdate { assignee: self.assignee.clone(), priority: self.priority.clone(), title: self.title.clone(), + content, }, ) .map_err(CliError::Repository)?; @@ -395,6 +447,9 @@ impl Command for IntentUpdate { if let Some(ref assignee) = info.assignee { println!(" assignee: {}", assignee); } + if body_updated { + println!(" body: updated"); + } Ok(()) } diff --git a/atomic-repository/src/repository/vault_intent.rs b/atomic-repository/src/repository/vault_intent.rs index 6f6b9da7..49c10bb0 100644 --- a/atomic-repository/src/repository/vault_intent.rs +++ b/atomic-repository/src/repository/vault_intent.rs @@ -60,6 +60,9 @@ pub struct IntentDeleteResult { } /// Options for updating an intent. +/// +/// `content` replaces the intent's Markdown body. When it is `None`, the +/// existing body is preserved unchanged. #[derive(Debug, Clone, Default)] pub struct IntentUpdateOptions { /// New status (backlog, planned, in-progress, review, done). @@ -70,6 +73,8 @@ pub struct IntentUpdateOptions { pub priority: Option, /// New title. pub title: Option, + /// New Markdown body content. When `None`, the existing body is kept. + pub content: Option, } /// Info for listing intents. @@ -454,13 +459,12 @@ impl Repository { } let new_fm = serde_json::to_string(&fm).unwrap_or_else(|_| "{}".to_string()); - // Re-store with updated frontmatter - self.vault_store( - &intent_file, - VaultEntryType::Intent, - entry.content_bytes.clone(), - new_fm, - )?; + let new_content = match options.content { + Some(ref body) => body.clone().into_bytes(), + None => entry.content_bytes.clone(), + }; + + self.vault_store(&intent_file, VaultEntryType::Intent, new_content, new_fm)?; // Update manifest { @@ -904,6 +908,79 @@ mod tests { assert_eq!(manifest.intents[&result.id].status, "in-progress"); } + #[test] + fn test_intent_update_body_content() { + let dir = tempdir().unwrap(); + let repo = init_repo_with_vault(dir.path()); + + let result = repo.vault_intent_create(create_opts("Body edit")).unwrap(); + let new_body = "# Body edit\n\n## Problem\n\nThe widget leaks memory.\n"; + + repo.vault_intent_update( + &result.id, + IntentUpdateOptions { + content: Some(new_body.to_string()), + ..Default::default() + }, + ) + .unwrap(); + + let after = repo.vault_intent_show(&result.id).unwrap(); + assert_eq!(String::from_utf8_lossy(&after.content_bytes), new_body); + } + + #[test] + fn test_intent_update_without_content_preserves_body() { + let dir = tempdir().unwrap(); + let repo = init_repo_with_vault(dir.path()); + + let result = repo.vault_intent_create(create_opts("Keep body")).unwrap(); + let original_body = repo.vault_intent_show(&result.id).unwrap().content_bytes; + + repo.vault_intent_update( + &result.id, + IntentUpdateOptions { + priority: Some("high".to_string()), + ..Default::default() + }, + ) + .unwrap(); + + assert_eq!( + repo.vault_intent_show(&result.id).unwrap().content_bytes, + original_body + ); + } + + #[test] + fn test_intent_update_body_and_frontmatter_together() { + let dir = tempdir().unwrap(); + let repo = init_repo_with_vault(dir.path()); + + let result = repo.vault_intent_create(create_opts("Combined")).unwrap(); + let new_body = "# Combined\n\nFully rewritten.\n"; + let updated = repo + .vault_intent_update( + &result.id, + IntentUpdateOptions { + status: Some("review".to_string()), + priority: Some("high".to_string()), + content: Some(new_body.to_string()), + ..Default::default() + }, + ) + .unwrap(); + + assert_eq!(updated.status, "review"); + assert_eq!(updated.priority, "high"); + assert_eq!( + String::from_utf8_lossy( + &repo.vault_intent_show(&result.id).unwrap().content_bytes + ), + new_body + ); + } + #[test] fn test_intent_delete_backlog_removes_manifest_entry_and_file() { let dir = tempdir().unwrap(); From cd05c95c22e4e463115690bc35adf23c5599ce65 Mon Sep 17 00:00:00 2001 From: Vincent Date: Mon, 22 Jun 2026 15:40:11 -0400 Subject: [PATCH 2/3] fix(vault): guard intent body rewrites --- atomic-cli/src/commands/vault/intent.rs | 5 + .../src/repository/vault_intent.rs | 118 ++++++++++++++++++ 2 files changed, 123 insertions(+) diff --git a/atomic-cli/src/commands/vault/intent.rs b/atomic-cli/src/commands/vault/intent.rs index df9d2919..1e92f1c5 100644 --- a/atomic-cli/src/commands/vault/intent.rs +++ b/atomic-cli/src/commands/vault/intent.rs @@ -388,6 +388,10 @@ pub struct IntentUpdate { /// Read the new Markdown body content from standard input. #[arg(long)] pub body_stdin: bool, + + /// Rewrite the body even if the intent has started or is linked to a goal. + #[arg(long, short = 'f')] + pub force: bool, } impl IntentUpdate { @@ -437,6 +441,7 @@ impl Command for IntentUpdate { priority: self.priority.clone(), title: self.title.clone(), content, + force: self.force, }, ) .map_err(CliError::Repository)?; diff --git a/atomic-repository/src/repository/vault_intent.rs b/atomic-repository/src/repository/vault_intent.rs index 49c10bb0..75e54724 100644 --- a/atomic-repository/src/repository/vault_intent.rs +++ b/atomic-repository/src/repository/vault_intent.rs @@ -75,6 +75,8 @@ pub struct IntentUpdateOptions { pub title: Option, /// New Markdown body content. When `None`, the existing body is kept. pub content: Option, + /// Allow rewriting the body after the intent has started or been linked. + pub force: bool, } /// Info for listing intents. @@ -433,6 +435,31 @@ impl Repository { let mut fm: serde_json::Map = serde_json::from_str(&entry.frontmatter_json).unwrap_or_default(); + if options.content.is_some() && !options.force { + let manifest = self.vault_manifest()?; + let summary = manifest.intents.get(&full_id); + let current_status = summary + .map(|intent| intent.status.as_str()) + .or_else(|| fm.get("status").and_then(|value| value.as_str())) + .unwrap_or("unknown"); + let has_linked_goal = summary.is_some_and(|intent| intent.goals > 0) + || manifest.goals.values().any(|goal| { + goal.intent + .as_deref() + .is_some_and(|id| id.eq_ignore_ascii_case(&full_id)) + }); + + if current_status != "backlog" || has_linked_goal { + return Err(RepositoryError::InvalidOperation { + message: format!( + "Intent '{}' has started or is linked to a goal; rewriting its body would \ + change the execution context. Retry with force enabled.", + full_id + ), + }); + } + } + if let Some(ref status) = options.status { fm.insert( "status".to_string(), @@ -1071,6 +1098,97 @@ mod tests { assert!(repo.vault_retrieve(&intent.intent_file).unwrap().is_some()); } + #[test] + fn test_intent_update_body_rejects_started_intent_without_force() { + let dir = tempdir().unwrap(); + let repo = init_repo_with_vault(dir.path()); + + let result = repo.vault_intent_create(create_opts("Started")).unwrap(); + repo.vault_intent_update( + &result.id, + IntentUpdateOptions { + status: Some("in-progress".to_string()), + ..Default::default() + }, + ) + .unwrap(); + + let before = repo.vault_intent_show(&result.id).unwrap().content_bytes; + let err = repo + .vault_intent_update( + &result.id, + IntentUpdateOptions { + content: Some("# Rewritten".to_string()), + ..Default::default() + }, + ) + .unwrap_err(); + + assert!(err.to_string().contains("Retry with force enabled")); + assert_eq!( + repo.vault_intent_show(&result.id).unwrap().content_bytes, + before + ); + } + + #[test] + fn test_intent_update_body_rejects_goal_reference_without_force() { + let dir = tempdir().unwrap(); + let repo = init_repo_with_vault(dir.path()); + + let intent = repo.vault_intent_create(create_opts("Linked")).unwrap(); + repo.vault_goal_start(GoalStartOptions { + name: Some("test-goal".to_string()), + intent: Some(intent.id.clone()), + ..Default::default() + }) + .unwrap(); + + let err = repo + .vault_intent_update( + &intent.id, + IntentUpdateOptions { + content: Some("# Rewritten".to_string()), + ..Default::default() + }, + ) + .unwrap_err(); + + assert!(err.to_string().contains("Retry with force enabled")); + } + + #[test] + fn test_intent_update_body_force_allows_started_intent() { + let dir = tempdir().unwrap(); + let repo = init_repo_with_vault(dir.path()); + + let result = repo.vault_intent_create(create_opts("Started")).unwrap(); + repo.vault_intent_update( + &result.id, + IntentUpdateOptions { + status: Some("in-progress".to_string()), + ..Default::default() + }, + ) + .unwrap(); + + let new_body = "# Rewritten with explicit force\n"; + repo.vault_intent_update( + &result.id, + IntentUpdateOptions { + content: Some(new_body.to_string()), + force: true, + ..Default::default() + }, + ) + .unwrap(); + + assert_eq!( + String::from_utf8_lossy(&repo.vault_intent_show(&result.id).unwrap().content_bytes), + new_body + ); + } + #[test] fn test_intent_link_goal() { let dir = tempdir().unwrap(); From efa4015aa3873e6e633407c0893d7ec8c1c260d2 Mon Sep 17 00:00:00 2001 From: Vincent Date: Tue, 23 Jun 2026 09:48:50 -0400 Subject: [PATCH 3/3] chore: format rebased intent update --- atomic-repository/src/repository/vault_intent.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/atomic-repository/src/repository/vault_intent.rs b/atomic-repository/src/repository/vault_intent.rs index 75e54724..09a078e8 100644 --- a/atomic-repository/src/repository/vault_intent.rs +++ b/atomic-repository/src/repository/vault_intent.rs @@ -1001,9 +1001,7 @@ mod tests { assert_eq!(updated.status, "review"); assert_eq!(updated.priority, "high"); assert_eq!( - String::from_utf8_lossy( - &repo.vault_intent_show(&result.id).unwrap().content_bytes - ), + String::from_utf8_lossy(&repo.vault_intent_show(&result.id).unwrap().content_bytes), new_body ); }