@bevel-software/platform-core-frontend 0.7.5 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/LICENSE +202 -202
  2. package/THIRD-PARTY-NOTICES.md +344 -988
  3. package/package.json +5 -5
  4. package/src/core/CoreAppShell.tsx +4 -4
  5. package/src/core/__tests__/ShellRoutes.test.tsx +1 -1
  6. package/src/core/__tests__/bootstrap.test.ts +47 -2
  7. package/src/core/bootstrap.ts +20 -0
  8. package/src/core/registry.ts +16 -4
  9. package/src/css-side-effect-imports.d.ts +7 -7
  10. package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +1 -1
  11. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +5 -5
  12. package/src/modules/access/api.ts +5 -5
  13. package/src/modules/access/components/ManageAccessDialog.tsx +21 -20
  14. package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
  15. package/src/modules/admin/components/AdminRolesPage.tsx +1 -1
  16. package/src/modules/admin/state/admin.context.tsx +15 -0
  17. package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +2 -2
  18. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +1 -1
  19. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +1 -1
  20. package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +4 -4
  21. package/src/modules/layout/__tests__/SidebarToggle.test.tsx +4 -4
  22. package/src/modules/layout/__tests__/breakpoints.test.ts +1 -1
  23. package/src/modules/layout/components/SidebarFrame.tsx +2 -2
  24. package/src/modules/library/__tests__/{AddToGroupDialog.test.tsx → AddToPluginDialog.test.tsx} +34 -34
  25. package/src/modules/library/__tests__/LibraryCard.test.tsx +30 -11
  26. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +84 -59
  27. package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +51 -51
  28. package/src/modules/library/__tests__/{LockedGroupView.test.tsx → LockedPluginView.test.tsx} +33 -33
  29. package/src/modules/library/__tests__/McpServerSection.test.tsx +138 -0
  30. package/src/modules/library/__tests__/{NewGroupDialog.test.tsx → NewPluginDialog.test.tsx} +22 -22
  31. package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +7 -7
  32. package/src/modules/library/__tests__/PluginExtras.test.tsx +131 -0
  33. package/src/modules/library/__tests__/{GroupJoinRequests.test.tsx → PluginJoinRequests.test.tsx} +24 -24
  34. package/src/modules/library/__tests__/{GroupPage.test.tsx → PluginPage.test.tsx} +197 -106
  35. package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +363 -0
  36. package/src/modules/library/__tests__/{GroupsSidebar.contextmenu.test.tsx → PluginsSidebar.contextmenu.test.tsx} +32 -31
  37. package/src/modules/library/__tests__/{GroupsSidebar.locked.test.tsx → PluginsSidebar.locked.test.tsx} +29 -28
  38. package/src/modules/library/__tests__/PluginsSidebar.test.tsx +171 -0
  39. package/src/modules/library/__tests__/{GroupsSidebarMenu.test.tsx → PluginsSidebarMenu.test.tsx} +18 -18
  40. package/src/modules/library/__tests__/SkillPage.test.tsx +8 -8
  41. package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +2 -2
  42. package/src/modules/library/__tests__/ToolPage.test.tsx +41 -12
  43. package/src/modules/library/__tests__/ToolSharePanel.test.tsx +1 -1
  44. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +57 -57
  45. package/src/modules/library/__tests__/auth-harness.tsx +4 -4
  46. package/src/modules/library/__tests__/library-data.test.ts +82 -0
  47. package/src/modules/library/__tests__/status.test.ts +19 -19
  48. package/src/modules/library/__tests__/tools.api.test.ts +70 -0
  49. package/src/modules/library/__tests__/useToolPage.test.tsx +4 -4
  50. package/src/modules/library/components/AccessRequestsBanner.tsx +8 -8
  51. package/src/modules/library/components/{AddToGroupDialog.tsx → AddToPluginDialog.tsx} +11 -11
  52. package/src/modules/library/components/ChangeRequestDock.tsx +1 -1
  53. package/src/modules/library/components/{DeleteGroupDialog.tsx → DeletePluginDialog.tsx} +9 -9
  54. package/src/modules/library/components/LibraryCard.tsx +26 -2
  55. package/src/modules/library/components/LibraryLayout.tsx +80 -71
  56. package/src/modules/library/components/LibraryPage.tsx +8 -8
  57. package/src/modules/library/components/LockGlyph.tsx +1 -1
  58. package/src/modules/library/components/{LockedGroupView.tsx → LockedPluginView.tsx} +35 -35
  59. package/src/modules/library/components/{ManagedGroupRequests.tsx → ManagedPluginRequests.tsx} +13 -13
  60. package/src/modules/library/components/{NewGroupDialog.tsx → NewPluginDialog.tsx} +24 -24
  61. package/src/modules/library/components/NewSkillPanel.tsx +23 -5
  62. package/src/modules/library/components/PageActions.tsx +34 -11
  63. package/src/modules/library/components/PersonalAddDialog.tsx +5 -5
  64. package/src/modules/library/components/{PersonalGroupPage.tsx → PersonalPluginPage.tsx} +29 -19
  65. package/src/modules/library/components/PluginExtras.tsx +195 -0
  66. package/src/modules/library/components/{GroupIndexRow.tsx → PluginIndexRow.tsx} +6 -6
  67. package/src/modules/library/components/PluginJoinRequests.tsx +77 -0
  68. package/src/modules/library/components/{GroupPage.tsx → PluginPage.tsx} +112 -72
  69. package/src/modules/library/components/{GroupsIndexPage.tsx → PluginsIndexPage.tsx} +91 -48
  70. package/src/modules/library/components/{GroupsSidebar.tsx → PluginsSidebar.tsx} +105 -55
  71. package/src/modules/library/components/{GroupsSidebarMenu.tsx → PluginsSidebarMenu.tsx} +15 -15
  72. package/src/modules/library/components/{group-page-parts.tsx → plugin-page-parts.tsx} +218 -27
  73. package/src/modules/library/components/skill-page/SkillPage.tsx +12 -12
  74. package/src/modules/library/components/tool-page/McpServerSection.tsx +380 -0
  75. package/src/modules/library/components/tool-page/ToolPage.tsx +22 -5
  76. package/src/modules/library/hooks/useJoinRequests.ts +8 -8
  77. package/src/modules/library/routes/LibraryRoutes.tsx +32 -19
  78. package/src/modules/library/routes/WorkspaceItemRoute.tsx +24 -24
  79. package/src/modules/library/routes/library-paths.ts +36 -36
  80. package/src/modules/library/services/library.api.ts +9 -9
  81. package/src/modules/library/services/{groups.api.ts → plugins.api.ts} +43 -43
  82. package/src/modules/library/services/tools.api.ts +54 -0
  83. package/src/modules/library/state/library-data.tsx +67 -46
  84. package/src/modules/library/utils/names.ts +1 -1
  85. package/src/modules/library/utils/{personal-group.ts → personal-plugin.ts} +8 -8
  86. package/src/modules/library/utils/{group-summary.ts → plugin-summary.ts} +14 -14
  87. package/src/modules/library/utils/status.ts +17 -17
  88. package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +318 -0
  89. package/src/modules/onboarding/__tests__/onboarding.test.tsx +86 -8
  90. package/src/modules/onboarding/agent-clients.ts +18 -14
  91. package/src/modules/onboarding/components/CreatorWelcomePage.tsx +143 -0
  92. package/src/modules/onboarding/components/WelcomePage.tsx +30 -22
  93. package/src/modules/onboarding/components/WelcomeRoute.tsx +57 -0
  94. package/src/modules/onboarding/welcome-state.ts +36 -0
  95. package/src/modules/review/components/MarkdownDiffViewer.tsx +1 -1
  96. package/src/modules/review/components/ReviewPanel.tsx +11 -11
  97. package/src/modules/review/components/__tests__/{isGroupItemPath.test.ts → isPluginItemPath.test.ts} +24 -24
  98. package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +3 -3
  99. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +1 -1
  100. package/src/modules/settings/components/SettingsLayout.tsx +1 -1
  101. package/src/modules/settings/components/SettingsNav.tsx +5 -5
  102. package/src/modules/setup/__tests__/setup.test.tsx +203 -0
  103. package/src/modules/setup/components/SetupScreen.tsx +235 -68
  104. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +29 -107
  105. package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +1 -1
  106. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +228 -0
  107. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +3 -3
  108. package/src/modules/workspace/components/FileExplorer.tsx +12 -12
  109. package/src/modules/workspace/components/FileRoute.tsx +8 -1
  110. package/src/modules/workspace/components/FileViewer.tsx +95 -38
  111. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +14 -14
  112. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +20 -0
  113. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +227 -18
  114. package/src/modules/workspace/components/renderers/ToolRenderer.tsx +7 -2
  115. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +25 -0
  116. package/src/modules/workspace/routing/kb-routes.ts +23 -1
  117. package/src/modules/workspace/utils/__tests__/diff.test.ts +1 -1
  118. package/src/modules/workspace/utils/fileTree.ts +54 -3
  119. package/src/shared/components/Surface.tsx +15 -0
  120. package/src/shared/mcp/ClaudeInstallLink.tsx +88 -0
  121. package/src/shared/mcp/ConnectionInstructions.tsx +51 -0
  122. package/src/shared/mcp/CopyBlock.tsx +42 -0
  123. package/src/shared/mcp/__tests__/ClaudeInstallLink.test.tsx +40 -0
  124. package/src/shared/mcp/__tests__/connect-snippets.test.ts +431 -0
  125. package/src/shared/mcp/__tests__/useCopyFeedback.test.ts +112 -0
  126. package/src/shared/mcp/connect-snippets.ts +353 -0
  127. package/src/shared/mcp/index.ts +28 -0
  128. package/src/shared/mcp/useCopyFeedback.ts +46 -0
  129. package/src/test-setup.ts +11 -0
  130. package/src/modules/library/__tests__/GroupsIndexPage.test.tsx +0 -283
  131. package/src/modules/library/__tests__/GroupsSidebar.test.tsx +0 -142
  132. package/src/modules/library/components/GroupJoinRequests.tsx +0 -56
@@ -1,33 +1,33 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
2
  import { render, screen, fireEvent, waitFor } from '@testing-library/react';
3
3
  import { MemoryRouter } from 'react-router-dom';
4
- import type { GroupSummary } from '../services/groups.api';
4
+ import type { PluginSummary } from '../services/plugins.api';
5
5
 
6
6
  /**
7
- * The locked group page: what it is allowed to say, and what asking to join
7
+ * The locked plugin page: what it is allowed to say, and what asking to join
8
8
  * does.
9
9
  *
10
10
  * Copy is asserted verbatim throughout because it IS the feature — a locked
11
- * group's whole surface is four sentences, and every one of them was chosen to
12
- * describe the group without describing its contents.
11
+ * plugin's whole surface is four sentences, and every one of them was chosen to
12
+ * describe the plugin without describing its contents.
13
13
  */
14
14
 
15
15
  const apiMock = vi.hoisted(() => ({
16
- requestGroupAccess: vi.fn(),
16
+ requestPluginAccess: vi.fn(),
17
17
  AlreadyReadableError: class AlreadyReadableError extends Error {},
18
18
  }));
19
- vi.mock('../services/groups.api', () => ({
20
- requestGroupAccess: apiMock.requestGroupAccess,
19
+ vi.mock('../services/plugins.api', () => ({
20
+ requestPluginAccess: apiMock.requestPluginAccess,
21
21
  AlreadyReadableError: apiMock.AlreadyReadableError,
22
22
  }));
23
23
 
24
24
  import { LibraryToastProvider } from '../state/toast';
25
- import { LockedGroupView } from '../components/LockedGroupView';
25
+ import { LockedPluginView } from '../components/LockedPluginView';
26
26
  import { joinNames, firstNames } from '../utils/names';
27
27
 
28
- const finance = (over: Partial<GroupSummary> = {}): GroupSummary => ({
28
+ const finance = (over: Partial<PluginSummary> = {}): PluginSummary => ({
29
29
  name: 'Finance',
30
- folders: ['Groups/Finance'],
30
+ folders: ['Plugins/Finance'],
31
31
  canRead: false,
32
32
  canWrite: false,
33
33
  isOwner: false,
@@ -41,15 +41,15 @@ const finance = (over: Partial<GroupSummary> = {}): GroupSummary => ({
41
41
  ...over,
42
42
  });
43
43
 
44
- function renderLocked(group: GroupSummary = finance()) {
44
+ function renderLocked(plugin: PluginSummary = finance()) {
45
45
  const onRequested = vi.fn();
46
46
  const onUnlocked = vi.fn();
47
47
  const onManage = vi.fn();
48
48
  const view = render(
49
49
  <MemoryRouter>
50
50
  <LibraryToastProvider>
51
- <LockedGroupView
52
- group={group}
51
+ <LockedPluginView
52
+ plugin={plugin}
53
53
  onRequested={onRequested}
54
54
  onUnlocked={onUnlocked}
55
55
  onManage={onManage}
@@ -62,19 +62,19 @@ function renderLocked(group: GroupSummary = finance()) {
62
62
 
63
63
  const askButton = () => screen.getByRole('button', { name: 'Subscribe to its skills and tools' });
64
64
 
65
- describe('LockedGroupView', () => {
65
+ describe('LockedPluginView', () => {
66
66
  beforeEach(() => {
67
- apiMock.requestGroupAccess.mockReset();
68
- apiMock.requestGroupAccess.mockResolvedValue(undefined);
67
+ apiMock.requestPluginAccess.mockReset();
68
+ apiMock.requestPluginAccess.mockResolvedValue(undefined);
69
69
  });
70
70
 
71
- it('states the group, who runs it, and how much is in it. And nothing else', () => {
71
+ it('states the plugin, who runs it, and how much is in it. And nothing else', () => {
72
72
  renderLocked();
73
73
  expect(screen.getByRole('heading', { name: 'Finance', level: 1 })).toBeInTheDocument();
74
74
  expect(screen.getByText('Locked')).toBeInTheDocument();
75
75
  expect(screen.getByText('Run by Olga Ivanova.')).toBeInTheDocument();
76
- expect(screen.getByText('2 skills · 1 tool. Visible to members only.')).toBeInTheDocument();
77
- expect(screen.getByRole('link', { name: 'All groups' })).toHaveAttribute(
76
+ expect(screen.getByText('2 skills · 1 tool. Visible once you have access.')).toBeInTheDocument();
77
+ expect(screen.getByRole('link', { name: 'All plugins' })).toHaveAttribute(
78
78
  'href',
79
79
  '/skills-and-tools',
80
80
  );
@@ -91,12 +91,12 @@ describe('LockedGroupView', () => {
91
91
 
92
92
  it('pluralises the counts line honestly', () => {
93
93
  renderLocked(finance({ skillCount: 1, toolCount: 0 }));
94
- expect(screen.getByText('1 skill · 0 tools. Visible to members only.')).toBeInTheDocument();
94
+ expect(screen.getByText('1 skill · 0 tools. Visible once you have access.')).toBeInTheDocument();
95
95
  });
96
96
 
97
97
  it('asks once, disables while in flight, and flips to the Requested box', async () => {
98
98
  let release = () => {};
99
- apiMock.requestGroupAccess.mockReturnValue(
99
+ apiMock.requestPluginAccess.mockReturnValue(
100
100
  new Promise<void>((resolve) => {
101
101
  release = () => resolve();
102
102
  }),
@@ -106,12 +106,12 @@ describe('LockedGroupView', () => {
106
106
  fireEvent.click(askButton());
107
107
  expect(askButton()).toBeDisabled();
108
108
  fireEvent.click(askButton());
109
- expect(apiMock.requestGroupAccess).toHaveBeenCalledTimes(1);
110
- expect(apiMock.requestGroupAccess).toHaveBeenCalledWith('Finance');
109
+ expect(apiMock.requestPluginAccess).toHaveBeenCalledTimes(1);
110
+ expect(apiMock.requestPluginAccess).toHaveBeenCalledWith('Finance');
111
111
 
112
112
  release();
113
113
  expect(
114
- await screen.findByText('Requested: Olga Ivanova decides who joins.'),
114
+ await screen.findByText('Requested: Olga Ivanova decides who gets access.'),
115
115
  ).toBeInTheDocument();
116
116
  expect(
117
117
  screen.queryByRole('button', { name: 'Subscribe to its skills and tools' }),
@@ -123,13 +123,13 @@ describe('LockedGroupView', () => {
123
123
  renderLocked();
124
124
  fireEvent.click(askButton());
125
125
  expect(
126
- await screen.findByText('Asked Olga. You get its skills and tools if they let you in.'),
126
+ await screen.findByText('Asked Olga. You get its skills and tools once they grant access.'),
127
127
  ).toBeInTheDocument();
128
128
  });
129
129
 
130
130
  it('shows the Requested box with no button when the server already has one', () => {
131
131
  renderLocked(finance({ hasRequested: true }));
132
- expect(screen.getByText('Requested: Olga Ivanova decides who joins.')).toBeInTheDocument();
132
+ expect(screen.getByText('Requested: Olga Ivanova decides who gets access.')).toBeInTheDocument();
133
133
  expect(
134
134
  screen.queryByRole('button', { name: 'Subscribe to its skills and tools' }),
135
135
  ).not.toBeInTheDocument();
@@ -141,11 +141,11 @@ describe('LockedGroupView', () => {
141
141
  fireEvent.click(askButton());
142
142
  expect(
143
143
  await screen.findByText(
144
- 'Asked the admins. You get its skills and tools if they let you in.',
144
+ 'Asked the admins. You get its skills and tools once they grant access.',
145
145
  ),
146
146
  ).toBeInTheDocument();
147
147
  expect(
148
- screen.getByText('Requested: the workspace admins decide who joins.'),
148
+ screen.getByText('Requested: the workspace admins decide who gets access.'),
149
149
  ).toBeInTheDocument();
150
150
  });
151
151
 
@@ -159,8 +159,8 @@ describe('LockedGroupView', () => {
159
159
  expect(screen.getByText('Run by Juan Viera, Admin.')).toBeInTheDocument();
160
160
  });
161
161
 
162
- it('opens the group rather than complaining when access already landed', async () => {
163
- apiMock.requestGroupAccess.mockRejectedValue(new apiMock.AlreadyReadableError());
162
+ it('opens the plugin rather than complaining when access already landed', async () => {
163
+ apiMock.requestPluginAccess.mockRejectedValue(new apiMock.AlreadyReadableError());
164
164
  const { onUnlocked, onRequested } = renderLocked();
165
165
  fireEvent.click(askButton());
166
166
  await waitFor(() => expect(onUnlocked).toHaveBeenCalledTimes(1));
@@ -169,7 +169,7 @@ describe('LockedGroupView', () => {
169
169
  });
170
170
 
171
171
  it('re-enables the button and says so when the request fails', async () => {
172
- apiMock.requestGroupAccess.mockRejectedValue(new Error('boom'));
172
+ apiMock.requestPluginAccess.mockRejectedValue(new Error('boom'));
173
173
  const { onRequested } = renderLocked();
174
174
  fireEvent.click(askButton());
175
175
  expect(await screen.findByText("Couldn't send that: try again.")).toBeInTheDocument();
@@ -178,9 +178,9 @@ describe('LockedGroupView', () => {
178
178
  });
179
179
 
180
180
  it('gives a locked-out admin the self-service way in', () => {
181
- const { onManage } = renderLocked(finance({ canWrite: true, folders: ['Groups/Finance'] }));
181
+ const { onManage } = renderLocked(finance({ canWrite: true, folders: ['Plugins/Finance'] }));
182
182
  fireEvent.click(screen.getByRole('button', { name: 'Manage access' }));
183
- expect(onManage).toHaveBeenCalledWith('Groups/Finance');
183
+ expect(onManage).toHaveBeenCalledWith('Plugins/Finance');
184
184
  });
185
185
 
186
186
  it('offers no Manage access to somebody who cannot write the folder', () => {
@@ -0,0 +1,138 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { render, screen, fireEvent, waitFor } from '@testing-library/react';
3
+ import { MemoryRouter } from 'react-router-dom';
4
+ import type { McpServerView } from '../services/tools.api';
5
+
6
+ /**
7
+ * The server-scoped editor. What is worth pinning: the section renders nothing
8
+ * for a `.tool`-backed manual (GET 404 → null), non-writers get facts and no
9
+ * button, and a RENAME with configured secrets is interrupted by a dialog that
10
+ * names the count — the save must not fire until "Rename anyway".
11
+ */
12
+
13
+ const apiMock = vi.hoisted(() => ({
14
+ getMcpServer: vi.fn<() => Promise<McpServerView | null>>(),
15
+ putMcpServer: vi.fn(),
16
+ }));
17
+ vi.mock('../services/tools.api', async (importOriginal) => ({
18
+ ...(await importOriginal<typeof import('../services/tools.api')>()),
19
+ getMcpServer: apiMock.getMcpServer,
20
+ putMcpServer: apiMock.putMcpServer,
21
+ }));
22
+
23
+ import { McpServerSection } from '../components/tool-page/McpServerSection';
24
+
25
+ const VIEW: McpServerView = {
26
+ name: 'vendor',
27
+ transport: 'streamable-http',
28
+ url: 'https://v.example/mcp',
29
+ literalHeaders: { 'X-V': '2' },
30
+ authHeaders: { Authorization: 'Bearer ${VENDOR_KEY}' },
31
+ variables: [{ name: 'VENDOR_KEY', scope: 'user' }],
32
+ local: false,
33
+ canWrite: true,
34
+ };
35
+
36
+ function renderSection(configuredCount = 2) {
37
+ const onSaved = vi.fn();
38
+ const onError = vi.fn();
39
+ render(
40
+ <MemoryRouter>
41
+ <McpServerSection slug="vendor" configuredCount={configuredCount} onSaved={onSaved} onError={onError} />
42
+ </MemoryRouter>,
43
+ );
44
+ return { onSaved, onError };
45
+ }
46
+
47
+ beforeEach(() => {
48
+ apiMock.getMcpServer.mockReset();
49
+ apiMock.putMcpServer.mockReset();
50
+ apiMock.putMcpServer.mockResolvedValue({ name: 'vendor' });
51
+ });
52
+
53
+ describe('McpServerSection', () => {
54
+ it('renders nothing for a .tool-backed manual', async () => {
55
+ apiMock.getMcpServer.mockResolvedValue(null);
56
+ renderSection();
57
+ await waitFor(() => expect(apiMock.getMcpServer).toHaveBeenCalled());
58
+ expect(screen.queryByText('Server')).not.toBeInTheDocument();
59
+ });
60
+
61
+ it('shows the facts, and the edit button only to writers', async () => {
62
+ apiMock.getMcpServer.mockResolvedValue({ ...VIEW, canWrite: false });
63
+ renderSection();
64
+ expect(await screen.findByText('https://v.example/mcp')).toBeInTheDocument();
65
+ expect(screen.queryByRole('button', { name: 'Edit server' })).not.toBeInTheDocument();
66
+ });
67
+
68
+ it('saves without ceremony when the name is unchanged', async () => {
69
+ apiMock.getMcpServer.mockResolvedValue(VIEW);
70
+ const { onSaved } = renderSection();
71
+ fireEvent.click(await screen.findByRole('button', { name: 'Edit server' }));
72
+ fireEvent.click(screen.getByRole('button', { name: 'Save' }));
73
+ await waitFor(() => expect(apiMock.putMcpServer).toHaveBeenCalledTimes(1));
74
+ // No newName in the payload — an unchanged name is not a rename.
75
+ expect(apiMock.putMcpServer.mock.calls[0]![1]).not.toHaveProperty('newName');
76
+ await waitFor(() => expect(onSaved).toHaveBeenCalled());
77
+ });
78
+
79
+ it('confirms a rename even when this caller sees nothing configured', async () => {
80
+ // Other members' user-scoped values and sign-ins are invisible to this
81
+ // page, so a zero count proves nothing — the confirm must still gate.
82
+ apiMock.getMcpServer.mockResolvedValue(VIEW);
83
+ renderSection(0);
84
+ fireEvent.click(await screen.findByRole('button', { name: 'Edit server' }));
85
+ fireEvent.change(screen.getByRole('textbox', { name: /Name/ }), {
86
+ target: { value: 'vendor_eu' },
87
+ });
88
+ fireEvent.click(screen.getByRole('button', { name: 'Save' }));
89
+ expect(apiMock.putMcpServer).not.toHaveBeenCalled();
90
+ expect(await screen.findByText(/other members' values, which this page cannot see/)).toBeInTheDocument();
91
+ });
92
+
93
+ it('round-trips cwd/env on a stdio save — the form has no fields for them', async () => {
94
+ // The PUT rebuilds the entry from the payload, so omitting `cwd`/`env`
95
+ // would erase values a hand-edited mcp.json carries.
96
+ apiMock.getMcpServer.mockResolvedValue({
97
+ name: 'vendor',
98
+ transport: 'stdio',
99
+ command: 'npx',
100
+ args: ['-y', 'vendor'],
101
+ cwd: './srv',
102
+ env: { VENDOR_MODE: 'ci' },
103
+ literalHeaders: {},
104
+ authHeaders: {},
105
+ variables: [],
106
+ local: true,
107
+ canWrite: true,
108
+ });
109
+ renderSection();
110
+ fireEvent.click(await screen.findByRole('button', { name: 'Edit server' }));
111
+ fireEvent.click(screen.getByRole('button', { name: 'Save' }));
112
+ await waitFor(() => expect(apiMock.putMcpServer).toHaveBeenCalledTimes(1));
113
+ expect(apiMock.putMcpServer.mock.calls[0]![1]).toMatchObject({
114
+ command: 'npx',
115
+ args: ['-y', 'vendor'],
116
+ cwd: './srv',
117
+ env: { VENDOR_MODE: 'ci' },
118
+ });
119
+ });
120
+
121
+ it('interrupts a rename with the disconnect count, and saves only on "Rename anyway"', async () => {
122
+ apiMock.getMcpServer.mockResolvedValue(VIEW);
123
+ renderSection(2);
124
+ fireEvent.click(await screen.findByRole('button', { name: 'Edit server' }));
125
+ fireEvent.change(screen.getByRole('textbox', { name: /Name/ }), {
126
+ target: { value: 'vendor_eu' },
127
+ });
128
+ fireEvent.click(screen.getByRole('button', { name: 'Save' }));
129
+
130
+ // The save did NOT fire — the dialog is the gate, and it says the cost.
131
+ expect(apiMock.putMcpServer).not.toHaveBeenCalled();
132
+ expect(await screen.findByText(/at least 2 are configured from your view alone/)).toBeInTheDocument();
133
+
134
+ fireEvent.click(screen.getByRole('button', { name: 'Rename anyway' }));
135
+ await waitFor(() => expect(apiMock.putMcpServer).toHaveBeenCalledTimes(1));
136
+ expect(apiMock.putMcpServer.mock.calls[0]![1]).toMatchObject({ newName: 'vendor_eu' });
137
+ });
138
+ });
@@ -3,22 +3,22 @@ import { render, screen, fireEvent, waitFor } from '@testing-library/react';
3
3
  import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom';
4
4
 
5
5
  /**
6
- * Making a group.
6
+ * Making a plugin.
7
7
  *
8
- * A group comes from the dedicated provisioning endpoint — the server owns
8
+ * A plugin comes from the dedicated provisioning endpoint — the server owns
9
9
  * the folder, the seeded access.md and the commit. What is worth testing here
10
10
  * is the two refusals the dialog can reach before the call — a name that
11
- * collides with a group you cannot even see, and a name that would create a
11
+ * collides with a plugin you cannot even see, and a name that would create a
12
12
  * nested folder — plus the fact that the caller lands somewhere real
13
13
  * afterwards, and that the server's own refusal is what the toast shows.
14
14
  */
15
15
 
16
- const groupsMock = vi.hoisted(() => ({ createGroup: vi.fn() }));
17
- vi.mock('../services/groups.api', () => ({
18
- createGroup: groupsMock.createGroup,
16
+ const pluginsMock = vi.hoisted(() => ({ createPlugin: vi.fn() }));
17
+ vi.mock('../services/plugins.api', () => ({
18
+ createPlugin: pluginsMock.createPlugin,
19
19
  }));
20
20
 
21
- import { NewGroupDialog } from '../components/NewGroupDialog';
21
+ import { NewPluginDialog } from '../components/NewPluginDialog';
22
22
  import { LibraryToastProvider } from '../state/toast';
23
23
 
24
24
  function LocationProbe() {
@@ -36,7 +36,7 @@ function renderDialog(existing: string[] = ['GTM', 'Finance']) {
36
36
  <Route
37
37
  path="*"
38
38
  element={
39
- <NewGroupDialog existing={existing} onClose={onClose} onCreated={onCreated} />
39
+ <NewPluginDialog existing={existing} onClose={onClose} onCreated={onCreated} />
40
40
  }
41
41
  />
42
42
  </Routes>
@@ -47,42 +47,42 @@ function renderDialog(existing: string[] = ['GTM', 'Finance']) {
47
47
  return {
48
48
  onCreated,
49
49
  onClose,
50
- field: () => screen.getByRole('textbox', { name: 'Group name' }),
51
- submit: () => screen.getByRole('button', { name: /Create group|Creating/ }),
50
+ field: () => screen.getByRole('textbox', { name: 'Plugin name' }),
51
+ submit: () => screen.getByRole('button', { name: /Create plugin|Creating/ }),
52
52
  pathname: () => screen.getByLabelText('pathname').textContent,
53
53
  };
54
54
  }
55
55
 
56
- describe('NewGroupDialog', () => {
56
+ describe('NewPluginDialog', () => {
57
57
  beforeEach(() => {
58
- groupsMock.createGroup.mockReset();
58
+ pluginsMock.createPlugin.mockReset();
59
59
  // A folder name that DIFFERS from the input, so a dialog that navigates
60
60
  // with the typed name instead of the server's answer fails here.
61
- groupsMock.createGroup.mockImplementation(async (name: string) => ({
61
+ pluginsMock.createPlugin.mockImplementation(async (name: string) => ({
62
62
  folder: `${name}-canonical`,
63
63
  }));
64
64
  });
65
65
 
66
- it('will not create an unnamed group', () => {
66
+ it('will not create an unnamed plugin', () => {
67
67
  const { submit } = renderDialog();
68
68
  expect(submit()).toBeDisabled();
69
69
  });
70
70
 
71
- it('creates the folder under Groups/ and opens the new group', async () => {
71
+ it('creates the folder under Plugins/ and opens the new plugin', async () => {
72
72
  const { field, submit, onCreated, pathname } = renderDialog();
73
73
  fireEvent.change(field(), { target: { value: ' Design ' } });
74
74
  fireEvent.click(submit());
75
75
 
76
76
  // Trimmed — the endpoint owns everything after the name.
77
- await waitFor(() => expect(groupsMock.createGroup).toHaveBeenCalledWith('Design'));
77
+ await waitFor(() => expect(pluginsMock.createPlugin).toHaveBeenCalledWith('Design'));
78
78
  // The route is built from the SERVER's folder, not the typed name.
79
- await waitFor(() => expect(pathname()).toBe('/skills-and-tools/groups/Design-canonical'));
79
+ await waitFor(() => expect(pathname()).toBe('/skills-and-tools/plugins/Design-canonical'));
80
80
  expect(onCreated).toHaveBeenCalledTimes(1);
81
81
  });
82
82
 
83
83
  it('refuses a name that is already taken, whoever can see it', () => {
84
- // `existing` carries LOCKED groups too. Creating `Groups/Finance` when a
85
- // Finance you cannot read exists would not make a group — it would put
84
+ // `existing` carries LOCKED plugins too. Creating `Plugins/Finance` when a
85
+ // Finance you cannot read exists would not make a plugin — it would put
86
86
  // your items in somebody else's.
87
87
  const { field, submit } = renderDialog(['GTM', 'Finance']);
88
88
  fireEvent.change(field(), { target: { value: 'finance' } });
@@ -91,7 +91,7 @@ describe('NewGroupDialog', () => {
91
91
  });
92
92
 
93
93
  it('refuses a name that would create a nested folder', () => {
94
- // `Groups/A/B` would be read back by `groupOfPath` as the group "A".
94
+ // `Plugins/A/B` would be read back by `pluginOfPath` as the plugin "A".
95
95
  const { field, submit } = renderDialog();
96
96
  fireEvent.change(field(), { target: { value: 'GTM/EMEA' } });
97
97
  expect(screen.getByRole('alert')).toHaveTextContent('/');
@@ -101,8 +101,8 @@ describe('NewGroupDialog', () => {
101
101
  it("shows the server's own refusal and stays open", async () => {
102
102
  // The server's check runs against the live tree (ours against a stale
103
103
  // catalog), so ITS words are the ones worth showing.
104
- groupsMock.createGroup.mockRejectedValue(
105
- new Error('Group names starting with "personal-" are reserved.'),
104
+ pluginsMock.createPlugin.mockRejectedValue(
105
+ new Error('Plugin names starting with "personal-" are reserved.'),
106
106
  );
107
107
  const { field, submit, onClose } = renderDialog();
108
108
  fireEvent.change(field(), { target: { value: 'personal-notes' } });
@@ -16,7 +16,7 @@ import { withAuth, TEST_PERSONAL_GROUP } from './auth-harness';
16
16
  * It carried one door until now — copy a prompt — because its first half used
17
17
  * to be a LINK into the destination folder and this page is defined as the
18
18
  * items in no folder. Writing needs no such destination: an ungrouped skill
19
- * lives in the caller's own `Groups/personal-<id>/` folder, so the door is back.
19
+ * lives in the caller's own `Plugins/personal-<id>/` folder, so the door is back.
20
20
  *
21
21
  * The load-bearing assertion is that it creates DIRECTLY. A skill you make
22
22
  * here is yours — the new folder's `access.md` is seeded naming you as owner
@@ -96,8 +96,8 @@ describe('PersonalAddDialog', () => {
96
96
  beforeEach(() => {
97
97
  apiMock.createEmptySkill.mockReset();
98
98
  apiMock.createEmptySkill.mockResolvedValue({
99
- repoRelativePath: 'Groups/scratch/SKILL.md',
100
- workspacePath: 'knowledge-base/Groups/scratch/SKILL.md',
99
+ repoRelativePath: 'Plugins/scratch/SKILL.md',
100
+ workspacePath: 'knowledge-base/Plugins/scratch/SKILL.md',
101
101
  branch: 'target-company-state',
102
102
  direct: true,
103
103
  });
@@ -115,7 +115,7 @@ describe('PersonalAddDialog', () => {
115
115
  const { field } = renderDialog();
116
116
  expect(field()).toBeInTheDocument();
117
117
  expect(screen.getByRole('button', { name: 'Copy prompt' })).toBeInTheDocument();
118
- expect(screen.getByText(/Yours alone until you add it to a group/)).toBeInTheDocument();
118
+ expect(screen.getByText(/Yours alone until you add it to a plugin/)).toBeInTheDocument();
119
119
  });
120
120
 
121
121
  it('creates the skill as PERSONAL. Destination resolution belongs to the api layer', async () => {
@@ -134,7 +134,7 @@ describe('PersonalAddDialog', () => {
134
134
  // The skill's own library page, editor invited open — not the Knowledge app.
135
135
  // The canonical address: the new SKILL.md's own workspace URL.
136
136
  await waitFor(() =>
137
- expect(href()).toBe(`/workspace/${DEFAULT_BRANCH}/knowledge-base/Groups/scratch/SKILL.md`),
137
+ expect(href()).toBe(`/workspace/${DEFAULT_BRANCH}/knowledge-base/Plugins/scratch/SKILL.md`),
138
138
  );
139
139
  expect(onClose).toHaveBeenCalledTimes(1);
140
140
  });
@@ -156,7 +156,7 @@ describe('PersonalAddDialog', () => {
156
156
  expect(screen.queryByText(/sent for review/)).not.toBeInTheDocument();
157
157
  });
158
158
 
159
- it('refuses a name a group’s skill already holds', async () => {
159
+ it('refuses a name a plugin’s skill already holds', async () => {
160
160
  const { field, create } = renderDialog(['rfi']);
161
161
  fireEvent.change(field(), { target: { value: 'RFI' } });
162
162
  expect(screen.getByRole('alert')).toHaveTextContent('already exists');
@@ -171,7 +171,7 @@ describe('PersonalAddDialog', () => {
171
171
  expect(screen.queryByRole('textbox', { name: 'Skill name' })).not.toBeInTheDocument();
172
172
  expect(screen.getByRole('button', { name: 'Copy prompt' })).toBeInTheDocument();
173
173
  expect(screen.getByText(/Tell your agent what you need/)).toBeInTheDocument();
174
- expect(screen.getByText(/Yours alone until you add it to a group/)).toBeInTheDocument();
174
+ expect(screen.getByText(/Yours alone until you add it to a plugin/)).toBeInTheDocument();
175
175
  expect(apiMock.createEmptySkill).not.toHaveBeenCalled();
176
176
  });
177
177
  });
@@ -0,0 +1,131 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
3
+ import { MemoryRouter } from 'react-router-dom';
4
+ import { DEFAULT_BRANCH, type FileTreeEntry } from '@bevel-software/platform-shared';
5
+ import {
6
+ WorkspaceContext,
7
+ type WorkspaceContextValue,
8
+ } from '../../workspace/state/workspace.context';
9
+
10
+ /**
11
+ * The client-extensions section's tree source. The section pins its listing to
12
+ * the default branch; what is under test is WHERE that tree comes from — the
13
+ * workspace context's already-loaded tree when the context sits on the default
14
+ * branch (no request at all), the fetch only when it sits elsewhere.
15
+ */
16
+
17
+ const apiMock = vi.hoisted(() => ({ listFiles: vi.fn() }));
18
+ vi.mock('../../workspace/services/workspace.api', async (importOriginal) => ({
19
+ ...(await importOriginal<object>()),
20
+ listFiles: apiMock.listFiles,
21
+ }));
22
+
23
+ const navigateMock = vi.hoisted(() => vi.fn());
24
+ vi.mock('react-router-dom', async (importOriginal) => ({
25
+ ...(await importOriginal<object>()),
26
+ useNavigate: () => navigateMock,
27
+ }));
28
+
29
+ import { ClientExtensionsSection } from '../components/PluginExtras';
30
+
31
+ const dir = (name: string, children: FileTreeEntry[]): FileTreeEntry =>
32
+ ({ name, relativePath: name, type: 'directory', children }) as FileTreeEntry;
33
+ const file = (name: string): FileTreeEntry =>
34
+ ({ name, relativePath: name, type: 'file' }) as FileTreeEntry;
35
+
36
+ /** A tree whose GTM plugin carries one foreign namespace dir. */
37
+ const TREE: FileTreeEntry = dir('root', [
38
+ dir('knowledge-base', [
39
+ dir('Plugins', [
40
+ dir('GTM', [
41
+ dir('com.example.client', [dir('hooks', [file('on-save.js')])]),
42
+ dir('outreach', [file('SKILL.md')]),
43
+ ]),
44
+ dir('Product', [dir('roadmap', [file('SKILL.md')])]),
45
+ ]),
46
+ ]),
47
+ ]);
48
+
49
+ function renderSection(workspace: Partial<WorkspaceContextValue>, folder = 'GTM') {
50
+ return render(
51
+ <MemoryRouter>
52
+ <WorkspaceContext.Provider value={workspace as WorkspaceContextValue}>
53
+ <ClientExtensionsSection kbDirName="knowledge-base" folder={folder} />
54
+ </WorkspaceContext.Provider>
55
+ </MemoryRouter>,
56
+ );
57
+ }
58
+
59
+ beforeEach(() => {
60
+ apiMock.listFiles.mockReset();
61
+ navigateMock.mockReset();
62
+ });
63
+
64
+ describe('ClientExtensionsSection', () => {
65
+ it('reuses the context tree when the workspace sits on the default branch — no fetch', async () => {
66
+ renderSection({ workspaceId: encodeURIComponent(DEFAULT_BRANCH), fileTree: TREE });
67
+ expect(await screen.findByText('com.example.client/')).toBeInTheDocument();
68
+ expect(screen.getByRole('button', { name: 'hooks/on-save.js' })).toBeInTheDocument();
69
+ expect(apiMock.listFiles).not.toHaveBeenCalled();
70
+ });
71
+
72
+ it('fetches the default-branch tree when the context sits on a draft branch', async () => {
73
+ // A draft's tree could list files the section's default-branch links
74
+ // cannot open — the fetch is the correctness fallback, not the norm.
75
+ apiMock.listFiles.mockResolvedValue(TREE);
76
+ renderSection({ workspaceId: 'draft-my-changes', fileTree: dir('root', []) });
77
+ expect(await screen.findByText('com.example.client/')).toBeInTheDocument();
78
+ expect(apiMock.listFiles).toHaveBeenCalledWith(encodeURIComponent(DEFAULT_BRANCH));
79
+ });
80
+
81
+ /**
82
+ * The fileTree can carry workspace/KB-clone wrapper levels above the kb dir
83
+ * (`findKbRoot` exists for exactly this shape). The section must find the
84
+ * plugin's namespace dirs through them, not assume the root's direct child
85
+ * is the kb dir.
86
+ */
87
+ it('finds the namespace dirs through wrapper levels above the kb dir', async () => {
88
+ const wrapped = dir('root', [dir('workspace-clone', TREE.children ?? [])]);
89
+ renderSection({ workspaceId: encodeURIComponent(DEFAULT_BRANCH), fileTree: wrapped });
90
+ expect(await screen.findByText('com.example.client/')).toBeInTheDocument();
91
+ expect(screen.getByRole('button', { name: 'hooks/on-save.js' })).toBeInTheDocument();
92
+ });
93
+
94
+ /**
95
+ * `rawFile` steps past the app gate into the Knowledge editor — right for
96
+ * opaque client data, wrong for a `.tool`, which has a first-class tool
97
+ * page in this app. The same URL without the state renders that page.
98
+ */
99
+ it('opens a .tool in the library (no rawFile), other files in the Knowledge editor', async () => {
100
+ const withTool: FileTreeEntry = dir('root', [
101
+ dir('knowledge-base', [
102
+ dir('Plugins', [
103
+ dir('GTM', [
104
+ dir('com.example.client', [dir('hooks', [file('on-save.js')])]),
105
+ dir('software.bevel.hexis', [dir('tools', [file('web-search.tool')])]),
106
+ ]),
107
+ ]),
108
+ ]),
109
+ ]);
110
+ renderSection({ workspaceId: encodeURIComponent(DEFAULT_BRANCH), fileTree: withTool });
111
+ fireEvent.click(await screen.findByRole('button', { name: 'tools/web-search.tool' }));
112
+ expect(navigateMock).toHaveBeenLastCalledWith(
113
+ expect.stringContaining('web-search.tool'),
114
+ undefined,
115
+ );
116
+ fireEvent.click(screen.getByRole('button', { name: 'hooks/on-save.js' }));
117
+ expect(navigateMock).toHaveBeenLastCalledWith(
118
+ expect.stringContaining('on-save.js'),
119
+ { state: { rawFile: true } },
120
+ );
121
+ });
122
+
123
+ it('renders nothing for a plugin with no namespace dirs, still without fetching', async () => {
124
+ const { container } = renderSection(
125
+ { workspaceId: encodeURIComponent(DEFAULT_BRANCH), fileTree: TREE },
126
+ 'Product',
127
+ );
128
+ await waitFor(() => expect(container).toBeEmptyDOMElement());
129
+ expect(apiMock.listFiles).not.toHaveBeenCalled();
130
+ });
131
+ });