From 2a3d5f569ed231aac71554d73256e10bd34eb1f3 Mon Sep 17 00:00:00 2001 From: Dominic Elm Date: Wed, 24 Jul 2024 17:43:32 +0200 Subject: [PATCH] chore(eslint): enforce consistent import paths (#8) --- eslint.config.mjs | 21 +++++++++++++++++-- .../bolt/app/components/chat/Artifact.tsx | 10 ++++----- .../bolt/app/components/chat/BaseChat.tsx | 6 +++--- .../bolt/app/components/chat/Chat.client.tsx | 10 ++++----- .../bolt/app/components/chat/CodeBlock.tsx | 4 ++-- .../bolt/app/components/chat/Markdown.tsx | 4 ++-- .../app/components/chat/Messages.client.tsx | 4 ++-- .../editor/codemirror/CodeMirrorEditor.tsx | 8 +++---- .../components/editor/codemirror/cm-theme.ts | 2 +- .../bolt/app/components/ui/IconButton.tsx | 2 +- .../app/components/ui/PanelHeaderButton.tsx | 2 +- .../app/components/workbench/EditorPanel.tsx | 12 +++++------ .../app/components/workbench/FileTree.tsx | 6 +++--- .../components/workbench/FileTreePanel.tsx | 6 +++--- .../bolt/app/components/workbench/Preview.tsx | 4 ++-- .../components/workbench/Workbench.client.tsx | 10 ++++----- packages/bolt/app/lib/.server/llm/prompts.ts | 4 ++-- .../bolt/app/lib/.server/llm/stream-text.ts | 4 ++-- .../bolt/app/lib/hooks/useMessageParser.ts | 6 +++--- .../bolt/app/lib/hooks/usePromptEnhancer.ts | 2 +- .../bolt/app/lib/runtime/action-runner.ts | 6 +++--- .../bolt/app/lib/runtime/message-parser.ts | 8 +++---- packages/bolt/app/lib/stores/editor.ts | 2 +- packages/bolt/app/lib/stores/files.ts | 6 +++--- packages/bolt/app/lib/stores/workbench.ts | 10 ++++----- packages/bolt/app/lib/webcontainer/index.ts | 2 +- packages/bolt/app/routes/_index.tsx | 8 +++---- packages/bolt/app/routes/api.chat.ts | 8 +++---- packages/bolt/app/routes/api.enhancer.ts | 4 ++-- packages/bolt/app/routes/login.tsx | 4 ++-- packages/bolt/functions/[[path]].ts | 2 +- 31 files changed, 102 insertions(+), 85 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 8e27ad6..31649e8 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,9 +1,10 @@ import blitzPlugin from '@blitz/eslint-plugin'; -import { getNamingConventionRule } from '@blitz/eslint-plugin/dist/configs/typescript.js'; +import { jsFileExtensions } from '@blitz/eslint-plugin/dist/configs/javascript.js'; +import { getNamingConventionRule, tsFileExtensions } from '@blitz/eslint-plugin/dist/configs/typescript.js'; export default [ { - ignores: ['**/dist', '**/node_modules'], + ignores: ['**/dist', '**/node_modules', '**/.wrangler', '**/bolt/build'], }, ...blitzPlugin.configs.recommended(), { @@ -25,4 +26,20 @@ export default [ '@typescript-eslint/no-empty-object-type': 'off', }, }, + { + files: [...tsFileExtensions, ...jsFileExtensions, '**/*.tsx'], + rules: { + 'no-restricted-imports': [ + 'error', + { + patterns: [ + { + group: ['../'], + message: `Relative imports are not allowed. Please use '~/' instead.`, + }, + ], + }, + ], + }, + }, ]; diff --git a/packages/bolt/app/components/chat/Artifact.tsx b/packages/bolt/app/components/chat/Artifact.tsx index a321372..c7fda83 100644 --- a/packages/bolt/app/components/chat/Artifact.tsx +++ b/packages/bolt/app/components/chat/Artifact.tsx @@ -3,11 +3,11 @@ import { AnimatePresence, motion } from 'framer-motion'; import { computed } from 'nanostores'; import { memo, useEffect, useRef, useState } from 'react'; import { createHighlighter, type BundledLanguage, type BundledTheme, type HighlighterGeneric } from 'shiki'; -import type { ActionState } from '../../lib/runtime/action-runner'; -import { chatStore } from '../../lib/stores/chat'; -import { workbenchStore } from '../../lib/stores/workbench'; -import { classNames } from '../../utils/classNames'; -import { cubicEasingFn } from '../../utils/easings'; +import type { ActionState } from '~/lib/runtime/action-runner'; +import { chatStore } from '~/lib/stores/chat'; +import { workbenchStore } from '~/lib/stores/workbench'; +import { classNames } from '~/utils/classNames'; +import { cubicEasingFn } from '~/utils/easings'; const highlighterOptions = { langs: ['shell'], diff --git a/packages/bolt/app/components/chat/BaseChat.tsx b/packages/bolt/app/components/chat/BaseChat.tsx index ada6235..a1f39f7 100644 --- a/packages/bolt/app/components/chat/BaseChat.tsx +++ b/packages/bolt/app/components/chat/BaseChat.tsx @@ -1,9 +1,9 @@ import type { Message } from 'ai'; import React, { type LegacyRef, type RefCallback } from 'react'; import { ClientOnly } from 'remix-utils/client-only'; -import { classNames } from '../../utils/classNames'; -import { IconButton } from '../ui/IconButton'; -import { Workbench } from '../workbench/Workbench.client'; +import { IconButton } from '~/components/ui/IconButton'; +import { Workbench } from '~/components/workbench/Workbench.client'; +import { classNames } from '~/utils/classNames'; import { Messages } from './Messages.client'; import { SendButton } from './SendButton.client'; diff --git a/packages/bolt/app/components/chat/Chat.client.tsx b/packages/bolt/app/components/chat/Chat.client.tsx index 161e3e2..47518bd 100644 --- a/packages/bolt/app/components/chat/Chat.client.tsx +++ b/packages/bolt/app/components/chat/Chat.client.tsx @@ -2,11 +2,11 @@ import { useChat } from 'ai/react'; import { useAnimate } from 'framer-motion'; import { useEffect, useRef, useState } from 'react'; import { ToastContainer, cssTransition } from 'react-toastify'; -import { useMessageParser, usePromptEnhancer, useSnapScroll } from '../../lib/hooks'; -import { chatStore } from '../../lib/stores/chat'; -import { workbenchStore } from '../../lib/stores/workbench'; -import { cubicEasingFn } from '../../utils/easings'; -import { createScopedLogger } from '../../utils/logger'; +import { useMessageParser, usePromptEnhancer, useSnapScroll } from '~/lib/hooks'; +import { chatStore } from '~/lib/stores/chat'; +import { workbenchStore } from '~/lib/stores/workbench'; +import { cubicEasingFn } from '~/utils/easings'; +import { createScopedLogger } from '~/utils/logger'; import { BaseChat } from './BaseChat'; const toastAnimation = cssTransition({ diff --git a/packages/bolt/app/components/chat/CodeBlock.tsx b/packages/bolt/app/components/chat/CodeBlock.tsx index 30997da..97be9a6 100644 --- a/packages/bolt/app/components/chat/CodeBlock.tsx +++ b/packages/bolt/app/components/chat/CodeBlock.tsx @@ -1,7 +1,7 @@ import { memo, useEffect, useState } from 'react'; import { bundledLanguages, codeToHtml, isSpecialLang, type BundledLanguage, type SpecialLanguage } from 'shiki'; -import { classNames } from '../../utils/classNames'; -import { createScopedLogger } from '../../utils/logger'; +import { classNames } from '~/utils/classNames'; +import { createScopedLogger } from '~/utils/logger'; import styles from './CodeBlock.module.scss'; const logger = createScopedLogger('CodeBlock'); diff --git a/packages/bolt/app/components/chat/Markdown.tsx b/packages/bolt/app/components/chat/Markdown.tsx index 609e070..4a966e7 100644 --- a/packages/bolt/app/components/chat/Markdown.tsx +++ b/packages/bolt/app/components/chat/Markdown.tsx @@ -1,8 +1,8 @@ import { memo, useMemo } from 'react'; import ReactMarkdown, { type Components } from 'react-markdown'; import type { BundledLanguage } from 'shiki'; -import { createScopedLogger } from '../../utils/logger'; -import { rehypePlugins, remarkPlugins } from '../../utils/markdown'; +import { createScopedLogger } from '~/utils/logger'; +import { rehypePlugins, remarkPlugins } from '~/utils/markdown'; import { Artifact } from './Artifact'; import { CodeBlock } from './CodeBlock'; diff --git a/packages/bolt/app/components/chat/Messages.client.tsx b/packages/bolt/app/components/chat/Messages.client.tsx index 3783ea1..ee3671a 100644 --- a/packages/bolt/app/components/chat/Messages.client.tsx +++ b/packages/bolt/app/components/chat/Messages.client.tsx @@ -1,8 +1,8 @@ import type { Message } from 'ai'; -import { classNames } from '../../utils/classNames'; +import React from 'react'; +import { classNames } from '~/utils/classNames'; import { AssistantMessage } from './AssistantMessage'; import { UserMessage } from './UserMessage'; -import React from 'react'; interface MessagesProps { id?: string; diff --git a/packages/bolt/app/components/editor/codemirror/CodeMirrorEditor.tsx b/packages/bolt/app/components/editor/codemirror/CodeMirrorEditor.tsx index 5b58bf2..ff07219 100644 --- a/packages/bolt/app/components/editor/codemirror/CodeMirrorEditor.tsx +++ b/packages/bolt/app/components/editor/codemirror/CodeMirrorEditor.tsx @@ -14,10 +14,10 @@ import { scrollPastEnd, } from '@codemirror/view'; import { memo, useEffect, useRef, useState, type MutableRefObject } from 'react'; -import type { Theme } from '../../../types/theme'; -import { classNames } from '../../../utils/classNames'; -import { debounce } from '../../../utils/debounce'; -import { createScopedLogger, renderLogger } from '../../../utils/logger'; +import type { Theme } from '~/types/theme'; +import { classNames } from '~/utils/classNames'; +import { debounce } from '~/utils/debounce'; +import { createScopedLogger, renderLogger } from '~/utils/logger'; import { BinaryContent } from './BinaryContent'; import { getTheme, reconfigureTheme } from './cm-theme'; import { indentKeyBinding } from './indent'; diff --git a/packages/bolt/app/components/editor/codemirror/cm-theme.ts b/packages/bolt/app/components/editor/codemirror/cm-theme.ts index 5d097c0..5a3d994 100644 --- a/packages/bolt/app/components/editor/codemirror/cm-theme.ts +++ b/packages/bolt/app/components/editor/codemirror/cm-theme.ts @@ -1,7 +1,7 @@ import { defaultHighlightStyle, syntaxHighlighting } from '@codemirror/language'; import { Compartment, type Extension } from '@codemirror/state'; import { EditorView } from '@codemirror/view'; -import type { Theme } from '../../../types/theme.js'; +import type { Theme } from '~/types/theme.js'; import type { EditorSettings } from './CodeMirrorEditor.js'; import { vscodeDarkTheme } from './themes/vscode-dark.js'; diff --git a/packages/bolt/app/components/ui/IconButton.tsx b/packages/bolt/app/components/ui/IconButton.tsx index e7a036f..085d9cd 100644 --- a/packages/bolt/app/components/ui/IconButton.tsx +++ b/packages/bolt/app/components/ui/IconButton.tsx @@ -1,5 +1,5 @@ import { memo } from 'react'; -import { classNames } from '../../utils/classNames'; +import { classNames } from '~/utils/classNames'; type IconSize = 'sm' | 'md' | 'xl' | 'xxl'; diff --git a/packages/bolt/app/components/ui/PanelHeaderButton.tsx b/packages/bolt/app/components/ui/PanelHeaderButton.tsx index bd0ba76..df25414 100644 --- a/packages/bolt/app/components/ui/PanelHeaderButton.tsx +++ b/packages/bolt/app/components/ui/PanelHeaderButton.tsx @@ -1,5 +1,5 @@ import { memo } from 'react'; -import { classNames } from '../../utils/classNames'; +import { classNames } from '~/utils/classNames'; interface PanelHeaderButtonProps { className?: string; diff --git a/packages/bolt/app/components/workbench/EditorPanel.tsx b/packages/bolt/app/components/workbench/EditorPanel.tsx index dc4c570..6d4459a 100644 --- a/packages/bolt/app/components/workbench/EditorPanel.tsx +++ b/packages/bolt/app/components/workbench/EditorPanel.tsx @@ -1,10 +1,6 @@ import { useStore } from '@nanostores/react'; import { memo, useMemo } from 'react'; import { Panel, PanelGroup, PanelResizeHandle } from 'react-resizable-panels'; -import type { FileMap } from '../../lib/stores/files'; -import { themeStore } from '../../lib/stores/theme'; -import { renderLogger } from '../../utils/logger'; -import { isMobile } from '../../utils/mobile'; import { CodeMirrorEditor, type EditorDocument, @@ -12,8 +8,12 @@ import { type OnChangeCallback as OnEditorChange, type OnSaveCallback as OnEditorSave, type OnScrollCallback as OnEditorScroll, -} from '../editor/codemirror/CodeMirrorEditor'; -import { PanelHeaderButton } from '../ui/PanelHeaderButton'; +} from '~/components/editor/codemirror/CodeMirrorEditor'; +import { PanelHeaderButton } from '~/components/ui/PanelHeaderButton'; +import type { FileMap } from '~/lib/stores/files'; +import { themeStore } from '~/lib/stores/theme'; +import { renderLogger } from '~/utils/logger'; +import { isMobile } from '~/utils/mobile'; import { FileTreePanel } from './FileTreePanel'; interface EditorPanelProps { diff --git a/packages/bolt/app/components/workbench/FileTree.tsx b/packages/bolt/app/components/workbench/FileTree.tsx index 90bbdde..7d7d237 100644 --- a/packages/bolt/app/components/workbench/FileTree.tsx +++ b/packages/bolt/app/components/workbench/FileTree.tsx @@ -1,7 +1,7 @@ import { memo, useEffect, useMemo, useState, type ReactNode } from 'react'; -import type { FileMap } from '../../lib/stores/files'; -import { classNames } from '../../utils/classNames'; -import { renderLogger } from '../../utils/logger'; +import type { FileMap } from '~/lib/stores/files'; +import { classNames } from '~/utils/classNames'; +import { renderLogger } from '~/utils/logger'; const NODE_PADDING_LEFT = 12; const DEFAULT_HIDDEN_FILES = [/\/node_modules\//]; diff --git a/packages/bolt/app/components/workbench/FileTreePanel.tsx b/packages/bolt/app/components/workbench/FileTreePanel.tsx index 65c73b2..5f5f6bf 100644 --- a/packages/bolt/app/components/workbench/FileTreePanel.tsx +++ b/packages/bolt/app/components/workbench/FileTreePanel.tsx @@ -1,7 +1,7 @@ import { memo } from 'react'; -import type { FileMap } from '../../lib/stores/files'; -import { WORK_DIR } from '../../utils/constants'; -import { renderLogger } from '../../utils/logger'; +import type { FileMap } from '~/lib/stores/files'; +import { WORK_DIR } from '~/utils/constants'; +import { renderLogger } from '~/utils/logger'; import { FileTree } from './FileTree'; interface FileTreePanelProps { diff --git a/packages/bolt/app/components/workbench/Preview.tsx b/packages/bolt/app/components/workbench/Preview.tsx index 3a211f0..38c6b49 100644 --- a/packages/bolt/app/components/workbench/Preview.tsx +++ b/packages/bolt/app/components/workbench/Preview.tsx @@ -1,7 +1,7 @@ import { useStore } from '@nanostores/react'; import { memo, useEffect, useRef, useState } from 'react'; -import { workbenchStore } from '../../lib/stores/workbench'; -import { IconButton } from '../ui/IconButton'; +import { IconButton } from '~/components/ui/IconButton'; +import { workbenchStore } from '~/lib/stores/workbench'; export const Preview = memo(() => { const iframeRef = useRef(null); diff --git a/packages/bolt/app/components/workbench/Workbench.client.tsx b/packages/bolt/app/components/workbench/Workbench.client.tsx index f5236ce..3d9ebf4 100644 --- a/packages/bolt/app/components/workbench/Workbench.client.tsx +++ b/packages/bolt/app/components/workbench/Workbench.client.tsx @@ -3,14 +3,14 @@ import { AnimatePresence, motion, type Variants } from 'framer-motion'; import { memo, useCallback, useEffect } from 'react'; import { Panel, PanelGroup, PanelResizeHandle } from 'react-resizable-panels'; import { toast } from 'react-toastify'; -import { workbenchStore } from '../../lib/stores/workbench'; -import { cubicEasingFn } from '../../utils/easings'; -import { renderLogger } from '../../utils/logger'; import { type OnChangeCallback as OnEditorChange, type OnScrollCallback as OnEditorScroll, -} from '../editor/codemirror/CodeMirrorEditor'; -import { IconButton } from '../ui/IconButton'; +} from '~/components/editor/codemirror/CodeMirrorEditor'; +import { IconButton } from '~/components/ui/IconButton'; +import { workbenchStore } from '~/lib/stores/workbench'; +import { cubicEasingFn } from '~/utils/easings'; +import { renderLogger } from '~/utils/logger'; import { EditorPanel } from './EditorPanel'; import { Preview } from './Preview'; diff --git a/packages/bolt/app/lib/.server/llm/prompts.ts b/packages/bolt/app/lib/.server/llm/prompts.ts index e691066..4e02864 100644 --- a/packages/bolt/app/lib/.server/llm/prompts.ts +++ b/packages/bolt/app/lib/.server/llm/prompts.ts @@ -1,5 +1,5 @@ -import { WORK_DIR } from '../../../utils/constants'; -import { stripIndents } from '../../../utils/stripIndent'; +import { WORK_DIR } from '~/utils/constants'; +import { stripIndents } from '~/utils/stripIndent'; export const getSystemPrompt = (cwd: string = WORK_DIR) => ` You are Bolt, an expert AI assistant and exceptional senior software developer with vast knowledge across multiple programming languages, frameworks, and best practices. diff --git a/packages/bolt/app/lib/.server/llm/stream-text.ts b/packages/bolt/app/lib/.server/llm/stream-text.ts index eddd215..b1149e4 100644 --- a/packages/bolt/app/lib/.server/llm/stream-text.ts +++ b/packages/bolt/app/lib/.server/llm/stream-text.ts @@ -1,6 +1,6 @@ import { streamText as _streamText, convertToCoreMessages } from 'ai'; -import { getAPIKey } from '../llm/api-key'; -import { getAnthropicModel } from '../llm/model'; +import { getAPIKey } from '~/lib/.server/llm/api-key'; +import { getAnthropicModel } from '~/lib/.server/llm/model'; import { MAX_TOKENS } from './constants'; import { getSystemPrompt } from './prompts'; diff --git a/packages/bolt/app/lib/hooks/useMessageParser.ts b/packages/bolt/app/lib/hooks/useMessageParser.ts index 9aad5c3..324727b 100644 --- a/packages/bolt/app/lib/hooks/useMessageParser.ts +++ b/packages/bolt/app/lib/hooks/useMessageParser.ts @@ -1,8 +1,8 @@ import type { Message } from 'ai'; import { useCallback, useState } from 'react'; -import { createScopedLogger } from '../../utils/logger'; -import { StreamingMessageParser } from '../runtime/message-parser'; -import { workbenchStore } from '../stores/workbench'; +import { StreamingMessageParser } from '~/lib/runtime/message-parser'; +import { workbenchStore } from '~/lib/stores/workbench'; +import { createScopedLogger } from '~/utils/logger'; const logger = createScopedLogger('useMessageParser'); diff --git a/packages/bolt/app/lib/hooks/usePromptEnhancer.ts b/packages/bolt/app/lib/hooks/usePromptEnhancer.ts index eb07e66..f376cc0 100644 --- a/packages/bolt/app/lib/hooks/usePromptEnhancer.ts +++ b/packages/bolt/app/lib/hooks/usePromptEnhancer.ts @@ -1,5 +1,5 @@ import { useState } from 'react'; -import { createScopedLogger } from '../../utils/logger'; +import { createScopedLogger } from '~/utils/logger'; const logger = createScopedLogger('usePromptEnhancement'); diff --git a/packages/bolt/app/lib/runtime/action-runner.ts b/packages/bolt/app/lib/runtime/action-runner.ts index 94536ee..078ce5a 100644 --- a/packages/bolt/app/lib/runtime/action-runner.ts +++ b/packages/bolt/app/lib/runtime/action-runner.ts @@ -1,9 +1,9 @@ import { WebContainer } from '@webcontainer/api'; import { map, type MapStore } from 'nanostores'; import * as nodePath from 'node:path'; -import type { BoltAction } from '../../types/actions'; -import { createScopedLogger } from '../../utils/logger'; -import { unreachable } from '../../utils/unreachable'; +import type { BoltAction } from '~/types/actions'; +import { createScopedLogger } from '~/utils/logger'; +import { unreachable } from '~/utils/unreachable'; import type { ActionCallbackData } from './message-parser'; const logger = createScopedLogger('ActionRunner'); diff --git a/packages/bolt/app/lib/runtime/message-parser.ts b/packages/bolt/app/lib/runtime/message-parser.ts index fd954cb..c828815 100644 --- a/packages/bolt/app/lib/runtime/message-parser.ts +++ b/packages/bolt/app/lib/runtime/message-parser.ts @@ -1,7 +1,7 @@ -import type { ActionType, BoltAction, BoltActionData, FileAction, ShellAction } from '../../types/actions'; -import type { BoltArtifactData } from '../../types/artifact'; -import { createScopedLogger } from '../../utils/logger'; -import { unreachable } from '../../utils/unreachable'; +import type { ActionType, BoltAction, BoltActionData, FileAction, ShellAction } from '~/types/actions'; +import type { BoltArtifactData } from '~/types/artifact'; +import { createScopedLogger } from '~/utils/logger'; +import { unreachable } from '~/utils/unreachable'; const ARTIFACT_TAG_OPEN = '; diff --git a/packages/bolt/app/lib/stores/files.ts b/packages/bolt/app/lib/stores/files.ts index caf507c..82de4de 100644 --- a/packages/bolt/app/lib/stores/files.ts +++ b/packages/bolt/app/lib/stores/files.ts @@ -1,9 +1,9 @@ import type { PathWatcherEvent, WebContainer } from '@webcontainer/api'; import { map, type MapStore } from 'nanostores'; import * as nodePath from 'node:path'; -import { bufferWatchEvents } from '../../utils/buffer'; -import { WORK_DIR } from '../../utils/constants'; -import { createScopedLogger } from '../../utils/logger'; +import { bufferWatchEvents } from '~/utils/buffer'; +import { WORK_DIR } from '~/utils/constants'; +import { createScopedLogger } from '~/utils/logger'; const logger = createScopedLogger('FilesStore'); diff --git a/packages/bolt/app/lib/stores/workbench.ts b/packages/bolt/app/lib/stores/workbench.ts index cbe41dc..a24fdf1 100644 --- a/packages/bolt/app/lib/stores/workbench.ts +++ b/packages/bolt/app/lib/stores/workbench.ts @@ -1,9 +1,9 @@ import { atom, map, type MapStore, type ReadableAtom, type WritableAtom } from 'nanostores'; -import type { EditorDocument, ScrollPosition } from '../../components/editor/codemirror/CodeMirrorEditor'; -import { unreachable } from '../../utils/unreachable'; -import { ActionRunner } from '../runtime/action-runner'; -import type { ActionCallbackData, ArtifactCallbackData } from '../runtime/message-parser'; -import { webcontainer } from '../webcontainer'; +import type { EditorDocument, ScrollPosition } from '~/components/editor/codemirror/CodeMirrorEditor'; +import { ActionRunner } from '~/lib/runtime/action-runner'; +import type { ActionCallbackData, ArtifactCallbackData } from '~/lib/runtime/message-parser'; +import { webcontainer } from '~/lib/webcontainer'; +import { unreachable } from '~/utils/unreachable'; import { EditorStore } from './editor'; import { FilesStore, type FileMap } from './files'; import { PreviewsStore } from './previews'; diff --git a/packages/bolt/app/lib/webcontainer/index.ts b/packages/bolt/app/lib/webcontainer/index.ts index 2926759..92f1685 100644 --- a/packages/bolt/app/lib/webcontainer/index.ts +++ b/packages/bolt/app/lib/webcontainer/index.ts @@ -1,5 +1,5 @@ import { WebContainer } from '@webcontainer/api'; -import { WORK_DIR_NAME } from '../../utils/constants'; +import { WORK_DIR_NAME } from '~/utils/constants'; interface WebContainerContext { loaded: boolean; diff --git a/packages/bolt/app/routes/_index.tsx b/packages/bolt/app/routes/_index.tsx index 48388c7..e700e04 100644 --- a/packages/bolt/app/routes/_index.tsx +++ b/packages/bolt/app/routes/_index.tsx @@ -1,9 +1,9 @@ import { json, redirect, type LoaderFunctionArgs, type MetaFunction } from '@remix-run/cloudflare'; import { ClientOnly } from 'remix-utils/client-only'; -import { BaseChat } from '../components/chat/BaseChat'; -import { Chat } from '../components/chat/Chat.client'; -import { Header } from '../components/Header'; -import { isAuthenticated } from '../lib/.server/sessions'; +import { BaseChat } from '~/components/chat/BaseChat'; +import { Chat } from '~/components/chat/Chat.client'; +import { Header } from '~/components/Header'; +import { isAuthenticated } from '~/lib/.server/sessions'; export const meta: MetaFunction = () => { return [{ title: 'Bolt' }, { name: 'description', content: 'Talk with Bolt, an AI assistant from StackBlitz' }]; diff --git a/packages/bolt/app/routes/api.chat.ts b/packages/bolt/app/routes/api.chat.ts index e554eaf..a487b37 100644 --- a/packages/bolt/app/routes/api.chat.ts +++ b/packages/bolt/app/routes/api.chat.ts @@ -1,9 +1,9 @@ import { type ActionFunctionArgs } from '@remix-run/cloudflare'; import { StreamingTextResponse } from 'ai'; -import { MAX_RESPONSE_SEGMENTS, MAX_TOKENS } from '../lib/.server/llm/constants'; -import { CONTINUE_PROMPT } from '../lib/.server/llm/prompts'; -import { streamText, type Messages, type StreamingOptions } from '../lib/.server/llm/stream-text'; -import SwitchableStream from '../lib/.server/llm/switchable-stream'; +import { MAX_RESPONSE_SEGMENTS, MAX_TOKENS } from '~/lib/.server/llm/constants'; +import { CONTINUE_PROMPT } from '~/lib/.server/llm/prompts'; +import { streamText, type Messages, type StreamingOptions } from '~/lib/.server/llm/stream-text'; +import SwitchableStream from '~/lib/.server/llm/switchable-stream'; export async function action({ context, request }: ActionFunctionArgs) { const { messages } = await request.json<{ messages: Messages }>(); diff --git a/packages/bolt/app/routes/api.enhancer.ts b/packages/bolt/app/routes/api.enhancer.ts index f9308e0..2da992e 100644 --- a/packages/bolt/app/routes/api.enhancer.ts +++ b/packages/bolt/app/routes/api.enhancer.ts @@ -1,7 +1,7 @@ import { type ActionFunctionArgs } from '@remix-run/cloudflare'; import { StreamingTextResponse, parseStreamPart } from 'ai'; -import { streamText } from '../lib/.server/llm/stream-text'; -import { stripIndents } from '../utils/stripIndent'; +import { streamText } from '~/lib/.server/llm/stream-text'; +import { stripIndents } from '~/utils/stripIndent'; const encoder = new TextEncoder(); const decoder = new TextDecoder(); diff --git a/packages/bolt/app/routes/login.tsx b/packages/bolt/app/routes/login.tsx index e9192d5..561b75f 100644 --- a/packages/bolt/app/routes/login.tsx +++ b/packages/bolt/app/routes/login.tsx @@ -6,8 +6,8 @@ import { type TypedResponse, } from '@remix-run/cloudflare'; import { Form, useActionData } from '@remix-run/react'; -import { verifyPassword } from '../lib/.server/login'; -import { createUserSession, isAuthenticated } from '../lib/.server/sessions'; +import { verifyPassword } from '~/lib/.server/login'; +import { createUserSession, isAuthenticated } from '~/lib/.server/sessions'; interface Errors { password?: string; diff --git a/packages/bolt/functions/[[path]].ts b/packages/bolt/functions/[[path]].ts index 4f19660..27bb892 100644 --- a/packages/bolt/functions/[[path]].ts +++ b/packages/bolt/functions/[[path]].ts @@ -2,7 +2,7 @@ import type { ServerBuild } from '@remix-run/cloudflare'; import { createPagesFunctionHandler } from '@remix-run/cloudflare-pages'; // @ts-ignore because the server build file is generated by `remix vite:build` -import * as serverBuild from '../build/server'; +import * as serverBuild from '~/build/server'; export const onRequest = createPagesFunctionHandler({ build: serverBuild as unknown as ServerBuild,