├── .firebaserc ├── .gitignore ├── .prettierrc ├── README.md ├── firebase.json ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo.png ├── manifest.json ├── ogimage.jpeg └── robots.txt ├── src ├── App.tsx ├── common │ ├── CopyButton.tsx │ ├── components.ts │ ├── github.interface.ts │ └── models.ts ├── index.css ├── index.tsx ├── react-app-env.d.ts ├── reportWebVitals.ts ├── setupTests.ts ├── steps │ ├── ConfigPrompt.tsx │ ├── SelectModel.tsx │ └── SelectRepo.tsx └── utils │ └── helper.ts ├── tsconfig.json └── yarn.lock /.firebaserc: -------------------------------------------------------------------------------- 1 | { 2 | "projects": { 3 | "default": "codeprompt-86dad" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | /.firebase 3 | 4 | # dependencies 5 | /node_modules 6 | /.pnp 7 | .pnp.js 8 | 9 | # testing 10 | /coverage 11 | 12 | # production 13 | /build 14 | 15 | # misc 16 | .DS_Store 17 | .env.local 18 | .env.development.local 19 | .env.test.local 20 | .env.production.local 21 | 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "es5", 3 | "useTabs": false, 4 | "semi": true, 5 | "singleQuote": false 6 | } 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CodePrompt 2 | 3 | > CodePrompt is the code repository loader interface that consumes your relevant code and turns it into a GPT prompt — allowing the GPT to write more complex code for you. 4 | 5 |
6 | 7 |
8 |
9 | 10 | CodePrompt is an experiment and an attempt to let GPT write more complex code while taking into consideration of the project's context. This includes tasks such as implementing a function that evolves edits on multiple files, creating new components while reusing existing functions, etc. 11 | 12 | The inspiration and ideas for this project were primarily drawn from [mpoon/gpt-repository-loader](https://github.com/mpoon/gpt-repository-loader). However, due to its limitations in loading all files into the prompt and encountering token context limit issues, using gpt-repository-loader is currently impractical. 13 | 14 | So in CodePrompt, we add functionalities such as file selection and code editing, which enable developers to selectively choose relevant files and specific portions of code to build a GPT prompt based on their requirements. 15 | 16 | [Try it yourself](https://codeprompt.xyz), [Report a Bug / Request a Feature](https://github.com/chunrapeepat/codeprompt/issues) 17 | 18 | ## 📖 How to use: 19 | 20 | 1. Choose a GPT model from the available options, such as GPT-3.5, GPT-4, or GPT-4-32K. 21 | 2. Select a public repository that you want to work with. 22 | 3. Choose the relevant files from the repository that you want to include into the prompt. 23 | 4. Remove any irrelevant code and add specific instructions as needed. 24 | 5. Copy the prompt to your chosen GPT model to generate the desired output. 25 | 26 | ## 🛠️ Installation 27 | 28 | ### Local Development Environment 29 | 30 | 1. Clone the repository: 31 | 32 | ```bash 33 | git clone git@github.com:chunrapeepat/codeprompt.git 34 | ``` 35 | 36 | 2. Install the required packages: 37 | 38 | ```bash 39 | cd codeprompt && yarn 40 | ``` 41 | 42 | 3. Build the application: 43 | 44 | ```bash 45 | yarn build 46 | ``` 47 | 48 | 4. Start the development server: 49 | 50 | ```bash 51 | yarn start 52 | ``` 53 | 54 | ## 👥 Contributing 55 | 56 | Contributions to CodePrompt are welcome and encouraged! To contribute, please follow these steps: 57 | 58 | 1. Fork the repository 59 | 2. Create a new branch 60 | 3. Make your changes 61 | 4. Push your changes to your fork 62 | 5. Submit a pull request 63 | 64 | Or, if you have any fun ideas, go to [the issues page](https://github.com/chunrapeepat/codeprompt/issues) and post them there 🔥 65 | 66 | --- 67 | 68 | Crafted with 💖 by [@chunrapeepat](https://twitter.com/chunrapeepat) 69 | -------------------------------------------------------------------------------- /firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "hosting": { 3 | "public": "build", 4 | "ignore": [ 5 | "firebase.json", 6 | "**/.*", 7 | "**/node_modules/**" 8 | ], 9 | "rewrites": [ 10 | { 11 | "source": "**", 12 | "destination": "/index.html" 13 | } 14 | ] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "codeprompt", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@ant-design/icons": "^5.0.1", 7 | "@monaco-editor/react": "^4.4.6", 8 | "@testing-library/jest-dom": "^5.16.5", 9 | "@testing-library/react": "^13.4.0", 10 | "@testing-library/user-event": "^13.5.0", 11 | "@types/jest": "^27.5.2", 12 | "@types/node": "^16.18.18", 13 | "@types/react": "^18.0.28", 14 | "@types/react-dom": "^18.0.11", 15 | "@types/styled-components": "^5.1.26", 16 | "antd": "^5.3.2", 17 | "gpt3-tokenizer": "^1.1.5", 18 | "react": "^18.2.0", 19 | "react-dom": "^18.2.0", 20 | "react-scripts": "5.0.1", 21 | "styled-components": "^5.3.9", 22 | "typescript": "^4.9.5", 23 | "web-vitals": "^2.1.4" 24 | }, 25 | "scripts": { 26 | "start": "react-scripts start", 27 | "build": "react-scripts build", 28 | "test": "react-scripts test", 29 | "eject": "react-scripts eject", 30 | "deploy": "firebase deploy" 31 | }, 32 | "eslintConfig": { 33 | "extends": [ 34 | "react-app", 35 | "react-app/jest" 36 | ] 37 | }, 38 | "browserslist": { 39 | "production": [ 40 | ">0.2%", 41 | "not dead", 42 | "not op_mini all" 43 | ], 44 | "development": [ 45 | "last 1 chrome version", 46 | "last 1 firefox version", 47 | "last 1 safari version" 48 | ] 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chunrapeepat/codeprompt/f69e6e6baab4f442ff5d6ee5d873ce391b46dd72/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | CodePrompt - The code repository loader interface for generating GPT 13 | prompt 14 | 15 | 19 | 20 | 21 | 25 | 29 | 30 | 31 | 32 | 33 | 34 | 38 | 42 | 43 | 44 | 45 | 46 | 50 | 55 | 56 | 57 | 58 |
59 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /public/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chunrapeepat/codeprompt/f69e6e6baab4f442ff5d6ee5d873ce391b46dd72/public/logo.png -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "Codeprompt", 3 | "name": "The code repository loader UI for generating the GPT prompt.", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#333333", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /public/ogimage.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chunrapeepat/codeprompt/f69e6e6baab4f442ff5d6ee5d873ce391b46dd72/public/ogimage.jpeg -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Steps } from "antd"; 3 | import styled from "styled-components"; 4 | import SelectModel from "./steps/SelectModel"; 5 | import MODELS from "./common/models"; 6 | import SelectRepo from "./steps/SelectRepo"; 7 | import { GithubFileObject } from "./common/github.interface"; 8 | import ConfigPrompt from "./steps/ConfigPrompt"; 9 | import { 10 | GithubOutlined, 11 | HeartFilled, 12 | TwitterOutlined, 13 | } from "@ant-design/icons"; 14 | import MonacoEditor from "@monaco-editor/react"; 15 | import { StepHeading } from "./common/components"; 16 | import CopyButton from "./common/CopyButton"; 17 | 18 | const Container = styled.div` 19 | width: 800px; 20 | margin: auto auto; 21 | `; 22 | const Grid = styled.div` 23 | display: grid; 24 | grid-template-columns: 200px 1fr; 25 | grid-gap: 30px; 26 | `; 27 | const Sticky = styled.div` 28 | position: sticky; 29 | top: 30px; 30 | `; 31 | const HeaderContainer = styled.div` 32 | padding: 50px 0; 33 | padding-top: 70px; 34 | 35 | & h1 { 36 | font-family: "Source Code Pro"; 37 | margin: 0; 38 | color: #333; 39 | } 40 | & p { 41 | font-style: italic; 42 | font-weight: 500; 43 | } 44 | & .grid { 45 | display: flex; 46 | justify-content: space-between; 47 | align-items: center; 48 | } 49 | & div > a { 50 | border: 1px solid #ccc; 51 | padding: 8px 16px; 52 | border-radius: 5rem; 53 | text-decoration: none; 54 | color: #333; 55 | font-weight: 500; 56 | } 57 | `; 58 | const Header = () => { 59 | return ( 60 | 61 |
62 |

{``}

63 |
64 | 70 | Star on Github 71 | 72 | 77 | 78 | 79 |
80 |
81 |

82 | A code repository loader interface for generating GPT prompt.{" "} 83 | 88 | See The Demo 89 | 90 |

91 |
92 | ); 93 | }; 94 | const FooterContainer = styled.div` 95 | padding: 50px 0; 96 | text-align: center; 97 | color: #555; 98 | 99 | & p { 100 | font-style: italic; 101 | font-weight: 500; 102 | } 103 | & a { 104 | color: #555; 105 | text-decoration: none; 106 | font-weight: 700; 107 | font-family: "Source Code Pro"; 108 | } 109 | `; 110 | const Footer = () => { 111 | return ( 112 | 113 |

114 | Made with by{" "} 115 | 120 | @chunrapeepat 121 | 122 |

123 |
124 | ); 125 | }; 126 | 127 | const stepItems = [ 128 | { 129 | title: "Select Model", 130 | description: "Select the GPT model", 131 | }, 132 | { 133 | title: "Select Repo", 134 | description: "Select the Github repo", 135 | }, 136 | { 137 | title: "Config Prompt", 138 | description: "Config the prompt", 139 | }, 140 | { 141 | title: "Finish", 142 | description: "Copy the prompt to GPT", 143 | }, 144 | ]; 145 | 146 | function App() { 147 | const [step, setStep] = React.useState(0); 148 | const [selectedModel, setSelectedModel] = React.useState(null); 149 | const [files, setFiles] = React.useState([]); 150 | const [prompt, setPrompt] = React.useState(""); 151 | 152 | return ( 153 | 154 |
155 | 156 | 157 |
158 | 159 | { 164 | return { 165 | title: ( 166 | 171 | {item.title} 172 | 173 | ), 174 | description: ( 175 |
176 | {item.description} 177 |
178 | ), 179 | }; 180 | })} 181 | /> 182 |
183 |
184 |
185 | { 187 | setSelectedModel(MODELS[modelId]); 188 | 189 | if (step > 1) return; 190 | setStep(Math.min(step + 1, 1)); 191 | }} 192 | /> 193 | 194 | {step >= 1 && ( 195 | { 197 | setFiles(files); 198 | 199 | if (step > 2) return; 200 | setStep(Math.min(step + 1, 2)); 201 | }} 202 | /> 203 | )} 204 | 205 | {step >= 2 && ( 206 | { 210 | setPrompt(prompt); 211 | 212 | if (step > 3) return; 213 | setStep(Math.min(step + 1, 3)); 214 | }} 215 | /> 216 | )} 217 | 218 | {step >= 3 && ( 219 |
220 | Prompt Generated 🎉 221 |

229 | Copy the prompt below to feed the GPT on{" "} 230 | 235 | The Official ChatGPT interface 236 | 237 | . 238 |

239 |
240 | 251 |
252 | 253 | 254 |
255 | )} 256 |
257 |
258 |