registry

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package registry loads the desired-state TOML (accounts, profiles, projects), validates it and syncs it into the database.

Index

Constants

View Source
const (
	PushNone        = "none"        // nobody: otag never pushes
	PushCoordinator = "coordinator" // the project's coordinator and the human (default)
	PushChild       = "child"       // also the task's own child run
)

Push policies (projects.push): who may run `otag task push`.

View Source
const FakeHarness = "fake"

FakeHarness is the scripted test/demo harness (internal/adapter/fake). It is valid in the registry but is not a CLI that doctor looks for.

Variables

View Source
var Harnesses = []string{"claude", "codex", "opencode"}

Harnesses supported by otag.

PushPolicies lists the push values.

Functions

func ValidHarness

func ValidHarness(h string) bool

ValidHarness reports whether h may be used by an account.

Types

type Account

type Account struct {
	Harness   string            `toml:"harness" json:"harness"`
	ConfigDir string            `toml:"config_dir" json:"config_dir,omitempty"`
	Command   string            `toml:"command" json:"command,omitempty"`
	Env       map[string]string `toml:"env" json:"env,omitempty"`
	// Quota tunes the quota collectors (internal/quota); nil = defaults.
	Quota *AccountQuota `toml:"quota" json:"quota,omitempty"`
}

Account is a harness login/config directory; quota lives here.

type AccountQuota

type AccountQuota struct {
	Disabled bool `toml:"disabled" json:"disabled,omitempty"`
	// OAuthUsage (claude) polls the undocumented OAuth usage endpoint with the token
	// Claude Code keeps in the Keychain (read-only, never refreshed). Off by default.
	OAuthUsage bool `toml:"oauth_usage" json:"oauth_usage,omitempty"`
	// LiteLLMProvider (opencode) names the provider in opencode.json whose /key/info is
	// read; default "litellm" or the only provider mentioning LiteLLM.
	LiteLLMProvider string `toml:"litellm_provider" json:"litellm_provider,omitempty"`
}

AccountQuota is the optional [accounts.<name>.quota] table.

type Config

type Config struct {
	Dir      string             `toml:"-"`
	Accounts map[string]Account `toml:"accounts"`
	Profiles map[string]Profile `toml:"profiles"`
	Projects []Project          `toml:"-"`
	// Warnings are non-fatal findings (unknown keys, missing project dirs).
	Warnings []string `toml:"-"`
}

Config is the full desired state.

func Load

func Load(dir string, getenv paths.Getenv) (*Config, error)

Load reads <dir>/registry.toml and <dir>/projects/*.toml, then validates.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks references, enums and duplicates. Fallback lists are not transitive (a run only walks its own profile's list), so mutual fallbacks such as c1 <-> c2 are allowed.

type Counts

type Counts struct {
	Added     int `json:"added"`
	Updated   int `json:"updated"`
	Unchanged int `json:"unchanged"`
	Retired   int `json:"retired"`
}

Counts summarizes what sync did to one table.

type Profile

type Profile struct {
	Account     string            `toml:"account" json:"account"`
	Model       string            `toml:"model" json:"model,omitempty"`
	Effort      string            `toml:"effort" json:"effort,omitempty"`
	Mode        string            `toml:"mode" json:"mode"`
	Tags        []string          `toml:"tags" json:"tags,omitempty"`
	Fallback    []string          `toml:"fallback" json:"fallback,omitempty"`
	Env         map[string]string `toml:"env" json:"env,omitempty"`
	Args        []string          `toml:"args" json:"args,omitempty"`
	Description string            `toml:"description" json:"description,omitempty"`
	// EnvPassthrough names variables of otag's own environment a run of this profile
	// gets (a trailing * matches a prefix), e.g. a LiteLLM key an OpenCode config
	// reads with {env:VAR}. Runs start with a clean environment otherwise.
	EnvPassthrough []string `toml:"env_passthrough" json:"env_passthrough,omitempty"`
}

Profile is account + model + effort + env + mode, with an ordered fallback list.

type ProfileRow

type ProfileRow struct {
	Name        string   `json:"name"`
	Account     string   `json:"account"`
	Harness     string   `json:"harness"`
	Model       string   `json:"model"`
	Effort      string   `json:"effort"`
	Mode        string   `json:"mode"`
	Tags        []string `json:"tags"`
	Fallback    []string `json:"fallback"`
	Description string   `json:"description"`
	ConfigHash  string   `json:"config_hash"`
}

ProfileRow is an active profile as stored in the database.

func ListProfiles

func ListProfiles(ctx context.Context, q db.Querier, tag string) ([]ProfileRow, error)

ListProfiles returns active profiles, optionally only those carrying tag.

type Project

type Project struct {
	Name               string   `toml:"name"`
	Path               string   `toml:"path"`
	Prefix             string   `toml:"prefix"`
	CoordinatorProfile string   `toml:"coordinator_profile"`
	DefaultProfile     string   `toml:"default_profile"`
	ReviewProfile      string   `toml:"review_profile"`
	Workspace          string   `toml:"workspace"`
	Deny               []string `toml:"deny"`
	// Guard is the guard level of the project's runs: light (default) | strict
	// (internal/guard, docs/ADAPTERS.md "Threat model").
	Guard string `toml:"guard"`
	// Base is the ref new task branches start from ("" = the project's HEAD); a
	// remote-tracking ref (origin/dev) is fetched first.
	Base string `toml:"base"`
	// BranchPrefix starts every new task branch: <branch_prefix><task>. Unset:
	// workspace.DefaultBranchPrefix; "" is allowed (the task id alone).
	BranchPrefix string `toml:"branch_prefix"`
	// Remote is where `otag task push` pushes ("" = the remote of a remote-tracking
	// base, else origin).
	Remote string `toml:"remote"`
	// Push is who may run `otag task push`: none | coordinator (default; and the
	// human) | child (also the task's own run).
	Push string `toml:"push"`
	// Raw holds every key of the file, including extra ones, for the config column.
	Raw  map[string]any `toml:"-"`
	File string         `toml:"-"`
}

Project is one projects/<name>.toml file.

func LoadProjects added in v0.1.1

func LoadProjects(dir string, getenv paths.Getenv) ([]Project, error)

LoadProjects reads only <dir>/projects/*.toml (no validation against the registry): what `otag init --force` keeps while it replaces registry.toml.

type ProjectRow

type ProjectRow struct {
	ID                 int64    `json:"-"`
	Name               string   `json:"name"`
	Path               string   `json:"path"`
	Prefix             string   `json:"prefix"`
	CoordinatorProfile string   `json:"coordinator_profile"`
	DefaultProfile     string   `json:"default_profile"`
	ReviewProfile      string   `json:"review_profile"`
	WorkspaceMode      string   `json:"workspace_mode"`
	Deny               []string `json:"deny"`
	Guard              string   `json:"guard"` // light | strict
	Base               string   `json:"base"`  // "" = the project's HEAD
	BranchPrefix       string   `json:"branch_prefix"`
	Remote             string   `json:"remote"` // "" = the base's remote, else origin
	Push               string   `json:"push"`   // none | coordinator | child
}

ProjectRow is an active project as stored in the database.

func ListProjects

func ListProjects(ctx context.Context, q db.Querier) ([]ProjectRow, error)

ListProjects returns active projects ordered by name.

type SyncResult

type SyncResult struct {
	Accounts  Counts   `json:"accounts"`
	Profiles  Counts   `json:"profiles"`
	Projects  Counts   `json:"projects"`
	Fallbacks int      `json:"fallback_lists_changed"`
	Warnings  []string `json:"warnings"`
}

SyncResult is returned by Sync.

func Sync

func Sync(ctx context.Context, tx *sql.Tx, cfg *Config, actor string) (SyncResult, error)

Sync upserts cfg into the database inside tx. Rows missing from cfg are retired, never deleted, so historic foreign keys stay valid. Running it twice is a no-op.

Jump to

Keyboard shortcuts

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