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 ¶
- Variables
- func DownloadBinary(tag string, w io.Writer) (string, error)
- func ExitCode(err error) (int, bool)
- func FindBinaryPath() (string, error)
- func MountCLI(opts ...MountOption) *cobra.Command
- func NeedsLegacyPassthrough(args []string) bool
- func ReplaceBinary(oldPath, newPath string, w io.Writer) error
- func Run(opts Options) int
- type CandidateScorer
- type CandidateScorerFunc
- type ExitError
- type GitHubRelease
- type MountOption
- func WithLong(long string) MountOption
- func WithShort(short string) MountOption
- func WithStderr(stderr io.Writer) MountOption
- func WithStdin(stdin io.Reader) MountOption
- func WithStdout(stdout io.Writer) MountOption
- func WithUse(use string) MountOption
- func WithVersion(version, buildTime, gitCommit string) MountOption
- type Options
- type SemVer
Constants ¶
This section is empty.
Variables ¶
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 ¶
DownloadBinary downloads the latest binary for the current platform.
func ExitCode ¶
ExitCode extracts a process-style exit code from errors returned by mounted command execution.
func FindBinaryPath ¶
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 ¶
NeedsLegacyPassthrough reports whether argv should bypass Cobra traversal until the corresponding command path has native pflag definitions.
func ReplaceBinary ¶
ReplaceBinary atomically replaces the old binary with the new one.
Types ¶
type CandidateScorer ¶
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 ¶
CandidateScorerFunc is a func adapter for CandidateScorer.
type ExitError ¶
type ExitError struct {
Code int
}
ExitError reports a non-zero CLI runner exit without terminating the parent process.
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 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 ¶
SemVer represents a semantic version.
func ParseSemVer ¶
ParseSemVer parses a version string like "v0.0.8" or "1.2.3-beta". Returns error for non-semantic versions like "dev".