@vetta-org/theme-ui 0.1.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 (406) hide show
  1. package/package.json +195 -0
  2. package/src/action-approval/AppearanceActionPickerView.tsx +291 -0
  3. package/src/action-approval/AppearanceApprovalDrawerView.tsx +69 -0
  4. package/src/action-approval/AppearancePickerApprovalView.tsx +31 -0
  5. package/src/action-approval/ApprovalParts.tsx +376 -0
  6. package/src/action-approval/BatchTasksApprovalFrameView.tsx +138 -0
  7. package/src/action-approval/BatchTasksExecutionApprovalView.tsx +158 -0
  8. package/src/action-approval/BatchTasksTaskApprovalView.tsx +152 -0
  9. package/src/action-approval/GeneralSetExecutionModeApprovalView.tsx +76 -0
  10. package/src/action-approval/GenericActionApprovalView.tsx +127 -0
  11. package/src/action-approval/ManageActionApprovalFrameTypes.ts +27 -0
  12. package/src/action-approval/ManageActionApprovalFrameView.tsx +136 -0
  13. package/src/action-approval/NavigationOpenApprovalView.tsx +119 -0
  14. package/src/action-approval/SchedulerActionApprovalDialogView.tsx +191 -0
  15. package/src/action-approval/SchedulerEditApprovalDrawerView.tsx +113 -0
  16. package/src/action-approval/SchedulerUpdateApprovalView.tsx +14 -0
  17. package/src/action-approval/ThemeChangeApprovalView.tsx +30 -0
  18. package/src/action-approval/WebhookDeleteApprovalView.tsx +56 -0
  19. package/src/action-approval/WebhookTestApprovalView.tsx +51 -0
  20. package/src/action-approval/cn.ts +4 -0
  21. package/src/action-approval/index.ts +88 -0
  22. package/src/activity/ActivityPanel.tsx +269 -0
  23. package/src/activity/ActivityPanelFrame.tsx +36 -0
  24. package/src/activity/BackgroundTasksTabPanelView.tsx +382 -0
  25. package/src/activity/BatchProgressTabPanelView.tsx +22 -0
  26. package/src/activity/BrowserPanelView.tsx +169 -0
  27. package/src/activity/ChatTabPanelView.tsx +36 -0
  28. package/src/activity/CodePreview.tsx +57 -0
  29. package/src/activity/DebugTabPanelView.tsx +67 -0
  30. package/src/activity/FileTabContentView.tsx +46 -0
  31. package/src/activity/FloatingActivityTabView.tsx +107 -0
  32. package/src/activity/HtmlPreviewView.tsx +135 -0
  33. package/src/activity/JourneyPanelView.tsx +327 -0
  34. package/src/activity/KnowledgeHistoryPanelView.tsx +93 -0
  35. package/src/activity/MarkdownPreviewView.tsx +217 -0
  36. package/src/activity/PluginTabPickerView.tsx +182 -0
  37. package/src/activity/RequestHistorySubTabView.tsx +102 -0
  38. package/src/activity/ScheduleExecutionTabPanelView.tsx +162 -0
  39. package/src/activity/TodoTabPanelView.tsx +66 -0
  40. package/src/activity/ToolCallsSubTabView.tsx +184 -0
  41. package/src/activity/WorkflowTabPanelView.tsx +129 -0
  42. package/src/activity/index.ts +110 -0
  43. package/src/app/AppBackground.tsx +24 -0
  44. package/src/app/AppBootLoadingView.tsx +51 -0
  45. package/src/app/RouteContentLoadingView.tsx +20 -0
  46. package/src/app/index.ts +13 -0
  47. package/src/app-boot.ts +1 -0
  48. package/src/app-shell/DefaultPageHeader.tsx +46 -0
  49. package/src/app-shell/DefaultWindowControls.tsx +32 -0
  50. package/src/app-shell/PageHeaderActionGroup.tsx +15 -0
  51. package/src/app-shell/PageHeaderContent.tsx +70 -0
  52. package/src/app-shell/PageHeaderFrame.tsx +53 -0
  53. package/src/app-shell/PageHeaderSidebarTrigger.tsx +21 -0
  54. package/src/app-shell/PageHeaderTitle.tsx +25 -0
  55. package/src/app-shell/PageHeaderWindowActions.tsx +22 -0
  56. package/src/app-shell/WindowControlButton.tsx +35 -0
  57. package/src/app-shell/index.ts +49 -0
  58. package/src/appearance/BackgroundImageFrame.tsx +57 -0
  59. package/src/appearance/CenterSliceImageFrame.tsx +64 -0
  60. package/src/appearance/CornerImageFrame.tsx +63 -0
  61. package/src/appearance/HorizontalSliceImageFrame.tsx +97 -0
  62. package/src/appearance/NineSliceImageFrame.tsx +65 -0
  63. package/src/appearance/ThemeSurface.tsx +91 -0
  64. package/src/appearance/index.ts +12 -0
  65. package/src/batch-tasks/BatchProjectArtifactFieldView.tsx +36 -0
  66. package/src/batch-tasks/BatchProjectDialogView.tsx +61 -0
  67. package/src/batch-tasks/BatchProjectFoldersFieldView.tsx +108 -0
  68. package/src/batch-tasks/BatchProjectGroupView.tsx +77 -0
  69. package/src/batch-tasks/BatchProjectNameFieldView.tsx +29 -0
  70. package/src/batch-tasks/BatchProjectNotificationFieldView.tsx +42 -0
  71. package/src/batch-tasks/BatchProjectRuntimeFieldsView.tsx +67 -0
  72. package/src/batch-tasks/BatchTaskActionButtonsView.tsx +67 -0
  73. package/src/batch-tasks/BatchTaskCardView.tsx +142 -0
  74. package/src/batch-tasks/BatchTaskGridView.tsx +95 -0
  75. package/src/batch-tasks/BatchTaskListView.tsx +10 -0
  76. package/src/batch-tasks/BatchTaskProjectActionsView.tsx +73 -0
  77. package/src/batch-tasks/BatchTaskProjectBlockView.tsx +117 -0
  78. package/src/batch-tasks/BatchTaskProjectHeaderView.tsx +74 -0
  79. package/src/batch-tasks/BatchTasksPageView.tsx +126 -0
  80. package/src/batch-tasks/batchTaskUi.tsx +101 -0
  81. package/src/batch-tasks/index.ts +70 -0
  82. package/src/batch-tasks/types.ts +120 -0
  83. package/src/chat/ActionButtonBarView.tsx +45 -0
  84. package/src/chat/AgentAvatarView.tsx +59 -0
  85. package/src/chat/AppshotCardView.tsx +89 -0
  86. package/src/chat/AskUserQuestionView.tsx +177 -0
  87. package/src/chat/AssistantMessageView.tsx +147 -0
  88. package/src/chat/AtPanelView.tsx +220 -0
  89. package/src/chat/BackgroundTasksBadgeView.tsx +28 -0
  90. package/src/chat/BashTerminalCard.tsx +225 -0
  91. package/src/chat/ChatExportHostView.tsx +17 -0
  92. package/src/chat/ChatHeaderActionsView.tsx +75 -0
  93. package/src/chat/ContextRingView.tsx +100 -0
  94. package/src/chat/CopyIconButton.tsx +61 -0
  95. package/src/chat/DefaultGuidingWords.tsx +75 -0
  96. package/src/chat/DefaultSceneCarousel.tsx +113 -0
  97. package/src/chat/DefaultSkillBadgeRow.tsx +103 -0
  98. package/src/chat/DrawerCard.tsx +149 -0
  99. package/src/chat/EditDiffView.tsx +137 -0
  100. package/src/chat/ExecutionModeSelectorView.tsx +124 -0
  101. package/src/chat/ExportMessageListView.tsx +20 -0
  102. package/src/chat/GuideBadgeSwiperView.tsx +79 -0
  103. package/src/chat/InlineTokenChip.tsx +68 -0
  104. package/src/chat/InputActionBarView.tsx +112 -0
  105. package/src/chat/InputBarBackground.tsx +25 -0
  106. package/src/chat/InputBarCapsule.tsx +56 -0
  107. package/src/chat/InputBarContextMenuView.tsx +79 -0
  108. package/src/chat/InputBarPlaceholder.tsx +84 -0
  109. package/src/chat/InputBarToolbarButton.tsx +42 -0
  110. package/src/chat/KnowledgeToolViews.tsx +119 -0
  111. package/src/chat/LiveThinkingView.tsx +102 -0
  112. package/src/chat/MessageActions.tsx +109 -0
  113. package/src/chat/MessageBlockSegmentsView.tsx +203 -0
  114. package/src/chat/MessageBoundaryViews.tsx +93 -0
  115. package/src/chat/MessageCardsView.tsx +126 -0
  116. package/src/chat/MessageFeedContext.tsx +14 -0
  117. package/src/chat/MessageFeedLayoutView.tsx +97 -0
  118. package/src/chat/MessageFeedView.tsx +228 -0
  119. package/src/chat/MessageInputView.tsx +193 -0
  120. package/src/chat/MessageLayoutView.tsx +156 -0
  121. package/src/chat/MessageListFooterView.tsx +127 -0
  122. package/src/chat/MessageSelectionContextMenuView.tsx +66 -0
  123. package/src/chat/MessageTimelineView.tsx +261 -0
  124. package/src/chat/MessageView.tsx +82 -0
  125. package/src/chat/MessageVisualView.tsx +43 -0
  126. package/src/chat/ModelSelectorView.tsx +407 -0
  127. package/src/chat/NewSession.ts +107 -0
  128. package/src/chat/NewSessionBackground.tsx +54 -0
  129. package/src/chat/NewSessionPageLayoutView.tsx +96 -0
  130. package/src/chat/NewSessionPicker.tsx +270 -0
  131. package/src/chat/ProgressGroupView.tsx +323 -0
  132. package/src/chat/ProjectSelectorView.tsx +253 -0
  133. package/src/chat/QueueCardView.tsx +151 -0
  134. package/src/chat/ReadImageView.tsx +73 -0
  135. package/src/chat/SandboxGrantsBadgeView.tsx +101 -0
  136. package/src/chat/SandboxPermissionCard.tsx +64 -0
  137. package/src/chat/SceneCard.tsx +138 -0
  138. package/src/chat/SendButton.tsx +135 -0
  139. package/src/chat/SessionDropZoneView.tsx +85 -0
  140. package/src/chat/SessionViewerPageView.tsx +56 -0
  141. package/src/chat/SkillCard.tsx +56 -0
  142. package/src/chat/SkillPromptAreaView.tsx +129 -0
  143. package/src/chat/SuggestionBubblesView.tsx +58 -0
  144. package/src/chat/TextBlockView.tsx +770 -0
  145. package/src/chat/TextPreview.tsx +37 -0
  146. package/src/chat/ThinkingBlockView.tsx +183 -0
  147. package/src/chat/TodoCard.tsx +243 -0
  148. package/src/chat/TodoProgress.tsx +205 -0
  149. package/src/chat/TodoStatusBarView.tsx +140 -0
  150. package/src/chat/ToolCallBlockView.tsx +188 -0
  151. package/src/chat/UsageBarView.tsx +19 -0
  152. package/src/chat/UserMessageContextMenuView.tsx +87 -0
  153. package/src/chat/UserMessageView.tsx +241 -0
  154. package/src/chat/WorkflowFooterItemsView.tsx +170 -0
  155. package/src/chat/WriteContentView.tsx +12 -0
  156. package/src/chat/index.ts +524 -0
  157. package/src/chat/markdown-link.test.ts +238 -0
  158. package/src/chat/markdown-link.ts +279 -0
  159. package/src/chat/send-button.css +318 -0
  160. package/src/chat/useHorizontalDragScroll.ts +146 -0
  161. package/src/file-explorer/ConfirmDeleteDialogView.tsx +62 -0
  162. package/src/file-explorer/FileContextMenuView.tsx +209 -0
  163. package/src/file-explorer/FileTreeCreateRow.tsx +82 -0
  164. package/src/file-explorer/FileTreeNodeView.tsx +274 -0
  165. package/src/file-explorer/FileTreeView.tsx +301 -0
  166. package/src/file-explorer/FilesPanelView.tsx +91 -0
  167. package/src/file-explorer/drag-target.test.ts +34 -0
  168. package/src/file-explorer/drag-target.ts +26 -0
  169. package/src/file-explorer/fileIcons.ts +1 -0
  170. package/src/file-explorer/index.ts +28 -0
  171. package/src/file-explorer/nativeFileDrag.test.ts +30 -0
  172. package/src/file-explorer/nativeFileDrag.ts +14 -0
  173. package/src/file-explorer/types.ts +40 -0
  174. package/src/file-explorer/useFileTreeMarqueeSelection.ts +115 -0
  175. package/src/file-preview/FilePreviewDialogView.tsx +241 -0
  176. package/src/file-preview/FilePreviewView.tsx +162 -0
  177. package/src/file-preview/LightboxImageView.tsx +131 -0
  178. package/src/file-preview/PluginFilePreviewView.tsx +24 -0
  179. package/src/file-preview/PreviewBodyView.tsx +99 -0
  180. package/src/file-preview/PreviewErrorBoundary.tsx +51 -0
  181. package/src/file-preview/TextCodeEditorView.tsx +72 -0
  182. package/src/file-preview/TextFileEditorView.tsx +213 -0
  183. package/src/file-preview/index.ts +56 -0
  184. package/src/file-preview/keyboard-target.test.ts +49 -0
  185. package/src/file-preview/keyboard-target.ts +33 -0
  186. package/src/file-preview/syntax-tokens.css +77 -0
  187. package/src/file-preview/syntax-tokens.test.ts +31 -0
  188. package/src/file-preview/syntax-tokens.ts +155 -0
  189. package/src/file-preview/text-code-editor-theme.ts +321 -0
  190. package/src/file-preview/text-editor-language.test.ts +58 -0
  191. package/src/file-preview/text-editor-language.ts +182 -0
  192. package/src/file-preview/types.ts +29 -0
  193. package/src/flowing/FlowingPanelView.tsx +79 -0
  194. package/src/flowing/FlowingWorkflowView.tsx +54 -0
  195. package/src/flowing/UserNodeView.tsx +148 -0
  196. package/src/flowing/WorkflowBindDialogView.tsx +145 -0
  197. package/src/flowing/WorkflowProgressView.tsx +149 -0
  198. package/src/flowing/index.ts +27 -0
  199. package/src/flowing-chat/ChatBubbleView.tsx +219 -0
  200. package/src/flowing-chat/ChatComposerView.tsx +362 -0
  201. package/src/flowing-chat/ChatMembersBarView.tsx +86 -0
  202. package/src/flowing-chat/ChatPanelView.tsx +73 -0
  203. package/src/flowing-chat/index.ts +21 -0
  204. package/src/index.ts +22 -0
  205. package/src/knowledge/KnowledgeBaseSwitcherView.tsx +154 -0
  206. package/src/knowledge/KnowledgeBreadcrumbView.tsx +92 -0
  207. package/src/knowledge/KnowledgeContentsPanelView.tsx +77 -0
  208. package/src/knowledge/KnowledgeContextMenuView.tsx +70 -0
  209. package/src/knowledge/KnowledgeFilesSkeleton.tsx +22 -0
  210. package/src/knowledge/KnowledgeGridView.tsx +113 -0
  211. package/src/knowledge/KnowledgeHowItWorksDialogView.tsx +85 -0
  212. package/src/knowledge/KnowledgeImportDialogView.tsx +153 -0
  213. package/src/knowledge/KnowledgeListView.tsx +107 -0
  214. package/src/knowledge/KnowledgePendingFilesDialogView.tsx +76 -0
  215. package/src/knowledge/KnowledgeProcessingBadgeView.tsx +18 -0
  216. package/src/knowledge/KnowledgeRenameDialogView.tsx +66 -0
  217. package/src/knowledge/KnowledgeSourcePickerView.tsx +60 -0
  218. package/src/knowledge/KnowledgeViewShared.tsx +103 -0
  219. package/src/knowledge/cn.ts +4 -0
  220. package/src/knowledge/coloredFileIcons.ts +1 -0
  221. package/src/knowledge/index.ts +66 -0
  222. package/src/knowledge/types.ts +31 -0
  223. package/src/knowledge/useMarqueeSelection.ts +95 -0
  224. package/src/layout/AppFrame.tsx +34 -0
  225. package/src/layout/MainContentFrame.tsx +54 -0
  226. package/src/layout/ResizeHandle.tsx +91 -0
  227. package/src/layout/SidebarDock.tsx +33 -0
  228. package/src/layout/SidebarOverlay.tsx +36 -0
  229. package/src/layout/index.ts +10 -0
  230. package/src/overlays/CommandMenuRow.tsx +119 -0
  231. package/src/overlays/CommandMenuView.tsx +183 -0
  232. package/src/overlays/ConfirmDialogView.tsx +109 -0
  233. package/src/overlays/DetailDrawer.tsx +63 -0
  234. package/src/overlays/DetailDrawerEnter.tsx +37 -0
  235. package/src/overlays/KnowledgeDropOverlayView.tsx +43 -0
  236. package/src/overlays/RouteErrorPageView.tsx +72 -0
  237. package/src/overlays/ToasterView.tsx +76 -0
  238. package/src/overlays/UpdateCheckerView.tsx +206 -0
  239. package/src/overlays/UpdateRestartDialogView.tsx +107 -0
  240. package/src/overlays/command-menu-types.ts +47 -0
  241. package/src/overlays/command-menu.css +69 -0
  242. package/src/overlays/detail-drawer-guard.test.ts +16 -0
  243. package/src/overlays/detail-drawer-guard.ts +13 -0
  244. package/src/overlays/index.ts +44 -0
  245. package/src/plugin-ui/index.ts +26 -0
  246. package/src/project/BatchQueueStatusView.tsx +352 -0
  247. package/src/project/ConversationTagDotsView.tsx +130 -0
  248. package/src/project/ConversationTagEditorDialogView.tsx +273 -0
  249. package/src/project/DefaultConversationSectionView.tsx +74 -0
  250. package/src/project/DefaultSessionListView.tsx +128 -0
  251. package/src/project/DefaultSessionRowView.tsx +125 -0
  252. package/src/project/NewProjectDialogView.tsx +140 -0
  253. package/src/project/ProjectContextMenuView.tsx +187 -0
  254. package/src/project/ProjectDetailPageView.tsx +351 -0
  255. package/src/project/ProjectGroupView.tsx +37 -0
  256. package/src/project/ProjectRowView.tsx +111 -0
  257. package/src/project/ProjectSessionsLoadingView.tsx +14 -0
  258. package/src/project/ProjectSessionsView.tsx +96 -0
  259. package/src/project/ProjectsLoadingView.tsx +15 -0
  260. package/src/project/ProjectsPanelMenusView.tsx +23 -0
  261. package/src/project/ProjectsPanelView.tsx +56 -0
  262. package/src/project/QuickScrollOverlay.tsx +188 -0
  263. package/src/project/ScheduleStatusView.tsx +110 -0
  264. package/src/project/SessionContextMenuView.tsx +71 -0
  265. package/src/project/SessionRenameInputView.tsx +49 -0
  266. package/src/project/SessionRowView.tsx +119 -0
  267. package/src/project/SidebarProjectsSectionView.tsx +35 -0
  268. package/src/project/index.ts +87 -0
  269. package/src/project/types.ts +21 -0
  270. package/src/project/useActiveSessionAutoScroll.ts +171 -0
  271. package/src/registry.ts +62 -0
  272. package/src/scheduler/AutomationPageView.tsx +159 -0
  273. package/src/scheduler/ExecutionHistoryView.tsx +179 -0
  274. package/src/scheduler/HistoryDrawerView.tsx +149 -0
  275. package/src/scheduler/TaskFormDialogView.tsx +60 -0
  276. package/src/scheduler/TaskListView.tsx +219 -0
  277. package/src/scheduler/index.ts +30 -0
  278. package/src/settings/AchievementNavigationButtonView.tsx +90 -0
  279. package/src/settings/AchievementPromotionDialogView.tsx +91 -0
  280. package/src/settings/AchievementSettingsView.tsx +44 -0
  281. package/src/settings/AppshotSettingsView.tsx +132 -0
  282. package/src/settings/ArchivedProjectsSettingsView.tsx +80 -0
  283. package/src/settings/BuiltinMcpSecretsDialogView.tsx +278 -0
  284. package/src/settings/BuiltinMcpSectionView.tsx +164 -0
  285. package/src/settings/EnvironmentSettingsView.tsx +176 -0
  286. package/src/settings/GeneralSettingsView.tsx +174 -0
  287. package/src/settings/ImChannelCardView.tsx +152 -0
  288. package/src/settings/ImChannelGuideDialogView.tsx +126 -0
  289. package/src/settings/ImFeishuDialogView.tsx +156 -0
  290. package/src/settings/ImLegacyImportBannerView.tsx +44 -0
  291. package/src/settings/ImLogDrawerView.tsx +75 -0
  292. package/src/settings/ImStatusBadgeView.tsx +39 -0
  293. package/src/settings/McpDefaultIcon.tsx +27 -0
  294. package/src/settings/McpJsonEditorView.tsx +56 -0
  295. package/src/settings/ModelsProviderFormView.tsx +128 -0
  296. package/src/settings/ModelsProvidersSectionView.tsx +52 -0
  297. package/src/settings/MotionSelect.tsx +125 -0
  298. package/src/settings/PermissionsSettingsView.tsx +106 -0
  299. package/src/settings/PetBubbleStylePreviewView.tsx +44 -0
  300. package/src/settings/PetSettingsView.tsx +165 -0
  301. package/src/settings/PresetProviderModelsListView.tsx +58 -0
  302. package/src/settings/PresetProviderRowView.tsx +302 -0
  303. package/src/settings/PresetProvidersSectionView.tsx +70 -0
  304. package/src/settings/QrBindDialogView.tsx +165 -0
  305. package/src/settings/QuickPanelSettingsSectionView.tsx +66 -0
  306. package/src/settings/RemoteMcpSectionView.tsx +192 -0
  307. package/src/settings/SettingChrome.tsx +104 -0
  308. package/src/settings/SettingsAiAssistButtonView.tsx +150 -0
  309. package/src/settings/SettingsAiAssistDialogView.tsx +251 -0
  310. package/src/settings/SettingsFormFields.tsx +121 -0
  311. package/src/settings/SettingsPageShellView.tsx +84 -0
  312. package/src/settings/SettingsSidebarView.tsx +133 -0
  313. package/src/settings/ShortcutRecorderView.tsx +88 -0
  314. package/src/settings/ShortcutsSettingsView.tsx +66 -0
  315. package/src/settings/SubscriptionActionsView.tsx +63 -0
  316. package/src/settings/SubscriptionCardsView.tsx +212 -0
  317. package/src/settings/TeamDetailView.tsx +148 -0
  318. package/src/settings/TeamDialogsView.tsx +151 -0
  319. package/src/settings/TeamListView.tsx +57 -0
  320. package/src/settings/TeamSettingsView.tsx +51 -0
  321. package/src/settings/TokenActivityChartView.tsx +286 -0
  322. package/src/settings/UsageStatsView.tsx +101 -0
  323. package/src/settings/WebhookEndpointListView.tsx +123 -0
  324. package/src/settings/WechatBindDialogView.tsx +45 -0
  325. package/src/settings/achievements/AchievementCurtains.tsx +50 -0
  326. package/src/settings/achievements/AchievementPromotionBadge3D.tsx +350 -0
  327. package/src/settings/achievements/AchievementPromotionConfetti.tsx +71 -0
  328. package/src/settings/achievements/AchievementTitle.tsx +52 -0
  329. package/src/settings/achievements/index.ts +13 -0
  330. package/src/settings/index.ts +226 -0
  331. package/src/settings/shouldCloseEmptyApiKeyEditor.test.ts +135 -0
  332. package/src/settings/shouldCloseEmptyApiKeyEditor.ts +40 -0
  333. package/src/settings/token-activity.test.ts +195 -0
  334. package/src/settings/token-activity.ts +320 -0
  335. package/src/shared/AvatarStackView.tsx +45 -0
  336. package/src/shared/BotAvatar.tsx +395 -0
  337. package/src/shared/CodeBlockCopyButton.tsx +48 -0
  338. package/src/shared/CollapsePanel.tsx +125 -0
  339. package/src/shared/ContextMenuView.tsx +134 -0
  340. package/src/shared/MacKeyboardPreview.tsx +260 -0
  341. package/src/shared/MarkdownTable.tsx +216 -0
  342. package/src/shared/MultiplierTag.tsx +15 -0
  343. package/src/shared/ScrollFade.tsx +114 -0
  344. package/src/shared/SegmentedControl.tsx +82 -0
  345. package/src/shared/SyntaxHighlightedCode.tsx +0 -0
  346. package/src/shared/TabBar.tsx +696 -0
  347. package/src/shared/TimePicker.tsx +96 -0
  348. package/src/shared/connected-tab-outline.test.ts +22 -0
  349. package/src/shared/connected-tab-outline.ts +39 -0
  350. package/src/shared/fileIcons.test.ts +28 -0
  351. package/src/shared/fileIcons.ts +322 -0
  352. package/src/shared/index.ts +38 -0
  353. package/src/shared/markdown-table-clipboard.ts +31 -0
  354. package/src/shared/provider-icon/icons.ts +56 -0
  355. package/src/shared/provider-icon/index.tsx +42 -0
  356. package/src/shared/provider-icon/svg-url.d.ts +4 -0
  357. package/src/shared/tab-drag.test.ts +14 -0
  358. package/src/shared/tab-drag.ts +15 -0
  359. package/src/shared/useDelayedUnmount.ts +36 -0
  360. package/src/sidebar/AddProjectMenuItem.tsx +21 -0
  361. package/src/sidebar/AddProjectMenuPopoverView.tsx +52 -0
  362. package/src/sidebar/AddProjectMenuTriggerView.tsx +50 -0
  363. package/src/sidebar/ChatMessageListView.tsx +66 -0
  364. package/src/sidebar/DefaultSidebar.tsx +91 -0
  365. package/src/sidebar/FlowingMessageListView.tsx +111 -0
  366. package/src/sidebar/MessageCenterDialogView.tsx +81 -0
  367. package/src/sidebar/MessageCenterEmptyState.tsx +24 -0
  368. package/src/sidebar/MessageCenterTabs.tsx +86 -0
  369. package/src/sidebar/MessageCenterToolbarButton.tsx +25 -0
  370. package/src/sidebar/MessageCenterTriggerView.tsx +39 -0
  371. package/src/sidebar/NotificationMessageListView.tsx +136 -0
  372. package/src/sidebar/ProjectsPanelEmptyState.tsx +20 -0
  373. package/src/sidebar/RunningPulseDot.tsx +10 -0
  374. package/src/sidebar/SessionStatusIcon.tsx +43 -0
  375. package/src/sidebar/SettingsMenuAccountSection.tsx +32 -0
  376. package/src/sidebar/SettingsMenuActionButton.tsx +24 -0
  377. package/src/sidebar/SettingsMenuDivider.tsx +5 -0
  378. package/src/sidebar/SettingsMenuQuotaSection.tsx +45 -0
  379. package/src/sidebar/SettingsMenuSettingsItem.tsx +18 -0
  380. package/src/sidebar/SettingsMenuThemeSection.tsx +51 -0
  381. package/src/sidebar/SettingsMenuTriggerView.tsx +65 -0
  382. package/src/sidebar/ShowMoreSessionsButton.tsx +37 -0
  383. package/src/sidebar/SidebarFilterSelectView.tsx +95 -0
  384. package/src/sidebar/SidebarNavBadgeView.tsx +58 -0
  385. package/src/sidebar/SidebarNavIcon.tsx +33 -0
  386. package/src/sidebar/SidebarNavItemButton.tsx +59 -0
  387. package/src/sidebar/SidebarNavMorePanel.tsx +199 -0
  388. package/src/sidebar/SidebarNavigation.tsx +223 -0
  389. package/src/sidebar/SidebarPanel.tsx +48 -0
  390. package/src/sidebar/SidebarTopBar.tsx +103 -0
  391. package/src/sidebar/SidebarUpdateIcon.tsx +79 -0
  392. package/src/sidebar/index.ts +118 -0
  393. package/src/sidebar/nav-badge-text.test.ts +23 -0
  394. package/src/sidebar/nav-badge-text.ts +19 -0
  395. package/src/sidebar/useSidebarNavDrag.ts +139 -0
  396. package/src/skills/PluginCardView.tsx +150 -0
  397. package/src/skills/SceneCardView.tsx +194 -0
  398. package/src/skills/SkillCardView.tsx +186 -0
  399. package/src/skills/SkillDetailDialogView.tsx +138 -0
  400. package/src/skills/SkillTagGroupView.tsx +56 -0
  401. package/src/skills/SkillToggleSwitch.tsx +31 -0
  402. package/src/skills/index.ts +29 -0
  403. package/src/skills/skill-icon.test.ts +38 -0
  404. package/src/skills/skill-icon.tsx +126 -0
  405. package/src/styles.css +75 -0
  406. package/src/utils/platform.ts +2 -0
@@ -0,0 +1,238 @@
1
+ import { createRequire } from "node:module";
2
+ import { describe, expect, test } from "vitest";
3
+ import {
4
+ chatUrlTransform,
5
+ classifyMarkdownLink,
6
+ fileUrlToPath,
7
+ normalizeLocalFileLinksInMarkdown,
8
+ } from "./markdown-link";
9
+
10
+ describe("fileUrlToPath", () => {
11
+ test("posix file URL", () => {
12
+ expect(fileUrlToPath("file:///home/u/a.ts")).toBe("/home/u/a.ts");
13
+ });
14
+
15
+ test("windows drive file URL", () => {
16
+ expect(fileUrlToPath("file:///C:/Users/u/a.ts")).toBe("C:/Users/u/a.ts");
17
+ });
18
+
19
+ test("windows drive with encoded spaces", () => {
20
+ expect(fileUrlToPath("file:///C:/Users/u/My%20Docs/a.ts")).toBe("C:/Users/u/My Docs/a.ts");
21
+ });
22
+ });
23
+
24
+ describe("chatUrlTransform", () => {
25
+ test("preserves windows drive paths that defaultUrlTransform blanks", () => {
26
+ expect(chatUrlTransform("C:\\Users\\u\\a.html")).toBe("C:\\Users\\u\\a.html");
27
+ expect(chatUrlTransform("C:/Users/u/a.html")).toBe("C:/Users/u/a.html");
28
+ expect(chatUrlTransform("C:%5CUsers%5Cu%5Ca.html")).toBe("C:%5CUsers%5Cu%5Ca.html");
29
+ });
30
+
31
+ test("preserves file: URLs", () => {
32
+ expect(chatUrlTransform("file:///C:/Users/u/a.html")).toBe("file:///C:/Users/u/a.html");
33
+ expect(chatUrlTransform("file:///tmp/a.html")).toBe("file:///tmp/a.html");
34
+ });
35
+
36
+ test("still blocks javascript:", () => {
37
+ expect(chatUrlTransform("javascript:alert(1)")).toBe("");
38
+ });
39
+
40
+ test("keeps https and posix absolute", () => {
41
+ expect(chatUrlTransform("https://example.com/a")).toBe("https://example.com/a");
42
+ expect(chatUrlTransform("/tmp/a.html")).toBe("/tmp/a.html");
43
+ });
44
+ });
45
+
46
+ describe("normalizeLocalFileLinksInMarkdown", () => {
47
+ test("repairs the exact Windows deliverable link emitted with spaces and parentheses", () => {
48
+ const input = "[travel-app.vetd](/C:/Users/admin/Desktop/新建文件夹 (7)/vetta/travel-app.vetd)";
49
+ expect(normalizeLocalFileLinksInMarkdown(input)).toBe(
50
+ "[travel-app.vetd](</C:/Users/admin/Desktop/新建文件夹 (7)/vetta/travel-app.vetd>)",
51
+ );
52
+ });
53
+
54
+ test("repairs POSIX absolute paths with spaces using a CommonMark angle-bracket destination", () => {
55
+ const input = "[report.pdf](/home/user/My Reports/report.pdf)";
56
+ expect(normalizeLocalFileLinksInMarkdown(input)).toBe("[report.pdf](</home/user/My Reports/report.pdf>)");
57
+ });
58
+
59
+ test("rewrites backslash destinations to forward slashes", () => {
60
+ const input = "[index.html](C:\\Users\\flowerwine\\.vetta\\conversation\\afc54df9\\index.html)";
61
+ const out = normalizeLocalFileLinksInMarkdown(input);
62
+ expect(out).toBe("[index.html](<C:/Users/flowerwine/.vetta/conversation/afc54df9/index.html>)");
63
+ });
64
+
65
+ test("rewrites angle-bracket destinations", () => {
66
+ const input = "[a](<C:\\Users\\x\\.vetta\\a.html>)";
67
+ expect(normalizeLocalFileLinksInMarkdown(input)).toBe("[a](<C:/Users/x/.vetta/a.html>)");
68
+ });
69
+
70
+ test("standardizes absolute local links and leaves web links alone", () => {
71
+ const input = "[a](C:/Users/x/a.html) and [b](https://x.com) and [c](/tmp/a)";
72
+ expect(normalizeLocalFileLinksInMarkdown(input)).toBe(
73
+ "[a](<C:/Users/x/a.html>) and [b](https://x.com) and [c](</tmp/a>)",
74
+ );
75
+ });
76
+
77
+ test("preserves standard markdown link titles", () => {
78
+ const input = "[a](C:/Users/x/a.html \"title\") and [b](/tmp/b.md 'title')";
79
+ expect(normalizeLocalFileLinksInMarkdown(input)).toBe(
80
+ "[a](<C:/Users/x/a.html> \"title\") and [b](</tmp/b.md> 'title')",
81
+ );
82
+ });
83
+
84
+ test("does not rewrite examples inside inline or fenced code", () => {
85
+ const inline = "`[a](C:/Users/x/My File.md)`";
86
+ const fenced = "```md\n[a](C:/Users/x/My File.md)\n```";
87
+ expect(normalizeLocalFileLinksInMarkdown(inline)).toBe(inline);
88
+ expect(normalizeLocalFileLinksInMarkdown(fenced)).toBe(fenced);
89
+ });
90
+ });
91
+
92
+ describe("classifyMarkdownLink", () => {
93
+ test("https URL", () => {
94
+ expect(classifyMarkdownLink("https://example.com/a")).toEqual({
95
+ type: "url",
96
+ url: "https://example.com/a",
97
+ });
98
+ });
99
+
100
+ test("protocol-relative URL", () => {
101
+ expect(classifyMarkdownLink("//cdn.example.com/x.js")).toEqual({
102
+ type: "url",
103
+ url: "https://cdn.example.com/x.js",
104
+ });
105
+ });
106
+
107
+ test("posix absolute path", () => {
108
+ expect(classifyMarkdownLink("/tmp/out.pdf")).toEqual({
109
+ type: "file",
110
+ path: "/tmp/out.pdf",
111
+ });
112
+ });
113
+
114
+ test("windows absolute path with backslashes", () => {
115
+ expect(classifyMarkdownLink("C:\\project\\report.pdf")).toEqual({
116
+ type: "file",
117
+ path: "C:/project/report.pdf",
118
+ });
119
+ });
120
+
121
+ test("windows absolute path with slashes", () => {
122
+ expect(classifyMarkdownLink("C:/project/report.pdf")).toEqual({
123
+ type: "file",
124
+ path: "C:/project/report.pdf",
125
+ });
126
+ });
127
+
128
+ test("rehype percent-encoded windows path", () => {
129
+ expect(classifyMarkdownLink("C:%5CUsers%5Cflowerwine%5C.vetta%5Cconversation%5Cafc54df9%5Cindex.html")).toEqual({
130
+ type: "file",
131
+ path: "C:/Users/flowerwine/.vetta/conversation/afc54df9/index.html",
132
+ });
133
+ });
134
+
135
+ test("file URL windows", () => {
136
+ expect(classifyMarkdownLink("file:///D:/work/a.md")).toEqual({
137
+ type: "file",
138
+ path: "D:/work/a.md",
139
+ });
140
+ });
141
+
142
+ test("relative with ./", () => {
143
+ expect(classifyMarkdownLink("./src/index.ts")).toEqual({
144
+ type: "file",
145
+ path: "./src/index.ts",
146
+ });
147
+ });
148
+
149
+ test("relative with path segment", () => {
150
+ expect(classifyMarkdownLink("src/index.ts")).toEqual({
151
+ type: "file",
152
+ path: "src/index.ts",
153
+ });
154
+ });
155
+
156
+ test("bare filename with known extension", () => {
157
+ expect(classifyMarkdownLink("readme.md")).toEqual({
158
+ type: "file",
159
+ path: "readme.md",
160
+ });
161
+ });
162
+
163
+ test("does not treat bare domain as file", () => {
164
+ expect(classifyMarkdownLink("www.example.com")).toEqual({
165
+ type: "other",
166
+ href: "www.example.com",
167
+ });
168
+ });
169
+
170
+ test("fragment and mailto are other", () => {
171
+ expect(classifyMarkdownLink("#section")).toEqual({ type: "other", href: "#section" });
172
+ expect(classifyMarkdownLink("mailto:a@b.com")).toEqual({
173
+ type: "other",
174
+ href: "mailto:a@b.com",
175
+ });
176
+ });
177
+
178
+ test("empty href after urlTransform blank is other", () => {
179
+ expect(classifyMarkdownLink("")).toEqual({ type: "other", href: "" });
180
+ });
181
+ });
182
+
183
+ describe("end-to-end: remark parse + urlTransform for user example", () => {
184
+ test("forward-slash Windows path with spaces and parentheses survives as a file link", () => {
185
+ const r = createRequire(import.meta.url);
186
+ const rmPath = r.resolve("react-markdown");
187
+ const r2 = createRequire(rmPath);
188
+ const { unified } = r2("unified");
189
+ const remarkParse = r2("remark-parse").default || r2("remark-parse");
190
+ const remarkRehype = r2("remark-rehype").default || r2("remark-rehype");
191
+ const { visit } = r2("unist-util-visit");
192
+
193
+ const raw = "[travel-app.vetd](/C:/Users/admin/Desktop/新建文件夹 (7)/vetta/travel-app.vetd)";
194
+ const source = normalizeLocalFileLinksInMarkdown(raw);
195
+ const processor = unified().use(remarkParse).use(remarkRehype);
196
+ const tree = processor.runSync(processor.parse(source));
197
+ let href: string | undefined;
198
+ visit(tree, "element", (node: { tagName?: string; properties?: { href?: string } }) => {
199
+ if (node.tagName === "a") href = node.properties?.href;
200
+ });
201
+
202
+ expect(href).toBe(
203
+ "/C:/Users/admin/Desktop/%E6%96%B0%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9%20(7)/vetta/travel-app.vetd",
204
+ );
205
+ expect(classifyMarkdownLink(chatUrlTransform(href ?? ""))).toEqual({
206
+ type: "file",
207
+ path: "/C:/Users/admin/Desktop/新建文件夹 (7)/vetta/travel-app.vetd",
208
+ });
209
+ });
210
+
211
+ test("backslash path survives and classifies as file with .vetta intact", () => {
212
+ const r = createRequire(import.meta.url);
213
+ const rmPath = r.resolve("react-markdown");
214
+ const r2 = createRequire(rmPath);
215
+ const { unified } = r2("unified");
216
+ const remarkParse = r2("remark-parse").default || r2("remark-parse");
217
+ const remarkRehype = r2("remark-rehype").default || r2("remark-rehype");
218
+ const { visit } = r2("unist-util-visit");
219
+
220
+ const BS = "\\";
221
+ const raw = `[index.html](C:${BS}Users${BS}flowerwine${BS}.vetta${BS}conversation${BS}afc54df9-bcf0-4ec0-9632-0c2a4dde88c7${BS}index.html)`;
222
+ const source = normalizeLocalFileLinksInMarkdown(raw);
223
+ expect(source).toContain("flowerwine/.vetta/");
224
+
225
+ const tree = unified().use(remarkParse).use(remarkRehype).runSync(unified().use(remarkParse).parse(source));
226
+ let href: string | undefined;
227
+ visit(tree, "element", (node: { tagName?: string; properties?: { href?: string } }) => {
228
+ if (node.tagName === "a") href = node.properties?.href;
229
+ });
230
+ expect(href).toBeDefined();
231
+ const transformed = chatUrlTransform(href ?? "");
232
+ expect(transformed).not.toBe("");
233
+ expect(classifyMarkdownLink(transformed)).toEqual({
234
+ type: "file",
235
+ path: "C:/Users/flowerwine/.vetta/conversation/afc54df9-bcf0-4ec0-9632-0c2a4dde88c7/index.html",
236
+ });
237
+ });
238
+ });
@@ -0,0 +1,279 @@
1
+ /**
2
+ * Classify markdown `href` values for chat text blocks.
3
+ *
4
+ * LLMs emit many shapes: `file://`, POSIX `/abs`, Windows `C:\…`,
5
+ * relative `./foo` / `src/a.ts`, and real `https://` URLs. Misclassifying a
6
+ * local path as a generic anchor (especially with `target="_blank"`) opens
7
+ * the system browser instead of the in-app file preview.
8
+ *
9
+ * Also: `react-markdown`'s `defaultUrlTransform` treats `C:` as an unknown
10
+ * protocol and blanks the href — Windows paths must be allowlisted via
11
+ * {@link chatUrlTransform}. Models also occasionally omit CommonMark's angle
12
+ * brackets around local destinations that contain whitespace. The normalizer
13
+ * repairs those legacy forms before parse and standardizes local destinations.
14
+ */
15
+
16
+ import { defaultUrlTransform } from "react-markdown";
17
+
18
+ export type MarkdownLinkKind =
19
+ | { type: "file"; path: string }
20
+ | { type: "url"; url: string }
21
+ | { type: "other"; href: string };
22
+
23
+ function safeDecode(raw: string): string {
24
+ try {
25
+ return decodeURIComponent(raw);
26
+ } catch {
27
+ return raw;
28
+ }
29
+ }
30
+
31
+ function toPosixSeparators(path: string): string {
32
+ return path.replace(/\\/g, "/");
33
+ }
34
+
35
+ /**
36
+ * Allow local filesystem hrefs that `defaultUrlTransform` would strip because
37
+ * it sees `C:` / `file:` as unsafe protocols. Everything else keeps the
38
+ * library default (blocks `javascript:` etc.).
39
+ */
40
+ export function chatUrlTransform(url: string): string {
41
+ // Windows drive: C:\… C:/… or rehype-encoded C:%5C…
42
+ if (/^[A-Za-z]:[\\/]/.test(url) || /^[A-Za-z]:%5[Cc]/i.test(url)) {
43
+ return url;
44
+ }
45
+ // file:// local URLs
46
+ if (/^file:/i.test(url)) {
47
+ return url;
48
+ }
49
+ return defaultUrlTransform(url);
50
+ }
51
+
52
+ interface MarkdownFence {
53
+ character: "`" | "~";
54
+ length: number;
55
+ }
56
+
57
+ const STANDARD_LINK_TITLE = /^(\S+)(\s+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\([^()]*\)))$/;
58
+
59
+ function splitStandardLinkTitle(destination: string): { path: string; title: string } {
60
+ const match = STANDARD_LINK_TITLE.exec(destination);
61
+ return match ? { path: match[1], title: match[2] } : { path: destination, title: "" };
62
+ }
63
+
64
+ function normalizeAbsoluteLocalDestination(path: string): string | null {
65
+ if (!path || /[<>\r\n]/.test(path)) return null;
66
+ if (/^\\\\[^\\]/.test(path)) {
67
+ return `file://${path.slice(2).replace(/\\/g, "/")}`;
68
+ }
69
+ if (/^file:/i.test(path)) return path.replace(/\\/g, "/");
70
+ if (/^\/?[A-Za-z]:[\\/]/.test(path)) return path.replace(/\\/g, "/");
71
+ if (path.startsWith("/") && !path.startsWith("//")) return path;
72
+ return null;
73
+ }
74
+
75
+ function normalizeBareDestination(destination: string): string | null {
76
+ const { path, title } = splitStandardLinkTitle(destination);
77
+ const normalized = normalizeAbsoluteLocalDestination(path);
78
+ return normalized ? `<${normalized}>${title}` : null;
79
+ }
80
+
81
+ function findBareDestinationEnd(line: string, start: number): number {
82
+ let parenthesesDepth = 0;
83
+ for (let index = start; index < line.length; index++) {
84
+ if (line[index] === "(") {
85
+ parenthesesDepth++;
86
+ continue;
87
+ }
88
+ if (line[index] !== ")") continue;
89
+ if (parenthesesDepth === 0) return index;
90
+ parenthesesDepth--;
91
+ }
92
+ return -1;
93
+ }
94
+
95
+ function normalizeMarkdownLine(line: string): string {
96
+ if (/^(?: {4}|\t)/.test(line)) return line;
97
+
98
+ let result = "";
99
+ let cursor = 0;
100
+ let codeDelimiterLength = 0;
101
+ for (let index = 0; index < line.length; ) {
102
+ if (line[index] === "`") {
103
+ let end = index + 1;
104
+ while (line[end] === "`") end++;
105
+ const runLength = end - index;
106
+ if (codeDelimiterLength === 0) codeDelimiterLength = runLength;
107
+ else if (runLength === codeDelimiterLength) codeDelimiterLength = 0;
108
+ index = end;
109
+ continue;
110
+ }
111
+
112
+ if (codeDelimiterLength !== 0 || line[index] !== "]" || line[index + 1] !== "(") {
113
+ index++;
114
+ continue;
115
+ }
116
+
117
+ const destinationStart = index + 2;
118
+ if (line[destinationStart] === "<") {
119
+ const angleEnd = line.indexOf(">)", destinationStart + 1);
120
+ if (angleEnd === -1) {
121
+ index++;
122
+ continue;
123
+ }
124
+ const normalized = normalizeAbsoluteLocalDestination(line.slice(destinationStart + 1, angleEnd));
125
+ if (!normalized) {
126
+ index = angleEnd + 2;
127
+ continue;
128
+ }
129
+ result += `${line.slice(cursor, destinationStart)}<${normalized}>)`;
130
+ cursor = angleEnd + 2;
131
+ index = cursor;
132
+ continue;
133
+ }
134
+
135
+ const destinationEnd = findBareDestinationEnd(line, destinationStart);
136
+ if (destinationEnd === -1) {
137
+ index++;
138
+ continue;
139
+ }
140
+ const normalized = normalizeBareDestination(line.slice(destinationStart, destinationEnd));
141
+ if (!normalized) {
142
+ index = destinationEnd + 1;
143
+ continue;
144
+ }
145
+ result += `${line.slice(cursor, destinationStart)}${normalized})`;
146
+ cursor = destinationEnd + 1;
147
+ index = cursor;
148
+ }
149
+ return result + line.slice(cursor);
150
+ }
151
+
152
+ /**
153
+ * Standardize absolute local link destinations as CommonMark angle-bracket
154
+ * destinations before parsing. This makes whitespace and balanced parentheses
155
+ * unambiguous, converts Windows separators, and repairs already persisted model
156
+ * output such as `[file](/C:/Users/name/My Files/file.md)`.
157
+ *
158
+ */
159
+ export function normalizeLocalFileLinksInMarkdown(markdown: string): string {
160
+ const parts = markdown.split(/(\r\n|\n|\r)/);
161
+ let fence: MarkdownFence | null = null;
162
+ return parts
163
+ .map((part) => {
164
+ if (part === "\n" || part === "\r" || part === "\r\n") return part;
165
+ const marker = /^ {0,3}(`{3,}|~{3,})/.exec(part)?.[1];
166
+ if (marker) {
167
+ const character = marker[0] as MarkdownFence["character"];
168
+ if (!fence) fence = { character, length: marker.length };
169
+ else if (
170
+ character === fence.character &&
171
+ marker.length >= fence.length &&
172
+ part.slice(part.indexOf(marker) + marker.length).trim() === ""
173
+ ) {
174
+ fence = null;
175
+ }
176
+ return part;
177
+ }
178
+ return fence ? part : normalizeMarkdownLine(part);
179
+ })
180
+ .join("");
181
+ }
182
+
183
+ /**
184
+ * Convert a `file://` URL to an OS path (POSIX absolute or Windows drive/UNC).
185
+ * Returns null when the input is not a usable file URL.
186
+ */
187
+ export function fileUrlToPath(href: string): string | null {
188
+ try {
189
+ const url = new URL(href);
190
+ if (url.protocol !== "file:") return null;
191
+ let path = safeDecode(url.pathname);
192
+ // Windows drive: /C:/Users → C:/Users
193
+ if (/^\/[A-Za-z]:/.test(path)) {
194
+ path = path.slice(1);
195
+ }
196
+ // UNC: file://server/share/path → //server/share/path
197
+ if (url.hostname && url.hostname !== "localhost") {
198
+ const body = path.startsWith("/") ? path : `/${path}`;
199
+ path = `//${url.hostname}${body}`;
200
+ }
201
+ return toPosixSeparators(path) || null;
202
+ } catch {
203
+ const stripped = safeDecode(href.replace(/^file:\/\//i, ""));
204
+ if (!stripped) return null;
205
+ if (/^\/[A-Za-z]:/.test(stripped)) {
206
+ return toPosixSeparators(stripped.slice(1));
207
+ }
208
+ return toPosixSeparators(stripped);
209
+ }
210
+ }
211
+
212
+ /**
213
+ * Bare names like `readme.md` should open as files; bare domains like
214
+ * `www.example.com` must not. Prefer path separators / relative prefixes;
215
+ * fall back to a conservative extension allowlist (not generic TLDs).
216
+ */
217
+ const LIKELY_FILE_EXT =
218
+ /\.(?:tsx?|jsx?|mjs|cjs|json|mdx?|txt|pdf|png|jpe?g|gif|webp|svg|html?|css|scss|less|py|rs|go|java|kt|swift|c|cc|cpp|h|hpp|cs|rb|php|sh|bash|zsh|ya?ml|toml|xml|csv|tsv|xlsx?|docx?|pptx?|zip|gz|tgz|7z|rar|mp3|mp4|wav|webm|ico|woff2?|ttf|otf|map|sql|vue|svelte|astro|wasm|log|conf|cfg|ini|plist|ipynb|rtf|lock|env)$/i;
219
+
220
+ function looksLikeRelativeFilePath(value: string): boolean {
221
+ if (/^[.]{1,2}[\\/]/.test(value)) return true;
222
+ if (/[\\/]/.test(value)) return true;
223
+ return LIKELY_FILE_EXT.test(value);
224
+ }
225
+
226
+ /**
227
+ * Classify a markdown link href into file / external URL / other.
228
+ * File paths are returned with `/` separators; relative paths are left relative
229
+ * for the host to resolve against the project cwd.
230
+ */
231
+ export function classifyMarkdownLink(href: string | undefined): MarkdownLinkKind {
232
+ if (!href) return { type: "other", href: "" };
233
+ const trimmed = href.trim();
234
+ if (!trimmed || trimmed.startsWith("#")) {
235
+ return { type: "other", href: trimmed };
236
+ }
237
+
238
+ if (/^(mailto|tel|javascript|data|blob|vetta):/i.test(trimmed)) {
239
+ return { type: "other", href: trimmed };
240
+ }
241
+
242
+ if (/^https?:\/\//i.test(trimmed)) {
243
+ return { type: "url", url: trimmed };
244
+ }
245
+
246
+ // Protocol-relative URL (//cdn.example.com/x) — not a Windows UNC path.
247
+ if (trimmed.startsWith("//") && !trimmed.startsWith("\\\\")) {
248
+ return { type: "url", url: `https:${trimmed}` };
249
+ }
250
+
251
+ if (/^file:\/\//i.test(trimmed)) {
252
+ const path = fileUrlToPath(trimmed);
253
+ if (path) return { type: "file", path };
254
+ return { type: "other", href: trimmed };
255
+ }
256
+
257
+ const decoded = safeDecode(trimmed);
258
+
259
+ // Windows drive absolute: C:\… or C:/… (after decode of %5C)
260
+ if (/^[A-Za-z]:[\\/]/.test(decoded)) {
261
+ return { type: "file", path: toPosixSeparators(decoded) };
262
+ }
263
+
264
+ // Windows UNC: \\server\share
265
+ if (decoded.startsWith("\\\\")) {
266
+ return { type: "file", path: toPosixSeparators(decoded) };
267
+ }
268
+
269
+ // POSIX absolute
270
+ if (decoded.startsWith("/")) {
271
+ return { type: "file", path: decoded };
272
+ }
273
+
274
+ if (looksLikeRelativeFilePath(decoded)) {
275
+ return { type: "file", path: toPosixSeparators(decoded) };
276
+ }
277
+
278
+ return { type: "other", href: trimmed };
279
+ }