SuperAPI AI 工具集

ai-studio-project-converter

前端与建站

查看项目

更新于 10-16 00:00

技能介绍

用途:把 Google AI Studio 生成的零配置 React 应用转换成本项目页面组件,保持视觉效果与功能并符合开发规范。核心目标为保持视觉一致、移除 AI Studio 特定入口与 HTML 模板、产出可运行的页面组件。

使用方式:先运行预处理脚本 node scripts/ai-studio-converter.mjs <ai-studio-project-dir> [output-name],示例 node scripts/ai-studio-converter.mjs "temp/my-ai-studio-project" my-page。脚本会复制项目到 src/prototypes/[页面名]/、分析结构、生成 .ai-studio-tasks.md 与 .ai-studio-analysis.json,且不修改任何代码。随后按任务清单完成转换。

转换要点:默认先转换为普通 React 页面组件,添加文件头注释、保持 JSX、Hooks 与 Tailwind 类名;仅当需求明确要求接入 Axhub/Axure 运行时能力时,才使用 forwardRef<AxureHandle, AxureProps>、useImperativeHandle 和 axure-types。样式上从 index.html 提取自定义样式,创建 style.css 并加入 @import "tailwindcss",有外部字体则补 @import。依赖上从 Import Map 提取,排除 react、react-dom,用 pnpm add 安装,例如 esm.sh/lucide-react 映射 lucide-react、esm.sh/framer-motion 映射 framer-motion、esm.sh/@google/genai 映射 @google/generative-ai。环境变量将 process.env.* 改为 import.meta.env.VITE_*,检查 vite.config.ts 的 define 并配置 .env.local。需移除 index.html(提取信息后)、index.tsx,metadata.json 可选保留。

验收:运行 node scripts/check-app-ready.mjs /prototypes/[页面名],要求状态为 READY、页面正常渲染、无控制台错误、交互与样式正常。限制与常见问题:依赖缺失按报告安装;确认所有 CDN 依赖已转为 npm 包;确认 style.css 含 Tailwind 导入;环境变量需按 VITE_ 前缀配置。参考资源包括 /rules/development-guide.md、/rules/debugging-guide.md、/skills/default-resource-recommendations/SKILL.md,接入 Axure 时参考 /rules/axure-api-guide.md。