| id | 52 |
|---|---|
| title | Archetype / Template Library for Agentic Patterns |
| status | ✅ |
Let users define their own required-structure archetype templates. Support common agentic Markdown patterns. Expose first-class CLI verbs to init, list, show, and locate archetypes.
mdsmith ships no built-in archetypes. Users point
mdsmith at archetype directories via config. The CLI
scaffolds, discovers, and inspects them. The
required-structure rule resolves archetype: <name>
against those roots.
- Remove the embedded built-in archetype templates
added in the first pass; delete
internal/archetypes/*.mdshipped assets and thego:embedregistry that loads them. - Add archetype discovery config to
.mdsmith.yml:archetypes.roots— ordered list of base directories searched for<name>.mdschemas. First match wins; earlier roots shadow later ones. - Update
required-structurerule soarchetype: <name>resolves via the configured roots. Missing archetype returns a clear diagnostic listing the roots searched and the archetypes discovered. - Add
mdsmith archetypes init [dir]CLI to scaffold a default archetypes directory (default:./archetypes/) containing a documented example schema. The command creates the directory if absent, writes the example only when it does not already exist, and prints follow-up config to add the root to.mdsmith.yml(it does not mutate the config file). - Add
mdsmith archetypes listto print each discovered archetype as<name>\t<path>, one per line, sorted by name. Whenarchetypes.rootsis omitted, search the default./archetypesdirectory. Exit non-zero if no archetypes are discovered. - Add
mdsmith archetypes show <name>to print the archetype source (including front matter) to stdout. Exit non-zero with a clear error when the name does not resolve. - Add
mdsmith archetypes path <name>to print the resolved filesystem path. Exit non-zero with a clear error when the name does not resolve. - Document archetype authoring,
archetypes.rootsconfiguration, and the new CLI verbs indocs/guides/directives/enforcing-structure.mdand the MDS020 README. Include a short cookbook entry showinginit→ edit → apply via override.
- Shipping opinionated archetype templates. A
separate, optional,
mdsmith archetypes init --with-examplesflag may be added later to copy community examples from a documented repo, but it is not part of this plan. - Editing the user's
.mdsmith.ymlautomatically;initonly scaffolds the directory and prints the config snippet to add.
- No archetype templates are embedded in the binary; the linker-visible symbol footprint for archetypes contains no schema text.
-
.mdsmith.ymlacceptsarchetypes.rootsas a list of relative directories; the linter uses it to resolvearchetype: <name>in required-structure settings. -
mdsmith archetypes initcreates the target directory with an example schema, refuses to overwrite an existing example, and prints a config snippet for the user to add. -
mdsmith archetypes listprints all discovered archetypes, each with its source path, sorted by name. -
mdsmith archetypes show <name>prints the raw schema source. -
mdsmith archetypes path <name>prints the filesystem path. - Unknown archetype names produce an error that names the configured roots and lists nearby candidates.
- Guide + MDS020 README document authoring,
archetypes.rootsconfiguration, and each CLI verb. - All tests pass:
go test ./... -
golangci-lint runreports no issues