Dominic Elm
commited on
chore(eslint): enforce consistent import paths (#8)
Browse files- eslint.config.mjs +19 -2
- packages/bolt/app/components/chat/Artifact.tsx +5 -5
- packages/bolt/app/components/chat/BaseChat.tsx +3 -3
- packages/bolt/app/components/chat/Chat.client.tsx +5 -5
- packages/bolt/app/components/chat/CodeBlock.tsx +2 -2
- packages/bolt/app/components/chat/Markdown.tsx +2 -2
- packages/bolt/app/components/chat/Messages.client.tsx +2 -2
- packages/bolt/app/components/editor/codemirror/CodeMirrorEditor.tsx +4 -4
- packages/bolt/app/components/editor/codemirror/cm-theme.ts +1 -1
- packages/bolt/app/components/ui/IconButton.tsx +1 -1
- packages/bolt/app/components/ui/PanelHeaderButton.tsx +1 -1
- packages/bolt/app/components/workbench/EditorPanel.tsx +6 -6
- packages/bolt/app/components/workbench/FileTree.tsx +3 -3
- packages/bolt/app/components/workbench/FileTreePanel.tsx +3 -3
- packages/bolt/app/components/workbench/Preview.tsx +2 -2
- packages/bolt/app/components/workbench/Workbench.client.tsx +5 -5
- packages/bolt/app/lib/.server/llm/prompts.ts +2 -2
- packages/bolt/app/lib/.server/llm/stream-text.ts +2 -2
- packages/bolt/app/lib/hooks/useMessageParser.ts +3 -3
- packages/bolt/app/lib/hooks/usePromptEnhancer.ts +1 -1
- packages/bolt/app/lib/runtime/action-runner.ts +3 -3
- packages/bolt/app/lib/runtime/message-parser.ts +4 -4
- packages/bolt/app/lib/stores/editor.ts +1 -1
- packages/bolt/app/lib/stores/files.ts +3 -3
- packages/bolt/app/lib/stores/workbench.ts +5 -5
- packages/bolt/app/lib/webcontainer/index.ts +1 -1
- packages/bolt/app/routes/_index.tsx +4 -4
- packages/bolt/app/routes/api.chat.ts +4 -4
- packages/bolt/app/routes/api.enhancer.ts +2 -2
- packages/bolt/app/routes/login.tsx +2 -2
- packages/bolt/functions/[[path]].ts +1 -1
eslint.config.mjs
CHANGED
@@ -1,9 +1,10 @@
|
|
1 |
import blitzPlugin from '@blitz/eslint-plugin';
|
2 |
-
import {
|
|
|
3 |
|
4 |
export default [
|
5 |
{
|
6 |
-
ignores: ['**/dist', '**/node_modules'],
|
7 |
},
|
8 |
...blitzPlugin.configs.recommended(),
|
9 |
{
|
@@ -25,4 +26,20 @@ export default [
|
|
25 |
'@typescript-eslint/no-empty-object-type': 'off',
|
26 |
},
|
27 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
];
|
|
|
1 |
import blitzPlugin from '@blitz/eslint-plugin';
|
2 |
+
import { jsFileExtensions } from '@blitz/eslint-plugin/dist/configs/javascript.js';
|
3 |
+
import { getNamingConventionRule, tsFileExtensions } from '@blitz/eslint-plugin/dist/configs/typescript.js';
|
4 |
|
5 |
export default [
|
6 |
{
|
7 |
+
ignores: ['**/dist', '**/node_modules', '**/.wrangler', '**/bolt/build'],
|
8 |
},
|
9 |
...blitzPlugin.configs.recommended(),
|
10 |
{
|
|
|
26 |
'@typescript-eslint/no-empty-object-type': 'off',
|
27 |
},
|
28 |
},
|
29 |
+
{
|
30 |
+
files: [...tsFileExtensions, ...jsFileExtensions, '**/*.tsx'],
|
31 |
+
rules: {
|
32 |
+
'no-restricted-imports': [
|
33 |
+
'error',
|
34 |
+
{
|
35 |
+
patterns: [
|
36 |
+
{
|
37 |
+
group: ['../'],
|
38 |
+
message: `Relative imports are not allowed. Please use '~/' instead.`,
|
39 |
+
},
|
40 |
+
],
|
41 |
+
},
|
42 |
+
],
|
43 |
+
},
|
44 |
+
},
|
45 |
];
|
packages/bolt/app/components/chat/Artifact.tsx
CHANGED
@@ -3,11 +3,11 @@ import { AnimatePresence, motion } from 'framer-motion';
|
|
3 |
import { computed } from 'nanostores';
|
4 |
import { memo, useEffect, useRef, useState } from 'react';
|
5 |
import { createHighlighter, type BundledLanguage, type BundledTheme, type HighlighterGeneric } from 'shiki';
|
6 |
-
import type { ActionState } from '
|
7 |
-
import { chatStore } from '
|
8 |
-
import { workbenchStore } from '
|
9 |
-
import { classNames } from '
|
10 |
-
import { cubicEasingFn } from '
|
11 |
|
12 |
const highlighterOptions = {
|
13 |
langs: ['shell'],
|
|
|
3 |
import { computed } from 'nanostores';
|
4 |
import { memo, useEffect, useRef, useState } from 'react';
|
5 |
import { createHighlighter, type BundledLanguage, type BundledTheme, type HighlighterGeneric } from 'shiki';
|
6 |
+
import type { ActionState } from '~/lib/runtime/action-runner';
|
7 |
+
import { chatStore } from '~/lib/stores/chat';
|
8 |
+
import { workbenchStore } from '~/lib/stores/workbench';
|
9 |
+
import { classNames } from '~/utils/classNames';
|
10 |
+
import { cubicEasingFn } from '~/utils/easings';
|
11 |
|
12 |
const highlighterOptions = {
|
13 |
langs: ['shell'],
|
packages/bolt/app/components/chat/BaseChat.tsx
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
import type { Message } from 'ai';
|
2 |
import React, { type LegacyRef, type RefCallback } from 'react';
|
3 |
import { ClientOnly } from 'remix-utils/client-only';
|
4 |
-
import {
|
5 |
-
import {
|
6 |
-
import {
|
7 |
import { Messages } from './Messages.client';
|
8 |
import { SendButton } from './SendButton.client';
|
9 |
|
|
|
1 |
import type { Message } from 'ai';
|
2 |
import React, { type LegacyRef, type RefCallback } from 'react';
|
3 |
import { ClientOnly } from 'remix-utils/client-only';
|
4 |
+
import { IconButton } from '~/components/ui/IconButton';
|
5 |
+
import { Workbench } from '~/components/workbench/Workbench.client';
|
6 |
+
import { classNames } from '~/utils/classNames';
|
7 |
import { Messages } from './Messages.client';
|
8 |
import { SendButton } from './SendButton.client';
|
9 |
|
packages/bolt/app/components/chat/Chat.client.tsx
CHANGED
@@ -2,11 +2,11 @@ import { useChat } from 'ai/react';
|
|
2 |
import { useAnimate } from 'framer-motion';
|
3 |
import { useEffect, useRef, useState } from 'react';
|
4 |
import { ToastContainer, cssTransition } from 'react-toastify';
|
5 |
-
import { useMessageParser, usePromptEnhancer, useSnapScroll } from '
|
6 |
-
import { chatStore } from '
|
7 |
-
import { workbenchStore } from '
|
8 |
-
import { cubicEasingFn } from '
|
9 |
-
import { createScopedLogger } from '
|
10 |
import { BaseChat } from './BaseChat';
|
11 |
|
12 |
const toastAnimation = cssTransition({
|
|
|
2 |
import { useAnimate } from 'framer-motion';
|
3 |
import { useEffect, useRef, useState } from 'react';
|
4 |
import { ToastContainer, cssTransition } from 'react-toastify';
|
5 |
+
import { useMessageParser, usePromptEnhancer, useSnapScroll } from '~/lib/hooks';
|
6 |
+
import { chatStore } from '~/lib/stores/chat';
|
7 |
+
import { workbenchStore } from '~/lib/stores/workbench';
|
8 |
+
import { cubicEasingFn } from '~/utils/easings';
|
9 |
+
import { createScopedLogger } from '~/utils/logger';
|
10 |
import { BaseChat } from './BaseChat';
|
11 |
|
12 |
const toastAnimation = cssTransition({
|
packages/bolt/app/components/chat/CodeBlock.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import { memo, useEffect, useState } from 'react';
|
2 |
import { bundledLanguages, codeToHtml, isSpecialLang, type BundledLanguage, type SpecialLanguage } from 'shiki';
|
3 |
-
import { classNames } from '
|
4 |
-
import { createScopedLogger } from '
|
5 |
import styles from './CodeBlock.module.scss';
|
6 |
|
7 |
const logger = createScopedLogger('CodeBlock');
|
|
|
1 |
import { memo, useEffect, useState } from 'react';
|
2 |
import { bundledLanguages, codeToHtml, isSpecialLang, type BundledLanguage, type SpecialLanguage } from 'shiki';
|
3 |
+
import { classNames } from '~/utils/classNames';
|
4 |
+
import { createScopedLogger } from '~/utils/logger';
|
5 |
import styles from './CodeBlock.module.scss';
|
6 |
|
7 |
const logger = createScopedLogger('CodeBlock');
|
packages/bolt/app/components/chat/Markdown.tsx
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
import { memo, useMemo } from 'react';
|
2 |
import ReactMarkdown, { type Components } from 'react-markdown';
|
3 |
import type { BundledLanguage } from 'shiki';
|
4 |
-
import { createScopedLogger } from '
|
5 |
-
import { rehypePlugins, remarkPlugins } from '
|
6 |
import { Artifact } from './Artifact';
|
7 |
import { CodeBlock } from './CodeBlock';
|
8 |
|
|
|
1 |
import { memo, useMemo } from 'react';
|
2 |
import ReactMarkdown, { type Components } from 'react-markdown';
|
3 |
import type { BundledLanguage } from 'shiki';
|
4 |
+
import { createScopedLogger } from '~/utils/logger';
|
5 |
+
import { rehypePlugins, remarkPlugins } from '~/utils/markdown';
|
6 |
import { Artifact } from './Artifact';
|
7 |
import { CodeBlock } from './CodeBlock';
|
8 |
|
packages/bolt/app/components/chat/Messages.client.tsx
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
import type { Message } from 'ai';
|
2 |
-
import
|
|
|
3 |
import { AssistantMessage } from './AssistantMessage';
|
4 |
import { UserMessage } from './UserMessage';
|
5 |
-
import React from 'react';
|
6 |
|
7 |
interface MessagesProps {
|
8 |
id?: string;
|
|
|
1 |
import type { Message } from 'ai';
|
2 |
+
import React from 'react';
|
3 |
+
import { classNames } from '~/utils/classNames';
|
4 |
import { AssistantMessage } from './AssistantMessage';
|
5 |
import { UserMessage } from './UserMessage';
|
|
|
6 |
|
7 |
interface MessagesProps {
|
8 |
id?: string;
|
packages/bolt/app/components/editor/codemirror/CodeMirrorEditor.tsx
CHANGED
@@ -14,10 +14,10 @@ import {
|
|
14 |
scrollPastEnd,
|
15 |
} from '@codemirror/view';
|
16 |
import { memo, useEffect, useRef, useState, type MutableRefObject } from 'react';
|
17 |
-
import type { Theme } from '
|
18 |
-
import { classNames } from '
|
19 |
-
import { debounce } from '
|
20 |
-
import { createScopedLogger, renderLogger } from '
|
21 |
import { BinaryContent } from './BinaryContent';
|
22 |
import { getTheme, reconfigureTheme } from './cm-theme';
|
23 |
import { indentKeyBinding } from './indent';
|
|
|
14 |
scrollPastEnd,
|
15 |
} from '@codemirror/view';
|
16 |
import { memo, useEffect, useRef, useState, type MutableRefObject } from 'react';
|
17 |
+
import type { Theme } from '~/types/theme';
|
18 |
+
import { classNames } from '~/utils/classNames';
|
19 |
+
import { debounce } from '~/utils/debounce';
|
20 |
+
import { createScopedLogger, renderLogger } from '~/utils/logger';
|
21 |
import { BinaryContent } from './BinaryContent';
|
22 |
import { getTheme, reconfigureTheme } from './cm-theme';
|
23 |
import { indentKeyBinding } from './indent';
|
packages/bolt/app/components/editor/codemirror/cm-theme.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import { defaultHighlightStyle, syntaxHighlighting } from '@codemirror/language';
|
2 |
import { Compartment, type Extension } from '@codemirror/state';
|
3 |
import { EditorView } from '@codemirror/view';
|
4 |
-
import type { Theme } from '
|
5 |
import type { EditorSettings } from './CodeMirrorEditor.js';
|
6 |
import { vscodeDarkTheme } from './themes/vscode-dark.js';
|
7 |
|
|
|
1 |
import { defaultHighlightStyle, syntaxHighlighting } from '@codemirror/language';
|
2 |
import { Compartment, type Extension } from '@codemirror/state';
|
3 |
import { EditorView } from '@codemirror/view';
|
4 |
+
import type { Theme } from '~/types/theme.js';
|
5 |
import type { EditorSettings } from './CodeMirrorEditor.js';
|
6 |
import { vscodeDarkTheme } from './themes/vscode-dark.js';
|
7 |
|
packages/bolt/app/components/ui/IconButton.tsx
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import { memo } from 'react';
|
2 |
-
import { classNames } from '
|
3 |
|
4 |
type IconSize = 'sm' | 'md' | 'xl' | 'xxl';
|
5 |
|
|
|
1 |
import { memo } from 'react';
|
2 |
+
import { classNames } from '~/utils/classNames';
|
3 |
|
4 |
type IconSize = 'sm' | 'md' | 'xl' | 'xxl';
|
5 |
|
packages/bolt/app/components/ui/PanelHeaderButton.tsx
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import { memo } from 'react';
|
2 |
-
import { classNames } from '
|
3 |
|
4 |
interface PanelHeaderButtonProps {
|
5 |
className?: string;
|
|
|
1 |
import { memo } from 'react';
|
2 |
+
import { classNames } from '~/utils/classNames';
|
3 |
|
4 |
interface PanelHeaderButtonProps {
|
5 |
className?: string;
|
packages/bolt/app/components/workbench/EditorPanel.tsx
CHANGED
@@ -1,10 +1,6 @@
|
|
1 |
import { useStore } from '@nanostores/react';
|
2 |
import { memo, useMemo } from 'react';
|
3 |
import { Panel, PanelGroup, PanelResizeHandle } from 'react-resizable-panels';
|
4 |
-
import type { FileMap } from '../../lib/stores/files';
|
5 |
-
import { themeStore } from '../../lib/stores/theme';
|
6 |
-
import { renderLogger } from '../../utils/logger';
|
7 |
-
import { isMobile } from '../../utils/mobile';
|
8 |
import {
|
9 |
CodeMirrorEditor,
|
10 |
type EditorDocument,
|
@@ -12,8 +8,12 @@ import {
|
|
12 |
type OnChangeCallback as OnEditorChange,
|
13 |
type OnSaveCallback as OnEditorSave,
|
14 |
type OnScrollCallback as OnEditorScroll,
|
15 |
-
} from '
|
16 |
-
import { PanelHeaderButton } from '
|
|
|
|
|
|
|
|
|
17 |
import { FileTreePanel } from './FileTreePanel';
|
18 |
|
19 |
interface EditorPanelProps {
|
|
|
1 |
import { useStore } from '@nanostores/react';
|
2 |
import { memo, useMemo } from 'react';
|
3 |
import { Panel, PanelGroup, PanelResizeHandle } from 'react-resizable-panels';
|
|
|
|
|
|
|
|
|
4 |
import {
|
5 |
CodeMirrorEditor,
|
6 |
type EditorDocument,
|
|
|
8 |
type OnChangeCallback as OnEditorChange,
|
9 |
type OnSaveCallback as OnEditorSave,
|
10 |
type OnScrollCallback as OnEditorScroll,
|
11 |
+
} from '~/components/editor/codemirror/CodeMirrorEditor';
|
12 |
+
import { PanelHeaderButton } from '~/components/ui/PanelHeaderButton';
|
13 |
+
import type { FileMap } from '~/lib/stores/files';
|
14 |
+
import { themeStore } from '~/lib/stores/theme';
|
15 |
+
import { renderLogger } from '~/utils/logger';
|
16 |
+
import { isMobile } from '~/utils/mobile';
|
17 |
import { FileTreePanel } from './FileTreePanel';
|
18 |
|
19 |
interface EditorPanelProps {
|
packages/bolt/app/components/workbench/FileTree.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import { memo, useEffect, useMemo, useState, type ReactNode } from 'react';
|
2 |
-
import type { FileMap } from '
|
3 |
-
import { classNames } from '
|
4 |
-
import { renderLogger } from '
|
5 |
|
6 |
const NODE_PADDING_LEFT = 12;
|
7 |
const DEFAULT_HIDDEN_FILES = [/\/node_modules\//];
|
|
|
1 |
import { memo, useEffect, useMemo, useState, type ReactNode } from 'react';
|
2 |
+
import type { FileMap } from '~/lib/stores/files';
|
3 |
+
import { classNames } from '~/utils/classNames';
|
4 |
+
import { renderLogger } from '~/utils/logger';
|
5 |
|
6 |
const NODE_PADDING_LEFT = 12;
|
7 |
const DEFAULT_HIDDEN_FILES = [/\/node_modules\//];
|
packages/bolt/app/components/workbench/FileTreePanel.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import { memo } from 'react';
|
2 |
-
import type { FileMap } from '
|
3 |
-
import { WORK_DIR } from '
|
4 |
-
import { renderLogger } from '
|
5 |
import { FileTree } from './FileTree';
|
6 |
|
7 |
interface FileTreePanelProps {
|
|
|
1 |
import { memo } from 'react';
|
2 |
+
import type { FileMap } from '~/lib/stores/files';
|
3 |
+
import { WORK_DIR } from '~/utils/constants';
|
4 |
+
import { renderLogger } from '~/utils/logger';
|
5 |
import { FileTree } from './FileTree';
|
6 |
|
7 |
interface FileTreePanelProps {
|
packages/bolt/app/components/workbench/Preview.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import { useStore } from '@nanostores/react';
|
2 |
import { memo, useEffect, useRef, useState } from 'react';
|
3 |
-
import {
|
4 |
-
import {
|
5 |
|
6 |
export const Preview = memo(() => {
|
7 |
const iframeRef = useRef<HTMLIFrameElement>(null);
|
|
|
1 |
import { useStore } from '@nanostores/react';
|
2 |
import { memo, useEffect, useRef, useState } from 'react';
|
3 |
+
import { IconButton } from '~/components/ui/IconButton';
|
4 |
+
import { workbenchStore } from '~/lib/stores/workbench';
|
5 |
|
6 |
export const Preview = memo(() => {
|
7 |
const iframeRef = useRef<HTMLIFrameElement>(null);
|
packages/bolt/app/components/workbench/Workbench.client.tsx
CHANGED
@@ -3,14 +3,14 @@ import { AnimatePresence, motion, type Variants } from 'framer-motion';
|
|
3 |
import { memo, useCallback, useEffect } from 'react';
|
4 |
import { Panel, PanelGroup, PanelResizeHandle } from 'react-resizable-panels';
|
5 |
import { toast } from 'react-toastify';
|
6 |
-
import { workbenchStore } from '../../lib/stores/workbench';
|
7 |
-
import { cubicEasingFn } from '../../utils/easings';
|
8 |
-
import { renderLogger } from '../../utils/logger';
|
9 |
import {
|
10 |
type OnChangeCallback as OnEditorChange,
|
11 |
type OnScrollCallback as OnEditorScroll,
|
12 |
-
} from '
|
13 |
-
import { IconButton } from '
|
|
|
|
|
|
|
14 |
import { EditorPanel } from './EditorPanel';
|
15 |
import { Preview } from './Preview';
|
16 |
|
|
|
3 |
import { memo, useCallback, useEffect } from 'react';
|
4 |
import { Panel, PanelGroup, PanelResizeHandle } from 'react-resizable-panels';
|
5 |
import { toast } from 'react-toastify';
|
|
|
|
|
|
|
6 |
import {
|
7 |
type OnChangeCallback as OnEditorChange,
|
8 |
type OnScrollCallback as OnEditorScroll,
|
9 |
+
} from '~/components/editor/codemirror/CodeMirrorEditor';
|
10 |
+
import { IconButton } from '~/components/ui/IconButton';
|
11 |
+
import { workbenchStore } from '~/lib/stores/workbench';
|
12 |
+
import { cubicEasingFn } from '~/utils/easings';
|
13 |
+
import { renderLogger } from '~/utils/logger';
|
14 |
import { EditorPanel } from './EditorPanel';
|
15 |
import { Preview } from './Preview';
|
16 |
|
packages/bolt/app/lib/.server/llm/prompts.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
import { WORK_DIR } from '
|
2 |
-
import { stripIndents } from '
|
3 |
|
4 |
export const getSystemPrompt = (cwd: string = WORK_DIR) => `
|
5 |
You are Bolt, an expert AI assistant and exceptional senior software developer with vast knowledge across multiple programming languages, frameworks, and best practices.
|
|
|
1 |
+
import { WORK_DIR } from '~/utils/constants';
|
2 |
+
import { stripIndents } from '~/utils/stripIndent';
|
3 |
|
4 |
export const getSystemPrompt = (cwd: string = WORK_DIR) => `
|
5 |
You are Bolt, an expert AI assistant and exceptional senior software developer with vast knowledge across multiple programming languages, frameworks, and best practices.
|
packages/bolt/app/lib/.server/llm/stream-text.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import { streamText as _streamText, convertToCoreMessages } from 'ai';
|
2 |
-
import { getAPIKey } from '
|
3 |
-
import { getAnthropicModel } from '
|
4 |
import { MAX_TOKENS } from './constants';
|
5 |
import { getSystemPrompt } from './prompts';
|
6 |
|
|
|
1 |
import { streamText as _streamText, convertToCoreMessages } from 'ai';
|
2 |
+
import { getAPIKey } from '~/lib/.server/llm/api-key';
|
3 |
+
import { getAnthropicModel } from '~/lib/.server/llm/model';
|
4 |
import { MAX_TOKENS } from './constants';
|
5 |
import { getSystemPrompt } from './prompts';
|
6 |
|
packages/bolt/app/lib/hooks/useMessageParser.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
import type { Message } from 'ai';
|
2 |
import { useCallback, useState } from 'react';
|
3 |
-
import {
|
4 |
-
import {
|
5 |
-
import {
|
6 |
|
7 |
const logger = createScopedLogger('useMessageParser');
|
8 |
|
|
|
1 |
import type { Message } from 'ai';
|
2 |
import { useCallback, useState } from 'react';
|
3 |
+
import { StreamingMessageParser } from '~/lib/runtime/message-parser';
|
4 |
+
import { workbenchStore } from '~/lib/stores/workbench';
|
5 |
+
import { createScopedLogger } from '~/utils/logger';
|
6 |
|
7 |
const logger = createScopedLogger('useMessageParser');
|
8 |
|
packages/bolt/app/lib/hooks/usePromptEnhancer.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import { useState } from 'react';
|
2 |
-
import { createScopedLogger } from '
|
3 |
|
4 |
const logger = createScopedLogger('usePromptEnhancement');
|
5 |
|
|
|
1 |
import { useState } from 'react';
|
2 |
+
import { createScopedLogger } from '~/utils/logger';
|
3 |
|
4 |
const logger = createScopedLogger('usePromptEnhancement');
|
5 |
|
packages/bolt/app/lib/runtime/action-runner.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
import { WebContainer } from '@webcontainer/api';
|
2 |
import { map, type MapStore } from 'nanostores';
|
3 |
import * as nodePath from 'node:path';
|
4 |
-
import type { BoltAction } from '
|
5 |
-
import { createScopedLogger } from '
|
6 |
-
import { unreachable } from '
|
7 |
import type { ActionCallbackData } from './message-parser';
|
8 |
|
9 |
const logger = createScopedLogger('ActionRunner');
|
|
|
1 |
import { WebContainer } from '@webcontainer/api';
|
2 |
import { map, type MapStore } from 'nanostores';
|
3 |
import * as nodePath from 'node:path';
|
4 |
+
import type { BoltAction } from '~/types/actions';
|
5 |
+
import { createScopedLogger } from '~/utils/logger';
|
6 |
+
import { unreachable } from '~/utils/unreachable';
|
7 |
import type { ActionCallbackData } from './message-parser';
|
8 |
|
9 |
const logger = createScopedLogger('ActionRunner');
|
packages/bolt/app/lib/runtime/message-parser.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
import type { ActionType, BoltAction, BoltActionData, FileAction, ShellAction } from '
|
2 |
-
import type { BoltArtifactData } from '
|
3 |
-
import { createScopedLogger } from '
|
4 |
-
import { unreachable } from '
|
5 |
|
6 |
const ARTIFACT_TAG_OPEN = '<boltArtifact';
|
7 |
const ARTIFACT_TAG_CLOSE = '</boltArtifact>';
|
|
|
1 |
+
import type { ActionType, BoltAction, BoltActionData, FileAction, ShellAction } from '~/types/actions';
|
2 |
+
import type { BoltArtifactData } from '~/types/artifact';
|
3 |
+
import { createScopedLogger } from '~/utils/logger';
|
4 |
+
import { unreachable } from '~/utils/unreachable';
|
5 |
|
6 |
const ARTIFACT_TAG_OPEN = '<boltArtifact';
|
7 |
const ARTIFACT_TAG_CLOSE = '</boltArtifact>';
|
packages/bolt/app/lib/stores/editor.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import { atom, computed, map, type MapStore, type WritableAtom } from 'nanostores';
|
2 |
-
import type { EditorDocument, ScrollPosition } from '
|
3 |
import type { FileMap, FilesStore } from './files';
|
4 |
|
5 |
export type EditorDocuments = Record<string, EditorDocument>;
|
|
|
1 |
import { atom, computed, map, type MapStore, type WritableAtom } from 'nanostores';
|
2 |
+
import type { EditorDocument, ScrollPosition } from '~/components/editor/codemirror/CodeMirrorEditor';
|
3 |
import type { FileMap, FilesStore } from './files';
|
4 |
|
5 |
export type EditorDocuments = Record<string, EditorDocument>;
|
packages/bolt/app/lib/stores/files.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
import type { PathWatcherEvent, WebContainer } from '@webcontainer/api';
|
2 |
import { map, type MapStore } from 'nanostores';
|
3 |
import * as nodePath from 'node:path';
|
4 |
-
import { bufferWatchEvents } from '
|
5 |
-
import { WORK_DIR } from '
|
6 |
-
import { createScopedLogger } from '
|
7 |
|
8 |
const logger = createScopedLogger('FilesStore');
|
9 |
|
|
|
1 |
import type { PathWatcherEvent, WebContainer } from '@webcontainer/api';
|
2 |
import { map, type MapStore } from 'nanostores';
|
3 |
import * as nodePath from 'node:path';
|
4 |
+
import { bufferWatchEvents } from '~/utils/buffer';
|
5 |
+
import { WORK_DIR } from '~/utils/constants';
|
6 |
+
import { createScopedLogger } from '~/utils/logger';
|
7 |
|
8 |
const logger = createScopedLogger('FilesStore');
|
9 |
|
packages/bolt/app/lib/stores/workbench.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
import { atom, map, type MapStore, type ReadableAtom, type WritableAtom } from 'nanostores';
|
2 |
-
import type { EditorDocument, ScrollPosition } from '
|
3 |
-
import {
|
4 |
-
import {
|
5 |
-
import
|
6 |
-
import {
|
7 |
import { EditorStore } from './editor';
|
8 |
import { FilesStore, type FileMap } from './files';
|
9 |
import { PreviewsStore } from './previews';
|
|
|
1 |
import { atom, map, type MapStore, type ReadableAtom, type WritableAtom } from 'nanostores';
|
2 |
+
import type { EditorDocument, ScrollPosition } from '~/components/editor/codemirror/CodeMirrorEditor';
|
3 |
+
import { ActionRunner } from '~/lib/runtime/action-runner';
|
4 |
+
import type { ActionCallbackData, ArtifactCallbackData } from '~/lib/runtime/message-parser';
|
5 |
+
import { webcontainer } from '~/lib/webcontainer';
|
6 |
+
import { unreachable } from '~/utils/unreachable';
|
7 |
import { EditorStore } from './editor';
|
8 |
import { FilesStore, type FileMap } from './files';
|
9 |
import { PreviewsStore } from './previews';
|
packages/bolt/app/lib/webcontainer/index.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import { WebContainer } from '@webcontainer/api';
|
2 |
-
import { WORK_DIR_NAME } from '
|
3 |
|
4 |
interface WebContainerContext {
|
5 |
loaded: boolean;
|
|
|
1 |
import { WebContainer } from '@webcontainer/api';
|
2 |
+
import { WORK_DIR_NAME } from '~/utils/constants';
|
3 |
|
4 |
interface WebContainerContext {
|
5 |
loaded: boolean;
|
packages/bolt/app/routes/_index.tsx
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
import { json, redirect, type LoaderFunctionArgs, type MetaFunction } from '@remix-run/cloudflare';
|
2 |
import { ClientOnly } from 'remix-utils/client-only';
|
3 |
-
import { BaseChat } from '
|
4 |
-
import { Chat } from '
|
5 |
-
import { Header } from '
|
6 |
-
import { isAuthenticated } from '
|
7 |
|
8 |
export const meta: MetaFunction = () => {
|
9 |
return [{ title: 'Bolt' }, { name: 'description', content: 'Talk with Bolt, an AI assistant from StackBlitz' }];
|
|
|
1 |
import { json, redirect, type LoaderFunctionArgs, type MetaFunction } from '@remix-run/cloudflare';
|
2 |
import { ClientOnly } from 'remix-utils/client-only';
|
3 |
+
import { BaseChat } from '~/components/chat/BaseChat';
|
4 |
+
import { Chat } from '~/components/chat/Chat.client';
|
5 |
+
import { Header } from '~/components/Header';
|
6 |
+
import { isAuthenticated } from '~/lib/.server/sessions';
|
7 |
|
8 |
export const meta: MetaFunction = () => {
|
9 |
return [{ title: 'Bolt' }, { name: 'description', content: 'Talk with Bolt, an AI assistant from StackBlitz' }];
|
packages/bolt/app/routes/api.chat.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
import { type ActionFunctionArgs } from '@remix-run/cloudflare';
|
2 |
import { StreamingTextResponse } from 'ai';
|
3 |
-
import { MAX_RESPONSE_SEGMENTS, MAX_TOKENS } from '
|
4 |
-
import { CONTINUE_PROMPT } from '
|
5 |
-
import { streamText, type Messages, type StreamingOptions } from '
|
6 |
-
import SwitchableStream from '
|
7 |
|
8 |
export async function action({ context, request }: ActionFunctionArgs) {
|
9 |
const { messages } = await request.json<{ messages: Messages }>();
|
|
|
1 |
import { type ActionFunctionArgs } from '@remix-run/cloudflare';
|
2 |
import { StreamingTextResponse } from 'ai';
|
3 |
+
import { MAX_RESPONSE_SEGMENTS, MAX_TOKENS } from '~/lib/.server/llm/constants';
|
4 |
+
import { CONTINUE_PROMPT } from '~/lib/.server/llm/prompts';
|
5 |
+
import { streamText, type Messages, type StreamingOptions } from '~/lib/.server/llm/stream-text';
|
6 |
+
import SwitchableStream from '~/lib/.server/llm/switchable-stream';
|
7 |
|
8 |
export async function action({ context, request }: ActionFunctionArgs) {
|
9 |
const { messages } = await request.json<{ messages: Messages }>();
|
packages/bolt/app/routes/api.enhancer.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import { type ActionFunctionArgs } from '@remix-run/cloudflare';
|
2 |
import { StreamingTextResponse, parseStreamPart } from 'ai';
|
3 |
-
import { streamText } from '
|
4 |
-
import { stripIndents } from '
|
5 |
|
6 |
const encoder = new TextEncoder();
|
7 |
const decoder = new TextDecoder();
|
|
|
1 |
import { type ActionFunctionArgs } from '@remix-run/cloudflare';
|
2 |
import { StreamingTextResponse, parseStreamPart } from 'ai';
|
3 |
+
import { streamText } from '~/lib/.server/llm/stream-text';
|
4 |
+
import { stripIndents } from '~/utils/stripIndent';
|
5 |
|
6 |
const encoder = new TextEncoder();
|
7 |
const decoder = new TextDecoder();
|
packages/bolt/app/routes/login.tsx
CHANGED
@@ -6,8 +6,8 @@ import {
|
|
6 |
type TypedResponse,
|
7 |
} from '@remix-run/cloudflare';
|
8 |
import { Form, useActionData } from '@remix-run/react';
|
9 |
-
import { verifyPassword } from '
|
10 |
-
import { createUserSession, isAuthenticated } from '
|
11 |
|
12 |
interface Errors {
|
13 |
password?: string;
|
|
|
6 |
type TypedResponse,
|
7 |
} from '@remix-run/cloudflare';
|
8 |
import { Form, useActionData } from '@remix-run/react';
|
9 |
+
import { verifyPassword } from '~/lib/.server/login';
|
10 |
+
import { createUserSession, isAuthenticated } from '~/lib/.server/sessions';
|
11 |
|
12 |
interface Errors {
|
13 |
password?: string;
|
packages/bolt/functions/[[path]].ts
CHANGED
@@ -2,7 +2,7 @@ import type { ServerBuild } from '@remix-run/cloudflare';
|
|
2 |
import { createPagesFunctionHandler } from '@remix-run/cloudflare-pages';
|
3 |
|
4 |
// @ts-ignore because the server build file is generated by `remix vite:build`
|
5 |
-
import * as serverBuild from '
|
6 |
|
7 |
export const onRequest = createPagesFunctionHandler({
|
8 |
build: serverBuild as unknown as ServerBuild,
|
|
|
2 |
import { createPagesFunctionHandler } from '@remix-run/cloudflare-pages';
|
3 |
|
4 |
// @ts-ignore because the server build file is generated by `remix vite:build`
|
5 |
+
import * as serverBuild from '~/build/server';
|
6 |
|
7 |
export const onRequest = createPagesFunctionHandler({
|
8 |
build: serverBuild as unknown as ServerBuild,
|