roots

package
v0.0.0-...-bebb484 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package roots loads and represents the Taskfile graphs for one or more workspace roots. It is the single owner of the *Root value type and contains all URI canonicalisation and Taskfile graph parsing helpers.

This package must not import the MCP SDK; it is consumed by the server package, which adapts roots.Root values into MCP state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalRootURI

func CanonicalRootURI(raw string) (string, string, error)

CanonicalRootURI resolves a client-provided local file URI to the canonical absolute file URI we use as the server's internal root identity. Equivalent aliases such as file:///repo and file://localhost/repo collapse to the same canonical URI and directory.

func DirToURI

func DirToURI(dir string) string

DirToURI converts an absolute directory path to a file:// URI.

Types

type Root

type Root struct {
	Taskfile       *ast.Taskfile
	Workdir        string
	WatchDirs      []string
	WatchTaskfiles map[string]struct{}
}

Root holds the loaded per-root Taskfile data. Once a *Root is published to a consumer (e.g. a server's roots map) its fields are treated as read-only; mutations are performed by replacing the pointer rather than writing through the existing value, so concurrent readers (snapshots, watchers) always observe a consistent state. *Root values therefore must NOT be mutated by code outside of construction sites in this package.

The fields are exported because reconcile, tool planning, and watcher code lives in other packages and needs to read them. They are still considered immutable after construction.

func Build

func Build(ctx context.Context, workdir string) (*Root, error)

Build resolves the Taskfile graph for workdir, sets up a task executor, and returns a fully populated *Root. workdir must already be an absolute path.

func Load

func Load(ctx context.Context, dir string) (*Root, error)

Load creates a new Root by loading the Taskfile from the given directory.

func NewUnloaded

func NewUnloaded(dir string) (*Root, error)

NewUnloaded creates a root placeholder for a workspace that does not yet have a loadable root Taskfile. Watching the root directory lets callers pick up a Taskfile that is created or fixed after startup.

Jump to

Keyboard shortcuts

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