@bevel-software/platform-core-frontend 0.13.6 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/package.json +2 -2
  2. package/src/core/CoreAppShell.tsx +18 -17
  3. package/src/core/__tests__/bootstrap.test.ts +33 -1
  4. package/src/core/bootstrap.ts +30 -1
  5. package/src/lib/__tests__/api.test.ts +38 -0
  6. package/src/lib/__tests__/utils.test.ts +43 -0
  7. package/src/lib/api.ts +19 -2
  8. package/src/lib/utils.ts +17 -7
  9. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +111 -1
  10. package/src/modules/access/__tests__/plugin-token.test.ts +21 -0
  11. package/src/modules/access/api.ts +52 -4
  12. package/src/modules/access/components/ManageAccessDialog.tsx +112 -83
  13. package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +65 -1
  14. package/src/modules/git/components/GitSyncFailedBanner.tsx +68 -5
  15. package/src/modules/layout/components/SidebarFrame.tsx +1 -1
  16. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +2 -1
  17. package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +1 -1
  18. package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +121 -0
  19. package/src/modules/library/__tests__/LockedPluginView.test.tsx +6 -0
  20. package/src/modules/library/__tests__/McpServerSection.test.tsx +7 -1
  21. package/src/modules/library/__tests__/NewPluginDialog.test.tsx +5 -4
  22. package/src/modules/library/__tests__/PluginExtras.test.tsx +15 -0
  23. package/src/modules/library/__tests__/PluginPage.test.tsx +195 -1
  24. package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +1 -1
  25. package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +1 -1
  26. package/src/modules/library/__tests__/PluginsSidebar.test.tsx +64 -3
  27. package/src/modules/library/__tests__/SkillPage.test.tsx +9 -2
  28. package/src/modules/library/__tests__/SkillsTree.test.tsx +172 -0
  29. package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +216 -8
  30. package/src/modules/library/__tests__/ToolPage.test.tsx +23 -3
  31. package/src/modules/library/__tests__/ToolVarRow.test.tsx +7 -7
  32. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +115 -4
  33. package/src/modules/library/__tests__/library-data.stale.test.tsx +90 -0
  34. package/src/modules/library/__tests__/library-paths.test.ts +32 -0
  35. package/src/modules/library/__tests__/link-membership.test.ts +120 -0
  36. package/src/modules/library/__tests__/plugin-summary.test.ts +32 -0
  37. package/src/modules/library/__tests__/status.test.ts +84 -0
  38. package/src/modules/library/__tests__/useJoinRequests.test.tsx +46 -0
  39. package/src/modules/library/components/AddToPluginDialog.tsx +33 -0
  40. package/src/modules/library/components/LibraryCard.tsx +21 -1
  41. package/src/modules/library/components/LibraryLayout.tsx +24 -14
  42. package/src/modules/library/components/LinkSkillPanel.tsx +171 -0
  43. package/src/modules/library/components/LockedPluginView.tsx +2 -2
  44. package/src/modules/library/components/NewPluginDialog.tsx +4 -4
  45. package/src/modules/library/components/PageActions.tsx +21 -1
  46. package/src/modules/library/components/PersonalPluginPage.tsx +2 -1
  47. package/src/modules/library/components/PluginExtras.tsx +3 -1
  48. package/src/modules/library/components/PluginPage.tsx +92 -12
  49. package/src/modules/library/components/PluginsIndexPage.tsx +11 -6
  50. package/src/modules/library/components/PluginsSidebar.tsx +110 -53
  51. package/src/modules/library/components/RenamePluginDialog.tsx +136 -0
  52. package/src/modules/library/components/SkillsTree.tsx +91 -0
  53. package/src/modules/library/components/StatusDot.tsx +1 -0
  54. package/src/modules/library/components/plugin-page-parts.tsx +32 -9
  55. package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +218 -0
  56. package/src/modules/library/components/skill-page/SkillPage.tsx +75 -7
  57. package/src/modules/library/components/tool-page/McpServerSection.tsx +9 -1
  58. package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +223 -8
  59. package/src/modules/library/components/tool-page/ToolPage.tsx +30 -2
  60. package/src/modules/library/components/tool-page/ToolVarRow.tsx +30 -8
  61. package/src/modules/library/hooks/useJoinRequests.ts +48 -18
  62. package/src/modules/library/hooks/useToolPage.ts +28 -11
  63. package/src/modules/library/routes/WorkspaceItemRoute.tsx +180 -83
  64. package/src/modules/library/routes/library-paths.ts +21 -8
  65. package/src/modules/library/services/library.api.ts +55 -1
  66. package/src/modules/library/services/plugins.api.ts +94 -3
  67. package/src/modules/library/state/library-data.tsx +115 -22
  68. package/src/modules/library/utils/plugin-summary.ts +36 -0
  69. package/src/modules/library/utils/status.ts +173 -17
  70. package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +3 -2
  71. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +29 -14
  72. package/src/modules/secrets-vault/components/SecretsPage.tsx +4 -1
  73. package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +4 -1
  74. package/src/modules/secrets-vault/services/tool-secrets.api.ts +36 -0
  75. package/src/modules/settings/components/ClaudeConnectionCard.tsx +169 -0
  76. package/src/modules/settings/components/DeploymentPage.tsx +15 -1
  77. package/src/modules/settings/components/__tests__/ClaudeConnectionCard.test.tsx +63 -0
  78. package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +10 -0
  79. package/src/modules/settings/services/github-facade.api.ts +43 -0
  80. package/src/modules/setup/__tests__/setup.test.tsx +118 -0
  81. package/src/modules/setup/components/SetupGate.tsx +1 -1
  82. package/src/modules/setup/components/SetupScreen.tsx +195 -2
  83. package/src/modules/setup/services/setup.api.ts +78 -0
  84. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +301 -93
  85. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +129 -6
  86. package/src/modules/toolbar/services/external-api-keys.api.ts +2 -0
  87. package/src/modules/workspace/__tests__/testFixtures.ts +1 -0
  88. package/src/modules/workspace/components/FileExplorer.tsx +292 -236
  89. package/src/modules/workspace/components/FileRoute.tsx +37 -0
  90. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +39 -0
  91. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +1 -0
  92. package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +70 -0
  93. package/src/modules/workspace/hooks/useWorkspaceState.ts +17 -3
  94. package/src/modules/workspace/routing/kb-routes.ts +1 -1
  95. package/src/modules/workspace/state/workspace.context.ts +8 -0
  96. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +15 -0
  97. package/src/modules/workspace/utils/fileTree.ts +14 -16
  98. package/src/shared/__tests__/marketplace-url.test.ts +54 -0
  99. package/src/shared/components/Badge.tsx +3 -1
  100. package/src/shared/components/Banner.tsx +5 -1
  101. package/src/shared/marketplace-url.ts +90 -0
  102. package/src/shared/theme/tokens.css +9 -0
@@ -85,12 +85,12 @@ export function LockedPluginView({ plugin, onRequested, onUnlocked, onManage }:
85
85
  </Link>
86
86
  <span aria-hidden="true">›</span>
87
87
  <span aria-current="page" className="truncate text-ink-muted">
88
- {plugin.name}
88
+ {plugin.displayName || plugin.name}
89
89
  </span>
90
90
  </nav>
91
91
 
92
92
  <div className="mt-1.5 flex items-center gap-2.5">
93
- <h1 className="text-display font-semibold">{plugin.name}</h1>
93
+ <h1 className="text-display font-semibold">{plugin.displayName || plugin.name}</h1>
94
94
  <Badge tone="outline" size="sm">
95
95
  <LockGlyph className="size-3 shrink-0" />
96
96
  Locked
@@ -50,12 +50,12 @@ export function NewPluginDialog({ existing, onClose, onCreated }: NewPluginDialo
50
50
  if (!canCreate) return;
51
51
  setBusy(true);
52
52
  try {
53
- // Navigate with the SERVER's folder name, not the typed one — the
54
- // endpoint owns the canonical spelling of what it created.
55
- const { folder } = await createPlugin(trimmed);
53
+ // Navigate with the SERVER's identity, not the typed name — the
54
+ // endpoint owns the identifier of what it created.
55
+ const { name } = await createPlugin(trimmed);
56
56
  onCreated();
57
57
  onClose();
58
- navigate(pathForPlugin(folder));
58
+ navigate(pathForPlugin(name));
59
59
  } catch (err) {
60
60
  // The server's refusal names the problem (name taken, reserved
61
61
  // prefix…) — worth more than a generic apology.
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useRef, useState } from 'react';
2
- import { Link2, Plus, Trash2, Users } from 'lucide-react';
2
+ import { Link2, Plus, Trash2, Users, Pencil } from 'lucide-react';
3
3
  import { cn } from '../../../lib/utils';
4
4
  import {
5
5
  Button,
@@ -58,6 +58,11 @@ export interface PageActionsProps {
58
58
  * 404s for everyone but the owner is a broken promise, not a consistency.
59
59
  */
60
60
  onDelete?: () => void;
61
+ /**
62
+ * Opens the rename dialog. Present only for a MANAGER (the same write
63
+ * verdict that lets them link and answer join requests).
64
+ */
65
+ onRename?: () => void;
61
66
  /** Names the thing, for the `+` tooltip and the accessible names. */
62
67
  addLabel?: string;
63
68
  }
@@ -67,6 +72,7 @@ export function PageActions({
67
72
  onAdd,
68
73
  onCopyLink,
69
74
  onDelete,
75
+ onRename,
70
76
  addLabel = 'Add a skill or tool',
71
77
  }: PageActionsProps) {
72
78
  const [open, setOpen] = useState(false);
@@ -128,6 +134,20 @@ export function PageActions({
128
134
  item that cannot do its job is worse than one that is not
129
135
  there. The menu exists so it drops in without moving
130
136
  anything. */}
137
+ {onRename && (
138
+ <MenuItem
139
+ role="menuitem"
140
+ onClick={() => {
141
+ close();
142
+ onRename();
143
+ }}
144
+ >
145
+ <span className="flex items-center gap-2.5">
146
+ <Pencil size={14} />
147
+ Rename plugin
148
+ </span>
149
+ </MenuItem>
150
+ )}
131
151
  {onDelete && (
132
152
  <MenuItem
133
153
  role="menuitem"
@@ -1,4 +1,5 @@
1
1
  import { useMemo, useState } from 'react';
2
+ import { isUngrouped } from '../utils/status';
2
3
  import { useNavigate } from 'react-router-dom';
3
4
  import { useAuth } from '../../auth/state/auth.context';
4
5
  import { useLibrary, type LibraryItem } from '../state/library-data';
@@ -46,7 +47,7 @@ export function PersonalPluginPage() {
46
47
  const [removing, setRemoving] = useState<LibraryItem | null>(null);
47
48
 
48
49
  const name = personalPluginName(user?.name);
49
- const items = useMemo(() => data.items.filter((i) => i.plugin === null), [data.items]);
50
+ const items = useMemo(() => data.items.filter(isUngrouped), [data.items]);
50
51
  /**
51
52
  * For the add dialog's name check. Every skill, not only the ungrouped ones:
52
53
  * a skill's id is its name and ids are global, so a new skill here collides
@@ -165,7 +165,9 @@ export function ClientExtensionsSection({
165
165
  */
166
166
  function namespaceListings(tree: FileTreeEntry, folder: string): NamespaceListing[] {
167
167
  const kbRoot = findKbRoot(tree);
168
- const pluginDir = kbRoot ? descend(kbRoot, [PLUGINS_DIR, folder]) : null;
168
+ // `folder` is the path below the plugins root — one segment for a top-level
169
+ // plugin, several for a nested one — and the tree is walked a segment at a time.
170
+ const pluginDir = kbRoot ? descend(kbRoot, [PLUGINS_DIR, ...folder.split('/')]) : null;
169
171
  if (!pluginDir?.children) return [];
170
172
  const out: NamespaceListing[] = [];
171
173
  for (const child of pluginDir.children) {
@@ -3,12 +3,15 @@ import { Link, useNavigate, useParams } from 'react-router-dom';
3
3
  import { Banner, Button } from '../../../shared/components';
4
4
  import { attentionOf, useLibrary, type LibraryItem } from '../state/library-data';
5
5
  import { useLibraryToast } from '../state/toast.context';
6
+ import { isInPlugin, withLinkHealth } from '../utils/status';
6
7
  import {
7
8
  decodePluginSegment,
9
+ pathForPlugin,
8
10
  pathForPluginsIndex,
9
11
  urlForLibraryItem,
10
12
  } from '../routes/library-paths';
11
- import { primaryFolderOf } from '../utils/plugin-summary';
13
+ import { pluginLabel, primaryFolderOf } from '../utils/plugin-summary';
14
+ import { RenamePluginDialog } from './RenamePluginDialog';
12
15
  import { PluginJoinRequests } from './PluginJoinRequests';
13
16
  import { useWorkspace } from '../../workspace/state/workspace.context';
14
17
  import { ManifestButton, ClientExtensionsSection } from './PluginExtras';
@@ -115,13 +118,18 @@ export function PluginPage() {
115
118
  const [removing, setRemoving] = useState<LibraryItem | null>(null);
116
119
  /** Whether the plugin's own delete confirmation is up. */
117
120
  const [deleteOpen, setDeleteOpen] = useState(false);
121
+ /** Whether the rename dialog is up. */
122
+ const [renameOpen, setRenameOpen] = useState(false);
118
123
 
119
124
  const summary = useMemo(
120
125
  () => data.pluginSummaries.find((g) => g.name === plugin) ?? null,
121
126
  [data.pluginSummaries, plugin],
122
127
  );
128
+ // Inline AND linked: a shared skill linked from this plugin's manifest is
129
+ // one of its skills. A link whose grant went missing carries the amber
130
+ // "needs setup" foot note here — the one place the plugin's members look.
123
131
  const pluginItems = useMemo(
124
- () => data.items.filter((i) => i.plugin === plugin),
132
+ () => data.items.filter((i) => isInPlugin(i, plugin)).map((i) => withLinkHealth(i, plugin)),
125
133
  [data.items, plugin],
126
134
  );
127
135
  /** For the add dialog's name check — global, because a skill's id is global. */
@@ -131,8 +139,13 @@ export function PluginPage() {
131
139
  );
132
140
 
133
141
  const skillItems = pluginItems.filter((i) => i.kind === 'skill');
142
+ const releasedSkillItems = skillItems.filter((i) => !i.pending);
134
143
  const toolItems = pluginItems.filter((i) => i.kind === 'integration');
135
- const attention = attentionOf(data.items, plugin);
144
+ // Two kinds of attention, two banners: a link without its grant locks the
145
+ // plugin's members out of a skill NOW, so it outranks an integration the
146
+ // reader has not connected for themselves.
147
+ const { total: attention, brokenLinks } = attentionOf(data.items, plugin, data.pluginSummaries);
148
+ const integrationsNeedingSetup = attention - brokenLinks;
136
149
  // What the Skills band actually renders. The filter is a VIEW over the band,
137
150
  // not a different query — flipping it back must show exactly what was there.
138
151
  const shownSkills = filterOn ? skillItems.filter((i) => i.status.state !== 'ok') : skillItems;
@@ -224,10 +237,16 @@ export function PluginPage() {
224
237
  }
225
238
 
226
239
  const primaryFolder = summary ? primaryFolderOf(summary) : null;
240
+ // What the page CALLS the plugin — its display name. `plugin` stays the
241
+ // identity: the URL, the grants, the API.
242
+ const label = pluginLabel(plugin, data.pluginSummaries);
243
+ // Where its files ARE, below the plugins root — what the manifest button
244
+ // and the extensions listing build paths from. The identity is not a path.
245
+ const folderBelowRoot = primaryFolder ? primaryFolder.slice(primaryFolder.indexOf('/') + 1) : plugin;
227
246
 
228
247
  return (
229
248
  <div className="pb-14">
230
- <PluginBreadcrumb name={plugin} />
249
+ <PluginBreadcrumb name={label} />
231
250
 
232
251
  {/* The title row carries the page's one persistent action. `Share` IS
233
252
  the manage-access dialog — not a doorway to it. It stays un-gated:
@@ -238,9 +257,18 @@ export function PluginPage() {
238
257
  Share stays un-gated: for a non-writer the dialog renders read-only,
239
258
  which is exactly what "who is this shared with?" should answer. */}
240
259
  <div className="flex items-start justify-between gap-4">
241
- <h1 className="mt-1.5 text-display font-semibold">{plugin}</h1>
260
+ <div className="min-w-0">
261
+ <h1 className="mt-1.5 text-display font-semibold">{label}</h1>
262
+ {/* Where it lives — the folder is no longer the name, so it is
263
+ said beneath it, the way a file path sits under a document title. */}
264
+ {primaryFolder && (
265
+ <p className="mt-0.5 truncate font-mono text-meta text-ink-faint" title={primaryFolder}>
266
+ {primaryFolder}
267
+ </p>
268
+ )}
269
+ </div>
242
270
  <div className="mt-1.5 flex items-center gap-1">
243
- <ManifestButton kbDirName={kbDirName} folder={plugin} canWrite={summary?.canWrite === true} />
271
+ <ManifestButton kbDirName={kbDirName} folder={folderBelowRoot} canWrite={summary?.canWrite === true} />
244
272
  <PageActions
245
273
  onShare={primaryFolder ? () => setManageFolder(primaryFolder) : undefined}
246
274
  // The dialog needs both to mount (`addOpen && summary &&
@@ -255,7 +283,11 @@ export function PluginPage() {
255
283
  // route enforces, so the item appears for exactly the people the
256
284
  // backend will let through.
257
285
  onDelete={summary?.isOwner ? () => setDeleteOpen(true) : undefined}
258
- addLabel={`Add a skill or tool to ${plugin}`}
286
+ // The MANAGER's verb: the same gate as linking and the join banner —
287
+ // and, like linking, only for a plugin this platform writes (an
288
+ // external format is renamed in its own repository).
289
+ onRename={summary?.canWrite && summary.linksAreManaged !== false ? () => setRenameOpen(true) : undefined}
290
+ addLabel={`Add a skill or tool to ${label}`}
259
291
  />
260
292
  </div>
261
293
  </div>
@@ -274,11 +306,20 @@ export function PluginPage() {
274
306
  />
275
307
  )}
276
308
 
277
- {attention > 0 && (
309
+ {brokenLinks > 0 && (
310
+ <Banner role="status" tone="urgent" className="mt-4">
311
+ {`${brokenLinks} ${
312
+ brokenLinks === 1
313
+ ? `linked skill can't be read by ${label}'s members: its access rules no longer name them. Repair the link`
314
+ : `linked skills can't be read by ${label}'s members: their access rules no longer name them. Repair the links`
315
+ } from the skill page${brokenLinks === 1 ? '' : 's'}.`}
316
+ </Banner>
317
+ )}
318
+ {integrationsNeedingSetup > 0 && (
278
319
  <Banner role="status" tone="wait" className="mt-4">
279
320
  <span>
280
- {`${attention} ${
281
- attention === 1
321
+ {`${integrationsNeedingSetup} ${
322
+ integrationsNeedingSetup === 1
282
323
  ? 'integration needs setup: connect it'
283
324
  : 'integrations need setup: connect them'
284
325
  } to unblock this plugin's skills.`}
@@ -289,6 +330,19 @@ export function PluginPage() {
289
330
  </Banner>
290
331
  )}
291
332
 
333
+ {/* Ownership decides readability, the plugin is a view: a linked skill
334
+ the caller may not read is simply absent from their list, and the
335
+ plugin's own total says how many. */}
336
+ {/* Against the RELEASED skills the caller sees: a pending proposal is
337
+ a card here but not in the plugin's total, and counting it would
338
+ hide one hidden skill per proposal. */}
339
+ {summary && summary.skillCount > releasedSkillItems.length && (
340
+ <p className="mb-2 text-detail text-ink-faint">
341
+ {summary.skillCount - releasedSkillItems.length === 1
342
+ ? '1 skill in this plugin is not shared with you.'
343
+ : `${summary.skillCount - releasedSkillItems.length} skills in this plugin are not shared with you.`}
344
+ </p>
345
+ )}
292
346
  <PluginItemSections
293
347
  skillItems={shownSkills}
294
348
  toolItems={toolItems}
@@ -297,6 +351,11 @@ export function PluginPage() {
297
351
  // them answer join requests. The backend's per-path gate enforces it
298
352
  // for real; this only decides who sees the affordance.
299
353
  onRemove={summary?.canWrite ? setRemoving : undefined}
354
+ // A LINK into a plugin whose links live in an external format cannot
355
+ // be removed here — the endpoint refuses it — so it is not offered.
356
+ canRemove={(item) =>
357
+ summary?.linksAreManaged !== false || !(item.plugins?.some((m) => m.name === plugin && m.linked) ?? false)
358
+ }
300
359
  emptySkills={
301
360
  filterOn ? (
302
361
  'Nothing in this band needs you right now.'
@@ -367,10 +426,28 @@ export function PluginPage() {
367
426
  // Every skill, not just this plugin's: a skill's id is its name and
368
427
  // ids are global, so the collision that matters is with any of them.
369
428
  existingSkills={allSkillNames}
429
+ linkable={data.items}
430
+ onLinked={() => {
431
+ data.reload();
432
+ data.reloadPlugins();
433
+ }}
370
434
  onClose={() => setAddOpen(false)}
371
435
  />
372
436
  )}
373
437
 
438
+ {renameOpen && summary && (
439
+ <RenamePluginDialog
440
+ plugin={summary}
441
+ onClose={() => setRenameOpen(false)}
442
+ onRenamed={(next) => {
443
+ data.reload();
444
+ data.reloadPlugins();
445
+ // The identity is the URL: a renamed plugin lives at a new address.
446
+ if (next.name !== plugin) navigate(pathForPlugin(next.name));
447
+ }}
448
+ />
449
+ )}
450
+
374
451
  {deleteOpen && summary && (
375
452
  <DeletePluginDialog
376
453
  name={plugin}
@@ -392,9 +469,12 @@ export function PluginPage() {
392
469
  <RemoveLibraryItemDialog
393
470
  item={removing}
394
471
  place={plugin}
472
+ // In this plugin by LINK: the manifest entry goes, the skill stays.
473
+ linked={removing.plugins?.some((m) => m.name === plugin && m.linked) ?? false}
395
474
  onClose={() => setRemoving(null)}
396
475
  onRemoved={() => {
397
- toast(`Removed ${removing.name} from ${plugin}.`);
476
+ const wasLinked = removing.plugins?.some((m) => m.name === plugin && m.linked) ?? false;
477
+ toast(wasLinked ? `Unlinked ${removing.name} from ${plugin}.` : `Removed ${removing.name} from ${plugin}.`);
398
478
  // Catalog for the card, plugin index for the counts.
399
479
  data.reload();
400
480
  data.reloadPlugins();
@@ -402,7 +482,7 @@ export function PluginPage() {
402
482
  />
403
483
  )}
404
484
 
405
- <ClientExtensionsSection kbDirName={kbDirName} folder={plugin} />
485
+ <ClientExtensionsSection kbDirName={kbDirName} folder={folderBelowRoot} />
406
486
  {manageDialog}
407
487
  </div>
408
488
  );
@@ -6,7 +6,7 @@ import { useAdmin } from '../../admin/state/admin.context';
6
6
  import { attentionOf, useLibrary, workspaceHasNoPlugins, type LibraryItem } from '../state/library-data';
7
7
  import { personalPluginName } from '../utils/personal-plugin';
8
8
  import { LIBRARY_ROOT, pathForPlugin } from '../routes/library-paths';
9
- import { ownersTextOf } from '../utils/plugin-summary';
9
+ import { ownersTextOf, pluginLabel } from '../utils/plugin-summary';
10
10
  import type { PluginSummary } from '../services/plugins.api';
11
11
  import { EmptyStateAction } from './plugin-page-parts';
12
12
  import { PluginIndexRow } from './PluginIndexRow';
@@ -36,6 +36,8 @@ interface IndexEntry {
36
36
  skillCount: number;
37
37
  toolCount: number;
38
38
  attention: number;
39
+ /** Some of the attention locks members out of a skill — orange, not amber. */
40
+ urgent: boolean;
39
41
  /** The caller can see inside: folder read, manage rights, or item grants. */
40
42
  member: boolean;
41
43
  }
@@ -63,6 +65,7 @@ export function PluginsIndexPage() {
63
65
  const derivedSkills = countKind(items, name, 'skill');
64
66
  const derivedTools = countKind(items, name, 'integration');
65
67
  const hasItems = derivedSkills + derivedTools > 0;
68
+ const attention = attentionOf(items, name, pluginSummaries);
66
69
  return {
67
70
  name,
68
71
  summary,
@@ -71,7 +74,8 @@ export function PluginsIndexPage() {
71
74
  // "4 skills" here as on the plugin page.
72
75
  skillCount: summary ? summary.skillCount : derivedSkills,
73
76
  toolCount: summary ? summary.toolCount : derivedTools,
74
- attention: attentionOf(items, name),
77
+ attention: attention.total,
78
+ urgent: attention.brokenLinks > 0,
75
79
  member: summary ? summary.canRead || summary.canWrite || hasItems : hasItems,
76
80
  };
77
81
  });
@@ -147,7 +151,7 @@ export function PluginsIndexPage() {
147
151
  {mine.map((entry) => (
148
152
  <PluginIndexRow
149
153
  key={entry.name}
150
- label={entry.name}
154
+ label={pluginLabel(entry.name, pluginSummaries)}
151
155
  badge={
152
156
  entry.summary?.canWrite ? (
153
157
  <Badge tone="outline" size="xs" className="shrink-0 uppercase">
@@ -158,7 +162,7 @@ export function PluginsIndexPage() {
158
162
  {...describe(entry)}
159
163
  trailing={
160
164
  entry.attention > 0 ? (
161
- <Badge tone="wait" size="xs">
165
+ <Badge tone={entry.urgent ? 'urgent' : 'wait'} size="xs">
162
166
  {entry.attention}
163
167
  </Badge>
164
168
  ) : undefined
@@ -175,7 +179,7 @@ export function PluginsIndexPage() {
175
179
  {locked.map((entry) => (
176
180
  <PluginIndexRow
177
181
  key={entry.name}
178
- label={entry.name}
182
+ label={pluginLabel(entry.name, pluginSummaries)}
179
183
  {...describe(entry)}
180
184
  /* The row has to SAY it is locked, not just look it — the
181
185
  glyph is decorative (`aria-hidden`) and the word beside
@@ -244,7 +248,8 @@ function countsText(skills: number, tools: number): string {
244
248
  }
245
249
 
246
250
  function countKind(items: LibraryItem[], plugin: string | null, kind: LibraryItem['kind']): number {
247
- return items.filter((i) => i.plugin === plugin && i.kind === kind).length;
251
+ // The `null` bucket is "yours alone": shared skills have no folder plugin but are not yours.
252
+ return items.filter((i) => i.plugin === plugin && i.kind === kind && (plugin !== null || !i.shared)).length;
248
253
  }
249
254
 
250
255
  /** Section label with an optional count cap beside it, not inside it — the
@@ -27,13 +27,24 @@ export interface PluginsSidebarProps {
27
27
  filter: LibraryFilter | null;
28
28
  /** A row was clicked — the layout navigates; the sidebar owns no state. */
29
29
  onSelect(filter: LibraryFilter): void;
30
- /** Readable plugins, with their item count and how many integrations need setup. */
31
- plugins: { plugin: string; count: number; attention: number }[];
30
+ /** Readable plugins, with their item count and how many integrations need setup. `label` is what the row shows; `plugin` is the identity it navigates by. */
31
+ plugins: {
32
+ plugin: string;
33
+ label?: string;
34
+ count: number;
35
+ attention: number;
36
+ /**
37
+ * Some of the attention is a linked skill the plugin's members cannot
38
+ * read. That outranks a tool the reader has not set up for themselves —
39
+ * it blocks other people — so the count turns orange, not amber.
40
+ */
41
+ urgent?: boolean;
42
+ }[];
32
43
  /**
33
44
  * Plugins the caller cannot read, alphabetical. Rendered after a gap, with a
34
- * lock instead of a count.
45
+ * lock instead of a count. A bare string is a plugin whose label is its name.
35
46
  */
36
- lockedPlugins: string[];
47
+ lockedPlugins: (string | { name: string; label: string })[];
37
48
  ownedCount: number;
38
49
  /**
39
50
  * How many of the caller's OWN items are waiting on them. Drives the amber
@@ -87,6 +98,16 @@ export interface PluginsSidebarProps {
87
98
  * appears — which is the honest default for a view with no actions wired.
88
99
  */
89
100
  onContextMenu?(target: SidebarContextTarget): void;
101
+ /**
102
+ * The Skills folder — a file tree of the shared `Skills/` root — rendered
103
+ * right under the All plugins home row, before the Library lenses: the two
104
+ * places the Library hangs off. A SLOT rather than a component this
105
+ * nav names: the tree reads the workspace and navigates on its own, and the
106
+ * sidebar stays what it is, a pure view of names and counts. Omitted, the
107
+ * nav has no Skills section, which keeps a host rendering the shipped nav
108
+ * source-compatible.
109
+ */
110
+ skillsTree?: ReactNode;
90
111
  }
91
112
 
92
113
  /**
@@ -123,6 +144,7 @@ export function PluginsSidebar({
123
144
  pluginsIndexActive,
124
145
  onOpenPluginsIndex,
125
146
  onContextMenu,
147
+ skillsTree,
126
148
  }: PluginsSidebarProps) {
127
149
  const rowClass = (selected: boolean) =>
128
150
  cn(
@@ -162,10 +184,12 @@ export function PluginsSidebar({
162
184
  label: string,
163
185
  target: LibraryFilter,
164
186
  count: number,
165
- tone: 'count' | 'pending' = 'count',
187
+ tone: 'count' | 'pending' | 'urgent' = 'count',
166
188
  ) => (
167
189
  <button
168
- key={label}
190
+ // Keyed by what the row IS (its target), never by what it says: two
191
+ // plugins may share a label, and React must still tell their rows apart.
192
+ key={target.kind === 'group' ? `group:${target.plugin}` : target.kind}
169
193
  type="button"
170
194
  aria-current={isCurrent(target)}
171
195
  className={rowClass(isCurrent(target))}
@@ -178,7 +202,11 @@ export function PluginsSidebar({
178
202
  <span
179
203
  className={cn(
180
204
  'h-4.5 shrink-0 basis-5.5 rounded-md text-center text-meta leading-[18px] tabular-nums',
181
- tone === 'pending' ? 'bg-wait-soft font-bold text-wait' : 'text-ink-faint',
205
+ tone === 'urgent'
206
+ ? 'bg-urgent-soft font-bold text-urgent'
207
+ : tone === 'pending'
208
+ ? 'bg-wait-soft font-bold text-wait'
209
+ : 'text-ink-faint',
182
210
  )}
183
211
  >
184
212
  {count}
@@ -198,13 +226,15 @@ export function PluginsSidebar({
198
226
  * (a non-member has nothing to fix). The accessible name carries the state in
199
227
  * words, so the glyph itself can stay decorative.
200
228
  */
201
- const lockedRow = (name: string) => {
229
+ const lockedRow = (locked: string | { name: string; label: string }) => {
230
+ const name = typeof locked === 'string' ? locked : locked.name;
231
+ const label = typeof locked === 'string' ? locked : locked.label;
202
232
  const target: LibraryFilter = { kind: 'group', plugin: name };
203
233
  return (
204
234
  <button
205
235
  key={`locked:${name}`}
206
236
  type="button"
207
- aria-label={`${name} (locked)`}
237
+ aria-label={`${label} (locked)`}
208
238
  aria-current={isCurrent(target)}
209
239
  className={rowClass(isCurrent(target))}
210
240
  onClick={() => onSelect(target)}
@@ -212,9 +242,9 @@ export function PluginsSidebar({
212
242
  // reason it gets the same click: a plugin you are not in is still a
213
243
  // place, and `Manage access` is exactly the item an admin locked out of
214
244
  // one needs. Which verbs are actually true is the layout's call.
215
- onContextMenu={(e) => openMenu(e, target, name, e.currentTarget)}
245
+ onContextMenu={(e) => openMenu(e, target, label, e.currentTarget)}
216
246
  >
217
- <span className="truncate">{name}</span>
247
+ <span className="truncate">{label}</span>
218
248
  <span className="flex h-4.5 shrink-0 basis-5.5 items-center justify-center text-ink-faint">
219
249
  <LockGlyph className="size-3" />
220
250
  </span>
@@ -225,7 +255,7 @@ export function PluginsSidebar({
225
255
  return (
226
256
  <>
227
257
  <nav
228
- aria-label="Library plugins"
258
+ aria-label="Library navigation"
229
259
  className="flex min-h-0 flex-1 flex-col gap-px overflow-y-auto"
230
260
  // The nav's empty space is a target too — Knowledge's tree gives its
231
261
  // ROOT row a menu holding the create verbs, and this is where the
@@ -253,6 +283,10 @@ export function PluginsSidebar({
253
283
  >
254
284
  <span className="truncate">All plugins</span>
255
285
  </button>
286
+ {/* The shared Skills root, a folder right under the home row: the
287
+ two places the Library hangs off — every plugin, every skill —
288
+ before any lens slices the catalog. The tree is its own row. */}
289
+ {skillsTree}
256
290
 
257
291
  {/* Lenses — the whole catalog, sliced — which is exactly what the
258
292
  plugin rows below are not. Naming the section is what keeps that
@@ -277,14 +311,16 @@ export function PluginsSidebar({
277
311
  {/* Your own space leads the plugins, as in the prototype (line 2487):
278
312
  it is the one you are always in. */}
279
313
  {row(personalPluginLabel, { kind: 'ungrouped' }, ungroupedCount)}
280
- {plugins.map(({ plugin, count, attention }) =>
314
+ {plugins.map(({ plugin, label, count, attention, urgent }) =>
281
315
  // Amber wins the count slot: a plugin that needs setup is telling you
282
- // something, and how many items it holds is not the news.
316
+ // something, and how many items it holds is not the news. Orange
317
+ // wins over amber: members locked out of a skill outrank a tool
318
+ // the reader has not set up for themselves.
283
319
  row(
284
- plugin,
320
+ label ?? plugin,
285
321
  { kind: 'group', plugin },
286
322
  attention > 0 ? attention : count,
287
- attention > 0 ? 'pending' : 'count',
323
+ attention > 0 ? (urgent ? 'urgent' : 'pending') : 'count',
288
324
  ),
289
325
  )}
290
326
  {/* The heading's `+` is hover-revealed, and a person with no plugins
@@ -337,52 +373,73 @@ export function PluginsSidebar({
337
373
  }
338
374
 
339
375
  /**
340
- * The `INCLUDED IN YOUR MCP` heading, and the one way to make a new plugin —
341
- * the prototype's `.lbladd` (line 78).
342
- *
343
- * The heading says what this list IS rather than what its rows are called:
344
- * these folders are the set mounted into the caller's MCP — the agent's
345
- * working context — not merely a directory of plugins. (The locked rows that
346
- * trail the list sit below a gap for exactly that reason: they are in the
347
- * workspace but not in your MCP, and the break is what keeps the heading
348
- * honest about them.)
376
+ * A nav section's name, with an optional row of actions at its right edge.
377
+ * The first one has no top padding — the sidebar's own `pt-6` already placed
378
+ * it — so every label is the same component with its spacing decided by where
379
+ * it sits, not by which one it is.
349
380
  *
350
- * `All plugins` is NOT a row here. It heads the whole nav instead: it is the
351
- * Library's home rather than one more entry in the set mounted into your MCP,
352
- * and inside this list it used to collect the clicks meant for the plugins
353
- * under it.
354
- *
355
- * The `+` is always in the DOM and always reachable by keyboard; only its
356
- * opacity follows hover, so the nav stays quiet without the control being
357
- * conditional. `focus-visible:opacity-100` is what keeps that honest for
381
+ * The actions are always in the DOM and always reachable by keyboard; only
382
+ * their opacity follows hover, so the nav stays quiet without the controls
383
+ * being conditional. `focus-within:opacity-100` is what keeps that honest for
358
384
  * anyone who never hovers anything.
385
+ *
386
+ * Exported for the Skills tree, whose heading is this label with the tree's
387
+ * own create buttons in the slot — one heading style over every list of
388
+ * places in this nav.
359
389
  */
360
- /**
361
- * A nav section's name. The first one has no top padding — the sidebar's own
362
- * `pt-6` already placed it — so the two labels are the same component with
363
- * their spacing decided by where they sit, not by which one they are.
364
- */
365
- function SectionLabel({ children, spaced = false }: { children: ReactNode; spaced?: boolean }) {
390
+ export function SectionLabel({
391
+ children,
392
+ spaced = false,
393
+ actions,
394
+ }: {
395
+ children: ReactNode;
396
+ spaced?: boolean;
397
+ actions?: ReactNode;
398
+ }) {
366
399
  return (
367
- <div className={cn('px-2.5 pb-1.5 text-label uppercase text-ink-faint', spaced && 'pt-5')}>
368
- {children}
400
+ <div className={cn('group/label flex items-center gap-1 px-2.5 pb-1.5', spaced && 'pt-5')}>
401
+ <span className="text-label uppercase text-ink-faint">{children}</span>
402
+ {actions && (
403
+ <span className="ml-auto flex items-center gap-0.5 opacity-0 transition-opacity focus-within:opacity-100 group-hover/label:opacity-100">
404
+ {actions}
405
+ </span>
406
+ )}
369
407
  </div>
370
408
  );
371
409
  }
372
410
 
411
+ /**
412
+ * The `PLUGINS` heading, and the one way to make a new plugin — the
413
+ * prototype's `.lbladd` (line 78).
414
+ *
415
+ * It used to read "Included in your MCP", from when a plugin was the only
416
+ * way a skill reached an agent. Skills have a root of their own now, listed
417
+ * as a tree above this section, so the heading says what these rows ARE:
418
+ * plugins — the bundles the caller is in. (The locked rows that trail the
419
+ * list sit below a gap for the same reason: they are in the workspace but
420
+ * not the caller's, and the break is what keeps the heading honest.)
421
+ *
422
+ * `All plugins` is NOT a row here. It heads the whole nav instead: it is the
423
+ * Library's home rather than one more entry in the caller's set, and inside
424
+ * this list it used to collect the clicks meant for the plugins under it.
425
+ */
373
426
  function PluginsLabel({ onCreate }: { onCreate(): void }) {
374
427
  return (
375
- <div className="group/label flex items-center gap-1 px-2.5 pb-1.5 pt-5">
376
- <span className="text-label uppercase text-ink-faint">Included in your MCP</span>
377
- <button
378
- type="button"
379
- onClick={onCreate}
380
- title="New plugin"
381
- aria-label="New plugin"
382
- className="ml-auto flex size-4.5 items-center justify-center rounded-xs text-ui leading-none text-ink-faint opacity-0 transition-opacity hover:bg-hover hover:text-ink focus-visible:opacity-100 group-hover/label:opacity-100"
383
- >
384
- +
385
- </button>
386
- </div>
428
+ <SectionLabel
429
+ spaced
430
+ actions={
431
+ <button
432
+ type="button"
433
+ onClick={onCreate}
434
+ title="New plugin"
435
+ aria-label="New plugin"
436
+ className="flex size-4.5 items-center justify-center rounded-xs text-ui leading-none text-ink-faint hover:bg-hover hover:text-ink"
437
+ >
438
+ +
439
+ </button>
440
+ }
441
+ >
442
+ Plugins
443
+ </SectionLabel>
387
444
  );
388
445
  }