create-better-t-stack 3.10.0 → 3.11.0-pr749.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/create-better-t-stack +98 -0
- package/package.json +40 -30
- package/src/api.ts +203 -0
- package/src/cli.ts +185 -0
- package/src/constants.ts +270 -0
- package/src/helpers/addons/addons-setup.ts +201 -0
- package/src/helpers/addons/examples-setup.ts +137 -0
- package/src/helpers/addons/fumadocs-setup.ts +99 -0
- package/src/helpers/addons/oxlint-setup.ts +36 -0
- package/src/helpers/addons/ruler-setup.ts +135 -0
- package/src/helpers/addons/starlight-setup.ts +45 -0
- package/src/helpers/addons/tauri-setup.ts +90 -0
- package/src/helpers/addons/tui-setup.ts +64 -0
- package/src/helpers/addons/ultracite-setup.ts +228 -0
- package/src/helpers/addons/vite-pwa-setup.ts +59 -0
- package/src/helpers/addons/wxt-setup.ts +86 -0
- package/src/helpers/core/add-addons.ts +85 -0
- package/src/helpers/core/add-deployment.ts +102 -0
- package/src/helpers/core/api-setup.ts +280 -0
- package/src/helpers/core/auth-setup.ts +203 -0
- package/src/helpers/core/backend-setup.ts +69 -0
- package/src/helpers/core/command-handlers.ts +354 -0
- package/src/helpers/core/convex-codegen.ts +14 -0
- package/src/helpers/core/create-project.ts +134 -0
- package/src/helpers/core/create-readme.ts +694 -0
- package/src/helpers/core/db-setup.ts +184 -0
- package/src/helpers/core/detect-project-config.ts +41 -0
- package/src/helpers/core/env-setup.ts +481 -0
- package/src/helpers/core/git.ts +23 -0
- package/src/helpers/core/install-dependencies.ts +29 -0
- package/src/helpers/core/payments-setup.ts +48 -0
- package/src/helpers/core/post-installation.ts +403 -0
- package/src/helpers/core/project-config.ts +250 -0
- package/src/helpers/core/runtime-setup.ts +76 -0
- package/src/helpers/core/template-manager.ts +917 -0
- package/src/helpers/core/workspace-setup.ts +184 -0
- package/src/helpers/database-providers/d1-setup.ts +28 -0
- package/src/helpers/database-providers/docker-compose-setup.ts +50 -0
- package/src/helpers/database-providers/mongodb-atlas-setup.ts +182 -0
- package/src/helpers/database-providers/neon-setup.ts +240 -0
- package/src/helpers/database-providers/planetscale-setup.ts +78 -0
- package/src/helpers/database-providers/prisma-postgres-setup.ts +193 -0
- package/src/helpers/database-providers/supabase-setup.ts +196 -0
- package/src/helpers/database-providers/turso-setup.ts +309 -0
- package/src/helpers/deployment/alchemy/alchemy-combined-setup.ts +80 -0
- package/src/helpers/deployment/alchemy/alchemy-next-setup.ts +52 -0
- package/src/helpers/deployment/alchemy/alchemy-nuxt-setup.ts +105 -0
- package/src/helpers/deployment/alchemy/alchemy-react-router-setup.ts +33 -0
- package/src/helpers/deployment/alchemy/alchemy-solid-setup.ts +33 -0
- package/src/helpers/deployment/alchemy/alchemy-svelte-setup.ts +99 -0
- package/src/helpers/deployment/alchemy/alchemy-tanstack-router-setup.ts +34 -0
- package/src/helpers/deployment/alchemy/alchemy-tanstack-start-setup.ts +99 -0
- package/src/helpers/deployment/alchemy/env-dts-setup.ts +76 -0
- package/src/helpers/deployment/alchemy/index.ts +7 -0
- package/src/helpers/deployment/server-deploy-setup.ts +55 -0
- package/src/helpers/deployment/web-deploy-setup.ts +58 -0
- package/src/index.ts +51 -0
- package/src/prompts/addons.ts +200 -0
- package/src/prompts/api.ts +49 -0
- package/src/prompts/auth.ts +84 -0
- package/src/prompts/backend.ts +83 -0
- package/src/prompts/config-prompts.ts +138 -0
- package/src/prompts/database-setup.ts +112 -0
- package/src/prompts/database.ts +57 -0
- package/src/prompts/examples.ts +60 -0
- package/src/prompts/frontend.ts +118 -0
- package/src/prompts/git.ts +16 -0
- package/src/prompts/install.ts +16 -0
- package/src/prompts/orm.ts +53 -0
- package/src/prompts/package-manager.ts +32 -0
- package/src/prompts/payments.ts +50 -0
- package/src/prompts/project-name.ts +86 -0
- package/src/prompts/runtime.ts +47 -0
- package/src/prompts/server-deploy.ts +91 -0
- package/src/prompts/web-deploy.ts +107 -0
- package/src/tui/app.tsx +1062 -0
- package/src/types.ts +70 -0
- package/src/utils/add-package-deps.ts +57 -0
- package/src/utils/analytics.ts +39 -0
- package/src/utils/better-auth-plugin-setup.ts +71 -0
- package/src/utils/bts-config.ts +122 -0
- package/src/utils/command-exists.ts +16 -0
- package/src/utils/compatibility-rules.ts +337 -0
- package/src/utils/compatibility.ts +11 -0
- package/src/utils/config-processing.ts +130 -0
- package/src/utils/config-validation.ts +470 -0
- package/src/utils/display-config.ts +96 -0
- package/src/utils/docker-utils.ts +70 -0
- package/src/utils/errors.ts +30 -0
- package/src/utils/file-formatter.ts +11 -0
- package/src/utils/generate-reproducible-command.ts +53 -0
- package/src/utils/get-latest-cli-version.ts +27 -0
- package/src/utils/get-package-manager.ts +13 -0
- package/src/utils/open-url.ts +18 -0
- package/src/utils/package-runner.ts +23 -0
- package/src/utils/project-directory.ts +102 -0
- package/src/utils/project-name-validation.ts +43 -0
- package/src/utils/render-title.ts +48 -0
- package/src/utils/setup-catalogs.ts +192 -0
- package/src/utils/sponsors.ts +101 -0
- package/src/utils/telemetry.ts +19 -0
- package/src/utils/template-processor.ts +64 -0
- package/src/utils/templates.ts +94 -0
- package/src/utils/ts-morph.ts +26 -0
- package/src/validation.ts +117 -0
- package/templates/auth/better-auth/convex/backend/convex/auth.ts.hbs +1 -1
- package/templates/backend/convex/packages/backend/convex/convex.config.ts.hbs +17 -0
- package/templates/examples/ai/convex/packages/backend/convex/agent.ts.hbs +9 -0
- package/templates/examples/ai/convex/packages/backend/convex/chat.ts.hbs +67 -0
- package/templates/examples/ai/native/bare/app/(drawer)/ai.tsx.hbs +301 -3
- package/templates/examples/ai/native/unistyles/app/(drawer)/ai.tsx.hbs +296 -10
- package/templates/examples/ai/native/uniwind/app/(drawer)/ai.tsx.hbs +180 -1
- package/templates/examples/ai/web/react/next/src/app/ai/page.tsx.hbs +172 -9
- package/templates/examples/ai/web/react/react-router/src/routes/ai.tsx.hbs +156 -6
- package/templates/examples/ai/web/react/tanstack-router/src/routes/ai.tsx.hbs +156 -4
- package/templates/examples/ai/web/react/tanstack-start/src/routes/ai.tsx.hbs +159 -6
- package/templates/frontend/react/web-base/src/index.css.hbs +1 -1
- package/dist/cli.d.mts +0 -1
- package/dist/cli.mjs +0 -8
- package/dist/index.d.mts +0 -347
- package/dist/index.mjs +0 -4
- package/dist/src-QkFdHtZE.mjs +0 -7072
- package/templates/auth/better-auth/convex/backend/convex/convex.config.ts.hbs +0 -7
- package/templates/examples/ai/web/react/base/src/components/response.tsx.hbs +0 -22
|
@@ -1,3 +1,147 @@
|
|
|
1
|
+
{{#if (eq backend "convex")}}
|
|
2
|
+
import { api } from "@{{projectName}}/backend/convex/_generated/api";
|
|
3
|
+
import {
|
|
4
|
+
useUIMessages,
|
|
5
|
+
useSmoothText,
|
|
6
|
+
type UIMessage,
|
|
7
|
+
} from "@convex-dev/agent/react";
|
|
8
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
9
|
+
import { useMutation } from "convex/react";
|
|
10
|
+
import { Send, Loader2 } from "lucide-react";
|
|
11
|
+
import { useRef, useEffect, useState } from "react";
|
|
12
|
+
import { Streamdown } from "streamdown";
|
|
13
|
+
|
|
14
|
+
import { Button } from "@/components/ui/button";
|
|
15
|
+
import { Input } from "@/components/ui/input";
|
|
16
|
+
|
|
17
|
+
export const Route = createFileRoute("/ai")({
|
|
18
|
+
component: RouteComponent,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
function MessageContent({
|
|
22
|
+
text,
|
|
23
|
+
isStreaming,
|
|
24
|
+
}: {
|
|
25
|
+
text: string;
|
|
26
|
+
isStreaming: boolean;
|
|
27
|
+
}) {
|
|
28
|
+
const [visibleText] = useSmoothText(text, {
|
|
29
|
+
startStreaming: isStreaming,
|
|
30
|
+
});
|
|
31
|
+
return <Streamdown>{visibleText}</Streamdown>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function RouteComponent() {
|
|
35
|
+
const [input, setInput] = useState("");
|
|
36
|
+
const [threadId, setThreadId] = useState<string | null>(null);
|
|
37
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
38
|
+
const messagesEndRef = useRef<HTMLDivElement>(null);
|
|
39
|
+
|
|
40
|
+
const createThread = useMutation(api.chat.createNewThread);
|
|
41
|
+
const sendMessage = useMutation(api.chat.sendMessage);
|
|
42
|
+
|
|
43
|
+
const { results: messages } = useUIMessages(
|
|
44
|
+
api.chat.listMessages,
|
|
45
|
+
threadId ? { threadId } : "skip",
|
|
46
|
+
{ initialNumItems: 50, stream: true },
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
51
|
+
}, [messages]);
|
|
52
|
+
|
|
53
|
+
const hasStreamingMessage = messages?.some(
|
|
54
|
+
(m: UIMessage) => m.status === "streaming",
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
const text = input.trim();
|
|
60
|
+
if (!text || isLoading) return;
|
|
61
|
+
|
|
62
|
+
setIsLoading(true);
|
|
63
|
+
setInput("");
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
let currentThreadId = threadId;
|
|
67
|
+
if (!currentThreadId) {
|
|
68
|
+
currentThreadId = await createThread();
|
|
69
|
+
setThreadId(currentThreadId);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
await sendMessage({ threadId: currentThreadId, prompt: text });
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error("Failed to send message:", error);
|
|
75
|
+
} finally {
|
|
76
|
+
setIsLoading(false);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div className="grid grid-rows-[1fr_auto] overflow-hidden w-full mx-auto p-4">
|
|
82
|
+
<div className="overflow-y-auto space-y-4 pb-4">
|
|
83
|
+
{!messages || messages.length === 0 ? (
|
|
84
|
+
<div className="text-center text-muted-foreground mt-8">
|
|
85
|
+
Ask me anything to get started!
|
|
86
|
+
</div>
|
|
87
|
+
) : (
|
|
88
|
+
messages.map((message: UIMessage) => (
|
|
89
|
+
<div
|
|
90
|
+
key={message.key}
|
|
91
|
+
className={`p-3 rounded-lg ${
|
|
92
|
+
message.role === "user"
|
|
93
|
+
? "bg-primary/10 ml-8"
|
|
94
|
+
: "bg-secondary/20 mr-8"
|
|
95
|
+
}`}
|
|
96
|
+
>
|
|
97
|
+
<p className="text-sm font-semibold mb-1">
|
|
98
|
+
{message.role === "user" ? "You" : "AI Assistant"}
|
|
99
|
+
</p>
|
|
100
|
+
<MessageContent
|
|
101
|
+
text={message.text ?? ""}
|
|
102
|
+
isStreaming={message.status === "streaming"}
|
|
103
|
+
/>
|
|
104
|
+
</div>
|
|
105
|
+
))
|
|
106
|
+
)}
|
|
107
|
+
{isLoading && !hasStreamingMessage && (
|
|
108
|
+
<div className="p-3 rounded-lg bg-secondary/20 mr-8">
|
|
109
|
+
<p className="text-sm font-semibold mb-1">AI Assistant</p>
|
|
110
|
+
<div className="flex items-center gap-2 text-muted-foreground">
|
|
111
|
+
<Loader2 className="h-4 w-4 animate-spin" />
|
|
112
|
+
<span>Thinking...</span>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
)}
|
|
116
|
+
<div ref={messagesEndRef} />
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<form
|
|
120
|
+
onSubmit={handleSubmit}
|
|
121
|
+
className="w-full flex items-center space-x-2 pt-2 border-t"
|
|
122
|
+
>
|
|
123
|
+
<Input
|
|
124
|
+
name="prompt"
|
|
125
|
+
value={input}
|
|
126
|
+
onChange={(e) => setInput(e.target.value)}
|
|
127
|
+
placeholder="Type your message..."
|
|
128
|
+
className="flex-1"
|
|
129
|
+
autoComplete="off"
|
|
130
|
+
autoFocus
|
|
131
|
+
disabled={isLoading}
|
|
132
|
+
/>
|
|
133
|
+
<Button type="submit" size="icon" disabled={isLoading || !input.trim()}>
|
|
134
|
+
{isLoading ? (
|
|
135
|
+
<Loader2 className="h-4 w-4 animate-spin" />
|
|
136
|
+
) : (
|
|
137
|
+
<Send size={18} />
|
|
138
|
+
)}
|
|
139
|
+
</Button>
|
|
140
|
+
</form>
|
|
141
|
+
</div>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
{{else}}
|
|
1
145
|
import { createFileRoute } from "@tanstack/react-router";
|
|
2
146
|
import { useChat } from "@ai-sdk/react";
|
|
3
147
|
import { DefaultChatTransport } from "ai";
|
|
@@ -5,7 +149,7 @@ import { Input } from "@/components/ui/input";
|
|
|
5
149
|
import { Button } from "@/components/ui/button";
|
|
6
150
|
import { Send } from "lucide-react";
|
|
7
151
|
import { useRef, useEffect, useState } from "react";
|
|
8
|
-
import {
|
|
152
|
+
import { Streamdown } from "streamdown";
|
|
9
153
|
|
|
10
154
|
export const Route = createFileRoute("/ai")({
|
|
11
155
|
component: RouteComponent,
|
|
@@ -13,9 +157,9 @@ export const Route = createFileRoute("/ai")({
|
|
|
13
157
|
|
|
14
158
|
function RouteComponent() {
|
|
15
159
|
const [input, setInput] = useState("");
|
|
16
|
-
const { messages, sendMessage } = useChat({
|
|
160
|
+
const { messages, sendMessage, status } = useChat({
|
|
17
161
|
transport: new DefaultChatTransport({
|
|
18
|
-
api: `${import.meta.env.VITE_SERVER_URL}/ai
|
|
162
|
+
api: {{#if (eq backend "self")}}"/api/ai"{{else}}`${import.meta.env.VITE_SERVER_URL}/ai`{{/if}},
|
|
19
163
|
}),
|
|
20
164
|
});
|
|
21
165
|
|
|
@@ -55,7 +199,14 @@ function RouteComponent() {
|
|
|
55
199
|
</p>
|
|
56
200
|
{message.parts?.map((part, index) => {
|
|
57
201
|
if (part.type === "text") {
|
|
58
|
-
return
|
|
202
|
+
return (
|
|
203
|
+
<Streamdown
|
|
204
|
+
key={index}
|
|
205
|
+
isAnimating={status === "streaming" && message.role === "assistant"}
|
|
206
|
+
>
|
|
207
|
+
{part.text}
|
|
208
|
+
</Streamdown>
|
|
209
|
+
);
|
|
59
210
|
}
|
|
60
211
|
return null;
|
|
61
212
|
})}
|
|
@@ -85,3 +236,4 @@ function RouteComponent() {
|
|
|
85
236
|
</div>
|
|
86
237
|
);
|
|
87
238
|
}
|
|
239
|
+
{{/if}}
|
|
@@ -1,11 +1,156 @@
|
|
|
1
|
+
{{#if (eq backend "convex")}}
|
|
2
|
+
import { api } from "@{{projectName}}/backend/convex/_generated/api";
|
|
3
|
+
import {
|
|
4
|
+
useUIMessages,
|
|
5
|
+
useSmoothText,
|
|
6
|
+
type UIMessage,
|
|
7
|
+
} from "@convex-dev/agent/react";
|
|
8
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
9
|
+
import { useMutation } from "convex/react";
|
|
10
|
+
import { Send, Loader2 } from "lucide-react";
|
|
11
|
+
import { useRef, useEffect, useState } from "react";
|
|
12
|
+
import { Streamdown } from "streamdown";
|
|
13
|
+
|
|
14
|
+
import { Button } from "@/components/ui/button";
|
|
15
|
+
import { Input } from "@/components/ui/input";
|
|
16
|
+
|
|
17
|
+
export const Route = createFileRoute("/ai")({
|
|
18
|
+
component: RouteComponent,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
function MessageContent({
|
|
22
|
+
text,
|
|
23
|
+
isStreaming,
|
|
24
|
+
}: {
|
|
25
|
+
text: string;
|
|
26
|
+
isStreaming: boolean;
|
|
27
|
+
}) {
|
|
28
|
+
const [visibleText] = useSmoothText(text, {
|
|
29
|
+
startStreaming: isStreaming,
|
|
30
|
+
});
|
|
31
|
+
return <Streamdown>{visibleText}</Streamdown>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function RouteComponent() {
|
|
35
|
+
const [input, setInput] = useState("");
|
|
36
|
+
const [threadId, setThreadId] = useState<string | null>(null);
|
|
37
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
38
|
+
const messagesEndRef = useRef<HTMLDivElement>(null);
|
|
39
|
+
|
|
40
|
+
const createThread = useMutation(api.chat.createNewThread);
|
|
41
|
+
const sendMessage = useMutation(api.chat.sendMessage);
|
|
42
|
+
|
|
43
|
+
const { results: messages } = useUIMessages(
|
|
44
|
+
api.chat.listMessages,
|
|
45
|
+
threadId ? { threadId } : "skip",
|
|
46
|
+
{ initialNumItems: 50, stream: true },
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
51
|
+
}, [messages]);
|
|
52
|
+
|
|
53
|
+
const hasStreamingMessage = messages?.some(
|
|
54
|
+
(m: UIMessage) => m.status === "streaming",
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
const text = input.trim();
|
|
60
|
+
if (!text || isLoading) return;
|
|
61
|
+
|
|
62
|
+
setIsLoading(true);
|
|
63
|
+
setInput("");
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
let currentThreadId = threadId;
|
|
67
|
+
if (!currentThreadId) {
|
|
68
|
+
currentThreadId = await createThread();
|
|
69
|
+
setThreadId(currentThreadId);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
await sendMessage({ threadId: currentThreadId, prompt: text });
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error("Failed to send message:", error);
|
|
75
|
+
} finally {
|
|
76
|
+
setIsLoading(false);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div className="grid grid-rows-[1fr_auto] overflow-hidden w-full mx-auto p-4">
|
|
82
|
+
<div className="overflow-y-auto space-y-4 pb-4">
|
|
83
|
+
{!messages || messages.length === 0 ? (
|
|
84
|
+
<div className="text-center text-muted-foreground mt-8">
|
|
85
|
+
Ask me anything to get started!
|
|
86
|
+
</div>
|
|
87
|
+
) : (
|
|
88
|
+
messages.map((message: UIMessage) => (
|
|
89
|
+
<div
|
|
90
|
+
key={message.key}
|
|
91
|
+
className={`p-3 rounded-lg ${
|
|
92
|
+
message.role === "user"
|
|
93
|
+
? "bg-primary/10 ml-8"
|
|
94
|
+
: "bg-secondary/20 mr-8"
|
|
95
|
+
}`}
|
|
96
|
+
>
|
|
97
|
+
<p className="text-sm font-semibold mb-1">
|
|
98
|
+
{message.role === "user" ? "You" : "AI Assistant"}
|
|
99
|
+
</p>
|
|
100
|
+
<MessageContent
|
|
101
|
+
text={message.text ?? ""}
|
|
102
|
+
isStreaming={message.status === "streaming"}
|
|
103
|
+
/>
|
|
104
|
+
</div>
|
|
105
|
+
))
|
|
106
|
+
)}
|
|
107
|
+
{isLoading && !hasStreamingMessage && (
|
|
108
|
+
<div className="p-3 rounded-lg bg-secondary/20 mr-8">
|
|
109
|
+
<p className="text-sm font-semibold mb-1">AI Assistant</p>
|
|
110
|
+
<div className="flex items-center gap-2 text-muted-foreground">
|
|
111
|
+
<Loader2 className="h-4 w-4 animate-spin" />
|
|
112
|
+
<span>Thinking...</span>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
)}
|
|
116
|
+
<div ref={messagesEndRef} />
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<form
|
|
120
|
+
onSubmit={handleSubmit}
|
|
121
|
+
className="w-full flex items-center space-x-2 pt-2 border-t"
|
|
122
|
+
>
|
|
123
|
+
<Input
|
|
124
|
+
name="prompt"
|
|
125
|
+
value={input}
|
|
126
|
+
onChange={(e) => setInput(e.target.value)}
|
|
127
|
+
placeholder="Type your message..."
|
|
128
|
+
className="flex-1"
|
|
129
|
+
autoComplete="off"
|
|
130
|
+
autoFocus
|
|
131
|
+
disabled={isLoading}
|
|
132
|
+
/>
|
|
133
|
+
<Button type="submit" size="icon" disabled={isLoading || !input.trim()}>
|
|
134
|
+
{isLoading ? (
|
|
135
|
+
<Loader2 className="h-4 w-4 animate-spin" />
|
|
136
|
+
) : (
|
|
137
|
+
<Send size={18} />
|
|
138
|
+
)}
|
|
139
|
+
</Button>
|
|
140
|
+
</form>
|
|
141
|
+
</div>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
{{else}}
|
|
1
145
|
import { createFileRoute } from "@tanstack/react-router";
|
|
2
146
|
import { useChat } from "@ai-sdk/react";
|
|
3
147
|
import { DefaultChatTransport } from "ai";
|
|
4
|
-
import { Input } from "@/components/ui/input";
|
|
5
|
-
import { Button } from "@/components/ui/button";
|
|
6
148
|
import { Send } from "lucide-react";
|
|
7
149
|
import { useRef, useEffect, useState } from "react";
|
|
8
|
-
import {
|
|
150
|
+
import { Streamdown } from "streamdown";
|
|
151
|
+
|
|
152
|
+
import { Button } from "@/components/ui/button";
|
|
153
|
+
import { Input } from "@/components/ui/input";
|
|
9
154
|
|
|
10
155
|
export const Route = createFileRoute("/ai")({
|
|
11
156
|
component: RouteComponent,
|
|
@@ -13,7 +158,7 @@ export const Route = createFileRoute("/ai")({
|
|
|
13
158
|
|
|
14
159
|
function RouteComponent() {
|
|
15
160
|
const [input, setInput] = useState("");
|
|
16
|
-
const { messages, sendMessage } = useChat({
|
|
161
|
+
const { messages, sendMessage, status } = useChat({
|
|
17
162
|
transport: new DefaultChatTransport({
|
|
18
163
|
api: {{#if (eq backend "self")}}"/api/ai"{{else}}`${import.meta.env.VITE_SERVER_URL}/ai`{{/if}},
|
|
19
164
|
}),
|
|
@@ -55,7 +200,14 @@ function RouteComponent() {
|
|
|
55
200
|
</p>
|
|
56
201
|
{message.parts?.map((part, index) => {
|
|
57
202
|
if (part.type === "text") {
|
|
58
|
-
return
|
|
203
|
+
return (
|
|
204
|
+
<Streamdown
|
|
205
|
+
key={index}
|
|
206
|
+
isAnimating={status === "streaming" && message.role === "assistant"}
|
|
207
|
+
>
|
|
208
|
+
{part.text}
|
|
209
|
+
</Streamdown>
|
|
210
|
+
);
|
|
59
211
|
}
|
|
60
212
|
return null;
|
|
61
213
|
})}
|
|
@@ -84,4 +236,5 @@ function RouteComponent() {
|
|
|
84
236
|
</form>
|
|
85
237
|
</div>
|
|
86
238
|
);
|
|
87
|
-
}
|
|
239
|
+
}
|
|
240
|
+
{{/if}}
|
package/dist/cli.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|