Full Coding Circus upgrade: hardened blocks, 29 new blocks, tests, landing + examples, Pages deploy - #1
Open
TheRealBrofessor wants to merge 8 commits into
Open
Full Coding Circus upgrade: hardened blocks, 29 new blocks, tests, landing + examples, Pages deploy#1TheRealBrofessor wants to merge 8 commits into
TheRealBrofessor wants to merge 8 commits into
Conversation
- Add generators/helpers.ts: validated dropdown lookup, NaN/Infinity-safe number literals, newline-stripping sanitizer for comment text, Python identifier legalizer, and single-point wrappers for Blockly's protected definitions_/nameDB_ APIs. - Route math/compare operators, number literals, and comment text through the helpers so corrupt project JSON degrades to blander Python instead of crashing generation or emitting invalid syntax. - Make workspace loading non-throwing: corrupt saved/imported projects now surface a console message and leave a cleared workspace instead of crashing the app; imports that collide with a saved project name are renamed "(imported)". Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…nctions, Debug, Stage - Input: ask text / ask number / ask whole number -> input(), float(input()), int(input()). Standard readable Python; the browser runner has no stdin, so EOFError/OSError now normalize to a friendly "export and run with desktop Python" hint. - Lists: create (up to 3 items), append, get by index (Python 0-based), length, for-each loop. - Random: randint, random(), choice — hoisting "import random" once. - Control additions: repeat-until, count-with (inclusive range), break, continue. - Functions: name-matched define/call/call-for-value/return with typed names legalized into safe Python identifiers (no parameters; mutators out of scope). - Debug: print variable with its name, type-of value, assert with message. - Stage: "show on stage" and "clear the stage" compile to plain print() calls; the app's stage now clears when an empty line is printed, keeping exported programs 100% standard Python. - Toolbox: six new categories with beginner-friendly shadow defaults. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- New project/validation.ts: single source of truth for project-name normalization, download-filename sanitization, and untrusted-JSON validation of imported project files (formatVersion-aware, with a clear message for files from newer app versions). - ProjectStorage treats localStorage as unreliable: corrupt entries load as null instead of throwing, the index self-heals to string entries, and save failures (quota/unavailable) raise beginner-readable errors. - ProjectExport sanitizes filenames, caps import size, and reports bad JSON / wrong-shape files with friendly messages. - Save in the UI now reports success/failure to the console panel and normalizes the project name field. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- 52 tests across 5 files: block/generator/toolbox coverage (every python_* block has a generator, appears in the toolbox, and vice versa), generated-Python checks for common programs (hello world, variables, if/else, loops+imports, lists, random, functions, count-with, input), empty-branch pass insertion, comment newline- injection defense, no NaN/undefined/Infinity artifacts. - Helper unit tests: operator fallback, safe numeric literals, inline text sanitizer, Python identifier legalization. - Persistence tests: name normalization, filename sanitization, corrupt/foreign JSON rejection (incl. future formatVersion message), localStorage round trip, corrupt entry -> null, index self-healing. - Wire vitest (jsdom) into vite.config.ts; add "typecheck" and "test" npm scripts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- New Landing overlay on first visit: branding, feature list, "Start Coding" CTA, opt-in "Watch it build a program" (the existing live demo), and a clear disclosure that Python runs via Pyodide from a CDN. The demo no longer auto-plays; the toolbar button is now "Demo" and demo replays start from a cleared workspace. - Seven starter projects (Hello World, Variables, If/Else, Repeat Loop, Input, Lists, Random) stored as workspace JSON and loadable from a new Examples menu in the toolbar, with tests asserting each loads and generates artifact-free Python. - Responsive layout: panels stack under the editor below 900px; landing scales for small screens and respects prefers-reduced-motion. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- New deploy-pages workflow: builds with --base=/coding-circus/ and deploys dist/ via actions/deploy-pages on pushes to main (Pages source must be set to "GitHub Actions"; on GitHub Free this requires the repo to be public). - Blockly media now loads relative to BASE_URL so the editor works when served from a subpath. - CI now runs typecheck, lint, test, and build. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- BLOCKS.md: full inventory table (block type, category, generated Python, status, runtime notes) for all 42 blocks. - ARCHITECTURE.md: generator safety rules, design decisions (input/stdin limitation, print-based stage convention, no-parameter functions, 0-based list indexing), persistence untrusted-data posture with the formatVersion migration hook, and the static-site/Pages deployment section. - README.md: updated features, runtime/limitation disclosures, scripts table, Pages deployment instructions, and project structure. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
npm ci (strict peer resolution, as used in CI) fails with jsdom 29 because blockly@13 declares a peer dependency on jsdom@^27. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the full product upgrade in seven grouped commits, preserving the existing MVP loop (blocks → Python → run → console/stage → save/load/export) end to end.
Block system hardening
generators/helpers.ts: validated operator lookups, NaN/Infinity-safe number literals, newline-injection-proof comment sanitizer, Python identifier legalizer, and single-point wrappers for Blockly's protecteddefinitions_/nameDB_APIs.29 new blocks (42 total, 12 categories)
Input (
input()/float(input())/int(input())), Lists (create/append/get/length/for-each), Random (randint/random/choice with hoisted import), loop control (repeat-until, inclusive count-with, break, continue), name-matched Functions (def/call/call-for-value/return), Debug (print-var-with-name, type-of, assert), Stage (show/clear via a plain-print()convention so exported programs stay standard Python). Full inventory:BLOCKS.md.Persistence hardening
project/validation.tscentralizes name normalization, filename sanitization, and untrusted-JSON validation (formatVersion-aware with a migration hook). Corrupt localStorage loads asnull, the index self-heals, save failures raise friendly errors, and import name collisions are renamed.Tests
61 Vitest tests: block/generator/toolbox coverage invariants, generated-Python checks for common programs, sanitizer/fallback units, corrupt-import and round-trip persistence, and per-example load checks. New
typecheckandtestscripts; CI runs typecheck → lint → test → build.Static site
First-visit landing hero with "Start Coding" CTA and opt-in self-building demo (no longer auto-plays), seven starter examples in a toolbar menu, responsive stacked layout under 900px, reduced-motion support, and an explicit Pyodide-CDN disclosure.
Deployment
GitHub Pages workflow (
--base=/coding-circus/,actions/deploy-pages); Blockly media is now BASE_URL-relative. Note: Pages needs Settings → Pages → Source: "GitHub Actions", and a public repo on GitHub Free.Verification (clean
npm ci)npm run typecheck✅npm run lint✅npm test✅ 61/61npm run build✅ (also verified with--base=/coding-circus/)Known limitations
ask …blocks generate correct Python but the browser runner has no stdin (no SharedArrayBuffer on static hosting) — normalized into a friendly "export and run with desktop Python" hint and documented.🤖 Generated with Claude Code