agentcli

package
v0.10.11 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Overview

Package agentcli exposes the fiz command runner for binaries and embedding callers that need to invoke the CLI without os.Exit.

Package main provides the agent CLI.

Index

Constants

This section is empty.

Variables

View Source
var (
	Version   = "dev"
	BuildTime = ""
	GitCommit = ""
)

Version info defaults. The standalone binary passes ldflag-populated values through Options; tests may still override these package vars directly.

Functions

func DownloadBinary

func DownloadBinary(tag string, w io.Writer) (string, error)

DownloadBinary downloads the latest binary for the current platform.

func ExitCode

func ExitCode(err error) (int, bool)

ExitCode extracts a process-style exit code from errors returned by mounted command execution.

func FindBinaryPath

func FindBinaryPath() (string, error)

FindBinaryPath finds the path to the agent binary.

func MountCLI

func MountCLI(opts ...MountOption) *cobra.Command

MountCLI returns a fresh, unattached Cobra root command. Most command paths are native Cobra commands; legacy compatibility remains for the default prompt path and explicitly delegated commands.

func NeedsLegacyPassthrough

func NeedsLegacyPassthrough(args []string) bool

NeedsLegacyPassthrough reports whether argv should bypass Cobra traversal until the corresponding command path has native pflag definitions.

func ReplaceBinary

func ReplaceBinary(oldPath, newPath string, w io.Writer) error

ReplaceBinary atomically replaces the old binary with the new one.

func Run

func Run(opts Options) int

Run executes the fiz CLI and returns its process exit code. It never calls os.Exit, which lets parent CLIs mount or test the command safely.

Types

type CandidateScorer

type CandidateScorer interface {
	Score(provider, model string, baseScore float64) float64
}

CandidateScorer allows external callers to overlay scores on top of the smart routing composite score. DDx uses this to factor in quota availability without forking the routing logic.

Score returns an adjusted score for a candidate. The baseScore is the composite score already computed from reliability, performance, load, cost, and capability. The scorer may return the baseScore unchanged, clamp it to zero (e.g., quota exhausted), or boost it (e.g., priority quota).

If the scorer returns a negative value, the candidate is treated as unhealthy and excluded from the ordering.

type CandidateScorerFunc

type CandidateScorerFunc func(provider, model string, baseScore float64) float64

CandidateScorerFunc is a func adapter for CandidateScorer.

func (CandidateScorerFunc) Score

func (f CandidateScorerFunc) Score(provider, model string, baseScore float64) float64

type ExitError

type ExitError struct {
	Code int
}

ExitError reports a non-zero CLI runner exit without terminating the parent process.

func (*ExitError) Error

func (e *ExitError) Error() string

type GitHubRelease

type GitHubRelease struct {
	TagName     string    `json:"tag_name"`
	Name        string    `json:"name"`
	Body        string    `json:"body"` // Release notes (markdown)
	PublishedAt time.Time `json:"published_at"`
}

GitHubRelease represents a GitHub release.

func GetLatestRelease

func GetLatestRelease(repo string, cacheFile string) (*GitHubRelease, error)

GetLatestRelease fetches the latest release from GitHub API.

type MountOption

type MountOption func(*mountConfig)

MountOption customizes a mounted fiz command tree.

func WithLong

func WithLong(long string) MountOption

WithLong overrides the Cobra long help text.

func WithShort

func WithShort(short string) MountOption

WithShort overrides the Cobra short help text.

func WithStderr

func WithStderr(stderr io.Writer) MountOption

WithStderr injects stderr for mounted invocations.

func WithStdin

func WithStdin(stdin io.Reader) MountOption

WithStdin injects stdin for mounted invocations.

func WithStdout

func WithStdout(stdout io.Writer) MountOption

WithStdout injects stdout for mounted invocations.

func WithUse

func WithUse(use string) MountOption

WithUse overrides the Cobra command use/name string.

func WithVersion

func WithVersion(version, buildTime, gitCommit string) MountOption

WithVersion injects version metadata for mounted invocations.

type Options

type Options struct {
	Args      []string
	Stdin     io.Reader
	Stdout    io.Writer
	Stderr    io.Writer
	Version   string
	BuildTime string
	GitCommit string
}

Options controls a single CLI invocation.

type SemVer

type SemVer struct {
	Major      int
	Minor      int
	Patch      int
	PreRelease string // e.g., "rc1", "beta2"
}

SemVer represents a semantic version.

func ParseSemVer

func ParseSemVer(v string) (SemVer, error)

ParseSemVer parses a version string like "v0.0.8" or "1.2.3-beta". Returns error for non-semantic versions like "dev".

func (SemVer) Less

func (v SemVer) Less(other SemVer) bool

Less returns true if v < other.

func (SemVer) String

func (v SemVer) String() string

String returns the version string.

Jump to

Keyboard shortcuts

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