Documentation
¶
Overview ¶
Package agentdex indexes three kinds of data and serves them through one coherent surface: the AI coding agents in a published catalog, the models.dev providers that power them, and the models those providers offer. It owns the outside of an agent — identity, location, paths, version, capability — and never reads an agent's internal configuration.
Open constructs an *Index with no network I/O; catalogs resolve lazily once under a guard. Options configure catalog source (registry module or local WithCatalogDir), caches, detection, and boundary inputs (env lookup, WithLookPath, working dir).
idx, err := agentdex.Open()
if err != nil { return err }
res, err := idx.Agents.List(ctx, agentdex.AgentQuery{Enrich: agentdex.EnrichCount})
Index exposes Agents, Providers, and Models, each with List and Get, plus Refresh and catalog/models staleness helpers. Detection is a property of an agent, not a top-level verb.
Enrich is the demand axis for agent operations (each level a superset):
- EnrichNone: catalog and detection only. Get never contacts models.dev; List does so only to validate a non-empty Providers filter.
- EnrichProviders: resolved provider set (offline for home-provider; validates caller ids for agnostic).
- EnrichCount: ProviderEnv, ModelCount, and coverage on Agents.Get.
- EnrichFull: full Models list on the same fetch as EnrichCount.
Installation does not gate enrichment. EnrichmentState records applied, not-requested, not-applicable (agnostic with no providers), or degraded.
Warnings carry Kind (branch) and Msg (emit verbatim) and are valid on the error return. Match errors with errors.Is against this package's sentinels; ErrModelsSchema aliases modelsdev.ErrModelsSchema. Adding an agent is a catalog edit: one generic detection path walks every entry.
Index ¶
- Variables
- type Agent
- type AgentDetail
- type AgentGetQuery
- type AgentQuery
- type AgentService
- type CatalogInfo
- type CatalogSource
- type CoverageStatus
- type Detection
- type Enrich
- type EnrichmentState
- type Index
- type KnownAgent
- type Model
- type ModelQuery
- type ModelScope
- type ModelService
- type Option
- func WithBinPaths(m map[string]string) Option
- func WithCacheDir(dir string) Option
- func WithCatalogDir(dir string) Option
- func WithCatalogModule(path string) Option
- func WithCatalogTTL(d time.Duration) Option
- func WithEnvLookup(fn func(string) (string, bool)) Option
- func WithHTTPClient(hc *http.Client) Option
- func WithLogger(l *slog.Logger) Option
- func WithLookPath(fn func(string) (string, error)) Option
- func WithModelsTTL(d time.Duration) Option
- func WithModelsURL(url string) Option
- func WithSearchDirs(dirs ...string) Option
- func WithWorkingDir(dir string) Option
- type PathEntry
- type Provider
- type ProviderCoverage
- type ProviderQuery
- type ProviderService
- type Refreshed
- type ResolvedPaths
- type Result
- type SkillsPaths
- type SkillsScope
- type Target
- type Warning
- type WarningKind
Constants ¶
This section is empty.
Variables ¶
var ( ErrCatalogUnavailable = errors.New("agentdex catalog unavailable") // ErrCatalogInvalid is a module that loaded but failed schema evaluation (data, not network). ErrCatalogInvalid = errors.New("agentdex catalog invalid") // Agent operations degrade instead. ErrModelsUnavailable = errors.New("models.dev unavailable") // ErrModelsSchema is the same value as modelsdev.ErrModelsSchema. ErrModelsSchema = modelsdev.ErrModelsSchema // ErrAgentUnknown is an agent id absent from the catalog. ErrAgentUnknown = errors.New("unknown agent id") // ErrUnknownProvider is a caller provider id models.dev does not know. ErrUnknownProvider = errors.New("unknown provider id") // ErrProvidersRequired is a model listing scoped to an agnostic agent with no providers. ErrProvidersRequired = errors.New("providers required for agnostic agent") // ErrProvidersNotAllowed is a home-provider agent given an explicit provider set. ErrProvidersNotAllowed = errors.New("providers not allowed for home-provider agent") // ErrMalformedModelID is a model composite with no "/". ErrMalformedModelID = errors.New("malformed model id") // ErrNotFound is a provider or model exact-get miss. ErrNotFound = errors.New("not found") )
Exported sentinels for errors.Is. Detail rides the wrapping message (library- owned). ErrModelsSchema aliases modelsdev.ErrModelsSchema (same value).
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
KnownAgent
Detection Detection
ResolvedProviders []string
ProviderEnv map[string]bool // API-key env -> present; nil when models.dev not consulted
Enrichment EnrichmentState
ModelCount int // meaningful when Enrichment == EnrichmentApplied
Models []Model // EnrichFull only; newest release first
}
Agent is catalog facts joined with detection and, from EnrichProviders upward, the resolved provider set and models.dev data. ResolvedProviders is empty below EnrichProviders and when an agnostic agent has no set.
type AgentDetail ¶
type AgentDetail struct {
Agent
Coverage ProviderCoverage
Warnings []Warning
}
AgentDetail is Agents.Get: Agent plus coverage verdict and this fetch's warnings.
type AgentGetQuery ¶
AgentGetQuery selects enrichment level and the agnostic provider set for Agents.Get.
type AgentQuery ¶
AgentQuery narrows and enriches an Agents.List. Providers is the listing-wide set for agnostic rows, validated at the boundary.
type AgentService ¶
type AgentService struct {
// contains filtered or unexported fields
}
AgentService browses and fetches agents joined with detection and enrichment.
func (AgentService) Get ¶
func (s AgentService) Get(ctx context.Context, id string, q AgentGetQuery) (AgentDetail, error)
Get returns detection detail for one agent, selected exactly by its catalog id. Coverage verdicts and not-installed or agnostic-without-providers are data plus warnings, never errors; warnings also ride the error return.
func (AgentService) List ¶
func (s AgentService) List(ctx context.Context, q AgentQuery) (Result[Agent], error)
List browses the catalog with local detection and, from EnrichProviders upward, the resolved provider set and models.dev enrichment. Detection fans out concurrently; no per-agent coverage is probed. Providers is validated once at the boundary at every level; an unknown id fails the whole listing.
type CatalogInfo ¶
type CatalogInfo struct {
Source CatalogSource
Dir string // set when Source is CatalogSourceDir
Module string // major-line path when Source is CatalogSourceRegistry
Version string // resolved version when Source is CatalogSourceRegistry
Stale bool
}
CatalogInfo is the identity of the loaded agent catalog. A directory source has no version and is never stale.
type CatalogSource ¶
type CatalogSource int
CatalogSource identifies where the agent catalog was loaded from.
const ( // CatalogSourceRegistry is the CUE Central Registry (or CUE_REGISTRY). CatalogSourceRegistry CatalogSource = iota // CatalogSourceDir is a local CUE module directory from WithCatalogDir. CatalogSourceDir )
func (CatalogSource) String ¶
func (s CatalogSource) String() string
String returns the constant name for known sources, or CatalogSource(n) for others.
type CoverageStatus ¶
type CoverageStatus int
CoverageStatus is the verdict of probing one agent's catalog provider set against models.dev. Zero is CoverageNotProbed; other values are probe results.
const ( // CoverageNotProbed means no models.dev contact, so no verdict. CoverageNotProbed CoverageStatus = iota CoverageAllPresent CoverageSomePresent CoverageNonePresent CoverageUnreachable CoverageSchemaDrift )
func (CoverageStatus) String ¶
func (s CoverageStatus) String() string
String returns the constant name for known statuses, or CoverageStatus(n) for others.
type Detection ¶
type Detection struct {
Found bool
BinaryPath string
Version string
Config ResolvedPaths
Skills SkillsPaths
}
Detection is what locating an agent found on this machine. Found gates only BinaryPath and Version; paths resolve the same whether or not the binary is installed.
type Enrich ¶
type Enrich int
Enrich selects how much provider and models.dev data an agent operation attaches. Each level is a superset of the one below.
const ( // EnrichNone is catalog and detection only. Get never contacts models.dev; List // still validates a non-empty Providers filter against it at every level. EnrichNone Enrich = iota // EnrichProviders adds the resolved provider set only (offline for home-provider; // validates caller ids for agnostic). EnrichProviders // EnrichCount adds ProviderEnv and ModelCount (and coverage on Agents.Get). EnrichCount // EnrichFull adds the Models list on the same fetch as EnrichCount. EnrichFull )
type EnrichmentState ¶
type EnrichmentState int
EnrichmentState records the outcome of enrichment on a returned Agent.
const ( // EnrichmentNotRequested means Enrich was EnrichNone. EnrichmentNotRequested EnrichmentState = iota // EnrichmentApplied means the requested level was satisfied in full. EnrichmentApplied // EnrichmentNotApplicable is agnostic with no providers: outside facts only, // distinct from a real empty result. EnrichmentNotApplicable // EnrichmentDegraded means models.dev could not fill the level, so ModelCount is // not a true zero. Fault rides a List warning or Get coverage verdict. EnrichmentDegraded )
func (EnrichmentState) String ¶
func (s EnrichmentState) String() string
String returns the constant name for known states, or EnrichmentState(n) for others.
type Index ¶
type Index struct {
Agents AgentService
Providers ProviderService
Models ModelService
// contains filtered or unexported fields
}
Index is the entry point and facade returned by Open. Safe for concurrent use: lazy catalog/models.dev resolution and Refresh publish under guards.
func Open ¶
Open constructs an *Index over the configured catalog source and models.dev client. No network I/O and no context: both catalogs resolve lazily once under the first needing operation's context. Safe for concurrent use. WithCatalogDir and WithCatalogModule are mutually exclusive.
func (*Index) CatalogInfo ¶
func (x *Index) CatalogInfo(ctx context.Context) (CatalogInfo, error)
CatalogInfo returns the loaded agent catalog's identity. Lazy like other catalog ops: cold-offline first call is ErrCatalogUnavailable, not empty.
func (*Index) CatalogStale ¶
CatalogStale is CatalogInfo(ctx).Stale. WithCatalogDir is never stale.
func (*Index) ModelsStale ¶
ModelsStale reports a models.dev stale-cache fallback. Lazy load; cold-offline with nothing cached is ErrModelsUnavailable, not a misleading false.
func (*Index) Refresh ¶
Refresh forces re-resolution or refetch past caches and publishes the result. TargetAll runs catalog then models.dev and stops at the first failure; Refreshed names only targets that completed. Failed targets leave prior state untouched. WithCatalogDir has nothing to re-resolve (not-refreshed, no error).
type KnownAgent ¶
type KnownAgent struct {
ID string
Name string
Bin string
Description string
Homepage string
CatalogProviders []string
Agnostic bool
}
KnownAgent is one catalog entry as identity and capability (no resolved paths). ID is the catalog map key. CatalogProviders is empty when Agnostic is true.
type Model ¶
type Model struct {
modelsdev.Model
Provider string `json:"provider"`
CanonicalID string `json:"canonical_id,omitempty"`
}
Model is a models.dev model with its provider and optional agnostic-catalog key. Every surface returns this type so a short id is never detached from its provider.
type ModelQuery ¶
type ModelQuery struct {
Scope ModelScope
Filter string
}
ModelQuery scopes and narrows a Models.List.
type ModelScope ¶
ModelScope selects the provider set a model listing spans. Providers is also the enrichment set for an agnostic Agent.
type ModelService ¶
type ModelService struct {
// contains filtered or unexported fields
}
ModelService browses and fetches models across models.dev providers.
func (ModelService) Get ¶
Get returns one model by composite provider-id/model-id. Splits on the first slash only (model key may contain slashes). No agent catalog, no warnings channel.
func (ModelService) List ¶
func (s ModelService) List(ctx context.Context, q ModelQuery) (Result[Model], error)
List browses models across the scoped providers, newest release first. Empty scope spans every models.dev provider. Each Model carries its provider and optional agnostic-map canonical id. Stale warnings ride the error path too.
type Option ¶
type Option func(*options)
Option configures Open. Nondeterministic inputs that shape reported values enter here (except process cache dir and clock). PATH search via WithLookPath.
func WithBinPaths ¶
WithBinPaths overrides agents' binary paths by id (filesystem path, not PATH- resolved; relative roots at working directory; used for the version exec).
func WithCacheDir ¶
WithCacheDir sets the catalog resolution and models.dev cache directory. The clock stays on the process.
func WithCatalogDir ¶
WithCatalogDir evaluates a local CUE module (never stale, no network). Mutually exclusive with WithCatalogModule; schema reject is ErrCatalogInvalid.
func WithCatalogModule ¶
WithCatalogModule overrides the registry catalog module path. Mutually exclusive with WithCatalogDir.
func WithCatalogTTL ¶
WithCatalogTTL sets the catalog version-resolution cache TTL. Inert under WithCatalogDir.
func WithEnvLookup ¶
WithEnvLookup supplies env for provider-env presence and path expansion ($VAR, ~). Default os.LookupEnv. Only presence is taken from a variable, never its value.
func WithHTTPClient ¶
WithHTTPClient overrides the HTTP client models.dev is fetched with.
func WithLogger ¶
WithLogger threads a structured logger through decision points. Default is discard so the library is silent unless a caller opts in.
func WithLookPath ¶
WithLookPath supplies PATH search for agent binaries (default exec.LookPath). Non-executable or failed hits fall through to WithSearchDirs. Inject a closed or fixture-scoped function so host PATH never leaks into detection.
func WithModelsTTL ¶
WithModelsTTL sets the models.dev cache TTL.
func WithModelsURL ¶
WithModelsURL overrides the models.dev catalog source URL.
func WithSearchDirs ¶
WithSearchDirs adds binary search locations consulted after PATH.
func WithWorkingDir ¶
WithWorkingDir sets the base for relative local config, skills, or binary paths. Default os.Getwd.
type PathEntry ¶
PathEntry is one expanded catalog path with on-disk existence. Path is "" when that role is unsupported for the agent/scope.
type ProviderCoverage ¶
type ProviderCoverage struct {
Present []string
Absent []string
Status CoverageStatus
// Err wraps the models.dev fault for Unreachable/SchemaDrift so errors.Is works.
Err error
}
ProviderCoverage is per-provider models.dev coverage of one agent's set, as data.
type ProviderQuery ¶
type ProviderQuery struct {
Filter string
}
ProviderQuery narrows a Providers.List by case-insensitive id/name substring.
type ProviderService ¶
type ProviderService struct {
// contains filtered or unexported fields
}
ProviderService browses and fetches models.dev providers.
func (ProviderService) Get ¶
Get returns one models.dev provider by id with API-key env presence. Unknown id is ErrNotFound. Loads no agent catalog (no warnings channel).
func (ProviderService) List ¶
func (s ProviderService) List(ctx context.Context, q ProviderQuery) (Result[Provider], error)
List browses models.dev providers by id order, optionally filtered. Loads no agent catalog. Stale fallback raises WarnModelsStale; outage is ErrModelsUnavailable; schema drift propagates modelsdev.ErrModelsSchema.
type ResolvedPaths ¶
ResolvedPaths is a catalog directory pair after expansion, with existence per scope. Local is "" when the catalog defines no local scope.
type Result ¶
Result is the symmetric return of every List: ordered items and warnings. Warnings are valid on the error return; read Items only when err is nil.
type SkillsPaths ¶
type SkillsPaths struct {
Global SkillsScope
Local SkillsScope
}
SkillsPaths is resolved skills by scope. Zero means the agent has no skills concept.
type SkillsScope ¶
type SkillsScope struct {
Agents PathEntry
Native PathEntry
Alternatives []PathEntry
Primary PathEntry
}
SkillsScope is one scope's classified skill roots after expansion. Primary: agents else native else Alternatives[0]. Alternatives is priority order.
type Warning ¶
type Warning struct {
Kind WarningKind
Msg string
}
Warning is Kind for branching and Msg for verbatim emission.
type WarningKind ¶
type WarningKind int
WarningKind classifies a non-fatal condition. Same kind may carry different Msg wording per operation; branch on Kind, emit Msg verbatim.
const ( WarnStaleCatalog WarningKind = iota WarnModelsUnreachable WarnModelsSchemaDrift WarnSomeProvidersAbsent WarnNotInstalled // WarnProvidersRequired is guidance: agnostic agent reported without providers. WarnProvidersRequired // WarnModelsStale: stale cache fallback after failed refetch; only when consulted. WarnModelsStale )
func (WarningKind) String ¶
func (k WarningKind) String() string
String returns the constant name for known kinds, or WarningKind(n) for others.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
agentdex
command
Command agentdex is the thin CLI over the agentdex detection library.
|
Command agentdex is the thin CLI over the agentdex detection library. |
|
internal
|
|
|
catalog
Package catalog fetches the agentdex agent catalog from the CUE Central Registry, validates it by evaluating the fetched module against its bundled schema, caches the resolved module version, and decodes the catalog into an internal representation.
|
Package catalog fetches the agentdex agent catalog from the CUE Central Registry, validates it by evaluating the fetched module against its bundled schema, caches the resolved module version, and decodes the catalog into an internal representation. |
|
catalogtest
Package catalogtest provides a stub registry and fixture helpers shared by the catalog loader tests and the root-package mapping tests.
|
Package catalogtest provides a stub registry and fixture helpers shared by the catalog loader tests and the root-package mapping tests. |
|
cli
Package cli is the agentdex command-line interface: a thin wrapper over the agentdex library and the modelsdev client.
|
Package cli is the agentdex command-line interface: a thin wrapper over the agentdex library and the modelsdev client. |
|
config
Package config loads and validates the agentdex user configuration (config.cue), resolves the XDG paths it lives under, resolves the per-cache TTLs, and maps the configuration together with the global flags into the agentdex library options and the modelsdev client options.
|
Package config loads and validates the agentdex user configuration (config.cue), resolves the XDG paths it lives under, resolves the per-cache TTLs, and maps the configuration together with the global flags into the agentdex library options and the modelsdev client options. |
|
modelsdevtest
Package modelsdevtest provides shared models.dev test doubles: fixture providers and the httptest servers that serve them, so library and CLI tests exercise the same deterministic, network-free models.dev.
|
Package modelsdevtest provides shared models.dev test doubles: fixture providers and the httptest servers that serve them, so library and CLI tests exercise the same deterministic, network-free models.dev. |
|
tui
Package tui renders agentdex's human-facing text output: NO_COLOR-aware colour styling and aligned tables.
|
Package tui renders agentdex's human-facing text output: NO_COLOR-aware colour styling and aligned tables. |
|
Package modelsdev is a reusable client for models.dev, the community database of model specifications, pricing, and capabilities.
|
Package modelsdev is a reusable client for models.dev, the community database of model specifications, pricing, and capabilities. |