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

Function get_condensed_text

atomic-cli/src/commands/agent/explain.rs:367–428  ·  view source on GitHub ↗

Get the condensed transcript text for a change. First tries to read from the change's unhashed section (already condensed during recording). If not available, falls back to reading the raw transcript file from the session and condensing it on the fly.

(
    change: &atomic_core::change::Change,
    session: &atomic_agent::turn::session::AgentSession,
)

Source from the content-addressed store, hash-verified

365/// during recording). If not available, falls back to reading the raw
366/// transcript file from the session and condensing it on the fly.
367fn get_condensed_text(
368 change: &atomic_core::change::Change,
369 session: &atomic_agent::turn::session::AgentSession,
370) -> CliResult<String> {
371 // Try the change's unhashed section first
372 if let Some(unhashed) = extract_unhashed(change) {
373 if !unhashed.condensed_text.is_empty() {
374 return Ok(unhashed.condensed_text);
375 }
376 // Has entries but no formatted text — format them
377 if !unhashed.condensed_transcript.is_empty() {
378 let files: Vec<String> = unhashed
379 .tools_used
380 .iter()
381 .flat_map(|t| t.files_affected.clone())
382 .collect();
383 return Ok(transcript::format_condensed(
384 &unhashed.condensed_transcript,
385 &files,
386 ));
387 }
388 }
389
390 // Fall back to reading the transcript file
391 if let Some(ref path) = session.transcript_path {
392 if path.exists() {
393 let raw = std::fs::read(path).map_err(|e| {
394 CliError::Internal(anyhow::anyhow!(
395 "Failed to read transcript at {}: {}",
396 path.display(),
397 e
398 ))
399 })?;
400
401 let format = if session.agent_name.contains("gemini") {
402 "json"
403 } else {
404 "jsonl"
405 };
406
407 let entries = transcript::condense_transcript(&raw, format);
408 if entries.is_empty() {
409 return Ok(String::new());
410 }
411
412 // Get files from FileOps (CRDT layer) or session state
413 let files: Vec<String> = if !change.file_ops().is_empty() {
414 change
415 .file_ops()
416 .iter()
417 .map(|fop| fop.path().to_string())
418 .collect()
419 } else {
420 session.files_touched.clone()
421 };
422
423 return Ok(transcript::format_condensed(&entries, &files));
424 }

Callers 1

runMethod · 0.85

Calls 12

extract_unhashedFunction · 0.85
format_condensedFunction · 0.85
condense_transcriptFunction · 0.85
readFunction · 0.70
is_emptyMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
cloneMethod · 0.45
existsMethod · 0.45
containsMethod · 0.45
file_opsMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected