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

Function build_turn_intent_map

atomic-cli/src/commands/session.rs:379–400  ·  view source on GitHub ↗

Build a map from session turn_number → intent human key for a specific session, read from the manifest's `session`/`turn` provenance fields. The stored `turn` is `turn_count + 1` at creation time (see `resolve_active_session` in vault/intent.rs), so we subtract 1 to recover the 0-indexed session-ledger turn number.

(repo: &Repository, session_id: &str)

Source from the content-addressed store, hash-verified

377/// `resolve_active_session` in vault/intent.rs), so we subtract 1 to recover
378/// the 0-indexed session-ledger turn number.
379fn build_turn_intent_map(repo: &Repository, session_id: &str) -> HashMap<u32, String> {
380 let mut map: HashMap<u32, String> = HashMap::new();
381 let manifest = match repo.vault_manifest() {
382 Ok(m) => m,
383 Err(_) => return map,
384 };
385 for (key, summary) in &manifest.intents {
386 if summary.session.as_deref() != Some(session_id) {
387 continue;
388 }
389 let Some(session_turn) = summary.turn.and_then(|t| t.checked_sub(1)) else {
390 continue;
391 };
392 let label = if summary.human_key.is_empty() {
393 key.clone()
394 } else {
395 summary.human_key.clone()
396 };
397 map.insert(session_turn, label);
398 }
399 map
400}
401
402fn truncate_column(value: &str, width: usize) -> String {
403 let count = value.chars().count();

Calls 4

vault_manifestMethod · 0.80
is_emptyMethod · 0.45
cloneMethod · 0.45
insertMethod · 0.45