agents

package
v0.10.257 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package agents loads trusted review agent definitions.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalid identifies malformed agent definitions or unsafe agent names.
	ErrInvalid = errors.New("agents: invalid")
	// ErrNotFound identifies a requested agent absent from a loaded catalog.
	ErrNotFound = errors.New("agents: not found")
	// ErrUnsafeSource identifies profile agent sources that are mutable or
	// ambiguous for PR review execution.
	ErrUnsafeSource = errors.New("agents: unsafe source")
)

Functions

func RequireSafeProfileSources added in v0.1.43

func RequireSafeProfileSources(dirs []string, invocationRoot string) error

RequireSafeProfileSources fails when profile sources are mutable or ambiguous for PR review execution.

Types

type Agent

type Agent struct {
	ID                   string     `json:"id"`
	Name                 string     `json:"name"`
	Category             Category   `json:"category"`
	Description          string     `json:"description,omitempty"`
	ModelTier            string     `json:"model_tier,omitempty"`
	ModelID              string     `json:"model_id,omitempty"`
	Effort               string     `json:"effort,omitempty"`
	FileGlobs            []string   `json:"file_globs,omitempty"`
	AppliesWhen          []string   `json:"applies_when,omitempty"`
	NeedsFullFileContent bool       `json:"needs_full_file_content"`
	Prompt               string     `json:"prompt,omitempty"`
	Provenance           Provenance `json:"provenance"`
	Overridden           []string   `json:"overridden,omitempty"`
}

Agent is one loaded review agent.

type Catalog

type Catalog struct {
	Agents  []Agent      `json:"agents"`
	Repo    *RepoInfo    `json:"repo,omitempty"`
	Sources []SourceInfo `json:"sources,omitempty"`
}

Catalog is the merged, precedence-resolved agent catalog.

func Load

func Load(ctx context.Context, opts LoadOptions) (Catalog, error)

Load builds a merged catalog from all configured sources.

func (Catalog) Find

func (c Catalog) Find(id string) (Agent, bool)

Find returns one agent by full ID.

type Category

type Category struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Owner       string `json:"owner,omitempty"`
}

Category is one agent category definition.

type LoadOptions

type LoadOptions struct {
	ProfileDirs               []string
	Repo                      *RepoSource
	FlagDirs                  []string
	RequireSafeProfileSources bool
	SafeProfileSourceRoot     string
	AllowSoftRepoFailures     bool
}

LoadOptions configures catalog loading.

type Provenance

type Provenance struct {
	Kind           SourceKind `json:"kind"`
	Label          string     `json:"label,omitempty"`
	Ref            string     `json:"ref,omitempty"`
	SHA            string     `json:"sha,omitempty"`
	Index          int        `json:"index,omitempty"`
	ConfiguredPath string     `json:"configured_path,omitempty"`
	CanonicalPath  string     `json:"canonical_path,omitempty"`
	Fingerprint    string     `json:"fingerprint,omitempty"`
	Warnings       []string   `json:"warnings,omitempty"`
}

Provenance identifies the winning source for one loaded agent.

func (Provenance) SourceInfo added in v0.1.35

func (p Provenance) SourceInfo() SourceInfo

SourceInfo returns the structured source details for this provenance.

func (Provenance) String

func (p Provenance) String() string

String returns the user-facing provenance label.

type RepoInfo

type RepoInfo struct {
	Ref        string `json:"ref"`
	SHA        string `json:"sha"`
	Provenance string `json:"provenance"`
}

RepoInfo describes the trusted repo-local source, when one was considered.

func (RepoInfo) TrustNote

func (r RepoInfo) TrustNote() string

TrustNote returns the human-readable base-branch trust-boundary note.

type RepoReader

type RepoReader interface {
	ListTreeAtRef(ctx context.Context, ref gitprovider.PRRef, gitRef string, treePath string) ([]gitprovider.TreeEntry, error)
	GetFileAtRef(ctx context.Context, ref gitprovider.PRRef, gitRef string, filePath string) ([]byte, error)
}

RepoReader is the narrow read seam needed to load repo-local agent files.

type RepoSource

type RepoSource struct {
	Reader RepoReader
	Ref    gitprovider.PRRef
	PR     gitprovider.PR
}

RepoSource pins repo-local agents to a resolved pull request base SHA.

type SourceInfo added in v0.1.35

type SourceInfo struct {
	Kind            SourceKind   `json:"kind"`
	Label           string       `json:"label,omitempty"`
	Ref             string       `json:"ref,omitempty"`
	SHA             string       `json:"sha,omitempty"`
	Index           int          `json:"index,omitempty"`
	ProvenanceLabel string       `json:"provenance"`
	ConfiguredPath  string       `json:"configured_path,omitempty"`
	CanonicalPath   string       `json:"canonical_path,omitempty"`
	Present         bool         `json:"present"`
	Status          SourceStatus `json:"status"`
	Fingerprint     string       `json:"fingerprint,omitempty"`
	Warnings        []string     `json:"warnings,omitempty"`
	Error           string       `json:"error,omitempty"`
}

SourceInfo describes one configured agent source for operator audit.

func InspectProfileSources added in v0.1.35

func InspectProfileSources(dirs []string) []SourceInfo

InspectProfileSources reports active-profile source status without failing on missing or unreadable deployment material.

type SourceKind

type SourceKind string

SourceKind identifies where an agent definition came from.

const (
	SourceProfile SourceKind = "profile"
	SourceRepo    SourceKind = "repo"
	SourceFlag    SourceKind = "flag"
)

Supported source kinds.

type SourceStatus added in v0.1.35

type SourceStatus string

SourceStatus reports whether a configured source is usable.

const (
	SourceStatusAvailable  SourceStatus = "available"
	SourceStatusMissing    SourceStatus = "missing"
	SourceStatusUnreadable SourceStatus = "unreadable"
	SourceStatusInvalid    SourceStatus = "invalid"
)

Supported source statuses.

Jump to

Keyboard shortcuts

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