Help us shape the future of Go! Take the 2026 Go Developer Survey

builtins

package
v1.53.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package builtins contains the stock in-process hook implementations shipped with docker-agent.

Available builtins:

  • add_date (turn_start) — today's date
  • add_environment_info (session_start) — cwd, git, OS, arch
  • add_prompt_files (turn_start) — contents of prompt files
  • add_git_status (turn_start) — `git status --short --branch`
  • add_git_diff (turn_start) — `git diff --stat` (or full)
  • add_directory_listing (session_start) — top-level entries of cwd
  • add_user_info (session_start) — current OS user and host
  • add_recent_commits (session_start) — `git log --oneline -n N`
  • max_iterations (before_llm_call) — hard stop after N model calls

Reference any of them from a hook YAML entry as `{type: builtin, command: "<name>"}`. The runtime additionally auto-injects add_date / add_environment_info / add_prompt_files from the matching agent flags.

turn_start builtins recompute every turn (date, git state). session_start builtins run once per session for context that's stable for its duration. max_iterations is stateful: its per-session counter lives on the State returned by Register; the runtime clears it via State.ClearSession from session_end.

LLM-as-a-judge hooks are NOT shipped here: write `type: model` with `schema: pre_tool_use_decision` instead — see pkg/hooks/shape_pre_tool_use_decision.go and examples/llm_judge.yaml.

Index

Constants

View Source
const AddDate = "add_date"

AddDate is the registered name of the add_date builtin.

View Source
const AddDirectoryListing = "add_directory_listing"

AddDirectoryListing is the registered name of the add_directory_listing builtin.

View Source
const AddEnvironmentInfo = "add_environment_info"

AddEnvironmentInfo is the registered name of the add_environment_info builtin.

View Source
const AddGitDiff = "add_git_diff"

AddGitDiff is the registered name of the add_git_diff builtin.

View Source
const AddGitStatus = "add_git_status"

AddGitStatus is the registered name of the add_git_status builtin.

View Source
const AddPromptFiles = "add_prompt_files"

AddPromptFiles is the registered name of the add_prompt_files builtin.

View Source
const AddRecentCommits = "add_recent_commits"

AddRecentCommits is the registered name of the add_recent_commits builtin.

View Source
const AddUserInfo = "add_user_info"

AddUserInfo is the registered name of the add_user_info builtin.

View Source
const MaxIterations = "max_iterations"

MaxIterations is the registered name of the max_iterations builtin.

Variables

This section is empty.

Functions

func ApplyAgentDefaults

func ApplyAgentDefaults(cfg *hooks.Config, d AgentDefaults) *hooks.Config

ApplyAgentDefaults appends the stock builtin hook entries implied by d to cfg. A nil cfg is treated as empty. Returns nil iff no hook (user-configured or auto-injected) is present.

Types

type AgentDefaults

type AgentDefaults struct {
	AddDate            bool
	AddEnvironmentInfo bool
	AddPromptFiles     []string
}

AgentDefaults captures the agent-level flags that map onto stock builtin hook entries. Pass each AgentConfig.AddXxx flag as-is.

type State

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

State holds the per-runtime state of the stateful builtins. It is returned by Register so callers can clear per-session entries on session_end. Stateless builtins don't appear here.

func Register

func Register(r *hooks.Registry) (*State, error)

Register installs the stock builtin hooks on r and returns a State handle the caller must use to clear per-session state on session_end.

func (*State) ClearSession

func (s *State) ClearSession(sessionID string)

ClearSession drops per-session state from every stateful builtin. A nil receiver is a no-op.

Jump to

Keyboard shortcuts

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