agentflags

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 6 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 agentflags checks the options a launch passes to the coding agent, so every place that stores them (prompts and launch defaults) and the launcher that passes them apply the same rules.

It knows the agent's effort levels, what a model name may look like, which flags the launcher sets itself (and so may not be added by hand), and how to read extra flags typed on one line, quoted the way a shell would, into one argument each.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidEffort is returned for an effort level the agent does not accept.
	ErrInvalidEffort = errors.New("unknown effort level")

	// ErrInvalidModel is returned for a model name the agent could misread.
	ErrInvalidModel = errors.New("invalid model name")

	// ErrReservedFlag is returned for an extra flag the launcher sets itself.
	ErrReservedFlag = errors.New("reserved flag")

	// ErrEmptyFlag is returned for an empty extra argument.
	ErrEmptyFlag = errors.New("empty argument")

	// ErrNULByte is returned for an argument holding a NUL byte, which no process
	// argument can carry.
	ErrNULByte = errors.New("value contains a NUL byte")

	// ErrTilde is returned for an argument that starts with ~: launch scripts quote every
	// argument, so no shell expands it.
	ErrTilde = errors.New("~ is not expanded")

	// ErrUnterminatedQuote is returned by Split for a quote that is never closed.
	ErrUnterminatedQuote = errors.New("unterminated quote")
)

Functions

func CheckExtra

func CheckExtra(args []string) error

CheckExtra checks extra arguments added by a prompt or a launch default. Each must be non-empty and free of NUL bytes, must not start with ~ or give a flag a value that does (--add-dir=~/x), since nothing expands it, and must not set a flag the launcher owns (see ReservedFlagError).

func EffortLevels

func EffortLevels() []string

EffortLevels returns the values the agent accepts for --effort, lowest first.

func Join

func Join(args []string) string

Join writes arguments on one line that Split reads back unchanged: an argument made only of letters, digits, and _@%+=:,./- is written as is, and any other is single-quoted.

func Split

func Split(line string) ([]string, error)

Split reads extra flags typed on one line into one argument each, the way a POSIX shell splits words, but without expanding anything: whitespace separates arguments, single quotes keep everything up to the next single quote, double quotes keep everything but an escaped \" or \\, and a backslash outside quotes keeps the next character. Two single quotes in a row make an empty argument. An unclosed quote is an ErrUnterminatedQuote. Split(Join(args)) returns args.

func ValidateEffort

func ValidateEffort(effort string) error

ValidateEffort accepts "" (the agent's default) or one of EffortLevels.

func ValidateModel

func ValidateModel(model string) error

ValidateModel accepts "" (the agent's default) or a model alias or full name: one word of printable characters, at most 100 long, that does not start with "-", so the agent can never read it as a flag.

Types

type ReservedFlagError

type ReservedFlagError struct {
	// Flag is the argument as written, such as "--model" or "-w".
	Flag string

	// Reason completes the sentence "<flag> ...": what to do instead.
	Reason string
}

ReservedFlagError is returned for an extra flag the launcher sets itself. Its message says which setting owns the flag.

func (*ReservedFlagError) Error

func (e *ReservedFlagError) Error() string

Error reads like "--model is set by the Model setting".

func (*ReservedFlagError) Is

func (e *ReservedFlagError) Is(target error) bool

Is makes a ReservedFlagError match ErrReservedFlag.

Jump to

Keyboard shortcuts

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