Skip to content

Commit fda86af

Browse files
committed
feat: update plan
1 parent 203b144 commit fda86af

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

.amazonq/plan/compare_template_files.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import difflib
55
from pathlib import Path
6-
from typing import Literal
76

87
import typer
98

@@ -48,12 +47,14 @@ def compare_files(file1: Path, file2: Path, label1: str, label2: str) -> bool:
4847

4948

5049
def main(
51-
mode: Literal["template", "generated"] = typer.Argument(
52-
help="Compare template files or generated files"
53-
),
50+
mode: str = typer.Argument(help="Compare template files or generated files (template|generated)"),
5451
question: str = typer.Option("invert_binary_tree", help="Question name for comparison"),
5552
):
5653
"""Compare files for template validation."""
54+
if mode not in ["template", "generated"]:
55+
print(f"❌ ERROR: Invalid mode '{mode}'. Use 'template' or 'generated'")
56+
return
57+
5758
base_dir = Path(__file__).parent.parent.parent
5859

5960
files_to_compare = ["solution.py", "tests.py", "README.md", "playground.ipynb", "__init__.py"]

.amazonq/plan/cookiecutter-template-plan.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# Cookiecutter Template Modernization Plan
22

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+
325
## Analysis Summary
426

527
**Target Structure**: `leetcode/.example/` contains the reference implementation
@@ -14,10 +36,9 @@
1436

1537
### 0. Explicit File Content Analysis
1638

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)
1840
- **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
2142
- **Analysis**: Line-by-line diff of all file types
2243
- **Document**: Exact differences and required changes
2344
- **Verify**: Template variables handle all variations
@@ -104,7 +125,7 @@
104125
- **Usage**:
105126
```bash
106127
# 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
108129
```
109130
- **Makefile**: `make q-validate QUESTION=name` (implemented)
110131
- **Test**: Template regression testing
@@ -200,17 +221,4 @@
200221
- **Multi-problem testing** ensures template generalization
201222
- **Explicit file comparison** documents exact requirements
202223

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-
216224
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

Comments
 (0)