├── .env.example ├── .gitignore ├── components ├── AutoGrowingInput.jsx ├── Chat.jsx ├── CodeBlocks.jsx ├── CodeRenderer.jsx └── PromptAndResponse.jsx ├── contexts └── AppContext.jsx ├── functions ├── clx.js ├── demoResponse.js ├── extractCodeFromBuffer.js └── transformImports.js ├── jsconfig.json ├── license ├── nodemon.json ├── package-lock.json ├── package.json ├── pages ├── _app.jsx ├── _document.jsx ├── api │ └── chat.js └── index.jsx ├── preview ├── Screenshot 2024-06-24 at 1.44.40 AM.png └── Screenshot 2024-06-28 at 7.57.19 PM.png ├── readme.md ├── server ├── execute-react.js ├── execute.js ├── findAvailablePort.js └── init.js └── styles ├── Chat.module.scss ├── CodeBlocks.module.scss ├── PromptAndResponse.module.scss ├── globals.scss └── mixins.scss /.env.example: -------------------------------------------------------------------------------- 1 | OPENAI_API_KEY = "openai api key" 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # directories 2 | .next 3 | node_modules 4 | 5 | # files 6 | .env 7 | .DS_Store 8 | *.sublime-* 9 | -------------------------------------------------------------------------------- /components/AutoGrowingInput.jsx: -------------------------------------------------------------------------------- 1 | import { useRef, useEffect } from 'react' 2 | 3 | export default ({ value, className, placeholder, onChange, onSubmit }) => { 4 | const textareaRef = useRef(null) 5 | 6 | useEffect(() => { 7 | adjustHeight() 8 | }, [value]) 9 | 10 | const adjustHeight = () => { 11 | const textarea = textareaRef.current 12 | if (textarea) { 13 | textarea.style.height = 'auto' 14 | textarea.style.height = `${textarea.scrollHeight}px` 15 | } 16 | } 17 | 18 | const handleKeyDown = (e) => { 19 | if (e.key === 'Enter' && !e.shiftKey) { 20 | onSubmit(e) 21 | } 22 | } 23 | 24 | return ( 25 |