A freshly-installed perplexed has no templates folder, so the directory-template
commands have nothing to match. Users had to copy templates from the plugin
source by hand. Now the four shipped templates (concept-, vocabulary-, source-,
toolkit-profile) plus a README are inlined into main.js via esbuild's text
loader for .md files, and a seeder writes them into the configured templates
root on plugin load — but only if the folder is missing or contains no markdown,
so existing customizations are never touched.
A new "Re-seed templates" button in the Directory templates settings section
fills in any shipped file whose filename doesn't already exist (for pulling in
new templates after a plugin update).
Pieces:
- esbuild.config.mjs: register `.md` text loader so markdown imports work
- src/types/markdown.d.ts: TS shim for `*.md` imports
- src/services/templateSeederService.ts: seedTemplatesIfMissing +
reSeedMissingFiles (idempotent, never overwrites)
- src/docs/templates/README.md: end-user docs for the template system
(zone anatomy, interpolation tokens, commands, image markers, citation
behavior, frontmatter stamps, writing a custom template)
- main.ts: seeder fires after settings load; settings tab gains a Re-seed
button
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>