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
- Variables
- func ActionFactMap(get func(name string) any) map[string]any
- func HeadlineName(i int) string
- func Load(layers []profile.Layer, bundled fs.FS, base *template.Template, ...) (*Loaded, Problems)
- func SampleActionFacts() map[string]any
- type Cache
- type CacheOptions
- type Loaded
- type Problem
- type Problems
- type Programs
- type TemplateCheck
Constants ¶
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 ¶
var ActionFuncs = template.FuncMap{"join": strings.Join, "name": func() string { return brand.Name }}
ActionFuncs are the functions action texts may call.
var Schema []byte
Schema is the JSON Schema of intent.toml, for editors (Taplo's #:schema directive).
var WorkflowSchema []byte
WorkflowSchema is the JSON Schema of workflow.toml, for editors.
Functions ¶
func ActionFactMap ¶
ActionFactMap nests dotted action facts into the map action texts execute over: {"pr": {"slug": ...}, "row": {"nudge": {"who": ...}}}.
func HeadlineName ¶
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 ¶
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.
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 ¶
BrokenNames is the names of the user intents that did not load, sorted.
type Problems ¶
type Problems []Problem
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
}
Source Files
¶
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. |