summarize

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package summarize provides AI-powered summarization of development sessions.

Index

Constants

View Source
const DefaultModel = "sonnet"

DefaultModel is the default model used for summarization. Sonnet provides a good balance of quality and cost, with 1M context window to handle long transcripts without truncation.

Variables

This section is empty.

Functions

func FormatCondensedTranscript

func FormatCondensedTranscript(input Input) string

FormatCondensedTranscript formats an Input into a human-readable string for LLM. The format is:

[User] user prompt here

[Assistant] assistant response here

[Tool] ToolName: description or file path

func GenerateFromTranscript

func GenerateFromTranscript(ctx context.Context, transcriptBytes []byte, filesTouched []string, agentType types.AgentType, generator Generator) (*checkpoint.Summary, error)

GenerateFromTranscript generates a summary from raw transcript bytes. This is the shared implementation used by both explain --generate and auto-summarize.

Parameters:

  • ctx: context for cancellation
  • transcriptBytes: raw transcript bytes (JSONL or JSON format depending on agent)
  • filesTouched: list of files modified during the session
  • agentType: the agent type to determine transcript format
  • generator: summary generator to use (if nil, uses default ClaudeGenerator)

Returns nil, error if transcript is empty or cannot be parsed.

Types

type ClaudeGenerator

type ClaudeGenerator struct {
	// ClaudePath is the path to the claude CLI executable.
	// If empty, defaults to "claude" (expects it to be in PATH).
	ClaudePath string

	// Model is the Claude model to use for summarization.
	// If empty, defaults to DefaultModel ("sonnet").
	Model string

	// CommandRunner allows injection of the command execution for testing.
	// If nil, uses exec.CommandContext directly.
	CommandRunner func(ctx context.Context, name string, args ...string) *exec.Cmd
}

ClaudeGenerator generates summaries using the Claude CLI.

func (*ClaudeGenerator) Generate

func (g *ClaudeGenerator) Generate(ctx context.Context, input Input) (*checkpoint.Summary, error)

Generate creates a summary from checkpoint data by calling the Claude CLI.

type Entry

type Entry struct {
	// Type is the entry type (user, assistant, tool)
	Type EntryType

	// Content is the text content for user/assistant entries
	Content string

	// ToolName is the name of the tool (for tool entries)
	ToolName string

	// ToolDetail is a description or file path (for tool entries)
	ToolDetail string
}

Entry represents one item in the condensed transcript.

func BuildCondensedTranscript

func BuildCondensedTranscript(lines []transcript.Line) []Entry

BuildCondensedTranscript extracts a condensed view of the transcript. It processes user prompts, assistant responses, and tool calls into a simplified format suitable for LLM summarization.

func BuildCondensedTranscriptFromBytes

func BuildCondensedTranscriptFromBytes(content []byte, agentType types.AgentType) ([]Entry, error)

BuildCondensedTranscriptFromBytes parses transcript bytes and extracts a condensed view. This is a convenience function that combines parsing and condensing. The agentType parameter determines which parser to use (Claude/OpenCode JSONL vs Gemini JSON).

type EntryType

type EntryType string

EntryType represents the type of a transcript entry.

const (
	// EntryTypeUser indicates a user prompt entry.
	EntryTypeUser EntryType = "user"
	// EntryTypeAssistant indicates an assistant response entry.
	EntryTypeAssistant EntryType = "assistant"
	// EntryTypeTool indicates a tool call entry.
	EntryTypeTool EntryType = "tool"
)

type Generator

type Generator interface {
	// Generate creates a summary from checkpoint data.
	// Returns the generated summary or an error if generation fails.
	Generate(ctx context.Context, input Input) (*checkpoint.Summary, error)
}

Generator generates checkpoint summaries using an LLM.

type Input

type Input struct {
	// Transcript is the condensed transcript entries
	Transcript []Entry

	// FilesTouched are the files modified during the session
	FilesTouched []string
}

Input contains condensed checkpoint data for summarization.

Jump to

Keyboard shortcuts

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