Skip to content

Commit 2e0e2ec

Browse files
committed
feat: Game Builder — AI-generated & pre-built games in markdown
🎮 New {{@GAMe:}} tag for interactive games in markdown preview: Core features: - Game card with engine selector (Three.js / Canvas 2D / P5.js) - AI generation via @prompt: with per-card model selector - @PreBuilt: field for instant pre-built games (no AI needed) - 📋 Import button to paste/upload external HTML game code - Source viewer/editor pre-fills with existing game HTML - 📥 Export as standalone HTML, ⛶ fullscreen mode - Single-line field parsing with lookahead regex Pre-built game library (6 games): - Chess, Snake, Space Shooter, Pong, Breakout, Maths Quiz (kids) Template: - 'Games for Kids' template in new Games category (13 categories total) - Shows tag syntax + rendered game for all 6 pre-built games Files added: - js/game-docgen.js — core module - css/game-docgen.css — purple gaming aesthetic + dark mode - js/game-prebuilts.js — pre-built HTML library - js/templates/games.js — games template - changelogs/CHANGELOG-game-builder.md - tests/feature/game-tag.spec.js — 12 Playwright tests Files modified: - index.html — 🎮 Game toolbar button - js/renderer.js — transform + bind hooks, srcdoc allowlist - src/main.js — CSS + module imports - js/templates.js, js/modal-templates.js — Games category - README.md — Game Builder row + release note - tests/feature/toolbar-tags.spec.js — game button test
1 parent 1c9eede commit 2e0e2ec

14 files changed

Lines changed: 2228 additions & 23 deletions

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,18 @@
3636
| **Desktop** | Native app via Neutralino.js with system tray and offline support |
3737
| **Code Execution** | 6 languages in-browser: Bash ([just-bash](https://justbash.dev/)), Math (Nerdamer), Python ([Pyodide](https://pyodide.org/)), HTML (sandboxed iframe, `html-autorun` for widgets/quizzes), JavaScript (sandboxed iframe), SQL ([sql.js](https://sql.js.org/) SQLite) · 25+ compiled languages via [Judge0 CE](https://ce.judge0.com): C, C++, Rust, Go, Java, TypeScript, Kotlin, Scala, Ruby, Swift, Haskell, Dart, C#, and more · **▶ Run All** notebook engine — one-click sequential execution of all blocks with progress bar, abort, per-block status badges, and SQLite shared context store |
3838
| **Security** | Content Security Policy (CSP), SRI integrity hashes, XSS sanitization (DOMPurify), ReDoS protection, Firestore write-token ownership, API keys via HTTP headers, postMessage origin validation, 8-char passphrase minimum, sandboxed code execution |
39-
| **AI Document Tags** | `{{@AI:}}` text generation, `{{@Think:}}` deep reasoning, `{{@Image:}}` image generation (Gemini Imagen), `{{@OCR:}}` image-to-text extraction (Text/Math/Table modes, PDF page rendering via pdf.js), `{{@STT:}}` speech-to-text dictation (engine selector: Whisper/Voxtral/Web Speech API, 11 languages, Record/Stop/Insert/Clear) — `@` prefix syntax on all tag types + metadata fields (`@name`, `@use`, `@think`, `@search`, `@prompt`, `@step`, `@upload`, `@model`); `@model:` field persists selected model per card with intelligent defaults (OCR→`granite-docling`, TTS→`kokoro-tts`, STT→`voxtral-stt`, Image→`imagen-ultra`); editable `@prompt:` textarea and `@step:` inputs in preview cards; description/prompt separation (bare text = label, `@prompt:` = AI instruction); 📎 image/PDF upload for multimodal vision analysis; per-card model selector with document-portable model persistence, concurrent block operations |
39+
| **AI Document Tags** | `{{@AI:}}` text generation, `{{@Think:}}` deep reasoning, `{{@Image:}}` image generation (Gemini Imagen), `{{@OCR:}}` image-to-text extraction (Text/Math/Table modes, PDF page rendering via pdf.js), `{{@STT:}}` speech-to-text dictation (engine selector: Whisper/Voxtral/Web Speech API, 11 languages, Record/Stop/Insert/Clear), `{{@Game:}}` game builder (AI-generated or pre-built, Canvas 2D/Three.js/P5.js, import/export HTML) — `@` prefix syntax on all tag types + metadata fields (`@name`, `@use`, `@think`, `@search`, `@prompt`, `@step`, `@upload`, `@model`, `@engine`, `@prebuilt`); `@model:` field persists selected model per card with intelligent defaults (OCR→`granite-docling`, TTS→`kokoro-tts`, STT→`voxtral-stt`, Image→`imagen-ultra`); editable `@prompt:` textarea and `@step:` inputs in preview cards; description/prompt separation (bare text = label, `@prompt:` = AI instruction); 📎 image/PDF upload for multimodal vision analysis; per-card model selector with document-portable model persistence, concurrent block operations |
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 — DuckDuckGo (free), Brave Search, Serper.dev; 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 |
4344
| **🐧 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 |
4445
| **❓ 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 |
4546
| **🧠 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) |
4647
| **✉️ Email to Self** | Send documents directly to your inbox from the share modal — email address input with `.md` file attached + share link; powered by Google Apps Script (free, 100 emails/day); loading state + success/error feedback; email persisted in localStorage; zero third-party dependencies |
4748
| **💾 Disk Workspace** | Folder-backed storage via File System Access API — "Open Folder" in sidebar header; `.md` files read/written directly to disk; `.textagent/workspace.json` manifest; debounced autosave ("💾 Saved to disk" indicator); refresh from disk for external edits; disconnect to revert to localStorage; auto-reconnect on reload via IndexedDB handles; unified action modal for rename/duplicate/delete with confirmation; Chromium-only (hidden in unsupported browsers) |
4849
| **📈 Finance Dashboard** | Stock/crypto/index dashboard templates with live TradingView charts; dynamic grid via `data-var-prefix` (add/remove tickers in `@variables` table, grid auto-adjusts); configurable chart range (`1M`, `12M`, `36M`), interval (`D`, `W`, `M`), and EMA period (default 52); interactive 1M/1Y/3Y range + 52D/52W/52M EMA toggle buttons; `@variables` table persists after ⚡ Vars for re-editing; JS code block generates grid HTML from variables |
49-
| **Extras** | Auto-save (localStorage + cloud), table of contents, image paste, 106+ templates (12 categories: AI, Agents, Coding, Creative, Documentation, Finance, Maths, PPT, Project, Quiz, Tables, Technical), template variable substitution (`$(varName)` with auto-detect), table spreadsheet tools (sort, filter, stats, chart, add row/col, inline cell edit, CSV/MD export), content statistics, modular codebase (13+ JS modules), fully responsive mobile UI with scrollable Quick Action Bar (Files, Search, TOC, Share, Copy, Tools, AI, Model, Upload, Help) and formatting toolbar, multi-file workspace sidebar, compact header mode with collapsible Tools dropdown (Presentation, Zen, Word Wrap, Focus, Voice, Dark Mode, Preview Theme), Clear All / Clear Selection buttons (undoable via Ctrl+Z) |
50+
| **Extras** | Auto-save (localStorage + cloud), table of contents, image paste, 107+ templates (13 categories: AI, Agents, Coding, Creative, Documentation, Finance, Games, Maths, PPT, Project, Quiz, Tables, Technical), template variable substitution (`$(varName)` with auto-detect), table spreadsheet tools (sort, filter, stats, chart, add row/col, inline cell edit, CSV/MD export), content statistics, modular codebase (13+ JS modules), fully responsive mobile UI with scrollable Quick Action Bar (Files, Search, TOC, Share, Copy, Tools, AI, Model, Upload, Help) and formatting toolbar, multi-file workspace sidebar, compact header mode with collapsible Tools dropdown (Presentation, Zen, Word Wrap, Focus, Voice, Dark Mode, Preview Theme), Clear All / Clear Selection buttons (undoable via Ctrl+Z) |
5051
| **Dev Tooling** | ESLint + Prettier (lint, format:check), Playwright test suite — 329 tests across smoke, feature, integration, dev, regression, performance, quality, and security categories (import, export, share, view-mode, editor, email-to-self, secure share, startup timing, export integrity, persistence, module loading, disk workspace, context memory, exec engine, build validation, load-time, accessibility, video player, TTS, STT, file converters, stock widget, embed grid, model registry, static analysis, code smell, XSS hardening, Florence-2 model, Docling model, TTS download), pre-commit changelog enforcement, GitHub Actions CI |
5152

5253
## 🤖 AI Assistant
@@ -458,6 +459,7 @@ TextAgent has undergone significant evolution since its inception. What started
458459

459460
| Date | Commits | Feature / Update |
460461
|------|---------|-----------------|
462+
| **2026-03-13** || 🎮 **Game Builder** — new `{{@Game:}}` tag for AI-generated and pre-built interactive games in markdown; engine selector pills (Canvas 2D / Three.js / P5.js); `@prebuilt:` field for 6 instant games (chess, snake, shooter, pong, breakout, maths quiz for kids); 📋 Import button to paste or upload external HTML game code with source viewer/editor; 📥 Export as standalone HTML; ⛶ fullscreen mode; `game-prebuilts.js` pre-built HTML library; `game-docgen.js` standalone module; `game-docgen.css` with purple gaming aesthetic and dark mode; single-line field parsing with lookahead regex; "Games for Kids" template category with all 6 pre-built games and syntax reference; `srcdoc` added to DOMPurify whitelist; 🎮 Game toolbar button in AI Tags dropdown |
461463
| **2026-03-12** || 🏷️ **@model Tag Field** — new `@model:` metadata field on all AI DocGen tag types (`{{@AI:}}`, `{{@Agent:}}`, `{{@Image:}}`, `{{@OCR:}}`, `{{@TTS:}}`, `{{@STT:}}`, `{{@Translate:}}`); persists selected model in document text for portability; intelligent defaults per tag type (OCR→`granite-docling`, TTS→`kokoro-tts`, STT→`voxtral-stt`, Image→`imagen-ultra`, AI/Agent→current model); dropdown shows all registered models, changing it syncs `@model:` back to editor; validated against `AI_MODELS` registry (invalid IDs silently ignored); fully backward-compatible with existing tags |
462464
| **2026-03-12** || 🔧 **Model Loading UX** — smart cache vs download detection in all 7 AI workers (📦 Loading from cache / ⬇️ Downloading from huggingface.co/textagent/...); source location display showing HuggingFace model path during loading; 🗑️ Delete Model button in consent dialog to clear Cache API + OPFS cached files and reset consent; `deleteModelCache()` function exposed on `M._ai`; workers forward Transformers.js `status` field (`initiate`/`progress`/`done`) with `source` and `loadingPhase`; new `.ai-progress-source` info bar and `.ai-consent-btn-danger` styling with dark mode |
463465
| **2026-03-12** || 🎤 **STT Tag Block & Florence-2 & TTS Download** — new `{{@STT:...}}` tag block for in-preview speech-to-text dictation with engine selector (Whisper V3 Turbo / Voxtral Mini 3B / Web Speech API), 11-language picker, Record/Stop/Insert/Clear buttons, amber-accented CSS with recording pulse animation; Florence-2 (230M) vision OCR+captioning model added (`textagent/Florence-2-base-ft`); TTS ⬇ Save button with float32→WAV encoder for audio download; PDF-to-image OCR renderer via pdf.js (2x scale, max 3 pages); Granite Docling migrated to `textagent/` with `onnx-community/` fallback, fp16 embed_tokens, degeneration loop guard, raw base64→data URL fix; Qwen3 AutoTokenizer fix for text-only models; OCR mode forwarding to doc-model workers |
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# CHANGELOG — Game Builder Tag
2+
3+
## feat: Game Builder — AI-generated & pre-built games in markdown
4+
5+
### What Changed
6+
Added a new `{{@Game:}}` tag for building and running interactive games inside markdown documents. Games can be AI-generated from prompts or loaded instantly from a pre-built library. Users can also import their own HTML game code.
7+
8+
### Key Features
9+
- **`{{@Game:}}` tag**: Inline game card with engine selector (Three.js, Canvas 2D, P5.js), model dropdown, Generate/Play/Export/Import/Fullscreen/Remove buttons
10+
- **`@prebuilt:` field**: Auto-load pre-built games (chess, snake, shooter, pong, breakout, maths) — plays instantly, no AI needed
11+
- **📋 Import button**: Paste external HTML game code or upload `.html` files; pre-fills with existing game source for viewing/editing
12+
- **Pre-built library**: 6 complete games in `game-prebuilts.js` — Chess, Snake, Space Shooter, Pong, Breakout, Maths Quiz (kids)
13+
- **Games template**: "Games for Kids" template in Games category with all 6 pre-built games and tag syntax reference
14+
- **Single-line field parsing**: All `@field:` tags work on one line: `{{@Game: @engine: canvas2d @prebuilt: chess @prompt: Chess}}`
15+
- **AI generation**: Describe any game with `@prompt:`, select engine + model, click Generate
16+
- **Export**: Download generated/imported games as standalone HTML files
17+
18+
### Files Added
19+
- `js/game-docgen.js` — Core module: tag parsing, card rendering, AI generation, iframe playback, import modal
20+
- `css/game-docgen.css` — Styles for game cards, engine pills, import modal, dark mode
21+
- `js/game-prebuilts.js` — Pre-built game HTML library (6 games)
22+
- `js/templates/games.js` — Games template category
23+
- `tests/feature/game-tag.spec.js` — Playwright tests for game tag
24+
25+
### Files Modified
26+
- `index.html` — 🎮 Game toolbar button in AI Tags dropdown
27+
- `js/renderer.js``transformGameMarkdown` + `bindGamePreviewActions` pipeline hooks; `srcdoc` added to DOMPurify allowlist
28+
- `src/main.js` — CSS import + dynamic imports for `game-prebuilts.js` and `game-docgen.js`
29+
- `js/templates.js` — Games category in concatenation, icon, and label maps
30+
- `js/modal-templates.js` — Games category pill in template picker
31+
- `tests/feature/toolbar-tags.spec.js` — Game toolbar button test

0 commit comments

Comments
 (0)