transcript

package
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	TypeUser      = "user"
	TypeAssistant = "assistant"
)

Message type constants for transcript lines.

View Source
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

func SliceFromLine(content []byte, startLine int) []byte

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

func ParseFromBytes(content []byte) ([]Line, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL