Documentation
¶
Overview ¶
Package requirements provides dependency checking and HITL installation prompts for assistant runtimes. It maps tool names from multi-agent-spec `requires` fields to install commands and interactive prompts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultRegistry = Registry{ "releasekit": { Name: "releasekit", Purpose: "language-specific validation (build, test, lint, format)", Check: "releasekit --version", Homepage: "https://github.com/grokify/releasekit", InstallMethods: []InstallMethod{ { Name: "go", Command: "go install github.com/grokify/releasekit/cmd/releasekit@latest", Requires: []string{"go"}, }, }, }, "schangelog": { Name: "schangelog", Purpose: "changelog generation and validation", Check: "schangelog --version", Homepage: "https://github.com/grokify/structured-changelog", InstallMethods: []InstallMethod{ { Name: "go", Command: "go install github.com/grokify/structured-changelog/cmd/schangelog@latest", Requires: []string{"go"}, }, }, }, "sroadmap": { Name: "sroadmap", Purpose: "roadmap generation from structured data", Check: "sroadmap --version", Homepage: "https://github.com/grokify/structured-roadmap", InstallMethods: []InstallMethod{ { Name: "go", Command: "go install github.com/grokify/structured-roadmap/cmd/sroadmap@latest", Requires: []string{"go"}, }, }, }, "golangci-lint": { Name: "golangci-lint", Purpose: "Go linting and static analysis", Check: "golangci-lint --version", Homepage: "https://golangci-lint.run", InstallMethods: []InstallMethod{ { Name: "go", Command: "go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest", Requires: []string{"go"}, }, { Name: "brew", Command: "brew install golangci-lint", Requires: []string{"brew"}, Platforms: []string{"darwin", "linux"}, }, { Name: "curl", Command: "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin", Requires: []string{"curl", "go"}, }, }, }, "go": { Name: "go", Purpose: "Go programming language toolchain", Check: "go version", Homepage: "https://go.dev", InstallMethods: []InstallMethod{ { Name: "brew", Command: "brew install go", Requires: []string{"brew"}, Platforms: []string{"darwin"}, }, { Name: "apt", Command: "sudo apt-get install -y golang", Requires: []string{"apt-get"}, Platforms: []string{"linux"}, }, { Name: "manual", Command: "# Download from https://go.dev/dl/", Requires: []string{}, }, }, }, "git": { Name: "git", Purpose: "version control system", Check: "git --version", Homepage: "https://git-scm.com", InstallMethods: []InstallMethod{ { Name: "brew", Command: "brew install git", Requires: []string{"brew"}, Platforms: []string{"darwin"}, }, { Name: "apt", Command: "sudo apt-get install -y git", Requires: []string{"apt-get"}, Platforms: []string{"linux"}, }, { Name: "xcode", Command: "xcode-select --install", Requires: []string{}, Platforms: []string{"darwin"}, }, }, }, "gh": { Name: "gh", Purpose: "GitHub CLI for PR, issue, and release management", Check: "gh --version", Homepage: "https://cli.github.com", InstallMethods: []InstallMethod{ { Name: "brew", Command: "brew install gh", Requires: []string{"brew"}, Platforms: []string{"darwin", "linux"}, }, { Name: "apt", Command: "sudo apt-get install -y gh", Requires: []string{"apt-get"}, Platforms: []string{"linux"}, }, { Name: "go", Command: "go install github.com/cli/cli/v2/cmd/gh@latest", Requires: []string{"go"}, }, }, }, "helm": { Name: "helm", Purpose: "Kubernetes package manager", Check: "helm version", Homepage: "https://helm.sh", InstallMethods: []InstallMethod{ { Name: "brew", Command: "brew install helm", Requires: []string{"brew"}, Platforms: []string{"darwin", "linux"}, }, { Name: "curl", Command: "curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash", Requires: []string{"curl"}, }, { Name: "apt", Command: "sudo apt-get install -y helm", Requires: []string{"apt-get"}, Platforms: []string{"linux"}, }, }, }, "brew": { Name: "brew", Purpose: "Homebrew package manager", Check: "brew --version", Homepage: "https://brew.sh", InstallMethods: []InstallMethod{ { Name: "curl", Command: `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`, Requires: []string{"curl"}, Platforms: []string{"darwin", "linux"}, }, }, }, "kubectl": { Name: "kubectl", Purpose: "Kubernetes command-line tool", Check: "kubectl version --client", Homepage: "https://kubernetes.io/docs/tasks/tools/", InstallMethods: []InstallMethod{ { Name: "brew", Command: "brew install kubectl", Requires: []string{"brew"}, Platforms: []string{"darwin", "linux"}, }, { Name: "apt", Command: "sudo apt-get install -y kubectl", Requires: []string{"apt-get"}, Platforms: []string{"linux"}, }, { Name: "gcloud", Command: "gcloud components install kubectl", Requires: []string{"gcloud"}, }, }, }, "docker": { Name: "docker", Purpose: "container runtime", Check: "docker --version", Homepage: "https://www.docker.com", InstallMethods: []InstallMethod{ { Name: "brew", Command: "brew install --cask docker", Requires: []string{"brew"}, Platforms: []string{"darwin"}, }, { Name: "apt", Command: "sudo apt-get install -y docker.io", Requires: []string{"apt-get"}, Platforms: []string{"linux"}, }, }, }, "node": { Name: "node", Purpose: "Node.js JavaScript runtime", Check: "node --version", Homepage: "https://nodejs.org", InstallMethods: []InstallMethod{ { Name: "brew", Command: "brew install node", Requires: []string{"brew"}, Platforms: []string{"darwin", "linux"}, }, { Name: "apt", Command: "sudo apt-get install -y nodejs", Requires: []string{"apt-get"}, Platforms: []string{"linux"}, }, { Name: "nvm", Command: "nvm install --lts", Requires: []string{"nvm"}, }, }, }, "npm": { Name: "npm", Purpose: "Node.js package manager", Check: "npm --version", Homepage: "https://www.npmjs.com", InstallMethods: []InstallMethod{ { Name: "node", Command: "# npm is included with Node.js", Requires: []string{"node"}, }, }, }, "pnpm": { Name: "pnpm", Purpose: "fast, disk space efficient package manager", Check: "pnpm --version", Homepage: "https://pnpm.io", InstallMethods: []InstallMethod{ { Name: "npm", Command: "npm install -g pnpm", Requires: []string{"npm"}, }, { Name: "brew", Command: "brew install pnpm", Requires: []string{"brew"}, Platforms: []string{"darwin", "linux"}, }, { Name: "curl", Command: "curl -fsSL https://get.pnpm.io/install.sh | sh -", Requires: []string{"curl"}, }, }, }, "govulncheck": { Name: "govulncheck", Purpose: "Go vulnerability scanner", Check: "govulncheck --version", Homepage: "https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck", InstallMethods: []InstallMethod{ { Name: "go", Command: "go install golang.org/x/vuln/cmd/govulncheck@latest", Requires: []string{"go"}, }, }, }, "trivy": { Name: "trivy", Purpose: "vulnerability scanner for containers and filesystems", Check: "trivy --version", Homepage: "https://trivy.dev", InstallMethods: []InstallMethod{ { Name: "brew", Command: "brew install trivy", Requires: []string{"brew"}, Platforms: []string{"darwin", "linux"}, }, { Name: "apt", Command: "sudo apt-get install -y trivy", Requires: []string{"apt-get"}, Platforms: []string{"linux"}, }, { Name: "curl", Command: "curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin", Requires: []string{"curl"}, }, }, }, }
DefaultRegistry contains the default set of known tools. Projects can extend this with project-specific requirements.
Functions ¶
func FormatMissingError ¶
func FormatMissingError(result CheckResult) string
FormatMissingError creates a user-friendly error message for missing requirements.
Types ¶
type CLIPrompter ¶
CLIPrompter implements Prompter for terminal interaction.
func NewCLIPrompter ¶
func NewCLIPrompter() *CLIPrompter
NewCLIPrompter creates a CLIPrompter using stdin/stdout.
func (*CLIPrompter) Choose ¶
func (p *CLIPrompter) Choose(message string, options []string) (int, error)
func (*CLIPrompter) Error ¶
func (p *CLIPrompter) Error(message string)
func (*CLIPrompter) Info ¶
func (p *CLIPrompter) Info(message string)
func (*CLIPrompter) Warn ¶
func (p *CLIPrompter) Warn(message string)
type CheckResult ¶
type CheckResult struct {
Satisfied []string // Tools that are installed
Missing []MissingRequirement // Tools that need installation
Unknown []string // Tools not in registry
}
CheckResult contains the results of checking requirements.
func EnsureRequirements ¶
func EnsureRequirements(requires []string, prompter Prompter) CheckResult
EnsureRequirements checks requirements and prompts for installation of missing ones. Returns the final CheckResult after any installations.
func EnsureRequirementsWithChecker ¶
func EnsureRequirementsWithChecker(requires []string, checker *Checker, prompter Prompter) CheckResult
EnsureRequirementsWithChecker uses a custom checker.
func (CheckResult) AllSatisfied ¶
func (r CheckResult) AllSatisfied() bool
AllSatisfied returns true if all requirements are met.
type Checker ¶
type Checker struct {
Registry Registry
}
Checker validates requirements and finds available install methods.
func NewChecker ¶
func NewChecker() *Checker
NewChecker creates a Checker with the default registry.
func NewCheckerWithRegistry ¶
NewCheckerWithRegistry creates a Checker with a custom registry.
func (*Checker) Check ¶
func (c *Checker) Check(requires []string) CheckResult
Check validates a list of required tools and returns the results.
func (*Checker) GetAllInstallCommands ¶
func (c *Checker) GetAllInstallCommands(name string) []InstallMethod
GetAllInstallCommands returns all available install commands for a tool.
func (*Checker) GetInstallCommand ¶
GetInstallCommand returns the best install command for a tool. Returns empty string if no method is available.
func (*Checker) IsInstalled ¶
IsInstalled checks if a single tool is installed.
type InstallMethod ¶
type InstallMethod struct {
// Name identifies the method (e.g., "go", "brew", "helm", "apt", "npm").
Name string `json:"name" yaml:"name"`
// Command is the install command to run.
Command string `json:"command" yaml:"command"`
// Requires lists tools that must be present for this method to work.
// For example, "go install" requires "go".
Requires []string `json:"requires,omitempty" yaml:"requires,omitempty"`
// Platforms limits this method to specific OS (empty = all platforms).
// Values: "darwin", "linux", "windows"
Platforms []string `json:"platforms,omitempty" yaml:"platforms,omitempty"`
}
InstallMethod defines one way to install a tool.
type MissingRequirement ¶
type MissingRequirement struct {
Requirement Requirement
AvailableMethods []InstallMethod // Methods that can be used (prerequisites met)
SuggestedMethod *InstallMethod // First available method (recommended)
}
MissingRequirement represents a tool that is not installed.
type Prompter ¶
type Prompter interface {
// Info displays an informational message.
Info(message string)
// Warn displays a warning message.
Warn(message string)
// Error displays an error message.
Error(message string)
// Confirm asks a yes/no question.
Confirm(message string) (bool, error)
// Choose presents options and returns the selected index (-1 if cancelled).
Choose(message string, options []string) (int, error)
}
Prompter handles human-in-the-loop interactions.
type Registry ¶
type Registry map[string]Requirement
Registry maps tool names to their requirement definitions.
func (Registry) Get ¶
func (r Registry) Get(name string) *Requirement
Get returns the requirement for a tool name, or nil if not found.
type Requirement ¶
type Requirement struct {
// Name is the canonical tool name (matches multi-agent-spec requires field).
Name string `json:"name" yaml:"name"`
// Purpose describes what this tool is used for.
Purpose string `json:"purpose" yaml:"purpose"`
// Check is the command to verify the tool is installed (e.g., "releasekit --version").
Check string `json:"check" yaml:"check"`
// InstallMethods lists ways to install this tool, in priority order.
// The first available method will be suggested to the user.
InstallMethods []InstallMethod `json:"install_methods" yaml:"install_methods"`
// Homepage is the tool's documentation URL.
Homepage string `json:"homepage,omitempty" yaml:"homepage,omitempty"`
}
Requirement defines an external tool/binary that an agent may require.