create-sidekick-app 0.0.1 → 2.0.1
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/LICENSE.md +202 -0
- package/NOTICE +27 -0
- package/README.md +29 -2
- package/dist/index.js +59 -0
- package/package.json +65 -4
- package/template/base/ai-chat/.env.example +6 -0
- package/template/base/ai-chat/.prettierignore +2 -0
- package/template/base/ai-chat/.prettierrc.json +5 -0
- package/template/base/ai-chat/README.md +38 -0
- package/template/base/ai-chat/_gitignore +41 -0
- package/template/base/ai-chat/components.json +23 -0
- package/template/base/ai-chat/next.config.ts +5 -0
- package/template/base/ai-chat/package.json +61 -0
- package/template/base/ai-chat/postcss.config.mjs +5 -0
- package/template/base/ai-chat/src/app/api/chat/route.ts +141 -0
- package/template/base/ai-chat/src/app/api/instant/route.ts +5 -0
- package/template/base/ai-chat/src/app/chat/[id]/page.tsx +20 -0
- package/template/base/ai-chat/src/app/globals.css +124 -0
- package/template/base/ai-chat/src/app/layout.tsx +34 -0
- package/template/base/ai-chat/src/app/page.tsx +6 -0
- package/template/base/ai-chat/src/components/AuthGate.tsx +15 -0
- package/template/base/ai-chat/src/components/Chat.tsx +228 -0
- package/template/base/ai-chat/src/components/InstantProvider.tsx +18 -0
- package/template/base/ai-chat/src/components/Login.tsx +163 -0
- package/template/base/ai-chat/src/components/Sidebar.tsx +100 -0
- package/template/base/ai-chat/src/components/ai-elements/agent.tsx +142 -0
- package/template/base/ai-chat/src/components/ai-elements/artifact.tsx +149 -0
- package/template/base/ai-chat/src/components/ai-elements/attachments.tsx +427 -0
- package/template/base/ai-chat/src/components/ai-elements/audio-player.tsx +229 -0
- package/template/base/ai-chat/src/components/ai-elements/canvas.tsx +26 -0
- package/template/base/ai-chat/src/components/ai-elements/chain-of-thought.tsx +223 -0
- package/template/base/ai-chat/src/components/ai-elements/checkpoint.tsx +72 -0
- package/template/base/ai-chat/src/components/ai-elements/code-block.tsx +556 -0
- package/template/base/ai-chat/src/components/ai-elements/commit.tsx +449 -0
- package/template/base/ai-chat/src/components/ai-elements/confirmation.tsx +173 -0
- package/template/base/ai-chat/src/components/ai-elements/connection.tsx +28 -0
- package/template/base/ai-chat/src/components/ai-elements/context.tsx +410 -0
- package/template/base/ai-chat/src/components/ai-elements/controls.tsx +19 -0
- package/template/base/ai-chat/src/components/ai-elements/conversation.tsx +167 -0
- package/template/base/ai-chat/src/components/ai-elements/edge.tsx +144 -0
- package/template/base/ai-chat/src/components/ai-elements/environment-variables.tsx +325 -0
- package/template/base/ai-chat/src/components/ai-elements/file-tree.tsx +298 -0
- package/template/base/ai-chat/src/components/ai-elements/image.tsx +25 -0
- package/template/base/ai-chat/src/components/ai-elements/inline-citation.tsx +294 -0
- package/template/base/ai-chat/src/components/ai-elements/jsx-preview.tsx +250 -0
- package/template/base/ai-chat/src/components/ai-elements/message.tsx +356 -0
- package/template/base/ai-chat/src/components/ai-elements/mic-selector.tsx +372 -0
- package/template/base/ai-chat/src/components/ai-elements/model-selector.tsx +214 -0
- package/template/base/ai-chat/src/components/ai-elements/node.tsx +72 -0
- package/template/base/ai-chat/src/components/ai-elements/open-in-chat.tsx +367 -0
- package/template/base/ai-chat/src/components/ai-elements/package-info.tsx +235 -0
- package/template/base/ai-chat/src/components/ai-elements/panel.tsx +16 -0
- package/template/base/ai-chat/src/components/ai-elements/persona.tsx +280 -0
- package/template/base/ai-chat/src/components/ai-elements/plan.tsx +144 -0
- package/template/base/ai-chat/src/components/ai-elements/prompt-input.tsx +1341 -0
- package/template/base/ai-chat/src/components/ai-elements/queue.tsx +275 -0
- package/template/base/ai-chat/src/components/ai-elements/reasoning.tsx +229 -0
- package/template/base/ai-chat/src/components/ai-elements/sandbox.tsx +128 -0
- package/template/base/ai-chat/src/components/ai-elements/schema-display.tsx +473 -0
- package/template/base/ai-chat/src/components/ai-elements/shimmer.tsx +78 -0
- package/template/base/ai-chat/src/components/ai-elements/snippet.tsx +141 -0
- package/template/base/ai-chat/src/components/ai-elements/sources.tsx +78 -0
- package/template/base/ai-chat/src/components/ai-elements/speech-input.tsx +324 -0
- package/template/base/ai-chat/src/components/ai-elements/stack-trace.tsx +531 -0
- package/template/base/ai-chat/src/components/ai-elements/suggestion.tsx +55 -0
- package/template/base/ai-chat/src/components/ai-elements/task.tsx +88 -0
- package/template/base/ai-chat/src/components/ai-elements/terminal.tsx +277 -0
- package/template/base/ai-chat/src/components/ai-elements/test-results.tsx +497 -0
- package/template/base/ai-chat/src/components/ai-elements/tool.tsx +174 -0
- package/template/base/ai-chat/src/components/ai-elements/toolbar.tsx +17 -0
- package/template/base/ai-chat/src/components/ai-elements/transcription.tsx +126 -0
- package/template/base/ai-chat/src/components/ai-elements/voice-selector.tsx +525 -0
- package/template/base/ai-chat/src/components/ai-elements/web-preview.tsx +282 -0
- package/template/base/ai-chat/src/components/ui/accordion.tsx +66 -0
- package/template/base/ai-chat/src/components/ui/alert.tsx +66 -0
- package/template/base/ai-chat/src/components/ui/avatar.tsx +109 -0
- package/template/base/ai-chat/src/components/ui/badge.tsx +48 -0
- package/template/base/ai-chat/src/components/ui/button-group.tsx +83 -0
- package/template/base/ai-chat/src/components/ui/button.tsx +64 -0
- package/template/base/ai-chat/src/components/ui/card.tsx +92 -0
- package/template/base/ai-chat/src/components/ui/carousel.tsx +241 -0
- package/template/base/ai-chat/src/components/ui/collapsible.tsx +33 -0
- package/template/base/ai-chat/src/components/ui/command.tsx +184 -0
- package/template/base/ai-chat/src/components/ui/dialog.tsx +158 -0
- package/template/base/ai-chat/src/components/ui/dropdown-menu.tsx +257 -0
- package/template/base/ai-chat/src/components/ui/hover-card.tsx +44 -0
- package/template/base/ai-chat/src/components/ui/input-group.tsx +170 -0
- package/template/base/ai-chat/src/components/ui/input.tsx +21 -0
- package/template/base/ai-chat/src/components/ui/popover.tsx +89 -0
- package/template/base/ai-chat/src/components/ui/progress.tsx +31 -0
- package/template/base/ai-chat/src/components/ui/scroll-area.tsx +58 -0
- package/template/base/ai-chat/src/components/ui/select.tsx +190 -0
- package/template/base/ai-chat/src/components/ui/separator.tsx +28 -0
- package/template/base/ai-chat/src/components/ui/spinner.tsx +16 -0
- package/template/base/ai-chat/src/components/ui/switch.tsx +35 -0
- package/template/base/ai-chat/src/components/ui/tabs.tsx +91 -0
- package/template/base/ai-chat/src/components/ui/textarea.tsx +18 -0
- package/template/base/ai-chat/src/components/ui/tooltip.tsx +57 -0
- package/template/base/ai-chat/src/instant.perms.ts +34 -0
- package/template/base/ai-chat/src/instant.schema.ts +107 -0
- package/template/base/ai-chat/src/lib/adminDb.ts +8 -0
- package/template/base/ai-chat/src/lib/db.ts +8 -0
- package/template/base/ai-chat/src/lib/mockModel.ts +119 -0
- package/template/base/ai-chat/src/lib/utils.ts +6 -0
- package/template/base/ai-chat/tsconfig.json +33 -0
- package/template/base/bun-react/.env.example +2 -0
- package/template/base/bun-react/README.md +12 -0
- package/template/base/bun-react/_gitignore +34 -0
- package/template/base/bun-react/bun-env.d.ts +17 -0
- package/template/base/bun-react/bunfig.toml +4 -0
- package/template/base/bun-react/package.json +22 -0
- package/template/base/bun-react/src/App.tsx +168 -0
- package/template/base/bun-react/src/frontend.tsx +20 -0
- package/template/base/bun-react/src/getUnusedPort.ts +32 -0
- package/template/base/bun-react/src/index.css +25 -0
- package/template/base/bun-react/src/index.html +13 -0
- package/template/base/bun-react/src/index.ts +21 -0
- package/template/base/bun-react/src/instant.perms.ts +24 -0
- package/template/base/bun-react/src/instant.schema.ts +46 -0
- package/template/base/bun-react/src/lib/db.ts +8 -0
- package/template/base/bun-react/src/logo.svg +1 -0
- package/template/base/bun-react/tsconfig.json +36 -0
- package/template/base/expo/.env.example +2 -0
- package/template/base/expo/README.md +18 -0
- package/template/base/expo/_gitignore +41 -0
- package/template/base/expo/app/+not-found.tsx +16 -0
- package/template/base/expo/app/_layout.tsx +37 -0
- package/template/base/expo/app/index.tsx +64 -0
- package/template/base/expo/app.json +42 -0
- package/template/base/expo/assets/fonts/SpaceMono-Regular.ttf +0 -0
- package/template/base/expo/assets/images/adaptive-icon.png +0 -0
- package/template/base/expo/assets/images/favicon.png +0 -0
- package/template/base/expo/assets/images/icon.png +0 -0
- package/template/base/expo/assets/images/partial-react-logo.png +0 -0
- package/template/base/expo/assets/images/react-logo.png +0 -0
- package/template/base/expo/assets/images/react-logo@2x.png +0 -0
- package/template/base/expo/assets/images/react-logo@3x.png +0 -0
- package/template/base/expo/assets/images/splash-icon.png +0 -0
- package/template/base/expo/babel.config.js +12 -0
- package/template/base/expo/constants/Colors.ts +26 -0
- package/template/base/expo/eslint.config.js +10 -0
- package/template/base/expo/global.css +3 -0
- package/template/base/expo/hooks/useColorScheme.ts +1 -0
- package/template/base/expo/hooks/useColorScheme.web.ts +21 -0
- package/template/base/expo/hooks/useThemeColor.ts +21 -0
- package/template/base/expo/instant.perms.ts +24 -0
- package/template/base/expo/instant.schema.ts +44 -0
- package/template/base/expo/lib/db.ts +7 -0
- package/template/base/expo/metro.config.js +6 -0
- package/template/base/expo/nativewind-env.d.ts +1 -0
- package/template/base/expo/package.json +57 -0
- package/template/base/expo/scripts/reset-project.js +112 -0
- package/template/base/expo/tailwind.config.js +9 -0
- package/template/base/expo/tsconfig.json +18 -0
- package/template/base/next-js-app-dir/.env.example +2 -0
- package/template/base/next-js-app-dir/README.md +18 -0
- package/template/base/next-js-app-dir/_gitignore +41 -0
- package/template/base/next-js-app-dir/next.config.ts +7 -0
- package/template/base/next-js-app-dir/package.json +27 -0
- package/template/base/next-js-app-dir/postcss.config.mjs +5 -0
- package/template/base/next-js-app-dir/public/file.svg +1 -0
- package/template/base/next-js-app-dir/public/globe.svg +1 -0
- package/template/base/next-js-app-dir/public/next.svg +1 -0
- package/template/base/next-js-app-dir/public/vercel.svg +1 -0
- package/template/base/next-js-app-dir/public/window.svg +1 -0
- package/template/base/next-js-app-dir/src/app/favicon.ico +0 -0
- package/template/base/next-js-app-dir/src/app/globals.css +26 -0
- package/template/base/next-js-app-dir/src/app/layout.tsx +34 -0
- package/template/base/next-js-app-dir/src/app/page.tsx +169 -0
- package/template/base/next-js-app-dir/src/instant.perms.ts +24 -0
- package/template/base/next-js-app-dir/src/instant.schema.ts +50 -0
- package/template/base/next-js-app-dir/src/lib/db.ts +8 -0
- package/template/base/next-js-app-dir/tsconfig.json +41 -0
- package/template/base/solidjs-vite/README.md +15 -0
- package/template/base/solidjs-vite/_gitignore +25 -0
- package/template/base/solidjs-vite/index.html +15 -0
- package/template/base/solidjs-vite/package.json +25 -0
- package/template/base/solidjs-vite/src/App.tsx +171 -0
- package/template/base/solidjs-vite/src/index.css +25 -0
- package/template/base/solidjs-vite/src/index.tsx +16 -0
- package/template/base/solidjs-vite/src/instant.perms.ts +24 -0
- package/template/base/solidjs-vite/src/instant.schema.ts +46 -0
- package/template/base/solidjs-vite/src/lib/db.ts +8 -0
- package/template/base/solidjs-vite/tsconfig.json +20 -0
- package/template/base/solidjs-vite/vite.config.ts +11 -0
- package/template/base/sveltekit/README.md +15 -0
- package/template/base/sveltekit/_gitignore +26 -0
- package/template/base/sveltekit/package.json +25 -0
- package/template/base/sveltekit/src/app.css +25 -0
- package/template/base/sveltekit/src/app.html +11 -0
- package/template/base/sveltekit/src/instant.perms.ts +24 -0
- package/template/base/sveltekit/src/instant.schema.ts +46 -0
- package/template/base/sveltekit/src/lib/db.ts +8 -0
- package/template/base/sveltekit/src/routes/+layout.svelte +6 -0
- package/template/base/sveltekit/src/routes/+page.svelte +236 -0
- package/template/base/sveltekit/src/routes/+page.ts +1 -0
- package/template/base/sveltekit/svelte.config.js +10 -0
- package/template/base/sveltekit/tsconfig.json +14 -0
- package/template/base/sveltekit/vite.config.ts +7 -0
- package/template/base/tanstack-start/.cta.json +12 -0
- package/template/base/tanstack-start/README.md +17 -0
- package/template/base/tanstack-start/_gitignore +13 -0
- package/template/base/tanstack-start/package.json +43 -0
- package/template/base/tanstack-start/public/favicon.ico +0 -0
- package/template/base/tanstack-start/public/logo192.png +0 -0
- package/template/base/tanstack-start/public/logo512.png +0 -0
- package/template/base/tanstack-start/public/manifest.json +25 -0
- package/template/base/tanstack-start/public/robots.txt +3 -0
- package/template/base/tanstack-start/public/tanstack-circle-logo.png +0 -0
- package/template/base/tanstack-start/public/tanstack-word-logo-white.svg +1 -0
- package/template/base/tanstack-start/src/components/Header.tsx +21 -0
- package/template/base/tanstack-start/src/instant.perms.ts +24 -0
- package/template/base/tanstack-start/src/instant.schema.ts +50 -0
- package/template/base/tanstack-start/src/lib/adminDb.ts +12 -0
- package/template/base/tanstack-start/src/lib/db.ts +9 -0
- package/template/base/tanstack-start/src/logo.svg +12 -0
- package/template/base/tanstack-start/src/routeTree.gen.ts +104 -0
- package/template/base/tanstack-start/src/router.tsx +22 -0
- package/template/base/tanstack-start/src/routes/__root.tsx +70 -0
- package/template/base/tanstack-start/src/routes/api/instant.ts +18 -0
- package/template/base/tanstack-start/src/routes/index.tsx +238 -0
- package/template/base/tanstack-start/src/routes/login.tsx +140 -0
- package/template/base/tanstack-start/src/styles.css +18 -0
- package/template/base/tanstack-start/tsconfig.json +28 -0
- package/template/base/tanstack-start/vite.config.ts +33 -0
- package/template/base/tanstack-start-with-tanstack-query/.cta.json +12 -0
- package/template/base/tanstack-start-with-tanstack-query/README.md +18 -0
- package/template/base/tanstack-start-with-tanstack-query/_gitignore +13 -0
- package/template/base/tanstack-start-with-tanstack-query/package.json +46 -0
- package/template/base/tanstack-start-with-tanstack-query/public/favicon.ico +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/logo192.png +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/logo512.png +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/manifest.json +25 -0
- package/template/base/tanstack-start-with-tanstack-query/public/robots.txt +3 -0
- package/template/base/tanstack-start-with-tanstack-query/public/tanstack-circle-logo.png +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/tanstack-word-logo-white.svg +1 -0
- package/template/base/tanstack-start-with-tanstack-query/src/components/Header.tsx +21 -0
- package/template/base/tanstack-start-with-tanstack-query/src/instant.perms.ts +24 -0
- package/template/base/tanstack-start-with-tanstack-query/src/instant.schema.ts +50 -0
- package/template/base/tanstack-start-with-tanstack-query/src/lib/adminDb.ts +9 -0
- package/template/base/tanstack-start-with-tanstack-query/src/lib/db.ts +11 -0
- package/template/base/tanstack-start-with-tanstack-query/src/lib/instantQuery.ts +93 -0
- package/template/base/tanstack-start-with-tanstack-query/src/logo.svg +12 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routeTree.gen.ts +104 -0
- package/template/base/tanstack-start-with-tanstack-query/src/router.tsx +108 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/__root.tsx +76 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/api/instant.ts +16 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/index.tsx +231 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/login.tsx +140 -0
- package/template/base/tanstack-start-with-tanstack-query/src/styles.css +17 -0
- package/template/base/tanstack-start-with-tanstack-query/tsconfig.json +28 -0
- package/template/base/tanstack-start-with-tanstack-query/vite.config.ts +33 -0
- package/template/base/vite-react/README.md +16 -0
- package/template/base/vite-react/_gitignore +26 -0
- package/template/base/vite-react/eslint.config.js +23 -0
- package/template/base/vite-react/index.html +13 -0
- package/template/base/vite-react/package.json +35 -0
- package/template/base/vite-react/public/favicon.svg +1 -0
- package/template/base/vite-react/src/App.tsx +167 -0
- package/template/base/vite-react/src/index.css +1 -0
- package/template/base/vite-react/src/instant.perms.ts +24 -0
- package/template/base/vite-react/src/instant.schema.ts +51 -0
- package/template/base/vite-react/src/lib/db.ts +8 -0
- package/template/base/vite-react/src/main.tsx +10 -0
- package/template/base/vite-react/tsconfig.app.json +25 -0
- package/template/base/vite-react/tsconfig.json +7 -0
- package/template/base/vite-react/tsconfig.node.json +24 -0
- package/template/base/vite-react/vite.config.ts +8 -0
- package/template/base/vite-vanilla/.env.example +2 -0
- package/template/base/vite-vanilla/README.md +17 -0
- package/template/base/vite-vanilla/_gitignore +25 -0
- package/template/base/vite-vanilla/index.html +13 -0
- package/template/base/vite-vanilla/package.json +20 -0
- package/template/base/vite-vanilla/pnpm-lock.yaml +707 -0
- package/template/base/vite-vanilla/public/vite.svg +1 -0
- package/template/base/vite-vanilla/src/instant.perms.ts +24 -0
- package/template/base/vite-vanilla/src/instant.schema.ts +50 -0
- package/template/base/vite-vanilla/src/lib/db.ts +11 -0
- package/template/base/vite-vanilla/src/main.ts +242 -0
- package/template/base/vite-vanilla/src/style.css +96 -0
- package/template/base/vite-vanilla/src/typescript.svg +1 -0
- package/template/base/vite-vanilla/src/vite-env.d.ts +1 -0
- package/template/base/vite-vanilla/tsconfig.json +24 -0
- package/template/base/vue-vite/README.md +15 -0
- package/template/base/vue-vite/_gitignore +43 -0
- package/template/base/vue-vite/env.d.ts +1 -0
- package/template/base/vue-vite/index.html +12 -0
- package/template/base/vue-vite/package.json +34 -0
- package/template/base/vue-vite/src/App.vue +238 -0
- package/template/base/vue-vite/src/assets/main.css +25 -0
- package/template/base/vue-vite/src/instant.perms.ts +24 -0
- package/template/base/vue-vite/src/instant.schema.ts +46 -0
- package/template/base/vue-vite/src/lib/db.ts +8 -0
- package/template/base/vue-vite/src/main.ts +6 -0
- package/template/base/vue-vite/tsconfig.app.json +15 -0
- package/template/base/vue-vite/tsconfig.json +11 -0
- package/template/base/vue-vite/tsconfig.node.json +27 -0
- package/template/base/vue-vite/vite.config.ts +16 -0
- package/template/rules/AGENTS.md +450 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { LucideIcon } from 'lucide-react';
|
|
4
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
|
7
|
+
import { Badge } from '@/components/ui/badge';
|
|
8
|
+
import {
|
|
9
|
+
Collapsible,
|
|
10
|
+
CollapsibleContent,
|
|
11
|
+
CollapsibleTrigger,
|
|
12
|
+
} from '@/components/ui/collapsible';
|
|
13
|
+
import { cn } from '@/lib/utils';
|
|
14
|
+
import { BrainIcon, ChevronDownIcon, DotIcon } from 'lucide-react';
|
|
15
|
+
import { createContext, memo, useContext, useMemo } from 'react';
|
|
16
|
+
|
|
17
|
+
interface ChainOfThoughtContextValue {
|
|
18
|
+
isOpen: boolean;
|
|
19
|
+
setIsOpen: (open: boolean) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const ChainOfThoughtContext = createContext<ChainOfThoughtContextValue | null>(
|
|
23
|
+
null,
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const useChainOfThought = () => {
|
|
27
|
+
const context = useContext(ChainOfThoughtContext);
|
|
28
|
+
if (!context) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
'ChainOfThought components must be used within ChainOfThought',
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
return context;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type ChainOfThoughtProps = ComponentProps<'div'> & {
|
|
37
|
+
open?: boolean;
|
|
38
|
+
defaultOpen?: boolean;
|
|
39
|
+
onOpenChange?: (open: boolean) => void;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const ChainOfThought = memo(
|
|
43
|
+
({
|
|
44
|
+
className,
|
|
45
|
+
open,
|
|
46
|
+
defaultOpen = false,
|
|
47
|
+
onOpenChange,
|
|
48
|
+
children,
|
|
49
|
+
...props
|
|
50
|
+
}: ChainOfThoughtProps) => {
|
|
51
|
+
const [isOpen, setIsOpen] = useControllableState({
|
|
52
|
+
defaultProp: defaultOpen,
|
|
53
|
+
onChange: onOpenChange,
|
|
54
|
+
prop: open,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const chainOfThoughtContext = useMemo(
|
|
58
|
+
() => ({ isOpen, setIsOpen }),
|
|
59
|
+
[isOpen, setIsOpen],
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<ChainOfThoughtContext.Provider value={chainOfThoughtContext}>
|
|
64
|
+
<div className={cn('not-prose w-full space-y-4', className)} {...props}>
|
|
65
|
+
{children}
|
|
66
|
+
</div>
|
|
67
|
+
</ChainOfThoughtContext.Provider>
|
|
68
|
+
);
|
|
69
|
+
},
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
export type ChainOfThoughtHeaderProps = ComponentProps<
|
|
73
|
+
typeof CollapsibleTrigger
|
|
74
|
+
>;
|
|
75
|
+
|
|
76
|
+
export const ChainOfThoughtHeader = memo(
|
|
77
|
+
({ className, children, ...props }: ChainOfThoughtHeaderProps) => {
|
|
78
|
+
const { isOpen, setIsOpen } = useChainOfThought();
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Collapsible onOpenChange={setIsOpen} open={isOpen}>
|
|
82
|
+
<CollapsibleTrigger
|
|
83
|
+
className={cn(
|
|
84
|
+
'text-muted-foreground hover:text-foreground flex w-full items-center gap-2 text-sm transition-colors',
|
|
85
|
+
className,
|
|
86
|
+
)}
|
|
87
|
+
{...props}
|
|
88
|
+
>
|
|
89
|
+
<BrainIcon className="size-4" />
|
|
90
|
+
<span className="flex-1 text-left">
|
|
91
|
+
{children ?? 'Chain of Thought'}
|
|
92
|
+
</span>
|
|
93
|
+
<ChevronDownIcon
|
|
94
|
+
className={cn(
|
|
95
|
+
'size-4 transition-transform',
|
|
96
|
+
isOpen ? 'rotate-180' : 'rotate-0',
|
|
97
|
+
)}
|
|
98
|
+
/>
|
|
99
|
+
</CollapsibleTrigger>
|
|
100
|
+
</Collapsible>
|
|
101
|
+
);
|
|
102
|
+
},
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
export type ChainOfThoughtStepProps = ComponentProps<'div'> & {
|
|
106
|
+
icon?: LucideIcon;
|
|
107
|
+
label: ReactNode;
|
|
108
|
+
description?: ReactNode;
|
|
109
|
+
status?: 'complete' | 'active' | 'pending';
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const stepStatusStyles = {
|
|
113
|
+
active: 'text-foreground',
|
|
114
|
+
complete: 'text-muted-foreground',
|
|
115
|
+
pending: 'text-muted-foreground/50',
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const ChainOfThoughtStep = memo(
|
|
119
|
+
({
|
|
120
|
+
className,
|
|
121
|
+
icon: Icon = DotIcon,
|
|
122
|
+
label,
|
|
123
|
+
description,
|
|
124
|
+
status = 'complete',
|
|
125
|
+
children,
|
|
126
|
+
...props
|
|
127
|
+
}: ChainOfThoughtStepProps) => (
|
|
128
|
+
<div
|
|
129
|
+
className={cn(
|
|
130
|
+
'flex gap-2 text-sm',
|
|
131
|
+
stepStatusStyles[status],
|
|
132
|
+
'fade-in-0 slide-in-from-top-2 animate-in',
|
|
133
|
+
className,
|
|
134
|
+
)}
|
|
135
|
+
{...props}
|
|
136
|
+
>
|
|
137
|
+
<div className="relative mt-0.5">
|
|
138
|
+
<Icon className="size-4" />
|
|
139
|
+
<div className="bg-border absolute top-7 bottom-0 left-1/2 -mx-px w-px" />
|
|
140
|
+
</div>
|
|
141
|
+
<div className="flex-1 space-y-2 overflow-hidden">
|
|
142
|
+
<div>{label}</div>
|
|
143
|
+
{description && (
|
|
144
|
+
<div className="text-muted-foreground text-xs">{description}</div>
|
|
145
|
+
)}
|
|
146
|
+
{children}
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
),
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
export type ChainOfThoughtSearchResultsProps = ComponentProps<'div'>;
|
|
153
|
+
|
|
154
|
+
export const ChainOfThoughtSearchResults = memo(
|
|
155
|
+
({ className, ...props }: ChainOfThoughtSearchResultsProps) => (
|
|
156
|
+
<div
|
|
157
|
+
className={cn('flex flex-wrap items-center gap-2', className)}
|
|
158
|
+
{...props}
|
|
159
|
+
/>
|
|
160
|
+
),
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
export type ChainOfThoughtSearchResultProps = ComponentProps<typeof Badge>;
|
|
164
|
+
|
|
165
|
+
export const ChainOfThoughtSearchResult = memo(
|
|
166
|
+
({ className, children, ...props }: ChainOfThoughtSearchResultProps) => (
|
|
167
|
+
<Badge
|
|
168
|
+
className={cn('gap-1 px-2 py-0.5 text-xs font-normal', className)}
|
|
169
|
+
variant="secondary"
|
|
170
|
+
{...props}
|
|
171
|
+
>
|
|
172
|
+
{children}
|
|
173
|
+
</Badge>
|
|
174
|
+
),
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
export type ChainOfThoughtContentProps = ComponentProps<
|
|
178
|
+
typeof CollapsibleContent
|
|
179
|
+
>;
|
|
180
|
+
|
|
181
|
+
export const ChainOfThoughtContent = memo(
|
|
182
|
+
({ className, children, ...props }: ChainOfThoughtContentProps) => {
|
|
183
|
+
const { isOpen } = useChainOfThought();
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<Collapsible open={isOpen}>
|
|
187
|
+
<CollapsibleContent
|
|
188
|
+
className={cn(
|
|
189
|
+
'mt-2 space-y-3',
|
|
190
|
+
'data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground data-[state=closed]:animate-out data-[state=open]:animate-in outline-none',
|
|
191
|
+
className,
|
|
192
|
+
)}
|
|
193
|
+
{...props}
|
|
194
|
+
>
|
|
195
|
+
{children}
|
|
196
|
+
</CollapsibleContent>
|
|
197
|
+
</Collapsible>
|
|
198
|
+
);
|
|
199
|
+
},
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
export type ChainOfThoughtImageProps = ComponentProps<'div'> & {
|
|
203
|
+
caption?: string;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export const ChainOfThoughtImage = memo(
|
|
207
|
+
({ className, children, caption, ...props }: ChainOfThoughtImageProps) => (
|
|
208
|
+
<div className={cn('mt-2 space-y-2', className)} {...props}>
|
|
209
|
+
<div className="bg-muted relative flex max-h-[22rem] items-center justify-center overflow-hidden rounded-lg p-3">
|
|
210
|
+
{children}
|
|
211
|
+
</div>
|
|
212
|
+
{caption && <p className="text-muted-foreground text-xs">{caption}</p>}
|
|
213
|
+
</div>
|
|
214
|
+
),
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
ChainOfThought.displayName = 'ChainOfThought';
|
|
218
|
+
ChainOfThoughtHeader.displayName = 'ChainOfThoughtHeader';
|
|
219
|
+
ChainOfThoughtStep.displayName = 'ChainOfThoughtStep';
|
|
220
|
+
ChainOfThoughtSearchResults.displayName = 'ChainOfThoughtSearchResults';
|
|
221
|
+
ChainOfThoughtSearchResult.displayName = 'ChainOfThoughtSearchResult';
|
|
222
|
+
ChainOfThoughtContent.displayName = 'ChainOfThoughtContent';
|
|
223
|
+
ChainOfThoughtImage.displayName = 'ChainOfThoughtImage';
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { LucideProps } from 'lucide-react';
|
|
4
|
+
import type { ComponentProps, HTMLAttributes } from 'react';
|
|
5
|
+
|
|
6
|
+
import { Button } from '@/components/ui/button';
|
|
7
|
+
import { Separator } from '@/components/ui/separator';
|
|
8
|
+
import {
|
|
9
|
+
Tooltip,
|
|
10
|
+
TooltipContent,
|
|
11
|
+
TooltipTrigger,
|
|
12
|
+
} from '@/components/ui/tooltip';
|
|
13
|
+
import { cn } from '@/lib/utils';
|
|
14
|
+
import { BookmarkIcon } from 'lucide-react';
|
|
15
|
+
|
|
16
|
+
export type CheckpointProps = HTMLAttributes<HTMLDivElement>;
|
|
17
|
+
|
|
18
|
+
export const Checkpoint = ({
|
|
19
|
+
className,
|
|
20
|
+
children,
|
|
21
|
+
...props
|
|
22
|
+
}: CheckpointProps) => (
|
|
23
|
+
<div
|
|
24
|
+
className={cn(
|
|
25
|
+
'text-muted-foreground flex items-center gap-0.5 overflow-hidden',
|
|
26
|
+
className,
|
|
27
|
+
)}
|
|
28
|
+
{...props}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
<Separator />
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
export type CheckpointIconProps = LucideProps;
|
|
36
|
+
|
|
37
|
+
export const CheckpointIcon = ({
|
|
38
|
+
className,
|
|
39
|
+
children,
|
|
40
|
+
...props
|
|
41
|
+
}: CheckpointIconProps) =>
|
|
42
|
+
children ?? (
|
|
43
|
+
<BookmarkIcon className={cn('size-4 shrink-0', className)} {...props} />
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
export type CheckpointTriggerProps = ComponentProps<typeof Button> & {
|
|
47
|
+
tooltip?: string;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const CheckpointTrigger = ({
|
|
51
|
+
children,
|
|
52
|
+
variant = 'ghost',
|
|
53
|
+
size = 'sm',
|
|
54
|
+
tooltip,
|
|
55
|
+
...props
|
|
56
|
+
}: CheckpointTriggerProps) =>
|
|
57
|
+
tooltip ? (
|
|
58
|
+
<Tooltip>
|
|
59
|
+
<TooltipTrigger asChild>
|
|
60
|
+
<Button size={size} type="button" variant={variant} {...props}>
|
|
61
|
+
{children}
|
|
62
|
+
</Button>
|
|
63
|
+
</TooltipTrigger>
|
|
64
|
+
<TooltipContent align="start" side="bottom">
|
|
65
|
+
{tooltip}
|
|
66
|
+
</TooltipContent>
|
|
67
|
+
</Tooltip>
|
|
68
|
+
) : (
|
|
69
|
+
<Button size={size} type="button" variant={variant} {...props}>
|
|
70
|
+
{children}
|
|
71
|
+
</Button>
|
|
72
|
+
);
|