agent

package
v0.0.0-...-9a07f48 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const MARGIN = 2

Variables

View Source
var (
	// SnowTheme uses cold, winter-inspired true colors
	// Official snowflake color: #6EC8FF (110, 200, 255)
	SnowTheme = Theme{
		Name:        "snow",
		DefaultText: color.RGB(255, 255, 255),
		Stdout:      color.RGB(80, 140, 180),

		Stderr:         color.RGB(255, 150, 150),
		ExitCode:       color.RGB(255, 100, 100),
		Reasoning:      color.RGB(200, 180, 255),
		UserMargin:     color.RGB(180, 140, 255),
		HinataLine:     color.RGB(110, 200, 255),
		QuerentLine:    color.RGB(220, 160, 255),
		TurnNumber:     color.RGB(160, 255, 200),
		ErrorHighlight: color.RGB(255, 120, 120),
		StatusMessage:  color.RGB(150, 150, 150),
		Spinner:        color.RGB(110, 200, 255),
		ShellBlockCode: color.RGB(110, 200, 255),
		HelpText:       color.RGB(160, 200, 255),
		Background:     color.RGB(0, 0, 0),
		FallbackLine:   color.RGB(255, 255, 255),

		DefaultTextRGB: &[3]int{255, 255, 255},
		HinataLineRGB:  &[3]int{110, 200, 255},
		HelpTextRGB:    &[3]int{160, 200, 255},
		BackgroundRGB:  &[3]int{0, 0, 0},
	}

	// DustTheme uses grayscale values for a muted, dusty appearance
	// Like looking through a dusty window - everything is visible but muted
	DustTheme = Theme{
		Name:           "dust",
		DefaultText:    color.RGB(220, 220, 220),
		Stdout:         color.RGB(160, 160, 160),
		Stderr:         color.RGB(200, 200, 200),
		ExitCode:       color.RGB(200, 200, 200),
		Reasoning:      color.RGB(180, 180, 180),
		UserMargin:     color.RGB(140, 140, 140),
		HinataLine:     color.RGB(190, 190, 190),
		QuerentLine:    color.RGB(170, 170, 170),
		TurnNumber:     color.RGB(210, 210, 210),
		ErrorHighlight: color.RGB(240, 240, 240),
		StatusMessage:  color.RGB(130, 130, 130),
		Spinner:        color.RGB(190, 190, 190),
		ShellBlockCode: color.RGB(200, 200, 200),
		HelpText:       color.RGB(170, 170, 170),
		Background:     color.RGB(20, 20, 20),
		FallbackLine:   color.RGB(220, 220, 220),

		DefaultTextRGB: &[3]int{220, 220, 220},
		HinataLineRGB:  &[3]int{190, 190, 190},
		HelpTextRGB:    &[3]int{170, 170, 170},
		BackgroundRGB:  &[3]int{20, 20, 20},
	}

	// AnsiTheme uses standard ANSI colors (terminal-configurable)
	AnsiTheme = Theme{
		Name:           "ansi",
		DefaultText:    color.New(color.FgWhite),
		Stdout:         color.New(color.FgCyan),
		Stderr:         color.New(color.FgRed),
		ExitCode:       color.New(color.FgRed),
		Reasoning:      color.New(color.FgYellow),
		UserMargin:     color.New(color.FgMagenta),
		HinataLine:     color.New(color.FgBlue),
		QuerentLine:    color.New(color.FgMagenta),
		TurnNumber:     color.New(color.FgGreen),
		ErrorHighlight: color.New(color.FgRed),
		StatusMessage:  color.New(color.FgHiBlack),
		Spinner:        color.New(color.FgCyan),
		ShellBlockCode: color.New(color.FgGreen),
		HelpText:       color.New(color.FgCyan),
		Background:     color.New(color.BgBlack),
		FallbackLine:   color.New(color.FgWhite),
	}
)

Themes

Functions

This section is empty.

Types

type Agent

type Agent struct {
	ConversationDir string
	SystemPrompt    string
	Model           string
	IgnoreReasoning bool
	NoConfirm       bool
	NoEscape        bool
	ShellDisplay    bool
	UseJSON         bool
	SpinnerIndex    *int
	SpinnerFile     string
	UseEditor       bool
	AutoExit        bool
	PromptHeight    int
	UseV2Streaming  bool // Use the new OutputCoordinator-based streaming
	// contains filtered or unexported fields
}

func New

func New(cfg Config) (*Agent, error)

func (*Agent) EnableBufferedStreaming

func (a *Agent) EnableBufferedStreaming()

EnableBufferedStreaming switches the agent to use line-buffered streaming

func (*Agent) Run

func (a *Agent) Run(userMessage string) error

type Config

type Config struct {
	ConversationDir string
	SystemPrompt    string
	Model           string
	PWD             string
	IgnoreReasoning bool
	NoConfirm       bool
	NoEscape        bool
	ShellDisplay    bool
	UseJSON         bool
	SpinnerIndex    *int
	SpinnerFile     string
	UseEditor       bool
	AutoExit        bool
	Theme           string
	PromptHeight    int
	ShellStartup    string
	UseV2Streaming  bool // Use the new OutputCoordinator-based streaming
}

type ParseResult

type ParseResult struct {
	BeforeTag   string // Text before any tag
	TagFound    string // The tag that was found (if any)
	AfterTag    string // Text after the tag
	HasOpenTag  bool   // True if <shell> was found
	HasCloseTag bool   // True if </shell> was found
}

ParseResult contains the results of parsing a chunk of text

type TagParser

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

TagParser handles detection of <shell> and </shell> tags across streaming token boundaries

func NewTagParser

func NewTagParser(logger *log.Logger) *TagParser

NewTagParser creates a new tag parser

func (*TagParser) IsInShellBlock

func (p *TagParser) IsInShellBlock() bool

IsInShellBlock returns true if we're currently inside a shell block

func (*TagParser) Parse

func (p *TagParser) Parse(chunk string) []ParseResult

Parse processes a chunk of text, detecting tags and returning the content

type Theme

type Theme struct {
	Name           string
	DefaultText    *color.Color // Default text color
	Stdout         *color.Color
	Stderr         *color.Color
	ExitCode       *color.Color
	Reasoning      *color.Color
	UserMargin     *color.Color
	HinataLine     *color.Color
	QuerentLine    *color.Color
	TurnNumber     *color.Color
	ErrorHighlight *color.Color
	StatusMessage  *color.Color // For status messages like "Executing command"
	Spinner        *color.Color // For spinner text
	ShellBlockCode *color.Color // For code inside <shell> blocks
	HelpText       *color.Color // For help text in selectors and editors
	Background     *color.Color // For background in selectors and editors
	FallbackLine   *color.Color // Fallback line color for unknown roles

	// RGB values for snow theme (nil for ansi theme)
	DefaultTextRGB *[3]int
	HinataLineRGB  *[3]int
	HelpTextRGB    *[3]int
	BackgroundRGB  *[3]int
}

Theme defines the color scheme for the agent UI

func GetTheme

func GetTheme(name string) Theme

GetTheme returns the theme based on name

Jump to

Keyboard shortcuts

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