Documentation
¶
Overview ¶
Package config handles Runefile discovery and settings resolution.
Index ¶
- Constants
- Variables
- func Compatible(f *ast.File) bool
- func Compose(f *ast.File, src diag.SourceProvider) diag.List
- func Discover(startDir string) (string, error)
- func ParseOutputLimit(s string) (int, error)
- func Resolve(fileFlag, startDir string) (string, error)
- func ResolveModPath(base string, m *ast.Mod, src diag.SourceProvider) string
- func RuneVersion(f *ast.File) string
- type AmbiguousError
- type MinimumRequirement
- type Settings
Constants ¶
const ( MinOutputLimit = 1 << 10 MaxOutputLimit = 1 << 30 )
Bounds of an output limit in bytes. They repeat MinOutputLimit and MaxOutputLimit so that this package, which the analyzer and the language server load, does not pull in the MCP server; a test in internal/cli holds the two pairs equal.
const CurrentVersion = "1"
CurrentVersion is the Runefile semantics version this build implements. Breaking changes are opt-in per file via `set rune_version := "..."`; the default interpretation never changes under a user (FR-033).
const UpgradeURL = "https://github.com/rune-task-runner/rune/releases"
UpgradeURL is where an incompatibility diagnostic points users to obtain a newer Rune binary.
Variables ¶
var ErrNotFound = errors.New("no Runefile found in this directory or any parent")
ErrNotFound is returned when no Runefile can be located by upward discovery.
Functions ¶
func Compatible ¶
Compatible reports whether this build can interpret the file's declared version. An empty pragma (the common case) is always compatible and uses the default interpretation.
func Compose ¶
Compose resolves a file's imports (spliced into the same namespace) and mods (loaded as child namespaces addressable as name::task). It mutates f in place and returns any diagnostics (including reported name collisions, FR-011). Imported and mod files are read through src (spec FR-003): when a document is open in an editor overlay, its unsaved content is used; otherwise src falls back to disk. A nil src (or one that does not resolve a path) falls back to the filesystem, preserving the original disk-only behavior.
func Discover ¶
Discover walks startDir and its ancestors, returning the absolute path of the nearest Runefile / .runefile (case-insensitive). It returns ErrNotFound if none exists up to the filesystem root, and an *AmbiguousError for a directory that holds more than one.
func ParseOutputLimit ¶ added in v0.9.0
ParseOutputLimit reads the size of `set mcp_output_limit` and of `rune mcp --output-limit`: decimal digits with an optional B, KiB, or MiB unit, from MinOutputLimit to MaxOutputLimit bytes. One parser serves both so a limit is spelled the same way in either place.
func Resolve ¶
Resolve picks the Runefile to use. If fileFlag is non-empty it is used directly (and must exist); otherwise discovery walks up from startDir.
func ResolveModPath ¶ added in v0.3.0
ResolveModPath resolves a mod declaration to its target file path using the same rules as Compose (explicit path, else <name>.rune / <name>/Runefile / <name>/.runefile), consulting src for open overlays. It returns "" when the mod cannot be resolved. Exposed so the analysis layer can build a complete import graph that includes directory-resolved mods.
func RuneVersion ¶
RuneVersion returns the version pragma declared by a file, or "" if none.
Types ¶
type AmbiguousError ¶ added in v0.10.0
AmbiguousError reports a directory that holds more than one Runefile. Picking one of them would let a file that was added beside the Runefile take its place without anyone saying so: a task an agent ran can write such a file (spec 053).
func (*AmbiguousError) Error ¶ added in v0.10.0
func (e *AmbiguousError) Error() string
type MinimumRequirement ¶ added in v0.3.0
type MinimumRequirement struct {
Present bool // whether the root file declared minimum_version
Raw string // the raw literal value, e.g. "0.8.0"
Version semver.Version // parsed requirement (valid only when the diags were empty)
Span token.Span // source span of the value literal, for diagnostics
}
MinimumRequirement is the minimum Rune version a root Runefile requires.
func MinimumVersion ¶ added in v0.3.0
func MinimumVersion(f *ast.File) (MinimumRequirement, diag.List)
MinimumVersion extracts and validates the root Runefile's `minimum_version` setting. It MUST be called on the root file BEFORE imports are spliced, so a child/imported file can never impose or relax the requirement (FR-012).
The value must be a static string literal holding a valid single semantic version. A non-literal value or an invalid semantic version is returned as a diagnostic (with the caret on the offending value); in that case the returned requirement's Version is unusable. Absence of the setting yields Present=false and no diagnostics.
func (MinimumRequirement) Satisfied ¶ added in v0.3.0
func (req MinimumRequirement) Satisfied(installed string) (ok, dev bool)
Satisfied reports whether the installed version meets the requirement. A build whose version is not a recognized semantic version — notably a local "dev" build — is treated as a development build (dev=true) that is not blocked, so `go build` binaries keep working against Runefiles that pin a minimum version; integration tests inject a concrete version to exercise real comparisons.
type Settings ¶
type Settings struct {
WorkingDir string // set working-directory := "path"
Quiet bool // set quiet
Export bool // set export (export all variables to the task env)
Fallback bool // set fallback
Dotenv string // set dotenv := ".env"
Shell []string // set shell := ["bash", "-euo", "pipefail"]
Python []string // set python := ["python3"]
Node []string // set node := ["node"]
AgentCmd []string // set agent_cmd := ["claude", "-p"]
Secrets []string // set secrets := ["NAME", ...] — extra names whose values are masked
Unmasked []string // set unmasked := ["NAME", ...] — names exempt from built-in mask patterns
// MCPOutputLimit is the bytes of each of stdout and stderr a tool result
// returns to an agent: set mcp_output_limit := "256KiB". Zero when absent.
MCPOutputLimit int
}
Settings holds the resolved module settings that influence execution.