@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
@@ -1,9 +1,10 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { render, screen } from '@testing-library/react';
2
+ import { render, screen, within } from '@testing-library/react';
3
3
  import userEvent from '@testing-library/user-event';
4
4
  import { MemoryRouter } from 'react-router-dom';
5
5
  import { ExternalAgentAccessPage } from '../ExternalAgentAccessPage';
6
6
  import { configureMcpUrl } from '../../../../shared/mcp';
7
+ import { GITHUB_LINK_KIND, configureMarketplaceGitUrl } from '../../../../shared/marketplace-url';
7
8
 
8
9
  /**
9
10
  * The Connect page's contract, and the reason this file exists at all: every
@@ -26,6 +27,10 @@ const { listMock, createMock } = vi.hoisted(() => ({
26
27
  createMock: vi.fn(),
27
28
  }));
28
29
 
30
+ vi.mock('../../../admin/state/admin.context', () => ({
31
+ useAdmin: () => ({ isAdmin: false }),
32
+ }));
33
+
29
34
  vi.mock('../../services/external-api-keys.api', () => ({
30
35
  listExternalApiKeys: listMock,
31
36
  createExternalApiKey: createMock,
@@ -56,6 +61,8 @@ beforeEach(() => {
56
61
 
57
62
  function mount(mcpUrl: string) {
58
63
  configureMcpUrl(mcpUrl);
64
+ // The marketplace remote is served from the same deployment address.
65
+ configureMarketplaceGitUrl(`${new URL(mcpUrl).origin}/git/marketplace.git`);
59
66
  return render(
60
67
  <MemoryRouter>
61
68
  <ExternalAgentAccessPage />
@@ -137,7 +144,12 @@ describe('the interactive tab: local first, hosted second, each with its own add
137
144
  it('keeps each family on its own address', () => {
138
145
  mount(PUBLIC_URL);
139
146
  for (const value of snippets()) {
140
- if (value.includes('hexis')) {
147
+ if (value.includes('marketplace.git')) {
148
+ // The marketplace remote is the deployment's own address (with the
149
+ // key in the userinfo, so the HOST is what survives), never the browser's.
150
+ expect(value).toContain(new URL(PUBLIC_URL).host);
151
+ expect(value).not.toContain(window.location.host);
152
+ } else if (value.includes('hexis')) {
141
153
  expect(value).toContain(window.location.origin);
142
154
  expect(value).not.toContain(PUBLIC_URL);
143
155
  } else {
@@ -220,6 +232,46 @@ describe('the key-bearing snippets quote the deployment too', () => {
220
232
  expect(json).not.toContain(PUBLIC_URL);
221
233
  });
222
234
 
235
+ /**
236
+ * The modal holds the SAME three drawers as the interactive tab, in the
237
+ * same order, and every one of them arrives closed: the key is what the
238
+ * dialog hands over, and the configs wait until the reader picks a side.
239
+ */
240
+ it('folds the configs into the tab\'s three drawers, all closed', async () => {
241
+ const user = userEvent.setup();
242
+ mount(PUBLIC_URL);
243
+ await revealAKey(user);
244
+ const dialog = screen.getByRole('alertdialog');
245
+ const summaries = [
246
+ 'Desktop agents — the local server (recommended)',
247
+ 'Web agents and pipelines — the hosted endpoint',
248
+ 'Skills as native plugins — the marketplace',
249
+ ].map((text) => within(dialog).getByText(text));
250
+ for (const summary of summaries) {
251
+ expect(summary.tagName).toBe('SUMMARY');
252
+ expect((summary.closest('details') as HTMLDetailsElement).open).toBe(false);
253
+ }
254
+ expect(summaries[0].compareDocumentPosition(summaries[1]) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
255
+ expect(summaries[1].compareDocumentPosition(summaries[2]) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
256
+ // The key itself is not behind a drawer.
257
+ expect(within(dialog).getByRole('button', { name: 'Copy external API key' }).closest('details')).toBeNull();
258
+ });
259
+
260
+ /**
261
+ * The placeholder in the keyless marketplace commands is a placeholder, not
262
+ * a percent-encoded one: `%3Cexternal-api-key%3E` looked like a secret to
263
+ * paste. The commands live on the Marketplaces tab now.
264
+ */
265
+ it('shows the marketplace placeholder verbatim in the keyless commands', async () => {
266
+ const user = userEvent.setup();
267
+ mount(PUBLIC_URL);
268
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
269
+ const marketplace = snippets().filter((v) => v.includes('marketplace.git'));
270
+ expect(marketplace.length).toBeGreaterThan(0);
271
+ for (const v of marketplace) expect(v).not.toContain('%3C');
272
+ expect(marketplace.some((v) => v.includes('key:<external-api-key>@'))).toBe(true);
273
+ });
274
+
223
275
  /**
224
276
  * The consolidation's real risk: snippets that must carry a secret
225
277
  * and snippets that must not. Losing the token during the move would look
@@ -231,13 +283,84 @@ describe('the key-bearing snippets quote the deployment too', () => {
231
283
  expect(snippets().some((v) => v.includes(KEY))).toBe(false);
232
284
  await revealAKey(user);
233
285
  expect(snippets().filter((v) => v.includes(KEY))).toHaveLength(
234
- // the reveal textarea itself, the three keyed hosted snippets, and the
235
- // two local-server (hexis-mcp) snippets
236
- 6,
286
+ // the reveal textarea itself, the three keyed hosted snippets, the two
287
+ // local-server (hexis-mcp) snippets, and the three marketplace commands
288
+ 9,
237
289
  );
238
290
  });
239
291
  });
240
292
 
293
+ describe('the Marketplaces tab', () => {
294
+ it('is the third tab, and the interactive tab points at it instead of carrying the remote', async () => {
295
+ const user = userEvent.setup();
296
+ mount(PUBLIC_URL);
297
+ expect(screen.getAllByRole('tab').map((t) => t.textContent)).toEqual([
298
+ 'Your agent',
299
+ 'Marketplaces',
300
+ 'Autonomous agents',
301
+ ]);
302
+ // The remote no longer lives on the interactive tab.
303
+ expect(snippets().some((v) => v.includes('marketplace.git'))).toBe(false);
304
+ await user.click(screen.getByRole('button', { name: 'Marketplaces' }));
305
+ expect(screen.getByRole('tab', { name: 'Marketplaces' })).toHaveAttribute('aria-selected', 'true');
306
+ });
307
+
308
+ it('leads with the Cowork route and follows with the git remote, both closed, one URL for both', async () => {
309
+ const user = userEvent.setup();
310
+ mount(PUBLIC_URL);
311
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
312
+ const cowork = screen.getByText('Cowork and claude.ai');
313
+ const git = screen.getByText('Claude Code, Codex and the skills CLI');
314
+ expect(cowork.compareDocumentPosition(git) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
315
+ for (const drawer of [cowork, git]) {
316
+ expect((drawer.closest('details') as HTMLDetailsElement).open).toBe(false);
317
+ }
318
+ const remote = `${new URL(PUBLIC_URL).origin}/git/marketplace.git`;
319
+ // The same address in both drawers: what Cowork adds is what Claude Code clones.
320
+ expect(snippets().filter((v) => v === remote)).toHaveLength(2);
321
+ // The keyed commands point at the deployment's host.
322
+ const commands = snippets().filter((v) => v.includes('key:'));
323
+ expect(commands.length).toBeGreaterThan(0);
324
+ for (const v of commands) expect(v).toContain(new URL(PUBLIC_URL).host);
325
+ });
326
+
327
+ it('tells Claude connections from keys by their stored kind — never by the label', async () => {
328
+ listMock.mockResolvedValue([
329
+ { id: 'c1', kind: GITHUB_LINK_KIND, label: 'My Cowork link', createdAt: Date.now(), lastUsedAt: null, revokedAt: null },
330
+ // A hand-made key wearing the link's usual label is still a key.
331
+ { id: 'k1', kind: 'key', label: 'Claude (claude.ai and Cowork)', createdAt: Date.now(), lastUsedAt: null, revokedAt: null },
332
+ ]);
333
+ const user = userEvent.setup();
334
+ mount(PUBLIC_URL);
335
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
336
+ const cowork = screen.getByText('Cowork and claude.ai').closest('details') as HTMLElement;
337
+ await screen.findByText('My Cowork link');
338
+ expect(cowork).toHaveTextContent('My Cowork link');
339
+ expect(cowork).not.toHaveTextContent('Claude (claude.ai and Cowork)');
340
+
341
+ await user.click(screen.getByRole('tab', { name: 'Autonomous agents' }));
342
+ await screen.findByText('Claude (claude.ai and Cowork)');
343
+ expect(screen.queryByText('My Cowork link')).toBeNull();
344
+ });
345
+
346
+ it('says where the keys went when only Claude connections exist, and shows a load error on both tabs', async () => {
347
+ listMock.mockResolvedValue([
348
+ { id: 'c1', kind: GITHUB_LINK_KIND, label: 'Claude', createdAt: Date.now(), lastUsedAt: null, revokedAt: null },
349
+ ]);
350
+ const user = userEvent.setup();
351
+ const first = mount(PUBLIC_URL);
352
+ await user.click(screen.getByRole('tab', { name: 'Autonomous agents' }));
353
+ await screen.findByText(/Your Claude connections are on the Marketplaces tab/);
354
+ first.unmount();
355
+
356
+ listMock.mockRejectedValue(new Error('keys are down'));
357
+ mount(PUBLIC_URL);
358
+ await user.click(screen.getByRole('tab', { name: 'Marketplaces' }));
359
+ await screen.findByText('keys are down');
360
+ expect(screen.queryByText(/None yet/)).toBeNull();
361
+ });
362
+ });
363
+
241
364
  describe('the one-click install link', () => {
242
365
  it('offers Add to Claude on a reachable deployment', () => {
243
366
  mount(PUBLIC_URL);
@@ -313,7 +436,7 @@ describe('tabs', () => {
313
436
  it('starts on the interactive tab', () => {
314
437
  mount(PUBLIC_URL);
315
438
  const tabs = screen.getAllByRole('tab');
316
- expect(tabs.map((t) => t.textContent)).toEqual(['Your agent', 'Autonomous agents']);
439
+ expect(tabs.map((t) => t.textContent)).toEqual(['Your agent', 'Marketplaces', 'Autonomous agents']);
317
440
  expect(tabs[0]).toHaveAttribute('aria-selected', 'true');
318
441
  expect(tabs[1]).toHaveAttribute('aria-selected', 'false');
319
442
  });
@@ -3,6 +3,8 @@ import { authFetch } from '../../../lib/api';
3
3
  export interface ExternalApiKeySummary {
4
4
  id: string;
5
5
  label: string;
6
+ /** `key` for one created by hand; `github-link` for one minted when a product (Claude) connected through the GitHub facade. */
7
+ kind: string;
6
8
  createdAt: number;
7
9
  lastUsedAt: number | null;
8
10
  revokedAt: number | null;
@@ -13,6 +13,7 @@ export function makeWorkspaceFixture(
13
13
  workspaceId: 'ws-1',
14
14
  kbDirName: 'knowledge-base',
15
15
  fileTree: null,
16
+ bootstrapError: null,
16
17
  openTabs: [],
17
18
  activeTab: null,
18
19
  dirtyTabFilenames: [],