Documentation
¶
Overview ¶
Package transcript provides shared types for parsing Claude Code transcripts. This package contains only data structures and constants, not parsing logic.
Index ¶
Constants ¶
const ( TypeUser = "user" TypeAssistant = "assistant" )
Message type constants for transcript lines.
const ( ContentTypeText = "text" ContentTypeToolUse = "tool_use" )
Content type constants for content blocks within messages.
Variables ¶
This section is empty.
Functions ¶
func ExtractUserContent ¶
func ExtractUserContent(message json.RawMessage) string
ExtractUserContent extracts user content from a raw message. Handles both string and array content formats. IDE-injected context tags (like <ide_opened_file>) are stripped from the result. Returns empty string if the message cannot be parsed or contains no text.
func SliceFromLine ¶
SliceFromLine returns the content starting from line number `startLine` (0-indexed). This is used to extract only the checkpoint-specific portion of a cumulative transcript. For example, if startLine is 2, lines 0 and 1 are skipped and the result starts at line 2. Returns empty slice if startLine exceeds the number of lines.
Types ¶
type AssistantMessage ¶
type AssistantMessage struct {
Content []ContentBlock `json:"content"`
}
AssistantMessage represents an assistant message in the transcript.
type ContentBlock ¶
type ContentBlock struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Name string `json:"name,omitempty"`
Input json.RawMessage `json:"input,omitempty"`
}
ContentBlock represents a block within an assistant message.
type Line ¶
type Line struct {
Type string `json:"type"`
UUID string `json:"uuid"`
Message json.RawMessage `json:"message"`
}
Line represents a single line in a Claude Code JSONL transcript.
func ParseFromBytes ¶
ParseFromBytes parses transcript content from a byte slice. Uses bufio.Reader to handle arbitrarily long lines.
type ToolInput ¶
type ToolInput struct {
FilePath string `json:"file_path,omitempty"`
NotebookPath string `json:"notebook_path,omitempty"`
Description string `json:"description,omitempty"`
Command string `json:"command,omitempty"`
Pattern string `json:"pattern,omitempty"`
// Skill tool fields
Skill string `json:"skill,omitempty"`
// WebFetch tool fields
URL string `json:"url,omitempty"`
Prompt string `json:"prompt,omitempty"`
}
ToolInput represents the input to various tools. Used to extract file paths and descriptions from tool calls.
type UserMessage ¶
type UserMessage struct {
Content interface{} `json:"content"`
}
UserMessage represents a user message in the transcript.