|
1 | 1 | # Cookiecutter Template Modernization Plan
|
2 | 2 |
|
| 3 | +## TASK PURPOSE & CRITICAL RULES |
| 4 | + |
| 5 | +**PURPOSE:** Update the cookiecutter template to generate files that exactly match the reference structure in `.templates/leetcode/.example/{{cookiecutter.question_name}}/` |
| 6 | + |
| 7 | +**REFERENCE DIRECTORIES (NEVER MODIFY - THESE ARE EXAMPLES):** |
| 8 | + |
| 9 | +- `.templates/leetcode/.example/{{cookiecutter.question_name}}/` - Shows what the template SHOULD generate |
| 10 | +- `leetcode/.example/` - Generated file examples for comparison |
| 11 | + |
| 12 | +**ACTUAL TEMPLATE DIRECTORY (MODIFY THIS):** |
| 13 | + |
| 14 | +- `.templates/leetcode/{{cookiecutter.question_name}}/` - The cookiecutter template files to update |
| 15 | + |
| 16 | +**WORKFLOW:** |
| 17 | + |
| 18 | +1. Look at `.templates/leetcode/.example/{{cookiecutter.question_name}}/` to see target structure |
| 19 | +2. Modify `.templates/leetcode/{{cookiecutter.question_name}}/` to match the reference |
| 20 | +3. Generate with `make q-gen` |
| 21 | +4. Compare generated files vs reference with `make q-validate` |
| 22 | + |
| 23 | +**ERROR PREVENTION:** The template directory does NOT have `.example` in the path! |
| 24 | + |
3 | 25 | ## Analysis Summary
|
4 | 26 |
|
5 | 27 | **Target Structure**: `leetcode/.example/` contains the reference implementation
|
|
14 | 36 |
|
15 | 37 | ### 0. Explicit File Content Analysis
|
16 | 38 |
|
17 |
| -- **Tool**: `.amazonq/plan/compare_template_files.py` (reusable comparison script) |
| 39 | +- **Tool**: `.amazonq/plan/compare_template_files.py` (already exists - no need to implement) |
18 | 40 | - **Usage**:
|
19 |
| - - `python .amazonq/plan/compare_template_files.py template` - Compare reference vs template source |
20 |
| - - `python .amazonq/plan/compare_template_files.py generated` - Compare reference vs generated files |
| 41 | + - `poetry run python .amazonq/plan/compare_template_files.py generated --question=QUESTION_NAME` - Compare generated files vs reference |
21 | 42 | - **Analysis**: Line-by-line diff of all file types
|
22 | 43 | - **Document**: Exact differences and required changes
|
23 | 44 | - **Verify**: Template variables handle all variations
|
|
104 | 125 | - **Usage**:
|
105 | 126 | ```bash
|
106 | 127 | # Validate current template generates correct files
|
107 |
| - python .amazonq/plan/compare_template_files.py generated --question=invert_binary_tree |
| 128 | + poetry run python .amazonq/plan/compare_template_files.py generated --question=invert_binary_tree |
108 | 129 | ```
|
109 | 130 | - **Makefile**: `make q-validate QUESTION=name` (implemented)
|
110 | 131 | - **Test**: Template regression testing
|
|
200 | 221 | - **Multi-problem testing** ensures template generalization
|
201 | 222 | - **Explicit file comparison** documents exact requirements
|
202 | 223 |
|
203 |
| -## Critical Rule: Reference Directory Protection |
204 |
| - |
205 |
| -**NEVER modify these reference directories:** |
206 |
| - |
207 |
| -- `.templates/leetcode/.example/` - Template reference examples |
208 |
| -- `leetcode/.example/` - Generated file reference examples |
209 |
| - |
210 |
| -**ONLY modify the actual template directory:** |
211 |
| - |
212 |
| -- `.templates/leetcode/{{cookiecutter.question_name}}/` - The actual cookiecutter template |
213 |
| - |
214 |
| -**Workflow**: Modify template → Generate (`make q-gen`) → Compare vs reference (`make q-validate`) |
215 |
| - |
216 | 224 | This plan ensures the template generates files that exactly match `leetcode/.example/` while maintaining the robust generation process described in the rules.
|
0 commit comments