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

Method vault_intent_create

atomic-repository/src/repository/vault_intent.rs:110–252  ·  view source on GitHub ↗

Create a new vault intent. Allocates a JIRA-style ID (e.g., "PIMO-1") and creates an intent directory with an `intent.md` scaffold. The prefix is derived from the project directory name on first use (first 4 alphanumeric chars, uppercased). Intent paths are view-scoped and session-scoped: `intents/ / / /intent.md`

(
        &self,
        options: IntentCreateOptions,
    )

Source from the content-addressed store, hash-verified

108 /// Intent paths are view-scoped and session-scoped:
109 /// `intents/<view>/<session>/<turn>/intent.md`
110 pub fn vault_intent_create(
111 &self,
112 options: IntentCreateOptions,
113 ) -> Result<IntentCreateResult, RepositoryError> {
114 if !self.has_vault()? {
115 return Err(RepositoryError::InvalidOperation {
116 message: "Vault not initialized. Run `atomic vault init` first.".to_string(),
117 });
118 }
119
120 let priority = options.priority.unwrap_or_else(|| "medium".to_string());
121 let view_name = self.current_view().to_string();
122
123 // Compute the session-scoped directory and file paths
124 let intent_dir = self.intent_dir_for(options.session_id.as_deref(), options.turn_id);
125 let intent_file = self.intent_file_for(options.session_id.as_deref(), options.turn_id);
126
127 // Allocate ID inside a write transaction
128 let intent_id;
129 {
130 let mut txn = self
131 .pristine
132 .write_txn()
133 .map_err(|e| RepositoryError::Database(e.to_string()))?;
134 let mut manifest = txn
135 .get_vault_manifest()
136 .map_err(|e| RepositoryError::Database(e.to_string()))?;
137
138 // Set prefix on first use, derived from project directory name
139 if manifest.intent_prefix.is_empty() {
140 let project_name = self
141 .root
142 .file_name()
143 .and_then(|n| n.to_str())
144 .unwrap_or("vault");
145 manifest.intent_prefix = VaultManifest::derive_intent_prefix(project_name);
146 // Fallback if project name yields empty prefix
147 if manifest.intent_prefix.is_empty() {
148 manifest.intent_prefix = "VAULT".to_string();
149 }
150 }
151
152 intent_id = manifest.allocate_intent_id();
153
154 // Add to manifest intents index
155 manifest.intents.insert(
156 intent_id.clone(),
157 IntentSummary {
158 status: "backlog".to_string(),
159 priority: priority.clone(),
160 assignee: options.assignee.clone(),
161 goals: 0,
162 blocked_by: Vec::new(),
163 title: options.title.clone(),
164 vault_path: intent_file.clone(),
165 },
166 );
167

Callers 15

runMethod · 0.80
runMethod · 0.80
repo_with_intentFunction · 0.80
repo_with_intentsFunction · 0.80
test_intent_createFunction · 0.80
test_intent_listFunction · 0.80
test_intent_showFunction · 0.80
test_intent_updateFunction · 0.80

Calls 15

derive_intent_prefixFunction · 0.85
current_viewMethod · 0.80
intent_dir_forMethod · 0.80
intent_file_forMethod · 0.80
write_txnMethod · 0.80
file_nameMethod · 0.80
allocate_intent_idMethod · 0.80
put_vault_manifestMethod · 0.80
commitMethod · 0.80
vault_storeMethod · 0.80
vault_materializeMethod · 0.80