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 ActionText(path, src string, sample map[string]any) (*template.Template, error)
- func DraftActionFactMap(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 NestFacts(env expr.Env, get func(name string) any) map[string]any
- func OverlayDraftApproval(base *draft.Policy, o ApprovalOverlay, env expr.Env) (draft.Policy, error)
- func OverlayRunApproval(a workflow.Approval, o ApprovalOverlay, env expr.Env) (workflow.Approval, error)
- func RefusalText(i int) string
- func RefuseWhyName(i int) string
- func SampleActionFacts() map[string]any
- func SampleDraftActionFacts() map[string]any
- func TurnEnv(d dintent.Def) expr.Env
- type ActionPrograms
- type ApprovalOverlay
- type BuiltinAction
- type Cache
- type CacheOptions
- type Loaded
- func (l *Loaded) BrokenNames() []dintent.Name
- func (l *Loaded) Refusal(name dintent.Name, facts map[string]any) (string, error)
- func (l *Loaded) Rules(intent string) (dintent.RecordRules, error)
- func (l *Loaded) Tree() (profile.Tree, error)
- func (l *Loaded) Why(name dintent.Name, facts map[string]any) (string, error)
- type Problem
- type Problems
- type Programs
- type RefusalProgram
- type RuleOverlay
- type TemplateCheck
Constants ¶
const ActionsFile = "actions.toml"
ActionsFile is the profile file that words the built-in actions.
const DefaultChanged = "The head moved since the question: re-check what changed before acting on the answer."
DefaultChanged is resume.changed when a manifest leaves it out: the generic sentence of resume.md.tmpl.
const DefaultsFile = "defaults.toml"
DefaultsFile is the profile file of the manifests' defaults, read from the bundled profile and then each layer, a later layer's key winning.
const WhyName = "manifest.why"
The names the manifest's other inline templates are parsed under in an intent's template set.
Variables ¶
var ActionFuncs = template.FuncMap{"join": strings.Join, "name": func() string { return brand.Name }, "command": func() string { return brand.Command }}
ActionFuncs are the functions action texts may call.
var ActionsSchema []byte
ActionsSchema is the JSON Schema of actions.toml, for editors.
var ConfigSchema []byte
ConfigSchema is the JSON Schema of config.json, for editors.
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": {"question": ...}}.
func ActionText ¶ added in v0.2.0
ActionText parses an action text named path and executes it once over sample, so a text that cannot render fails at load.
func DraftActionFactMap ¶ added in v0.2.0
DraftActionFactMap is ActionFactMap for the texts of a draft's actions.
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. The partials under partials/ of each directory layer are parsed over base's; one that does not parse, or that a problem names, is left out and the bundled partials load instead. Layers with an empty Dir are skipped: the bundled intents come from bundled only. A user directory named as a bundled intent overrides its files one by one; when the result does not load, the bundled intent stays and the problems name the user's files.
func NestFacts ¶ added in v0.2.0
NestFacts nests the dotted facts of env into the map an inline template executes over, {"pr": {"slug": ...}}, each read by get; a fact get has no value for reads as its type's zero value.
func OverlayDraftApproval ¶ added in v0.2.0
func OverlayDraftApproval(base *draft.Policy, o ApprovalOverlay, env expr.Env) (draft.Policy, error)
OverlayDraftApproval is base, a workflow's draft policy (nil: wait), with o laid over it, o's rules compiled over env. The merged policy is validated.
func OverlayRunApproval ¶ added in v0.2.0
func OverlayRunApproval(a workflow.Approval, o ApprovalOverlay, env expr.Env) (workflow.Approval, error)
OverlayRunApproval is a, a workflow's run approval, with o laid over it, o's rules compiled over env, the workflow's facts. The merged approval is validated, and a releasing rule of o may not read an untrusted fact.
func RefusalText ¶ added in v0.2.0
RefusalText is the ActionTexts key of the why of refusal i.
func RefuseWhyName ¶ added in v0.2.0
RefuseWhyName is the name refuse[i].why is parsed under.
func SampleActionFacts ¶
SampleActionFacts is the action fact map with every fact set, for checking texts.
func SampleDraftActionFacts ¶ added in v0.2.0
SampleDraftActionFacts is SampleActionFacts for a draft's actions.
Types ¶
type ActionPrograms ¶ added in v0.2.0
type ActionPrograms struct {
When *expr.Program
Primary *expr.Program
Refuse []RefusalProgram
// ActionTexts are note, warning, confirm and each refusal's why
// ("refuse[<i>].why"), over the action fact map.
ActionTexts map[string]*template.Template
}
ActionPrograms are an intent's compiled [action] predicates and texts.
type ApprovalOverlay ¶ added in v0.2.0
type ApprovalOverlay struct {
Mode string
Window *time.Duration
Rules []RuleOverlay
}
ApprovalOverlay is the configuration's approval block of a workflow, laid over its manifest's field by field: a set Mode or Window replaces that field, and non-nil Rules replace the rules, an empty list clearing them. A Mode other than delay drops the manifest's window, which JSON cannot unset.
type BuiltinAction ¶ added in v0.2.0
type BuiltinAction struct {
Label, Summary string
Input struct{ Label, Help string }
// Texts are note, warning, confirm and why, parsed; a text the table
// leaves empty is absent.
Texts map[string]*template.Template
}
BuiltinAction is a built-in action's texts, from its actions.toml table.
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, and overrides read as bundled
Broken map[dintent.Name]Problems // user intents that failed, keyed by directory name
Reverted map[dintent.Name]Problems // bundled intents read without the user's override, which does not load
// Warnings are what the loaded intents and workflows declare that loads
// but is deprecated.
Warnings Problems
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
// RevertedWorkflows are bundled workflows read without the user's override, which does not load.
RevertedWorkflows map[string]Problems
// Actions are the built-in actions' texts from actions.toml, by catalog id.
Actions map[string]BuiltinAction
// EmptyRefusal is what a [[refuse]] case whose why renders empty says,
// from defaults.toml.
EmptyRefusal string
// contains filtered or unexported fields
}
func (*Loaded) BrokenNames ¶
BrokenNames is the kinds whose blocks are skipped, sorted: the user intents that did not load, and the kinds whose blocks need what a reverted override declared.
func (*Loaded) Refusal ¶ added in v0.2.0
Refusal is the why of the intent name's first refusal whose when holds over facts, the unit's workflow facts, never empty when one holds; "" when none holds.
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.
type Problems ¶
type Problems []Problem
type RefusalProgram ¶ added in v0.2.0
RefusalProgram is an [[action.refuse]] case's compiled when.
type RuleOverlay ¶ added in v0.2.0
RuleOverlay is one rule of an ApprovalOverlay.
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 facts reference page: the intents' facts and the workflow facts, each grouped by slot, the draft approval facts, the workflow steps, then the draft effects.
|
Command factsdoc prints the facts reference page: the intents' facts and the workflow facts, each grouped by slot, the draft approval facts, the workflow steps, then the draft effects. |
|
cmd/grammardoc
command
Command grammardoc writes what the grammar table derives: the JSON schemas of the profile files and the configuration, the generated tables of the manifest and configuration reference pages, and the language page.
|
Command grammardoc writes what the grammar table derives: the JSON schemas of the profile files and the configuration, the generated tables of the manifest and configuration reference pages, and the language page. |
|
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. |