├── types ├── theme.ts ├── artifact.ts ├── terminal.ts └── actions.ts ├── .eslintrc.json ├── app ├── favicon.ico ├── fonts │ ├── GeistVF.woff │ ├── PaytoneOne.ttf │ └── GeistMonoVF.woff ├── chat │ └── [id] │ │ └── page.tsx ├── _document.tsx ├── page.tsx ├── layout.tsx ├── api │ └── chat │ │ └── route.ts ├── background.tsx └── globals.css ├── persistance ├── index.ts ├── ChatDescription.tsx └── useChatHistory.ts ├── public ├── logo.png ├── template.jpg ├── faviconround.ico ├── screenshot.png └── logo-transparent.png ├── utils ├── easings.ts ├── unreachable.ts ├── mobile.ts ├── constants.ts ├── terminal.ts ├── react.ts ├── debounce.ts ├── promises.ts ├── stripIndent.ts ├── buffer.ts ├── stacktrace.ts ├── sampler.ts ├── markdown.ts ├── logger.ts └── diff.ts ├── hooks ├── index.ts ├── use-mobile.tsx ├── useSpeechRecognition.ts ├── useSnapScroll.ts ├── usePromptEnhancer.ts ├── useShortcuts.ts ├── useMessageParser.ts └── use-toast.ts ├── lib ├── stores │ ├── chat.ts │ ├── settings.ts │ ├── theme.ts │ ├── previews.ts │ ├── terminal.ts │ ├── provider.ts │ └── editor.ts ├── utils.ts ├── llm │ ├── constants.ts │ ├── switchable-stream.ts │ └── stream-text.ts └── webcontainer │ ├── auth.client.ts │ └── index.ts ├── postcss.config.mjs ├── components ├── ui │ ├── aspect-ratio.tsx │ ├── skeleton.tsx │ ├── collapsible.tsx │ ├── PanelHeader.tsx │ ├── textarea.tsx │ ├── label.tsx │ ├── input.tsx │ ├── separator.tsx │ ├── progress.tsx │ ├── toaster.tsx │ ├── sonner.tsx │ ├── checkbox.tsx │ ├── slider.tsx │ ├── PanelHeaderButton.tsx │ ├── switch.tsx │ ├── badge.tsx │ ├── hover-card.tsx │ ├── tooltip.tsx │ ├── popover.tsx │ ├── radio-group.tsx │ ├── avatar.tsx │ ├── toggle.tsx │ ├── alert.tsx │ ├── scroll-area.tsx │ ├── resizable.tsx │ ├── toggle-group.tsx │ ├── tabs.tsx │ ├── button.tsx │ ├── OldSlider.tsx │ ├── IconButton.tsx │ ├── card.tsx │ ├── accordion.tsx │ ├── input-otp.tsx │ ├── calendar.tsx │ ├── breadcrumb.tsx │ ├── pagination.tsx │ ├── table.tsx │ ├── drawer.tsx │ ├── OldDialog.tsx │ ├── dialog.tsx │ └── sheet.tsx ├── editor │ └── codemirror │ │ ├── BinaryContent.tsx │ │ ├── indent.ts │ │ └── languages.ts ├── chat │ ├── AssistantMessage.tsx │ ├── ShellCodeBlock.tsx │ ├── SendButton.tsx │ ├── UserMessage.tsx │ ├── ChatIntro.tsx │ ├── Markdown.tsx │ ├── CodeBlock.tsx │ ├── Messages.tsx │ ├── ChatExamples.tsx │ ├── ProviderSelector.tsx │ └── Markdown.module.css ├── sidebar │ ├── nav-secondary.tsx │ ├── date-binning.ts │ ├── nav-projects.tsx │ ├── HistoryItem.tsx │ ├── nav-main.tsx │ └── nav-user.tsx └── workbench │ ├── terminal │ ├── theme.ts │ └── Terminal.tsx │ ├── PortDropdown.tsx │ └── Preview.tsx ├── next.config.mjs ├── components.json ├── .gitignore ├── tsconfig.json ├── tailwind.config.ts └── package.json /types/theme.ts: -------------------------------------------------------------------------------- 1 | export type Theme = 'dark' | 'light'; 2 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["next/core-web-vitals", "next/typescript"] 3 | } 4 | -------------------------------------------------------------------------------- /app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xKevIsDev/nextjs-bolt/HEAD/app/favicon.ico -------------------------------------------------------------------------------- /persistance/index.ts: -------------------------------------------------------------------------------- 1 | export * from './db'; 2 | export * from './useChatHistory'; 3 | -------------------------------------------------------------------------------- /public/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xKevIsDev/nextjs-bolt/HEAD/public/logo.png -------------------------------------------------------------------------------- /public/template.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xKevIsDev/nextjs-bolt/HEAD/public/template.jpg -------------------------------------------------------------------------------- /app/fonts/GeistVF.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xKevIsDev/nextjs-bolt/HEAD/app/fonts/GeistVF.woff -------------------------------------------------------------------------------- /public/faviconround.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xKevIsDev/nextjs-bolt/HEAD/public/faviconround.ico -------------------------------------------------------------------------------- /public/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xKevIsDev/nextjs-bolt/HEAD/public/screenshot.png -------------------------------------------------------------------------------- /app/fonts/PaytoneOne.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xKevIsDev/nextjs-bolt/HEAD/app/fonts/PaytoneOne.ttf -------------------------------------------------------------------------------- /app/fonts/GeistMonoVF.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xKevIsDev/nextjs-bolt/HEAD/app/fonts/GeistMonoVF.woff -------------------------------------------------------------------------------- /public/logo-transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xKevIsDev/nextjs-bolt/HEAD/public/logo-transparent.png -------------------------------------------------------------------------------- /types/artifact.ts: -------------------------------------------------------------------------------- 1 | export interface BoltNextArtifactData { 2 | id: string; 3 | title: string; 4 | type?: string; 5 | } 6 | -------------------------------------------------------------------------------- /utils/easings.ts: -------------------------------------------------------------------------------- 1 | import { cubicBezier } from 'framer-motion'; 2 | 3 | export const cubicEasingFn = cubicBezier(0.4, 0, 0.2, 1); 4 | -------------------------------------------------------------------------------- /utils/unreachable.ts: -------------------------------------------------------------------------------- 1 | export function unreachable(message: string): never { 2 | throw new Error(`Unreachable: ${message}`); 3 | } 4 | -------------------------------------------------------------------------------- /hooks/index.ts: -------------------------------------------------------------------------------- 1 | export * from './useMessageParser'; 2 | export * from './usePromptEnhancer'; 3 | export * from './useShortcuts'; 4 | export * from './useSnapScroll'; 5 | -------------------------------------------------------------------------------- /lib/stores/chat.ts: -------------------------------------------------------------------------------- 1 | import { map } from 'nanostores'; 2 | 3 | export const chatStore = map({ 4 | started: false, 5 | aborted: false, 6 | showChat: true, 7 | }); 8 | -------------------------------------------------------------------------------- /utils/mobile.ts: -------------------------------------------------------------------------------- 1 | export function isMobile() { 2 | // we use sm: as the breakpoint for mobile. It's currently set to 640px 3 | return globalThis.innerWidth < 640; 4 | } 5 | -------------------------------------------------------------------------------- /postcss.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('postcss-load-config').Config} */ 2 | const config = { 3 | plugins: { 4 | tailwindcss: {}, 5 | }, 6 | }; 7 | 8 | export default config; 9 | -------------------------------------------------------------------------------- /utils/constants.ts: -------------------------------------------------------------------------------- 1 | export const WORK_DIR_NAME = 'project'; 2 | export const WORK_DIR = `/home/${WORK_DIR_NAME}`; 3 | export const MODIFICATIONS_TAG_NAME = 'boltnext_file_modifications'; 4 | -------------------------------------------------------------------------------- /lib/utils.ts: -------------------------------------------------------------------------------- 1 | import { clsx, type ClassValue } from "clsx" 2 | import { twMerge } from "tailwind-merge" 3 | 4 | export function cn(...inputs: ClassValue[]) { 5 | return twMerge(clsx(inputs)) 6 | } 7 | -------------------------------------------------------------------------------- /components/ui/aspect-ratio.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | 3 | import * as AspectRatioPrimitive from "@radix-ui/react-aspect-ratio" 4 | 5 | const AspectRatio = AspectRatioPrimitive.Root 6 | 7 | export { AspectRatio } 8 | -------------------------------------------------------------------------------- /app/chat/[id]/page.tsx: -------------------------------------------------------------------------------- 1 | 'use client'; 2 | 3 | import Chat from '@/components/chat/Chat'; 4 | 5 | export default function ChatPage() { 6 | return ( 7 | <> 8 | 9 | 10 | ); 11 | } -------------------------------------------------------------------------------- /persistance/ChatDescription.tsx: -------------------------------------------------------------------------------- 1 | import { useStore } from '@nanostores/react'; 2 | import { description } from './useChatHistory'; 3 | 4 | export function ChatDescription() { 5 | return useStore(description); 6 | } 7 | -------------------------------------------------------------------------------- /lib/llm/constants.ts: -------------------------------------------------------------------------------- 1 | // see https://docs.anthropic.com/en/docs/about-claude/models 2 | export const MAX_TOKENS = 8192; 3 | 4 | // limits the number of model responses that can be returned in a single request 5 | export const MAX_RESPONSE_SEGMENTS = 2; 6 | -------------------------------------------------------------------------------- /lib/webcontainer/auth.client.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This client-only module that contains everything related to auth and is used 3 | * to avoid importing `@webcontainer/api` in the server bundle. 4 | */ 5 | 6 | export { auth, type AuthAPI } from '@webcontainer/api'; 7 | -------------------------------------------------------------------------------- /utils/terminal.ts: -------------------------------------------------------------------------------- 1 | const reset = '\x1b[0m'; 2 | 3 | export const escapeCodes = { 4 | reset, 5 | clear: '\x1b[g', 6 | red: '\x1b[1;31m', 7 | }; 8 | 9 | export const coloredText = { 10 | red: (text: string) => `${escapeCodes.red}${text}${reset}`, 11 | }; 12 | -------------------------------------------------------------------------------- /types/terminal.ts: -------------------------------------------------------------------------------- 1 | export interface ITerminal { 2 | readonly cols?: number; 3 | readonly rows?: number; 4 | 5 | reset: () => void; 6 | write: (data: string) => void; 7 | onData: (cb: (data: string) => void) => void; 8 | input: (data: string) => void; 9 | } 10 | -------------------------------------------------------------------------------- /components/editor/codemirror/BinaryContent.tsx: -------------------------------------------------------------------------------- 1 | export function BinaryContent() { 2 | return ( 3 |
4 | File format cannot be displayed. 5 |
6 | ); 7 | } 8 | -------------------------------------------------------------------------------- /utils/react.ts: -------------------------------------------------------------------------------- 1 | import { memo } from 'react'; 2 | 3 | export const genericMemo: >( 4 | component: T, 5 | propsAreEqual?: (prevProps: React.ComponentProps, nextProps: React.ComponentProps) => boolean, 6 | ) => T & { displayName?: string } = memo; 7 | -------------------------------------------------------------------------------- /components/ui/skeleton.tsx: -------------------------------------------------------------------------------- 1 | import { cn } from "@/lib/utils" 2 | 3 | function Skeleton({ 4 | className, 5 | ...props 6 | }: React.HTMLAttributes) { 7 | return ( 8 |
12 | ) 13 | } 14 | 15 | export { Skeleton } 16 | -------------------------------------------------------------------------------- /components/ui/collapsible.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | 3 | import * as CollapsiblePrimitive from "@radix-ui/react-collapsible" 4 | 5 | const Collapsible = CollapsiblePrimitive.Root 6 | 7 | const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger 8 | 9 | const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent 10 | 11 | export { Collapsible, CollapsibleTrigger, CollapsibleContent } 12 | -------------------------------------------------------------------------------- /components/chat/AssistantMessage.tsx: -------------------------------------------------------------------------------- 1 | import { memo } from 'react'; 2 | import { Markdown } from './Markdown'; 3 | 4 | interface AssistantMessageProps { 5 | content: string; 6 | } 7 | 8 | export const AssistantMessage = memo(({ content }: AssistantMessageProps) => { 9 | return ( 10 |
11 | {content} 12 |
13 | ); 14 | }); 15 | -------------------------------------------------------------------------------- /utils/debounce.ts: -------------------------------------------------------------------------------- 1 | export function debounce(fn: (...args: Args) => void, delay = 100) { 2 | if (delay === 0) { 3 | return fn; 4 | } 5 | 6 | let timer: number | undefined; 7 | 8 | return function (this: U, ...args: Args) { 9 | const context = this; 10 | 11 | clearTimeout(timer); 12 | 13 | timer = window.setTimeout(() => { 14 | fn.apply(context, args); 15 | }, delay); 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /next.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = { 3 | async headers() { 4 | return [ 5 | { 6 | source: '/:path*', 7 | headers: [ 8 | { key: 'Cross-Origin-Embedder-Policy', value: 'require-corp' }, 9 | { key: 'Cross-Origin-Opener-Policy', value: 'same-origin' }, 10 | ], 11 | }, 12 | ]; 13 | }, 14 | }; 15 | 16 | export default nextConfig; 17 | -------------------------------------------------------------------------------- /utils/promises.ts: -------------------------------------------------------------------------------- 1 | export function withResolvers(): PromiseWithResolvers { 2 | if (typeof Promise.withResolvers === 'function') { 3 | return Promise.withResolvers(); 4 | } 5 | 6 | let resolve!: (value: T | PromiseLike) => void; 7 | let reject!: (reason?: any) => void; 8 | 9 | const promise = new Promise((_resolve, _reject) => { 10 | resolve = _resolve; 11 | reject = _reject; 12 | }); 13 | 14 | return { 15 | resolve, 16 | reject, 17 | promise, 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://ui.shadcn.com/schema.json", 3 | "style": "new-york", 4 | "rsc": true, 5 | "tsx": true, 6 | "tailwind": { 7 | "config": "tailwind.config.ts", 8 | "css": "app/globals.css", 9 | "baseColor": "neutral", 10 | "cssVariables": true, 11 | "prefix": "" 12 | }, 13 | "aliases": { 14 | "components": "@/components", 15 | "utils": "@/lib/utils", 16 | "ui": "@/components/ui", 17 | "lib": "@/lib", 18 | "hooks": "@/hooks" 19 | }, 20 | "iconLibrary": "lucide" 21 | } -------------------------------------------------------------------------------- /app/_document.tsx: -------------------------------------------------------------------------------- 1 | import { Html, Head, Main, NextScript } from 'next/document'; 2 | 3 | export default function Document() { 4 | return ( 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | ); 18 | } -------------------------------------------------------------------------------- /components/ui/PanelHeader.tsx: -------------------------------------------------------------------------------- 1 | import { memo } from 'react'; 2 | import { cn } from '@/lib/utils'; 3 | 4 | interface PanelHeaderProps { 5 | className?: string; 6 | children: React.ReactNode; 7 | } 8 | 9 | export const PanelHeader = memo(({ className, children }: PanelHeaderProps) => { 10 | return ( 11 |
17 | {children} 18 |
19 | ); 20 | }); 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | .yarn/install-state.gz 8 | 9 | # testing 10 | /coverage 11 | 12 | # next.js 13 | /.next/ 14 | /out/ 15 | 16 | # production 17 | /build 18 | 19 | # misc 20 | .DS_Store 21 | *.pem 22 | 23 | # debug 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | 28 | # local env files 29 | .env* 30 | !.env.example 31 | 32 | # vercel 33 | .vercel 34 | 35 | # typescript 36 | *.tsbuildinfo 37 | next-env.d.ts 38 | .env 39 | -------------------------------------------------------------------------------- /hooks/use-mobile.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | 3 | const MOBILE_BREAKPOINT = 768 4 | 5 | export function useIsMobile() { 6 | const [isMobile, setIsMobile] = React.useState(undefined) 7 | 8 | React.useEffect(() => { 9 | const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`) 10 | const onChange = () => { 11 | setIsMobile(window.innerWidth < MOBILE_BREAKPOINT) 12 | } 13 | mql.addEventListener("change", onChange) 14 | setIsMobile(window.innerWidth < MOBILE_BREAKPOINT) 15 | return () => mql.removeEventListener("change", onChange) 16 | }, []) 17 | 18 | return !!isMobile 19 | } 20 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["dom", "dom.iterable", "esnext"], 4 | "allowJs": true, 5 | "skipLibCheck": true, 6 | "target": "es2017", 7 | "strict": true, 8 | "noEmit": true, 9 | "esModuleInterop": true, 10 | "module": "esnext", 11 | "moduleResolution": "bundler", 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "jsx": "preserve", 15 | "incremental": true, 16 | "plugins": [ 17 | { 18 | "name": "next" 19 | } 20 | ], 21 | "paths": { 22 | "@/*": ["./*"] 23 | } 24 | }, 25 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], 26 | "exclude": ["node_modules"] 27 | } 28 | -------------------------------------------------------------------------------- /app/page.tsx: -------------------------------------------------------------------------------- 1 | 'use client' 2 | 3 | import { RefCallback, useRef, useState } from 'react' 4 | import { FileSpreadsheet, Layout, FootprintsIcon as Shoe, Code } from 'lucide-react' 5 | import { Message } from 'postcss' 6 | import Chat from '@/components/chat/Chat' 7 | import { SidebarInset, SidebarProvider, SidebarTrigger } from '@/components/ui/sidebar' 8 | import { AppSidebar } from '@/components/sidebar/app-sidebar' 9 | import BeautifulBackground from './background' 10 | import { Button } from '@/components/ui/button' 11 | import { Toaster } from '@/components/ui/toaster' 12 | 13 | export default function Home({}) { 14 | 15 | return ( 16 | <> 17 | 18 | 19 | 20 | ) 21 | } 22 | 23 | -------------------------------------------------------------------------------- /utils/stripIndent.ts: -------------------------------------------------------------------------------- 1 | export function stripIndents(value: string): string; 2 | export function stripIndents(strings: TemplateStringsArray, ...values: any[]): string; 3 | export function stripIndents(arg0: string | TemplateStringsArray, ...values: any[]) { 4 | if (typeof arg0 !== 'string') { 5 | const processedString = arg0.reduce((acc, curr, i) => { 6 | acc += curr + (values[i] ?? ''); 7 | return acc; 8 | }, ''); 9 | 10 | return _stripIndents(processedString); 11 | } 12 | 13 | return _stripIndents(arg0); 14 | } 15 | 16 | function _stripIndents(value: string) { 17 | return value 18 | .split('\n') 19 | .map((line) => line.trim()) 20 | .join('\n') 21 | .trimStart() 22 | .replace(/[\r\n]$/, ''); 23 | } 24 | -------------------------------------------------------------------------------- /components/ui/textarea.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | 3 | import { cn } from "@/lib/utils" 4 | 5 | const Textarea = React.forwardRef< 6 | HTMLTextAreaElement, 7 | React.ComponentProps<"textarea"> 8 | >(({ className, ...props }, ref) => { 9 | return ( 10 |