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

Function get_condensed_text

atomic-cli/src/commands/agent/explain.rs:358–419  ·  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

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

Callers 1

runMethod · 0.85

Calls 10

extract_unhashedFunction · 0.85
format_condensedFunction · 0.85
condense_transcriptFunction · 0.85
is_emptyMethod · 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