Documentation
¶
Overview ¶
Package ast defines the Runefile abstract syntax tree produced by the parser and consumed by the analyzer, evaluator, scheduler, cache, and MCP server. Every node carries a token.Span so any diagnostic can point at precise source (Principle II).
Index ¶
- Constants
- func Dump(f *File) string
- func DumpExpr(e Expr) string
- type Assignment
- type Attribute
- type Binary
- type BodyLine
- type CondBranch
- type Conditional
- type DepCall
- type Expr
- type File
- type FuncCall
- type Import
- type Mod
- type Node
- type Param
- type ParamKind
- type Setting
- type StringLit
- type Task
- type VarRef
Constants ¶
const ( ExecSh = "sh" ExecPython = "python" ExecNode = "node" ExecAgent = "agent" )
Executor names for the built-in body languages. The empty string means the default shell executor; any other non-built-in string is a custom executor.
const ( AttrPrivate = "private" AttrConfirm = "confirm" AttrGroup = "group" AttrParallel = "parallel" AttrLinux = "linux" AttrMacos = "macos" AttrWindows = "windows" AttrUnix = "unix" AttrNoCD = "no-cd" AttrWorkingDirectory = "working-directory" AttrEnv = "env" AttrDoc = "doc" AttrScript = "script" AttrCache = "cache" AttrNetwork = "network" // sets MCP openWorldHint AttrNoExitMessage = "no-exit-message" // suppress the trailing error banner AttrContext = "context" // project-health hook injected into agent context (spec 021) )
Attribute kinds.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Assignment ¶
Assignment is a module-level variable binding `NAME := EXPR`.
func (*Assignment) Span ¶
func (a *Assignment) Span() token.Span
type Attribute ¶
type Attribute struct {
Kind string
Str string // confirm prompt, group name, doc, script cmd, working-directory, env name
Str2 string // env value
Inputs []Expr // cache(inputs=[...])
Outputs []Expr // cache(outputs=[...])
HasOutputs bool
Sp token.Span
}
Attribute is a `[name(args)]` annotation on a task. Most attributes carry a single string argument (Str); env carries two (Str, Str2); cache carries input/output glob lists.
type BodyLine ¶
type BodyLine struct {
Raw string
NoEcho bool // leading @
ContinueOnError bool // leading -
Sp token.Span
}
BodyLine is one line of a task body, with leading-sigil flags stripped. Raw retains {{ ... }} interpolation placeholders for the evaluator.
type CondBranch ¶
CondBranch is one `if/else if` clause: Left Op Right { Result }.
type Conditional ¶
type Conditional struct {
Branches []CondBranch
Else Expr
Sp token.Span
}
Conditional is an if/else-if/else expression. It always has a final Else.
func (*Conditional) Span ¶
func (e *Conditional) Span() token.Span
type Expr ¶
type Expr interface {
Node
// contains filtered or unexported methods
}
Expr is implemented by every expression node.
type File ¶
type File struct {
Path string
Settings []*Setting
Assignments []*Assignment
Tasks []*Task
Imports []*Import
Mods []*Mod
Sp token.Span
}
File is the root of one parsed Runefile. A project may be a tree of Files via import (spliced) and mod (namespaced).
type Import ¶
type Import struct {
Path string // decoded string-literal path
Optional bool // import?
Sp token.Span
}
Import splices another file's definitions into the current namespace.
type Mod ¶
type Mod struct {
Name string
Path string // optional explicit path; "" => derive from name
Sp token.Span
}
Mod loads another file as a child namespace addressable as name::task.
type Param ¶
type Param struct {
Name string
Kind ParamKind
Default Expr // only for ParamDefaulted
Sp token.Span
}
Param is a positional task parameter.
type Setting ¶
type Setting struct {
Name string
Value Expr // nil for the bare boolean form
List []Expr // populated for list-valued settings
Bool bool // true for the bare form
Sp token.Span
}
Setting is a `set NAME [:= VALUE]` directive. The bare form (`set export`) is boolean true (Bool=true, Value=nil). List-valued settings (e.g. `set shell`) keep their elements in List.
type Task ¶
type Task struct {
Name string
Doc string // from the preceding comment run or [doc("...")]
Params []*Param
Executor string // "" => default sh
Deps []*DepCall
PostHooks []*DepCall // run after, on success (&&)
FailHooks []*DepCall // run after, on failure (||)
Attributes []*Attribute
Body []*BodyLine
Sp token.Span
}
Task is a named recipe.
func (*Task) AvailableOn ¶ added in v0.5.0
AvailableOn reports whether the task may run on the given GOOS. A task with no OS attribute is available everywhere; multiple OS attributes combine as OR; "unix" matches every GOOS except "windows". This is the single availability rule shared by listing, completion, MCP exposure, root resolution, and dependency scheduling.
func (*Task) Edges ¶ added in v0.6.0
Edges returns every outgoing task reference of t: dependencies, && post- hooks, and || failure hooks — the single edge-set definition shared by dependency resolution, cycle detection, context closure walks, and editor navigation, so a new clause kind cannot be missed by one of them.
func (*Task) IsPrivate ¶
IsPrivate reports whether the task carries the [private] attribute or a name beginning with '_'.