Plan: Unified Template System — TMP Phase 1
IMPLEMENTATION RULES: Before implementing this plan, read and follow:
- WORKFLOW.md - The implementation process
- PLANS.md - Plan structure and best practices
Status: Completed
Completed: 2026-04-04
Goal: Migrate template metadata from bash TEMPLATE_INFO + TEMPLATE_CATEGORIES to YAML (template-info.yaml + template-categories.yaml), generate a unified template-registry.json, and update Docusaurus to consume it.
Investigation: INVESTIGATE-unified-template-system.md
Priority: High
Last Updated: 2026-04-04
Overview
TMP Phase 1 is the foundation that enables everything else. It replaces the current bash-based metadata system with YAML files and a generated JSON registry. No other team needs to change anything until this is done.
What changes:
- Each template folder gets a
template-categories.yaml(replacesTEMPLATE_CATEGORIES) - Each template gets a
template-info.yaml(replacesTEMPLATE_INFO) - A TypeScript generation script produces
template-registry.json(replacestemplates.json+categories.json) - Docusaurus components switch from two JSON files to one registry
- CI pipeline runs the new generation and drops the old sync step
What stays the same during Phase 1:
- DCT's
dev-template.shanddev-template-ai.shkeep working (oldTEMPLATE_INFOfiles stay until DCT migrates in Phase A) - The old bash
TEMPLATE_CATEGORIESfiles stay until DCT migrates - No new template types added yet (no
doc-templates/,rules-templates/, etc.)
Backward compatibility: Both old (TEMPLATE_INFO, TEMPLATE_CATEGORIES) and new (template-info.yaml, template-categories.yaml) files coexist during the transition. Old files are removed only after DCT Phase A ships.
Phase 1: Create YAML metadata files — DONE
Tasks
- 1.1 Create
templates/template-categories.yamlwithcontext: dct, categoriesBASIC_WEB_SERVERandWEB_APP(migrate fromTEMPLATE_CATEGORIES) - 1.2 Create
ai-templates/template-categories.yamlwithcontext: dct, categoryWORKFLOW - 1.3 Create
template-info.yamlfor all 7 app templates (python, typescript, php, golang, java, csharp, designsystemet) — migrate fields fromTEMPLATE_INFO, addinstall_type: app - 1.4 Create
template-info.yamlforplan-based-workflow— migrate fields fromTEMPLATE_INFO, addinstall_type: overlay - 1.5 Validate all YAML files parse correctly (no syntax errors)
Validation
All 10 YAML files exist and are valid. Field values match current TEMPLATE_INFO content. install_type is set correctly (app for templates/, overlay for ai-templates/).
Phase 2: TypeScript generation script — DONE
Tasks
- 2.1 Create
scripts/generate-registry.tsthat scans*/template-categories.yaml+*/*/template-info.yamland outputswebsite/src/data/template-registry.json - 2.2 The script validates: category IDs are unique across folders, each template's
categorymatches a defined category, required fields are present,idmatches directory name - 2.3 The generated
template-registry.jsoncontains bothcategoriesandtemplatesarrays (format as defined in the investigation spec) - 2.4 Create
scripts/generate-registry.shas a wrapper that runs the TypeScript script (matching pattern of existing bash wrappers) - 2.5 Run the script and verify the output matches the current
templates.json+categories.jsoncontent (same data, new format)
Implementation Notes
- Use
js-yamlfor YAML parsing (already a Docusaurus dependency, or add to devDependencies) - The script should fail with clear errors on validation failures — not silently generate bad JSON
- Output format follows the investigation spec exactly (see "Generated Registry" section)
- Tags:
template-info.yamluses YAML list, registry JSON uses space-separated string (for backward compatibility with Docusaurus components — can be changed to array later)
Validation
template-registry.json is generated. Contains all 8 templates and 3 categories. Data matches current JSON files.
Phase 3: Update Docusaurus components — DONE
Tasks
- 3.1 Update
website/src/utils/data.tsto import fromtemplate-registry.jsoninstead oftemplates.json+categories.json - 3.2 Update types:
Template(addedfolder,install_type,context, removedtype),Category(addedemoji,context, removedicon) - 3.3 Update
generate-docs-markdown.shto read from registry — deferred to Phase 5 (still works with old TEMPLATE_INFO files during transition) - 3.4 Fixed broken links to moved investigation file (INVESTIGATE-dct-template-metadata-update.md)
- 3.5 Run
npm run buildin devcontainer — builds successfully
Implementation Notes
data.tscurrently exports:getTemplates(),getCategories(),getTemplatesByCategory(),getTemplateById(),getCategoryById(),getTemplateCountByCategory(). All must keep working.- The
TemplateHeadercomponent uses: name, version, description, tags, logo, docs, website. Verify these fields exist in the registry. generate-docs-markdown.shcurrently sourcesTEMPLATE_INFObash files. It needs to read from JSON instead (usejq).
Validation
npm run build succeeds. Template pages render with correct data. No visual regressions on the website.
Phase 4: Update CI pipeline — DONE
Tasks
- 4.1 Add
npx tsx scripts/generate-registry.tsstep to CI (runs after old JSON generation) - 4.2 Keep "Sync TEMPLATE_CATEGORIES" step — still needed during transition (deferred removal to Phase 5)
- 4.3 Add Node.js setup +
npm cito thegeneratejob (needed for tsx and js-yaml) - 4.4 Add YAML trigger paths (
template-info.yaml,template-categories.yaml) to workflow - 4.5 Push to main and verify CI runs successfully — after PR merge
- 4.4 Update
validate-metadata.sh— deferred to Phase 5 (old validation still works during transition)
Implementation Notes
- Keep
generate-templates-json.shtemporarily — it still generates the old JSON files that DCT's current scripts read via sparse-checkout. Remove it only after DCT Phase A ships. - The CI should generate both old and new formats during the transition period.
Validation
CI pipeline runs green. template-registry.json is auto-generated and committed. Website deploys with correct data.
Phase 5: Cleanup (after DCT Phase A ships) — DONE
DCT Phase A confirmed complete (23MSG). Old format files removed.
Tasks
- 5.1 Remove
TEMPLATE_INFOfiles from all template directories (8 files) - 5.2 Remove
scripts/lib/TEMPLATE_CATEGORIES - 5.3 Remove
templates/TEMPLATE_CATEGORIESandai-templates/TEMPLATE_CATEGORIES(CI-copied files) - 5.4 Remove
website/src/data/templates.jsonandwebsite/src/data/categories.json - 5.5 Remove
scripts/generate-templates-json.sh(old generation script) - 5.6 Remove
scripts/lib/categories.shandscripts/lib/template-scanner.sh(no longer needed) - 5.7 Remove CI sync step for TEMPLATE_CATEGORIES and old JSON generation step
- 5.8 Update
website/docs/contributors/naming-conventions.mdto referencetemplate-info.yaml - 5.9 Update
website/docs/contributors/template-metadata.mdto document YAML format - 5.10 Update
validate-metadata.shto validate YAML files (uses node + js-yaml) - 5.11 Update
generate-docs-markdown.shto read fromtemplate-registry.json(uses jq)
Validation
No old-format files remain. CI runs clean. Website still works. DCT confirms no breakage.
Acceptance Criteria
-
template-categories.yamlexists intemplates/andai-templates/ -
template-info.yamlexists in all 8 template directories -
template-registry.jsonis auto-generated by CI from YAML source files - Docusaurus website renders correctly from the registry
- All existing template data is preserved (no fields lost in migration)
- Old formats coexisted during transition, then removed after DCT Phase A confirmed complete
- CI pipeline is green (PR #20 Phase 1-4, PR #21 Phase 5)
Files to Create
templates/template-categories.yamlai-templates/template-categories.yamltemplates/*/template-info.yaml(7 files)ai-templates/plan-based-workflow/template-info.yamlscripts/generate-registry.tsscripts/generate-registry.sh
Files to Modify
website/src/utils/data.tswebsite/src/data/(newtemplate-registry.json)scripts/generate-docs-markdown.shscripts/validate-metadata.sh.github/workflows/deploy-docs.ymlwebsite/docs/contributors/naming-conventions.md
Files to Remove (Phase 5, after DCT Phase A)
templates/*/TEMPLATE_INFO(7 files)ai-templates/plan-based-workflow/TEMPLATE_INFOscripts/lib/TEMPLATE_CATEGORIEStemplates/TEMPLATE_CATEGORIESai-templates/TEMPLATE_CATEGORIESwebsite/src/data/templates.jsonwebsite/src/data/categories.jsonscripts/generate-templates-json.shscripts/lib/categories.sh