Skip to content

Commit 94c51ed

Browse files
committed
feat: Japanese quiz games, game-gen improvements & OpenRouter retry
- Added 2 new prebuilt games: Hiragana Quiz (@PreBuilt: hiragana, 12 kana) and Kana Master (@PreBuilt: kanamaster, full 46 hiragana with combos/levels) - Rewritten Canvas 2D/Three.js/P5.js engine prompts for completeness - CDN URL normalizer rewrites AI-generated URLs to CSP-approved sources - ensureModelReady() pre-generation check in game-docgen.js - OpenRouter worker retry logic with exponential backoff (500/502/503/429) - CSP updated with unpkg.com and threejs.org script sources - Updated games template, documentation, and README (prebuilt count 6→8)
1 parent 12ce545 commit 94c51ed

File tree

8 files changed

+538
-44
lines changed

8 files changed

+538
-44
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
| **🔌 API Calls** | `{{API:}}` REST API integration — GET/POST/PUT/DELETE methods, custom headers, JSON body, response stored in `$(api_varName)` variables; inline review panel; toolbar GET/POST buttons |
4141
| **🔗 Agent Flow** | `{{Agent:}}` multi-step pipeline — define Step 1/2/3, chain outputs, per-card model + search provider selector, live step status indicators (⏳/✅/❌), review combined output |
4242
| **🔍 Web Search** | Toggle web search for AI — 7 providers: DuckDuckGo (free), Brave Search, Serper.dev, Tavily (AI-optimized), Google CSE, Wikipedia, Wikidata; search results injected into LLM context; source citations in responses; per-agent-card search provider selector |
43-
| **🎮 Game Builder** | `{{@Game:}}` tag — AI-generated games (Canvas 2D / Three.js / P5.js) or instant pre-built games via `@prebuilt:` field (chess, snake, shooter, pong, breakout, maths quiz); engine selector pills; per-card model picker; 📋 Import button for pasting/uploading external HTML game code with source viewer; 📥 Export as standalone HTML; ⛶ fullscreen; single-line field parsing; "Games for Kids" template with 6 playable games |
43+
| **🎮 Game Builder** | `{{@Game:}}` tag — AI-generated games (Canvas 2D / Three.js / P5.js) or instant pre-built games via `@prebuilt:` field (chess, snake, shooter, pong, breakout, maths quiz, hiragana, kana master); engine selector pills; per-card model picker; CDN URL normalizer for CSP compliance; auto model-ready check before generation; 📋 Import button for pasting/uploading external HTML game code with source viewer; 📥 Export as standalone HTML; ⛶ fullscreen; single-line field parsing; "Games for Kids" template with 8 playable games |
4444
| **🐧 Linux Terminal** | `{{Linux:}}` tag — two modes: (1) Terminal mode opens full Debian Linux ([WebVM](https://webvm.io)) in new window with `Packages:` field; (2) Compile & Run mode (`Language:` + `Script:`) compiles/executes 25+ languages (C++, Rust, Go, Java, Python, TypeScript, Kotlin, Scala…) via [Judge0 CE](https://ce.judge0.com) with inline output, execution time & memory stats |
4545
| **❓ Help Mode** | Interactive learning mode — click ❓ Help to highlight all buttons, click any button for description + keyboard shortcut + animated demo video; 50% screen demo panel with fullscreen expand; 16 dedicated demo videos mapped to every toolbar button |
4646
| **🧠 Context Memory** | `{{@Memory:}}` tag for workspace intelligence — SQLite FTS5 full-text search with heading-aware chunking (~1500 chars/chunk); three storage modes: browser-only (IndexedDB), disk workspace (`.textagent/memory.db`), external folders (IndexedDB); `@use: workspace, my-docs` in AI/Think/Agent tags for multi-source context retrieval; Memory Selector dropdown on AI/Think/Agent cards; amber-accented Memory card with Folder/Files/Rebuild buttons + stats; auto-discovery of workspace files; `Use: none` opt-out; reuses existing sql.js WASM (zero bundle increase) |
@@ -459,6 +459,7 @@ TextAgent has undergone significant evolution since its inception. What started
459459

460460
| Date | Commits | Feature / Update |
461461
|------|---------|-----------------:|
462+
| **2026-03-16** | | 🇯🇵 **Japanese Quiz Games & Game Gen Improvements** — 2 new prebuilt games: Hiragana Quiz (`@prebuilt: hiragana`, 12-kana falling-block quiz) and Kana Master (`@prebuilt: kanamaster`, full 46-kana with combos, levels, particles, screen shake); rewritten Canvas 2D/Three.js/P5.js engine prompts with strict completeness rules and 8K-char budget; `normalizeGameCdnUrls()` rewrites AI-generated CDN URLs to CSP-approved sources; `ensureModelReady()` pre-generation check; OpenRouter worker retry logic with exponential backoff for 500/502/503/429; CSP updated with `unpkg.com` and `threejs.org` script sources; prebuilt game count 6→8 |
462463
| **2026-03-16** | | 🐛 **Debug Template Upgrade** — upgraded "Debug This Error" from single-pass AI prompt to 3-phase pipeline (Triage & Classify with 14-pattern common-fix lookup table → Root Cause & Fix with before/after diffs and DO/DON'T rules → Verify & Prevent via Agent multi-step with verification commands, preventive guard code, and related-issue sweep); added `language` and `codeSnippet` variables |
463464
| **2026-03-16** | | 🤖 **5 New Agent Templates** — Performance Profiler (N+1 detection, memory leaks, O(n²) loops, caching strategy), Implementation Planner (feature→phased plan with task breakdown, risk assessment), Git Commit Reviewer (diff→conventional commits, breaking change detection, changelog), Deployment Checklist (stack→CI/CD pipeline, Docker config, rollback plan), Cost-Aware LLM Pipeline (model routing, budget tracking, fallback strategies) |
464465
| **2026-03-16** | | 🎮 **Game Template Fixes** — fixed emoji encoding (HTML entities→native Unicode), wrapped localStorage in try/catch for sandboxed iframes, added Breakout touch events for mobile, removed duplicate code blocks from game template, added `allow-same-origin` to game iframe sandbox, added Canvas 2D arcade game templates (platformer, top-down shooter, rhythm, tile match, tower defense) |
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Changelog — Japanese Quiz Games & Game Gen Improvements
2+
3+
## 🎮 Japanese Quiz Prebuilt Games
4+
5+
- Added **Hiragana Quiz** (`@prebuilt: hiragana`) — simple 12-kana falling-block quiz game (あ–し), catch the correct hiragana matching the romaji prompt, score 10 to win, 3 lives
6+
- Added **Kana Master** (`@prebuilt: kanamaster`) — full 46-kana version with combo system, level progression (speed increases every 5 points), particle effects, screen shake on damage, gradient paddle with glow, rounded blocks, star background, timer bar, win at 46 points
7+
- `game-prebuilts.js` — two new `window.__GAME_PREBUILTS` entries
8+
- `games.js` — two new cards (🇯🇵 Hiragana Quiz, 🎌 Kana Master) in "Games for Kids" template; updated prebuilt reference table
9+
- `documentation.js` — updated prebuilt game lists and template count (6 → 8) in Feature Showcase
10+
11+
## 🛠 Game Generation Improvements
12+
13+
- **Rewritten engine prompts** — Canvas 2D, Three.js, and P5.js system prompts rewritten with strict "CRITICAL RULES" format emphasizing completeness (no TODOs, no empty functions), 8000-character budget, and "output ONLY raw HTML" instruction
14+
- **CDN URL normalizer** — new `normalizeGameCdnUrls()` function in `game-docgen.js` rewrites AI-generated CDN URLs (unpkg.com, threejs.org, jsdelivr.net) to CSP-approved cdnjs.cloudflare.com sources for Three.js and P5.js
15+
- **Model ready check**`ensureModelReady()` async function verifies AI model is loaded before game generation; triggers loading if needed with progress feedback
16+
- **UI reorder** — moved description text above skill pills for better card layout
17+
18+
## 🔧 OpenRouter Worker Retry Logic
19+
20+
- Added `MAX_RETRIES` (2) with exponential backoff for transient HTTP errors (500, 502, 503, 429)
21+
- Retry loop in `generate()` function catches fetch failures and retries with delay
22+
- Improved error handling and status code classification
23+
24+
## 🛡 CSP Update
25+
26+
- Added `https://unpkg.com` and `https://threejs.org` to `script-src` CSP directive in `index.html` for AI-generated game scripts that reference these CDN hosts
27+
28+
## Files Changed
29+
30+
- `index.html` — CSP script-src update
31+
- `js/game-docgen.js` — prompt rewrites, CDN normalizer, model-ready check, UI reorder
32+
- `js/game-prebuilts.js` — hiragana + kanamaster prebuilt game HTML
33+
- `js/templates/games.js` — two new game cards, updated reference table
34+
- `js/templates/documentation.js` — updated prebuilt lists and count
35+
- `public/ai-worker-openrouter.js` — retry logic with backoff

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<!-- Content Security Policy -->
2121
<meta http-equiv="Content-Security-Policy" content="
2222
default-src 'self';
23-
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://esm.sh https://esm.run https://www.gstatic.com https://vjs.zencdn.net;
23+
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://esm.sh https://esm.run https://www.gstatic.com https://vjs.zencdn.net https://unpkg.com https://threejs.org;
2424
style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://vjs.zencdn.net;
2525
connect-src 'self' https: http: https://firestore.googleapis.com https://generativelanguage.googleapis.com https://api.groq.com https://openrouter.ai https://cdn.jsdelivr.net https://cdnjs.cloudflare.com https://esm.sh https://esm.run https://huggingface.co https://cdn-lfs.hf.co https://cdn-lfs-us-1.hf.co;
2626
img-src 'self' data: blob: https://www.plantuml.com https://textagent.github.io https://img.shields.io https://www.google.com;

0 commit comments

Comments
 (0)