cli

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package cli implements every mpqt command against injected dependencies. It is llm-free; cmd/mpqt (the nested module) supplies the constructors (App.NewClient, App.NewCounter) that reach a real inference.Client and pricing.Counter. This package never imports github.com/looprig/llm and never constructs a client or counter itself -- it only ever calls the functions App carries.

Index

Constants

View Source
const (
	ExitOK             = 0
	ExitCommandFailure = 1
	ExitUsage          = 2
	ExitGateFailed     = 3
	ExitPricing        = 4
)

Process exit codes, per Main's own doc comment: 0 ok; 1 command failure; 2 usage; 3 disposition/comparison gate failed; 4 cost ceiling or pricing-completeness failure.

Variables

This section is empty.

Functions

func Main

func Main(args []string, app App) int

Main parses args and dispatches. Returns the process exit code: 0 ok; 1 command failure; 2 usage; 3 disposition/comparison gate failed; 4 cost ceiling or pricing-completeness failure.

Types

type App

type App struct {
	Registry       *packfile.Registry
	NewClient      func(model.Model) (inference.Client, error) // nil => gen/run/judge unavailable
	NewCounter     func(model.Model) (pricing.Counter, error)  // nil => heuristic preflight
	LookupEnv      func(string) (string, bool)                 // for key presence checks (never values in output)
	Stdout, Stderr io.Writer
	Now            func() time.Time

	// RateLimit configures client-side rate limiting (RPM pacing, concurrency
	// cap, 429/5xx retry-with-backoff) applied to every live client this App
	// hands out. The zero value disables it (a pure passthrough). The paid
	// commands set it from their --max-rpm/--max-retries/--max-concurrent-
	// requests flags before resolving any client, so both the target and the
	// judge client route through the same limiter.
	RateLimit ratelimit.Config
}

App wires the environment-specific pieces. Every field has a working zero-cost default except the client constructors, which nil out LLM commands with a clear error: App{} is enough to run init/validate/schema/ evaluators/compare (see withDefaults), but gen/run need NewClient (and, for a real token estimate rather than the heuristic fallback, NewCounter).

type LLMConfig

type LLMConfig struct {
	LLM struct {
		Provider  string `yaml:"provider"`
		Model     string `yaml:"model"`
		APIFormat string `yaml:"api-format"`
		BaseURL   string `yaml:"base-url"`
	} `yaml:"llm"`
}

LLMConfig is the generator/judge configuration file shape: non-secret provider/model identity only. The API key comes only from the provider's own environment variable (never this file, never a CLI flag) -- see checkKeyPresence.

Jump to

Keyboard shortcuts

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