bolt.new-any-llm/CONTRIBUTING.md

111 lines
5.3 KiB
Markdown
Raw Normal View History

2024-10-03 12:12:13 +00:00
[![Bolt Open Source Codebase](./public/social_preview_index.jpg)](https://bolt.new)
> Welcome to the **Bolt** open-source codebase! This repo contains a simple example app using the core components from bolt.new to help you get started building **AI-powered software development tools** powered by StackBlitzs **WebContainer API**.
2024-07-10 16:44:39 +00:00
2024-10-01 00:14:28 +00:00
### Why Build with Bolt + WebContainer API
2024-10-07 17:28:13 +00:00
By building with the Bolt + WebContainer API you can create browser-based applications that let users **prompt, run, edit, and deploy** full-stack web apps directly in the browser, without the need for virtual machines. With WebContainer API, you can build apps that give AI direct access and full control over a **Node.js server**, **filesystem**, **package manager** and **dev terminal** inside your users browser tab. This powerful combination allows you to create a new class of development tools that support all major JavaScript libraries and Node packages right out of the box, all without remote environments or local installs.
2024-10-01 00:14:28 +00:00
### Whats the Difference Between Bolt (This Repo) and [Bolt.new](https://bolt.new)?
2024-10-03 15:13:11 +00:00
- **Bolt.new**: This is the **commercial product** from StackBlitz—a hosted, browser-based AI development tool that enables users to prompt, run, edit, and deploy full-stack web applications directly in the browser. Built on top of the [Bolt open-source repo](https://github.com/stackblitz/bolt.new) and powered by the StackBlitz **WebContainer API**.
2024-10-01 00:14:28 +00:00
2024-10-03 15:13:11 +00:00
- **Bolt (This Repo)**: This open-source repository provides the core components used to make **Bolt.new**. This repo contains the UI interface for Bolt as well as the server components, built using [Remix Run](https://remix.run/). By leveraging this repo and StackBlitzs **WebContainer API**, you can create your own AI-powered development tools and full-stack applications that run entirely in the browser.
2024-10-01 00:14:28 +00:00
2024-10-03 04:24:22 +00:00
# Get Started Building with Bolt
2024-10-03 15:13:11 +00:00
Bolt combines the capabilities of AI with sandboxed development environments to create a collaborative experience where code can be developed by the assistant and the programmer together. Bolt combines [WebContainer API](https://webcontainers.io/api) with [Claude Sonnet 3.5](https://www.anthropic.com/news/claude-3-5-sonnet) using [Remix](https://remix.run/) and the [AI SDK](https://sdk.vercel.ai/).
2024-10-03 04:24:22 +00:00
### WebContainer API
2024-10-03 15:13:11 +00:00
Bolt uses [WebContainers](https://webcontainers.io/) to run generated code in the browser. WebContainers provide Bolt with a full-stack sandbox environment using [WebContainer API](https://webcontainers.io/api). WebContainers run full-stack applications directly in the browser without the cost and security concerns of cloud hosted AI agents. WebContainers are interactive and editable, and enables Bolt's AI to run code and understand any changes from the user.
2024-10-03 04:24:22 +00:00
2024-10-01 00:14:28 +00:00
The [WebContainer API](https://webcontainers.io) is free for personal and open source usage. If you're building an application for commercial usage, you can learn more about our [WebContainer API commercial usage pricing here](https://stackblitz.com/pricing#webcontainer-api).
2024-10-03 04:24:22 +00:00
### Remix App
Bolt is built with [Remix](https://remix.run/) and
deployed using [CloudFlare Pages](https://pages.cloudflare.com/) and
[CloudFlare Workers](https://workers.cloudflare.com/).
### AI SDK Integration
Bolt uses the [AI SDK](https://github.com/vercel/ai) to integrate with AI
models. At this time, Bolt supports using Anthropic's Claude Sonnet 3.5.
You can get an API key from the [Anthropic API Console](https://console.anthropic.com/) to use with Bolt.
2024-10-03 12:17:24 +00:00
Take a look at how [Bolt uses the AI SDK](https://github.com/stackblitz/bolt.new/tree/main/app/lib/.server/llm)
2024-10-03 04:24:22 +00:00
2024-09-25 18:54:09 +00:00
## Prerequisites
2024-07-10 16:44:39 +00:00
2024-09-25 18:54:09 +00:00
Before you begin, ensure you have the following installed:
2024-07-10 16:44:39 +00:00
2024-07-11 19:25:19 +00:00
- Node.js (v20.15.1)
2024-07-10 16:44:39 +00:00
- pnpm (v9.4.0)
2024-09-25 18:54:09 +00:00
## Setup
2024-07-10 16:44:39 +00:00
2024-09-25 18:54:09 +00:00
1. Clone the repository (if you haven't already):
2024-07-10 16:44:39 +00:00
```bash
2024-09-30 16:20:55 +00:00
git clone https://github.com/stackblitz/bolt.new.git
2024-07-10 16:44:39 +00:00
```
2. Install dependencies:
```bash
2024-09-25 18:54:09 +00:00
pnpm install
```
3. Create a `.env.local` file in the root directory and add your Anthropic API key:
```
ANTHROPIC_API_KEY=XXX
```
2024-10-03 12:13:43 +00:00
Optionally, you can set the debug level:
2024-09-25 18:54:09 +00:00
```
VITE_LOG_LEVEL=debug
```
**Important**: Never commit your `.env.local` file to version control. It's already included in .gitignore.
## Available Scripts
- `pnpm run dev`: Starts the development server.
- `pnpm run build`: Builds the project.
- `pnpm run start`: Runs the built application locally using Wrangler Pages. This script uses `bindings.sh` to set up necessary bindings so you don't have to duplicate environment variables.
- `pnpm run preview`: Builds the project and then starts it locally, useful for testing the production build. Note, HTTP streaming currently doesn't work as expected with `wrangler pages dev`.
2024-10-07 17:28:13 +00:00
- `pnpm test`: Runs the test suite using Vitest.
2024-09-25 18:54:09 +00:00
- `pnpm run typecheck`: Runs TypeScript type checking.
- `pnpm run typegen`: Generates TypeScript types using Wrangler.
- `pnpm run deploy`: Builds the project and deploys it to Cloudflare Pages.
## Development
To start the development server:
2024-07-29 18:31:45 +00:00
```bash
2024-09-25 18:54:09 +00:00
pnpm run dev
2024-07-29 18:31:45 +00:00
```
2024-09-25 18:54:09 +00:00
This will start the Remix Vite development server.
2024-07-10 16:44:39 +00:00
2024-09-25 18:54:09 +00:00
## Testing
2024-07-10 16:44:39 +00:00
2024-09-25 18:54:09 +00:00
Run the test suite with:
2024-07-10 16:44:39 +00:00
```bash
2024-09-25 18:54:09 +00:00
pnpm test
2024-07-10 16:44:39 +00:00
```
2024-09-25 18:54:09 +00:00
## Deployment
To deploy the application to Cloudflare Pages:
2024-07-10 16:44:39 +00:00
```bash
2024-09-25 18:54:09 +00:00
pnpm run deploy
2024-07-10 16:44:39 +00:00
```
2024-09-25 18:54:09 +00:00
Make sure you have the necessary permissions and Wrangler is correctly configured for your Cloudflare account.