repl

package
v1.5.177 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 44 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

This file implements the manual `/dream` REPL command (SPEC §4.1, US-007): it spawns the process-isolated memory-consolidation subprocess (`golder --dream [--dream-dry-run] -C <projectDir>`) and renders the returned Report as a full-table change report. The spawn/lock/render plumbing is shared with the TUI and lives in internal/cli/dreamcmd.

This file wires the startup background trigger for /dream memory consolidation (US-008, FR-4/FR-17): when an interactive REPL session starts, if dream.enabled and a consolidation is due (per dream.State.Due), the dream subprocess is spawned in the BACKGROUND so it never delays the first user response, and a non-intrusive one-line summary is printed on completion.

The decision + goroutine live in dream.Scheduler; this file only supplies the CLI-side spawn seam (reusing dreamcmd.Spawn) and the one-line notice renderer (dreamcmd.RenderReportLine). The subprocess's O_EXCL lock enforces single-instance, so a second trigger just yields a skipped child (silent).

This file makes replDeps satisfy cli.Host: the accessor and mutator methods let the /goal, /btw, /status and REPL logic reach the session's collaborators and mutable state through the cli.Host contract rather than the concrete aggregate. The compile-time assertion below fails the build if replDeps drifts out of conformance.

This file wires the line-based REPL (US-003) and session persistence (US-024, #43) into the golder command. When invoked without a prompt on a terminal, golder starts the REPL loop (see repl.go); each run's messages are persisted to a local JSONL session so the conversation can be listed, resumed and replayed later.

This file wires the remote-control bridge (internal/remotecontrol, #442) into the interactive REPL (#443). It adds the "/remote-control" command that starts/stops an in-process HTTP+WebSocket server mirroring the session to a paired browser on the LAN, tees REPL output to that browser, merges browser-submitted prompts into the input loop, and routes tool-call confirmations to the browser while a client is connected.

The design keeps the non-remote path byte-identical: when no remote session is active, teeWriter forwards only to stdout, the input select degenerates to a plain editor read (the remote channel is nil), and confirmations use the local stdin prompt unchanged.

This file implements the line-based interactive REPL (US-003/#106), the --no-tui path (the full-screen TUI in internal/cli/tui is the default front-end). It runs a simple read → run → stream-print loop over a persisted session: no full-screen rendering, no popup menus, no viewport — a prompt, the agent's streamed reply, and a new prompt.

The REPL is a synchronous loop on the main goroutine: it reads one line, resolves slash-commands, launches an agent run, drains the run's event stream to stdout as it streams, persists the session, and returns to the prompt. A SIGINT during a run cancels that run's context and returns to the prompt; when idle, the reader sees EOF/interrupt and exits cleanly.

This file is the REPL's half of the multiplexer reporting (see internal/hostcompat): the moments the line-based driver knows about, wired onto the session it already assembles.

It mirrors internal/cli/tui/sessionhost.go, deliberately: the two drivers report the same session state the same way, and every decision about what a state means lives in internal/hostcompat so they cannot drift apart. What is here is only *when* the REPL knows.

This file implements the /rewind command (edit checkpoint / rewind): golder's analogue of Claude Code's Esc-Esc rewind. Where /tree only moves the conversation leaf, /rewind also restores the working tree — it replays the file-snapshot journal (see agenttool.FileSnapshotRecorder) so a turn's write and edit mutations are rolled back, then switches the active conversation leaf to the point before that turn. The two together return the session to an earlier state in code and dialogue at once.

Scope (v1): only golder's own write/edit tools are journaled. Files changed by bash commands are not captured and are left untouched by a rewind.

This file wires the `!command` passthrough into the REPL. A passthrough command runs locally — no model call, no approval, no sandbox — and its settled record joins the shared context as a user-role <user_shell_command> message, so the next prompt's model sees what the user ran (codex parity; the TUI implements the same escape hatch in internal/cli/tui/usershell.go).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(opts Options) error

Run starts the line-based REPL over a persisted session. It keeps a single growing AgentContext across prompts (so turns share history) and saves the session's messages after each run completes (see runREPL/streamRun in repl.go).

Types

type Options

type Options struct {
	Model        string
	ProviderName string
	Provider     provider.Provider
	BaseURL      string
	APIKey       string
	Protocol     string
	// Credentials is the shared resolver assembled by run.SetupEnv. APIKey is
	// retained for embedders that construct Options directly.
	Credentials *provider.CredentialStore
	// Version is the build-time version string ("dev" for source builds, a real
	// "vX.Y.Z" for released binaries). It feeds the cached latest-release check so
	// the REPL prints the same one-line upgrade hint as the TUI banner. Mirrors
	// tui.Options.Version; dev/unparseable values never show the hint.
	Version string
	// ThinkingLevel is the resolved reasoning-effort level (US-023): it seeds the
	// live run config so every REPL turn requests it, until a control command
	// changes it.
	ThinkingLevel agentcore.ThinkingLevel
	Tools         []agentcore.AgentTool
	SysPrompt     string

	// Prompt is the launch context SysPrompt was built from (user-authored base
	// and appends, working directory, skills, tools). A resumed session rebuilds
	// its prompt through it — see cli.ResumeSystemPrompt — so the guide and
	// environment come from THIS binary while the session's own user inputs are
	// preserved.
	Prompt runtime.PromptInputs

	// ResumeID, when non-empty, resumes an existing session: its messages seed
	// the context and replayed transcript. Otherwise a fresh session is created.
	ResumeID string

	// Approve, when true, grants the launch directory session trust before the
	// run so the first-launch trust prompt is skipped and side-effect tools run
	// without per-call confirmation (mirrors pi's --approve/-a).
	Approve bool
	// Skills is the pre-loaded skill set (loaded once by setupAgentEnv, shared
	// with prompt injection). Each is registered as a /skill-name command. Empty
	// under --no-skills, so nothing is registered.
	Skills []*runtime.Skill

	Extensions *extensions.Manager

	// ConfigPrompts holds prompt-template paths from the config.toml `prompts`
	// array (settings tier); each is a file or dir loaded non-recursively.
	ConfigPrompts []string
	// CliPrompts holds --prompt-template paths (CLI tier, repeatable).
	CliPrompts []string
	// NoPromptTemplates disables all prompt-template discovery (global, project,
	// settings, CLI); built-in slash commands are unaffected. Independent of
	// --no-skills.
	NoPromptTemplates bool

	// Dream is the resolved [dream] configuration (US-008). Run uses it to decide
	// whether to launch the startup background consolidation; a zero value
	// (Enabled false) disables the auto-trigger entirely.
	Dream dream.Config

	// Permissions is the live approval mode shared with the tool set (created
	// by run.SetupEnv). /permissions mutates it in place. Nil falls back to a
	// private auto state.
	Permissions *permissions.State
	// ReviewNotes is the announcement sink for mode decisions (approvals,
	// sandbox routing, denials), shared with the gates. The REPL registers a
	// handler that prints each note to the current output.
	ReviewNotes *run.ReviewNotes

	// Budget is the session-scoped context-window budget (created by
	// run.SetupEnv) shared by every run of the session, so the low-budget
	// reminder ladder and get_context_remaining stay consistent across prompts.
	// A nil value falls back to a run-local state.
	Budget *contextbudget.State

	// MaxContext is the resolved [compaction] max_context value: a token count
	// or window fraction that lowers the auto-compaction trigger point. The
	// zero value leaves the defaults.
	MaxContext config.MaxContext
}

Options carries the resolved run configuration plus optional resume state into Run.

Jump to

Keyboard shortcuts

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