@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
@@ -12,8 +12,8 @@ import {
12
12
  pathForPluginsIndex,
13
13
  pathForLibraryFilter,
14
14
  } from '../routes/library-paths';
15
- import { pluginCounts, type LibraryFilter } from '../utils/status';
16
- import { primaryFolderOf } from '../utils/plugin-summary';
15
+ import { isUngrouped, pluginCounts, pluginsOfItem, type LibraryFilter } from '../utils/status';
16
+ import { pluginLabel, primaryFolderOf } from '../utils/plugin-summary';
17
17
  import { LINK_COPIED_TOAST, LINK_COPY_FAILED_TOAST, copyToClipboard } from '../utils/clipboard';
18
18
  import { useLibraryToast } from '../state/toast.context';
19
19
  import { useSidebar } from '../../layout/state/sidebar';
@@ -22,6 +22,7 @@ import { useWorkspace } from '../../workspace/state/workspace.context';
22
22
  import { ManageAccessDialog } from '../../access/components/ManageAccessDialog';
23
23
  import { ConnectAgentPill } from '../../onboarding/components/ConnectAgentPill';
24
24
  import { PluginsSidebar, type SidebarContextTarget } from './PluginsSidebar';
25
+ import { SkillsTree } from './SkillsTree';
25
26
  import { PluginsSidebarMenu } from './PluginsSidebarMenu';
26
27
  import { AddToPluginDialog } from './AddToPluginDialog';
27
28
  import { DeletePluginDialog } from './DeletePluginDialog';
@@ -96,8 +97,8 @@ export function LibraryLayout() {
96
97
  * The member rows: every plugin the caller can READ (or manages), whether or
97
98
  * not anything is in it yet. Counts come from the catalog, membership does
98
99
  * not — a freshly created plugin has no skills or tools, and deriving the
99
- * rows from the items alone made it vanish from the very nav that says
100
- * "Included in your MCP". Being in a plugin is what puts it in your MCP;
100
+ * rows from the items alone made it vanish from the very nav that lists
101
+ * the caller's plugins. Being in a plugin is what puts it in your MCP;
101
102
  * having content is not. The catalog still contributes names the summaries
102
103
  * miss (a per-file grant can surface one skill from an otherwise unreadable
103
104
  * folder), so the two witnesses are merged rather than either winning.
@@ -110,11 +111,16 @@ export function LibraryLayout() {
110
111
  }
111
112
  return [...names]
112
113
  .sort((a, b) => a.localeCompare(b))
113
- .map((plugin) => ({
114
- plugin,
115
- count: counts.get(plugin) ?? 0,
116
- attention: attentionOf(items, plugin),
117
- }));
114
+ .map((plugin) => {
115
+ const attention = attentionOf(items, plugin, pluginSummaries);
116
+ return {
117
+ plugin,
118
+ label: pluginLabel(plugin, pluginSummaries),
119
+ count: counts.get(plugin) ?? 0,
120
+ attention: attention.total,
121
+ urgent: attention.brokenLinks > 0,
122
+ };
123
+ });
118
124
  }, [items, pluginSummaries]);
119
125
  /**
120
126
  * Plugins the caller cannot get into, alphabetical.
@@ -127,13 +133,16 @@ export function LibraryLayout() {
127
133
  * which is what keeps the row and the page it opens in agreement.
128
134
  */
129
135
  const lockedPlugins = useMemo(() => {
130
- const visible = new Set(items.map((i) => i.plugin).filter((g): g is string => g !== null));
136
+ // Membership by folder AND by link: a shared skill linked into a plugin
137
+ // the caller cannot open still sits in the gallery under that plugin, so
138
+ // the plugin is visible, not locked — or it would be listed twice.
139
+ const visible = new Set(items.flatMap((i) => pluginsOfItem(i)));
131
140
  return pluginSummaries
132
141
  // A manager (canWrite via admin-rescue) is not locked out — their plugin
133
142
  // belongs with the ones they run, not below the gap.
134
143
  .filter((g) => !g.canRead && !g.canWrite && !visible.has(g.name))
135
- .map((g) => g.name)
136
- .sort((a, b) => a.localeCompare(b));
144
+ .map((g) => ({ name: g.name, label: g.displayName || g.name }))
145
+ .sort((a, b) => a.label.localeCompare(b.label));
137
146
  }, [pluginSummaries, items]);
138
147
 
139
148
  const ownedCount = useMemo(() => items.filter((i) => i.owned).length, [items]);
@@ -146,7 +155,7 @@ export function LibraryLayout() {
146
155
  () => items.filter((i) => i.owned && i.status.state !== 'ok').length,
147
156
  [items],
148
157
  );
149
- const ungroupedCount = useMemo(() => items.filter((i) => i.plugin === null).length, [items]);
158
+ const ungroupedCount = useMemo(() => items.filter(isUngrouped).length, [items]);
150
159
  const attentionCount = useMemo(
151
160
  () => items.filter((i) => i.kind === 'integration' && i.status.state !== 'ok').length,
152
161
  [items],
@@ -207,7 +216,7 @@ export function LibraryLayout() {
207
216
  place — a person who skipped the welcome page and stayed in
208
217
  Knowledge still sees it. It renders nothing once onboarding is
209
218
  done. */}
210
- <SidebarFrame label="Library plugins" header={<ConnectAgentPill />}>
219
+ <SidebarFrame label="Library navigation" header={<ConnectAgentPill />}>
211
220
  <PluginsSidebar
212
221
  filter={filter}
213
222
  onSelect={(next) => navigate(pathForLibraryFilter(next))}
@@ -229,6 +238,7 @@ export function LibraryLayout() {
229
238
  pluginsIndexActive={isPluginsIndexPath(location.pathname)}
230
239
  onOpenPluginsIndex={() => navigate(pathForPluginsIndex())}
231
240
  onContextMenu={openContextMenu}
241
+ skillsTree={<SkillsTree />}
232
242
  />
233
243
  </SidebarFrame>
234
244
 
@@ -0,0 +1,171 @@
1
+ import { useMemo, useState } from 'react';
2
+ import { Button, Badge } from '../../../shared/components';
3
+ import type { LibraryItem } from '../state/library-data';
4
+ import { useLibraryToast } from '../state/toast.context';
5
+ import { NeedsSkillWriteError, linkSkill } from '../services/plugins.api';
6
+ import { requestSkillAccess } from '../services/library.api';
7
+ import { isInPlugin } from '../utils/status';
8
+
9
+ /**
10
+ * "Link an existing skill" — the picker behind adding a shared skill to a
11
+ * plugin without copying it.
12
+ *
13
+ * Every released skill the caller can read is offered, minus the ones already
14
+ * in this plugin. Linking needs write on the skill's rules as well as on the
15
+ * plugin (the link grants the plugin's principal on the skill), and the server
16
+ * is the one that knows: a refusal of that shape turns the row's action into
17
+ * "Request write access", which opens the same kind of change request as
18
+ * asking to join a plugin. Nothing is decided client-side from a stale verdict.
19
+ *
20
+ * Prop-driven (the caller hands it the catalog) so it renders anywhere the
21
+ * plugin page's data is, without reaching for the library context itself.
22
+ */
23
+ export function LinkSkillPanel({
24
+ plugin,
25
+ items,
26
+ onLinked,
27
+ }: {
28
+ plugin: string;
29
+ /** The caller's catalog; the panel offers its released skills not yet in `plugin`. */
30
+ items: LibraryItem[];
31
+ onLinked(): void;
32
+ }) {
33
+ const toast = useLibraryToast();
34
+ const [query, setQuery] = useState('');
35
+ // What is in flight, and for which skill: the live region names the
36
+ // operation, so a write-access request is never announced as a link.
37
+ const [busy, setBusy] = useState<{ id: string; op: 'link' | 'request' } | null>(null);
38
+ /** Per skill: the server said write on the skill is missing / a request is open. */
39
+ const [needsWrite, setNeedsWrite] = useState<Record<string, 'ask' | 'requested'>>({});
40
+
41
+ const candidates = useMemo(() => {
42
+ const q = query.trim().toLowerCase();
43
+ return items
44
+ // Retired skills are kept for their owners and never shared onward; the
45
+ // server refuses them too, this just keeps them out of the list.
46
+ .filter((i): i is LibraryItem => i.kind === 'skill' && !i.pending && i.lifecycle !== 'retired' && !isInPlugin(i, plugin))
47
+ .filter((i) => !q || i.name.toLowerCase().includes(q) || i.description.toLowerCase().includes(q))
48
+ .sort((a, b) => a.name.localeCompare(b.name));
49
+ }, [items, plugin, query]);
50
+
51
+ async function link(item: LibraryItem) {
52
+ setBusy({ id: item.id, op: 'link' });
53
+ try {
54
+ const result = await linkSkill(plugin, item.path);
55
+ toast(
56
+ result.skills.length === 1
57
+ ? `${item.name} is now in ${plugin}. Its members can read it; its managers can edit it.`
58
+ : `${result.skills.length} skills are now in ${plugin}.`,
59
+ );
60
+ onLinked();
61
+ } catch (err) {
62
+ if (err instanceof NeedsSkillWriteError) {
63
+ setNeedsWrite((m) => ({ ...m, [item.id]: 'ask' }));
64
+ } else {
65
+ toast(err instanceof Error ? err.message : "Couldn't link that skill.", 'danger');
66
+ }
67
+ } finally {
68
+ setBusy(null);
69
+ }
70
+ }
71
+
72
+ async function request(item: LibraryItem) {
73
+ setBusy({ id: item.id, op: 'request' });
74
+ try {
75
+ await requestSkillAccess(item.name);
76
+ setNeedsWrite((m) => ({ ...m, [item.id]: 'requested' }));
77
+ toast(`Asked ${item.name}'s editors for write access. Link it once they say yes.`);
78
+ } catch (err) {
79
+ toast(err instanceof Error ? err.message : "Couldn't request access.", 'danger');
80
+ } finally {
81
+ setBusy(null);
82
+ }
83
+ }
84
+
85
+ return (
86
+ <div data-testid="link-skill-panel">
87
+ <p className="text-ui text-ink-muted">
88
+ {`Link a skill that already exists. It stays where it is; ${plugin}'s members get to read it and its managers get to edit it.`}
89
+ </p>
90
+ {/* The in-flight word for assistive tech. The clicked button says
91
+ "Linking…" too, but a button that goes disabled drops focus, so a
92
+ label change there is never read out; a live region is. */}
93
+ <span role="status" aria-live="polite" aria-label="Link progress" className="sr-only">
94
+ {busy === null
95
+ ? ''
96
+ : busy.op === 'link'
97
+ ? `Linking ${busy.id}…`
98
+ : `Requesting write access to ${busy.id}…`}
99
+ </span>
100
+ <input
101
+ type="search"
102
+ value={query}
103
+ onChange={(e) => setQuery(e.target.value)}
104
+ placeholder="Search skills…"
105
+ aria-label="Search skills to link"
106
+ className="mt-2.5 w-full rounded-md border border-line bg-surface px-2.5 py-1.5 text-ui text-ink placeholder:text-ink-faint focus:outline-none"
107
+ />
108
+ <ul className="mt-2 max-h-64 divide-y divide-line overflow-auto rounded-md border border-line">
109
+ {candidates.length === 0 && (
110
+ <li className="px-3 py-3 text-detail text-ink-faint">
111
+ {query.trim() ? 'No skill matches.' : 'Every skill you can see is already in this plugin.'}
112
+ </li>
113
+ )}
114
+ {candidates.map((item) => {
115
+ const state = needsWrite[item.id];
116
+ return (
117
+ <li key={item.id} className="flex items-center gap-3 px-3 py-2">
118
+ <div className="min-w-0 flex-1">
119
+ <div className="flex items-center gap-1.5">
120
+ <span className="truncate text-ui font-medium text-ink">{item.name}</span>
121
+ {item.shared ? (
122
+ <Badge tone="outline" size="xs" className="shrink-0 uppercase">
123
+ Shared
124
+ </Badge>
125
+ ) : item.plugin ? (
126
+ <Badge tone="outline" size="xs" className="shrink-0 uppercase">
127
+ {item.plugin}
128
+ </Badge>
129
+ ) : null}
130
+ </div>
131
+ {item.description && (
132
+ <div className="truncate text-detail text-ink-muted">{item.description}</div>
133
+ )}
134
+ {state === 'ask' && (
135
+ <div className="text-detail text-wait">
136
+ {"You can't change who may read this skill yet. Ask its editors first."}
137
+ </div>
138
+ )}
139
+ </div>
140
+ {state === 'requested' ? (
141
+ <span className="shrink-0 text-detail text-ink-faint">Requested</span>
142
+ ) : state === 'ask' ? (
143
+ <Button
144
+ variant="outline"
145
+ size="tiny"
146
+ disabled={busy !== null}
147
+ onClick={() => void request(item)}
148
+ >
149
+ {busy?.id === item.id ? 'Requesting…' : 'Request write access'}
150
+ </Button>
151
+ ) : (
152
+ <Button
153
+ variant="outline"
154
+ size="tiny"
155
+ disabled={busy !== null}
156
+ onClick={() => void link(item)}
157
+ >
158
+ {/* A link is a commit and a push — a second or two. The
159
+ button says so, or a greyed "Link" reads as a page that
160
+ froze. Same word as the panel beside it: "Creating…";
161
+ the live region above says it for screen readers. */}
162
+ {busy?.id === item.id ? 'Linking…' : 'Link'}
163
+ </Button>
164
+ )}
165
+ </li>
166
+ );
167
+ })}
168
+ </ul>
169
+ </div>
170
+ );
171
+ }
@@ -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