agents

package
v0.1.32 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 12 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")
)

Functions

This section is empty.

Types

type Agent

type Agent struct {
	ID                   string     `json:"id"`
	Name                 string     `json:"name"`
	Category             Category   `json:"category"`
	Description          string     `json:"description,omitempty"`
	Model                string     `json:"model,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"`
}

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
}

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"`
}

Provenance identifies the winning source for one loaded agent.

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 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.

Jump to

Keyboard shortcuts

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