@bevel-software/platform-core-frontend 0.14.0 → 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 (89) 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/api.ts +19 -2
  7. package/src/lib/utils.ts +2 -0
  8. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +111 -1
  9. package/src/modules/access/__tests__/plugin-token.test.ts +21 -0
  10. package/src/modules/access/api.ts +52 -4
  11. package/src/modules/access/components/ManageAccessDialog.tsx +112 -83
  12. package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +65 -1
  13. package/src/modules/git/components/GitSyncFailedBanner.tsx +68 -5
  14. package/src/modules/layout/components/SidebarFrame.tsx +1 -1
  15. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +1 -1
  16. package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +1 -1
  17. package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +121 -0
  18. package/src/modules/library/__tests__/LockedPluginView.test.tsx +6 -0
  19. package/src/modules/library/__tests__/NewPluginDialog.test.tsx +5 -4
  20. package/src/modules/library/__tests__/PluginExtras.test.tsx +15 -0
  21. package/src/modules/library/__tests__/PluginPage.test.tsx +195 -1
  22. package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +1 -1
  23. package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +1 -1
  24. package/src/modules/library/__tests__/PluginsSidebar.test.tsx +64 -3
  25. package/src/modules/library/__tests__/SkillPage.test.tsx +9 -2
  26. package/src/modules/library/__tests__/SkillsTree.test.tsx +172 -0
  27. package/src/modules/library/__tests__/ToolPage.test.tsx +7 -0
  28. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +115 -4
  29. package/src/modules/library/__tests__/library-data.stale.test.tsx +90 -0
  30. package/src/modules/library/__tests__/library-paths.test.ts +32 -0
  31. package/src/modules/library/__tests__/link-membership.test.ts +120 -0
  32. package/src/modules/library/__tests__/plugin-summary.test.ts +32 -0
  33. package/src/modules/library/__tests__/useJoinRequests.test.tsx +46 -0
  34. package/src/modules/library/components/AddToPluginDialog.tsx +33 -0
  35. package/src/modules/library/components/LibraryCard.tsx +14 -0
  36. package/src/modules/library/components/LibraryLayout.tsx +24 -14
  37. package/src/modules/library/components/LinkSkillPanel.tsx +171 -0
  38. package/src/modules/library/components/LockedPluginView.tsx +2 -2
  39. package/src/modules/library/components/NewPluginDialog.tsx +4 -4
  40. package/src/modules/library/components/PageActions.tsx +21 -1
  41. package/src/modules/library/components/PersonalPluginPage.tsx +2 -1
  42. package/src/modules/library/components/PluginExtras.tsx +3 -1
  43. package/src/modules/library/components/PluginPage.tsx +92 -12
  44. package/src/modules/library/components/PluginsIndexPage.tsx +11 -6
  45. package/src/modules/library/components/PluginsSidebar.tsx +110 -53
  46. package/src/modules/library/components/RenamePluginDialog.tsx +136 -0
  47. package/src/modules/library/components/SkillsTree.tsx +91 -0
  48. package/src/modules/library/components/StatusDot.tsx +1 -0
  49. package/src/modules/library/components/plugin-page-parts.tsx +32 -9
  50. package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +218 -0
  51. package/src/modules/library/components/skill-page/SkillPage.tsx +70 -6
  52. package/src/modules/library/components/tool-page/ToolPage.tsx +11 -2
  53. package/src/modules/library/hooks/useJoinRequests.ts +48 -18
  54. package/src/modules/library/routes/WorkspaceItemRoute.tsx +180 -83
  55. package/src/modules/library/routes/library-paths.ts +21 -8
  56. package/src/modules/library/services/library.api.ts +55 -1
  57. package/src/modules/library/services/plugins.api.ts +94 -3
  58. package/src/modules/library/state/library-data.tsx +115 -22
  59. package/src/modules/library/utils/plugin-summary.ts +36 -0
  60. package/src/modules/library/utils/status.ts +74 -7
  61. package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +3 -2
  62. package/src/modules/settings/components/ClaudeConnectionCard.tsx +169 -0
  63. package/src/modules/settings/components/DeploymentPage.tsx +15 -1
  64. package/src/modules/settings/components/__tests__/ClaudeConnectionCard.test.tsx +63 -0
  65. package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +10 -0
  66. package/src/modules/settings/services/github-facade.api.ts +43 -0
  67. package/src/modules/setup/__tests__/setup.test.tsx +118 -0
  68. package/src/modules/setup/components/SetupGate.tsx +1 -1
  69. package/src/modules/setup/components/SetupScreen.tsx +195 -2
  70. package/src/modules/setup/services/setup.api.ts +78 -0
  71. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +295 -83
  72. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +129 -6
  73. package/src/modules/toolbar/services/external-api-keys.api.ts +2 -0
  74. package/src/modules/workspace/__tests__/testFixtures.ts +1 -0
  75. package/src/modules/workspace/components/FileExplorer.tsx +292 -236
  76. package/src/modules/workspace/components/FileRoute.tsx +37 -0
  77. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +39 -0
  78. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +1 -0
  79. package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +70 -0
  80. package/src/modules/workspace/hooks/useWorkspaceState.ts +17 -3
  81. package/src/modules/workspace/routing/kb-routes.ts +1 -1
  82. package/src/modules/workspace/state/workspace.context.ts +8 -0
  83. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +15 -0
  84. package/src/modules/workspace/utils/fileTree.ts +14 -16
  85. package/src/shared/__tests__/marketplace-url.test.ts +54 -0
  86. package/src/shared/components/Badge.tsx +3 -1
  87. package/src/shared/components/Banner.tsx +5 -1
  88. package/src/shared/marketplace-url.ts +90 -0
  89. package/src/shared/theme/tokens.css +9 -0
@@ -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
  }
@@ -0,0 +1,136 @@
1
+ import { useId, useState } from 'react';
2
+ import { PERSONAL_PLUGIN_PREFIX, pluginManifestName } from '@bevel-software/platform-shared';
3
+ import { Banner, Button, Dialog, TextField } from '../../../shared/components';
4
+ import { renamePlugin, type PluginSummary } from '../services/plugins.api';
5
+ import { useLibraryToast } from '../state/toast.context';
6
+
7
+ /** The Agent Plugins identifier rule — lowercase kebab-case, nothing else. */
8
+ const IDENTIFIER_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
9
+
10
+ /**
11
+ * Rename a plugin: its identifier, its display name, or both.
12
+ *
13
+ * The identifier is the plugin — the grants spell it, the URLs key on it,
14
+ * the marketplace publishes it — so changing it rewrites every grant that
15
+ * names the old one, in one commit, and the dialog says so before the click.
16
+ * The display name is only what people see.
17
+ */
18
+ export function RenamePluginDialog({
19
+ plugin,
20
+ onClose,
21
+ onRenamed,
22
+ }: {
23
+ plugin: Pick<PluginSummary, 'name' | 'displayName' | 'folders'>;
24
+ onClose(): void;
25
+ /** The rename landed; the host reloads and, when the identifier changed, navigates. */
26
+ onRenamed(next: { name: string; displayName: string }): void;
27
+ }) {
28
+ const nameId = useId();
29
+ const displayId = useId();
30
+ const toast = useLibraryToast();
31
+ const [name, setName] = useState(plugin.name);
32
+ const [displayName, setDisplayName] = useState(plugin.displayName ?? plugin.name);
33
+ const [busy, setBusy] = useState(false);
34
+ const [error, setError] = useState<string | null>(null);
35
+
36
+ const trimmedName = name.trim();
37
+ const identifierChanges = trimmedName !== plugin.name;
38
+ // The same three rules the server applies — the identifier shape, the
39
+ // reserved prefix, and that the name is its own slug (the marketplace keys
40
+ // on a 64-character slug; a longer name would be one thing here and
41
+ // another everywhere it is published) — and, like the server, only to a
42
+ // NEW identifier: the current one is whatever the manifest says, and a
43
+ // name that predates a rule must not block a display-name change.
44
+ const nameError = !identifierChanges || !trimmedName
45
+ ? null
46
+ : !IDENTIFIER_RE.test(trimmedName)
47
+ ? 'Lowercase letters, digits and single hyphens, like sales-team.'
48
+ : trimmedName.startsWith(PERSONAL_PLUGIN_PREFIX)
49
+ ? `"${PERSONAL_PLUGIN_PREFIX}" is reserved for personal folders. Pick another identifier.`
50
+ : pluginManifestName(trimmedName) !== trimmedName
51
+ ? 'Too long: an identifier is at most 64 characters.'
52
+ : null;
53
+ const changed = identifierChanges || displayName.trim() !== (plugin.displayName ?? plugin.name);
54
+ const canSubmit = trimmedName.length > 0 && nameError === null && changed && !busy;
55
+
56
+ async function submit() {
57
+ if (!canSubmit) return;
58
+ setBusy(true);
59
+ setError(null);
60
+ try {
61
+ const next = await renamePlugin(plugin.name, {
62
+ ...(identifierChanges ? { name: trimmedName } : {}),
63
+ displayName: displayName.trim(),
64
+ });
65
+ toast(identifierChanges ? `Renamed ${plugin.name} to ${next.name}.` : `Renamed to ${next.displayName}.`);
66
+ onRenamed(next);
67
+ onClose();
68
+ } catch (err) {
69
+ setError(err instanceof Error ? err.message : "Couldn't rename the plugin.");
70
+ setBusy(false);
71
+ }
72
+ }
73
+
74
+ return (
75
+ <Dialog
76
+ open
77
+ onClose={onClose}
78
+ title={`Rename ${plugin.displayName ?? plugin.name}`}
79
+ size="md"
80
+ busy={busy}
81
+ footer={
82
+ <>
83
+ <Button variant="quiet" onClick={onClose} disabled={busy}>
84
+ Cancel
85
+ </Button>
86
+ <Button onClick={() => void submit()} disabled={!canSubmit}>
87
+ {busy ? 'Renaming…' : 'Rename'}
88
+ </Button>
89
+ </>
90
+ }
91
+ >
92
+ <div className="space-y-3">
93
+ <div>
94
+ <label htmlFor={displayId} className="mb-1 block text-detail font-medium text-ink">
95
+ Display name
96
+ </label>
97
+ <TextField
98
+ id={displayId}
99
+ value={displayName}
100
+ onChange={(e) => setDisplayName(e.target.value)}
101
+ placeholder={plugin.folders[0]?.split('/').pop() ?? plugin.name}
102
+ />
103
+ <p className="mt-1 text-meta text-ink-faint">What people see in the sidebar and on this page.</p>
104
+ </div>
105
+ <div>
106
+ <label htmlFor={nameId} className="mb-1 block text-detail font-medium text-ink">
107
+ Identifier
108
+ </label>
109
+ <TextField
110
+ id={nameId}
111
+ value={name}
112
+ onChange={(e) => setName(e.target.value)}
113
+ aria-invalid={nameError ? true : undefined}
114
+ className="font-mono"
115
+ />
116
+ <p className="mt-1 text-meta text-ink-faint">
117
+ {nameError ??
118
+ 'The name agents install it by, and the one grants use: plugin/<identifier>/read.'}
119
+ </p>
120
+ </div>
121
+ {identifierChanges && !nameError && (
122
+ <Banner tone="wait" role="status">
123
+ Every grant of <span className="font-mono">plugin/{plugin.name}/…</span> in the knowledge base is
124
+ rewritten to <span className="font-mono">plugin/{trimmedName}/…</span> in the same change. The folder
125
+ stays where it is.
126
+ </Banner>
127
+ )}
128
+ {error && (
129
+ <Banner tone="danger" role="alert">
130
+ {error}
131
+ </Banner>
132
+ )}
133
+ </div>
134
+ </Dialog>
135
+ );
136
+ }
@@ -0,0 +1,91 @@
1
+ import { useMemo } from 'react';
2
+ import { useLocation, useNavigate } from 'react-router-dom';
3
+ import { DEFAULT_BRANCH, SKILLS_DIR } from '@bevel-software/platform-shared';
4
+ import { useWorkspace } from '../../workspace/state/workspace.context';
5
+ import { findKbRoot } from '../../workspace/utils/fileTree';
6
+ import { KB_ROUTE_PREFIX, kbFileUrl, safeDecode } from '../../workspace/routing/kb-routes';
7
+ import { useMergedWorkspaceTree } from '../../workspace/hooks/useMergedWorkspaceTree';
8
+ import {
9
+ FileTreeNode,
10
+ TreeChrome,
11
+ UploadNotices,
12
+ type TreeNav,
13
+ } from '../../workspace/components/FileExplorer';
14
+
15
+ /**
16
+ * The Skills section of the Library's nav: the shared `Skills/` root as a
17
+ * file tree, made of the SAME rows as Knowledge's explorer — right-click menu
18
+ * (new file, new folder, rename, delete, manage access, download), drag to
19
+ * move, drop to upload, the caller's proposed files shown in accent. One tree
20
+ * component in the app, holding a different root.
21
+ *
22
+ * The root is a collapsible folder row called Skills, exactly as Knowledge
23
+ * and Data are top-level folders in the Knowledge explorer: open by default
24
+ * with its scopes collapsed under it, a drop target for uploads into
25
+ * `Skills/`, the create buttons on hover, the folder's menu on right-click —
26
+ * minus what a platform-owned root must not offer (`FileTreeNode.reserved`:
27
+ * no rename, delete, drag or pin).
28
+ *
29
+ * Two things differ from Knowledge, and both are the surroundings' (see
30
+ * `TreeChrome`), not the rows':
31
+ *
32
+ * - A click opens the file on its SKILL PAGE, here in Skills & Tools — at
33
+ * the item's canonical default-branch URL, whatever branch is checked
34
+ * out. The Library speaks the default branch everywhere; this is no
35
+ * exception.
36
+ * - The current row is the file the URL names, not the pane workspace's
37
+ * open tab, which the Library never sets.
38
+ *
39
+ * Renders nothing while the tree is loading or when the caller can read no
40
+ * part of the root — an empty Skills folder would be a question, not a
41
+ * section.
42
+ */
43
+ export function SkillsTree() {
44
+ const { kbDirName } = useWorkspace();
45
+ const { tree, suggestionOnlyPaths } = useMergedWorkspaceTree();
46
+ const location = useLocation();
47
+ const navigate = useNavigate();
48
+
49
+ const root = useMemo(() => {
50
+ const kids = findKbRoot(tree)?.children;
51
+ return kids?.find((c) => c.type === 'directory' && c.name === SKILLS_DIR) ?? null;
52
+ }, [tree]);
53
+
54
+ const nav = useMemo<TreeNav>(
55
+ () => ({
56
+ activePath: activeWorkspacePath(location.pathname, kbDirName),
57
+ open: (path) => navigate(kbFileUrl(DEFAULT_BRANCH, path)),
58
+ }),
59
+ [location.pathname, kbDirName, navigate],
60
+ );
61
+
62
+ if (!root) return null;
63
+
64
+ return (
65
+ <TreeChrome nav={nav} suggestionOnlyPaths={suggestionOnlyPaths}>
66
+ {/* A right-click that lands between the tree's rows is the tree's, not
67
+ the plugin nav's behind it: with nothing wired for the gap the
68
+ browser's own menu is the honest answer, as in Knowledge. The rows
69
+ stop their own events before reaching here. */}
70
+ <div data-testid="skills-tree" onContextMenu={(e) => e.stopPropagation()}>
71
+ <UploadNotices />
72
+ <FileTreeNode entry={root} depth={0} reserved collapseChildren />
73
+ </div>
74
+ </TreeChrome>
75
+ );
76
+ }
77
+
78
+ /**
79
+ * The workspace-relative path a Library URL names, or null. Library item
80
+ * pages live at `/workspace/<default>/<kbDir>/...` — the inverse of
81
+ * `kbFileUrl`, segment by segment. Any other URL (the index, a lens, a
82
+ * plugin page) names no file, so no row is current.
83
+ */
84
+ function activeWorkspacePath(pathname: string, kbDirName: string | null): string | null {
85
+ const prefix = `${KB_ROUTE_PREFIX}/`;
86
+ if (!pathname.startsWith(prefix)) return null;
87
+ const [branch, ...rest] = pathname.slice(prefix.length).split('/').map(safeDecode);
88
+ if (branch !== DEFAULT_BRANCH || rest.length < 2) return null;
89
+ if (kbDirName !== null && rest[0] !== kbDirName) return null;
90
+ return rest.join('/');
91
+ }
@@ -4,6 +4,7 @@ import type { GemState } from '../utils/status';
4
4
  const TONE: Record<GemState, string> = {
5
5
  ok: 'bg-ok',
6
6
  warn: 'bg-wait-dot',
7
+ urgent: 'bg-urgent',
7
8
  err: 'bg-danger',
8
9
  };
9
10
 
@@ -7,6 +7,7 @@ import { Banner, Button, Dialog, IconButton } from '../../../shared/components';
7
7
  import { pathForPluginsIndex } from '../routes/library-paths';
8
8
  import type { LibraryItem } from '../state/library-data';
9
9
  import { removeLibraryItem } from '../services/library.api';
10
+ import { unlinkSkill } from '../services/plugins.api';
10
11
  import { LibraryCard } from './LibraryCard';
11
12
 
12
13
  /**
@@ -111,6 +112,7 @@ export function CardGrid({
111
112
  items,
112
113
  onOpen,
113
114
  onRemove,
115
+ canRemove,
114
116
  }: {
115
117
  items: LibraryItem[];
116
118
  onOpen(item: LibraryItem): void;
@@ -121,6 +123,12 @@ export function CardGrid({
121
123
  * card is one <button>, and a button inside a button is not HTML.
122
124
  */
123
125
  onRemove?(item: LibraryItem): void;
126
+ /**
127
+ * Per item, whether the verb would succeed — a link into a plugin whose
128
+ * links live in an external format cannot be removed here. Absent: every
129
+ * item. A verb the server would refuse is not offered.
130
+ */
131
+ canRemove?(item: LibraryItem): boolean;
124
132
  }) {
125
133
  return (
126
134
  <div
@@ -156,6 +164,7 @@ export function CardGrid({
156
164
  owned={item.owned}
157
165
  status={item.status}
158
166
  version={item.version}
167
+ lifecycle={item.lifecycle}
159
168
  pending={
160
169
  item.pending && {
161
170
  authorName: item.pending.authorName,
@@ -167,7 +176,7 @@ export function CardGrid({
167
176
  );
168
177
  // A pending proposal is not IN the place yet — there is nothing to
169
178
  // remove; declining it lives with the review.
170
- if (!onRemove || item.pending) return card;
179
+ if (!onRemove || item.pending || (canRemove && !canRemove(item))) return card;
171
180
  return (
172
181
  // `grid`, not a plain block: the wrapper takes the card's place as
173
182
  // the grid item, and only a grid (or flex) container stretches its
@@ -199,16 +208,24 @@ export function CardGrid({
199
208
  * The "are you sure" a removal deserves: deleting a skill or tool from a
200
209
  * plugin takes it from EVERYONE in the plugin, not from a personal shelf, and
201
210
  * there is no undo shortcut — the content survives only in git history.
211
+ *
212
+ * A LINKED skill is the other case: it lives elsewhere and the plugin only
213
+ * points at it, so "remove" means unlink — the manifest entry and the
214
+ * plugin's grant go, the skill stays where it is. Sending a link through the
215
+ * delete path would delete a shared skill (or be refused by its own rules).
202
216
  */
203
217
  export function RemoveLibraryItemDialog({
204
218
  item,
205
219
  place,
220
+ linked = false,
206
221
  onClose,
207
222
  onRemoved,
208
223
  }: {
209
224
  item: LibraryItem;
210
225
  /** Where it is being removed from, for the copy: a plugin name, or "your space". */
211
226
  place: string;
227
+ /** The item is in `place` by LINK — remove the link, not the item. `place` is then the plugin. */
228
+ linked?: boolean;
212
229
  onClose(): void;
213
230
  /** Fired after the delete lands; the host page reloads and says so. */
214
231
  onRemoved(): void;
@@ -221,7 +238,8 @@ export function RemoveLibraryItemDialog({
221
238
  setBusy(true);
222
239
  setError(null);
223
240
  try {
224
- await removeLibraryItem(item.path);
241
+ if (linked) await unlinkSkill(place, item.path);
242
+ else await removeLibraryItem(item.path);
225
243
  onRemoved();
226
244
  onClose();
227
245
  } catch (err) {
@@ -236,7 +254,7 @@ export function RemoveLibraryItemDialog({
236
254
  <Dialog
237
255
  open
238
256
  onClose={onClose}
239
- title={`Remove ${item.name}?`}
257
+ title={linked ? `Unlink ${item.name}?` : `Remove ${item.name}?`}
240
258
  size="md"
241
259
  busy={busy}
242
260
  footer={
@@ -245,15 +263,17 @@ export function RemoveLibraryItemDialog({
245
263
  Cancel
246
264
  </Button>
247
265
  <Button variant="danger" onClick={() => void remove()} disabled={busy}>
248
- {busy ? 'Removing…' : 'Remove'}
266
+ {busy ? (linked ? 'Unlinking…' : 'Removing…') : linked ? 'Unlink' : 'Remove'}
249
267
  </Button>
250
268
  </>
251
269
  }
252
270
  >
253
271
  <p className="text-ui text-ink-muted">
254
- {item.kind === 'skill'
255
- ? `This deletes the skill and its files from ${place}. Everyone here loses it the next time their agent connects.`
256
- : `This deletes the tool and its connection settings from ${place}. Skills here that need it will ask for setup again.`}
272
+ {linked
273
+ ? `This removes the link from ${place}. The skill itself stays where it lives; ${place}'s members stop seeing it here.`
274
+ : item.kind === 'skill'
275
+ ? `This deletes the skill and its files from ${place}. Everyone here loses it the next time their agent connects.`
276
+ : `This deletes the tool and its connection settings from ${place}. Skills here that need it will ask for setup again.`}
257
277
  </p>
258
278
  {error && (
259
279
  <Banner tone="danger" role="alert" className="mt-3">
@@ -276,6 +296,7 @@ export function PluginItemSections({
276
296
  toolItems,
277
297
  onOpen,
278
298
  onRemove,
299
+ canRemove,
279
300
  emptySkills,
280
301
  emptyTools = 'No tools yet.',
281
302
  hideEmpty = false,
@@ -287,6 +308,8 @@ export function PluginItemSections({
287
308
  onOpen(item: LibraryItem): void;
288
309
  /** See {@link CardGrid} — present only when the caller manages this place. */
289
310
  onRemove?(item: LibraryItem): void;
311
+ /** See {@link CardGrid}. */
312
+ canRemove?(item: LibraryItem): boolean;
290
313
  /**
291
314
  * A plain sentence, or an `EmptySkillsNudge`. A string still gets the band's
292
315
  * standard paragraph; a node is trusted to bring its own — the nudge carries
@@ -329,7 +352,7 @@ export function PluginItemSections({
329
352
  emptySkills
330
353
  )
331
354
  ) : (
332
- <CardGrid items={skillItems} onOpen={onOpen} onRemove={onRemove} />
355
+ <CardGrid items={skillItems} onOpen={onOpen} onRemove={onRemove} canRemove={canRemove} />
333
356
  )}
334
357
  </PluginSection>
335
358
  )}
@@ -339,7 +362,7 @@ export function PluginItemSections({
339
362
  {toolItems.length === 0 ? (
340
363
  <p className="text-ui text-ink-faint">{emptyTools}</p>
341
364
  ) : (
342
- <CardGrid items={toolItems} onOpen={onOpen} onRemove={onRemove} />
365
+ <CardGrid items={toolItems} onOpen={onOpen} onRemove={onRemove} canRemove={canRemove} />
343
366
  )}
344
367
  </PluginSection>
345
368
  )}