intent

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 9 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 intent holds the definition of an intent, as its manifest declares it, and the registry of every loaded intent.

Index

Constants

View Source
const AnyProvider unit.ProviderID = "any"

AnyProvider is the provider of an intent whose turns run on units of every provider.

View Source
const DimReviewer = "reviewer"

DimReviewer is the profile dimension that selects an address round by a reviewer it answers.

View Source
const DimStage = "stage"

DimStage is the profile dimension that selects by the pass over a unit: first or follow-up.

Variables

This section is empty.

Functions

func Normalize

func Normalize(spec Input, v any) (any, error)

Normalize is v as the input's type: a bool a bool, a text a string, a list a []string, whatever JSON decoded them as.

func OrList

func OrList(names []string) string

OrList joins names as a message lists alternatives: "a, b or c".

func Zero

func Zero(v any) bool

Zero tells an input value that is unset: nil, its type's zero, or an empty list or map.

Types

type Action

type Action struct {
	Group    string
	Surfaces []string
	When     Pred
	Primary  Pred
	// Refuse are the cases that offer the action disabled; the first whose
	// When holds gives its Why.
	Refuse  []Refusal
	Note    Text
	Warning Text
	Confirm Text
}

Action is how an intent's action is offered on a row. Its description is the intent's Summary.

type AlsoProfile

type AlsoProfile struct {
	Profile, Define, Prefix string
	// Dims pins dimensions of the other judgment, such as stage = first.
	Dims map[string]string
	When Pred
}

type Brief

type Brief struct {
	Render, Wait bool
	// Need are the brief intent's extra fields the turn needs: a brief
	// missing one is completed before the turn starts.
	Need []string
}

type Case

type Case struct {
	When Pred
	Text Text
}

type Def

type Def struct {
	Name       Name
	Label      string
	Summary    string
	Key        string
	Verb       string // the gtd verb its action fulfills; "" for none
	UserFacing bool
	Workspace  string // review | author | linked_else_main | given
	Session    Session
	Context    string // pr | synthetic, from the role
	Launch     string // "" | probe, from the role
	Policy     string // round | probe, from the role
	Intake     bool
	StartLine  string
	OwnerOnly  bool
	Answerable bool
	Board      string // review | author | none, from the workspace
	DrivesRow  bool   // from the role, moved to a user intent that takes it
	Reports    bool
	Reconcile  string // "" | my_review, from the role
	Brief      Brief
	Profile    string // "" means none
	Dims       []string
	// Records is [record] when.
	Records Pred
	Prepare string // from the role
	// Effects are what sending the turn applies, turn effects of
	// builtin.Effects.
	Effects      []string
	Headline     Headline
	Guidance     Guidance
	Inputs       []Input // sorted by name
	AlsoProfiles []AlsoProfile
	Action       *Action // nil: not offered
	Join         Join
	Record       RecordRules
	Resume       Resume
	Source       Source
	Bundled      bool
	// Provider is the manifest's provider; default "github".
	Provider unit.ProviderID
	// DraftApproval is the manifest's [drafts.approval] block; nil when absent.
	DraftApproval *draft.Policy
	// Runners are turn.Runner values; default ["session"].
	Runners []string
	// Providers are the providers of a manifest whose provider is a list,
	// Provider the first; nil for a single provider.
	Providers []unit.ProviderID
	// Role is what Go resolves the intent by (Registry.ByRole), one of
	// builtin.Roles; "" none.
	Role string
	// Builds is what a builder intent builds, such as "brief": it is never
	// started as a turn. Prompt and Schema are its prompt, resolved through
	// the profile layers, and its schema, in its directory.
	Builds, Prompt, Schema string
	// Extra are a brief builder's extra fields, the top-level properties of
	// its Schema as the loader compiled it; nil for any other intent.
	Extra []jsonschema.Property
	// WorkspaceRepo is a manifest's workspace table: the repository the
	// turn runs in, named outright or by an input; nil for a workspace
	// builtin.
	WorkspaceRepo *WorkspaceRepo
	// AllowedEffects are the effects the intent's agents may declare on the
	// drafts they propose, names of builtin.Effects.
	AllowedEffects []string
	// RoundKind is the sweep round the intent's turns are, from its role:
	// "review" (first or follow-up, by the step's stage) or "address"; ""
	// none.
	RoundKind string
	// Why is the template, over the unit's workflow facts, that says why
	// the intent's turn is due; empty for none.
	Why Text
	// Refuse are the refusals of turn.start, in order: the first whose when
	// holds refuses with its why.
	Refuse []Refuse
	// Skill says whether install writes the intent a turn skill.
	Skill bool
	Help  Help
}

func (Def) NormalizeAll

func (d Def) NormalizeAll(in map[string]any) (map[string]any, error)

NormalizeAll normalizes inputs read back from a stored request, keeping only the declared ones.

func (Def) ProviderOrDefault

func (d Def) ProviderOrDefault() unit.ProviderID

ProviderOrDefault is the provider whose units the intent's turns run on; the loader fills it from the profile's defaults when the manifest names none.

func (Def) Runs

func (d Def) Runs(runner string) bool

Runs says whether the intent's turns may run under runner, a turn.Runner value; nil Runners run as session only.

func (Def) Serves

func (d Def) Serves(p unit.ProviderID) bool

Serves says whether the intent's turns run on units of p.

type Guidance

type Guidance struct {
	Label, Help string
	Max         int
}

type Headline

type Headline struct {
	Resumed Text
	New     []Case // the last case has an empty When
}

type Help added in v0.2.0

type Help struct {
	// Target says what the command's target is, such as "a pull request
	// URL"; the turn skill and the command's help read it.
	Target string
	// Summary is the main help's line for the command, Summary when empty.
	Summary string
	// Group is the title of the main help's group the command joins, in
	// any case; "" or a title the help has not joins the user's intents.
	Group string
	// Examples are command lines without the command's name.
	Examples []string
	// Docs is a page path of the documentation site.
	Docs string
}

Help is how the intent's command and turn skill present it.

type Input

type Input struct {
	Name       string
	Type       string // flag | text | list
	Flag       string
	Help       string
	From       string // user | prepare
	Persist    bool
	Hidden     bool
	ByHandOnly bool
	Before     string
	Max        int
	Surfaces   []string
	At         Pos
}

func (Input) Label

func (in Input) Label() string

Label is how a message names an input: its flag, else its field.

type Join

type Join struct{ DiffersOn []string }

type Name

type Name string

Name is an intent's name: the directory of its manifest.

const (
	Review  Name = "review"
	Address Name = "address"
	Nudge   Name = "nudge"
	Probe   Name = "probe"
	Act     Name = "act"
)

The intents Go binds by name; every other use of an intent goes through the registry.

type Pos

type Pos struct {
	File      string
	Line, Col int
}

type Pred

type Pred struct {
	Src string
	At  Pos
}

Pred is a predicate's source and where its value starts; compiled programs live in the loader.

type RecordRules

type RecordRules struct {
	States          []string // done settled asked failed
	Artifacts       []string
	Outcome         []string // verdict url
	OutcomeDoc      string
	HistoryArtifact string
	Require         []Require
}

type Refusal added in v0.2.0

type Refusal struct {
	When Pred
	Why  Text
}

Refusal is one [[action.refuse]] case.

type Refuse added in v0.2.0

type Refuse struct {
	When Pred
	Why  Text
}

Refuse is a refusal of turn.start: when holds over the unit's workflow facts, why says it.

type Registry

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

Registry is the set of loaded intents, read-only once built.

func NewRegistry

func NewRegistry(defs []Def) *Registry

func (*Registry) All

func (r *Registry) All() []Def

func (*Registry) AllNames

func (r *Registry) AllNames() string

AllNames is Names over every intent, user-facing or not.

func (*Registry) Answerable

func (r *Registry) Answerable() []string

func (*Registry) Builder added in v0.2.0

func (r *Registry) Builder(what string, p unit.ProviderID) (Def, bool)

Builder is the intent that builds what for units of p, such as the brief: the user's holder over the bundled one.

func (*Registry) ByRole added in v0.2.0

func (r *Registry) ByRole(role string, p unit.ProviderID) (Def, bool)

ByRole is the intent holding role for units of p: a user's intent over the bundled one; the loader refuses two holders in one layer.

func (*Registry) ClosesWhenDone

func (r *Registry) ClosesWhenDone(intent string) bool

func (*Registry) DeclaringFlag

func (r *Registry) DeclaringFlag(flag string) []Name

func (*Registry) ForProvider

func (r *Registry) ForProvider(p unit.ProviderID) []Def

ForProvider is the intents whose turns run on units of p.

func (*Registry) Get

func (r *Registry) Get(n Name) (Def, bool)

func (*Registry) Names

func (r *Registry) Names() string

Names is "address, ask-author, nudge or review": user-facing, for messages.

func (*Registry) Reconcile

func (r *Registry) Reconcile(intent string) string

func (*Registry) Rules

func (r *Registry) Rules(intent string) (RecordRules, error)

Rules, Answerable, ClosesWhenDone, Reconcile and SessionTitles satisfy turns.Intents.

func (*Registry) SessionTitles

func (r *Registry) SessionTitles() []string

SessionTitles is session.title of the user-facing intents, each once.

func (*Registry) UserFacing

func (r *Registry) UserFacing() []Def

type Require

type Require struct {
	State, Artifact string
	Fields          []string
}

type Resume

type Resume struct{ Changed string }

Resume holds Changed, the text a resumed turn reads when its unit changed since the question.

type Session

type Session struct {
	Strategy      string // reuse_live | new
	Title         string
	CloseWhenDone bool
}

type Source

type Source struct {
	Layer, Dir string // Dir "" for bundled
	// Overrides are the files, relative to Dir, that replace a bundled
	// intent's; the bundled intent's other files are inherited.
	Overrides []string
}

type Text

type Text struct {
	Src string
	At  Pos
}

Text is a text/template source.

type WorkspaceRepo added in v0.2.0

type WorkspaceRepo struct {
	Repo, RepoInput string
}

WorkspaceRepo is where a turn runs when its manifest names a repository: Repo (owner/name) outright, or the input RepoInput holds.

Jump to

Keyboard shortcuts

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