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

Function condense_claude_transcript

atomic-agent/src/transcript/condense.rs:34–76  ·  view source on GitHub ↗

Parse a Claude Code JSONL transcript into condensed entries. Reads each line as JSON, extracts user prompts, assistant text responses, and tool calls. Filters out: - Skill content injections (verbose skill instructions in user messages) - Full file contents from Read tool responses - Verbose tool outputs # Arguments `raw` — Raw JSONL bytes from the Claude Code transcript file # Returns A vect

(raw: &[u8])

Source from the content-addressed store, hash-verified

32/// A vector of condensed entries suitable for display and summarization.
33/// Returns an empty vector if the transcript is empty or unparseable.
34pub fn condense_claude_transcript(raw: &[u8]) -> Vec<CondensedEntry> {
35 let mut entries = Vec::new();
36
37 for line in raw.split(|&b| b == b'\n') {
38 if line.is_empty() {
39 continue;
40 }
41
42 let Ok(parsed) = serde_json::from_slice::<TranscriptLine>(line) else {
43 continue;
44 };
45
46 match parsed.r#type.as_str() {
47 "user" => {
48 if let Some(content) = extract_user_content(&parsed.message) {
49 // Skip skill content injections
50 if !content.starts_with(SKILL_CONTENT_PREFIX) {
51 entries.push(CondensedEntry::user(content));
52 }
53 }
54 }
55 "assistant" => {
56 if let Ok(msg) = serde_json::from_value::<AssistantMessage>(parsed.message) {
57 for block in &msg.content {
58 match block.r#type.as_str() {
59 "text" if !block.text.is_empty() => {
60 entries.push(CondensedEntry::assistant(&block.text));
61 }
62 "tool_use" => {
63 let detail = extract_tool_detail(&block.name, &block.input);
64 entries.push(CondensedEntry::tool(&block.name, detail));
65 }
66 _ => {}
67 }
68 }
69 }
70 }
71 _ => {}
72 }
73 }
74
75 entries
76}
77
78/// Condense a transcript from raw bytes, auto-detecting format.
79///

Calls 5

extract_user_contentFunction · 0.85
extract_tool_detailFunction · 0.85
is_emptyMethod · 0.45
as_strMethod · 0.45
pushMethod · 0.45