Restore tutorial-specific code generation for BuildPlan and legacy paths - #149
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
Agent-Logs-Url: https://github.com/groupthinking/EventRelay/sessions/66cebfea-a2bd-4579-a88f-c036944c77f2 Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
Agent-Logs-Url: https://github.com/groupthinking/EventRelay/sessions/66cebfea-a2bd-4579-a88f-c036944c77f2 Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
Head branch was pushed to by a user without write access
| build_plan = video_analysis.get("build_plan") or extracted_info.get("build_plan") | ||
| # Upstream callers may pass either a Pydantic BuildPlan or a plain dict. | ||
| if hasattr(build_plan, "model_dump"): | ||
| build_plan = build_plan.model_dump() |
There was a problem hiding this comment.
build_plan.model_dump() may leave StepAction enum instances inside the resulting dict (Pydantic v2 default "python" mode). Downstream code formats step["action"] into README strings and may emit StepAction.CREATE_FILE instead of create_file, and it can also complicate JSON serialization. Consider using model_dump(mode="json") (or otherwise normalizing step actions to plain strings) when converting BuildPlan to a dict.
| build_plan = build_plan.model_dump() | |
| build_plan = build_plan.model_dump(mode="json") |
| def _tempdir_factory(*paths: Path): | ||
| remaining = iter(paths) | ||
|
|
||
| def _mkdtemp(prefix: str) -> str: | ||
| path = next(remaining) | ||
| path.mkdir() | ||
| return str(path) | ||
|
|
||
| return _mkdtemp | ||
|
|
There was a problem hiding this comment.
This test module appears to duplicate the same helper functions and test cases found in tests/unit/test_code_generator.py. Keeping both copies will run the same assertions twice and increases maintenance overhead. Consider consolidating these tests into a single location (or factoring shared helpers into fixtures) and deleting the duplicate file/tests.
| def _tempdir_factory(*paths: Path): | ||
| remaining = iter(paths) | ||
|
|
||
| def _mkdtemp(prefix: str) -> str: | ||
| path = next(remaining) | ||
| path.mkdir() | ||
| return str(path) | ||
|
|
||
| return _mkdtemp | ||
|
|
There was a problem hiding this comment.
This file duplicates the same helper functions and test cases found in tests/test_code_generator.py. Duplicated tests increase runtime and maintenance burden; consider consolidating into one module (unit vs integration) and sharing helpers via fixtures to avoid two identical copies.
|
C |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| metadata = video_analysis.get("metadata") or video_analysis.get("video_data") or {} | ||
| ai_analysis = video_analysis.get("ai_analysis") or {} | ||
| build_plan = video_analysis.get("build_plan") or extracted_info.get("build_plan") | ||
| # Upstream callers may pass either a Pydantic BuildPlan or a plain dict. |
| build_plan = video_analysis.get("build_plan") or extracted_info.get("build_plan") | ||
| # Upstream callers may pass either a Pydantic BuildPlan or a plain dict. | ||
| if hasattr(build_plan, "model_dump"): | ||
| build_plan = build_plan.model_dump() |
Template-based generation was collapsing into generic output because the generation context was inconsistent across code paths: BuildPlan-backed requests could drop tutorial-specific fields, step metadata was normalized incorrectly, and dict-based build plans could fail during result packaging. This PR tightens context assembly so generated projects keep the source tutorial’s title, concepts, steps, and summary without reintroducing boilerplate fallbacks.
Context assembly
build_planinputs to a plain dict before downstream use.features,summary, andkey_conceptsin both BuildPlan and legacy extraction paths.BuildPlan step handling
orderfor structured steps, with fallback to legacystep_numberand then positional index.BuildStepschema instead of relying on non-existent fields.Generated output
Result packaging
.to_dict()on plain dicts.Regression coverage
main.jsandstyles.cssExample of the step normalization applied in the generator: