mirror of
https://github.com/coleam00/bolt.new-any-llm
synced 2024-12-27 22:33:03 +00:00
Merge branch 'main' into main
This commit is contained in:
commit
368022d797
39
.github/workflows/github-build-push.yml
vendored
Normal file
39
.github/workflows/github-build-push.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
name: Build and Push Container
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
# paths:
|
||||
# - 'Dockerfile'
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: [ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and Push Containers
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/${{ github.repository }}:latest
|
||||
ghcr.io/${{ github.repository }}:${{ github.sha }}
|
136
CONTRIBUTING.md
136
CONTRIBUTING.md
@ -1,110 +1,98 @@
|
||||
[![Bolt Open Source Codebase](./public/social_preview_index.jpg)](https://bolt.new)
|
||||
# Contributing to Bolt.new Fork
|
||||
|
||||
> 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 StackBlitz’s **WebContainer API**.
|
||||
First off, thank you for considering contributing to Bolt.new! This fork aims to expand the capabilities of the original project by integrating multiple LLM providers and enhancing functionality. Every contribution helps make Bolt.new a better tool for developers worldwide.
|
||||
|
||||
### Why Build with Bolt + WebContainer API
|
||||
## 📋 Table of Contents
|
||||
- [Code of Conduct](#code-of-conduct)
|
||||
- [How Can I Contribute?](#how-can-i-contribute)
|
||||
- [Pull Request Guidelines](#pull-request-guidelines)
|
||||
- [Coding Standards](#coding-standards)
|
||||
- [Development Setup](#development-setup)
|
||||
- [Project Structure](#project-structure)
|
||||
|
||||
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.
|
||||
## Code of Conduct
|
||||
|
||||
### What’s the Difference Between Bolt (This Repo) and [Bolt.new](https://bolt.new)?
|
||||
This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers.
|
||||
|
||||
- **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**.
|
||||
## How Can I Contribute?
|
||||
|
||||
- **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 StackBlitz’s **WebContainer API**, you can create your own AI-powered development tools and full-stack applications that run entirely in the browser.
|
||||
### 🐞 Reporting Bugs and Feature Requests
|
||||
- Check the issue tracker to avoid duplicates
|
||||
- Use the issue templates when available
|
||||
- Include as much relevant information as possible
|
||||
- For bugs, add steps to reproduce the issue
|
||||
|
||||
# Get Started Building with Bolt
|
||||
### 🔧 Code Contributions
|
||||
1. Fork the repository
|
||||
2. Create a new branch for your feature/fix
|
||||
3. Write your code
|
||||
4. Submit a pull request
|
||||
|
||||
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/).
|
||||
### ✨ Becoming a Core Contributor
|
||||
We're looking for dedicated contributors to help maintain and grow this project. If you're interested in becoming a core contributor, please fill out our [Contributor Application Form](https://forms.gle/TBSteXSDCtBDwr5m7).
|
||||
|
||||
### WebContainer API
|
||||
## Pull Request Guidelines
|
||||
|
||||
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.
|
||||
### 📝 PR Checklist
|
||||
- [ ] Branch from the main branch
|
||||
- [ ] Update documentation if needed
|
||||
- [ ] Manually verify all new functionality works as expected
|
||||
- [ ] Keep PRs focused and atomic
|
||||
|
||||
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).
|
||||
### 👀 Review Process
|
||||
1. Manually test the changes
|
||||
2. At least one maintainer review required
|
||||
3. Address all review comments
|
||||
4. Maintain clean commit history
|
||||
|
||||
### Remix App
|
||||
## Coding Standards
|
||||
|
||||
Bolt is built with [Remix](https://remix.run/) and
|
||||
deployed using [CloudFlare Pages](https://pages.cloudflare.com/) and
|
||||
[CloudFlare Workers](https://workers.cloudflare.com/).
|
||||
### 💻 General Guidelines
|
||||
- Follow existing code style
|
||||
- Comment complex logic
|
||||
- Keep functions focused and small
|
||||
- Use meaningful variable names
|
||||
|
||||
### 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.
|
||||
Take a look at how [Bolt uses the AI SDK](https://github.com/stackblitz/bolt.new/tree/main/app/lib/.server/llm)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Before you begin, ensure you have the following installed:
|
||||
|
||||
- Node.js (v20.15.1)
|
||||
- pnpm (v9.4.0)
|
||||
|
||||
## Setup
|
||||
|
||||
1. Clone the repository (if you haven't already):
|
||||
## Development Setup
|
||||
|
||||
### 🔄 Initial Setup
|
||||
1. Clone the repository:
|
||||
```bash
|
||||
git clone https://github.com/stackblitz/bolt.new.git
|
||||
git clone https://github.com/coleam00/bolt.new-any-llm.git
|
||||
```
|
||||
|
||||
2. Install dependencies:
|
||||
|
||||
```bash
|
||||
pnpm install
|
||||
```
|
||||
|
||||
3. Create a `.env.local` file in the root directory and add your Anthropic API key:
|
||||
|
||||
```
|
||||
3. Set up environment variables:
|
||||
- Rename `.env.example` to `.env.local`
|
||||
- Add your LLM API keys (only set the ones you plan to use):
|
||||
```bash
|
||||
GROQ_API_KEY=XXX
|
||||
OPENAI_API_KEY=XXX
|
||||
ANTHROPIC_API_KEY=XXX
|
||||
...
|
||||
```
|
||||
|
||||
Optionally, you can set the debug level:
|
||||
|
||||
```
|
||||
- Optionally set debug level:
|
||||
```bash
|
||||
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`.
|
||||
- `pnpm test`: Runs the test suite using Vitest.
|
||||
- `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:
|
||||
|
||||
### 🚀 Running the Development Server
|
||||
```bash
|
||||
pnpm run dev
|
||||
```
|
||||
|
||||
This will start the Remix Vite development server.
|
||||
**Note**: You will need Google Chrome Canary to run this locally if you use Chrome! It's an easy install and a good browser for web development anyway.
|
||||
|
||||
## Testing
|
||||
## Questions?
|
||||
|
||||
Run the test suite with:
|
||||
For any questions about contributing, please:
|
||||
1. Check existing documentation
|
||||
2. Search through issues
|
||||
3. Create a new issue with the question label
|
||||
|
||||
```bash
|
||||
pnpm test
|
||||
```
|
||||
|
||||
## Deployment
|
||||
|
||||
To deploy the application to Cloudflare Pages:
|
||||
|
||||
```bash
|
||||
pnpm run deploy
|
||||
```
|
||||
|
||||
Make sure you have the necessary permissions and Wrangler is correctly configured for your Cloudflare account.
|
||||
Thank you for contributing to Bolt.new! 🚀
|
29
Dockerfile
Normal file
29
Dockerfile
Normal file
@ -0,0 +1,29 @@
|
||||
# Use an official Node.js runtime as the base image
|
||||
FROM node:20.15.1
|
||||
|
||||
# Set the working directory in the container
|
||||
WORKDIR /app
|
||||
|
||||
# Install pnpm
|
||||
RUN npm install -g pnpm@9.4.0
|
||||
|
||||
# Copy package.json and pnpm-lock.yaml (if available)
|
||||
COPY package.json pnpm-lock.yaml* ./
|
||||
|
||||
# Install dependencies
|
||||
RUN pnpm install
|
||||
|
||||
# Copy the rest of the application code
|
||||
COPY . .
|
||||
|
||||
# Build the application
|
||||
RUN pnpm run build
|
||||
|
||||
# Make sure bindings.sh is executable
|
||||
RUN chmod +x bindings.sh
|
||||
|
||||
# Expose the port the app runs on (adjust if you specified a different port)
|
||||
EXPOSE 3000
|
||||
|
||||
# Start the application
|
||||
CMD ["pnpm", "run", "start"]
|
23
README.md
23
README.md
@ -2,15 +2,16 @@
|
||||
|
||||
# Bolt.new Fork by Cole Medin
|
||||
|
||||
This fork of bolt.new allows you to choose the LLM that you use for each prompt! Currently you can use OpenAI, Anthropic, Ollama, OpenRouter, Gemini, or Groq models - and it is easily extended to use any other model supported by the Vercel AI SDK! See instructions below for running this locally and extending to include more models.
|
||||
This fork of Bolt.new allows you to choose the LLM that you use for each prompt! Currently, you can use OpenAI, Anthropic, Ollama, OpenRouter, Gemini, or Groq models - and it is easily extended to use any other model supported by the Vercel AI SDK! See the instructions below for running this locally and extending it to include more models.
|
||||
|
||||
# Requested Additions to this Fork - Feel Free to Contribute!!
|
||||
|
||||
- ✅ OpenRouter Integration (@coleam00)
|
||||
- ✅ Gemini Integration (@jonathands)
|
||||
- ✅ Autogenerate Ollama models from what is downloaded (@mosquet)
|
||||
- ✅ Autogenerate Ollama models from what is downloaded (@yunatamos)
|
||||
- ✅ Filter models by provider (@jasonm23)
|
||||
- ✅ Download project as ZIP (@fabwaseem)
|
||||
- ✅ Improvements to the main Bolt.new prompt in `app\lib\.server\llm\prompts.ts` (@kofi-bhr)
|
||||
- ⬜ LM Studio Integration
|
||||
- ⬜ DeepSeek API Integration
|
||||
- ⬜ Together Integration
|
||||
@ -20,15 +21,15 @@ This fork of bolt.new allows you to choose the LLM that you use for each prompt!
|
||||
- ⬜ Containerize the application with Docker for easy installation
|
||||
- ⬜ Better prompting for smaller LLMs (code window sometimes doesn't start)
|
||||
- ⬜ Attach images to prompts
|
||||
- ⬜ Run agents in the backend instead of a single model call
|
||||
- ⬜ Run agents in the backend as opposed to a single model call
|
||||
- ⬜ Publish projects directly to GitHub
|
||||
- ⬜ Deploy directly to Vercel/Netlify/other similar platforms
|
||||
- ⬜ Load local projects into the app
|
||||
- ⬜ Improvements to the main Bolt.new prompt in `app\lib\.server\llm\prompts.ts` (there is definitely opportunity there)
|
||||
- ⬜ Ability to revert code to earlier version
|
||||
- ⬜ Prompt caching
|
||||
- ⬜ Ability to entire API keys in the UI
|
||||
- ⬜ Prevent Bolt from rewriting files so often
|
||||
- ⬜ Ability to enter API keys in the UI
|
||||
- ⬜ Prevent Bolt from rewriting files as often
|
||||
- ⬜ Have LLM plan the project in a MD file for better results/transparency
|
||||
|
||||
# Bolt.new: AI-Powered Full-Stack Web Development in the Browser
|
||||
|
||||
@ -36,7 +37,7 @@ Bolt.new is an AI-powered web development agent that allows you to prompt, run,
|
||||
|
||||
## What Makes Bolt.new Different
|
||||
|
||||
Claude, v0, etc are incredible- but you can't install packages, run backends or edit code. That’s where Bolt.new stands out:
|
||||
Claude, v0, etc are incredible- but you can't install packages, run backends, or edit code. That’s where Bolt.new stands out:
|
||||
|
||||
- **Full-Stack in the Browser**: Bolt.new integrates cutting-edge AI models with an in-browser development environment powered by **StackBlitz’s WebContainers**. This allows you to:
|
||||
- Install and run npm tools and libraries (like Vite, Next.js, and more)
|
||||
@ -45,9 +46,9 @@ Claude, v0, etc are incredible- but you can't install packages, run backends or
|
||||
- Deploy to production from chat
|
||||
- Share your work via a URL
|
||||
|
||||
- **AI with Environment Control**: Unlike traditional dev environments where the AI can only assist in code generation, Bolt.new gives AI models **complete control** over the entire environment including the filesystem, node server, package manager, terminal, and browser console. This empowers AI agents to handle the entire app lifecycle—from creation to deployment.
|
||||
- **AI with Environment Control**: Unlike traditional dev environments where the AI can only assist in code generation, Bolt.new gives AI models **complete control** over the entire environment including the filesystem, node server, package manager, terminal, and browser console. This empowers AI agents to handle the whole app lifecycle—from creation to deployment.
|
||||
|
||||
Whether you’re an experienced developer, a PM or designer, Bolt.new allows you to build production-grade full-stack applications with ease.
|
||||
Whether you’re an experienced developer, a PM, or a designer, Bolt.new allows you to easily build production-grade full-stack applications.
|
||||
|
||||
For developers interested in building their own AI-powered development tools with WebContainers, check out the open-source Bolt codebase in this repo!
|
||||
|
||||
@ -90,7 +91,7 @@ VITE_LOG_LEVEL=debug
|
||||
|
||||
## Adding New LLMs:
|
||||
|
||||
To make new LLMs available to use in this version of Bolt.new, head on over to `app/utils/constants.ts` and find the constant MODEL_LIST. Each element in this array is an object that has the model ID for the name (get this from the provider's API documentation), a lable for the frontend model dropdown, and the provider.
|
||||
To make new LLMs available to use in this version of Bolt.new, head on over to `app/utils/constants.ts` and find the constant MODEL_LIST. Each element in this array is an object that has the model ID for the name (get this from the provider's API documentation), a label for the frontend model dropdown, and the provider.
|
||||
|
||||
By default, Anthropic, OpenAI, Groq, and Ollama are implemented as providers, but the YouTube video for this repo covers how to extend this to work with more providers if you wish!
|
||||
|
||||
@ -115,7 +116,7 @@ To start the development server:
|
||||
pnpm run dev
|
||||
```
|
||||
|
||||
This will start the Remix Vite development server. You will need Google Chrome Canary to run this locally! It's a very easy install and a good browser for web development anyway.
|
||||
This will start the Remix Vite development server. You will need Google Chrome Canary to run this locally if you use Chrome! It's an easy install and a good browser for web development anyway.
|
||||
|
||||
## Tips and Tricks
|
||||
|
||||
|
@ -162,6 +162,31 @@ export const Workbench = memo(({ chatStarted, isStreaming }: WorkspaceProps) =>
|
||||
<div className="i-ph:terminal" />
|
||||
Toggle Terminal
|
||||
</PanelHeaderButton>
|
||||
<PanelHeaderButton
|
||||
className="mr-1 text-sm"
|
||||
onClick={() => {
|
||||
const repoName = prompt("Please enter a name for your new GitHub repository:", "bolt-generated-project");
|
||||
if (!repoName) {
|
||||
alert("Repository name is required. Push to GitHub cancelled.");
|
||||
return;
|
||||
}
|
||||
const githubUsername = prompt("Please enter your GitHub username:");
|
||||
if (!githubUsername) {
|
||||
alert("GitHub username is required. Push to GitHub cancelled.");
|
||||
return;
|
||||
}
|
||||
const githubToken = prompt("Please enter your GitHub personal access token:");
|
||||
if (!githubToken) {
|
||||
alert("GitHub token is required. Push to GitHub cancelled.");
|
||||
return;
|
||||
}
|
||||
|
||||
workbenchStore.pushToGitHub(repoName, githubUsername, githubToken);
|
||||
}}
|
||||
>
|
||||
<div className="i-ph:github-logo" />
|
||||
Push to GitHub
|
||||
</PanelHeaderButton>
|
||||
</>
|
||||
)}
|
||||
<IconButton
|
||||
|
@ -1,5 +1,5 @@
|
||||
// see https://docs.anthropic.com/en/docs/about-claude/models
|
||||
export const MAX_TOKENS = 8192;
|
||||
export const MAX_TOKENS = 8000;
|
||||
|
||||
// limits the number of model responses that can be returned in a single request
|
||||
export const MAX_RESPONSE_SEGMENTS = 2;
|
||||
|
@ -29,7 +29,32 @@ You are Bolt, an expert AI assistant and exceptional senior software developer w
|
||||
|
||||
IMPORTANT: When choosing databases or npm packages, prefer options that don't rely on native binaries. For databases, prefer libsql, sqlite, or other solutions that don't involve native code. WebContainer CANNOT execute arbitrary native binaries.
|
||||
|
||||
Available shell commands: cat, chmod, cp, echo, hostname, kill, ln, ls, mkdir, mv, ps, pwd, rm, rmdir, xxd, alias, cd, clear, curl, env, false, getconf, head, sort, tail, touch, true, uptime, which, code, jq, loadenv, node, python3, wasm, xdg-open, command, exit, export, source
|
||||
Available shell commands:
|
||||
File Operations:
|
||||
- cat: Display file contents
|
||||
- cp: Copy files/directories
|
||||
- ls: List directory contents
|
||||
- mkdir: Create directory
|
||||
- mv: Move/rename files
|
||||
- rm: Remove files
|
||||
- rmdir: Remove empty directories
|
||||
- touch: Create empty file/update timestamp
|
||||
|
||||
System Information:
|
||||
- hostname: Show system name
|
||||
- ps: Display running processes
|
||||
- pwd: Print working directory
|
||||
- uptime: Show system uptime
|
||||
- env: Environment variables
|
||||
|
||||
Development Tools:
|
||||
- node: Execute Node.js code
|
||||
- python3: Run Python scripts
|
||||
- code: VSCode operations
|
||||
- jq: Process JSON
|
||||
|
||||
Other Utilities:
|
||||
- curl, head, sort, tail, clear, which, export, chmod, scho, hostname, kill, ln, xxd, alias, false, getconf, true, loadenv, wasm, xdg-open, command, exit, source
|
||||
</system_constraints>
|
||||
|
||||
<code_formatting_info>
|
||||
@ -84,6 +109,36 @@ You are Bolt, an expert AI assistant and exceptional senior software developer w
|
||||
</${MODIFICATIONS_TAG_NAME}>
|
||||
</diff_spec>
|
||||
|
||||
<chain_of_thought_instructions>
|
||||
Before providing a solution, BRIEFLY outline your implementation steps. This helps ensure systematic thinking and clear communication. Your planning should:
|
||||
- List concrete steps you'll take
|
||||
- Identify key components needed
|
||||
- Note potential challenges
|
||||
- Be concise (2-4 lines maximum)
|
||||
|
||||
Example responses:
|
||||
|
||||
User: "Create a todo list app with local storage"
|
||||
Assistant: "Sure. I'll start by:
|
||||
1. Set up Vite + React
|
||||
2. Create TodoList and TodoItem components
|
||||
3. Implement localStorage for persistence
|
||||
4. Add CRUD operations
|
||||
|
||||
Let's start now.
|
||||
|
||||
[Rest of response...]"
|
||||
|
||||
User: "Help debug why my API calls aren't working"
|
||||
Assistant: "Great. My first steps will be:
|
||||
1. Check network requests
|
||||
2. Verify API endpoint format
|
||||
3. Examine error handling
|
||||
|
||||
[Rest of response...]"
|
||||
|
||||
</chain_of_thought_instructions>
|
||||
|
||||
<artifact_info>
|
||||
Bolt creates a SINGLE, comprehensive artifact for each project. The artifact contains all necessary steps and components, including:
|
||||
|
||||
|
@ -11,6 +11,7 @@ import { PreviewsStore } from './previews';
|
||||
import { TerminalStore } from './terminal';
|
||||
import JSZip from 'jszip';
|
||||
import { saveAs } from 'file-saver';
|
||||
import { Octokit } from "@octokit/rest";
|
||||
|
||||
export interface ArtifactState {
|
||||
id: string;
|
||||
@ -333,6 +334,111 @@ export class WorkbenchStore {
|
||||
|
||||
return syncedFiles;
|
||||
}
|
||||
|
||||
async pushToGitHub(repoName: string, githubUsername: string, ghToken: string) {
|
||||
|
||||
try {
|
||||
// Get the GitHub auth token from environment variables
|
||||
const githubToken = ghToken;
|
||||
|
||||
const owner = githubUsername;
|
||||
|
||||
if (!githubToken) {
|
||||
throw new Error('GitHub token is not set in environment variables');
|
||||
}
|
||||
|
||||
// Initialize Octokit with the auth token
|
||||
const octokit = new Octokit({ auth: githubToken });
|
||||
|
||||
// Check if the repository already exists before creating it
|
||||
let repo
|
||||
try {
|
||||
repo = await octokit.repos.get({ owner: owner, repo: repoName });
|
||||
} catch (error) {
|
||||
if (error instanceof Error && 'status' in error && error.status === 404) {
|
||||
// Repository doesn't exist, so create a new one
|
||||
const { data: newRepo } = await octokit.repos.createForAuthenticatedUser({
|
||||
name: repoName,
|
||||
private: false,
|
||||
auto_init: true,
|
||||
});
|
||||
repo = newRepo;
|
||||
} else {
|
||||
console.log('cannot create repo!');
|
||||
throw error; // Some other error occurred
|
||||
}
|
||||
}
|
||||
|
||||
// Get all files
|
||||
const files = this.files.get();
|
||||
if (!files || Object.keys(files).length === 0) {
|
||||
throw new Error('No files found to push');
|
||||
}
|
||||
|
||||
// Create blobs for each file
|
||||
const blobs = await Promise.all(
|
||||
Object.entries(files).map(async ([filePath, dirent]) => {
|
||||
if (dirent?.type === 'file' && dirent.content) {
|
||||
const { data: blob } = await octokit.git.createBlob({
|
||||
owner: repo.owner.login,
|
||||
repo: repo.name,
|
||||
content: Buffer.from(dirent.content).toString('base64'),
|
||||
encoding: 'base64',
|
||||
});
|
||||
return { path: filePath.replace(/^\/home\/project\//, ''), sha: blob.sha };
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
const validBlobs = blobs.filter(Boolean); // Filter out any undefined blobs
|
||||
|
||||
if (validBlobs.length === 0) {
|
||||
throw new Error('No valid files to push');
|
||||
}
|
||||
|
||||
// Get the latest commit SHA (assuming main branch, update dynamically if needed)
|
||||
const { data: ref } = await octokit.git.getRef({
|
||||
owner: repo.owner.login,
|
||||
repo: repo.name,
|
||||
ref: `heads/${repo.default_branch || 'main'}`, // Handle dynamic branch
|
||||
});
|
||||
const latestCommitSha = ref.object.sha;
|
||||
|
||||
// Create a new tree
|
||||
const { data: newTree } = await octokit.git.createTree({
|
||||
owner: repo.owner.login,
|
||||
repo: repo.name,
|
||||
base_tree: latestCommitSha,
|
||||
tree: validBlobs.map((blob) => ({
|
||||
path: blob!.path,
|
||||
mode: '100644',
|
||||
type: 'blob',
|
||||
sha: blob!.sha,
|
||||
})),
|
||||
});
|
||||
|
||||
// Create a new commit
|
||||
const { data: newCommit } = await octokit.git.createCommit({
|
||||
owner: repo.owner.login,
|
||||
repo: repo.name,
|
||||
message: 'Initial commit from your app',
|
||||
tree: newTree.sha,
|
||||
parents: [latestCommitSha],
|
||||
});
|
||||
|
||||
// Update the reference
|
||||
await octokit.git.updateRef({
|
||||
owner: repo.owner.login,
|
||||
repo: repo.name,
|
||||
ref: `heads/${repo.default_branch || 'main'}`, // Handle dynamic branch
|
||||
sha: newCommit.sha,
|
||||
});
|
||||
|
||||
alert(`Repository created and code pushed: ${repo.html_url}`);
|
||||
} catch (error) {
|
||||
console.error('Error pushing to GitHub:', error instanceof Error ? error.message : String(error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const workbenchStore = new WorkbenchStore();
|
||||
|
24
docker-compose.yml
Normal file
24
docker-compose.yml
Normal file
@ -0,0 +1,24 @@
|
||||
services:
|
||||
bolt-app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
# Add any other environment variables your app needs
|
||||
# - OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||
# - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
|
||||
# - GROQ_API_KEY=${GROQ_API_KEY}
|
||||
# - OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY}
|
||||
volumes:
|
||||
# This volume is for development purposes, allowing live code updates
|
||||
# Comment out or remove for production
|
||||
- .:/app
|
||||
# This volume is to prevent node_modules from being overwritten by the above volume
|
||||
- /app/node_modules
|
||||
command: pnpm run start
|
||||
|
||||
volumes:
|
||||
node_modules:
|
@ -13,7 +13,7 @@
|
||||
"test:watch": "vitest",
|
||||
"lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
|
||||
"lint:fix": "npm run lint -- --fix",
|
||||
"start": "bindings=$(./bindings.sh) && wrangler pages dev ./build/client $bindings",
|
||||
"start": "bindings=$(./bindings.sh) && wrangler pages dev ./build/client $bindings --ip 0.0.0.0 --port 3000",
|
||||
"typecheck": "tsc",
|
||||
"typegen": "wrangler types",
|
||||
"preview": "pnpm run build && pnpm run start"
|
||||
@ -44,6 +44,8 @@
|
||||
"@iconify-json/svg-spinners": "^1.1.2",
|
||||
"@lezer/highlight": "^1.2.0",
|
||||
"@nanostores/react": "^0.7.2",
|
||||
"@octokit/rest": "^21.0.2",
|
||||
"@octokit/types": "^13.6.1",
|
||||
"@openrouter/ai-sdk-provider": "^0.0.5",
|
||||
"@radix-ui/react-dialog": "^1.1.1",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.1",
|
||||
|
136
pnpm-lock.yaml
136
pnpm-lock.yaml
@ -77,6 +77,12 @@ importers:
|
||||
'@nanostores/react':
|
||||
specifier: ^0.7.2
|
||||
version: 0.7.2(nanostores@0.10.3)(react@18.3.1)
|
||||
'@octokit/rest':
|
||||
specifier: ^21.0.2
|
||||
version: 21.0.2
|
||||
'@octokit/types':
|
||||
specifier: ^13.6.1
|
||||
version: 13.6.1
|
||||
'@openrouter/ai-sdk-provider':
|
||||
specifier: ^0.0.5
|
||||
version: 0.0.5(zod@3.23.8)
|
||||
@ -1230,6 +1236,58 @@ packages:
|
||||
resolution: {integrity: sha512-gGq0NJkIGSwdbUt4yhdF8ZrmkGKVz9vAdVzpOfnom+V8PLSmSOVhZwbNvZZS1EYcJN5hzzKBxmmVVAInM6HQLg==}
|
||||
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
|
||||
|
||||
'@octokit/auth-token@5.1.1':
|
||||
resolution: {integrity: sha512-rh3G3wDO8J9wSjfI436JUKzHIxq8NaiL0tVeB2aXmG6p/9859aUOAjA9pmSPNGGZxfwmaJ9ozOJImuNVJdpvbA==}
|
||||
engines: {node: '>= 18'}
|
||||
|
||||
'@octokit/core@6.1.2':
|
||||
resolution: {integrity: sha512-hEb7Ma4cGJGEUNOAVmyfdB/3WirWMg5hDuNFVejGEDFqupeOysLc2sG6HJxY2etBp5YQu5Wtxwi020jS9xlUwg==}
|
||||
engines: {node: '>= 18'}
|
||||
|
||||
'@octokit/endpoint@10.1.1':
|
||||
resolution: {integrity: sha512-JYjh5rMOwXMJyUpj028cu0Gbp7qe/ihxfJMLc8VZBMMqSwLgOxDI1911gV4Enl1QSavAQNJcwmwBF9M0VvLh6Q==}
|
||||
engines: {node: '>= 18'}
|
||||
|
||||
'@octokit/graphql@8.1.1':
|
||||
resolution: {integrity: sha512-ukiRmuHTi6ebQx/HFRCXKbDlOh/7xEV6QUXaE7MJEKGNAncGI/STSbOkl12qVXZrfZdpXctx5O9X1AIaebiDBg==}
|
||||
engines: {node: '>= 18'}
|
||||
|
||||
'@octokit/openapi-types@22.2.0':
|
||||
resolution: {integrity: sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg==}
|
||||
|
||||
'@octokit/plugin-paginate-rest@11.3.5':
|
||||
resolution: {integrity: sha512-cgwIRtKrpwhLoBi0CUNuY83DPGRMaWVjqVI/bGKsLJ4PzyWZNaEmhHroI2xlrVXkk6nFv0IsZpOp+ZWSWUS2AQ==}
|
||||
engines: {node: '>= 18'}
|
||||
peerDependencies:
|
||||
'@octokit/core': '>=6'
|
||||
|
||||
'@octokit/plugin-request-log@5.3.1':
|
||||
resolution: {integrity: sha512-n/lNeCtq+9ofhC15xzmJCNKP2BWTv8Ih2TTy+jatNCCq/gQP/V7rK3fjIfuz0pDWDALO/o/4QY4hyOF6TQQFUw==}
|
||||
engines: {node: '>= 18'}
|
||||
peerDependencies:
|
||||
'@octokit/core': '>=6'
|
||||
|
||||
'@octokit/plugin-rest-endpoint-methods@13.2.6':
|
||||
resolution: {integrity: sha512-wMsdyHMjSfKjGINkdGKki06VEkgdEldIGstIEyGX0wbYHGByOwN/KiM+hAAlUwAtPkP3gvXtVQA9L3ITdV2tVw==}
|
||||
engines: {node: '>= 18'}
|
||||
peerDependencies:
|
||||
'@octokit/core': '>=6'
|
||||
|
||||
'@octokit/request-error@6.1.5':
|
||||
resolution: {integrity: sha512-IlBTfGX8Yn/oFPMwSfvugfncK2EwRLjzbrpifNaMY8o/HTEAFqCA1FZxjD9cWvSKBHgrIhc4CSBIzMxiLsbzFQ==}
|
||||
engines: {node: '>= 18'}
|
||||
|
||||
'@octokit/request@9.1.3':
|
||||
resolution: {integrity: sha512-V+TFhu5fdF3K58rs1pGUJIDH5RZLbZm5BI+MNF+6o/ssFNT4vWlCh/tVpF3NxGtP15HUxTTMUbsG5llAuU2CZA==}
|
||||
engines: {node: '>= 18'}
|
||||
|
||||
'@octokit/rest@21.0.2':
|
||||
resolution: {integrity: sha512-+CiLisCoyWmYicH25y1cDfCrv41kRSvTq6pPWtRroRJzhsCZWZyCqGyI8foJT5LmScADSwRAnr/xo+eewL04wQ==}
|
||||
engines: {node: '>= 18'}
|
||||
|
||||
'@octokit/types@13.6.1':
|
||||
resolution: {integrity: sha512-PHZE9Z+kWXb23Ndik8MKPirBPziOc0D2/3KH1P+6jK5nGWe96kadZuE4jev2/Jq7FvIfTlT2Ltg8Fv2x1v0a5g==}
|
||||
|
||||
'@openrouter/ai-sdk-provider@0.0.5':
|
||||
resolution: {integrity: sha512-AfxXQhISpxQSeUjU/4jo9waM5GRNX6eIkfTFS9l7vHkD1TKDP81Y/dXrE0ttJeN/Kap3tPF3Jwh49me0gWwjSw==}
|
||||
engines: {node: '>=18'}
|
||||
@ -2211,6 +2269,9 @@ packages:
|
||||
resolution: {integrity: sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
before-after-hook@3.0.2:
|
||||
resolution: {integrity: sha512-Nik3Sc0ncrMK4UUdXQmAnRtzmNQTAAXmXIopizwZ1W1t8QmfJj+zL4OA2I7XPTPW5z5TDqv4hRo/JzouDJnX3A==}
|
||||
|
||||
binary-extensions@2.3.0:
|
||||
resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==}
|
||||
engines: {node: '>=8'}
|
||||
@ -4970,9 +5031,6 @@ packages:
|
||||
engines: {node: '>=14.17'}
|
||||
hasBin: true
|
||||
|
||||
ufo@1.5.3:
|
||||
resolution: {integrity: sha512-Y7HYmWaFwPUmkoQCUIAYpKqkOf+SbVj/2fJJZ4RJMCfZp0rTGwRbzQD+HghfnhKOjL9E01okqz+ncJskGYfBNw==}
|
||||
|
||||
ufo@1.5.4:
|
||||
resolution: {integrity: sha512-UsUk3byDzKd04EyoZ7U4DOlxQaD14JUKQl6/P7wiX4FNvUfm3XL246n9W5AmqwW5RSFJ27NAuM0iLscAOYUiGQ==}
|
||||
|
||||
@ -5053,6 +5111,9 @@ packages:
|
||||
unist-util-visit@5.0.0:
|
||||
resolution: {integrity: sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==}
|
||||
|
||||
universal-user-agent@7.0.2:
|
||||
resolution: {integrity: sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q==}
|
||||
|
||||
universalify@2.0.1:
|
||||
resolution: {integrity: sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==}
|
||||
engines: {node: '>= 10.0.0'}
|
||||
@ -6363,6 +6424,67 @@ snapshots:
|
||||
dependencies:
|
||||
which: 3.0.1
|
||||
|
||||
'@octokit/auth-token@5.1.1': {}
|
||||
|
||||
'@octokit/core@6.1.2':
|
||||
dependencies:
|
||||
'@octokit/auth-token': 5.1.1
|
||||
'@octokit/graphql': 8.1.1
|
||||
'@octokit/request': 9.1.3
|
||||
'@octokit/request-error': 6.1.5
|
||||
'@octokit/types': 13.6.1
|
||||
before-after-hook: 3.0.2
|
||||
universal-user-agent: 7.0.2
|
||||
|
||||
'@octokit/endpoint@10.1.1':
|
||||
dependencies:
|
||||
'@octokit/types': 13.6.1
|
||||
universal-user-agent: 7.0.2
|
||||
|
||||
'@octokit/graphql@8.1.1':
|
||||
dependencies:
|
||||
'@octokit/request': 9.1.3
|
||||
'@octokit/types': 13.6.1
|
||||
universal-user-agent: 7.0.2
|
||||
|
||||
'@octokit/openapi-types@22.2.0': {}
|
||||
|
||||
'@octokit/plugin-paginate-rest@11.3.5(@octokit/core@6.1.2)':
|
||||
dependencies:
|
||||
'@octokit/core': 6.1.2
|
||||
'@octokit/types': 13.6.1
|
||||
|
||||
'@octokit/plugin-request-log@5.3.1(@octokit/core@6.1.2)':
|
||||
dependencies:
|
||||
'@octokit/core': 6.1.2
|
||||
|
||||
'@octokit/plugin-rest-endpoint-methods@13.2.6(@octokit/core@6.1.2)':
|
||||
dependencies:
|
||||
'@octokit/core': 6.1.2
|
||||
'@octokit/types': 13.6.1
|
||||
|
||||
'@octokit/request-error@6.1.5':
|
||||
dependencies:
|
||||
'@octokit/types': 13.6.1
|
||||
|
||||
'@octokit/request@9.1.3':
|
||||
dependencies:
|
||||
'@octokit/endpoint': 10.1.1
|
||||
'@octokit/request-error': 6.1.5
|
||||
'@octokit/types': 13.6.1
|
||||
universal-user-agent: 7.0.2
|
||||
|
||||
'@octokit/rest@21.0.2':
|
||||
dependencies:
|
||||
'@octokit/core': 6.1.2
|
||||
'@octokit/plugin-paginate-rest': 11.3.5(@octokit/core@6.1.2)
|
||||
'@octokit/plugin-request-log': 5.3.1(@octokit/core@6.1.2)
|
||||
'@octokit/plugin-rest-endpoint-methods': 13.2.6(@octokit/core@6.1.2)
|
||||
|
||||
'@octokit/types@13.6.1':
|
||||
dependencies:
|
||||
'@octokit/openapi-types': 22.2.0
|
||||
|
||||
'@openrouter/ai-sdk-provider@0.0.5(zod@3.23.8)':
|
||||
dependencies:
|
||||
'@ai-sdk/provider': 0.0.12
|
||||
@ -7530,6 +7652,8 @@ snapshots:
|
||||
safe-buffer: 5.1.2
|
||||
optional: true
|
||||
|
||||
before-after-hook@3.0.2: {}
|
||||
|
||||
binary-extensions@2.3.0: {}
|
||||
|
||||
binaryextensions@6.11.0:
|
||||
@ -9972,7 +10096,7 @@ snapshots:
|
||||
dependencies:
|
||||
destr: 2.0.3
|
||||
node-fetch-native: 1.6.4
|
||||
ufo: 1.5.3
|
||||
ufo: 1.5.4
|
||||
|
||||
ollama-ai-provider@0.15.2(zod@3.23.8):
|
||||
dependencies:
|
||||
@ -11002,8 +11126,6 @@ snapshots:
|
||||
|
||||
typescript@5.5.2: {}
|
||||
|
||||
ufo@1.5.3: {}
|
||||
|
||||
ufo@1.5.4: {}
|
||||
|
||||
unconfig@0.3.13:
|
||||
@ -11122,6 +11244,8 @@ snapshots:
|
||||
unist-util-is: 6.0.0
|
||||
unist-util-visit-parents: 6.0.1
|
||||
|
||||
universal-user-agent@7.0.2: {}
|
||||
|
||||
universalify@2.0.1: {}
|
||||
|
||||
unocss@0.61.3(postcss@8.4.38)(rollup@4.18.0)(vite@5.3.1(@types/node@20.14.9)(sass@1.77.6)):
|
||||
|
Loading…
Reference in New Issue
Block a user