intent

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 8 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 DimRound = "round"

DimRound is the profile dimension that selects by review round.

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 flag 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
	Visible          Pred
	Enabled          Pred
	ReasonOff        Text
	Primary          Pred
	Confirm          Text
	Hint             Text
	NoteWhenQuestion string
}

type AlsoProfile

type AlsoProfile struct {
	Profile, Round, Define, SourcePrefix string
	When                                 Pred
}

type Brief

type Brief struct{ Render, Wait bool }

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 | pr_else_main | given
	Session      Session
	Context      string // pr | synthetic
	Launch       string // "" | probe
	Policy       string // round | probe
	Intake       bool
	StartLine    string
	OwnerOnly    bool
	Answerable   bool
	Board        string // review | author | none
	DrivesRow    bool
	Reports      bool
	Reconcile    string // "" | my_review
	Brief        Brief
	Profile      string // "" means none
	Dims         []string
	Records      Pred
	Prepare      string
	OnSent       []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 [draft_approval] block; nil when absent.
	DraftApproval *draft.Approval
	// Modes are turn.Mode values; default ["session"].
	Modes []string
}

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.

func (Def) Runs

func (d Def) Runs(mode string) bool

Runs says whether the intent's turns may run in mode, a turn.Mode value; nil Modes 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 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 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) 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{ HeadMoved string }

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
}

type Text

type Text struct {
	Src string
	At  Pos
}

Text is a text/template source.

Jump to

Keyboard shortcuts

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