repl

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SkipProjectConfig bool

SkipProjectConfig disables loading GOCODE.md/CLAUDE.md into the system prompt.

Functions

func BuildSystemPrompt

func BuildSystemPrompt(tools []apitypes.ToolDef) string

BuildSystemPrompt constructs the system prompt for the agent. Modeled after Claude Code's agentic behavior — proactive, autonomous, thorough.

func PrintBanner

func PrintBanner(w io.Writer, cfg BannerConfig)

PrintBanner renders the OpenCode-style welcome screen with Go blue GOCODE branding.

func ReadInput

func ReadInput(scanner *bufio.Scanner) (string, error)

ReadInput reads a potentially multi-line input from the reader. Lines ending with backslash are treated as continuations.

func RenderMarkdown added in v0.2.2

func RenderMarkdown(text string) string

RenderMarkdown converts markdown text to ANSI-colored terminal output.

func RenderToolOutput added in v0.2.2

func RenderToolOutput(name string, output string, isError bool) string

RenderToolOutput formats tool output with dimmed styling.

func RunOneShot

func RunOneShot(ctx context.Context, rt *agent.ConversationRuntime, prompt string, stream bool, w io.Writer) error

RunOneShot runs a single prompt through the agent and prints the result.

Types

type BannerConfig

type BannerConfig struct {
	Version   string
	Model     string
	MaxTurns  int
	Cwd       string
	BuddyLine string // optional — empty means no buddy
}

BannerConfig holds the info displayed in the welcome banner.

type Display

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

Display handles rendering of streaming events and tool status to the terminal.

func NewDisplay

func NewDisplay(w io.Writer) *Display

NewDisplay creates a new Display writing to w.

func (*Display) Error

func (d *Display) Error(err error)

Error displays an error message.

func (*Display) PermissionPrompt

func (d *Display) PermissionPrompt(toolName, operation string)

PermissionPrompt displays a permission request.

func (*Display) PermissionPromptExtended added in v0.8.1

func (d *Display) PermissionPromptExtended(toolName, operation string)

PermissionPromptExtended displays a permission request with trust options.

func (*Display) RenderResponse added in v0.2.2

func (d *Display) RenderResponse(resp *apitypes.MessageResponse)

RenderResponse renders a full message response with markdown formatting.

func (*Display) StreamEvent

func (d *Display) StreamEvent(ev apitypes.StreamEvent)

StreamEvent renders a single stream event incrementally.

func (*Display) Usage

func (d *Display) Usage(usage string)

Usage displays token usage.

type REPL

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

REPL provides the interactive terminal chat interface.

func NewREPL

func NewREPL(rt *agent.ConversationRuntime, r io.Reader, w io.Writer, cfg REPLConfig, sk []skills.Skill) *REPL

NewREPL creates a new REPL.

func (*REPL) Run

func (r *REPL) Run(ctx context.Context) error

Run starts the interactive REPL loop.

func (*REPL) SetBuddy added in v0.9.0

func (r *REPL) SetBuddy(b *buddy.Companion)

SetBuddy sets the terminal companion displayed in the banner.

func (*REPL) SetCheckpointManager added in v0.9.0

func (r *REPL) SetCheckpointManager(mgr *checkpoint.Manager)

SetCheckpointManager sets the checkpoint manager for /undo support.

func (*REPL) SetDreamEngine added in v0.9.0

func (r *REPL) SetDreamEngine(d *dream.Dreamer)

SetDreamEngine sets the dream engine for idle/session-end memory consolidation.

func (*REPL) SetOutputStyle added in v0.9.0

func (r *REPL) SetOutputStyle(style string)

SetOutputStyle sets the active output style.

func (*REPL) SetUltraPlanner added in v0.9.0

func (r *REPL) SetUltraPlanner(p *ultraplan.Planner)

SetUltraPlanner sets the ultraplan planner for /ultraplan support.

func (*REPL) SetVoiceListener added in v0.9.0

func (r *REPL) SetVoiceListener(l *voice.Listener)

SetVoiceListener sets the voice listener for /voice support.

func (*REPL) SetWorktreeManager added in v0.9.0

func (r *REPL) SetWorktreeManager(mgr *worktree.Manager)

SetWorktreeManager sets the worktree manager for /worktree support.

type REPLConfig

type REPLConfig struct {
	Version  string
	Model    string
	MaxTurns int
}

REPLConfig holds configuration for the REPL display.

type SlashCommand

type SlashCommand int

SlashCommand represents a parsed slash command.

const (
	CmdNone SlashCommand = iota
	CmdExit
	CmdClear
	CmdCost
	CmdPlan
	CmdInitDeep
	CmdSkill
	CmdCompact
	CmdModel
	CmdHelp
	CmdDiff
	CmdUndo
	CmdStatus
	CmdReview
	CmdPermissions
	CmdDoctor
	CmdRedo
	CmdConnect
	CmdShare
	CmdCommit
	CmdMemory
	CmdTasks
	CmdWorktree
	CmdVoice
	CmdUltraPlan
	CmdVim
	CmdOutputStyle
)

func ParseSlashCommand

func ParseSlashCommand(input string) SlashCommand

ParseSlashCommand checks if input is a slash command.

type Spinner added in v0.2.1

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

Spinner shows an animated loading indicator. It is restartable — Stop/Start can be called multiple times.

func NewSpinner added in v0.2.1

func NewSpinner(w io.Writer, message string) *Spinner

NewSpinner creates a spinner that writes to w.

func (*Spinner) Start added in v0.2.1

func (s *Spinner) Start()

Start begins the spinner animation in a goroutine. Safe to call multiple times — restarts if already stopped.

func (*Spinner) Stop added in v0.2.1

func (s *Spinner) Stop()

Stop halts the spinner and clears the line. Safe to call multiple times or when not running.

func (*Spinner) UpdateMessage added in v0.2.1

func (s *Spinner) UpdateMessage(msg string)

UpdateMessage changes the spinner text while running.

type TerminalPermissionPrompter

type TerminalPermissionPrompter struct {
	Scanner *bufio.Scanner
	Writer  io.Writer
	Trusted *agent.TrustedToolStore
}

TerminalPermissionPrompter prompts the user in the terminal for permission.

func (*TerminalPermissionPrompter) Prompt

func (p *TerminalPermissionPrompter) Prompt(toolName string, operation string) (bool, error)

Prompt asks the user for permission, showing the tool name and params. Options: y=yes once, n=deny, a=always trust this tool, t=trust tool:command prefix

type TerminalToolCallback added in v0.2.1

type TerminalToolCallback struct {
	Writer  io.Writer
	Spinner *Spinner
}

TerminalToolCallback updates the terminal during tool execution. It stops the spinner before showing tool progress.

func (*TerminalToolCallback) OnToolEnd added in v0.2.1

func (t *TerminalToolCallback) OnToolEnd(name string, success bool)

func (*TerminalToolCallback) OnToolStart added in v0.2.1

func (t *TerminalToolCallback) OnToolStart(name string, input map[string]interface{})

Jump to

Keyboard shortcuts

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