Documentation
¶
Overview ¶
Package templates holds the starting structures a new project can be created from: a directory skeleton plus the AGENTS.md that explains it.
The files are go:embed'ed rather than fetched, because `cmd/bdrive` is one binary serving the CLI, the daemon and the hub — so the hub that seeds a project at creation and the client that seeds one with `bdrive init --template` read the identical set, with no gallery and no drift.
The AGENTS.md is the deliverable. Directories are the easy half and the half that decays; what makes a structure stick is the instruction file telling an agent where a new note goes, when something is archived, and what a good filename looks like.
One hard rule for the content: BearDrive syncs paths, not directories (internal/syncer/walk.go only journals regular files), so an empty directory never reaches a teammate. Every directory in a template holds at least one real file — asserted in the tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SafePath ¶ added in v0.15.0
SafePath reports whether p is a path a template may name: a clean, relative, control-character-free path inside the project. It is the one rule both seeding doors apply — WriteTo on disk, and the hub's seedTemplate, which hands it to cleanUploadPath as well.
The rule is journal.SafePath: a template file becomes an Op.Path on every device, so this door may not be more permissive than the journal is.
Types ¶
type File ¶
File is one file of a template: a slash-separated path relative to the project root, and its literal content.
type Template ¶
type Template struct {
Name string `json:"name"` // the flag/API value, e.g. "docs"
Title string `json:"title"` // what a menu shows, e.g. "Docs + decision records"
Blurb string `json:"blurb"` // the one-line shape, e.g. "docs/, decisions/"
Files []File `json:"-"`
}
Template is one starting structure.
func (Template) Dirs ¶
Dirs lists every directory a template's paths imply, for the every-directory-holds-a-file check.
func (Template) WriteTo ¶
WriteTo writes the template into dir and returns the paths it wrote. A path that already exists is never overwritten and is left out of the result — which is what makes seeding twice a no-op rather than a divergence. Template and File are exported with exported fields, so "today every template comes from the go:embed" is a property of the callers, not of this function: the guard belongs where the write happens.