Repository navigation
Add Page Designer (page-designer), a MiniMax Code port of fx0 - #41
Closed
yujiachen-y wants to merge 2 commits into
Closed
yujiachen-y wants to merge 2 commits into
yujiachen-y wants to merge 2 commits into
Conversation
Page Designer turns a description into a single self-contained HTML page and keeps refining it in conversation, with a sandboxed live preview and a version history. It is a port of fx0 by Vercel Labs (https://github.com/vercel-labs/fx0, Apache-2.0, commit e584782): the design instructions, the HTML validation rules, the preview CSP and bootstrap, and the exact-replacement edit tool are adapted from fx0, and each adapted file says what changed. The package ships under Apache-2.0 with a NOTICE that credits fx0; the app's About dialog links to it and states that the port is not affiliated with or endorsed by Vercel. What is different: the Agent is the user's own MiniMax Code Agent (context.agent, one hidden session per page, model and thinking level picked in the app) and writes pages through the Mini App's own MCP endpoint. Pages live in context.dataDir. fx0's ten brand-inspired design.md styles are replaced by six original styles plus design.md upload. Every route answers only loopback requests (Host header and browser Origin), writes must be same-site JSON, previews run in a sandbox="allow-scripts" iframe under fx0's CSP, and the Node process makes no outbound requests.
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.
Page Designer (
page-designer) 1.0.0Describe a page and your own MiniMax Code Agent writes it as one self-contained HTML file. The page appears in a sandboxed live preview next to the chat, every version is kept, and you can copy or download the HTML. Pick any model MiniMax Code can use (and its thinking level) per page; start from one of six built-in styles or upload a
design.md. English and Chinese interface, light and dark themes.Source and credit
This is a port of fx0 by Vercel Labs (Apache-2.0, commit
e584782). Thank you to the fx0 authors: the idea and several core pieces come from their work.DESIGN_INSTRUCTIONS), the HTML validation rules, the preview CSP and sandbox bootstrap (lib/design-artifact.ts), the exact-replacement edits (lib/agent.ts), and the page-tool descriptions (lib/tools.ts). Each adapted file names its source and lists the changes at its top.NOTICEthat credits fx0. The README has a Credits section, and the app's About dialog links to fx0 and states that this is an independent community project, not affiliated with or endorsed by Vercel.design.mdfiles (third-party brand style analyses). The six built-in styles, the Mini App runtime, the page and the icon were written for this package. No Vercel or fx0 marks are used in the name or icon.Differences from fx0: the Agent is MiniMax Code's (no libfx, no AI Gateway, no sign-in or billing); pages live in
context.dataDirinstead of Redis/Neon; the Agent writes through MCP tools, so the preview updates per version rather than while HTML streams; no steering of a running turn and no image attachments.Data & access
context.dataDir:projects/<id>/project.json(title, transcript, run records, model and style, linked session id) andprojects/<id>/v<n>.html. Nothing is read or written outsidedataDir; the page keeps only the model choice and preview width inlocalStorage.agentAccess: ["session.run"],agentConcurrency: 4. Each page gets one hidden session fromcontext.agent.create(); each message is one turn run from Node. The first turn carries the design brief (adapted from fx0), the style and the user's message; the brief asks the Agent to work only through Page Designer's MCP tools and allows web search/fetch for reference.permission.requestedis shown as a card with Allow once / Deny / "Decide in conversation". The app never answers on its own: it relays exactly the user's click for that one request./mcp/page-designer(publish_design,edit_design,read_design,list_designs). Only HTML that passes fx0's validation (one complete document ≤ 512 KiB, inline scripts/styles,data:assets, no comments/forms/frames/externalsrc, only#fragmentorhttps://links) becomes a version.<iframe sandbox="allow-scripts">(opaque origin, no access to the Mini App, its storage orwindow.mcode) plus fx0's CSP, which blocks all network requests, forms, frames, workers and external assets; WebRTC is disabled before the page runs. The raw-HTML route is served with asandboxCSP.Hostand, when a browser sends one, anOriginequal to this listener (403 otherwise). Writes must be JSON (415) and not marked cross-site.surface.windowfor pop-out.Tested environment
/studio?p=<id>).edit_design(v2, v3; the preview switched by itself), a page from an English description, Stop during a run ("Stopped.", composer usable again). After the loopback fix: a rename and anotheredit_designturn (v3) repeated in the Host. No console errors or failed requests.https://link in the preview reachingwindow.open.publish_design; text before a tool call ordered after the version card; DNS-rebound hostnames reaching the API (baseline: 201 and an Agent turn started; now 403 on every route); a rename sending two PATCHes and Escape still saving.Checks
npm run check(Node 26.1.0 locally; CI runs Node 22): 69/69 tests pass,plugins/yujiachen-y/page-designer: OK(0 errors, 0 warnings).npm testin the package: 18/18node:testcases (MCP tools and validation, approvals relaying only the user's decision, questionnaire continuation, lost session replaced once, Stop before/during a turn, loopback and same-origin JSON guards, persistence across restart).README.mdandREADME.zh-CN.mdeach gain one row. Preview screenshot uses synthetic content.Need help on this PR? Tag
@codesmith-botwith what you need.