@bevel-software/platform-core-frontend 0.15.1 → 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 (346) hide show
  1. package/THIRD-PARTY-NOTICES.md +2 -2
  2. package/package.json +3 -3
  3. package/src/core/CoreAppShell.tsx +16 -9
  4. package/src/core/__tests__/AppChrome.test.tsx +0 -3
  5. package/src/core/__tests__/events.test.ts +43 -0
  6. package/src/core/bootstrap.ts +11 -3
  7. package/src/core/events.ts +85 -3
  8. package/src/core/registry.ts +1 -1
  9. package/src/lib/__tests__/email.test.ts +44 -0
  10. package/src/lib/email.ts +37 -1
  11. package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
  12. package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
  13. package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
  14. package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
  15. package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
  16. package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
  17. package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
  18. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
  19. package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
  20. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +721 -126
  21. package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
  22. package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
  23. package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
  24. package/src/modules/access/api.ts +140 -6
  25. package/src/modules/access/components/ManageAccessDialog.tsx +1299 -561
  26. package/src/modules/access/manage-access-affordance.ts +17 -0
  27. package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
  28. package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
  29. package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
  30. package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
  31. package/src/modules/admin/__tests__/ConnectionKeysPage.test.tsx +266 -0
  32. package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
  33. package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
  34. package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
  35. package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
  36. package/src/modules/admin/components/AddMemberInput.tsx +268 -0
  37. package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
  38. package/src/modules/admin/components/ConnectionKeysPage.tsx +269 -0
  39. package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
  40. package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
  41. package/src/modules/admin/components/connection-keys-grouping.ts +43 -0
  42. package/src/modules/admin/components/group-members-path.ts +32 -0
  43. package/src/modules/admin/services/connection-keys.api.ts +47 -0
  44. package/src/modules/admin/services/roles.api.ts +12 -1
  45. package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
  46. package/src/modules/auth/components/AccountPage.tsx +73 -54
  47. package/src/modules/auth/components/LoginScreen.tsx +1 -0
  48. package/src/modules/auth/services/account.api.ts +78 -4
  49. package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
  50. package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
  51. package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
  52. package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
  53. package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
  54. package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
  55. package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
  56. package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
  57. package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
  58. package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
  59. package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
  60. package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
  61. package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
  62. package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
  63. package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
  64. package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
  65. package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
  66. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
  67. package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
  68. package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
  69. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
  70. package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
  71. package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
  72. package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
  73. package/src/modules/change-requests/services/change-requests.api.ts +57 -1
  74. package/src/modules/change-requests/services/denied-file.api.ts +53 -0
  75. package/src/modules/change-requests/services/propose.api.ts +97 -8
  76. package/src/modules/change-requests/utils/approval.ts +15 -0
  77. package/src/modules/change-requests/utils/author.ts +32 -0
  78. package/src/modules/change-requests/utils/readFailure.ts +110 -0
  79. package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
  80. package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
  81. package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
  82. package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
  83. package/src/modules/git/services/error-messages.ts +12 -0
  84. package/src/modules/git/services/pr-prompts.ts +5 -5
  85. package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
  86. package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
  87. package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
  88. package/src/modules/layout/components/AppLayout.tsx +2 -0
  89. package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
  90. package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
  91. package/src/modules/layout/components/SidebarFrame.tsx +108 -3
  92. package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
  93. package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
  94. package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
  95. package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
  96. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
  97. package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +103 -98
  98. package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +20 -5
  99. package/src/modules/library/__tests__/LockedPluginView.test.tsx +97 -7
  100. package/src/modules/library/__tests__/NewPluginDialog.test.tsx +13 -4
  101. package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
  102. package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
  103. package/src/modules/library/__tests__/PluginExtras.test.tsx +100 -9
  104. package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
  105. package/src/modules/library/__tests__/PluginPage.test.tsx +258 -6
  106. package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +16 -56
  107. package/src/modules/library/__tests__/PluginsSidebar.test.tsx +155 -152
  108. package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
  109. package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
  110. package/src/modules/library/__tests__/SkillPage.test.tsx +386 -80
  111. package/src/modules/library/__tests__/SkillsTree.test.tsx +293 -4
  112. package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
  113. package/src/modules/library/__tests__/ToolPage.test.tsx +87 -4
  114. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +173 -26
  115. package/src/modules/library/__tests__/auth-harness.tsx +9 -9
  116. package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
  117. package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
  118. package/src/modules/library/__tests__/library-data.stale.test.tsx +121 -28
  119. package/src/modules/library/__tests__/library-data.test.ts +7 -0
  120. package/src/modules/library/__tests__/library-paths.test.ts +47 -4
  121. package/src/modules/library/__tests__/link-membership.test.ts +13 -4
  122. package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
  123. package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
  124. package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
  125. package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
  126. package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
  127. package/src/modules/library/__tests__/plugin-summary.test.ts +36 -1
  128. package/src/modules/library/__tests__/status.test.ts +82 -2
  129. package/src/modules/library/__tests__/tools.api.test.ts +44 -1
  130. package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
  131. package/src/modules/library/components/AddDialogTabs.tsx +103 -0
  132. package/src/modules/library/components/AddToPluginDialog.tsx +74 -18
  133. package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
  134. package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
  135. package/src/modules/library/components/LibraryCard.tsx +146 -45
  136. package/src/modules/library/components/LibraryLayout.tsx +119 -256
  137. package/src/modules/library/components/LibraryPage.tsx +172 -39
  138. package/src/modules/library/components/LinkSkillPanel.tsx +1 -3
  139. package/src/modules/library/components/LockedPluginView.tsx +62 -34
  140. package/src/modules/library/components/NameWithBadges.tsx +164 -0
  141. package/src/modules/library/components/NewPluginDialog.tsx +16 -2
  142. package/src/modules/library/components/PageActions.tsx +11 -9
  143. package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
  144. package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
  145. package/src/modules/library/components/PersonalPluginPage.tsx +121 -22
  146. package/src/modules/library/components/PluginExtras.tsx +140 -17
  147. package/src/modules/library/components/PluginIndexRow.tsx +47 -12
  148. package/src/modules/library/components/PluginPage.tsx +157 -41
  149. package/src/modules/library/components/PluginRows.tsx +286 -0
  150. package/src/modules/library/components/PluginsSidebar.tsx +239 -263
  151. package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
  152. package/src/modules/library/components/ShareButton.tsx +17 -0
  153. package/src/modules/library/components/SkillsTree.tsx +141 -28
  154. package/src/modules/library/components/TeamRoute.tsx +15 -0
  155. package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
  156. package/src/modules/library/components/plugin-page-parts.tsx +103 -17
  157. package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +6 -12
  158. package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
  159. package/src/modules/library/components/skill-page/SkillPage.tsx +274 -122
  160. package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
  161. package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
  162. package/src/modules/library/components/tool-page/ToolPage.tsx +106 -16
  163. package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
  164. package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
  165. package/src/modules/library/hooks/useLibraryData.ts +92 -19
  166. package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
  167. package/src/modules/library/routes/WorkspaceItemRoute.tsx +77 -27
  168. package/src/modules/library/routes/library-paths.ts +26 -28
  169. package/src/modules/library/services/library.api.ts +38 -20
  170. package/src/modules/library/services/plugins.api.ts +69 -8
  171. package/src/modules/library/services/teams.api.ts +15 -0
  172. package/src/modules/library/services/tools.api.ts +78 -0
  173. package/src/modules/library/state/library-data.tsx +170 -32
  174. package/src/modules/library/utils/personal-plugin.ts +13 -15
  175. package/src/modules/library/utils/plugin-entries.ts +134 -0
  176. package/src/modules/library/utils/plugin-summary.ts +75 -9
  177. package/src/modules/library/utils/status.ts +135 -33
  178. package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +8 -1
  179. package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
  180. package/src/modules/onboarding/agent-clients.ts +55 -23
  181. package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
  182. package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
  183. package/src/modules/pr/services/pr-merge.api.ts +2 -1
  184. package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
  185. package/src/modules/review/components/ReviewPanel.tsx +15 -17
  186. package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
  187. package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
  188. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
  189. package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
  190. package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
  191. package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
  192. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
  193. package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
  194. package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
  195. package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
  196. package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
  197. package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
  198. package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
  199. package/src/modules/secrets-vault/services/connect.api.ts +36 -5
  200. package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
  201. package/src/modules/settings/components/ClaudeConnectionCard.tsx +9 -24
  202. package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
  203. package/src/modules/settings/components/DeploymentPage.tsx +10 -30
  204. package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
  205. package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +67 -4
  206. package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
  207. package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +5 -5
  208. package/src/modules/settings/services/github-facade.api.ts +23 -0
  209. package/src/modules/settings/settings-nav-items.tsx +10 -2
  210. package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
  211. package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
  212. package/src/modules/setup/__tests__/setup.test.tsx +497 -4
  213. package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
  214. package/src/modules/setup/components/SetupGate.tsx +16 -16
  215. package/src/modules/setup/components/SetupScreen.tsx +521 -43
  216. package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
  217. package/src/modules/setup/services/setup.api.ts +140 -3
  218. package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
  219. package/src/modules/setup/utils/root-folders.ts +46 -0
  220. package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
  221. package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
  222. package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
  223. package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
  224. package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
  225. package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
  226. package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
  227. package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
  228. package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
  229. package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
  230. package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
  231. package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
  232. package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
  233. package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
  234. package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
  235. package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
  236. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +177 -118
  237. package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
  238. package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
  239. package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
  240. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +542 -42
  241. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
  242. package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
  243. package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
  244. package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
  245. package/src/modules/toolbar/components/deployment-address.ts +29 -0
  246. package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
  247. package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
  248. package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
  249. package/src/modules/toolbar/services/external-api-keys.api.ts +6 -0
  250. package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
  251. package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
  252. package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
  253. package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
  254. package/src/modules/workflow/state/event-bus.context.ts +10 -0
  255. package/src/modules/workspace/__tests__/testFixtures.ts +5 -3
  256. package/src/modules/workspace/components/FileExplorer.tsx +1295 -191
  257. package/src/modules/workspace/components/FileRoute.tsx +353 -36
  258. package/src/modules/workspace/components/FileViewer.tsx +166 -45
  259. package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
  260. package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
  261. package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
  262. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2473 -129
  263. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +731 -18
  264. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +331 -12
  265. package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
  266. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
  267. package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
  268. package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
  269. package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
  270. package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
  271. package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
  272. package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
  273. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
  274. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
  275. package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
  276. package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
  277. package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
  278. package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
  279. package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
  280. package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
  281. package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
  282. package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
  283. package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
  284. package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
  285. package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
  286. package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
  287. package/src/modules/workspace/components/renderers/index.ts +53 -2
  288. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
  289. package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
  290. package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
  291. package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
  292. package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
  293. package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
  294. package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
  295. package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +22 -3
  296. package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
  297. package/src/modules/workspace/hooks/useWorkspaceState.ts +424 -66
  298. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
  299. package/src/modules/workspace/routing/kb-routes.ts +206 -29
  300. package/src/modules/workspace/services/__tests__/workspace.api.test.ts +57 -1
  301. package/src/modules/workspace/services/workspace.api.ts +57 -4
  302. package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
  303. package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
  304. package/src/modules/workspace/state/open-change-requests.tsx +100 -12
  305. package/src/modules/workspace/state/workspace.context.ts +125 -19
  306. package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
  307. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +220 -6
  308. package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
  309. package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
  310. package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
  311. package/src/modules/workspace/utils/file-trace.ts +50 -0
  312. package/src/modules/workspace/utils/fileTree.ts +112 -36
  313. package/src/modules/workspace/utils/frontmatter.ts +8 -4
  314. package/src/modules/workspace/utils/pasteLink.ts +90 -0
  315. package/src/modules/workspace/utils/treeConfirm.ts +338 -0
  316. package/src/modules/workspace/utils/uploadError.ts +29 -0
  317. package/src/shared/__tests__/marketplace-url.test.ts +6 -1
  318. package/src/shared/components/Button.tsx +16 -2
  319. package/src/shared/components/Dialog.tsx +27 -11
  320. package/src/shared/components/Menu.tsx +13 -1
  321. package/src/shared/components/PageShell.tsx +13 -8
  322. package/src/shared/components/__tests__/primitives.test.tsx +116 -2
  323. package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
  324. package/src/shared/components/index.ts +2 -0
  325. package/src/shared/components/useDismissableMenu.ts +32 -10
  326. package/src/shared/components/useFocusHandoff.ts +51 -0
  327. package/src/shared/components/useLatestRef.ts +28 -0
  328. package/src/shared/markdown/Markdown.tsx +12 -3
  329. package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
  330. package/src/shared/markdown/hrefs.ts +50 -0
  331. package/src/shared/marketplace-url.ts +33 -5
  332. package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
  333. package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
  334. package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
  335. package/src/shared/mcp/connect-snippets.ts +14 -9
  336. package/src/shared/mcp/index.ts +1 -1
  337. package/src/shared/theme/__tests__/header-band.test.ts +197 -0
  338. package/src/shared/theme/header.ts +75 -0
  339. package/src/shared/theme/measure.ts +7 -4
  340. package/src/shared/theme/tokens.css +25 -0
  341. package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
  342. package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
  343. package/src/modules/library/components/PluginsIndexPage.tsx +0 -270
  344. package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
  345. package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
  346. package/src/modules/update-check/services/update-check.api.ts +0 -24
@@ -125,6 +125,42 @@ export async function getMcpServer(slug: string): Promise<McpServerView | null>
125
125
  return (await res.json()) as McpServerView;
126
126
  }
127
127
 
128
+ /**
129
+ * What deleting a tool would affect — the dialog's whole content.
130
+ *
131
+ * Owner-only on the backend, which is the same verdict the page gates the menu
132
+ * item on: a 403 here means the affordance should never have been offered, and
133
+ * the dialog says so rather than pretending the delete is still possible.
134
+ */
135
+ export interface ToolDependents {
136
+ slug: string;
137
+ name: string;
138
+ /** `manual` — a `.tool` file; `server` — one entry in a plugin's mcp.json. */
139
+ source: 'manual' | 'server';
140
+ /** Where the page returns once the tool is gone. */
141
+ plugin: { name: string; displayName: string };
142
+ /** Skills whose `allowed-tools` name this tool — their files are NOT touched. */
143
+ skills: { name: string; path: string }[];
144
+ /** Other plugins that carry it. */
145
+ plugins: { name: string; displayName: string }[];
146
+ /** Counts only — never a value, never whose. */
147
+ storedKeys: number;
148
+ signIns: number;
149
+ }
150
+
151
+ export async function getToolDependents(slug: string): Promise<ToolDependents> {
152
+ const res = await authFetch(`/api/tools/${encodeURIComponent(slug)}/dependents`);
153
+ if (!res.ok) await unwrap(res, "Couldn't read what depends on this tool.");
154
+ return (await res.json()) as ToolDependents;
155
+ }
156
+
157
+ /** Delete the tool. Answers the plugin it lived in — where the page goes next. */
158
+ export async function deleteTool(slug: string): Promise<{ plugin: string }> {
159
+ const res = await authFetch(`/api/tools/${encodeURIComponent(slug)}`, { method: 'DELETE' });
160
+ if (!res.ok) await unwrap(res, "Couldn't delete the tool.");
161
+ return (await res.json()) as { plugin: string };
162
+ }
163
+
128
164
  export async function putMcpServer(slug: string, write: McpServerWrite): Promise<{ name: string }> {
129
165
  const res = await authFetch(`/api/tools/${encodeURIComponent(slug)}/server`, {
130
166
  method: 'PUT',
@@ -134,3 +170,45 @@ export async function putMcpServer(slug: string, write: McpServerWrite): Promise
134
170
  if (!res.ok) await unwrap(res, "Couldn't save the server configuration.");
135
171
  return (await res.json()) as { name: string };
136
172
  }
173
+
174
+ /**
175
+ * A tool that exists only on an open change request's branch — proposed, and
176
+ * waiting on somebody to approve it. The mirror of `PendingSkillSummary`, and
177
+ * separate from every catalog type for the same reason: it is not in the
178
+ * catalog, nothing registers it, nothing calls it, and it is visible only to
179
+ * its author and to whoever could approve it.
180
+ */
181
+ export interface PendingToolSummary {
182
+ slug: string;
183
+ name: string;
184
+ /** The `.tool` file, or the plugin's `mcp.json` — what the card files under. */
185
+ path: string;
186
+ type: 'inline' | 'http' | 'mcp';
187
+ description?: string;
188
+ /** The plugin folder the declaration targets, or null when it targets none. */
189
+ plugin: string | null;
190
+ changeRequestNumber: number;
191
+ branch: string;
192
+ authorName: string;
193
+ createdAt: string;
194
+ /** True when the caller proposed it themselves. */
195
+ isAuthor: boolean;
196
+ }
197
+
198
+ /**
199
+ * Tools awaiting approval that the caller may see. The backend does the
200
+ * filtering — author or possible approver — so this is a plain read.
201
+ */
202
+ export async function listPendingTools(): Promise<PendingToolSummary[]> {
203
+ const res = await authFetch('/api/tools/pending');
204
+ if (!res.ok) await unwrap(res, "Couldn't load proposed tools.");
205
+ const body = (await res.json()) as { tools?: PendingToolSummary[] } | null;
206
+ // Guarded, not trusted: a backend BUILT BEFORE this route existed answers
207
+ // through `/tools/:slug` — a 200 whose shape is not this one. The review
208
+ // shelf degrading to empty is the right failure; `undefined` reaching the
209
+ // item mapper takes the whole library down (blank page), which is exactly
210
+ // what it did on the skills side before its own guard. A bare `null` body is
211
+ // one of those shapes, and reading `.tools` off it would throw BEFORE the
212
+ // guard ran — so the optional chain is the guard's first half, not decoration.
213
+ return Array.isArray(body?.tools) ? body.tools : [];
214
+ }
@@ -1,8 +1,8 @@
1
- import { PR_STALE_EVENT } from '../../../core/events';
1
+ import { subscribePrStale, TOOL_CREDENTIALS_STALE_EVENT } from '../../../core/events';
2
2
  import { useCallback, useContext, useEffect, useMemo, useState, type ReactNode, } from 'react';
3
3
  import { LibraryContext } from './library-context';
4
4
  import { SKILLS_DIR } from '@bevel-software/platform-shared';
5
- import { pluginNameForPath } from '../utils/plugin-summary';
5
+ import { pluginNameForPath, pluginsHoldingTool } from '../utils/plugin-summary';
6
6
  import type { PluginMembership } from '../services/library.api';
7
7
 
8
8
  /**
@@ -26,12 +26,14 @@ function isSharedPath(path: string): boolean {
26
26
  }
27
27
  import { useLibraryData, type LibraryData } from '../hooks/useLibraryData';
28
28
  import { listPlugins, type PluginSummary } from '../services/plugins.api';
29
+ import { listTeams } from '../services/teams.api';
29
30
  import {
30
31
  isInPlugin,
31
32
  neededToolsFor,
32
33
  skillStatus,
33
34
  toolStatus,
34
35
  type AttentionStatus,
36
+ type TeamAccess,
35
37
  } from '../utils/status';
36
38
 
37
39
  /**
@@ -56,16 +58,27 @@ export interface LibraryItem {
56
58
  id: string;
57
59
  name: string;
58
60
  description: string;
61
+ /**
62
+ * The caller is named in the item's `owner:` grant, directly or through a
63
+ * role — the Owner pill and "Owned by me". Write access is not ownership.
64
+ */
59
65
  owned: boolean;
66
+ /**
67
+ * The caller may write the item — a skill's SKILL.md, a tool's `.tool`
68
+ * file. What the editor-side affordances go by, owner or not.
69
+ */
70
+ canWrite: boolean;
60
71
  status: AttentionStatus;
61
72
  /** Folder plugin from the KB path, or null when the item is in none. */
62
73
  plugin: string | null;
63
74
  /** Under the shared `Skills/` root — see `LibraryFilterable.shared`. */
64
75
  shared?: boolean;
65
- /** Every plugin holding a skill, inline or linked (skills only). */
76
+ /**
77
+ * Every plugin holding the item, inline or linked. A skill's comes from the
78
+ * server, which keeps the link index; a TOOL's is derived here from where
79
+ * its file sits and which roots each plugin links (`pluginsHoldingTool`).
80
+ */
66
81
  plugins?: PluginMembership[];
67
- /** A skill's governance lifecycle (`metadata.lifecycle`), when declared. */
68
- lifecycle?: string;
69
82
  /** Repo-root-relative path — the skill's folder, or the `.tool` file. */
70
83
  path: string;
71
84
  /**
@@ -75,12 +88,15 @@ export interface LibraryItem {
75
88
  */
76
89
  version?: string;
77
90
  /**
78
- * Set only on a skill that does not exist yet — it lives on an open change
79
- * request's branch and is waiting on somebody to approve it.
91
+ * Set only on an item that does not exist yet — it lives on an open change
92
+ * request's branch and is waiting on somebody to approve it. A skill's
93
+ * `SKILL.md`, a tool's `.tool` manual or `mcp.json` server: the same flag,
94
+ * because the reader's question ("can I use this yet?") and the card's
95
+ * answer are the same for both.
80
96
  *
81
97
  * Deliberately NOT folded into `status`: `AttentionStatus` answers "is
82
98
  * anything standing in this item's way?", which drives the setup filter and
83
- * the amber counts, and a skill under review is not a broken skill. Callers
99
+ * the amber counts, and an item under review is not a broken one. Callers
84
100
  * that must treat a proposal differently — the card, the click — read this.
85
101
  */
86
102
  pending?: {
@@ -98,6 +114,19 @@ export interface LibraryContextValue extends LibraryData {
98
114
  pluginSummaries: PluginSummary[];
99
115
  pluginsLoading: boolean;
100
116
  pluginsError: string | null;
117
+ /**
118
+ * What each team can use (`GET /api/teams`), `[]` until loaded and on
119
+ * error. Loaded and reloaded WITH the plugin summaries: both are answers
120
+ * from the access rules, and an edit that changes one changes the other.
121
+ */
122
+ teams: TeamAccess[];
123
+ teamsLoading: boolean;
124
+ /**
125
+ * Why `teams` is empty when it is: the request failed. Kept apart from
126
+ * "no teams" so a team page can tell "this team is not there" from "we
127
+ * could not ask" — the second is not the first.
128
+ */
129
+ teamsError: string | null;
101
130
  reloadPlugins(): void;
102
131
  }
103
132
 
@@ -108,6 +137,9 @@ export function LibraryProvider({ children }: { children: ReactNode }) {
108
137
  const [pluginSummaries, setPluginSummaries] = useState<PluginSummary[]>([]);
109
138
  const [pluginsLoading, setPluginsLoading] = useState(true);
110
139
  const [pluginsError, setPluginsError] = useState<string | null>(null);
140
+ const [teams, setTeams] = useState<TeamAccess[]>([]);
141
+ const [teamsLoading, setTeamsLoading] = useState(true);
142
+ const [teamsError, setTeamsError] = useState<string | null>(null);
111
143
  const [pluginsRevision, setPluginsRevision] = useState(0);
112
144
 
113
145
  useEffect(() => {
@@ -132,6 +164,34 @@ export function LibraryProvider({ children }: { children: ReactNode }) {
132
164
  };
133
165
  }, [pluginsRevision]);
134
166
 
167
+ useEffect(() => {
168
+ let cancelled = false;
169
+ // The team lens degrades to "no teams" rather than failing the Library:
170
+ // the sidebar simply has no team rows, and Everything is untouched.
171
+ // (`teamsLoading` is raised by `reloadPlugins`, as `pluginsLoading` is —
172
+ // the first load starts raised, and the effect body stays free of a
173
+ // synchronous setState.)
174
+ listTeams()
175
+ .then((next) => {
176
+ if (cancelled) return;
177
+ setTeams(next);
178
+ setTeamsError(null);
179
+ })
180
+ .catch((err: unknown) => {
181
+ if (cancelled) return;
182
+ setTeams([]);
183
+ // A blank message is no message: the page tells the error state
184
+ // apart from "no teams" by this being non-empty.
185
+ setTeamsError((err instanceof Error && err.message) || "Couldn't load teams.");
186
+ })
187
+ .finally(() => {
188
+ if (!cancelled) setTeamsLoading(false);
189
+ });
190
+ return () => {
191
+ cancelled = true;
192
+ };
193
+ }, [pluginsRevision]);
194
+
135
195
  const items: LibraryItem[] = useMemo(() => {
136
196
  const skillItems: LibraryItem[] = data.skills.map((s) => ({
137
197
  kind: 'skill',
@@ -139,10 +199,10 @@ export function LibraryProvider({ children }: { children: ReactNode }) {
139
199
  name: s.name,
140
200
  description: s.description,
141
201
  owned: data.ownedSkills.has(s.name),
202
+ canWrite: data.writableSkills.has(s.name),
142
203
  plugin: pluginOfItem(s.path, s.plugins, pluginSummaries),
143
204
  shared: isSharedPath(s.path),
144
205
  plugins: s.plugins ?? [],
145
- lifecycle: s.lifecycle,
146
206
  path: s.path,
147
207
  version: s.version,
148
208
  status: skillStatus(
@@ -166,6 +226,7 @@ export function LibraryProvider({ children }: { children: ReactNode }) {
166
226
  name: s.name,
167
227
  description: s.description,
168
228
  owned: false,
229
+ canWrite: false,
169
230
  plugin: pluginOfItem(s.path, undefined, pluginSummaries),
170
231
  shared: isSharedPath(s.path),
171
232
  path: s.path,
@@ -178,24 +239,79 @@ export function LibraryProvider({ children }: { children: ReactNode }) {
178
239
  mine: s.isAuthor,
179
240
  },
180
241
  }));
181
- const toolItems: LibraryItem[] = data.tools.map((t) => ({
182
- kind: 'integration',
183
- id: t.slug,
184
- name: t.name,
185
- // The browser tool surface exposes no human description for a `.tool`
186
- // manual yet (see report) — the card stays clean; detail lives behind it.
187
- description: '',
188
- owned: t.canWrite,
189
- plugin: pluginOfItem(t.path, undefined, pluginSummaries),
190
- path: t.path,
191
- status: toolStatus(t),
192
- }));
193
- return [...skillItems, ...pendingItems, ...toolItems];
242
+ const toolItems: LibraryItem[] = data.tools.map((t) => {
243
+ // A tool's memberships are DERIVED, not served — the tool surface knows
244
+ // where the file is, the summaries know which roots each plugin links,
245
+ // and `pluginsHoldingTool` is the one place those two meet. With them a
246
+ // tool under a linked root is on the plugin's page, pill and all, the
247
+ // way a linked skill is.
248
+ const plugins = pluginsHoldingTool(t.path, pluginSummaries);
249
+ return {
250
+ kind: 'integration',
251
+ id: t.slug,
252
+ name: t.name,
253
+ // The browser tool surface exposes no human description for a `.tool`
254
+ // manual yet (see report) — the card stays clean; detail lives behind it.
255
+ description: '',
256
+ owned: data.ownedTools.has(t.slug),
257
+ canWrite: t.canWrite,
258
+ plugin: pluginOfItem(t.path, plugins, pluginSummaries),
259
+ plugins,
260
+ path: t.path,
261
+ status: toolStatus(t),
262
+ };
263
+ });
264
+ /**
265
+ * Proposed tools, beside the released ones exactly as proposed skills sit
266
+ * beside released skills — and for the very same bug: a tool an agent
267
+ * proposed was nowhere in the library at all until somebody merged it, so
268
+ * the person who asked for it had no way to see that it was on its way.
269
+ *
270
+ * `owned`/`canWrite` are false and stay false: there is no file on the
271
+ * default branch to own or to edit, and every affordance that reads them
272
+ * would address a path that is not there. Membership is derived from the
273
+ * declaration's own path — where the file will land — by the same
274
+ * `pluginsHoldingTool` the released tools use, so a proposal into a root a
275
+ * plugin LINKS is on that plugin's page the way its released neighbours
276
+ * are. Without it a linked-root proposal would belong to no plugin here and
277
+ * simply never appear.
278
+ */
279
+ const pendingToolItems: LibraryItem[] = data.pendingTools.map((t) => {
280
+ const plugins = pluginsHoldingTool(t.path, pluginSummaries);
281
+ return {
282
+ kind: 'integration',
283
+ id: t.slug,
284
+ name: t.name,
285
+ // The released tool cards carry no description either — detail lives
286
+ // behind the card — and a proposal has even less standing to differ.
287
+ description: '',
288
+ owned: false,
289
+ canWrite: false,
290
+ plugin: pluginOfItem(t.path, plugins, pluginSummaries),
291
+ plugins,
292
+ path: t.path,
293
+ // The neutral `ok`, as for a proposed skill: a proposal has no
294
+ // credential resolved against it, and reporting `warn` would put it in
295
+ // the setup filter and the plugin's amber count as though an integration
296
+ // somebody has to configure had appeared.
297
+ status: { state: 'ok', text: 'In review' },
298
+ pending: {
299
+ changeRequestNumber: t.changeRequestNumber,
300
+ branch: t.branch,
301
+ authorName: t.authorName,
302
+ mine: t.isAuthor,
303
+ },
304
+ };
305
+ });
306
+ return [...skillItems, ...pendingItems, ...toolItems, ...pendingToolItems];
194
307
  }, [
195
308
  data.skills,
196
309
  data.pendingSkills,
197
310
  data.tools,
311
+ data.pendingTools,
198
312
  data.ownedSkills,
313
+ data.writableSkills,
314
+ data.ownedTools,
199
315
  data.allowedToolsBySkill,
200
316
  pluginSummaries,
201
317
  ]);
@@ -206,6 +322,7 @@ export function LibraryProvider({ children }: { children: ReactNode }) {
206
322
  // costs a cascading render on every revision).
207
323
  const reloadPlugins = useCallback(() => {
208
324
  setPluginsLoading(true);
325
+ setTeamsLoading(true);
209
326
  setPluginsRevision((r) => r + 1);
210
327
  }, []);
211
328
 
@@ -225,10 +342,18 @@ export function LibraryProvider({ children }: { children: ReactNode }) {
225
342
  // event; so does the whole Library, or the two would disagree after a
226
343
  // proposal lands or is resolved — and a merged change can move plugin
227
344
  // links and access, so the summaries refresh with the catalog here too.
345
+ useEffect(() => subscribePrStale(reloadAll), [reloadAll]);
346
+
347
+ // A credential landing anywhere in the app is a catalog change here: every
348
+ // "needs setup" in the Library — the cards, the plugin page's banner, the
349
+ // sidebar count — is derived from the tool rows this catalog carries, and
350
+ // they were loaded before the save. The tool page re-probes itself, which is
351
+ // why the bug only ever showed up one click LATER: on the page the reader
352
+ // went back to.
228
353
  useEffect(() => {
229
- const onStale = () => reloadAll();
230
- window.addEventListener(PR_STALE_EVENT, onStale);
231
- return () => window.removeEventListener(PR_STALE_EVENT, onStale);
354
+ const onCredentials = () => reloadAll();
355
+ window.addEventListener(TOOL_CREDENTIALS_STALE_EVENT, onCredentials);
356
+ return () => window.removeEventListener(TOOL_CREDENTIALS_STALE_EVENT, onCredentials);
232
357
  }, [reloadAll]);
233
358
 
234
359
  const value = useMemo(
@@ -239,9 +364,12 @@ export function LibraryProvider({ children }: { children: ReactNode }) {
239
364
  pluginSummaries,
240
365
  pluginsLoading,
241
366
  pluginsError,
367
+ teams,
368
+ teamsLoading,
369
+ teamsError,
242
370
  reloadPlugins,
243
371
  }),
244
- [data, reloadAll, items, pluginSummaries, pluginsLoading, pluginsError, reloadPlugins],
372
+ [data, reloadAll, items, pluginSummaries, pluginsLoading, pluginsError, teams, teamsLoading, teamsError, reloadPlugins],
245
373
  );
246
374
 
247
375
  return <LibraryContext.Provider value={value}>{children}</LibraryContext.Provider>;
@@ -289,25 +417,35 @@ export function workspaceHasNoPlugins(lib: LibraryContextValue): boolean {
289
417
  * concern, not a setup one, and belong to a different surface.
290
418
  */
291
419
  export interface PluginAttention {
292
- /** Everything that needs a person: integrations to set up plus broken links. */
420
+ /** Everything that needs a person: integrations to set up, broken links, and what the definition left out. */
293
421
  total: number;
294
422
  /** The broken-link part alone — what turns the count orange. */
295
423
  brokenLinks: number;
424
+ /** What the platform could not keep of the plugin's definition — a server, a skill root — as the server reports it. */
425
+ warnings: number;
296
426
  }
297
427
 
298
428
  export function attentionOf(
299
- items: LibraryItem[],
429
+ items: readonly LibraryItem[],
300
430
  plugin: string,
301
- summaries: readonly Pick<PluginSummary, 'name' | 'brokenLinks'>[] = [],
431
+ summaries: readonly Pick<PluginSummary, 'name' | 'brokenLinks' | 'warnings'>[] = [],
302
432
  ): PluginAttention {
303
433
  // One pass for the links, returned beside the total: every caller wants
304
434
  // both, and computing the part again for the tone would filter the whole
305
435
  // catalog a second time per plugin.
306
436
  const brokenLinks = brokenLinksOf(items, plugin, summaries);
437
+ // `!i.pending` is said out loud rather than left to the neutral `ok` a
438
+ // proposal carries: this count drives the sidebar badge and the setup
439
+ // filter, and "somebody has to configure this integration" is never true of
440
+ // a tool that does not exist yet. A future status change on the proposal
441
+ // side must not be able to leak into the amber count by accident.
307
442
  const integrations = items.filter(
308
- (i) => isInPlugin(i, plugin) && i.kind === 'integration' && i.status.state !== 'ok',
443
+ (i) => isInPlugin(i, plugin) && i.kind === 'integration' && !i.pending && i.status.state !== 'ok',
309
444
  ).length;
310
- return { total: integrations + brokenLinks, brokenLinks };
445
+ // Amber, like an integration to set up: it needs a person who can edit
446
+ // the plugin's files, and blocks nobody but the users of what is missing.
447
+ const warnings = summaries.find((s) => s.name === plugin)?.warnings?.length ?? 0;
448
+ return { total: integrations + brokenLinks + warnings, brokenLinks, warnings };
311
449
  }
312
450
 
313
451
  /**
@@ -325,7 +463,7 @@ export function attentionOf(
325
463
  * exactly the skill this is about.
326
464
  */
327
465
  export function brokenLinksOf(
328
- items: LibraryItem[],
466
+ items: readonly LibraryItem[],
329
467
  plugin: string,
330
468
  summaries: readonly Pick<PluginSummary, 'name' | 'brokenLinks'>[] = [],
331
469
  ): number {
@@ -1,20 +1,20 @@
1
1
  /**
2
- * The name of a person's own space — the prototype's `MINE()` (line 2078),
3
- * which reads `me().name.split(' ')[0] + "'s List"`.
2
+ * The name of a person's own space — the prototype's `MINE()`, which named
3
+ * it after the person (`Juan's List`).
4
4
  *
5
5
  * It is called a PLUGIN here rather than a list because that is what it now is:
6
6
  * the same page, the same sections, the same card grid as `Plugins/Engineering`.
7
7
  * The only difference is which items it holds, and that is a query, not a kind.
8
8
  *
9
- * First name only, deliberately. "Juan's Plugin" is what a colleague would call
10
- * it out loud; "Juan Viera's Plugin" is what a directory would call it.
9
+ * One name for everyone, deliberately: the page is always the reader's own,
10
+ * so the reader's name on it adds nothing — and a sign-in record's spelling
11
+ * of a name is not a style guide. (`displayFirstName` still greets people
12
+ * on the welcome page.)
11
13
  */
12
- export function personalPluginName(displayName: string | null | undefined): string {
13
- const first = displayFirstName(displayName);
14
- // Nobody signed in, or a user record with no name: the space still exists and
15
- // still needs a heading, and "Yours" is true for whoever is reading it.
16
- if (!first) return 'Yours';
17
- return `${first}'s Plugin`;
14
+ export const PERSONAL_PLUGIN_NAME = 'Personal plugin';
15
+
16
+ export function personalPluginName(): string {
17
+ return PERSONAL_PLUGIN_NAME;
18
18
  }
19
19
 
20
20
  /**
@@ -22,12 +22,10 @@ export function personalPluginName(displayName: string | null | undefined): stri
22
22
  *
23
23
  * Sign-in records are not a style guide — an account created from a lowercase
24
24
  * email or a hastily typed name should still be greeted the way a person
25
- * writes their own name. The capital belongs HERE rather than at each call
26
- * site, so the welcome page and the plugin heading cannot disagree about how
27
- * to spell the same person.
25
+ * writes their own name. The capital belongs HERE rather than at the call
26
+ * site, so every greeting spells the same person the same way.
28
27
  *
29
- * Empty when there is no name to work with, and each caller picks its own
30
- * fallback: the plugin heading says "Yours", the welcome page says "there".
28
+ * Empty when there is no name to work with; the welcome page then says "there".
31
29
  */
32
30
  export function displayFirstName(displayName: string | null | undefined): string {
33
31
  const first = (displayName ?? '').trim().split(/\s+/)[0] ?? '';
@@ -0,0 +1,134 @@
1
+ import { attentionOf, type LibraryItem } from '../state/library-data';
2
+ import type { PluginSummary } from '../services/plugins.api';
3
+ import { pluginLabel } from './plugin-summary';
4
+ import { filterLibraryItems, isInPlugin, pluginsOfItem, type LibraryFilter, type TeamAccess } from './status';
5
+
6
+ /**
7
+ * One plugin row of a gallery page — the Library's plugin renderer takes
8
+ * these (see `PluginRows`). Built from BOTH witnesses, as the all-plugins
9
+ * index built its rows: the summaries (the server's list, with verdicts and
10
+ * counts) and the catalog (an item whose path or link names a plugin the
11
+ * summaries missed still proves the plugin is there).
12
+ */
13
+ export interface PluginEntry {
14
+ /** Identity — what the row navigates by. `null` for the caller's own space. */
15
+ name: string | null;
16
+ label: string;
17
+ summary: PluginSummary | null;
18
+ skillCount: number;
19
+ toolCount: number;
20
+ attention: number;
21
+ urgent: boolean;
22
+ /** The caller can READ it — the server says so, or an item of it is in their catalog. */
23
+ member: boolean;
24
+ }
25
+
26
+ /**
27
+ * The "Owned by me" nav row's numbers, from the two slices its page lists —
28
+ * the owned cards and the owned plugin rows — so the count is the pilled
29
+ * items and cannot drift into a different meaning of "owned". `attention` is
30
+ * the owned cards that need a person.
31
+ */
32
+ export function ownedLensOf(
33
+ items: readonly LibraryItem[],
34
+ summaries: readonly PluginSummary[],
35
+ teams: readonly TeamAccess[],
36
+ personalLabel: string,
37
+ ): { count: number; attention: number } {
38
+ const filter: LibraryFilter = { kind: 'owned' };
39
+ const cards = filterLibraryItems(items, filter, '', teams);
40
+ const plugins = pluginEntriesFor(items, summaries, filter, teams, '', personalLabel);
41
+ return {
42
+ count: cards.length + plugins.length,
43
+ attention: cards.filter((i) => i.status.state !== 'ok').length,
44
+ };
45
+ }
46
+
47
+ /**
48
+ * The plugin rows a gallery filter shows.
49
+ *
50
+ * - Everything: the caller's own space, then every plugin the index lists,
51
+ * members' and locked alike — locked ones are still places on the map.
52
+ * - Owned by me: the plugins the caller owns (`isOwner`), own space first.
53
+ * - A team: the plugins the team can read, as the server named them; the
54
+ * counts on those rows are the TEAM's — how many of the plugin's skills
55
+ * and tools are in the team's slice — so a row never claims more than
56
+ * the cards beneath it show.
57
+ * - A plugin's own page and the personal page list items, not plugins.
58
+ *
59
+ * `query` matches the label, so a search narrows plugins with the cards.
60
+ */
61
+ export function pluginEntriesFor(
62
+ items: readonly LibraryItem[],
63
+ summaries: readonly PluginSummary[],
64
+ filter: LibraryFilter,
65
+ teams: readonly TeamAccess[],
66
+ query: string,
67
+ personalLabel: string,
68
+ ): PluginEntry[] {
69
+ if (filter.kind === 'group' || filter.kind === 'ungrouped') return [];
70
+ const q = query.trim().toLowerCase();
71
+ const matches = (label: string) => !q || label.toLowerCase().includes(q);
72
+
73
+ // Both witnesses: the index, and every plugin an item belongs to — by
74
+ // folder or by link. A plugin the caller reaches only through a shared
75
+ // skill it links has no folder item to name it, and must still be a row.
76
+ const names = new Set<string>(summaries.map((g) => g.name));
77
+ for (const item of items) for (const name of pluginsOfItem(item)) names.add(name);
78
+ const team = filter.kind === 'team' ? teams.find((t) => t.name === filter.group) : undefined;
79
+ const teamItems = filter.kind === 'team' ? filterLibraryItems(items, filter, '', teams) : null;
80
+
81
+ const entries: PluginEntry[] = [];
82
+ if (filter.kind !== 'team') {
83
+ entries.push({
84
+ name: null,
85
+ label: personalLabel,
86
+ summary: null,
87
+ skillCount: countKind(items, null, 'skill'),
88
+ toolCount: countKind(items, null, 'integration'),
89
+ attention: 0,
90
+ urgent: false,
91
+ member: true,
92
+ });
93
+ }
94
+ for (const name of [...names].sort((a, b) => a.localeCompare(b))) {
95
+ const summary = summaries.find((g) => g.name === name) ?? null;
96
+ const derivedSkills = countKind(items, name, 'skill');
97
+ const derivedTools = countKind(items, name, 'integration');
98
+ const hasItems = derivedSkills + derivedTools > 0;
99
+ const attention = attentionOf(items, name, summaries);
100
+ // Membership is READ, never write: an admin rescued into a plugin's
101
+ // rules can manage a folder they cannot open, and that row is locked.
102
+ const member = summary ? summary.canRead || hasItems : hasItems;
103
+ // Ownership, not management: the same `isOwner` the row's Owner pill shows.
104
+ if (filter.kind === 'owned' && !summary?.isOwner) continue;
105
+ if (filter.kind === 'team' && !team?.plugins.includes(name)) continue;
106
+ entries.push({
107
+ name,
108
+ label: pluginLabel(name, summaries),
109
+ summary,
110
+ skillCount: teamItems ? countKind(teamItems, name, 'skill') : summary ? summary.skillCount : derivedSkills,
111
+ toolCount: teamItems ? countKind(teamItems, name, 'integration') : summary ? summary.toolCount : derivedTools,
112
+ attention: attention.total,
113
+ urgent: attention.brokenLinks > 0,
114
+ member,
115
+ });
116
+ }
117
+ return entries.filter((e) => matches(e.label));
118
+ }
119
+
120
+ /**
121
+ * How many of a plugin's items the catalog holds — by folder OR by link,
122
+ * the way the plugin page lists them. `null` is the caller's own space: in
123
+ * no plugin folder and not a shared skill — a shared skill is nobody's
124
+ * alone, however it is linked.
125
+ */
126
+ export function countKind(
127
+ items: readonly LibraryItem[],
128
+ plugin: string | null,
129
+ kind: LibraryItem['kind'],
130
+ ): number {
131
+ return items.filter(
132
+ (i) => i.kind === kind && (plugin === null ? i.plugin === null && !i.shared : isInPlugin(i, plugin)),
133
+ ).length;
134
+ }