scaffold

package
v0.166.3 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package scaffold renders the starter Saga `draugr init` writes for a source tree.

It holds the part of init that decides what a descriptor says, and none of what writes it or prints a summary, so every caller that proposes a descriptor for a directory proposes the same one: the CLI writes it to a file, and the MCP server returns it for an assistant to show.

Index

Constants

View Source
const Here = "."

Here is the url a scaffold gives the repository of the directory it describes. A relative repository url resolves against the directory Draugr runs in, and a scaffold is written to be run from the directory it describes.

Variables

This section is empty.

Functions

func FilePaths

func FilePaths(files []manifests.File) []string

FilePaths are the paths of files, in order.

func GoModules

func GoModules(t inventory.Tree) []string

GoModules names the go.mod files a tree's Go directories hold.

func Model added in v0.163.0

func Model(t inventory.Tree, name string) (*saga.Model, error)

Model is the descriptor Saga writes for the tree, read back as Draugr reads one: one component, with every scanner the tree calls for and nothing that Saga leaves commented out.

Read from the text rather than built beside it, so a scan with no descriptor runs what `draugr init` would write for the same directory, and a scanner added to one is added to the other. A second construction would agree with the text until the day somebody changed only one of them.

func NameFor added in v0.159.0

func NameFor(dir string) string

NameFor is the name a scaffold gives the project and the component for dir: the last element of its absolute path, folded by ProjectName.

func OneLine added in v0.163.0

func OneLine(path string) string

OneLine is a path as a comment or a terminal can carry it: unchanged, or quoted with Go's escapes where it holds a control character or a line break.

A file name may hold a newline, and a scaffold writes paths into YAML comments. Unquoted, the text after the newline would be read as part of the descriptor, and a scan with no descriptor reads this text as its own configuration. YAML also breaks a line at U+0085, U+2028 and U+2029.

func PathList

func PathList(paths []string) string

PathList joins paths with a separator, the first shownPaths of them and a count of the rest.

func ProjectName

func ProjectName(dir string) string

ProjectName turns a directory name into one a descriptor accepts.

Lowercase letters, digits and dashes, starting and ending with a letter or digit, which is what `pkg/saga` enforces. Anything else becomes a dash, runs of dashes collapse, and the ends are trimmed. A name with nothing usable left in it, which a directory of punctuation or of non-Latin script produces, falls back to the same placeholder an unnamed directory gets: a scaffold somebody renames beats one that will not load.

func RepositoryURL added in v0.159.0

func RepositoryURL(dir string) string

RepositoryURL is the url a descriptor read from the working directory gives the repository in dir: Here for the working directory itself, the relative path for a directory beneath it, and the absolute path for any other.

For the directory a scaffold describes, run from that directory, it is the Here the scaffold writes.

func Saga

func Saga(t inventory.Tree, name string, perDirectory bool) string

Saga renders a starter Saga for what the tree holds, run from the directory it describes.

func SagaAt added in v0.165.3

func SagaAt(t inventory.Tree, name string, perDirectory bool, url string) string

SagaAt renders a starter Saga for what the tree holds, with url as the repository of every component: Here for a Saga run from the directory it describes, or the directory's path from where the Saga runs.

func Scalar added in v0.135.1

func Scalar(s string) string

Scalar is s as a YAML scalar that reads back as the same string, in a block mapping or inside a flow sequence: bare where it would, double-quoted where YAML would read it as a number, a boolean or null (2024, 1e3, 0x10, true) or where it holds a character that means something in YAML. Names and paths come from directory names, which can be any of these.

The YAML 1.1 booleans are quoted too, because an editor's parser may read yes and on as true, and the schema then rejects the value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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