Skip to main content

Module templates

Module templates 

Source
Expand description

Discovery of prompt templates — the /command convention.

A template is a markdown file whose body is a prompt, with optional YAML frontmatter describing it. basis finds them, layers them, and substitutes arguments into them; it does not decide what any of them are for (PROPOSAL.md Bet 4). Over ACP each becomes an AvailableCommand, which is the reason they carry names at all — that mapping lives in basis-acp, since nothing here knows a protocol.

§Where they come from

.basis/templates/ in the workspace, then templates/ in the global config directory: the same two roots, in the same precedence order, as skills. Roots layer rather than replace — a workspace template shadows a personal one of the same name and everything else in the personal root still loads. That is PATH’s rule, and it is the rule mentra already applies to skills, so the two conventions cannot surprise each other.

§Names

A template’s name is its path below the root with the .md dropped and directories joined by :.basis/templates/git/commit.md is git:commit. Nesting is therefore namespacing, and two authors can each write a review.md without colliding.

§Errors, not silence

A directory that is absent is not an error; nobody wrote any templates. A file that exists and cannot be understood is: unterminated frontmatter, YAML that does not parse, a missing description, two files claiming one name. Skipping those would make “the template failed to load” and “the template was never written” look identical to the person who wrote it.

Structs§

Template
One template, body included.
TemplateSource
A templates directory that exists on disk.
TemplatesConfig
How to look for templates. Every knob has a convention-shaped default; none of them encode a task.

Enums§

TemplateError
Anything that can go wrong while loading templates.

Constants§

DEFAULT_GLOBAL_TEMPLATES_DIR
Where basis looks inside the global config directory.
DEFAULT_WORKSPACE_TEMPLATES_DIR
Where basis looks inside a workspace, relative to its root.
NAMESPACE_SEPARATOR
What joins directory levels in a template’s name.
TEMPLATE_EXTENSION
The extension a template file must have.

Functions§

discover
Every templates directory that exists, most specific first.
load
Every template the workspace defines, layered and ordered by name.
load_sources
Loads from sources already in hand, for a host that chose the roots itself.