l-update-generator
Detect and fix drift between the main zudo-doc project and the create-zudo-doc generator CLI. Use when adding/removing features, or to verify the generator stays in sync. Also triggered by "update gen...
Update create-zudo-doc Generator
Detect and fix drift between the main zudo-doc project and the create-zudo-doc CLI generator.
Architecture Overview
The generator uses additive composition — not copy-then-strip:
A minimal base template (
templates/base/) is copied firstProgrammatic generators create config files from user choices (
zfb-config-gen.ts,settings-gen.ts)Feature modules (
src/features/*.ts) inject code into anchor points (@slot:) in shared files and copy feature-specific filescompose.tsorchestrates feature file copying, injection, and anchor cleanupSome features have postProcess hooks that mutate or remove generated files (e.g.,
i18n.tspatches locale strings and may deletesrc/)pages/ ja/
When to Use
After adding or removing a feature from zudo-doc
When the drift-detection test fails
Periodically to verify generator health
User says "update generator", "sync generator", "check generator drift", "l-update-generator", or the old name "l-sync-create-zudo-doc"
Quick pre-check: Run pnpm check:template-drift first to get an automated summary of base template drift. Then proceed with the full workflow below for settings, dependency, zfb config, and feature composition drift.
Step 1: Analyze Drift
Compare the main project's source files with what the generator produces.
1a. Settings drift
Read both files and extract setting field names:
Main:
src/— the canonical settings objectconfig/ settings. ts Generator:
packages/— what gets generatedcreate- zudo- doc/ src/ settings- gen. ts
Compare field names. Any field in the main settings that is missing from the generator output is drift.
1b. Dependency drift
Compare dependencies:
Main:
package.json— root dependenciesGenerator:
packages/create- zudo- doc/ src/ scaffold. ts generatePackageJson()— generated deps
Check for packages used in base template files and feature files that are not included in the generated package.json.
1c. zfb config drift
Compare the main project's zfb.config.ts with what the generator produces:
Main:
zfb.config.ts— all imports and integrationsGenerator:
packages/— programmatic generationcreate- zudo- doc/ src/ zfb- config- gen. ts
For each integration in the main zfb.config.ts, verify that either:
It is unconditionally included in
zfb-config-gen.ts, ORIt is conditionally included based on the correct feature selection
1d. Feature composition drift
Check that features in the main project have corresponding feature modules:
Main: Feature-gated files across
src/components/,src/integrations/,src/pages/,src/config/,src/utils/,src/scripts/,src/hooks/Generator:
packages/— feature modules with injections and postProcess hookscreate- zudo- doc/ src/ features/ *. ts Templates:
packages/— feature-specific filescreate- zudo- doc/ templates/ features/ */ files/
For each feature-gated file in the main project, verify:
A feature module exists in
src/features/The feature's files are in
templates/features/<name>/files/Injection anchors (
@slot:) exist in the base template for the feature's injectionsIf the feature has a
postProcesshook, verify the mutations it performs still match the main project's behavior
1e. Base template drift
Compare shared files between the main project and the base template:
Main:
src/components/,src/config/,src/hooks/,src/layouts/,src/pages/,src/plugins/,src/scripts/,src/styles/,src/types/,src/utils/Template:
packages/create- zudo- doc/ templates/ base/
Check that non-feature-specific files in the base template reflect the latest changes from the main project (layout updates, plugin changes, utility functions, type definitions, etc.).
Automated first check: Run pnpm check:template-drift before doing manual analysis. This runs scripts/ and quickly identifies files that differ between the main project and the base template.
Allowlist note: Some files are listed in .template-drift-allowlist (e.g., global.css) and are skipped entirely by the automated script because they contain slot sections that intentionally differ. These files still require manual review — check that any non-slot-section changes in the main project are reflected in the template counterpart.
Step 2: Report Findings
Present a clear drift report:
# # Settings Drift
- Missing in generator: fieldA, fieldB
- Extra in generator (not in main): fieldC
# # Dependency Drift
- Missing from generated package. json: packageX (used by featureY)
- Unnecessary in generated package. json: packageZ (feature disabled)
# # zfb Config Drift
- Missing integration: integrationX (present in main, absent from zfb- config- gen. ts)
- Missing conditional: integrationY should be gated by feature "Z"
# # Feature Composition Drift
- Missing feature module: feature "X" exists in main but has no feature module
- Missing template files: feature "X" module exists but templates/ features/ X/ files/ is missing
- Missing anchor: feature "X" injects at @slot: Y but anchor not found in base template
# # Base Template Drift
- Stale file: templates/ base/ src/ components/ foo. tsx differs from main src/ components/ foo. tsx
# # No Drift Detected
(if everything is in sync)Step 3: Apply Fixes
For each drift item found:
Settings drift → Update
settings-gen.tsto add missing fields with sensible defaultsDependency drift → Update
scaffold.tsgeneratePackageJson()to add/remove depszfb config drift → Update
zfb-config-gen.tsto add/remove imports and integrationsFeature composition drift → Create/update feature module in
src/features/, add template files, add anchors to base templateBase template drift → Update the stale file in
templates/base/
After fixes:
Run
cd packages/create-zudo-doc && pnpm buildto verify TypeScript compilesRun
cd packages/create-zudo-doc && pnpm testto verify tests pass (including drift-detection test)Commit with message:
fix(create-zudo-doc): sync generator with main project
Key Files
| File | Role |
|---|---|
src/ | Canonical settings (source of truth) |
zfb.config.ts | Main project zfb config (reference for generator) |
packages/ | Generates settings.ts |
packages/ | Generates zfb.config.ts programmatically (content-collection schemas live inline — there is no separate content config) |
packages/ | Additive composition engine (injections, anchors) |
packages/ | Feature modules (injections + file lists) |
packages/ | Orchestrates generation pipeline, generates package.json |
packages/ | Minimal base template with @slot: anchors |
packages/ | Feature-specific files copied when feature is enabled |
packages/ | Integration tests |