(&self)
| 69 | |
| 70 | impl Command for IntentNew { |
| 71 | fn run(&self) -> CliResult<()> { |
| 72 | if self.template != "feature" { |
| 73 | return Err(CliError::InvalidArgument { |
| 74 | message: format!( |
| 75 | "unknown template '{}' (only 'feature' is implemented)", |
| 76 | self.template |
| 77 | ), |
| 78 | }); |
| 79 | } |
| 80 | |
| 81 | let root = find_repository_root()?; |
| 82 | let repo = Repository::open(&root).map_err(CliError::Repository)?; |
| 83 | |
| 84 | // Create through the EXISTING vault write path so the intent enters |
| 85 | // redb normally and joins the merkle exactly as `atomic vault intent |
| 86 | // create` does — we do NOT invent a new redb write. |
| 87 | let created = repo |
| 88 | .vault_intent_create(IntentCreateOptions { |
| 89 | title: self.title.clone(), |
| 90 | priority: None, |
| 91 | assignee: None, |
| 92 | labels: Vec::new(), |
| 93 | session_id: None, |
| 94 | turn_id: None, |
| 95 | }) |
| 96 | .map_err(CliError::Repository)?; |
| 97 | |
| 98 | // Overwrite the (legacy positional) scaffold body with the directive |
| 99 | // scaffold, again through the existing update path. `force` is set |
| 100 | // because this runs immediately after create; the intent is a fresh |
| 101 | // backlog draft with no linked goal, so force is a no-op guard-skip. |
| 102 | // |
| 103 | // Child ids (acceptance criteria, tasks) are namespaced under the |
| 104 | // intent's ULID — not the human key — so they are globally unique and |
| 105 | // never carry the human key's `::`/`-` separators. Use the ULID as-is |
| 106 | // (ULIDs are uppercase) so the child ids share the intent's case; the |
| 107 | // KG canonicalizes these to an uppercase local regardless, but keeping |
| 108 | // the on-disk ids uppercase avoids an upper/lower split in the file. |
| 109 | let scaffold = FEATURE_SCAFFOLD.replace("{id}", &created.uid); |
| 110 | repo.vault_intent_update( |
| 111 | &created.id, |
| 112 | IntentUpdateOptions { |
| 113 | content: Some(scaffold), |
| 114 | force: true, |
| 115 | ..Default::default() |
| 116 | }, |
| 117 | ) |
| 118 | .map_err(CliError::Repository)?; |
| 119 | |
| 120 | println!("Created intent: {}", created.id); |
| 121 | println!(" file: .vault/{}", created.intent_file); |
| 122 | println!(" template: {}", self.template); |
| 123 | println!(); |
| 124 | println!("Edit the directive stubs, then:"); |
| 125 | println!(" atomic intent validate {}", created.id); |
| 126 | println!(" atomic intent attest {}", created.id); |
| 127 | |
| 128 | Ok(()) |
nothing calls this directly
no test coverage detected