progress

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IconWorkflowLoad     = "📋" // Loading workflow file
	IconWorkflowCompiled = "✅" // Workflow successfully compiled
	IconWorkflowError    = "❌" // Workflow error

	IconDocumentStart    = "📄"  // Document processing started
	IconDocumentComplete = "✅"  // Document processed successfully
	IconDocumentError    = "❌"  // Document processing error
	IconDocumentSkipped  = "⏭️" // Document skipped

	IconStepProcessing = "⚙️ " // Step is processing (mutable line)
	IconStepComplete   = "✅"   // Step completed successfully
	IconStepError      = "❌"   // Step failed with error

	IconRouterEvaluating = "🧭" // Router evaluating conditions
	IconRouterMatched    = "↳" // Router matched a route (text, not emoji)

	IconForeachStart = "🔁" // Foreach loop started
	IconForeachItem  = "✅" // Foreach item completed

	IconRetryAttempt   = "🔄" // Retry attempt
	IconRetrySuccess   = "✅" // Retry succeeded
	IconRetryExhausted = "❌" // All retries exhausted

	IconBatchProcessing = "📂"  // Batch processing
	IconChunking        = "✂️" // Document chunking

	IconThinking = "💭" // LLM thinking/reasoning content

	IconSummary = "📊"  // Pipeline summary
	IconWarning = "⚠️" // Warning message
)

Icons used for progress reporting - centralized for easy customization

Variables

This section is empty.

Functions

func ContextCallStack added in v0.2.0

func ContextCallStack(ctx context.Context, jobName string, jobSize, stepID int) context.Context

func ContextForEach added in v0.2.0

func ContextForEach(ctx context.Context, jobName string, index, total int) context.Context

func ContextRouter added in v0.2.0

func ContextRouter(ctx context.Context, jobName string) context.Context

func WithReporter

func WithReporter(ctx context.Context, reporter *Reporter) context.Context

WithReporter embeds a progress reporter in the context

func WithStepInfo

func WithStepInfo(ctx context.Context, info StepInfo) context.Context

WithStepInfo embeds step information in the context

Types

type ProfileTokenUsage

type ProfileTokenUsage struct {
	Name  string
	Usage TokenUsage
}

ProfileTokenUsage represents token usage for a specific profile

type ProgressBar added in v0.2.0

type ProgressBar interface {
	// Token source management
	SetTokenSource(source TokenSource)
	SetForeachMode(inForeach bool)

	// Workflow lifecycle events
	WorkflowLoading(path string)
	WorkflowCompiled(name string, jobCount, stepCount int)
	WorkflowError(err error)

	// Document processing events
	DocumentStart(path string, sizeKB float64)
	DocumentComplete(path string, duration time.Duration)
	DocumentError(path string, err error)
	DocumentSkipped(path string, reason string)

	// Step execution events
	StepStart(jobName, stepName string, stepNum, totalSteps int)
	StepProgress(message string)
	StepComplete(jobName, stepName string, stepNum, totalSteps int, duration time.Duration, tokens int)
	StepSkipped(jobName, stepName string, stepNum, totalSteps int, reason string)
	StepError(jobName, stepName string, stepNum, totalSteps int, err error)

	// Router and control flow events
	RouterEvaluating()
	RouterMatched(routeName string, targetJob string)
	RouterDefault(targetJob string)
	RouterNoMatch()

	// Foreach iteration events
	ForeachStart(itemCount int)
	ForeachItem(index, total int, status string)
	ForeachComplete(successCount, totalCount int, duration time.Duration)

	// Retry and recovery events
	RetryAttempt(attempt, maxAttempts int, delay time.Duration)
	RetrySuccess(attempt int)
	RetryExhausted(maxAttempts int)

	// LLM thinking events
	ThinkingContent(text string)

	// Batch processing events
	BatchStart(inputPath, outputPath string, mutable bool)
	BatchProgress(processed, total int)
	BatchComplete()

	// Chunking events
	ChunkingStart(strategy string, chunkCount int)

	// Summary and statistics
	Summary()
	SummaryQuick(docCount int, duration time.Duration)
	UpdateTokens(inputTokens, outputTokens int)
	GetStats() Stats
}

ProgressBar interface defines all progress reporting methods

func FromContext

func FromContext(ctx context.Context) ProgressBar

FromContext extracts the progress reporter from context

type Reporter

type Reporter struct {
	// contains filtered or unexported fields
}

Reporter handles all progress output to stderr with educational messages

func New

func New(quiet bool) *Reporter

New creates a new progress reporter

func NewWithWriter

func NewWithWriter(w io.Writer, quiet bool) *Reporter

NewWithWriter creates a reporter with a custom writer (for testing)

func (*Reporter) BatchComplete

func (r *Reporter) BatchComplete()

BatchComplete finalizes batch progress

func (*Reporter) BatchProgress

func (r *Reporter) BatchProgress(processed, total int)

BatchProgress reports batch processing progress

func (*Reporter) BatchStart

func (r *Reporter) BatchStart(inputPath, outputPath string, mutable bool)

BatchStart indicates batch processing is starting

func (*Reporter) ChunkingStart

func (r *Reporter) ChunkingStart(strategy string, chunkCount int)

ChunkingStart indicates document is being split

func (*Reporter) DocumentComplete

func (r *Reporter) DocumentComplete(path string, duration time.Duration)

DocumentComplete indicates successful document completion

func (*Reporter) DocumentError

func (r *Reporter) DocumentError(path string, err error)

DocumentError reports a document processing error

func (*Reporter) DocumentSkipped

func (r *Reporter) DocumentSkipped(path string, reason string)

DocumentSkipped indicates a document was skipped

func (*Reporter) DocumentStart

func (r *Reporter) DocumentStart(path string, sizeKB float64)

DocumentStart indicates a document is starting to process

func (*Reporter) ForeachComplete

func (r *Reporter) ForeachComplete(successCount, totalCount int, duration time.Duration)

ForeachComplete indicates foreach loop completed

func (*Reporter) ForeachItem

func (r *Reporter) ForeachItem(index, total int, status string)

ForeachItem reports progress on a foreach item

func (*Reporter) ForeachStart

func (r *Reporter) ForeachStart(itemCount int)

ForeachStart indicates foreach loop is starting

func (*Reporter) GetStats

func (r *Reporter) GetStats() Stats

GetStats returns a copy of current statistics

func (*Reporter) RetryAttempt

func (r *Reporter) RetryAttempt(attempt, maxAttempts int, delay time.Duration)

RetryAttempt indicates a retry is being attempted

func (*Reporter) RetryExhausted

func (r *Reporter) RetryExhausted(maxAttempts int)

RetryExhausted indicates all retry attempts failed

func (*Reporter) RetrySuccess

func (r *Reporter) RetrySuccess(attempt int)

RetrySuccess indicates retry succeeded

func (*Reporter) RouterDefault

func (r *Reporter) RouterDefault(targetJob string)

RouterDefault indicates router is using default route

func (*Reporter) RouterEvaluating

func (r *Reporter) RouterEvaluating()

RouterEvaluating indicates router is evaluating conditions

func (*Reporter) RouterMatched

func (r *Reporter) RouterMatched(routeName string, targetJob string)

RouterMatched indicates router matched a route

func (*Reporter) RouterNoMatch

func (r *Reporter) RouterNoMatch()

RouterNoMatch indicates no route was matched

func (*Reporter) SetForeachMode

func (r *Reporter) SetForeachMode(inForeach bool)

SetForeachMode sets whether we're inside a foreach loop

func (*Reporter) SetTokenSource

func (r *Reporter) SetTokenSource(source TokenSource)

SetTokenSource sets the token source for final usage reporting

func (*Reporter) StepComplete

func (r *Reporter) StepComplete(jobName, stepName string, stepNum, totalSteps int, duration time.Duration, tokens int)

StepComplete indicates step completion

func (*Reporter) StepError

func (r *Reporter) StepError(jobName, stepName string, stepNum, totalSteps int, err error)

StepError reports a step error

func (*Reporter) StepProgress

func (r *Reporter) StepProgress(message string)

StepProgress updates the current step status (mutable)

func (*Reporter) StepSkipped added in v0.1.16

func (r *Reporter) StepSkipped(jobName, stepName string, stepNum, totalSteps int, reason string)

StepSkipped indicates step was skipped (e.g., cache hit)

func (*Reporter) StepStart

func (r *Reporter) StepStart(jobName, stepName string, stepNum, totalSteps int)

StepStart indicates a workflow step is starting

func (*Reporter) Summary

func (r *Reporter) Summary()

Summary prints final execution summary

func (*Reporter) SummaryQuick

func (r *Reporter) SummaryQuick(docCount int, duration time.Duration)

SummaryQuick prints a compact one-line summary

func (*Reporter) ThinkingContent

func (r *Reporter) ThinkingContent(text string)

ThinkingContent displays LLM thinking/reasoning content This is used when --llm-think is enabled to show intermediate reasoning

func (*Reporter) UpdateTokens

func (r *Reporter) UpdateTokens(inputTokens, outputTokens int)

UpdateTokens updates token statistics

func (*Reporter) WorkflowCompiled

func (r *Reporter) WorkflowCompiled(name string, jobCount, stepCount int)

WorkflowCompiled indicates successful workflow compilation

func (*Reporter) WorkflowError

func (r *Reporter) WorkflowError(err error)

WorkflowError reports a workflow-level error

func (*Reporter) WorkflowLoading

func (r *Reporter) WorkflowLoading(path string)

WorkflowLoading indicates workflow file is being loaded

type Silent added in v0.2.0

type Silent struct{}

Silent is a no-op implementation of ProgressBar that does nothing

func NewSilent added in v0.2.0

func NewSilent() *Silent

NewSilent creates a new silent progress reporter

func (*Silent) BatchComplete added in v0.2.0

func (s *Silent) BatchComplete()

BatchComplete does nothing

func (*Silent) BatchProgress added in v0.2.0

func (s *Silent) BatchProgress(processed, total int)

BatchProgress does nothing

func (*Silent) BatchStart added in v0.2.0

func (s *Silent) BatchStart(inputPath, outputPath string, mutable bool)

BatchStart does nothing

func (*Silent) ChunkingStart added in v0.2.0

func (s *Silent) ChunkingStart(strategy string, chunkCount int)

ChunkingStart does nothing

func (*Silent) DocumentComplete added in v0.2.0

func (s *Silent) DocumentComplete(path string, duration time.Duration)

DocumentComplete does nothing

func (*Silent) DocumentError added in v0.2.0

func (s *Silent) DocumentError(path string, err error)

DocumentError does nothing

func (*Silent) DocumentSkipped added in v0.2.0

func (s *Silent) DocumentSkipped(path string, reason string)

DocumentSkipped does nothing

func (*Silent) DocumentStart added in v0.2.0

func (s *Silent) DocumentStart(path string, sizeKB float64)

DocumentStart does nothing

func (*Silent) ForeachComplete added in v0.2.0

func (s *Silent) ForeachComplete(successCount, totalCount int, duration time.Duration)

ForeachComplete does nothing

func (*Silent) ForeachItem added in v0.2.0

func (s *Silent) ForeachItem(index, total int, status string)

ForeachItem does nothing

func (*Silent) ForeachStart added in v0.2.0

func (s *Silent) ForeachStart(itemCount int)

ForeachStart does nothing

func (*Silent) GetStats added in v0.2.0

func (s *Silent) GetStats() Stats

GetStats returns empty statistics

func (*Silent) RetryAttempt added in v0.2.0

func (s *Silent) RetryAttempt(attempt, maxAttempts int, delay time.Duration)

RetryAttempt does nothing

func (*Silent) RetryExhausted added in v0.2.0

func (s *Silent) RetryExhausted(maxAttempts int)

RetryExhausted does nothing

func (*Silent) RetrySuccess added in v0.2.0

func (s *Silent) RetrySuccess(attempt int)

RetrySuccess does nothing

func (*Silent) RouterDefault added in v0.2.0

func (s *Silent) RouterDefault(targetJob string)

RouterDefault does nothing

func (*Silent) RouterEvaluating added in v0.2.0

func (s *Silent) RouterEvaluating()

RouterEvaluating does nothing

func (*Silent) RouterMatched added in v0.2.0

func (s *Silent) RouterMatched(routeName string, targetJob string)

RouterMatched does nothing

func (*Silent) RouterNoMatch added in v0.2.0

func (s *Silent) RouterNoMatch()

RouterNoMatch does nothing

func (*Silent) SetForeachMode added in v0.2.0

func (s *Silent) SetForeachMode(inForeach bool)

SetForeachMode does nothing

func (*Silent) SetTokenSource added in v0.2.0

func (s *Silent) SetTokenSource(source TokenSource)

SetTokenSource does nothing

func (*Silent) StepComplete added in v0.2.0

func (s *Silent) StepComplete(jobName, stepName string, stepNum, totalSteps int, duration time.Duration, tokens int)

StepComplete does nothing

func (*Silent) StepError added in v0.2.0

func (s *Silent) StepError(jobName, stepName string, stepNum, totalSteps int, err error)

StepError does nothing

func (*Silent) StepProgress added in v0.2.0

func (s *Silent) StepProgress(message string)

StepProgress does nothing

func (*Silent) StepSkipped added in v0.2.0

func (s *Silent) StepSkipped(jobName, stepName string, stepNum, totalSteps int, reason string)

StepSkipped does nothing

func (*Silent) StepStart added in v0.2.0

func (s *Silent) StepStart(jobName, stepName string, stepNum, totalSteps int)

StepStart does nothing

func (*Silent) Summary added in v0.2.0

func (s *Silent) Summary()

Summary does nothing

func (*Silent) SummaryQuick added in v0.2.0

func (s *Silent) SummaryQuick(docCount int, duration time.Duration)

SummaryQuick does nothing

func (*Silent) ThinkingContent added in v0.2.0

func (s *Silent) ThinkingContent(text string)

ThinkingContent does nothing

func (*Silent) UpdateTokens added in v0.2.0

func (s *Silent) UpdateTokens(inputTokens, outputTokens int)

UpdateTokens does nothing

func (*Silent) WorkflowCompiled added in v0.2.0

func (s *Silent) WorkflowCompiled(name string, jobCount, stepCount int)

WorkflowCompiled does nothing

func (*Silent) WorkflowError added in v0.2.0

func (s *Silent) WorkflowError(err error)

WorkflowError does nothing

func (*Silent) WorkflowLoading added in v0.2.0

func (s *Silent) WorkflowLoading(path string)

WorkflowLoading does nothing

type Stats

type Stats struct {
	DocsProcessed int
	DocsSkipped   int
	DocsErrors    int
	TokensInput   int
	TokensOutput  int
	Errors        []error
}

Stats tracks processing metrics

type StepInfo

type StepInfo struct {
	// Nesting support for router and foreach
	Parent *StepInfo // Link to parent step (for nested jobs)

	JobName string
	JobSize int

	StepID   int
	StepName string

	// Retry-specific fields
	Attempt int
	Delay   int

	// ForEach-specific fields
	ItemIndex int // Current item (1-based), 0 = not in foreach
	ItemTotal int // Total items, 0 = not in foreach
}

StepInfo carries information about the current step execution

func GetStepInfo

func GetStepInfo(ctx context.Context) *StepInfo

GetStepInfo extracts step information from context

type TokenSource

type TokenSource interface {
	Usage() TokenUsage
	ProfileUsage() []ProfileTokenUsage
}

TokenSource interface for accessing token usage from LLM routers

type TokenUsage

type TokenUsage struct {
	InputTokens int
	ReplyTokens int
}

TokenUsage represents token usage statistics

Jump to

Keyboard shortcuts

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