goal

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 13 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 /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.

/goal is intercepted in the REPL loop rather than routed through a slash Action closure because it must run agent streams and mutate the shared context and goal state — none of which a pure string→string Action can do, exactly like /compact and /fork. It reaches the session's collaborators and mutable state through the cli.Host contract, so it need not import the concrete replDeps aggregate that assembles them.

Scope: core autonomous continuation plus an optional token budget. Goal state lives only in the session's in-memory GoalState (host.Goal()); it is not persisted across process restarts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FollowUp

FollowUp returns the loop's GetFollowUpMessages hook for a goal run: on each settle it accounts for the turns produced since the previous one (their output tokens and whether any tool ran), records the iteration on the goal state, and re-prompts the model to continue until a guard trips. It is exported so the TUI can drive the same autonomous loop with its own run seam.

Auto-compaction can shrink agentCtx.Messages in place between settles, dropping its length below the tracked mark; the mark is clamped so the slice never goes out of bounds (the compacted turn's tokens are then under-counted, which is acceptable for a soft budget guard).

func ParseObjective

func ParseObjective(args string) (objective string, budget int, err error)

ParseObjective splits an optional leading "--tokens N" flag from the objective text (see parseGoalObjective). Exported for the TUI.

func Reminders

Reminders returns the reminder registry for a goal run: the goal reminder plus the todo reminder when a todo tool is present. Exported for the TUI.

func RenderOutcome

func RenderOutcome(out io.Writer, snap agenttool.GoalSnapshot)

RenderOutcome writes the one-line result banner for a settled goal run. Exported for the TUI.

func RenderStatus

func RenderStatus(out io.Writer, state *agenttool.GoalState)

RenderStatus writes a summary of the current goal state (the bare /goal output). Exported for the TUI.

func RunGoal

func RunGoal(setCancel func(context.CancelFunc), out io.Writer, host cli.Host, line string)

runGoal parses and dispatches a /goal invocation. setCancel publishes the active run's cancel func so the REPL's SIGINT handler can interrupt an autonomous run (same plumbing as a normal turn).

func Start

func Start(state *agenttool.GoalState, objective string, budget int)

Start records a new objective on the goal state. Exported for the TUI, which starts the run through its own async seam.

func ToolRegistry

func ToolRegistry(base *agenttool.ToolRegistry, state *agenttool.GoalState) *agenttool.ToolRegistry

ToolRegistry returns a registry holding every tool from base plus the two goal-control tools (goal_complete / goal_blocked), so an autonomous run can end itself. Exported for the TUI's goal run.

Types

This section is empty.

Jump to

Keyboard shortcuts

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