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

Function build_turn_intent_map

atomic-cli/src/commands/session.rs:435–456  ·  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

433/// `resolve_active_session` in vault/intent.rs), so we subtract 1 to recover
434/// the 0-indexed session-ledger turn number.
435fn build_turn_intent_map(repo: &Repository, session_id: &str) -> HashMap<u32, String> {
436 let mut map: HashMap<u32, String> = HashMap::new();
437 let manifest = match repo.vault_manifest() {
438 Ok(m) => m,
439 Err(_) => return map,
440 };
441 for (key, summary) in &manifest.intents {
442 if summary.session.as_deref() != Some(session_id) {
443 continue;
444 }
445 let Some(session_turn) = summary.turn.and_then(|t| t.checked_sub(1)) else {
446 continue;
447 };
448 let label = if summary.human_key.is_empty() {
449 key.clone()
450 } else {
451 summary.human_key.clone()
452 };
453 map.insert(session_turn, label);
454 }
455 map
456}
457
458fn truncate_column(value: &str, width: usize) -> String {
459 let count = value.chars().count();

Calls 4

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