cli

package
v1.5.122 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 29 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

Package cli is the contract and shared-type layer for golder's command-line surface. It holds the interfaces and value types that the cmd/golder entry point and the internal/cli/* subpackages share, plus the assembly helpers those subpackages are built from (host.go, liveconfig.go, persist.go, the boundary path accessors).

Subpackage layout:

internal/cli            — Host/Editor contracts, LiveConfig, TelemetryHolder
internal/cli/ui         — color, markdown, imageref helpers
internal/cli/config     — config-file loading and overrides
internal/cli/run        — run assembly and tool wiring
internal/cli/headless   — headless session and subagent RPC drivers
internal/cli/goal       — /goal state machine
internal/cli/btw        — /btw side thread
internal/cli/status     — /status command
internal/cli/repl       — interactive REPL and line editor
internal/cli/tui        — full-screen terminal UI
internal/cli/prompts    — slash-command registrations and their help text
internal/cli/sessioncmd — the session subcommand
internal/cli/dreamcmd   — the dream subcommand
internal/cli/hostcmd    — the host-compat subcommand
internal/cli/memstatus  — memory status helpers
internal/cli/testutil   — cross-subpackage test helpers

The Host interface (see host.go) is the seam that lets the /goal, /btw, /status and REPL subpackages read and mutate the session's live state without importing the concrete replDeps aggregate that assembles it.

This file defines the Host and Editor contracts that let the /goal, /btw, /status and REPL subpackages read and mutate a session's live state without importing the concrete replDeps aggregate that assembles it (see doc.go). The aggregate implements Host by exposing accessor and mutator methods over its fields; the line editor implements Editor.

This file defines LiveConfig, the mutable run configuration a control command may change mid-session. It was moved verbatim from cmd/golder (the former liveRunConfig) and exported so the run, repl, btw, status and goal subpackages can read and mutate it through the Host contract. The run closure reads it on every prompt, so a /model switch takes effect on the next turn. It carries no lock: it is read and written only on the REPL's single main goroutine (slash actions and the run are both invoked synchronously from the REPL loop, never concurrently).

This file holds PersistTurn, the session-tree persistence step shared by the REPL loop and the /goal autonomous loop. It reads and advances a session's mutable cursor state through the Host contract, so a command need not import the concrete replDeps aggregate to persist the tail of a turn.

This file holds ProviderHelp, the "--help" provider block moved from cmd/golder (US-004, #361). It enumerates the built-in provider registry so the values accepted by --provider (and their env vars / default base URLs / protocols) stay in sync with the code rather than being hand-maintained.

This file implements the telemetry holder that retains per-run telemetry events (US-001, #291) and folds them into a cumulative accumulator for the /status command to display. It was moved verbatim from cmd/golder (telemetry_state.go, US-013) into the shared cli layer so the status and repl subpackages share one holder type.

This file implements the `!command` shell passthrough shared by the TUI and the REPL. A passthrough command runs locally — no model call, no approval, no sandbox; it is the user's explicit full-access escape hatch, mirroring codex's user shell command. Its output streams back to the caller, and once it settles the command plus its exit result is recorded in the conversation as a user-role <user_shell_command> message, so the model sees exactly what the user ran and what came back.

Index

Constants

View Source
const (
	ReadableSourceSaved   = "grants.json"
	ReadableSourceSession = "session"
)

Where a readable path comes from; displayed next to the path. The remembered label names the file the row lives in, and the session label marks what dies with the process.

View Source
const (
	WritableSourceSaved   = ReadableSourceSaved
	WritableSourceSession = ReadableSourceSession
)

Where a writable path comes from; displayed next to the path.

View Source
const AllSessionsFlag = "--all"

AllSessionsFlag lifts the default project filter on a resume view, listing every project's sessions — the shape `codex resume --all` established.

View Source
const DefaultContextWindow = 1000000

DefaultContextWindow is the fallback context-token budget used when a model's true window is unknown. It is deliberately large so auto-compaction only fires on genuinely long sessions (threshold = window - ReserveTokens), never on ordinary short exchanges.

View Source
const ResumeListN = 10

ResumeListN is how many recent sessions a bare /resume view lists.

Variables

View Source
var ErrLineInterrupted = errors.New("line input interrupted")

ErrLineInterrupted is returned by an Editor.ReadLine when the user hits an idle Ctrl+C at the prompt (rather than during a run). Control commands that run their own follow-up loop (e.g. /btw) check for it with errors.Is to leave the loop cleanly. It lives here, beside the Editor contract, so a subpackage can recognize the interrupt without importing the concrete line editor.

View Source
var ErrResumeNoSelector = errors.New("no session selector")

ErrResumeNoSelector reports a /resume invocation with no selector at all. Both front-ends answer that case by listing the recent sessions (see the bare form in the command's own hint), so this is a guard rather than a message users meet — and it carries no usage line on purpose: the grammar belongs to the registry, which this package cannot reach (cli/prompts imports cli). A literal here would be a second spelling of a grammar nothing in this package can check.

Functions

func AddReadablePath added in v1.2.17

func AddReadablePath(raw string) (path string, err error)

AddReadablePath grants a directory for reading and persists it, so the next launch applies it without asking. The validation is the table's (grants.AddReadRoot refuses a root too broad to be a boundary), so a typo cannot turn into "read everything" whichever front-end made it.

func AddWritablePath added in v1.2.3

func AddWritablePath(raw string) (path string, err error)

AddWritablePath grants a path read+write inside the sandbox and persists it, so the next launch applies it without asking. One row answers both sides, because a file you may write and not read back is a half-failure.

func CompactionSettingsFor added in v1.2.18

func CompactionSettingsFor(maxContext config.MaxContext, contextWindow int) compaction.CompactionSettings

CompactionSettingsFor resolves the compaction thresholds for a window, with the configured compaction max_context applied. Drivers that do not carry a LiveConfig (headless -p, the SDK) call it directly so the knob works there too. max_context only lowers the trigger point (see CompactionSettings.MaxContextTokens).

func DisplayHomePath added in v1.2.3

func DisplayHomePath(p string) string

DisplayHomePath shortens a path under $HOME to "~/…" for display; the grant itself always uses the full path. It is ui's implementation, kept under this name because every caller in this package (and the TUI's pickers, which share the wording) reads it as cli's.

func FilterSessions added in v1.2.16

func FilterSessions(headers []session.SessionHeader, scope ResumeScope, n int) []session.SessionHeader

FilterSessions returns the headers in scope, preserving the store's newest-first order and capping the result at n (n <= 0 means no cap).

func FormatContextWindow added in v1.2.14

func FormatContextWindow(tokens int) string

FormatContextWindow renders a context-token budget compactly for model lists and switch confirmations: 200000 → "200K", 1048576 → "1.05M", 1000000 → "1M". A non-positive budget (the catalog does not know the model) returns "", so callers can omit the field rather than print a fake zero.

func HostGates added in v1.2.17

func HostGates(host Host, out io.Writer) *run.Gates

HostGates assembles a session's gate chain from the Host contract, so a command that drives its own run (/goal, /btw) inherits exactly the gates of the run that invoked it rather than re-listing them. It is the same run.Gates the main run installs; only the output writer differs, which is why the caller passes the writer its run prints to.

func HostReviewer added in v1.2.17

func HostReviewer(host Host) judge.Classifier

HostReviewer builds the reviewer for the session's active model, rebuilt per chain so a /model switch changes the reviewer with the conversation.

func MostRecentSession added in v1.2.16

func MostRecentSession(store *session.Store, scope ResumeScope) (session.SessionHeader, bool, error)

MostRecentSession returns the most recently updated session in scope; ok is false when the scope holds none. The caller decides what an empty project means: --continue falls back to the newest session of any project and names the directory it came from.

func PersistTurn

func PersistTurn(out io.Writer, h Host)

PersistTurn appends the messages produced since the last persist as a new branch descending from the host's current leaf, advancing the leaf and the persisted-message cursor. Growing the tree with AppendBranch (rather than a full linear Save) is what lets a later /tree leaf-switch fork the on-disk history instead of clobbering it. If nothing new was produced it is a no-op: rewriting the file would regenerate entry ids and flatten the tree.

func PrintProviderHelp

func PrintProviderHelp(w io.Writer)

PrintProviderHelp writes the "Supported providers" block appended to `--help` output. It enumerates the built-in provider registry so the list of values accepted by --provider (and their env vars / default base URLs / protocols) stays in sync with the code rather than being hand-maintained.

func ReadableSourceLabel added in v1.2.17

func ReadableSourceLabel(source string, zh bool) string

ReadableSourceLabel renders the provenance of a readable path for the human, in the conversation's language.

func RecentSessions

func RecentSessions(store *session.Store, scope ResumeScope, n int) ([]session.SessionHeader, error)

RecentSessions returns up to n most-recently-updated session headers in scope (the store already sorts newest-first). It backs the bare-/resume picker in every frontend so the list — and therefore the 1-based numbering — is identical everywhere.

func ResolveContextWindow added in v1.2.13

func ResolveContextWindow(providerName, model string) int

ResolveContextWindow resolves the context-token budget for a (provider, model) pair: the value models.dev publishes when its catalog knows the model, DefaultContextWindow otherwise. The catalog is read from the same 24h disk cache the reasoning ladder uses, so this never blocks on the network; a model the catalog does not cover (custom base URL, brand-new release) keeps the historical 1M fallback.

func ResolveResumeID

func ResolveResumeID(store *session.Store, arg, projectDir string) (string, error)

ResolveResumeID maps a /resume argument to a session id: a 1-based number selects the nth session of the scope's recent list (the same list the caller displayed, so the numbering always agrees), anything else is treated as a literal id and resolves globally — an exact id is unambiguous, so it is never narrowed by the project filter. An empty argument is a usage error; callers show the recent list instead.

func ResumeEmptyMessage added in v1.2.16

func ResumeEmptyMessage(store *session.Store, scope ResumeScope) string

ResumeEmptyMessage explains an empty scoped list: either the store really is empty, or the project filter is hiding other projects' sessions — in which case it names the flag that shows them.

func ResumeHiddenHint added in v1.2.16

func ResumeHiddenHint(store *session.Store, scope ResumeScope, shown int) string

ResumeHiddenHint reports how many sessions the project filter (or the list cap) is keeping out of a shown list, phrased for a dim trailing line; "" when nothing is hidden or the list is already unfiltered.

func ResumeScopeLabel added in v1.2.16

func ResumeScopeLabel(scope ResumeScope) string

ResumeScopeLabel describes a scope for a header line: the project directory it is anchored at, shortened for display, or "all projects" when unfiltered.

func ResumeSystemPrompt added in v1.2.16

func ResumeSystemPrompt(h session.SessionHeader, launch runtime.PromptInputs) string

ResumeSystemPrompt returns the system prompt a resumed session should run under: the current binary's guide, environment block, AGENTS.md and skills, with the user-authored inputs preserved — the session's recorded --system-prompt base and --append-system-prompt blocks, plus this launch's flags, which win where given (passing a flag means the user is telling us now).

A session written before the header recorded those inputs has none, so its stored prompt is replaced outright by a freshly built one. That is the point of the change — but it does mean a custom base in such a session (if one ever existed; every session on this machine is the default) is not recoverable, because the input was never kept.

A rebuild failure (an AGENTS.md that exists but cannot be read) falls back to the stored prompt: a resume must not break over a file it did not need.

func ScopedSessions added in v1.2.16

func ScopedSessions(store *session.Store, scope ResumeScope, n int) (inScope, total int, err error)

ScopedSessions reports how many recent sessions the store holds in total and how many of them scope selects, capped at n for the in-scope count. It powers the empty and short-list hints ("no sessions in ~/proj", "…--all lists 7"), which is what tells a user the filter — not an empty store — is hiding history.

func SessionDirDisplay added in v1.2.16

func SessionDirDisplay(h session.SessionHeader) string

SessionDirDisplay renders a session's recorded directory for a list row: $HOME shortened to "~", and a missing Cwd (a session written before the field existed) as "unknown".

func SessionPreview

func SessionPreview(store *session.Store, id string) string

SessionPreview returns the first user message's excerpt for a session, falling back to the first assistant text. It is single-line and capped at previewRunes runes so CJK titles survive; "" when the session has no text.

func UserShellDisplayOutput added in v1.2.12

func UserShellDisplayOutput(output string) string

UserShellDisplayOutput caps the output a UI card renders. Callers pass the raw buffered output; the returned text is safe to split into display rows.

func UserShellMessage added in v1.2.12

func UserShellMessage(command string, exitCode int, d time.Duration, output string) agentcore.UserMessage

UserShellMessage wraps UserShellRecord as the user-role message appended to the conversation. The output is capped first, so a chatty command can never flow into the model window whole.

func UserShellRecord added in v1.2.12

func UserShellRecord(command string, exitCode int, d time.Duration, output string) string

UserShellRecord renders the conversation record for a settled passthrough command: codex's user-role <user_shell_command> fragment verbatim, so the model sees the command, its exit code, duration, and output in the shape it already knows from codex sessions.

Types

type Editor

type Editor interface {
	ReadLine(prompt string) (string, error)
}

Editor is the line-input contract a control command uses to read a follow-up line from the user (e.g. the /btw follow-up loop). It is satisfied by the REPL's line editor.

type Host

type Host interface {
	// Session collaborators.
	Store() *session.Store
	Header() session.SessionHeader
	AgentCtx() *agentcore.AgentContext
	Live() *LiveConfig
	Registry() *agenttool.ToolRegistry
	Reminders() *runtime.ReminderRegistry
	Slash() *runtime.SlashRegistry
	Creds() *provider.CredentialStore
	Trust() *trust.Manager
	// Permissions returns the live approval mode shared by the session's gates
	// and tools. /goal and /btw build their own runs and need it to enforce the
	// same mode as the main conversation.
	Permissions() *permissions.State
	// ReviewNotes returns the announcement sink for permission decisions, so a
	// side run's gate publishes decisions to the same transcript surface as the
	// main run.
	ReviewNotes() *run.ReviewNotes
	Goal() *agenttool.GoalState
	Telemetry() *TelemetryHolder

	// Dispatcher returns the session's hook dispatcher, or nil when no hooks are
	// configured (FR-18). Side-runs (/goal, /btw) install the per-turn seams onto
	// their own cfg via run.InstallSeams(cfg, host.Dispatcher(), host.HookDeps()).
	Dispatcher() *hooks.Dispatcher
	// HookDeps carries the session id / project dir stamped onto every HookInput.
	HookDeps() run.HookDeps
	// PromptNote returns the session's hook for "a prompt is about to be put to
	// the person", or nil when the session reports to no terminal multiplexer.
	// Side-runs (/goal, /btw) install it on their own gates so a question asked
	// from one of them also shows up as a pane waiting for a human, exactly as
	// one asked from the main conversation does. See internal/hostcompat.
	PromptNote() func(question string) func()

	// Cwd is the directory golder was launched in; it does not change during a
	// session and gates side-effect tools.
	Cwd() string
	// Input is the shared buffered stdin reader used by both the main loop and
	// the tool-call confirmation prompt.
	Input() *bufio.Reader
	// ConfirmMu serializes tool-call confirmation prompts across concurrent
	// side-effect tool calls.
	ConfirmMu() *sync.Mutex

	// Session-tree cursor and persistence bookkeeping.
	CurLeaf() string
	SetCurLeaf(id string)
	Persisted() int
	SetPersisted(n int)

	// Last /btw side thread from this process and its background base index.
	LastBtw() *agentcore.AgentContext
	SetLastBtw(ctx *agentcore.AgentContext)
	LastBtwBase() int
	SetLastBtwBase(n int)
}

Host is the seam through which a control command (/goal, /btw, /status) and the REPL loop access the collaborators and mutable state of a session. It is satisfied by the replDeps aggregate assembled once per session.

Getters return the shared collaborators (never copies, except where noted). The setters cover the fields a command may advance mid-session: the active session leaf, the persisted-message count, and the last /btw side thread.

type LiveConfig

type LiveConfig struct {
	Model        string
	ProviderName string
	Provider     provider.Provider
	BaseURL      string
	Protocol     string
	// ThinkingLevel is the reasoning-effort level applied to each turn. It is
	// seeded from the resolved config chain and read on every prompt.
	ThinkingLevel agentcore.ThinkingLevel
	// ContextWindow is the model's total context-token budget, used to gate
	// automatic compaction. When 0 the window is unknown and auto-compaction is
	// disabled; the REPL seeds it with a conservative default so long sessions
	// still compact rather than overflow.
	ContextWindow int
	// MaxContext is the parsed [compaction] max_context value (the zero value
	// is "unset"). CompactionSettings resolves it against the current
	// ContextWindow on every read, so a "N%" form keeps working across a
	// /model switch that changes the window. It can only lower the trigger
	// point, never raise it past the provider limit.
	MaxContext config.MaxContext

	// FetchedModels is the online model catalog pulled from the live provider's
	// endpoint by the bare-/model list (issue #566), sorted and
	// deduplicated. /model prefers it over the heuristic chain for ids it
	// contains (so a fetched id stays on the gateway that serves it) and reuses
	// it for numeric picks. The list is also persisted to a shared 24h disk
	// cache, so the network is consulted about once a day per provider rather
	// than once per session; this field is the session-lifetime copy, seeded
	// either from that cache or from a fresh fetch.
	FetchedModels []string
	FetchedAt     time.Time
	FetchedKey    string
}

LiveConfig is the mutable run configuration a control command may change mid-session.

func (*LiveConfig) CompactionSettings added in v1.2.18

func (l *LiveConfig) CompactionSettings() compaction.CompactionSettings

CompactionSettings returns the compaction thresholds for this session: the defaults with the configured max_context lower bound applied. Every driver (main run, goal loop, side thread, manual /compact) reads this instead of the package defaults, so the one knob a user can set reaches all of them.

func (*LiveConfig) RefreshContextWindow added in v1.2.13

func (l *LiveConfig) RefreshContextWindow()

RefreshContextWindow re-resolves ContextWindow from the current provider and model. Call it after a /model or /provider switch, and after a /resume adopts another session (which changes the context being described even when the model does not), so the status-bar percentage and the auto-compaction threshold track the model actually in use instead of the launch model.

type ReadablePathEntry added in v1.2.17

type ReadablePathEntry struct {
	Path   string
	Source string
	// Detail is the row's own Source field (which dialog or command recorded
	// it), kept for a caller that wants to show more than the two-way label.
	Detail string
}

ReadablePathEntry is one readable root with its provenance.

func ListReadablePaths added in v1.2.17

func ListReadablePaths() ([]ReadablePathEntry, []string)

ListReadablePaths returns every row that grants reading, remembered first (the table's own order), each with the label the dialog prints.

type ReadableRemoval added in v1.2.17

type ReadableRemoval struct {
	Path          string
	WasSession    bool
	WasRemembered bool
	// StillReadable reports that the read grant survives the removal because
	// the row also grants write, and write implies read: the honest answer for
	// "remove reading" on a writable root is that writing it means reading it.
	StillReadable bool
}

ReadableRemoval reports what a removal touched.

func RemoveReadablePath added in v1.2.17

func RemoveReadablePath(raw string) (ReadableRemoval, error)

RemoveReadablePath revokes a read grant. A row that also grants write keeps reading — write implies read — and says so rather than pretending the revocation worked.

func (ReadableRemoval) Found added in v1.2.17

func (r ReadableRemoval) Found() bool

Found reports whether the path held a read grant at all.

type ResumeItem

type ResumeItem struct {
	Header  session.SessionHeader
	Preview string
}

ResumeItem pairs a session header with a human-readable preview.

func RecentSessionsWithPreview

func RecentSessionsWithPreview(store *session.Store, scope ResumeScope, n int) ([]ResumeItem, error)

RecentSessionsWithPreview returns up to n recent sessions with previews, newest first, filtered to scope. A session with no text yields an empty Preview.

type ResumeScope added in v1.2.16

type ResumeScope struct {
	// All lifts the filter (from AllSessionsFlag).
	All bool
	// Dir is the directory the view is anchored at; a session is in scope when
	// it ran in the same project as Dir (same repository root, or the same
	// directory outside any repository).
	Dir string
}

ResumeScope is the project filter a resume view applies. The zero value matches nothing: a caller that does not know its working directory gets an empty view rather than another project's history.

func AllSessionsScope added in v1.2.16

func AllSessionsScope() ResumeScope

AllSessionsScope returns the unfiltered scope.

func ParseResumeArg added in v1.2.16

func ParseResumeArg(arg, projectDir string) (ResumeScope, string)

ParseResumeArg splits a /resume argument into the scope it selects and the selector left over (a 1-based number or a literal id; "" for the bare list). --all (or -a) anywhere in the argument lifts the project filter, so both "/resume --all" and "/resume --all 3" work.

func ProjectScope added in v1.2.16

func ProjectScope(dir string) ResumeScope

ProjectScope returns the default scope for a launch directory: the sessions that ran in the same project.

func (ResumeScope) Match added in v1.2.16

Match reports whether h belongs to the scope. A session with no recorded Cwd (written before the field existed) is unattributed and only matches --all. A scope with no anchor directory degrades to --all: with no project to compare against, hiding every session would be strictly worse than showing them.

type TelemetryHolder

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

TelemetryHolder holds the most recent run's telemetry event and a cumulative accumulator that sums metrics across all runs in the session.

func NewTelemetryHolder

func NewTelemetryHolder() *TelemetryHolder

NewTelemetryHolder creates a new, empty TelemetryHolder with no telemetry yet.

func (*TelemetryHolder) CumulativeCompactionCount

func (h *TelemetryHolder) CumulativeCompactionCount() int

CumulativeCompactionCount returns the total number of compactions across all runs.

func (*TelemetryHolder) CumulativeContextUtilization

func (h *TelemetryHolder) CumulativeContextUtilization() float64

CumulativeContextUtilization returns the latest utilization ratio, or 0 if no window is known.

func (*TelemetryHolder) CumulativeToolDurations

func (h *TelemetryHolder) CumulativeToolDurations() map[string]agentcore.ToolTiming

CumulativeToolDurations returns the aggregated tool timings across all runs.

func (*TelemetryHolder) CumulativeTruncationCount

func (h *TelemetryHolder) CumulativeTruncationCount() int

CumulativeTruncationCount returns the total number of truncations across all runs.

func (*TelemetryHolder) CumulativeTurns

func (h *TelemetryHolder) CumulativeTurns() int

CumulativeTurns returns the total number of turns across all runs.

func (*TelemetryHolder) Fold

Fold incorporates a new TelemetryEvent into the holder: it becomes the new "last run" event, and its metrics are added to the cumulative accumulator.

func (*TelemetryHolder) HasTelemetry

func (h *TelemetryHolder) HasTelemetry() bool

HasTelemetry returns true if at least one run has completed and telemetry is available.

func (*TelemetryHolder) Last

Last returns the most recent TelemetryEvent, or nil if no run has completed.

func (*TelemetryHolder) LatestContextTokens

func (h *TelemetryHolder) LatestContextTokens() int

LatestContextTokens returns the most recent observed context token count.

func (*TelemetryHolder) LatestContextWindow

func (h *TelemetryHolder) LatestContextWindow() int

LatestContextWindow returns the most recent observed context window size.

func (*TelemetryHolder) Reset

func (h *TelemetryHolder) Reset()

Reset clears the holder to "no telemetry yet", as if the session had just started. It is called when switching sessions (/fork, /clone, /import).

type UserShellOutcome added in v1.2.12

type UserShellOutcome struct {
	// Command is the command line the user typed, without the leading "!".
	Command string
	// ExitCode is the process exit code (-1 when the command was aborted).
	ExitCode int
	// Duration is the wall-clock run time (zero when aborted, mirroring codex).
	Duration time.Duration
	// Output is the command's combined output, bounded by the in-memory window.
	Output string
	// TimedOut reports the one-hour backstop fired and the process was killed.
	TimedOut bool
	// Aborted reports the user interrupted the command (Ctrl+C / Esc).
	Aborted bool
}

UserShellOutcome is a settled passthrough command.

type UserShellRecordData added in v1.2.12

type UserShellRecordData struct {
	Command  string
	ExitCode int
	Output   string
}

UserShellRecordData is the parsed form of a <user_shell_command> message.

func ParseUserShellRecord added in v1.2.12

func ParseUserShellRecord(text string) (UserShellRecordData, bool)

ParseUserShellRecord recognizes a conversation message written by UserShellRecord and extracts its command, exit code, and output. ok is false for every other message, so replay paths render a record as the shell card it was instead of dumping raw XML into the transcript.

type UserShellRun added in v1.2.12

type UserShellRun struct {
	// Command is the command line being run (without the leading "!").
	Command string
	// contains filtered or unexported fields
}

UserShellRun is one in-flight passthrough command. The process lives on the shared execsess manager, so it is covered by the same LRU bookkeeping and kill-on-exit as the agent's own shells.

func StartUserShell added in v1.2.12

func StartUserShell(mgr *execsess.Manager, cwd, command string) (*UserShellRun, error)

StartUserShell spawns command under the login shell in cwd. It is the `!` escape hatch: no sandbox, no approval, no model call.

func (*UserShellRun) Done added in v1.2.12

func (u *UserShellRun) Done() bool

Done reports whether the process has exited.

func (*UserShellRun) Output added in v1.2.12

func (u *UserShellRun) Output() string

Output returns everything buffered so far: the running UI polls this while the command streams.

func (*UserShellRun) Wait added in v1.2.12

Wait blocks until the process exits, the timeout fires, or ctx is cancelled. A cancelled ctx is the user's Ctrl+C: the command is killed and the outcome reports codex's aborted shape (exit code -1, "command aborted by user", zero duration).

type WritablePathEntry added in v1.2.3

type WritablePathEntry struct {
	Path   string
	Source string
	// Detail is the row's own Source field, kept for a caller that wants more
	// than the two-way label.
	Detail string
}

WritablePathEntry is one writable root with its provenance.

func ListWritablePaths added in v1.2.3

func ListWritablePaths() ([]WritablePathEntry, []string)

ListWritablePaths returns every row that grants writing, remembered first.

type WritableRemoval added in v1.2.3

type WritableRemoval struct {
	Path          string
	WasSession    bool
	WasRemembered bool
}

WritableRemoval reports what a removal touched.

func RemoveWritablePath added in v1.2.3

func RemoveWritablePath(raw string) (WritableRemoval, error)

RemoveWritablePath revokes the write grant a writable root was created for.

It clears read and write together, because that is the row this command put there: a writable root carries Read implicitly (a file you may write and not read back is a half-failure), so clearing only Write would leave the directory readable — the opposite of what "remove the writable path" means. An Execute grant on the same row survives, because trust and the boundary are separate decisions and this command speaks for the boundary.

func (WritableRemoval) Found added in v1.2.3

func (r WritableRemoval) Found() bool

Found reports whether the path held a write grant at all.

Directories

Path Synopsis
This file implements the /btw command (mirrors Claude Code's /btw and the pi agent extension @narumitw/pi-btw): a throwaway "side thread" for asking the model a quick side question that must NOT pollute the main conversation.
This file implements the /btw command (mirrors Claude Code's /btw and the pi agent extension @narumitw/pi-btw): a throwaway "side thread" for asking the model a quick side question that must NOT pollute the main conversation.
Package config implements golder's optional user config file at $GOLDER_HOME/config.toml (~/.golder/config.toml by default) plus the provider-agnostic base-url env-var name derivation.
Package config implements golder's optional user config file at $GOLDER_HOME/config.toml (~/.golder/config.toml by default) plus the provider-agnostic base-url env-var name derivation.
Package dreamcmd holds the CLI-side plumbing shared by the REPL and the TUI for the /dream memory-consolidation command: spawning the process-isolated `golder --dream` child, detecting a live consolidation lock, parsing the dry-run flag, and rendering the returned Report.
Package dreamcmd holds the CLI-side plumbing shared by the REPL and the TUI for the /dream memory-consolidation command: spawning the process-isolated `golder --dream` child, detecting a live consolidation lock, parsing the dry-run flag, and rendering the returned Report.
Package extensioncmd is the shared text command surface for the CLI, REPL and TUI.
Package extensioncmd is the shared text command surface for the CLI, REPL and TUI.
This file implements the /goal command (mirrors pi-goal / Claude Code's goal mode): given a high-level objective, golder runs the agent autonomously — re-prompting it turn after turn from the loop's follow-up seam — until the model declares the goal done (goal_complete), reports a true impasse (goal_blocked), or a safety guard (max turns / no-progress) or the token budget stops it.
This file implements the /goal command (mirrors pi-goal / Claude Code's goal mode): given a high-level objective, golder runs the agent autonomously — re-prompting it turn after turn from the loop's follow-up seam — until the model declares the goal done (goal_complete), reports a true impasse (goal_blocked), or a safety guard (max turns / no-progress) or the token budget stops it.
This file is the headless run driver: the print / stream-json run path (US-020) extracted from the CLI dispatch seam (#363).
This file is the headless run driver: the print / stream-json run path (US-020) extracted from the CLI dispatch seam (#363).
Package hostcmd implements the `golder host-compat` subcommand family: what the terminal multiplexer around this process sees, and the one file that makes tuios recognise a golder pane at all.
Package hostcmd implements the `golder host-compat` subcommand family: what the terminal multiplexer around this process sees, and the one file that makes tuios recognise a golder pane at all.
Package launchcfg owns the provider-facing part of launch configuration that every Golder front-end shares.
Package launchcfg owns the provider-facing part of launch configuration that every Golder front-end shares.
This file implements the /memory slash command (US-011, FR-20, #484) that prints a colored report describing the persistent memory store and the infinite-context state: entry counts by scope, the current context window and auto-compaction trigger point, current context usage, and checkpoint status.
This file implements the /memory slash command (US-011, FR-20, #484) that prints a colored report describing the persistent memory store and the infinite-context state: entry counts by scope, the current context window and auto-compaction trigger point, current context usage, and checkpoint status.
Package prompts holds the slash-command registry assembly shared by the REPL (internal/cli/repl) and the forthcoming TUI (internal/cli/tui).
Package prompts holds the slash-command registry assembly shared by the REPL (internal/cli/repl) and the forthcoming TUI (internal/cli/tui).
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.
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.
This file is the single assembly point for a session's tool gates: the trust gate, the workspace-boundary gate and the permission gate, composed once and installed on every run of the session — the main run, a /goal or /btw side run, and any sub-agent they dispatch.
This file is the single assembly point for a session's tool gates: the trust gate, the workspace-boundary gate and the permission gate, composed once and installed on every run of the session — the main run, a /goal or /btw side run, and any sub-agent they dispatch.
Package sessioncmd implements the `golder session` subcommand family (issue #570): sharing persisted sessions from the command line, without entering the REPL.
Package sessioncmd implements the `golder session` subcommand family (issue #570): sharing persisted sessions from the command line, without entering the REPL.
This file implements the /status slash command (US-002, #292) that prints a colored multi-section status report with runtime config, context usage, and more.
This file implements the /status slash command (US-002, #292) that prints a colored multi-section status report with runtime config, context usage, and more.
Package testutil holds test helpers shared across the internal/cli subpackages.
Package testutil holds test helpers shared across the internal/cli subpackages.
Package tui hosts the full-screen terminal UI for golder's interactive mode (US-001).
Package tui hosts the full-screen terminal UI for golder's interactive mode (US-001).
Package ui holds the leaf terminal-UI helpers shared across the cmd/golder and internal/cli subpackages: ANSI color gating (color.go), turn-end Markdown rendering (markdown.go), and prompt image-reference parsing (imageref.go).
Package ui holds the leaf terminal-UI helpers shared across the cmd/golder and internal/cli subpackages: ANSI color gating (color.go), turn-end Markdown rendering (markdown.go), and prompt image-reference parsing (imageref.go).
Package workspacecmd implements `golder workspace`: the command line that manages global named terminal sessions, each with an independent daemon.
Package workspacecmd implements `golder workspace`: the command line that manages global named terminal sessions, each with an independent daemon.

Jump to

Keyboard shortcuts

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