@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
@@ -0,0 +1,120 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import {
3
+ filterLibraryItems,
4
+ isInPlugin,
5
+ isUngrouped,
6
+ pluginCounts,
7
+ pluginsOfItem,
8
+ withLinkHealth,
9
+ type AttentionStatus,
10
+ } from '../utils/status';
11
+ import { attentionOf, brokenLinksOf, type LibraryItem } from '../state/library-data';
12
+
13
+ /**
14
+ * Membership by LINK, alongside membership by folder. A shared skill under
15
+ * `Skills/` has no folder plugin, yet belongs to every plugin whose manifest
16
+ * links it — and the gallery, the sidebar counts and the plugin page all have
17
+ * to agree on that.
18
+ */
19
+
20
+ const OK: AttentionStatus = { state: 'ok', text: 'Ready' };
21
+
22
+ const shared = {
23
+ kind: 'skill' as const,
24
+ name: 'deploy',
25
+ description: 'Ship it.',
26
+ owned: false,
27
+ plugin: null,
28
+ shared: true,
29
+ plugins: [
30
+ { name: 'GTM', linked: true, granted: true },
31
+ { name: 'Ops', linked: true, granted: false },
32
+ ],
33
+ status: OK,
34
+ };
35
+ const inline = {
36
+ kind: 'skill' as const,
37
+ name: 'outreach',
38
+ description: '',
39
+ owned: true,
40
+ plugin: 'GTM',
41
+ plugins: [{ name: 'GTM', linked: false, granted: true }],
42
+ status: OK,
43
+ };
44
+ const personal = { kind: 'skill' as const, name: 'mine', description: '', owned: true, plugin: null, status: OK };
45
+
46
+ describe('membership by link', () => {
47
+ it('a linked skill belongs to the plugins that link it, and to no folder plugin', () => {
48
+ expect(isInPlugin(shared, 'GTM')).toBe(true);
49
+ expect(isInPlugin(shared, 'Ops')).toBe(true);
50
+ expect(isInPlugin(shared, 'Sales')).toBe(false);
51
+ expect(pluginsOfItem(shared).sort()).toEqual(['GTM', 'Ops']);
52
+ // Shared is not "yours alone" — only the personal skill is.
53
+ expect(isUngrouped(shared)).toBe(false);
54
+ expect(isUngrouped(personal)).toBe(true);
55
+ });
56
+
57
+ it('the plugin view and the sidebar counts follow links', () => {
58
+ const items = [shared, inline, personal];
59
+ expect(filterLibraryItems(items, { kind: 'group', plugin: 'GTM' }, '').map((i) => i.name)).toEqual([
60
+ 'deploy',
61
+ 'outreach',
62
+ ]);
63
+ expect(filterLibraryItems(items, { kind: 'ungrouped' }, '').map((i) => i.name)).toEqual(['mine']);
64
+ expect(pluginCounts(items)).toEqual([
65
+ { plugin: 'GTM', count: 2 },
66
+ { plugin: 'Ops', count: 1 },
67
+ ]);
68
+ });
69
+
70
+ it('a link whose grant is missing wears the amber note on THAT plugin\'s page only', () => {
71
+ // Granted on GTM: untouched.
72
+ expect(withLinkHealth(shared, 'GTM').status).toBe(OK);
73
+ // Not granted on Ops: needs setup, in ORANGE (it locks members out), and
74
+ // says whose job it is.
75
+ expect(withLinkHealth(shared, 'Ops').status).toMatchObject({ state: 'urgent', text: 'Needs setup' });
76
+ expect(withLinkHealth({ ...shared, owned: true }, 'Ops').status.text).toBe(
77
+ 'Needs setup: share with plugin members',
78
+ );
79
+ // Inline membership never wears it.
80
+ expect(withLinkHealth(inline, 'GTM').status).toBe(OK);
81
+ });
82
+
83
+ it('a broken link never erases a reason the card already shows', () => {
84
+ const needsTools = { ...shared, status: { state: 'warn' as const, text: 'Needs setup: 1 tool' } };
85
+ // Ops's link is broken too — but the card's own reason comes first.
86
+ expect(withLinkHealth(needsTools, 'Ops').status).toBe(needsTools.status);
87
+ });
88
+
89
+ it("a broken link counts in the plugin's attention, apart from its tools", () => {
90
+ const unsetTool = {
91
+ kind: 'integration' as const,
92
+ name: 'hubspot',
93
+ description: '',
94
+ owned: false,
95
+ plugin: 'Ops',
96
+ status: { state: 'warn' as const, text: 'Needs setup' },
97
+ };
98
+ const items = [shared, inline, personal, unsetTool] as unknown as LibraryItem[];
99
+ // Ops: one tool to set up, one linked skill its members cannot read.
100
+ expect(brokenLinksOf(items, 'Ops')).toBe(1);
101
+ expect(attentionOf(items, 'Ops')).toEqual({ total: 2, brokenLinks: 1 });
102
+ // GTM's link is granted: nothing to report.
103
+ expect(brokenLinksOf(items, 'GTM')).toBe(0);
104
+ expect(attentionOf(items, 'GTM')).toEqual({ total: 0, brokenLinks: 0 });
105
+ // An inline skill is never a broken link, whatever `granted` says.
106
+ const oddInline = { ...inline, plugins: [{ name: 'GTM', linked: false, granted: false }] };
107
+ expect(brokenLinksOf([oddInline] as unknown as LibraryItem[], 'GTM')).toBe(0);
108
+ });
109
+
110
+ it("the server's broken-link count wins over the caller's catalog", () => {
111
+ // The catalog cannot list a skill the caller may not read — which is the
112
+ // skill a missing grant is about — so the summary's count decides.
113
+ const items = [shared, inline] as unknown as LibraryItem[];
114
+ expect(brokenLinksOf(items, 'GTM', [{ name: 'GTM', brokenLinks: 2 }])).toBe(2);
115
+ expect(attentionOf(items, 'GTM', [{ name: 'GTM', brokenLinks: 2 }])).toEqual({ total: 2, brokenLinks: 2 });
116
+ // An older server sends no count: the catalog is the fallback.
117
+ expect(brokenLinksOf(items, 'Ops', [{ name: 'Ops' }])).toBe(1);
118
+ expect(brokenLinksOf(items, 'Ops', [])).toBe(1);
119
+ });
120
+ });
@@ -0,0 +1,32 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { pluginLabel, pluginNameForPath } from '../utils/plugin-summary';
3
+
4
+ const summaries = [
5
+ { name: 'gtm', displayName: 'Go To Market', folders: ['Plugins/GTM'] },
6
+ { name: 'deep', displayName: 'Deep', folders: ['Plugins/GTM/teams/Deep'] },
7
+ ];
8
+
9
+ describe('pluginNameForPath', () => {
10
+ it('names the plugin by the catalog folder holding the path — the deepest one', () => {
11
+ expect(pluginNameForPath('Plugins/GTM/skills/outreach', summaries)).toBe('gtm');
12
+ expect(pluginNameForPath('Plugins/GTM/teams/Deep/skills/x', summaries)).toBe('deep');
13
+ });
14
+
15
+ it('asks the catalog FIRST: a listed folder names the plugin whatever the folder is called', () => {
16
+ const listed = [{ name: 'shelf', displayName: 'Shelf', folders: ['Plugins/personal-u1'] }];
17
+ expect(pluginNameForPath('Plugins/personal-u1/skills/notes', listed)).toBe('shelf');
18
+ });
19
+
20
+ it('falls back to the folder for an unlisted path, and to null for a personal shelf', () => {
21
+ expect(pluginNameForPath('Plugins/Legacy/skills/x', summaries)).toBe('Legacy');
22
+ expect(pluginNameForPath('Plugins/personal-u1/skills/notes', summaries)).toBeNull();
23
+ expect(pluginNameForPath('Skills/Eng/deploy', summaries)).toBeNull();
24
+ });
25
+ });
26
+
27
+ describe('pluginLabel', () => {
28
+ it('is the display name, else the identity', () => {
29
+ expect(pluginLabel('gtm', summaries)).toBe('Go To Market');
30
+ expect(pluginLabel('unknown', summaries)).toBe('unknown');
31
+ });
32
+ });
@@ -24,6 +24,90 @@ function tool(overrides: Partial<ToolSecrets>): ToolSecrets {
24
24
  };
25
25
  }
26
26
 
27
+ /**
28
+ * The distinction this whole feature exists for: a STORED credential and a
29
+ * WORKING one are different claims, and the badge must not make the second on
30
+ * the evidence of the first.
31
+ */
32
+ describe('toolStatus: stored vs working', () => {
33
+ const withKey = () =>
34
+ tool({
35
+ variables: [
36
+ { name: 'API_KEY', scope: 'user', label: null, key: 'slack_API_KEY', adminConfigured: false, userConfigured: true },
37
+ ],
38
+ });
39
+
40
+ it('says Key saved — not Connected — when a key is stored but never tested', () => {
41
+ // No verdict at all is the DEFAULT everywhere but the tool page: nothing is
42
+ // stored, so a list built from saved values can never earn "Connected".
43
+ const s = toolStatus(withKey());
44
+ expect(s.state).toBe('ok');
45
+ expect(s.text).toBe('Key saved');
46
+ // Green, because nothing needs a person; but the word claims only what is known.
47
+ expect(s.hint).toMatch(/not verified/i);
48
+ });
49
+
50
+ it('says Key saved when the probe could not reach a verdict', () => {
51
+ const s = toolStatus(withKey(), { status: 'unverifiable', detail: 'Provider timed out.', checkedAt: new Date().toISOString() });
52
+ expect(s.state).toBe('ok');
53
+ expect(s.text).toBe('Key saved');
54
+ expect(s.hint).toBe('Provider timed out.');
55
+ });
56
+
57
+ it('earns Connected only from a passing probe, and shows when it was checked', () => {
58
+ const s = toolStatus(withKey(), { status: 'ok', detail: null, checkedAt: new Date().toISOString() });
59
+ expect(s.state).toBe('ok');
60
+ expect(s.text).toBe('Connected');
61
+ expect(s.hint).toMatch(/^Checked /);
62
+ });
63
+
64
+ it('goes red with the provider\'s own words when the credential is rejected', () => {
65
+ const s = toolStatus(withKey(), { status: 'failed', detail: 'Invalid API key.', checkedAt: new Date().toISOString() });
66
+ expect(s.state).toBe('err');
67
+ expect(s.text).toBe('Not working');
68
+ expect(s.hint).toBe('Invalid API key.');
69
+ });
70
+
71
+ it('says Signed in rather than Key saved when the tool is oauth-backed', () => {
72
+ const s = toolStatus(
73
+ tool({
74
+ variables: [
75
+ { name: 'SIGNIN', scope: 'user', label: null, key: 'slack_SIGNIN', adminConfigured: true, userConfigured: true, oauth: true, authorized: true },
76
+ ],
77
+ }),
78
+ );
79
+ expect(s.text).toBe('Signed in');
80
+ });
81
+
82
+ /**
83
+ * Setup outranks the verdict. A `failed` from before the key was entered must
84
+ * never displace the thing actually in the way — "Needs a key from you" is the
85
+ * sentence the reader can act on.
86
+ */
87
+ it('names the missing key rather than a stale failure', () => {
88
+ const s = toolStatus(
89
+ tool({
90
+ variables: [
91
+ { name: 'API_KEY', scope: 'user', label: null, key: 'slack_API_KEY', adminConfigured: false, userConfigured: false },
92
+ ],
93
+ }),
94
+ { status: 'failed', detail: 'Invalid API key.', checkedAt: new Date().toISOString() },
95
+ );
96
+ expect(s.state).toBe('warn');
97
+ expect(s.text).toBe('Needs a key from you');
98
+ });
99
+
100
+ it('says No key needed for a tool that asks for nothing', () => {
101
+ // "Key saved" would name a key the user was never asked for.
102
+ expect(toolStatus(tool({ variables: [] })).text).toBe('No key needed');
103
+ });
104
+
105
+ /** An unverified tool blocks nothing: it needs no person, so a skill is Ready. */
106
+ it('leaves a skill Ready when its tools are merely unverified', () => {
107
+ expect(skillStatus([withKey()]).state).toBe('ok');
108
+ });
109
+ });
110
+
27
111
  describe('toolStatus', () => {
28
112
  it('is ok when every variable is satisfied', () => {
29
113
  const t = tool({
@@ -0,0 +1,46 @@
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import { renderHook, waitFor } from '@testing-library/react';
3
+ import type { ReactNode } from 'react';
4
+ import type { JoinRequest } from '../services/plugins.api';
5
+ import { LibraryToastProvider } from '../state/toast';
6
+ import { useJoinRequests, type JoinRequestsApi } from '../hooks/useJoinRequests';
7
+
8
+ /**
9
+ * Requests belong to the plugin they were fetched for. A page that moves
10
+ * from one skill to the next without unmounting must show nothing of the
11
+ * previous one while the next one's answer is on its way: a banner still
12
+ * listing A's requests over B's folder would grant A's proposal to B.
13
+ */
14
+ const request = (number: number): JoinRequest => ({
15
+ number,
16
+ branch: `ali/join-${number}`,
17
+ requesterName: 'Ali',
18
+ createdAt: '2026-01-01T00:00:00.000Z',
19
+ proposals: [],
20
+ });
21
+
22
+ const wrapper = ({ children }: { children: ReactNode }) => <LibraryToastProvider>{children}</LibraryToastProvider>;
23
+
24
+ describe('useJoinRequests', () => {
25
+ it('shows only the requests of the plugin it is asked about, never a previous one\'s', async () => {
26
+ let releaseB: (rows: JoinRequest[]) => void = () => {};
27
+ const api: JoinRequestsApi = {
28
+ list: vi.fn((name: string) =>
29
+ name === 'A' ? Promise.resolve([request(1)]) : new Promise<JoinRequest[]>((resolve) => (releaseB = resolve)),
30
+ ),
31
+ reconcile: vi.fn().mockResolvedValue(false),
32
+ };
33
+ const { result, rerender } = renderHook(({ plugin }) => useJoinRequests(plugin, `Skills/${plugin}`, api), {
34
+ wrapper,
35
+ initialProps: { plugin: 'A' },
36
+ });
37
+ await waitFor(() => expect(result.current.requests.map((r) => r.number)).toEqual([1]));
38
+
39
+ rerender({ plugin: 'B' });
40
+ // B's answer has not arrived: nothing, not A's rows.
41
+ expect(result.current.requests).toEqual([]);
42
+
43
+ releaseB([request(2)]);
44
+ await waitFor(() => expect(result.current.requests.map((r) => r.number)).toEqual([2]));
45
+ });
46
+ });
@@ -1,6 +1,8 @@
1
1
  import { Button, Dialog, Surface } from '../../../shared/components';
2
2
  import { useAdmin } from '../../admin/state/admin.context';
3
3
  import { NewSkillPanel } from './NewSkillPanel';
4
+ import { LinkSkillPanel } from './LinkSkillPanel';
5
+ import type { LibraryItem } from '../state/library-data';
4
6
  import { useLibraryToast } from '../state/toast.context';
5
7
  import { COPIED_TOAST, COPY_FAILED_TOAST, copyToClipboard } from '../utils/clipboard';
6
8
 
@@ -18,6 +20,13 @@ export interface AddToPluginDialogProps {
18
20
  canWrite: boolean | null;
19
21
  /** Every skill name already in the catalog. The admin create half rejects collisions. */
20
22
  existingSkills: string[];
23
+ /**
24
+ * The caller's catalog, for the "link an existing skill" half. Optional
25
+ * together with `onLinked`: a caller without them gets the dialog as it was
26
+ * before linking existed.
27
+ */
28
+ linkable?: LibraryItem[];
29
+ onLinked?(): void;
21
30
  onClose(): void;
22
31
  }
23
32
 
@@ -43,6 +52,8 @@ export function AddToPluginDialog({
43
52
  primaryPath,
44
53
  canWrite,
45
54
  existingSkills,
55
+ linkable,
56
+ onLinked,
46
57
  onClose,
47
58
  }: AddToPluginDialogProps) {
48
59
  const { isAdmin } = useAdmin();
@@ -85,6 +96,28 @@ export function AddToPluginDialog({
85
96
  : `Use the prompt below to have your agent draft the skill and send it to ${name} as a change request for an owner to review.`}
86
97
  </p>
87
98
 
99
+ {/* Linking is the MANAGER's half: it edits this plugin's manifest, and the
100
+ server refuses anyone else. A non-manager only gets the prompt below. */}
101
+ {canWrite && linkable && onLinked && (
102
+ <>
103
+ <div className="mt-3">
104
+ <LinkSkillPanel
105
+ plugin={name}
106
+ items={linkable}
107
+ onLinked={() => {
108
+ onLinked();
109
+ onClose();
110
+ }}
111
+ />
112
+ </div>
113
+ <div className="my-3.5 flex items-center gap-3">
114
+ <span aria-hidden="true" className="h-px flex-1 bg-line" />
115
+ <span className="text-meta text-ink-faint">or</span>
116
+ <span aria-hidden="true" className="h-px flex-1 bg-line" />
117
+ </div>
118
+ </>
119
+ )}
120
+
88
121
  {isAdmin && (
89
122
  <>
90
123
  <NewSkillPanel
@@ -42,6 +42,13 @@ export interface LibraryCardCommonProps {
42
42
  * person who has to decide (being waited on).
43
43
  */
44
44
  pending?: { authorName: string; mine: boolean };
45
+ /**
46
+ * A skill's governance lifecycle (`metadata.lifecycle`). Only the two states
47
+ * that need a reader's attention are shown — `deprecated` (still works,
48
+ * find the replacement) and `retired` (kept for its owners, never
49
+ * distributed); `active` and absence render nothing.
50
+ */
51
+ lifecycle?: string;
45
52
  /** Open the item. The whole card is the target. */
46
53
  onOpen(): void;
47
54
  }
@@ -49,6 +56,7 @@ export interface LibraryCardCommonProps {
49
56
  const STATUS_INK: Record<GemState, string> = {
50
57
  ok: 'text-ok',
51
58
  warn: 'text-wait',
59
+ urgent: 'text-urgent',
52
60
  err: 'text-danger',
53
61
  };
54
62
 
@@ -75,6 +83,7 @@ export function LibraryCard({
75
83
  status,
76
84
  version,
77
85
  pending,
86
+ lifecycle,
78
87
  onOpen,
79
88
  flavor,
80
89
  }: LibraryCardProps) {
@@ -142,6 +151,11 @@ export function LibraryCard({
142
151
  Owner
143
152
  </Badge>
144
153
  )}
154
+ {(lifecycle === 'deprecated' || lifecycle === 'retired') && (
155
+ <Badge tone="wait" size="xs" className="shrink-0 uppercase">
156
+ {lifecycle === 'retired' ? 'Retired' : 'Deprecated'}
157
+ </Badge>
158
+ )}
145
159
  </span>
146
160
 
147
161
  {description && (
@@ -166,7 +180,13 @@ export function LibraryCard({
166
180
  </span>
167
181
  )}
168
182
  {footNote && (
169
- <span className={cn('flex items-center gap-1.5 font-semibold', STATUS_INK[footNote.state])}>
183
+ /* `title` carries the evidence behind the word — what the provider
184
+ said, or when it was last checked. A card has room for one word;
185
+ the sentence that justifies it belongs on hover. */
186
+ <span
187
+ className={cn('flex items-center gap-1.5 font-semibold', STATUS_INK[footNote.state])}
188
+ title={footNote.hint}
189
+ >
170
190
  <StatusDot state={footNote.state} />
171
191
  {footNote.text}
172
192
  </span>
@@ -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
+ }