@bevel-software/platform-core-frontend 0.14.0 → 0.19.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 (360) hide show
  1. package/THIRD-PARTY-NOTICES.md +2 -2
  2. package/package.json +3 -3
  3. package/src/core/CoreAppShell.tsx +34 -26
  4. package/src/core/__tests__/AppChrome.test.tsx +0 -3
  5. package/src/core/__tests__/bootstrap.test.ts +33 -1
  6. package/src/core/__tests__/events.test.ts +43 -0
  7. package/src/core/bootstrap.ts +38 -1
  8. package/src/core/events.ts +85 -3
  9. package/src/core/registry.ts +1 -1
  10. package/src/lib/__tests__/api.test.ts +38 -0
  11. package/src/lib/__tests__/email.test.ts +44 -0
  12. package/src/lib/api.ts +19 -2
  13. package/src/lib/email.ts +37 -1
  14. package/src/lib/utils.ts +2 -0
  15. package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
  16. package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
  17. package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
  18. package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
  19. package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
  20. package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
  21. package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
  22. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
  23. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
  24. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +781 -76
  25. package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
  26. package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
  27. package/src/modules/access/__tests__/plugin-token.test.ts +21 -0
  28. package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
  29. package/src/modules/access/api.ts +192 -10
  30. package/src/modules/access/components/ManageAccessDialog.tsx +1337 -570
  31. package/src/modules/access/manage-access-affordance.ts +17 -0
  32. package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
  33. package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
  34. package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
  35. package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
  36. package/src/modules/admin/__tests__/ConnectionKeysPage.test.tsx +266 -0
  37. package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
  38. package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
  39. package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
  40. package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
  41. package/src/modules/admin/components/AddMemberInput.tsx +268 -0
  42. package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
  43. package/src/modules/admin/components/ConnectionKeysPage.tsx +269 -0
  44. package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
  45. package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
  46. package/src/modules/admin/components/connection-keys-grouping.ts +43 -0
  47. package/src/modules/admin/components/group-members-path.ts +32 -0
  48. package/src/modules/admin/services/connection-keys.api.ts +47 -0
  49. package/src/modules/admin/services/roles.api.ts +12 -1
  50. package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
  51. package/src/modules/auth/components/AccountPage.tsx +73 -54
  52. package/src/modules/auth/components/LoginScreen.tsx +1 -0
  53. package/src/modules/auth/services/account.api.ts +78 -4
  54. package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
  55. package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
  56. package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
  57. package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
  58. package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
  59. package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
  60. package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
  61. package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
  62. package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
  63. package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
  64. package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
  65. package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
  66. package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
  67. package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
  68. package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
  69. package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
  70. package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
  71. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
  72. package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
  73. package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
  74. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
  75. package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
  76. package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
  77. package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
  78. package/src/modules/change-requests/services/change-requests.api.ts +57 -1
  79. package/src/modules/change-requests/services/denied-file.api.ts +53 -0
  80. package/src/modules/change-requests/services/propose.api.ts +97 -8
  81. package/src/modules/change-requests/utils/approval.ts +15 -0
  82. package/src/modules/change-requests/utils/author.ts +32 -0
  83. package/src/modules/change-requests/utils/readFailure.ts +110 -0
  84. package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
  85. package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +65 -1
  86. package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
  87. package/src/modules/git/components/GitSyncFailedBanner.tsx +68 -5
  88. package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
  89. package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
  90. package/src/modules/git/services/error-messages.ts +12 -0
  91. package/src/modules/git/services/pr-prompts.ts +5 -5
  92. package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
  93. package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
  94. package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
  95. package/src/modules/layout/components/AppLayout.tsx +2 -0
  96. package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
  97. package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
  98. package/src/modules/layout/components/SidebarFrame.tsx +109 -4
  99. package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
  100. package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
  101. package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
  102. package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
  103. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
  104. package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +104 -99
  105. package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +136 -0
  106. package/src/modules/library/__tests__/LockedPluginView.test.tsx +103 -7
  107. package/src/modules/library/__tests__/NewPluginDialog.test.tsx +18 -8
  108. package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
  109. package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
  110. package/src/modules/library/__tests__/PluginExtras.test.tsx +115 -9
  111. package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
  112. package/src/modules/library/__tests__/PluginPage.test.tsx +453 -7
  113. package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +17 -57
  114. package/src/modules/library/__tests__/PluginsSidebar.test.tsx +161 -97
  115. package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
  116. package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
  117. package/src/modules/library/__tests__/SkillPage.test.tsx +391 -78
  118. package/src/modules/library/__tests__/SkillsTree.test.tsx +461 -0
  119. package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
  120. package/src/modules/library/__tests__/ToolPage.test.tsx +94 -4
  121. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +279 -21
  122. package/src/modules/library/__tests__/auth-harness.tsx +9 -9
  123. package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
  124. package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
  125. package/src/modules/library/__tests__/library-data.stale.test.tsx +183 -0
  126. package/src/modules/library/__tests__/library-data.test.ts +7 -0
  127. package/src/modules/library/__tests__/library-paths.test.ts +75 -0
  128. package/src/modules/library/__tests__/link-membership.test.ts +129 -0
  129. package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
  130. package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
  131. package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
  132. package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
  133. package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
  134. package/src/modules/library/__tests__/plugin-summary.test.ts +67 -0
  135. package/src/modules/library/__tests__/status.test.ts +82 -2
  136. package/src/modules/library/__tests__/tools.api.test.ts +44 -1
  137. package/src/modules/library/__tests__/useJoinRequests.test.tsx +46 -0
  138. package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
  139. package/src/modules/library/components/AddDialogTabs.tsx +103 -0
  140. package/src/modules/library/components/AddToPluginDialog.tsx +107 -18
  141. package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
  142. package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
  143. package/src/modules/library/components/LibraryCard.tsx +149 -34
  144. package/src/modules/library/components/LibraryLayout.tsx +120 -247
  145. package/src/modules/library/components/LibraryPage.tsx +172 -39
  146. package/src/modules/library/components/LinkSkillPanel.tsx +169 -0
  147. package/src/modules/library/components/LockedPluginView.tsx +63 -35
  148. package/src/modules/library/components/NameWithBadges.tsx +164 -0
  149. package/src/modules/library/components/NewPluginDialog.tsx +19 -5
  150. package/src/modules/library/components/PageActions.tsx +31 -9
  151. package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
  152. package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
  153. package/src/modules/library/components/PersonalPluginPage.tsx +123 -23
  154. package/src/modules/library/components/PluginExtras.tsx +143 -18
  155. package/src/modules/library/components/PluginIndexRow.tsx +47 -12
  156. package/src/modules/library/components/PluginPage.tsx +234 -38
  157. package/src/modules/library/components/PluginRows.tsx +286 -0
  158. package/src/modules/library/components/PluginsSidebar.tsx +271 -238
  159. package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
  160. package/src/modules/library/components/RenamePluginDialog.tsx +136 -0
  161. package/src/modules/library/components/ShareButton.tsx +17 -0
  162. package/src/modules/library/components/SkillsTree.tsx +204 -0
  163. package/src/modules/library/components/StatusDot.tsx +1 -0
  164. package/src/modules/library/components/TeamRoute.tsx +15 -0
  165. package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
  166. package/src/modules/library/components/plugin-page-parts.tsx +132 -23
  167. package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +212 -0
  168. package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
  169. package/src/modules/library/components/skill-page/SkillPage.tsx +337 -121
  170. package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
  171. package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
  172. package/src/modules/library/components/tool-page/ToolPage.tsx +116 -17
  173. package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
  174. package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
  175. package/src/modules/library/hooks/useJoinRequests.ts +48 -18
  176. package/src/modules/library/hooks/useLibraryData.ts +92 -19
  177. package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
  178. package/src/modules/library/routes/WorkspaceItemRoute.tsx +229 -82
  179. package/src/modules/library/routes/library-paths.ts +46 -35
  180. package/src/modules/library/services/library.api.ts +89 -17
  181. package/src/modules/library/services/plugins.api.ts +161 -9
  182. package/src/modules/library/services/teams.api.ts +15 -0
  183. package/src/modules/library/services/tools.api.ts +78 -0
  184. package/src/modules/library/state/library-data.tsx +268 -37
  185. package/src/modules/library/utils/personal-plugin.ts +13 -15
  186. package/src/modules/library/utils/plugin-entries.ts +134 -0
  187. package/src/modules/library/utils/plugin-summary.ts +102 -0
  188. package/src/modules/library/utils/status.ts +204 -35
  189. package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +11 -3
  190. package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
  191. package/src/modules/onboarding/agent-clients.ts +55 -23
  192. package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
  193. package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
  194. package/src/modules/pr/services/pr-merge.api.ts +2 -1
  195. package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
  196. package/src/modules/review/components/ReviewPanel.tsx +15 -17
  197. package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
  198. package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
  199. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
  200. package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
  201. package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
  202. package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
  203. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
  204. package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
  205. package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
  206. package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
  207. package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
  208. package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
  209. package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
  210. package/src/modules/secrets-vault/services/connect.api.ts +36 -5
  211. package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
  212. package/src/modules/settings/components/ClaudeConnectionCard.tsx +154 -0
  213. package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
  214. package/src/modules/settings/components/DeploymentPage.tsx +16 -22
  215. package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
  216. package/src/modules/settings/components/__tests__/ClaudeConnectionCard.test.tsx +63 -0
  217. package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +74 -1
  218. package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
  219. package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +5 -5
  220. package/src/modules/settings/services/github-facade.api.ts +66 -0
  221. package/src/modules/settings/settings-nav-items.tsx +10 -2
  222. package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
  223. package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
  224. package/src/modules/setup/__tests__/setup.test.tsx +615 -4
  225. package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
  226. package/src/modules/setup/components/SetupGate.tsx +16 -16
  227. package/src/modules/setup/components/SetupScreen.tsx +711 -40
  228. package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
  229. package/src/modules/setup/services/setup.api.ts +218 -3
  230. package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
  231. package/src/modules/setup/utils/root-folders.ts +46 -0
  232. package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
  233. package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
  234. package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
  235. package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
  236. package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
  237. package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
  238. package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
  239. package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
  240. package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
  241. package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
  242. package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
  243. package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
  244. package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
  245. package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
  246. package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
  247. package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
  248. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +395 -124
  249. package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
  250. package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
  251. package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
  252. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +659 -36
  253. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
  254. package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
  255. package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
  256. package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
  257. package/src/modules/toolbar/components/deployment-address.ts +29 -0
  258. package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
  259. package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
  260. package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
  261. package/src/modules/toolbar/services/external-api-keys.api.ts +8 -0
  262. package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
  263. package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
  264. package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
  265. package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
  266. package/src/modules/workflow/state/event-bus.context.ts +10 -0
  267. package/src/modules/workspace/__tests__/testFixtures.ts +6 -3
  268. package/src/modules/workspace/components/FileExplorer.tsx +1527 -367
  269. package/src/modules/workspace/components/FileRoute.tsx +376 -22
  270. package/src/modules/workspace/components/FileViewer.tsx +166 -45
  271. package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
  272. package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
  273. package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
  274. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2473 -129
  275. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +768 -16
  276. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +332 -12
  277. package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
  278. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
  279. package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
  280. package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
  281. package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
  282. package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
  283. package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
  284. package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
  285. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
  286. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
  287. package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
  288. package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
  289. package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
  290. package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
  291. package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
  292. package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
  293. package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
  294. package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
  295. package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
  296. package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
  297. package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
  298. package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
  299. package/src/modules/workspace/components/renderers/index.ts +53 -2
  300. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
  301. package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
  302. package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
  303. package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
  304. package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
  305. package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
  306. package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
  307. package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +89 -0
  308. package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
  309. package/src/modules/workspace/hooks/useWorkspaceState.ts +438 -66
  310. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
  311. package/src/modules/workspace/routing/kb-routes.ts +207 -30
  312. package/src/modules/workspace/services/__tests__/workspace.api.test.ts +57 -1
  313. package/src/modules/workspace/services/workspace.api.ts +57 -4
  314. package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
  315. package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
  316. package/src/modules/workspace/state/open-change-requests.tsx +100 -12
  317. package/src/modules/workspace/state/workspace.context.ts +130 -16
  318. package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
  319. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +234 -5
  320. package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
  321. package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
  322. package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
  323. package/src/modules/workspace/utils/file-trace.ts +50 -0
  324. package/src/modules/workspace/utils/fileTree.ts +126 -52
  325. package/src/modules/workspace/utils/frontmatter.ts +8 -4
  326. package/src/modules/workspace/utils/pasteLink.ts +90 -0
  327. package/src/modules/workspace/utils/treeConfirm.ts +338 -0
  328. package/src/modules/workspace/utils/uploadError.ts +29 -0
  329. package/src/shared/__tests__/marketplace-url.test.ts +59 -0
  330. package/src/shared/components/Badge.tsx +3 -1
  331. package/src/shared/components/Banner.tsx +5 -1
  332. package/src/shared/components/Button.tsx +16 -2
  333. package/src/shared/components/Dialog.tsx +27 -11
  334. package/src/shared/components/Menu.tsx +13 -1
  335. package/src/shared/components/PageShell.tsx +13 -8
  336. package/src/shared/components/__tests__/primitives.test.tsx +116 -2
  337. package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
  338. package/src/shared/components/index.ts +2 -0
  339. package/src/shared/components/useDismissableMenu.ts +32 -10
  340. package/src/shared/components/useFocusHandoff.ts +51 -0
  341. package/src/shared/components/useLatestRef.ts +28 -0
  342. package/src/shared/markdown/Markdown.tsx +12 -3
  343. package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
  344. package/src/shared/markdown/hrefs.ts +50 -0
  345. package/src/shared/marketplace-url.ts +118 -0
  346. package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
  347. package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
  348. package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
  349. package/src/shared/mcp/connect-snippets.ts +14 -9
  350. package/src/shared/mcp/index.ts +1 -1
  351. package/src/shared/theme/__tests__/header-band.test.ts +197 -0
  352. package/src/shared/theme/header.ts +75 -0
  353. package/src/shared/theme/measure.ts +7 -4
  354. package/src/shared/theme/tokens.css +34 -0
  355. package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
  356. package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
  357. package/src/modules/library/components/PluginsIndexPage.tsx +0 -265
  358. package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
  359. package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
  360. package/src/modules/update-check/services/update-check.api.ts +0 -24
@@ -1,7 +1,8 @@
1
- import { useCallback, useEffect, useState } from 'react';
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import type { PullRequestSummary } from '@bevel-software/platform-shared';
3
3
  import { fetchFileAccessBatch } from '../../access/api';
4
4
  import { listToolSecrets, type ToolSecrets } from '../../secrets-vault/services/tool-secrets.api';
5
+ import { listPendingTools, type PendingToolSummary } from '../services/tools.api';
5
6
  import {
6
7
  defaultWorkspaceId,
7
8
  getSkill,
@@ -21,19 +22,37 @@ import {
21
22
  * - skills — `GET /api/skills` (default-branch catalog, canRead-filtered)
22
23
  * - tools — `GET /api/secrets/tools` (variables + per-user config status
23
24
  * + per-tool `canWrite`)
24
- * - ownership — "owned by me" = write access on the skill's `SKILL.md`
25
- * (`POST /workspace/:id/access/batch` on the default-branch
26
- * workspace); tools reuse the `canWrite` the secrets route
27
- * already computes
25
+ * - ownership — "owned by me" = named in an `owner:` grant (directly or by
26
+ * role) on the skill's `SKILL.md` or the tool's `.tool` file:
27
+ * ONE `POST /workspace/:id/access/batch` with `verb: owner`
28
+ * on the default-branch workspace, skills and tools together
29
+ * (one more per 500 paths past the endpoint's cap).
30
+ * Write alone is not ownership — an Admin writes everywhere.
31
+ * - write — the skills' `SKILL.md` write verdict, the same batch without
32
+ * a verb; it drives the editor-side affordances, which a
33
+ * writer keeps whether or not they own. Tools reuse the
34
+ * `canWrite` the secrets route already computes
28
35
  * - change requests — all open + the caller's own, for the review layer
29
36
  * - pending skills — `GET /api/skills/pending`, the skills that exist only on
30
37
  * an open change request's branch (author + approvers only)
38
+ * - pending tools — `GET /api/tools/pending`, the same for a `.tool` manual or
39
+ * an `mcp.json` server proposed on an open change request
31
40
  *
32
41
  * Non-critical failures degrade to empty sets rather than blocking the page —
33
42
  * only the skills+tools pair failing surfaces as a load error.
34
43
  */
35
44
  export interface LibraryData {
45
+ /**
46
+ * True until the FIRST load answers. A reload keeps what is on screen and
47
+ * swaps it when the new answer lands: the library is re-read after every
48
+ * access edit, credential save and change-request event, and a load is
49
+ * many round trips (one per skill for its frontmatter), so dropping the
50
+ * page to "Loading…" each time meant a long blank after closing a dialog
51
+ * that changed nothing.
52
+ */
36
53
  loading: boolean;
54
+ /** A load is in flight behind what is on screen. Absent means no. */
55
+ refreshing?: boolean;
37
56
  error: string | null;
38
57
  skills: LibrarySkillSummary[];
39
58
  /**
@@ -43,8 +62,19 @@ export interface LibraryData {
43
62
  */
44
63
  pendingSkills: PendingSkillSummary[];
45
64
  tools: ToolSecrets[];
46
- /** Skill names (folder ids) whose SKILL.md the caller can write. */
65
+ /**
66
+ * Proposed tools, not yet released. Kept SEPARATE from `tools` for exactly
67
+ * the reason `pendingSkills` is kept out of `skills`: everything downstream
68
+ * of `tools` treats an entry as an integration that exists — it has a page, a
69
+ * connection state, secrets to fill in — and a proposal has none of that.
70
+ */
71
+ pendingTools: PendingToolSummary[];
72
+ /** Skill names (folder ids) whose SKILL.md names the caller in an `owner:` grant. */
47
73
  ownedSkills: Set<string>;
74
+ /** Skill names (folder ids) whose SKILL.md the caller can write. */
75
+ writableSkills: Set<string>;
76
+ /** Tool slugs whose `.tool` file names the caller in an `owner:` grant. */
77
+ ownedTools: Set<string>;
48
78
  /**
49
79
  * Per-skill `allowed-tools` frontmatter (name → entries), used to derive
50
80
  * which integrations a skill needs. Loaded via one `getSkill` per catalog
@@ -61,34 +91,59 @@ export interface LibraryData {
61
91
  export function useLibraryData(): LibraryData {
62
92
  const [state, setState] = useState<Omit<LibraryData, 'reload'>>({
63
93
  loading: true,
94
+ refreshing: false,
64
95
  error: null,
65
96
  skills: [],
66
97
  pendingSkills: [],
98
+ pendingTools: [],
67
99
  tools: [],
68
100
  ownedSkills: new Set(),
101
+ writableSkills: new Set(),
102
+ ownedTools: new Set(),
69
103
  allowedToolsBySkill: new Map(),
70
104
  crs: [],
71
105
  myCrNumbers: new Set(),
72
106
  });
73
107
  const [revision, setRevision] = useState(0);
108
+ /** Whether any load has answered with a catalog — what makes a reload quiet. */
109
+ const loadedOnce = useRef(false);
74
110
 
75
111
  useEffect(() => {
76
112
  let cancelled = false;
77
- setState((s) => ({ ...s, loading: true, error: null }));
78
113
 
79
114
  (async () => {
80
115
  const [skills, tools] = await Promise.all([listSkills(), listToolSecrets()]);
81
116
 
82
- const [ownership, crs, mine, pending, details] = await Promise.all([
83
- skills.length
84
- ? fetchFileAccessBatch(
85
- defaultWorkspaceId(),
86
- skills.map((s) => `${s.path}/SKILL.md`),
87
- ).catch(() => ({ results: {} as Record<string, boolean> }))
88
- : Promise.resolve({ results: {} as Record<string, boolean> }),
117
+ const skillProbes = skills.map((s) => `${s.path}/SKILL.md`);
118
+ const ownerProbes = [...skillProbes, ...tools.map((t) => t.path)];
119
+ // The batch endpoint refuses more than 500 paths per request, so a large
120
+ // catalog goes out in slices of that size and the verdicts are merged.
121
+ // A failed slice is "no verdicts" for its paths: nothing pilled, nothing
122
+ // unlocked — and the other slices still stand. Slices go one after
123
+ // another, so a large catalog costs more round trips, never a burst: at
124
+ // most one request per verb is in flight. A load that was superseded
125
+ // (unmount, reload) stops sending slices; its verdicts are discarded.
126
+ const BATCH_LIMIT = 500;
127
+ const verdicts = async (paths: string[], verb: 'write' | 'owner') => {
128
+ const results: Record<string, boolean> = {};
129
+ for (let i = 0; i < paths.length && !cancelled; i += BATCH_LIMIT) {
130
+ const part = await fetchFileAccessBatch(
131
+ defaultWorkspaceId(),
132
+ paths.slice(i, i + BATCH_LIMIT),
133
+ verb,
134
+ ).catch(() => ({ results: {} as Record<string, boolean> }));
135
+ Object.assign(results, part.results);
136
+ }
137
+ return { results };
138
+ };
139
+
140
+ const [writable, ownership, crs, mine, pending, pendingTools, details] = await Promise.all([
141
+ verdicts(skillProbes, 'write'),
142
+ verdicts(ownerProbes, 'owner'),
89
143
  listOpenChangeRequests().catch(() => [] as PullRequestSummary[]),
90
144
  listMyChangeRequests().catch(() => [] as PullRequestSummary[]),
91
145
  listPendingSkills().catch(() => [] as PendingSkillSummary[]),
146
+ listPendingTools().catch(() => [] as PendingToolSummary[]),
92
147
  Promise.all(
93
148
  skills.map(
94
149
  (s): Promise<[string, string[]]> =>
@@ -100,16 +155,21 @@ export function useLibraryData(): LibraryData {
100
155
  ]);
101
156
 
102
157
  if (cancelled) return;
103
- const ownedSkills = new Set(
104
- skills.filter((s) => ownership.results[`${s.path}/SKILL.md`] === true).map((s) => s.name),
105
- );
158
+ // Fail closed: a path missing from the verdicts is a no.
159
+ const skillsWhere = (results: Record<string, boolean>) =>
160
+ new Set(skills.filter((s) => results[`${s.path}/SKILL.md`] === true).map((s) => s.name));
161
+ loadedOnce.current = true;
106
162
  setState({
107
163
  loading: false,
164
+ refreshing: false,
108
165
  error: null,
109
166
  skills,
110
167
  pendingSkills: pending,
111
168
  tools,
112
- ownedSkills,
169
+ pendingTools,
170
+ ownedSkills: skillsWhere(ownership.results),
171
+ writableSkills: skillsWhere(writable.results),
172
+ ownedTools: new Set(tools.filter((t) => ownership.results[t.path] === true).map((t) => t.slug)),
113
173
  allowedToolsBySkill: new Map(details),
114
174
  crs: crs.filter((c) => c.state === 'open'),
115
175
  myCrNumbers: new Set(mine.map((c) => c.number)),
@@ -119,6 +179,7 @@ export function useLibraryData(): LibraryData {
119
179
  setState((s) => ({
120
180
  ...s,
121
181
  loading: false,
182
+ refreshing: false,
122
183
  error: err instanceof Error ? err.message : "Couldn't load the library.",
123
184
  }));
124
185
  });
@@ -128,7 +189,19 @@ export function useLibraryData(): LibraryData {
128
189
  };
129
190
  }, [revision]);
130
191
 
131
- const reload = useCallback(() => setRevision((r) => r + 1), []);
192
+ // The flags are flipped HERE, from the event that asks for the load, not
193
+ // in the effect (a synchronous setState there costs a cascading render on
194
+ // every revision). The first load is loud — `useState(true)` above — and a
195
+ // reload is quiet: `refreshing` behind what is on screen, the error
196
+ // cleared for the new attempt.
197
+ const reload = useCallback(() => {
198
+ // Quiet only once a load has ANSWERED: a retry after a failed first load
199
+ // has nothing on screen to keep, and goes loud like the first attempt.
200
+ setState((s) =>
201
+ s.loading ? s : loadedOnce.current ? { ...s, refreshing: true, error: null } : { ...s, loading: true, error: null },
202
+ );
203
+ setRevision((r) => r + 1);
204
+ }, []);
132
205
 
133
206
  return { ...state, reload };
134
207
  }
@@ -5,8 +5,8 @@ import { useWorkspace } from '../../workspace/state/workspace.context';
5
5
  import { LibraryLayout } from '../components/LibraryLayout';
6
6
  import { LibraryPage } from '../components/LibraryPage';
7
7
  import { PluginPage } from '../components/PluginPage';
8
- import { PluginsIndexPage } from '../components/PluginsIndexPage';
9
8
  import { PersonalPluginPage } from '../components/PersonalPluginPage';
9
+ import { TeamRoute } from '../components/TeamRoute';
10
10
  import { WelcomeRoute } from '../../onboarding/components/WelcomeRoute';
11
11
  import { WorkspaceItemRoute } from './WorkspaceItemRoute';
12
12
  import { decodePluginSegment, LIBRARY_ROOT, pathForPlugin, urlForLibraryItem, urlForSkillFile } from './library-paths';
@@ -32,14 +32,17 @@ export function LibraryRoutes() {
32
32
  <LibraryProvider>
33
33
  <Routes>
34
34
  <Route element={<LibraryLayout />}>
35
- {/* The Library OPENS on its plugins. A plugin is where skills and
36
- tools live and who they are for, so the index of them is the
37
- orienting view; the undifferentiated card grid is a lens on
38
- the same catalog and keeps its own row and URL below. */}
39
- <Route index element={<PluginsIndexPage />} />
35
+ {/* The Library OPENS on Everything: plugins, skills and tools, the
36
+ whole catalog with the library-wide search. `everything` is
37
+ the same page at the URL it used to have, so older links
38
+ still land. */}
39
+ <Route index element={<LibraryPage filter={{ kind: 'all' }} />} />
40
+ <Route path="everything" element={<Navigate to={LIBRARY_ROOT} replace />} />
40
41
 
41
- {/* The whole catalog as cards, with the library-wide search. */}
42
- <Route path="everything" element={<LibraryPage filter={{ kind: 'all' }} />} />
42
+ {/* A team's lens — what one group from the access rules can use.
43
+ The name is a route param; the page decides whether the
44
+ team is known. */}
45
+ <Route path="teams/:group" element={<TeamRoute />} />
43
46
 
44
47
  {/* The connect-your-agent welcome — inside the layout, so the
45
48
  sidebar (and the pill's selected state) is on screen with it.
@@ -50,9 +53,9 @@ export function LibraryRoutes() {
50
53
  <Route path="owned" element={<LibraryPage filter={{ kind: 'owned' }} />} />
51
54
 
52
55
  {/* `yours` is a PLUGIN page, not a gallery filter — the items in no
53
- folder, given the same page the folders get. The sidebar still
54
- lights it through the `ungrouped` filter, so the URL and the
55
- selection stay the pair they were. */}
56
+ folder, given the same page the folders get. It has no nav row
57
+ (your own space is not a group); it is reached from its row on
58
+ Everything, the welcome page and by URL. */}
56
59
  <Route path="yours" element={<PersonalPluginPage />} />
57
60
 
58
61
  {/* A plugin is a PLACE: `plugins/:plugin` is a real page with a real
@@ -1,27 +1,49 @@
1
- import { Navigate, useParams, useSearchParams } from 'react-router-dom';
2
- import { DEFAULT_BRANCH, PLUGINS_DIR } from '@bevel-software/platform-shared';
1
+ import { Link, Navigate, useLocation, useParams, useSearchParams } from 'react-router-dom';
2
+ import { DEFAULT_BRANCH, PLUGINS_DIR, SKILLS_DIR, type FileTreeEntry } from '@bevel-software/platform-shared';
3
3
  import { useWorkspace } from '../../workspace/state/workspace.context';
4
+ import { safeDecode } from '../../workspace/routing/kb-routes';
4
5
  import { useLibrary } from '../state/library-data';
6
+ import type { PluginSummary } from '../services/plugins.api';
7
+ import { pluginHoldingPath } from '../utils/plugin-summary';
8
+ import { FileRoute } from '../../workspace/components/FileRoute';
5
9
  import { SkillPage } from '../components/skill-page/SkillPage';
6
10
  import { ToolPage } from '../components/tool-page/ToolPage';
7
11
  import { LIBRARY_ROOT, pathForPlugin } from './library-paths';
8
12
 
9
13
  /**
10
14
  * The library page behind a canonical workspace URL —
11
- * `/workspace/<default>/<kbDir>/Plugins/<plugin>/<...>` — rendered INSIDE the
12
- * same `LibraryLayout` route tree as every other library page, so the sidebar
13
- * is the one the reader already had and nothing remounts on the way in.
15
+ * `/workspace/<default>/<kbDir>/Plugins/<plugin>/<...>` or
16
+ * `/workspace/<default>/<kbDir>/Skills/<...>` — rendered INSIDE the same
17
+ * `LibraryLayout` route tree as every other library page, so the sidebar is
18
+ * the one the reader already had and nothing remounts on the way in.
14
19
  *
15
20
  * Resolution is STRUCTURAL, not a catalog lookup: under `Plugins/<plugin>/`, a
16
21
  * `*.tool` file is a tool page, the plugin's `mcp.json` is a tool page too
17
22
  * (which of its servers is named by `?server=`, or by the catalog when the file
18
- * declares only one), any other direct FILE (an extension, no segments below
19
- * it — `access.md`) belongs to the plugin page, and everything else is a skill
20
- * FOLDER whose name is the skill's id — the same identity the old name-based
21
- * route used. That is what makes a skill created a moment ago
22
- * open instantly: its URL says everything the page needs, and `SkillPage`
23
- * fetches the skill by name itself. Waiting on the catalog here raced every
24
- * reload and lost (the just-created skill bounced to its plugin's page).
23
+ * declares only one), and everything else — under either root — is a skill
24
+ * FOLDER whose name is the skill's id, resolved by {@link resolveSkillPath}.
25
+ * That is what makes a skill created a moment ago open instantly: its URL
26
+ * says everything the page needs, and `SkillPage` fetches the skill by name
27
+ * itself. Waiting on the catalog here raced every reload and lost (the
28
+ * just-created skill bounced to its plugin's page).
29
+ *
30
+ * The two roots differ only in where a FOLDER that is no skill goes: a
31
+ * container belongs to its plugin page under `Plugins/`; under `Skills/` a
32
+ * scope folder has no page (home). A loose FILE — a folder's `access.md`,
33
+ * a plugin's `plugin.json`, a stray upload — opens as the plain file it is
34
+ * under either root, HERE, inside this app: the same `FileRoute` Knowledge
35
+ * renders, in the Library's own frame. Which app a file opens in follows
36
+ * the folder it is in — the two roots ARE the two apps — never the viewer it
37
+ * needs, so a person reading a plugin's manifest keeps the Skills & Tools nav
38
+ * and switcher around it. (The plugin page was never the file either: it
39
+ * keys on the plugin's identity, which a folder name need not be — a
40
+ * personal space, a folder spelled unlike its manifest — so the old bounce
41
+ * there landed on "doesn't exist" for a file plainly present.)
42
+ *
43
+ * Router state `rawFile` asks for that raw view OUTRIGHT, whatever the URL
44
+ * would otherwise resolve to — the tool page's "Edit the tool file", the
45
+ * plugin page's manifest button. State, not URL: a shared link never carries
46
+ * it, so nobody lands on the editor by accident.
25
47
  *
26
48
  * The catalog is consulted only to REFINE a tool's slug (a `.tool` may
27
49
  * declare an explicit id different from its filename); the filename is the
@@ -30,27 +52,51 @@ import { LIBRARY_ROOT, pathForPlugin } from './library-paths';
30
52
  export function WorkspaceItemRoute() {
31
53
  const params = useParams<{ branch: string; '*': string }>();
32
54
  const [searchParams] = useSearchParams();
55
+ const location = useLocation();
33
56
  const splat = params['*'] ?? '';
34
57
  const branch = safeDecode(params.branch ?? '');
35
- const { kbDirName } = useWorkspace();
58
+ const { kbDirName, fileTree } = useWorkspace();
36
59
  const data = useLibrary();
60
+ // The workspace tree as a second witness — see `resolveSkillPath`.
61
+ const witness = (folderRel: string) => folderHasSkillMd(fileTree, kbDirName ? `${kbDirName}/${folderRel}` : null);
37
62
 
38
63
  // Shape re-validation: the route pattern (`:branch/*`) is broader than the
39
64
  // shape the shell dispatches here, and a stray URL must not read as a page.
40
65
  const segments = splat.split('/').filter(Boolean).map(safeDecode);
41
- if (branch !== DEFAULT_BRANCH || segments[1] !== PLUGINS_DIR || segments.length < 3) {
66
+ const kbRoot = segments[1];
67
+ if (branch !== DEFAULT_BRANCH || (kbRoot !== PLUGINS_DIR && kbRoot !== SKILLS_DIR) || segments.length < 3) {
42
68
  return <Navigate to={LIBRARY_ROOT} replace />;
43
69
  }
44
70
  if (kbDirName !== null && segments[0] !== kbDirName) {
45
71
  return <Navigate to={LIBRARY_ROOT} replace />;
46
72
  }
47
73
 
48
- const [, , plugin, ...tail] = segments;
49
- const last = tail[tail.length - 1];
50
- if (!plugin || !last) {
51
- return <Navigate to={LIBRARY_ROOT} replace />;
52
- }
53
- const repoRel = `${PLUGINS_DIR}/${plugin}/${tail.join('/')}`;
74
+ /**
75
+ * The Knowledge file route, in this frame. `canonicalize` is OFF: its id
76
+ * redirect would send an id-bearing file (a `.tool`, a note with an `id`)
77
+ * to an id URL, which is no library location — and the surface would
78
+ * switch to Knowledge after all. The path URL is the one the tree gave.
79
+ *
80
+ * Above it, when the file sits inside a listed plugin, one line says which
81
+ * plugin and links to its page: a manifest or an access.md opens as the
82
+ * file it is (routing the manifest to the page instead proved unreliable),
83
+ * and the page is one click away for whoever wanted it.
84
+ */
85
+ const fileView = () => (
86
+ <>
87
+ {/* Only from a SETTLED list: while it is (re)loading the summaries on
88
+ hand may be the previous list's, and a plugin whose identity just
89
+ changed would be linked by its old name. The file itself waits for
90
+ nothing. */}
91
+ <PluginFileNote
92
+ plugin={data.pluginsLoading ? null : pluginHoldingPath(segments.slice(1).join('/'), data.pluginSummaries)}
93
+ />
94
+ <FileRoute canonicalize={false} />
95
+ </>
96
+ );
97
+
98
+ // Asked for the raw file by name: no resolution, the editor it is.
99
+ if ((location.state as { rawFile?: boolean } | null)?.rawFile === true) return fileView();
54
100
 
55
101
  /**
56
102
  * `key={name}` is load-bearing. A provisional name gets CORRECTED once the
@@ -63,6 +109,36 @@ export function WorkspaceItemRoute() {
63
109
  <SkillPage key={name} name={name} activeFile={activeFile} provisional={provisional} />
64
110
  );
65
111
 
112
+ /**
113
+ * A loose file (a folder's access.md, a plugin's manifest, a stray note)
114
+ * opens as the plain file it is — the Knowledge file route, rendered right
115
+ * here in the Library's column, same URL, same viewer, this app's frame.
116
+ */
117
+ const rawFileView = fileView;
118
+
119
+ if (kbRoot === SKILLS_DIR) {
120
+ const rest = segments.slice(2);
121
+ const resolved = resolveSkillPath(data, `${SKILLS_DIR}/${rest.join('/')}`, rest, null, witness);
122
+ switch (resolved.kind) {
123
+ case 'skill':
124
+ return skillPage(resolved.name, resolved.file, resolved.provisional);
125
+ case 'wait':
126
+ return null;
127
+ case 'container':
128
+ // A scope has no page of its own — the sidebar's tree is where it is browsed.
129
+ return <Navigate to={LIBRARY_ROOT} replace />;
130
+ case 'loose-file':
131
+ return rawFileView();
132
+ }
133
+ }
134
+
135
+ const [, , plugin, ...tail] = segments;
136
+ const last = tail[tail.length - 1];
137
+ if (!plugin || !last) {
138
+ return <Navigate to={LIBRARY_ROOT} replace />;
139
+ }
140
+ const repoRel = `${PLUGINS_DIR}/${plugin}/${tail.join('/')}`;
141
+
66
142
  // A `.tool` is a tool page wherever it sits. The backend finds manuals at
67
143
  // ANY depth below `Plugins/` (`walkFiles` over the whole tree), so a manual
68
144
  // filed inside a category folder is a real, listed tool — matching only at
@@ -99,68 +175,148 @@ export function WorkspaceItemRoute() {
99
175
  return <Navigate to={pathForPlugin(plugin)} replace />;
100
176
  }
101
177
 
102
- // THE CATALOG IS THE AUTHORITY on which folder is a skill and what its id
103
- // is. Plugins may nest (`Plugins/Engineering/coding/create-ticket/SKILL.md`),
104
- // and a skill's id is its frontmatter `id`/`name` — only FALLING BACK to the
105
- // folder name — so neither the depth nor the id can be read off the URL with
106
- // certainty. Take the DEEPEST skill whose folder contains this path: a
107
- // category folder is never itself a skill, so the deepest match is the owner,
108
- // and a `SKILL.md` bundled inside a skill (`<skill>/examples/SKILL.md`)
109
- // stays that skill's file instead of inventing a skill called `examples`.
178
+ // `Plugins/<plugin>/SKILL.md` makes the plugin folder itself the skill,
179
+ // which is what the backend's walk would report for it.
180
+ const resolved = resolveSkillPath(data, repoRel, tail, plugin, witness);
181
+ switch (resolved.kind) {
182
+ case 'skill':
183
+ return skillPage(resolved.name, resolved.file, resolved.provisional);
184
+ case 'wait':
185
+ return null;
186
+ case 'container':
187
+ // A category has no page of its own; its plugin does.
188
+ return <Navigate to={pathForPlugin(plugin)} replace />;
189
+ case 'loose-file':
190
+ // A file that can be no skill's — `access.md` at either level, the
191
+ // manifest, a stray upload — is shown as the file it is.
192
+ return rawFileView();
193
+ }
194
+ }
195
+
196
+ type SkillPathResolution =
197
+ | { kind: 'skill'; name: string; file: string; provisional: boolean }
198
+ /** A folder with catalog skills BELOW it — a category or a scope, never a skill itself. */
199
+ | { kind: 'container' }
200
+ /** A file that can be no skill's: directly in the root folder, or in a known container. */
201
+ | { kind: 'loose-file' }
202
+ /** Nothing positive settled it and the catalog is still loading. */
203
+ | { kind: 'wait' };
204
+
205
+ /**
206
+ * What a path under a root names, by the ONE set of evidence rules both roots
207
+ * share. `tail` is the path below the root's own folder (the plugin, or
208
+ * `Skills/` itself); `selfName` is that folder's name when it can be a skill
209
+ * (a plugin holding a bare `SKILL.md`), null when it cannot (`Skills/`).
210
+ *
211
+ * THE CATALOG IS THE AUTHORITY on which folder is a skill and what its id
212
+ * is. Folders may nest (`Plugins/Engineering/coding/create-ticket/SKILL.md`),
213
+ * and a skill's id is its frontmatter `id`/`name` — only FALLING BACK to the
214
+ * folder name — so neither the depth nor the id can be read off the URL with
215
+ * certainty. Take the DEEPEST skill whose folder contains this path: a
216
+ * category folder is never itself a skill, so the deepest match is the owner,
217
+ * and a `SKILL.md` bundled inside a skill (`<skill>/examples/SKILL.md`)
218
+ * stays that skill's file instead of inventing a skill called `examples`.
219
+ *
220
+ * Not in the catalog: a `SKILL.md` still names its own skill structurally —
221
+ * the folder holding it — and that is deliberately catalog-FREE, so a skill
222
+ * created a moment ago opens from its URL alone, before any reload lands.
223
+ *
224
+ * Everything below that is decided on POSITIVE evidence only. What the
225
+ * catalog KNOWS is trustworthy whenever it is there — cached entries survive
226
+ * a failed refresh — but what it does NOT know proves nothing: it may be
227
+ * loading, stale (a skill created seconds ago), or have failed outright.
228
+ * Reading absence as "this is not a page" is what bounced valid deep links
229
+ * to the plugin, so this never draws that inference. A folder with catalog
230
+ * skills UNDER it is a container, not a skill — the discriminator between a
231
+ * category and a just-created skill whose reload hasn't landed: the former
232
+ * has known descendants, the latter has none. A FILE is loose when it cannot
233
+ * be a skill's: it sits directly in the root folder (structurally never
234
+ * inside a skill), or its own folder is a known container. A file under an
235
+ * UNKNOWN folder is left alone — that folder is most likely a skill the
236
+ * catalog hasn't caught up with — unless the WORKSPACE TREE, the second
237
+ * witness, has the folder and shows no `SKILL.md` in it: then it is a
238
+ * container (a scope with nothing the caller may read beneath) or a loose
239
+ * file in one, and no catalog can make it a skill. When nothing positive
240
+ * settled it and the catalog is still loading, WAIT: the evidence may be one
241
+ * render away, and guessing flashes a page for a name that is about to
242
+ * change. Only then is the URL read structurally — a file belongs to the
243
+ * folder holding it, a bare folder names itself — and provisionally, so
244
+ * `SkillPage` must not turn a failed lookup into "doesn't exist" until the
245
+ * catalog has answered.
246
+ */
247
+ function resolveSkillPath(
248
+ data: { items: readonly { kind: string; id: string; path: string }[]; loading: boolean },
249
+ repoRel: string,
250
+ tail: readonly string[],
251
+ selfName: string | null,
252
+ /** Whether a repo-relative folder holds a SKILL.md — true, false, or undefined when the tree cannot say. */
253
+ witness?: (folderRel: string) => boolean | undefined,
254
+ ): SkillPathResolution {
255
+ const last = tail[tail.length - 1]!;
110
256
  const owner = deepestSkillOwning(data.items, repoRel);
111
257
  if (owner) {
112
258
  const file = repoRel.slice(owner.path.length + 1);
113
- return skillPage(owner.id, file || 'SKILL.md', false);
259
+ return { kind: 'skill', name: owner.id, file: file || 'SKILL.md', provisional: false };
114
260
  }
115
-
116
- // Not in the catalog. A `SKILL.md` still names its own skill structurally —
117
- // the folder holding it — and that is deliberately catalog-FREE: a skill
118
- // created a moment ago opens from its URL alone, before any reload lands.
119
- // (`Plugins/<plugin>/SKILL.md` makes the plugin folder itself the skill, which
120
- // is what the backend's walk would report for it.)
121
- if (last === 'SKILL.md') {
122
- return skillPage(tail.length >= 2 ? tail[tail.length - 2]! : plugin, 'SKILL.md', true);
261
+ const parentName = tail.length >= 2 ? tail[tail.length - 2]! : selfName;
262
+ const parentRel = repoRel.slice(0, repoRel.length - last.length - 1);
263
+ // The tree's verdict comes BEFORE any structural reading of the URL: a
264
+ // folder the tree holds with no SKILL.md in it is no skill, whatever the
265
+ // path is called — a `SKILL.md` URL into it included.
266
+ if (witness?.(hasExtension(last) ? parentRel : repoRel) === false) {
267
+ return hasExtension(last) ? { kind: 'loose-file' } : { kind: 'container' };
123
268
  }
124
-
125
- // Everything below is decided on POSITIVE evidence only. What the catalog
126
- // KNOWS is trustworthy whenever it is there — cached entries survive a
127
- // failed refresh — but what it does NOT know proves nothing: it may be
128
- // loading, stale (a skill created seconds ago), or have failed outright.
129
- // Reading absence as "this is not a page" is what bounced valid deep links
130
- // to the plugin, so this no longer draws that inference at all.
131
-
132
- // A folder with catalog skills UNDER it is a category, not a skill. That is
133
- // the discriminator between a category folder and a just-created skill whose
134
- // reload hasn't landed: the former has known descendants, the latter has
135
- // none. A category has no page of its own; its plugin does.
136
- if (!hasExtension(last) && containsCatalogSkill(data.items, repoRel)) {
137
- return <Navigate to={pathForPlugin(plugin)} replace />;
269
+ if (last === 'SKILL.md' && parentName !== null) {
270
+ return { kind: 'skill', name: parentName, file: 'SKILL.md', provisional: true };
138
271
  }
139
-
140
- // A FILE is the plugin's business when it cannot be a skill's file: either it
141
- // sits directly in the plugin folder (structurally never inside a skill), or
142
- // its own folder is a known category. `access.md` at either level, a stray
143
- // upload. A file under an UNKNOWN folder is left alone — that folder is most
144
- // likely a skill the catalog hasn't caught up with.
145
- const parentRel = repoRel.slice(0, repoRel.length - last.length - 1);
272
+ if (!hasExtension(last) && containsCatalogSkill(data.items, repoRel)) return { kind: 'container' };
146
273
  if (hasExtension(last) && (tail.length === 1 || containsCatalogSkill(data.items, parentRel))) {
147
- return <Navigate to={pathForPlugin(plugin)} replace />;
274
+ return { kind: 'loose-file' };
275
+ }
276
+ if (data.loading) return { kind: 'wait' };
277
+ if (hasExtension(last)) {
278
+ return parentName === null
279
+ ? { kind: 'loose-file' }
280
+ : { kind: 'skill', name: parentName, file: last, provisional: true };
148
281
  }
282
+ return { kind: 'skill', name: last, file: 'SKILL.md', provisional: true };
283
+ }
284
+
285
+ /**
286
+ * Whether the folder at `workspaceRel` holds a `SKILL.md`, by the workspace
287
+ * tree: true or false when the tree has the folder, undefined when it does
288
+ * not (not loaded, not readable, not on this branch) — an absence that
289
+ * proves nothing, exactly like the catalog's.
290
+ */
291
+ function folderHasSkillMd(tree: FileTreeEntry | null, workspaceRel: string | null): boolean | undefined {
292
+ if (!tree || workspaceRel === null) return undefined;
293
+ const find = (node: FileTreeEntry): FileTreeEntry | null => {
294
+ if (node.relativePath === workspaceRel) return node;
295
+ if (!node.children || !workspaceRel.startsWith(node.relativePath === '.' ? '' : `${node.relativePath}/`)) return null;
296
+ for (const child of node.children) {
297
+ const hit = find(child);
298
+ if (hit) return hit;
299
+ }
300
+ return null;
301
+ };
302
+ const folder = find(tree);
303
+ if (!folder || folder.type !== 'directory') return undefined;
304
+ return (folder.children ?? []).some((c) => c.type === 'file' && c.name === 'SKILL.md');
305
+ }
149
306
 
150
- // Nothing positive settled it. While the catalog is still loading, WAIT: the
151
- // evidence above may be one render away, and guessing flashes a page for a
152
- // name that is about to change. The layout and its sidebar are already on
153
- // screen around this.
154
- if (data.loading) return null;
155
-
156
- // Read the URL structurally — a file belongs to the folder holding it, a
157
- // bare folder names itself, the same rule the backend applies when no
158
- // frontmatter declares an id. Provisional: the catalog never confirmed it,
159
- // so SkillPage must not turn a failed lookup into "doesn't exist" until the
160
- // catalog has actually answered.
161
- return hasExtension(last)
162
- ? skillPage(tail.length >= 2 ? tail[tail.length - 2]! : plugin, last, true)
163
- : skillPage(last, 'SKILL.md', true);
307
+ /** One line above a file that sits inside a plugin: which plugin, and the way to its page. */
308
+ function PluginFileNote({ plugin }: { plugin: PluginSummary | null }) {
309
+ if (!plugin) return null;
310
+ return (
311
+ <p className="mb-3 flex flex-wrap items-center gap-x-2 text-detail text-ink-muted">
312
+ <span>
313
+ Part of the <span className="font-medium text-ink">{plugin.displayName ?? plugin.name}</span> plugin.
314
+ </span>
315
+ <Link to={pathForPlugin(plugin.name)} className="font-medium text-ink underline underline-offset-2">
316
+ Open plugin
317
+ </Link>
318
+ </p>
319
+ );
164
320
  }
165
321
 
166
322
  /** Whether a path segment names a file rather than a folder. */
@@ -202,12 +358,3 @@ function deepestSkillOwning(
202
358
  }
203
359
  return best;
204
360
  }
205
-
206
- /** A malformed escape is a bad link, not a crash — fall back to the raw segment. */
207
- function safeDecode(raw: string): string {
208
- try {
209
- return decodeURIComponent(raw);
210
- } catch {
211
- return raw;
212
- }
213
- }