repl

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package repl provides the exec mode runner for the agent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureSessionTitle

func EnsureSessionTitle(ctx context.Context, cfg *config.Config, sess *session.Session, promptText string, haveUserMsg bool, writer *ui.Writer) string

EnsureSessionTitle sets the session's display title once, at the start of a session, and reports what it set ("" when there was nothing to title). An existing title is left alone, so this is a no-op after the first turn.

The title is a 3-6 word summary of the first prompt from the `summarizer: true` models: entry (see Config.SummarizerEntry). When no entry is flagged, or the call fails or returns nothing usable, the title falls back to the prompt's first words.

It sets meta.Title but does not save: the RunExec caller saves meta.json once with FirstPrompt and Title together. Tests can read sess.Meta().Title without saving.

func RunExec

func RunExec(ctx context.Context, runner *agent.Runner, writer *ui.Writer, cfg *config.Config, systemPrompt string, promptText string, quietMode bool, sess *session.Session, projectInstructions *ProjectInstructions, imagePaths []string) error

RunExec runs one turn: load the session's conversation, put the prompt to the model, and append what the turn produces to the session's history.

History is appended to rather than rewritten, and written as the turn goes rather than at the end of it: the prompt up front, then the model's turn and each tool result as each happens. So a crash costs one message rather than a turn, and "tail -f" on history.jsonl follows a turn while it runs. When the loop backtracks over messages that are already written, the discard is recorded as its own line, which keeps the file append-only and leaves the abandoned attempt visible. RunExec returns the error that ended the turn, or nil when the turn finished. The caller turns that into the process's exit status: a turn whose model call failed used to exit 0, which left a wrapper or a CI job unable to tell a failed turn from a successful one.

func RunTurn added in v0.2.0

func RunTurn(ctx context.Context, runner *agent.Runner, writer *ui.Writer, cfg *config.Config, systemPrompt string, promptText string, quietMode bool, sess *session.Session, projectInstructions *ProjectInstructions, imagePaths []string, observe func([]llm.Message)) (*agent.RunResult, error)

RunTurn is RunExec for a caller that reports the turn somewhere else as well: observe, when set, is handed each batch of messages right after the session has recorded it, which is while the turn runs. It returns the loop's result, or the error that stopped the loop.

Types

type ProjectInstructions

type ProjectInstructions struct {
	Path    string
	Content string
}

ProjectInstructions is a project-local instruction file loaded at startup.

func LoadProjectInstructions

func LoadProjectInstructions(cfg *config.Config, launchDir string) (*ProjectInstructions, error)

LoadProjectInstructions loads the configured project instruction file. Missing or empty files are treated as absent.

Jump to

Keyboard shortcuts

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