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: 33 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 loads intent manifests from the bundled profile and the user's layers into one registry; import it as intentload.

Index

Constants

View Source
const DefaultHeadMoved = "The head moved since the question: re-check what changed before acting on the answer."

DefaultHeadMoved is resume.head_moved when a manifest leaves it out: the generic sentence of resume.md.tmpl.

Variables

View Source
var ActionFuncs = template.FuncMap{"join": strings.Join, "name": func() string { return brand.Name }}

ActionFuncs are the functions action texts may call.

View Source
var Schema []byte

Schema is the JSON Schema of intent.toml, for editors (Taplo's #:schema directive).

View Source
var WorkflowSchema []byte

WorkflowSchema is the JSON Schema of workflow.toml, for editors.

Functions

func ActionFactMap

func ActionFactMap(get func(name string) any) map[string]any

ActionFactMap nests dotted action facts into the map action texts execute over: {"pr": {"slug": ...}, "row": {"nudge": {"who": ...}}}.

func HeadlineName

func HeadlineName(i int) string

HeadlineName is the name a headline text is parsed under in an intent's template set: "headline.resumed", "headline.new[0]", ...

func Load

func Load(layers []profile.Layer, bundled fs.FS, base *template.Template, check TemplateCheck) (*Loaded, Problems)

Load reads intents/ of the bundled FS and of each directory layer; check may be nil. Layers with an empty Dir are skipped: the bundled intents come from bundled only.

func SampleActionFacts

func SampleActionFacts() map[string]any

SampleActionFacts is the action fact map with every fact set, for checking texts.

Types

type Cache

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

Cache reloads when the newest mtime under the user layer's intents/ and blocks changes; safe for concurrent use.

func NewCache

func NewCache(layers func() []profile.Layer, bundled fs.FS, base *template.Template, check TemplateCheck, opts CacheOptions) *Cache

func (*Cache) Get

func (c *Cache) Get() *Loaded

type CacheOptions

type CacheOptions struct {
	// Recheck is how long a stamp is trusted before the layers are walked again.
	Recheck time.Duration
	// Now is the clock; time.Now when nil.
	Now func() time.Time
	// LoadTree reads the profile tree of a Loaded; profile.Load when nil.
	LoadTree func([]profile.Layer, *dintent.Registry, []dintent.Name) (profile.Tree, error)
	// OnReload is called, holding no lock, after Get replaces the loaded registry with a changed one; the first load is not a reload.
	OnReload func()
}

CacheOptions tune a Cache; the zero value rechecks the stamp on every Get.

type Loaded

type Loaded struct {
	Registry  *dintent.Registry
	Templates map[dintent.Name]*template.Template // body on a clone of base, missingkey=error
	Programs  map[dintent.Name]Programs
	Problems  Problems                  // user intents that did not load; the bundled layer never has problems
	Broken    map[dintent.Name]Problems // user intents that failed, keyed by directory name

	Workflows       []workflow.Workflow // by order, then name; a user workflow that failed is not here
	BrokenWorkflows map[string]Problems // user workflows that failed, keyed by directory name
	// contains filtered or unexported fields
}

func (*Loaded) BrokenNames

func (l *Loaded) BrokenNames() []dintent.Name

BrokenNames is the names of the user intents that did not load, sorted.

func (*Loaded) Rules

func (l *Loaded) Rules(intent string) (dintent.RecordRules, error)

Rules is intent's record rules; for a broken user intent the error carries its first problem.

func (*Loaded) Tree

func (l *Loaded) Tree() (profile.Tree, error)

Tree is the profile's blocks as of this load, read on the first call and kept; an unreadable block is the error every call returns.

type Problem

type Problem struct {
	File      string
	Line, Col int
	Field     string // "inputs.self_review.persist", "action.enabled"
	Msg       string
	Snippet   string // a predicate problem's expression and caret line; Error leaves it out
}

type Problems

type Problems []Problem

func (Problems) Error

func (p Problems) Error() string

Error is the problems sorted, one "file:line:col: field: msg" per line; a problem with no line (a whole directory) reads "dir: msg".

func (Problems) Sorted

func (p Problems) Sorted() Problems

Sorted is the problems by file, line, column, field and message.

type Programs

type Programs struct {
	Records     *expr.Program
	Headline    []*expr.Program // per Headline.New case; nil for the unconditional last case
	Also        []*expr.Program
	Visible     *expr.Program
	Enabled     *expr.Program
	Primary     *expr.Program
	ActionTexts map[string]*template.Template // reason_off, confirm, hint over the action fact map
}

type TemplateCheck

type TemplateCheck func(d dintent.Def, t *template.Template) []Problem

TemplateCheck renders a manifest's templates against real samples; internal/turn provides it.

Directories

Path Synopsis
Package builtin is the Go vocabulary manifests name: builtins by slot, reserved names and keys, and the facts predicates read.
Package builtin is the Go vocabulary manifests name: builtins by slot, reserved names and keys, and the facts predicates read.
cmd/factsdoc command
Command factsdoc prints the generated tables of the facts reference page: the intents' facts, one table per workflow slot, then the workflow steps.
Command factsdoc prints the generated tables of the facts reference page: the intents' facts, one table per workflow slot, then the workflow steps.
Package expr compiles and evaluates the predicates of intent and workflow manifests: CEL expressions (cel-go) over typed facts, checked at load.
Package expr compiles and evaluates the predicates of intent and workflow manifests: CEL expressions (cel-go) over typed facts, checked at load.

Jump to

Keyboard shortcuts

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