feat: AI Agent — Prompt Optimizer + HTML Animation Studio#16
Open
wj2132792581 wants to merge 1 commit into
Open
feat: AI Agent — Prompt Optimizer + HTML Animation Studio#16wj2132792581 wants to merge 1 commit into
wj2132792581 wants to merge 1 commit into
Conversation
Add two AI Agent features: prompt rewrite/scoring with before-after comparison, and self-contained HTML animation generation with sandboxed preview. Wire both through existing credits and auth patterns, with cross-page prompt handoff. Co-authored-by: Cursor <cursoragent@cursor.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
This PR adds two AI Agent features to the Open SaaS demo app:
/prompt-optimizer) — Rewrites and scores user prompts (clarity, specificity, actionability) via OpenAI function calling, with a before/after comparison UI and per-user history./html-animation) — Generates self-contained HTML/CSS animations from natural-language prompts, previews them in a sandboxed iframe, and persists generation history.The two features are wired together: after optimizing a prompt, users can jump directly to the animation studio with the optimized text pre-filled.
Direction chosen: AI Agent (Prompt Optimizer + HTML Animation Generation)
Design decisions
Shared patterns
z.toJSONSchema()→ OpenAItools+tool_choicefor type-safe, parseable responses.context.user.id.Prompt Optimizer
PromptOptimizationstoresoriginalPrompt,optimizedPrompt, and a JSONcontentblob for full replay (last 10 items).HTML Animation Studio
<!DOCTYPE html>document with inline CSS/JS only (no CDN, no fetch). This keeps previews portable and copy-paste friendly.assertHtmlSafeForPreview()blocks external scripts, iframes, event handlers, and network APIs; the client renders in<iframe sandbox="allow-scripts">withoutallow-same-originso generated code cannot access the parent page.gpt-4o-minifor generation — Better HTML/CSS quality thangpt-3.5-turbowhile keeping latency reasonable for a demo flow.Intentionally out of scope
Files changed
schema.prisma—PromptOptimization,HtmlAnimationmigrations/20260713120000_add_prompt_optimizer_and_html_animation/promptOptimizer.ts,PromptOptimizerPage.tsx,operations.ts,demo-ai-app.wasp.tshtml-animation/module (schemas, sanitize, operations, page, wasp spec)NavBar/constants.ts,DemoAppPage.tsx,main.wasp.tssanitize.test.ts— unit tests for HTML safety guardTest plan
Setup
Prompt Optimizer
/prompt-optimizer/html-animationwith prompt pre-filledHTML Animation Studio
/html-animation, enter a prompt (or use transferred optimized prompt)Unit tests
Follow-ups