create-sidekick-app 0.0.1 → 2.0.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.
Files changed (299) hide show
  1. package/LICENSE.md +202 -0
  2. package/NOTICE +27 -0
  3. package/README.md +29 -2
  4. package/dist/index.js +59 -0
  5. package/package.json +65 -4
  6. package/template/base/ai-chat/.env.example +6 -0
  7. package/template/base/ai-chat/.prettierignore +2 -0
  8. package/template/base/ai-chat/.prettierrc.json +5 -0
  9. package/template/base/ai-chat/README.md +38 -0
  10. package/template/base/ai-chat/_gitignore +41 -0
  11. package/template/base/ai-chat/components.json +23 -0
  12. package/template/base/ai-chat/next.config.ts +5 -0
  13. package/template/base/ai-chat/package.json +61 -0
  14. package/template/base/ai-chat/postcss.config.mjs +5 -0
  15. package/template/base/ai-chat/src/app/api/chat/route.ts +141 -0
  16. package/template/base/ai-chat/src/app/api/instant/route.ts +5 -0
  17. package/template/base/ai-chat/src/app/chat/[id]/page.tsx +20 -0
  18. package/template/base/ai-chat/src/app/globals.css +124 -0
  19. package/template/base/ai-chat/src/app/layout.tsx +34 -0
  20. package/template/base/ai-chat/src/app/page.tsx +6 -0
  21. package/template/base/ai-chat/src/components/AuthGate.tsx +15 -0
  22. package/template/base/ai-chat/src/components/Chat.tsx +228 -0
  23. package/template/base/ai-chat/src/components/InstantProvider.tsx +18 -0
  24. package/template/base/ai-chat/src/components/Login.tsx +163 -0
  25. package/template/base/ai-chat/src/components/Sidebar.tsx +100 -0
  26. package/template/base/ai-chat/src/components/ai-elements/agent.tsx +142 -0
  27. package/template/base/ai-chat/src/components/ai-elements/artifact.tsx +149 -0
  28. package/template/base/ai-chat/src/components/ai-elements/attachments.tsx +427 -0
  29. package/template/base/ai-chat/src/components/ai-elements/audio-player.tsx +229 -0
  30. package/template/base/ai-chat/src/components/ai-elements/canvas.tsx +26 -0
  31. package/template/base/ai-chat/src/components/ai-elements/chain-of-thought.tsx +223 -0
  32. package/template/base/ai-chat/src/components/ai-elements/checkpoint.tsx +72 -0
  33. package/template/base/ai-chat/src/components/ai-elements/code-block.tsx +556 -0
  34. package/template/base/ai-chat/src/components/ai-elements/commit.tsx +449 -0
  35. package/template/base/ai-chat/src/components/ai-elements/confirmation.tsx +173 -0
  36. package/template/base/ai-chat/src/components/ai-elements/connection.tsx +28 -0
  37. package/template/base/ai-chat/src/components/ai-elements/context.tsx +410 -0
  38. package/template/base/ai-chat/src/components/ai-elements/controls.tsx +19 -0
  39. package/template/base/ai-chat/src/components/ai-elements/conversation.tsx +167 -0
  40. package/template/base/ai-chat/src/components/ai-elements/edge.tsx +144 -0
  41. package/template/base/ai-chat/src/components/ai-elements/environment-variables.tsx +325 -0
  42. package/template/base/ai-chat/src/components/ai-elements/file-tree.tsx +298 -0
  43. package/template/base/ai-chat/src/components/ai-elements/image.tsx +25 -0
  44. package/template/base/ai-chat/src/components/ai-elements/inline-citation.tsx +294 -0
  45. package/template/base/ai-chat/src/components/ai-elements/jsx-preview.tsx +250 -0
  46. package/template/base/ai-chat/src/components/ai-elements/message.tsx +356 -0
  47. package/template/base/ai-chat/src/components/ai-elements/mic-selector.tsx +372 -0
  48. package/template/base/ai-chat/src/components/ai-elements/model-selector.tsx +214 -0
  49. package/template/base/ai-chat/src/components/ai-elements/node.tsx +72 -0
  50. package/template/base/ai-chat/src/components/ai-elements/open-in-chat.tsx +367 -0
  51. package/template/base/ai-chat/src/components/ai-elements/package-info.tsx +235 -0
  52. package/template/base/ai-chat/src/components/ai-elements/panel.tsx +16 -0
  53. package/template/base/ai-chat/src/components/ai-elements/persona.tsx +280 -0
  54. package/template/base/ai-chat/src/components/ai-elements/plan.tsx +144 -0
  55. package/template/base/ai-chat/src/components/ai-elements/prompt-input.tsx +1341 -0
  56. package/template/base/ai-chat/src/components/ai-elements/queue.tsx +275 -0
  57. package/template/base/ai-chat/src/components/ai-elements/reasoning.tsx +229 -0
  58. package/template/base/ai-chat/src/components/ai-elements/sandbox.tsx +128 -0
  59. package/template/base/ai-chat/src/components/ai-elements/schema-display.tsx +473 -0
  60. package/template/base/ai-chat/src/components/ai-elements/shimmer.tsx +78 -0
  61. package/template/base/ai-chat/src/components/ai-elements/snippet.tsx +141 -0
  62. package/template/base/ai-chat/src/components/ai-elements/sources.tsx +78 -0
  63. package/template/base/ai-chat/src/components/ai-elements/speech-input.tsx +324 -0
  64. package/template/base/ai-chat/src/components/ai-elements/stack-trace.tsx +531 -0
  65. package/template/base/ai-chat/src/components/ai-elements/suggestion.tsx +55 -0
  66. package/template/base/ai-chat/src/components/ai-elements/task.tsx +88 -0
  67. package/template/base/ai-chat/src/components/ai-elements/terminal.tsx +277 -0
  68. package/template/base/ai-chat/src/components/ai-elements/test-results.tsx +497 -0
  69. package/template/base/ai-chat/src/components/ai-elements/tool.tsx +174 -0
  70. package/template/base/ai-chat/src/components/ai-elements/toolbar.tsx +17 -0
  71. package/template/base/ai-chat/src/components/ai-elements/transcription.tsx +126 -0
  72. package/template/base/ai-chat/src/components/ai-elements/voice-selector.tsx +525 -0
  73. package/template/base/ai-chat/src/components/ai-elements/web-preview.tsx +282 -0
  74. package/template/base/ai-chat/src/components/ui/accordion.tsx +66 -0
  75. package/template/base/ai-chat/src/components/ui/alert.tsx +66 -0
  76. package/template/base/ai-chat/src/components/ui/avatar.tsx +109 -0
  77. package/template/base/ai-chat/src/components/ui/badge.tsx +48 -0
  78. package/template/base/ai-chat/src/components/ui/button-group.tsx +83 -0
  79. package/template/base/ai-chat/src/components/ui/button.tsx +64 -0
  80. package/template/base/ai-chat/src/components/ui/card.tsx +92 -0
  81. package/template/base/ai-chat/src/components/ui/carousel.tsx +241 -0
  82. package/template/base/ai-chat/src/components/ui/collapsible.tsx +33 -0
  83. package/template/base/ai-chat/src/components/ui/command.tsx +184 -0
  84. package/template/base/ai-chat/src/components/ui/dialog.tsx +158 -0
  85. package/template/base/ai-chat/src/components/ui/dropdown-menu.tsx +257 -0
  86. package/template/base/ai-chat/src/components/ui/hover-card.tsx +44 -0
  87. package/template/base/ai-chat/src/components/ui/input-group.tsx +170 -0
  88. package/template/base/ai-chat/src/components/ui/input.tsx +21 -0
  89. package/template/base/ai-chat/src/components/ui/popover.tsx +89 -0
  90. package/template/base/ai-chat/src/components/ui/progress.tsx +31 -0
  91. package/template/base/ai-chat/src/components/ui/scroll-area.tsx +58 -0
  92. package/template/base/ai-chat/src/components/ui/select.tsx +190 -0
  93. package/template/base/ai-chat/src/components/ui/separator.tsx +28 -0
  94. package/template/base/ai-chat/src/components/ui/spinner.tsx +16 -0
  95. package/template/base/ai-chat/src/components/ui/switch.tsx +35 -0
  96. package/template/base/ai-chat/src/components/ui/tabs.tsx +91 -0
  97. package/template/base/ai-chat/src/components/ui/textarea.tsx +18 -0
  98. package/template/base/ai-chat/src/components/ui/tooltip.tsx +57 -0
  99. package/template/base/ai-chat/src/instant.perms.ts +34 -0
  100. package/template/base/ai-chat/src/instant.schema.ts +107 -0
  101. package/template/base/ai-chat/src/lib/adminDb.ts +8 -0
  102. package/template/base/ai-chat/src/lib/db.ts +8 -0
  103. package/template/base/ai-chat/src/lib/mockModel.ts +119 -0
  104. package/template/base/ai-chat/src/lib/utils.ts +6 -0
  105. package/template/base/ai-chat/tsconfig.json +33 -0
  106. package/template/base/bun-react/.env.example +2 -0
  107. package/template/base/bun-react/README.md +12 -0
  108. package/template/base/bun-react/_gitignore +34 -0
  109. package/template/base/bun-react/bun-env.d.ts +17 -0
  110. package/template/base/bun-react/bunfig.toml +4 -0
  111. package/template/base/bun-react/package.json +22 -0
  112. package/template/base/bun-react/src/App.tsx +168 -0
  113. package/template/base/bun-react/src/frontend.tsx +20 -0
  114. package/template/base/bun-react/src/getUnusedPort.ts +32 -0
  115. package/template/base/bun-react/src/index.css +25 -0
  116. package/template/base/bun-react/src/index.html +13 -0
  117. package/template/base/bun-react/src/index.ts +21 -0
  118. package/template/base/bun-react/src/instant.perms.ts +24 -0
  119. package/template/base/bun-react/src/instant.schema.ts +46 -0
  120. package/template/base/bun-react/src/lib/db.ts +8 -0
  121. package/template/base/bun-react/src/logo.svg +1 -0
  122. package/template/base/bun-react/tsconfig.json +36 -0
  123. package/template/base/expo/.env.example +2 -0
  124. package/template/base/expo/README.md +18 -0
  125. package/template/base/expo/_gitignore +41 -0
  126. package/template/base/expo/app/+not-found.tsx +16 -0
  127. package/template/base/expo/app/_layout.tsx +37 -0
  128. package/template/base/expo/app/index.tsx +64 -0
  129. package/template/base/expo/app.json +42 -0
  130. package/template/base/expo/assets/fonts/SpaceMono-Regular.ttf +0 -0
  131. package/template/base/expo/assets/images/adaptive-icon.png +0 -0
  132. package/template/base/expo/assets/images/favicon.png +0 -0
  133. package/template/base/expo/assets/images/icon.png +0 -0
  134. package/template/base/expo/assets/images/partial-react-logo.png +0 -0
  135. package/template/base/expo/assets/images/react-logo.png +0 -0
  136. package/template/base/expo/assets/images/react-logo@2x.png +0 -0
  137. package/template/base/expo/assets/images/react-logo@3x.png +0 -0
  138. package/template/base/expo/assets/images/splash-icon.png +0 -0
  139. package/template/base/expo/babel.config.js +12 -0
  140. package/template/base/expo/constants/Colors.ts +26 -0
  141. package/template/base/expo/eslint.config.js +10 -0
  142. package/template/base/expo/global.css +3 -0
  143. package/template/base/expo/hooks/useColorScheme.ts +1 -0
  144. package/template/base/expo/hooks/useColorScheme.web.ts +21 -0
  145. package/template/base/expo/hooks/useThemeColor.ts +21 -0
  146. package/template/base/expo/instant.perms.ts +24 -0
  147. package/template/base/expo/instant.schema.ts +44 -0
  148. package/template/base/expo/lib/db.ts +7 -0
  149. package/template/base/expo/metro.config.js +6 -0
  150. package/template/base/expo/nativewind-env.d.ts +1 -0
  151. package/template/base/expo/package.json +57 -0
  152. package/template/base/expo/scripts/reset-project.js +112 -0
  153. package/template/base/expo/tailwind.config.js +9 -0
  154. package/template/base/expo/tsconfig.json +18 -0
  155. package/template/base/next-js-app-dir/.env.example +2 -0
  156. package/template/base/next-js-app-dir/README.md +18 -0
  157. package/template/base/next-js-app-dir/_gitignore +41 -0
  158. package/template/base/next-js-app-dir/next.config.ts +7 -0
  159. package/template/base/next-js-app-dir/package.json +27 -0
  160. package/template/base/next-js-app-dir/postcss.config.mjs +5 -0
  161. package/template/base/next-js-app-dir/public/file.svg +1 -0
  162. package/template/base/next-js-app-dir/public/globe.svg +1 -0
  163. package/template/base/next-js-app-dir/public/next.svg +1 -0
  164. package/template/base/next-js-app-dir/public/vercel.svg +1 -0
  165. package/template/base/next-js-app-dir/public/window.svg +1 -0
  166. package/template/base/next-js-app-dir/src/app/favicon.ico +0 -0
  167. package/template/base/next-js-app-dir/src/app/globals.css +26 -0
  168. package/template/base/next-js-app-dir/src/app/layout.tsx +34 -0
  169. package/template/base/next-js-app-dir/src/app/page.tsx +169 -0
  170. package/template/base/next-js-app-dir/src/instant.perms.ts +24 -0
  171. package/template/base/next-js-app-dir/src/instant.schema.ts +50 -0
  172. package/template/base/next-js-app-dir/src/lib/db.ts +8 -0
  173. package/template/base/next-js-app-dir/tsconfig.json +41 -0
  174. package/template/base/solidjs-vite/README.md +15 -0
  175. package/template/base/solidjs-vite/_gitignore +25 -0
  176. package/template/base/solidjs-vite/index.html +15 -0
  177. package/template/base/solidjs-vite/package.json +25 -0
  178. package/template/base/solidjs-vite/src/App.tsx +171 -0
  179. package/template/base/solidjs-vite/src/index.css +25 -0
  180. package/template/base/solidjs-vite/src/index.tsx +16 -0
  181. package/template/base/solidjs-vite/src/instant.perms.ts +24 -0
  182. package/template/base/solidjs-vite/src/instant.schema.ts +46 -0
  183. package/template/base/solidjs-vite/src/lib/db.ts +8 -0
  184. package/template/base/solidjs-vite/tsconfig.json +20 -0
  185. package/template/base/solidjs-vite/vite.config.ts +11 -0
  186. package/template/base/sveltekit/README.md +15 -0
  187. package/template/base/sveltekit/_gitignore +26 -0
  188. package/template/base/sveltekit/package.json +25 -0
  189. package/template/base/sveltekit/src/app.css +25 -0
  190. package/template/base/sveltekit/src/app.html +11 -0
  191. package/template/base/sveltekit/src/instant.perms.ts +24 -0
  192. package/template/base/sveltekit/src/instant.schema.ts +46 -0
  193. package/template/base/sveltekit/src/lib/db.ts +8 -0
  194. package/template/base/sveltekit/src/routes/+layout.svelte +6 -0
  195. package/template/base/sveltekit/src/routes/+page.svelte +236 -0
  196. package/template/base/sveltekit/src/routes/+page.ts +1 -0
  197. package/template/base/sveltekit/svelte.config.js +10 -0
  198. package/template/base/sveltekit/tsconfig.json +14 -0
  199. package/template/base/sveltekit/vite.config.ts +7 -0
  200. package/template/base/tanstack-start/.cta.json +12 -0
  201. package/template/base/tanstack-start/README.md +17 -0
  202. package/template/base/tanstack-start/_gitignore +13 -0
  203. package/template/base/tanstack-start/package.json +43 -0
  204. package/template/base/tanstack-start/public/favicon.ico +0 -0
  205. package/template/base/tanstack-start/public/logo192.png +0 -0
  206. package/template/base/tanstack-start/public/logo512.png +0 -0
  207. package/template/base/tanstack-start/public/manifest.json +25 -0
  208. package/template/base/tanstack-start/public/robots.txt +3 -0
  209. package/template/base/tanstack-start/public/tanstack-circle-logo.png +0 -0
  210. package/template/base/tanstack-start/public/tanstack-word-logo-white.svg +1 -0
  211. package/template/base/tanstack-start/src/components/Header.tsx +21 -0
  212. package/template/base/tanstack-start/src/instant.perms.ts +24 -0
  213. package/template/base/tanstack-start/src/instant.schema.ts +50 -0
  214. package/template/base/tanstack-start/src/lib/adminDb.ts +12 -0
  215. package/template/base/tanstack-start/src/lib/db.ts +9 -0
  216. package/template/base/tanstack-start/src/logo.svg +12 -0
  217. package/template/base/tanstack-start/src/routeTree.gen.ts +104 -0
  218. package/template/base/tanstack-start/src/router.tsx +22 -0
  219. package/template/base/tanstack-start/src/routes/__root.tsx +70 -0
  220. package/template/base/tanstack-start/src/routes/api/instant.ts +18 -0
  221. package/template/base/tanstack-start/src/routes/index.tsx +238 -0
  222. package/template/base/tanstack-start/src/routes/login.tsx +140 -0
  223. package/template/base/tanstack-start/src/styles.css +18 -0
  224. package/template/base/tanstack-start/tsconfig.json +28 -0
  225. package/template/base/tanstack-start/vite.config.ts +33 -0
  226. package/template/base/tanstack-start-with-tanstack-query/.cta.json +12 -0
  227. package/template/base/tanstack-start-with-tanstack-query/README.md +18 -0
  228. package/template/base/tanstack-start-with-tanstack-query/_gitignore +13 -0
  229. package/template/base/tanstack-start-with-tanstack-query/package.json +46 -0
  230. package/template/base/tanstack-start-with-tanstack-query/public/favicon.ico +0 -0
  231. package/template/base/tanstack-start-with-tanstack-query/public/logo192.png +0 -0
  232. package/template/base/tanstack-start-with-tanstack-query/public/logo512.png +0 -0
  233. package/template/base/tanstack-start-with-tanstack-query/public/manifest.json +25 -0
  234. package/template/base/tanstack-start-with-tanstack-query/public/robots.txt +3 -0
  235. package/template/base/tanstack-start-with-tanstack-query/public/tanstack-circle-logo.png +0 -0
  236. package/template/base/tanstack-start-with-tanstack-query/public/tanstack-word-logo-white.svg +1 -0
  237. package/template/base/tanstack-start-with-tanstack-query/src/components/Header.tsx +21 -0
  238. package/template/base/tanstack-start-with-tanstack-query/src/instant.perms.ts +24 -0
  239. package/template/base/tanstack-start-with-tanstack-query/src/instant.schema.ts +50 -0
  240. package/template/base/tanstack-start-with-tanstack-query/src/lib/adminDb.ts +9 -0
  241. package/template/base/tanstack-start-with-tanstack-query/src/lib/db.ts +11 -0
  242. package/template/base/tanstack-start-with-tanstack-query/src/lib/instantQuery.ts +93 -0
  243. package/template/base/tanstack-start-with-tanstack-query/src/logo.svg +12 -0
  244. package/template/base/tanstack-start-with-tanstack-query/src/routeTree.gen.ts +104 -0
  245. package/template/base/tanstack-start-with-tanstack-query/src/router.tsx +108 -0
  246. package/template/base/tanstack-start-with-tanstack-query/src/routes/__root.tsx +76 -0
  247. package/template/base/tanstack-start-with-tanstack-query/src/routes/api/instant.ts +16 -0
  248. package/template/base/tanstack-start-with-tanstack-query/src/routes/index.tsx +231 -0
  249. package/template/base/tanstack-start-with-tanstack-query/src/routes/login.tsx +140 -0
  250. package/template/base/tanstack-start-with-tanstack-query/src/styles.css +17 -0
  251. package/template/base/tanstack-start-with-tanstack-query/tsconfig.json +28 -0
  252. package/template/base/tanstack-start-with-tanstack-query/vite.config.ts +33 -0
  253. package/template/base/vite-react/README.md +16 -0
  254. package/template/base/vite-react/_gitignore +26 -0
  255. package/template/base/vite-react/eslint.config.js +23 -0
  256. package/template/base/vite-react/index.html +13 -0
  257. package/template/base/vite-react/package.json +35 -0
  258. package/template/base/vite-react/public/favicon.svg +1 -0
  259. package/template/base/vite-react/src/App.tsx +167 -0
  260. package/template/base/vite-react/src/index.css +1 -0
  261. package/template/base/vite-react/src/instant.perms.ts +24 -0
  262. package/template/base/vite-react/src/instant.schema.ts +51 -0
  263. package/template/base/vite-react/src/lib/db.ts +8 -0
  264. package/template/base/vite-react/src/main.tsx +10 -0
  265. package/template/base/vite-react/tsconfig.app.json +25 -0
  266. package/template/base/vite-react/tsconfig.json +7 -0
  267. package/template/base/vite-react/tsconfig.node.json +24 -0
  268. package/template/base/vite-react/vite.config.ts +8 -0
  269. package/template/base/vite-vanilla/.env.example +2 -0
  270. package/template/base/vite-vanilla/README.md +17 -0
  271. package/template/base/vite-vanilla/_gitignore +25 -0
  272. package/template/base/vite-vanilla/index.html +13 -0
  273. package/template/base/vite-vanilla/package.json +20 -0
  274. package/template/base/vite-vanilla/pnpm-lock.yaml +707 -0
  275. package/template/base/vite-vanilla/public/vite.svg +1 -0
  276. package/template/base/vite-vanilla/src/instant.perms.ts +24 -0
  277. package/template/base/vite-vanilla/src/instant.schema.ts +50 -0
  278. package/template/base/vite-vanilla/src/lib/db.ts +11 -0
  279. package/template/base/vite-vanilla/src/main.ts +242 -0
  280. package/template/base/vite-vanilla/src/style.css +96 -0
  281. package/template/base/vite-vanilla/src/typescript.svg +1 -0
  282. package/template/base/vite-vanilla/src/vite-env.d.ts +1 -0
  283. package/template/base/vite-vanilla/tsconfig.json +24 -0
  284. package/template/base/vue-vite/README.md +15 -0
  285. package/template/base/vue-vite/_gitignore +43 -0
  286. package/template/base/vue-vite/env.d.ts +1 -0
  287. package/template/base/vue-vite/index.html +12 -0
  288. package/template/base/vue-vite/package.json +34 -0
  289. package/template/base/vue-vite/src/App.vue +238 -0
  290. package/template/base/vue-vite/src/assets/main.css +25 -0
  291. package/template/base/vue-vite/src/instant.perms.ts +24 -0
  292. package/template/base/vue-vite/src/instant.schema.ts +46 -0
  293. package/template/base/vue-vite/src/lib/db.ts +8 -0
  294. package/template/base/vue-vite/src/main.ts +6 -0
  295. package/template/base/vue-vite/tsconfig.app.json +15 -0
  296. package/template/base/vue-vite/tsconfig.json +11 -0
  297. package/template/base/vue-vite/tsconfig.node.json +27 -0
  298. package/template/base/vue-vite/vite.config.ts +16 -0
  299. package/template/rules/AGENTS.md +436 -0
@@ -0,0 +1,531 @@
1
+ 'use client';
2
+
3
+ import type { ComponentProps } from 'react';
4
+
5
+ import { useControllableState } from '@radix-ui/react-use-controllable-state';
6
+ import { Button } from '@/components/ui/button';
7
+ import {
8
+ Collapsible,
9
+ CollapsibleContent,
10
+ CollapsibleTrigger,
11
+ } from '@/components/ui/collapsible';
12
+ import { cn } from '@/lib/utils';
13
+ import {
14
+ AlertTriangleIcon,
15
+ CheckIcon,
16
+ ChevronDownIcon,
17
+ CopyIcon,
18
+ } from 'lucide-react';
19
+ import {
20
+ createContext,
21
+ memo,
22
+ useCallback,
23
+ useContext,
24
+ useEffect,
25
+ useMemo,
26
+ useRef,
27
+ useState,
28
+ } from 'react';
29
+
30
+ // Regex patterns for parsing stack traces
31
+ const STACK_FRAME_WITH_PARENS_REGEX = /^at\s+(.+?)\s+\((.+):(\d+):(\d+)\)$/;
32
+ const STACK_FRAME_WITHOUT_FN_REGEX = /^at\s+(.+):(\d+):(\d+)$/;
33
+ const ERROR_TYPE_REGEX = /^(\w+Error|Error):\s*(.*)$/;
34
+ const AT_PREFIX_REGEX = /^at\s+/;
35
+
36
+ interface StackFrame {
37
+ raw: string;
38
+ functionName: string | null;
39
+ filePath: string | null;
40
+ lineNumber: number | null;
41
+ columnNumber: number | null;
42
+ isInternal: boolean;
43
+ }
44
+
45
+ interface ParsedStackTrace {
46
+ errorType: string | null;
47
+ errorMessage: string;
48
+ frames: StackFrame[];
49
+ raw: string;
50
+ }
51
+
52
+ interface StackTraceContextValue {
53
+ trace: ParsedStackTrace;
54
+ raw: string;
55
+ isOpen: boolean;
56
+ setIsOpen: (open: boolean) => void;
57
+ onFilePathClick?: (filePath: string, line?: number, column?: number) => void;
58
+ }
59
+
60
+ const StackTraceContext = createContext<StackTraceContextValue | null>(null);
61
+
62
+ const useStackTrace = () => {
63
+ const context = useContext(StackTraceContext);
64
+ if (!context) {
65
+ throw new Error('StackTrace components must be used within StackTrace');
66
+ }
67
+ return context;
68
+ };
69
+
70
+ const parseStackFrame = (line: string): StackFrame => {
71
+ const trimmed = line.trim();
72
+
73
+ // Pattern: at functionName (filePath:line:column)
74
+ const withParensMatch = trimmed.match(STACK_FRAME_WITH_PARENS_REGEX);
75
+ if (withParensMatch) {
76
+ const [, functionName, filePath, lineNum, colNum] = withParensMatch;
77
+ const isInternal =
78
+ filePath.includes('node_modules') ||
79
+ filePath.startsWith('node:') ||
80
+ filePath.includes('internal/');
81
+ return {
82
+ columnNumber: colNum ? Number.parseInt(colNum, 10) : null,
83
+ filePath: filePath ?? null,
84
+ functionName: functionName ?? null,
85
+ isInternal,
86
+ lineNumber: lineNum ? Number.parseInt(lineNum, 10) : null,
87
+ raw: trimmed,
88
+ };
89
+ }
90
+
91
+ // Pattern: at filePath:line:column (no function name)
92
+ const withoutFnMatch = trimmed.match(STACK_FRAME_WITHOUT_FN_REGEX);
93
+ if (withoutFnMatch) {
94
+ const [, filePath, lineNum, colNum] = withoutFnMatch;
95
+ const isInternal =
96
+ (filePath?.includes('node_modules') ?? false) ||
97
+ (filePath?.startsWith('node:') ?? false) ||
98
+ (filePath?.includes('internal/') ?? false);
99
+ return {
100
+ columnNumber: colNum ? Number.parseInt(colNum, 10) : null,
101
+ filePath: filePath ?? null,
102
+ functionName: null,
103
+ isInternal,
104
+ lineNumber: lineNum ? Number.parseInt(lineNum, 10) : null,
105
+ raw: trimmed,
106
+ };
107
+ }
108
+
109
+ // Fallback: unparseable line
110
+ return {
111
+ columnNumber: null,
112
+ filePath: null,
113
+ functionName: null,
114
+ isInternal: trimmed.includes('node_modules') || trimmed.includes('node:'),
115
+ lineNumber: null,
116
+ raw: trimmed,
117
+ };
118
+ };
119
+
120
+ const parseStackTrace = (trace: string): ParsedStackTrace => {
121
+ const lines = trace.split('\n').filter((line) => line.trim());
122
+
123
+ if (lines.length === 0) {
124
+ return {
125
+ errorMessage: trace,
126
+ errorType: null,
127
+ frames: [],
128
+ raw: trace,
129
+ };
130
+ }
131
+
132
+ const firstLine = lines[0].trim();
133
+ let errorType: string | null = null;
134
+ let errorMessage = firstLine;
135
+
136
+ // Try to extract error type from "ErrorType: message" format
137
+ const errorMatch = firstLine.match(ERROR_TYPE_REGEX);
138
+ if (errorMatch) {
139
+ const [, type, msg] = errorMatch;
140
+ errorType = type;
141
+ errorMessage = msg || '';
142
+ }
143
+
144
+ // Parse stack frames (lines starting with "at")
145
+ const frames = lines
146
+ .slice(1)
147
+ .filter((line) => line.trim().startsWith('at '))
148
+ .map(parseStackFrame);
149
+
150
+ return {
151
+ errorMessage,
152
+ errorType,
153
+ frames,
154
+ raw: trace,
155
+ };
156
+ };
157
+
158
+ export type StackTraceProps = ComponentProps<'div'> & {
159
+ trace: string;
160
+ open?: boolean;
161
+ defaultOpen?: boolean;
162
+ onOpenChange?: (open: boolean) => void;
163
+ onFilePathClick?: (filePath: string, line?: number, column?: number) => void;
164
+ };
165
+
166
+ export const StackTrace = memo(
167
+ ({
168
+ trace,
169
+ className,
170
+ open,
171
+ defaultOpen = false,
172
+ onOpenChange,
173
+ onFilePathClick,
174
+ children,
175
+ ...props
176
+ }: StackTraceProps) => {
177
+ const [isOpen, setIsOpen] = useControllableState({
178
+ defaultProp: defaultOpen,
179
+ onChange: onOpenChange,
180
+ prop: open,
181
+ });
182
+
183
+ const parsedTrace = useMemo(() => parseStackTrace(trace), [trace]);
184
+
185
+ const contextValue = useMemo(
186
+ () => ({
187
+ isOpen,
188
+ onFilePathClick,
189
+ raw: trace,
190
+ setIsOpen,
191
+ trace: parsedTrace,
192
+ }),
193
+ [parsedTrace, trace, isOpen, setIsOpen, onFilePathClick],
194
+ );
195
+
196
+ return (
197
+ <StackTraceContext.Provider value={contextValue}>
198
+ <div
199
+ className={cn(
200
+ 'not-prose bg-background w-full overflow-hidden rounded-lg border font-mono text-sm',
201
+ className,
202
+ )}
203
+ {...props}
204
+ >
205
+ {children}
206
+ </div>
207
+ </StackTraceContext.Provider>
208
+ );
209
+ },
210
+ );
211
+
212
+ export type StackTraceHeaderProps = ComponentProps<typeof CollapsibleTrigger>;
213
+
214
+ export const StackTraceHeader = memo(
215
+ ({ className, children, ...props }: StackTraceHeaderProps) => {
216
+ const { isOpen, setIsOpen } = useStackTrace();
217
+
218
+ return (
219
+ <Collapsible onOpenChange={setIsOpen} open={isOpen}>
220
+ <CollapsibleTrigger asChild {...props}>
221
+ <div
222
+ className={cn(
223
+ 'hover:bg-muted/50 flex w-full cursor-pointer items-center gap-3 p-3 text-left transition-colors',
224
+ className,
225
+ )}
226
+ >
227
+ {children}
228
+ </div>
229
+ </CollapsibleTrigger>
230
+ </Collapsible>
231
+ );
232
+ },
233
+ );
234
+
235
+ export type StackTraceErrorProps = ComponentProps<'div'>;
236
+
237
+ export const StackTraceError = memo(
238
+ ({ className, children, ...props }: StackTraceErrorProps) => (
239
+ <div
240
+ className={cn(
241
+ 'flex flex-1 items-center gap-2 overflow-hidden',
242
+ className,
243
+ )}
244
+ {...props}
245
+ >
246
+ <AlertTriangleIcon className="text-destructive size-4 shrink-0" />
247
+ {children}
248
+ </div>
249
+ ),
250
+ );
251
+
252
+ export type StackTraceErrorTypeProps = ComponentProps<'span'>;
253
+
254
+ export const StackTraceErrorType = memo(
255
+ ({ className, children, ...props }: StackTraceErrorTypeProps) => {
256
+ const { trace } = useStackTrace();
257
+
258
+ return (
259
+ <span
260
+ className={cn('text-destructive shrink-0 font-semibold', className)}
261
+ {...props}
262
+ >
263
+ {children ?? trace.errorType}
264
+ </span>
265
+ );
266
+ },
267
+ );
268
+
269
+ export type StackTraceErrorMessageProps = ComponentProps<'span'>;
270
+
271
+ export const StackTraceErrorMessage = memo(
272
+ ({ className, children, ...props }: StackTraceErrorMessageProps) => {
273
+ const { trace } = useStackTrace();
274
+
275
+ return (
276
+ <span className={cn('text-foreground truncate', className)} {...props}>
277
+ {children ?? trace.errorMessage}
278
+ </span>
279
+ );
280
+ },
281
+ );
282
+
283
+ export type StackTraceActionsProps = ComponentProps<'div'>;
284
+
285
+ const handleActionsClick = (e: React.MouseEvent) => e.stopPropagation();
286
+ const handleActionsKeyDown = (e: React.KeyboardEvent) => {
287
+ if (e.key === 'Enter' || e.key === ' ') {
288
+ e.stopPropagation();
289
+ }
290
+ };
291
+
292
+ export const StackTraceActions = memo(
293
+ ({ className, children, ...props }: StackTraceActionsProps) => (
294
+ // biome-ignore lint/a11y/noNoninteractiveElementInteractions: stopPropagation required for nested interactions
295
+ // biome-ignore lint/a11y/useSemanticElements: fieldset doesn't fit this UI pattern
296
+ <div
297
+ className={cn('flex shrink-0 items-center gap-1', className)}
298
+ onClick={handleActionsClick}
299
+ onKeyDown={handleActionsKeyDown}
300
+ role="group"
301
+ {...props}
302
+ >
303
+ {children}
304
+ </div>
305
+ ),
306
+ );
307
+
308
+ export type StackTraceCopyButtonProps = ComponentProps<typeof Button> & {
309
+ onCopy?: () => void;
310
+ onError?: (error: Error) => void;
311
+ timeout?: number;
312
+ };
313
+
314
+ export const StackTraceCopyButton = memo(
315
+ ({
316
+ onCopy,
317
+ onError,
318
+ timeout = 2000,
319
+ className,
320
+ children,
321
+ ...props
322
+ }: StackTraceCopyButtonProps) => {
323
+ const [isCopied, setIsCopied] = useState(false);
324
+ const timeoutRef = useRef<number>(0);
325
+ const { raw } = useStackTrace();
326
+
327
+ const copyToClipboard = useCallback(async () => {
328
+ if (typeof window === 'undefined' || !navigator?.clipboard?.writeText) {
329
+ onError?.(new Error('Clipboard API not available'));
330
+ return;
331
+ }
332
+
333
+ try {
334
+ await navigator.clipboard.writeText(raw);
335
+ setIsCopied(true);
336
+ onCopy?.();
337
+ timeoutRef.current = window.setTimeout(
338
+ () => setIsCopied(false),
339
+ timeout,
340
+ );
341
+ } catch (error) {
342
+ onError?.(error as Error);
343
+ }
344
+ }, [raw, onCopy, onError, timeout]);
345
+
346
+ useEffect(
347
+ () => () => {
348
+ window.clearTimeout(timeoutRef.current);
349
+ },
350
+ [],
351
+ );
352
+
353
+ const Icon = isCopied ? CheckIcon : CopyIcon;
354
+
355
+ return (
356
+ <Button
357
+ className={cn('size-7', className)}
358
+ onClick={copyToClipboard}
359
+ size="icon"
360
+ variant="ghost"
361
+ {...props}
362
+ >
363
+ {children ?? <Icon size={14} />}
364
+ </Button>
365
+ );
366
+ },
367
+ );
368
+
369
+ export type StackTraceExpandButtonProps = ComponentProps<'div'>;
370
+
371
+ export const StackTraceExpandButton = memo(
372
+ ({ className, ...props }: StackTraceExpandButtonProps) => {
373
+ const { isOpen } = useStackTrace();
374
+
375
+ return (
376
+ <div
377
+ className={cn('flex size-7 items-center justify-center', className)}
378
+ {...props}
379
+ >
380
+ <ChevronDownIcon
381
+ className={cn(
382
+ 'text-muted-foreground size-4 transition-transform',
383
+ isOpen ? 'rotate-180' : 'rotate-0',
384
+ )}
385
+ />
386
+ </div>
387
+ );
388
+ },
389
+ );
390
+
391
+ export type StackTraceContentProps = ComponentProps<
392
+ typeof CollapsibleContent
393
+ > & {
394
+ maxHeight?: number;
395
+ };
396
+
397
+ export const StackTraceContent = memo(
398
+ ({
399
+ className,
400
+ maxHeight = 400,
401
+ children,
402
+ ...props
403
+ }: StackTraceContentProps) => {
404
+ const { isOpen } = useStackTrace();
405
+
406
+ return (
407
+ <Collapsible open={isOpen}>
408
+ <CollapsibleContent
409
+ className={cn(
410
+ 'bg-muted/30 overflow-auto border-t',
411
+ 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:animate-out data-[state=open]:animate-in',
412
+ className,
413
+ )}
414
+ style={{ maxHeight }}
415
+ {...props}
416
+ >
417
+ {children}
418
+ </CollapsibleContent>
419
+ </Collapsible>
420
+ );
421
+ },
422
+ );
423
+
424
+ export type StackTraceFramesProps = ComponentProps<'div'> & {
425
+ showInternalFrames?: boolean;
426
+ };
427
+
428
+ interface FilePathButtonProps {
429
+ frame: StackFrame;
430
+ onFilePathClick?: (
431
+ filePath: string,
432
+ lineNumber?: number,
433
+ columnNumber?: number,
434
+ ) => void;
435
+ }
436
+
437
+ const FilePathButton = memo(
438
+ ({ frame, onFilePathClick }: FilePathButtonProps) => {
439
+ const handleClick = useCallback(() => {
440
+ if (frame.filePath) {
441
+ onFilePathClick?.(
442
+ frame.filePath,
443
+ frame.lineNumber ?? undefined,
444
+ frame.columnNumber ?? undefined,
445
+ );
446
+ }
447
+ }, [frame, onFilePathClick]);
448
+
449
+ return (
450
+ <button
451
+ className={cn(
452
+ 'hover:text-primary underline decoration-dotted',
453
+ onFilePathClick && 'cursor-pointer',
454
+ )}
455
+ disabled={!onFilePathClick}
456
+ onClick={handleClick}
457
+ type="button"
458
+ >
459
+ {frame.filePath}
460
+ {frame.lineNumber !== null && `:${frame.lineNumber}`}
461
+ {frame.columnNumber !== null && `:${frame.columnNumber}`}
462
+ </button>
463
+ );
464
+ },
465
+ );
466
+
467
+ FilePathButton.displayName = 'FilePathButton';
468
+
469
+ export const StackTraceFrames = memo(
470
+ ({
471
+ className,
472
+ showInternalFrames = true,
473
+ ...props
474
+ }: StackTraceFramesProps) => {
475
+ const { trace, onFilePathClick } = useStackTrace();
476
+
477
+ const framesToShow = showInternalFrames
478
+ ? trace.frames
479
+ : trace.frames.filter((f) => !f.isInternal);
480
+
481
+ return (
482
+ <div className={cn('space-y-1 p-3', className)} {...props}>
483
+ {framesToShow.map((frame, index) => (
484
+ <div
485
+ className={cn(
486
+ 'text-xs',
487
+ frame.isInternal
488
+ ? 'text-muted-foreground/50'
489
+ : 'text-foreground/90',
490
+ )}
491
+ key={`${frame.raw}-${index}`}
492
+ >
493
+ <span className="text-muted-foreground">at </span>
494
+ {frame.functionName && (
495
+ <span className={frame.isInternal ? '' : 'text-foreground'}>
496
+ {frame.functionName}{' '}
497
+ </span>
498
+ )}
499
+ {frame.filePath && (
500
+ <>
501
+ <span className="text-muted-foreground">(</span>
502
+ <FilePathButton
503
+ frame={frame}
504
+ onFilePathClick={onFilePathClick}
505
+ />
506
+ <span className="text-muted-foreground">)</span>
507
+ </>
508
+ )}
509
+ {!(frame.filePath || frame.functionName) && (
510
+ <span>{frame.raw.replace(AT_PREFIX_REGEX, '')}</span>
511
+ )}
512
+ </div>
513
+ ))}
514
+ {framesToShow.length === 0 && (
515
+ <div className="text-muted-foreground text-xs">No stack frames</div>
516
+ )}
517
+ </div>
518
+ );
519
+ },
520
+ );
521
+
522
+ StackTrace.displayName = 'StackTrace';
523
+ StackTraceHeader.displayName = 'StackTraceHeader';
524
+ StackTraceError.displayName = 'StackTraceError';
525
+ StackTraceErrorType.displayName = 'StackTraceErrorType';
526
+ StackTraceErrorMessage.displayName = 'StackTraceErrorMessage';
527
+ StackTraceActions.displayName = 'StackTraceActions';
528
+ StackTraceCopyButton.displayName = 'StackTraceCopyButton';
529
+ StackTraceExpandButton.displayName = 'StackTraceExpandButton';
530
+ StackTraceContent.displayName = 'StackTraceContent';
531
+ StackTraceFrames.displayName = 'StackTraceFrames';
@@ -0,0 +1,55 @@
1
+ 'use client';
2
+
3
+ import type { ComponentProps } from 'react';
4
+
5
+ import { Button } from '@/components/ui/button';
6
+ import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
7
+ import { cn } from '@/lib/utils';
8
+ import { useCallback } from 'react';
9
+
10
+ export type SuggestionsProps = ComponentProps<typeof ScrollArea>;
11
+
12
+ export const Suggestions = ({
13
+ className,
14
+ children,
15
+ ...props
16
+ }: SuggestionsProps) => (
17
+ <ScrollArea className="w-full overflow-x-auto whitespace-nowrap" {...props}>
18
+ <div className={cn('flex w-max flex-nowrap items-center gap-2', className)}>
19
+ {children}
20
+ </div>
21
+ <ScrollBar className="hidden" orientation="horizontal" />
22
+ </ScrollArea>
23
+ );
24
+
25
+ export type SuggestionProps = Omit<ComponentProps<typeof Button>, 'onClick'> & {
26
+ suggestion: string;
27
+ onClick?: (suggestion: string) => void;
28
+ };
29
+
30
+ export const Suggestion = ({
31
+ suggestion,
32
+ onClick,
33
+ className,
34
+ variant = 'outline',
35
+ size = 'sm',
36
+ children,
37
+ ...props
38
+ }: SuggestionProps) => {
39
+ const handleClick = useCallback(() => {
40
+ onClick?.(suggestion);
41
+ }, [onClick, suggestion]);
42
+
43
+ return (
44
+ <Button
45
+ className={cn('cursor-pointer rounded-full px-4', className)}
46
+ onClick={handleClick}
47
+ size={size}
48
+ type="button"
49
+ variant={variant}
50
+ {...props}
51
+ >
52
+ {children || suggestion}
53
+ </Button>
54
+ );
55
+ };
@@ -0,0 +1,88 @@
1
+ 'use client';
2
+
3
+ import type { ComponentProps } from 'react';
4
+
5
+ import {
6
+ Collapsible,
7
+ CollapsibleContent,
8
+ CollapsibleTrigger,
9
+ } from '@/components/ui/collapsible';
10
+ import { cn } from '@/lib/utils';
11
+ import { ChevronDownIcon, SearchIcon } from 'lucide-react';
12
+
13
+ export type TaskItemFileProps = ComponentProps<'div'>;
14
+
15
+ export const TaskItemFile = ({
16
+ children,
17
+ className,
18
+ ...props
19
+ }: TaskItemFileProps) => (
20
+ <div
21
+ className={cn(
22
+ 'bg-secondary text-foreground inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs',
23
+ className,
24
+ )}
25
+ {...props}
26
+ >
27
+ {children}
28
+ </div>
29
+ );
30
+
31
+ export type TaskItemProps = ComponentProps<'div'>;
32
+
33
+ export const TaskItem = ({ children, className, ...props }: TaskItemProps) => (
34
+ <div className={cn('text-muted-foreground text-sm', className)} {...props}>
35
+ {children}
36
+ </div>
37
+ );
38
+
39
+ export type TaskProps = ComponentProps<typeof Collapsible>;
40
+
41
+ export const Task = ({
42
+ defaultOpen = true,
43
+ className,
44
+ ...props
45
+ }: TaskProps) => (
46
+ <Collapsible className={cn(className)} defaultOpen={defaultOpen} {...props} />
47
+ );
48
+
49
+ export type TaskTriggerProps = ComponentProps<typeof CollapsibleTrigger> & {
50
+ title: string;
51
+ };
52
+
53
+ export const TaskTrigger = ({
54
+ children,
55
+ className,
56
+ title,
57
+ ...props
58
+ }: TaskTriggerProps) => (
59
+ <CollapsibleTrigger asChild className={cn('group', className)} {...props}>
60
+ {children ?? (
61
+ <div className="text-muted-foreground hover:text-foreground flex w-full cursor-pointer items-center gap-2 text-sm transition-colors">
62
+ <SearchIcon className="size-4" />
63
+ <p className="text-sm">{title}</p>
64
+ <ChevronDownIcon className="size-4 transition-transform group-data-[state=open]:rotate-180" />
65
+ </div>
66
+ )}
67
+ </CollapsibleTrigger>
68
+ );
69
+
70
+ export type TaskContentProps = ComponentProps<typeof CollapsibleContent>;
71
+
72
+ export const TaskContent = ({
73
+ children,
74
+ className,
75
+ ...props
76
+ }: TaskContentProps) => (
77
+ <CollapsibleContent
78
+ className={cn(
79
+ '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',
80
+ className,
81
+ )}
82
+ {...props}
83
+ >
84
+ <div className="border-muted mt-4 space-y-2 border-l-2 pl-4">
85
+ {children}
86
+ </div>
87
+ </CollapsibleContent>
88
+ );