name: l-update-generator description: "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 generator", "sync generator", "l-update-generator", "l-sync-create-zudo-doc"."
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 first - Programmatic 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 files compose.tsorchestrates feature file copying, injection, and anchor cleanup- Some 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/config/settings.ts— the canonical settings object - Generator:
packages/create-zudo-doc/src/settings-gen.ts— what gets generated
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 dependencies - Generator:
packages/create-zudo-doc/src/scaffold.tsgeneratePackageJson()— 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 integrations - Generator:
packages/create-zudo-doc/src/zfb-config-gen.ts— programmatic generation
For each integration in the main zfb.config.ts, verify that either:
- It is unconditionally included in
zfb-config-gen.ts, OR - It 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/create-zudo-doc/src/features/*.ts— feature modules with injections and postProcess hooks - Templates:
packages/create-zudo-doc/templates/features/*/files/— feature-specific 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 injections - If 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/check-template-drift.sh 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 defaults - Dependency drift → Update
scaffold.tsgeneratePackageJson()to add/remove deps - zfb config drift → Update
zfb-config-gen.tsto add/remove imports and integrations - Feature composition drift → Create/update feature module in
src/features/, add template files, add anchors to base template - Base template drift → Update the stale file in
templates/base/
After fixes:
- Run
cd packages/create-zudo-doc && pnpm buildto verify TypeScript compiles - Run
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/config/settings.ts |
Canonical settings (source of truth) |
zfb.config.ts |
Main project zfb config (reference for generator) |
packages/create-zudo-doc/src/settings-gen.ts |
Generates settings.ts |
packages/create-zudo-doc/src/zfb-config-gen.ts |
Generates zfb.config.ts programmatically (content-collection schemas live inline — there is no separate content config) |
packages/create-zudo-doc/src/compose.ts |
Additive composition engine (injections, anchors) |
packages/create-zudo-doc/src/features/*.ts |
Feature modules (injections + file lists) |
packages/create-zudo-doc/src/scaffold.ts |
Orchestrates generation pipeline, generates package.json |
packages/create-zudo-doc/templates/base/ |
Minimal base template with @slot: anchors |
packages/create-zudo-doc/templates/features/ |
Feature-specific files copied when feature is enabled |
packages/create-zudo-doc/src/__tests__/scaffold.test.ts |
Integration tests |