ui

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 5 Imported by: 0

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

View Source
const (
	IconRead     = "\U0001F4C4" // πŸ“„
	IconGlob     = "\U0001F50D" // πŸ”
	IconGrep     = "\U0001F50E" // πŸ”Ž
	IconWeb      = "\U0001F310" // 🌐
	IconSearch   = "\U0001F50D" // πŸ” (web search)
	IconError    = "\u274C"     // ❌
	IconSuccess  = "\u2713"     // βœ“
	IconFile     = "\U0001F4C1" // πŸ“
	IconDuration = "\u23F1"     // ⏱
)

Icons

View Source
const MaxLineLength = 500

MaxLineLength is the maximum length of a content line

Variables ΒΆ

View Source
var (
	ColorSuccess = lipgloss.Color("#10B981") // green
	ColorError   = lipgloss.Color("#EF4444") // red
	ColorMuted   = lipgloss.Color("#6B7280") // gray
	ColorAccent  = lipgloss.Color("#60A5FA") // blue
	ColorWarn    = lipgloss.Color("#F59E0B") // yellow
	ColorMatch   = lipgloss.Color("#FBBF24") // yellow (highlight match)
	ColorBorder  = lipgloss.Color("#374151") // dark gray for borders
)

Colors

View Source
var (
	// Header box styles
	HeaderStyle = lipgloss.NewStyle().
				BorderStyle(lipgloss.RoundedBorder()).
				BorderForeground(ColorBorder).
				Padding(0, 1)

	HeaderTitleStyle = lipgloss.NewStyle().
						Bold(true).
						Foreground(ColorAccent)

	HeaderSubtitleStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color("#E5E7EB"))

	HeaderMetaStyle = lipgloss.NewStyle().
					Foreground(ColorMuted)

	// Content styles
	LineNumberStyle = lipgloss.NewStyle().
					Foreground(ColorMuted).
					Width(5).
					Align(lipgloss.Right)

	LineContentStyle = lipgloss.NewStyle()

	MatchStyle = lipgloss.NewStyle().
				Foreground(ColorMatch).
				Bold(true)

	FilePathStyle = lipgloss.NewStyle().
					Foreground(ColorAccent)

	TruncatedStyle = lipgloss.NewStyle().
					Foreground(ColorMuted).
					Italic(true)

	// Error styles
	ErrorStyle = lipgloss.NewStyle().
				Foreground(ColorError)

	ErrorMsgStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("#FCA5A5"))

	// Progress styles
	SpinnerStyle = lipgloss.NewStyle().
					Foreground(ColorWarn)

	ProgressMsgStyle = lipgloss.NewStyle().
						Foreground(ColorMuted)
)

Styles

View Source
var SpinnerFrames = []string{"β ‹", "β ™", "β Ή", "β Έ", "β Ό", "β ΄", "β ¦", "β §", "β ‡", "⠏"}

SpinnerFrames contains the spinner animation frames

Functions ΒΆ

func FormatDuration ΒΆ

func FormatDuration(d time.Duration) string

FormatDuration formats duration to human readable string

func FormatSize ΒΆ

func FormatSize(bytes int64) string

FormatSize formats bytes to human readable size

func FormatSkillSummary ΒΆ added in v1.2.0

func FormatSkillSummary(info *SkillResultInfo) string

FormatSkillSummary formats the skill result summary for display

Examples:

Loaded: git:commit [2 scripts, 1 ref]
Loaded: pdf [3 scripts]
Loaded: my-skill

func GetProgressMessage ΒΆ

func GetProgressMessage(toolName string, args string) string

GetProgressMessage returns the appropriate progress message for a tool

func RenderCompactHeader ΒΆ

func RenderCompactHeader(meta ResultMetadata) string

RenderCompactHeader renders a single-line header for compact display πŸ“„ Read: /path/to/file.go (2.4 KB Β· 85 lines Β· 12ms)

func RenderCompactResult ΒΆ

func RenderCompactResult(result ToolResult) string

RenderCompactResult renders a compact single-line result

func RenderErrorHeader ΒΆ

func RenderErrorHeader(toolName, errorMsg string, width int) string

RenderErrorHeader renders an error header box β”Œβ”€ Read ──────────────────────────────────────┐ β”‚ ❌ Error β”‚ β”‚ file not found: /path/to/missing.go β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

func RenderFileList ΒΆ

func RenderFileList(files []string, maxShow int) string

RenderFileList renders a list of file paths

src/main.go
src/utils/helper.go

func RenderGrepResults ΒΆ

func RenderGrepResults(lines []ContentLine, maxShow int) string

RenderGrepResults renders grep search results

main.go:42: // TODO: fix this
utils.go:15: // TODO: refactor

func RenderHeader ΒΆ

func RenderHeader(meta ResultMetadata, width int) string

RenderHeader renders the tool header box β”Œβ”€ Read ──────────────────────────────────────┐ β”‚ πŸ“„ /path/to/file.go β”‚ β”‚ 2.4 KB Β· 85 lines Β· 12ms β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

func RenderLines ΒΆ

func RenderLines(lines []ContentLine, showLineNo bool) string

RenderLines renders content lines with optional line numbers

1β”‚package main
2β”‚
3β”‚import "fmt"

func RenderProgress ΒΆ

func RenderProgress(spinnerFrame string, message string) string

RenderProgress renders an in-progress state β ‹ Reading file... β ™ Searching 42 files... β Ή Fetching https://example.com...

func RenderToolResult ΒΆ

func RenderToolResult(result ToolResult, width int) string

RenderToolResult renders a complete tool result with header and content

func TruncateText ΒΆ

func TruncateText(text string, maxLen int) string

TruncateText truncates text to maxLen with ellipsis

Types ΒΆ

type ContentLine ΒΆ

type ContentLine struct {
	LineNo int      // Line number (0 means no line number)
	Text   string   // Line content
	Type   LineType // Line type
	File   string   // File path (for grep results)
}

ContentLine represents a formatted content line

type LineType ΒΆ

type LineType int

LineType represents the type of content line

const (
	LineNormal    LineType = iota // Normal line
	LineMatch                     // Matched line (highlight)
	LineHeader                    // File header
	LineTruncated                 // Truncated indicator
)

type ResultMetadata ΒΆ

type ResultMetadata struct {
	Title      string        // Tool name
	Icon       string        // Tool icon
	Subtitle   string        // Short description (e.g., file path)
	Size       int64         // File/content size in bytes
	Duration   time.Duration // Execution duration
	LineCount  int           // Number of lines
	ItemCount  int           // Number of items (files/matches)
	StatusCode int           // HTTP status code (WebFetch)
	Truncated  bool          // Whether output was truncated
}

ResultMetadata contains metadata about tool execution result

type SkillResultInfo ΒΆ added in v1.2.0

type SkillResultInfo struct {
	SkillName   string // Full skill name (namespace:name)
	ScriptCount int    // Number of scripts in skill
	RefCount    int    // Number of reference files
}

SkillResultInfo contains skill-specific result metadata for custom rendering

type ToolResult ΒΆ

type ToolResult struct {
	Success   bool             // Whether the tool succeeded
	Output    string           // Main output content
	Error     string           // Error message if failed
	Metadata  ResultMetadata   // Result metadata
	Lines     []ContentLine    // Formatted content lines (optional)
	Files     []string         // File list (for Glob)
	SkillInfo *SkillResultInfo // Skill-specific info (for Skill tool)
}

ToolResult represents the result of a tool execution

func NewErrorResult ΒΆ

func NewErrorResult(title, errorMsg string) ToolResult

NewErrorResult creates an error result

func NewSuccessResult ΒΆ

func NewSuccessResult(title, icon, subtitle string, size int64, lineCount, itemCount int, duration time.Duration) ToolResult

NewSuccessResult creates a success result with metadata

func (ToolResult) FormatForLLM ΒΆ

func (r ToolResult) FormatForLLM() string

FormatForLLM returns a plain text representation of the result for LLM consumption

Jump to

Keyboard shortcuts

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