role

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package role loads a role's contract (role.yaml) and the project's settings for it, as described in docs/spec/role-contract.md.

Index

Constants

This section is empty.

Variables

View Source
var Retired = map[string]string{
	"release-manager": "the release-manager role is retired: workline cuts no releases, it works with the release tool a project has " +
		"(docs/adr/0017-the-release-manager.md, ADR-0017). Release with one — release-please, release-plz, releaser-pleaser, " +
		"semantic-release or changesets; GoReleaser to publish — and route `release: [documentalist]` before it",
}

Retired says what replaces a role workline no longer ships, by its name.

Functions

func CheckConfig

func CheckConfig(data []byte) error

CheckConfig refuses a config holding a key the engine does not know.

func IsConfigError

func IsConfigError(err error) bool

IsConfigError reports whether err, or an error it wraps, is a ConfigError.

Types

type ConfigError

type ConfigError struct {
	// contains filtered or unexported fields
}

ConfigError is a .workline/config.yaml the engine cannot trust: unreadable, or holding a key it does not know. A key that is ignored is a setting someone believes in and nothing applies, so it blocks (principle 12).

func (*ConfigError) Error

func (e *ConfigError) Error() string

type Model

type Model struct {
	Capability   string `yaml:"capability"`
	Tier         string `yaml:"tier"`
	Effort       string `yaml:"effort"`
	PromoteAfter int    `yaml:"promote-after"`
	Timeout      string `yaml:"timeout"` // how long one answer may take, e.g. "10m"; default 3m
	// Tasks gives a kind of task, named by pre in in/task-kind, other needs
	// than the role's: condensing a doc needs more than judging one.
	Tasks map[string]Model `yaml:"tasks"`
}

Model is what kind of thinking a role needs (docs/spec/model-grid.md).

func (Model) AnswerTimeout

func (m Model) AnswerTimeout() (time.Duration, error)

AnswerTimeout is how long the agent may take for one answer.

func (Model) For

func (m Model) For(kind string) Model

For returns the needs of a task of that kind: the role's, with what model.tasks sets for the kind in their place.

type ProjectConfig

type ProjectConfig struct {
	AI    string `yaml:"ai"`    // default agent for this project: none, claude...
	Forge string `yaml:"forge"` // github, gitlab, or none
	Roles map[string]struct {
		Settings map[string]any    `yaml:"settings"`
		Enforce  map[string]string `yaml:"enforce"`
	} `yaml:"roles"`
}

ProjectConfig is the part of .workline/config.yaml the engine reads today.

func LoadProjectConfig

func LoadProjectConfig(repo string) (*ProjectConfig, error)

LoadProjectConfig reads <repo>/.workline/config.yaml. A missing file is an empty config; an unreadable or invalid one is an error.

type Role

type Role struct {
	Contract   int      `yaml:"contract"`
	Name       string   `yaml:"name"`
	Mission    string   `yaml:"mission"`
	Events     []string `yaml:"events"`
	Requires   []string `yaml:"requires"`
	Uses       []string `yaml:"uses"`
	Intentions []string `yaml:"intentions"`
	Model      Model    `yaml:"model"`
	Duties     struct {
		Reads  []string `yaml:"reads"`
		Writes []string `yaml:"writes"`
	} `yaml:"duties"`
	Context struct {
		Knowledge []string `yaml:"knowledge"`
		Budget    int      `yaml:"budget"`
	} `yaml:"context"`
	WithoutAI string         `yaml:"without-ai"`
	Settings  map[string]any `yaml:"settings"`

	Dir string `yaml:"-"`
}

Role is a parsed role.yaml, plus the folder it was loaded from.

func Load

func Load(rolesDir, name string) (*Role, error)

Load reads roles/<name>/role.yaml from rolesDir.

func (*Role) Accepts

func (r *Role) Accepts(event string) bool

Accepts reports whether the role can run on event.

func (*Role) Allows

func (r *Role) Allows(kind string) bool

Allows reports whether the role may emit an intention of this kind.

func (*Role) Enforcement

func (r *Role) Enforcement(c *ProjectConfig) map[string]string

Enforcement returns how hard each rule bites for this role in this project.

func (*Role) MergedSettings

func (r *Role) MergedSettings(c *ProjectConfig) map[string]any

MergedSettings returns the role's defaults overridden by the project's settings.

func (*Role) Writes

func (r *Role) Writes(settings map[string]any) []string

Writes returns the path patterns the role may write, with `$settings.<name>` replaced by the setting's value (a string or a list of strings).

Jump to

Keyboard shortcuts

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