@bevel-software/platform-core-frontend 0.7.4 → 0.8.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.
- package/LICENSE +202 -202
- package/THIRD-PARTY-NOTICES.md +344 -988
- package/package.json +5 -5
- package/src/core/CoreAppShell.tsx +4 -4
- package/src/core/__tests__/ShellRoutes.test.tsx +1 -1
- package/src/core/__tests__/bootstrap.test.ts +47 -2
- package/src/core/bootstrap.ts +20 -0
- package/src/css-side-effect-imports.d.ts +7 -7
- package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +1 -1
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +5 -5
- package/src/modules/access/api.ts +5 -5
- package/src/modules/access/components/ManageAccessDialog.tsx +21 -20
- package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
- package/src/modules/admin/components/AdminRolesPage.tsx +1 -1
- package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +2 -2
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +1 -1
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +1 -1
- package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +4 -4
- package/src/modules/layout/__tests__/SidebarToggle.test.tsx +4 -4
- package/src/modules/layout/__tests__/breakpoints.test.ts +1 -1
- package/src/modules/layout/components/SidebarFrame.tsx +2 -2
- package/src/modules/library/__tests__/{AddToGroupDialog.test.tsx → AddToPluginDialog.test.tsx} +34 -34
- package/src/modules/library/__tests__/LibraryCard.test.tsx +30 -11
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +84 -59
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +51 -51
- package/src/modules/library/__tests__/{LockedGroupView.test.tsx → LockedPluginView.test.tsx} +33 -33
- package/src/modules/library/__tests__/McpServerSection.test.tsx +138 -0
- package/src/modules/library/__tests__/{NewGroupDialog.test.tsx → NewPluginDialog.test.tsx} +22 -22
- package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +7 -7
- package/src/modules/library/__tests__/PluginExtras.test.tsx +131 -0
- package/src/modules/library/__tests__/{GroupJoinRequests.test.tsx → PluginJoinRequests.test.tsx} +24 -24
- package/src/modules/library/__tests__/{GroupPage.test.tsx → PluginPage.test.tsx} +101 -101
- package/src/modules/library/__tests__/{GroupsIndexPage.test.tsx → PluginsIndexPage.test.tsx} +57 -57
- package/src/modules/library/__tests__/{GroupsSidebar.contextmenu.test.tsx → PluginsSidebar.contextmenu.test.tsx} +31 -31
- package/src/modules/library/__tests__/{GroupsSidebar.locked.test.tsx → PluginsSidebar.locked.test.tsx} +28 -28
- package/src/modules/library/__tests__/{GroupsSidebar.test.tsx → PluginsSidebar.test.tsx} +39 -39
- package/src/modules/library/__tests__/{GroupsSidebarMenu.test.tsx → PluginsSidebarMenu.test.tsx} +18 -18
- package/src/modules/library/__tests__/SkillPage.test.tsx +8 -8
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +2 -2
- package/src/modules/library/__tests__/ToolPage.test.tsx +41 -12
- package/src/modules/library/__tests__/ToolSharePanel.test.tsx +1 -1
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +57 -57
- package/src/modules/library/__tests__/auth-harness.tsx +4 -4
- package/src/modules/library/__tests__/status.test.ts +19 -19
- package/src/modules/library/__tests__/tools.api.test.ts +70 -0
- package/src/modules/library/__tests__/useToolPage.test.tsx +4 -4
- package/src/modules/library/components/AccessRequestsBanner.tsx +8 -8
- package/src/modules/library/components/{AddToGroupDialog.tsx → AddToPluginDialog.tsx} +11 -11
- package/src/modules/library/components/ChangeRequestDock.tsx +1 -1
- package/src/modules/library/components/{DeleteGroupDialog.tsx → DeletePluginDialog.tsx} +9 -9
- package/src/modules/library/components/LibraryCard.tsx +26 -2
- package/src/modules/library/components/LibraryLayout.tsx +70 -70
- package/src/modules/library/components/LibraryPage.tsx +8 -8
- package/src/modules/library/components/LockGlyph.tsx +1 -1
- package/src/modules/library/components/{LockedGroupView.tsx → LockedPluginView.tsx} +35 -35
- package/src/modules/library/components/{ManagedGroupRequests.tsx → ManagedPluginRequests.tsx} +13 -13
- package/src/modules/library/components/{NewGroupDialog.tsx → NewPluginDialog.tsx} +24 -24
- package/src/modules/library/components/NewSkillPanel.tsx +5 -5
- package/src/modules/library/components/PageActions.tsx +3 -3
- package/src/modules/library/components/PersonalAddDialog.tsx +5 -5
- package/src/modules/library/components/{PersonalGroupPage.tsx → PersonalPluginPage.tsx} +17 -17
- package/src/modules/library/components/PluginExtras.tsx +195 -0
- package/src/modules/library/components/{GroupIndexRow.tsx → PluginIndexRow.tsx} +6 -6
- package/src/modules/library/components/{GroupJoinRequests.tsx → PluginJoinRequests.tsx} +12 -12
- package/src/modules/library/components/{GroupPage.tsx → PluginPage.tsx} +72 -69
- package/src/modules/library/components/{GroupsIndexPage.tsx → PluginsIndexPage.tsx} +46 -46
- package/src/modules/library/components/{GroupsSidebar.tsx → PluginsSidebar.tsx} +55 -55
- package/src/modules/library/components/{GroupsSidebarMenu.tsx → PluginsSidebarMenu.tsx} +15 -15
- package/src/modules/library/components/{group-page-parts.tsx → plugin-page-parts.tsx} +35 -24
- package/src/modules/library/components/skill-page/SkillPage.tsx +12 -12
- package/src/modules/library/components/tool-page/McpServerSection.tsx +380 -0
- package/src/modules/library/components/tool-page/ToolPage.tsx +22 -5
- package/src/modules/library/hooks/useJoinRequests.ts +8 -8
- package/src/modules/library/routes/LibraryRoutes.tsx +30 -17
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +24 -24
- package/src/modules/library/routes/library-paths.ts +36 -36
- package/src/modules/library/services/library.api.ts +9 -9
- package/src/modules/library/services/{groups.api.ts → plugins.api.ts} +43 -43
- package/src/modules/library/services/tools.api.ts +54 -0
- package/src/modules/library/state/library-data.tsx +46 -46
- package/src/modules/library/utils/names.ts +1 -1
- package/src/modules/library/utils/{personal-group.ts → personal-plugin.ts} +8 -8
- package/src/modules/library/utils/{group-summary.ts → plugin-summary.ts} +14 -14
- package/src/modules/library/utils/status.ts +17 -17
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +86 -8
- package/src/modules/onboarding/agent-clients.ts +18 -14
- package/src/modules/onboarding/components/WelcomePage.tsx +19 -8
- package/src/modules/review/components/MarkdownDiffViewer.tsx +1 -1
- package/src/modules/review/components/ReviewPanel.tsx +11 -11
- package/src/modules/review/components/__tests__/{isGroupItemPath.test.ts → isPluginItemPath.test.ts} +24 -24
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +3 -3
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +1 -1
- package/src/modules/settings/components/SettingsLayout.tsx +1 -1
- package/src/modules/settings/components/SettingsNav.tsx +5 -5
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +29 -107
- package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +1 -1
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +228 -0
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +3 -3
- package/src/modules/workspace/components/FileExplorer.tsx +12 -12
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +14 -14
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +7 -2
- package/src/modules/workspace/utils/__tests__/diff.test.ts +1 -1
- package/src/modules/workspace/utils/fileTree.ts +3 -3
- package/src/shared/mcp/ClaudeInstallLink.tsx +88 -0
- package/src/shared/mcp/ConnectionInstructions.tsx +51 -0
- package/src/shared/mcp/CopyBlock.tsx +42 -0
- package/src/shared/mcp/__tests__/ClaudeInstallLink.test.tsx +40 -0
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +431 -0
- package/src/shared/mcp/__tests__/useCopyFeedback.test.ts +112 -0
- package/src/shared/mcp/connect-snippets.ts +353 -0
- package/src/shared/mcp/index.ts +28 -0
- package/src/shared/mcp/useCopyFeedback.ts +46 -0
- package/src/test-setup.ts +11 -0
|
@@ -2,105 +2,105 @@ import { authFetch } from '../../../lib/api';
|
|
|
2
2
|
import { handleApiResponse } from '../../git/services/git.api';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* `modules/
|
|
5
|
+
* Plugin enumeration + join requests — the browser half of the backend's
|
|
6
|
+
* `modules/plugins`.
|
|
7
7
|
*
|
|
8
8
|
* Enumeration is fail-closed with three ordinary access verdicts: a listed
|
|
9
|
-
*
|
|
10
|
-
* admin-rescued), or may DISCOVER (they can read the
|
|
11
|
-
* file — granted by its own `read: everyone` frontmatter). A
|
|
9
|
+
* plugin is one the caller is a MEMBER of (`canRead`), MANAGES (`canWrite`,
|
|
10
|
+
* admin-rescued), or may DISCOVER (they can read the plugin's `access.md`
|
|
11
|
+
* file — granted by its own `read: everyone` frontmatter). A plugin with no
|
|
12
12
|
* verdict is absent. Asking to join opens a plain change request; nothing
|
|
13
13
|
* request-shaped is stored anywhere else.
|
|
14
14
|
*
|
|
15
|
-
* Every type below MIRRORS the backend contract (`
|
|
15
|
+
* Every type below MIRRORS the backend contract (`plugins.contract.ts`). Keep
|
|
16
16
|
* them in step.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
export interface
|
|
19
|
+
export interface PluginPrincipals {
|
|
20
20
|
roles: string[];
|
|
21
21
|
users: { name: string; email: string }[];
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export interface
|
|
24
|
+
export interface PluginReaders extends PluginPrincipals {
|
|
25
25
|
/** False when `read: everyone` applies cleanly (the lists are then empty). */
|
|
26
26
|
restricted: boolean;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export interface
|
|
30
|
-
/**
|
|
29
|
+
export interface PluginSummary {
|
|
30
|
+
/** Plugin folder name, e.g. `GTM`. */
|
|
31
31
|
name: string;
|
|
32
|
-
/** Repo-relative constituent folders, e.g. `['
|
|
32
|
+
/** Repo-relative constituent folders, e.g. `['Plugins/GTM']`. */
|
|
33
33
|
folders: string[];
|
|
34
34
|
/** Per-caller: can read the folder (membership). Locked === !canRead. */
|
|
35
35
|
canRead: boolean;
|
|
36
|
-
/** Per-caller; true ⇒ may manage the
|
|
36
|
+
/** Per-caller; true ⇒ may manage the plugin's access (admin-rescue applies). */
|
|
37
37
|
canWrite: boolean;
|
|
38
38
|
/**
|
|
39
39
|
* Per-caller: holds the `owner` verb on the folder (owner-lists only, no
|
|
40
|
-
* admin rescue). Deleting the
|
|
40
|
+
* admin rescue). Deleting the plugin is the owner's verb — the DELETE route
|
|
41
41
|
* enforces this same verdict, so it also decides who sees the affordance.
|
|
42
42
|
*/
|
|
43
43
|
isOwner: boolean;
|
|
44
|
-
/** The
|
|
44
|
+
/** The plugin's TOTALS, not the caller's slice. */
|
|
45
45
|
skillCount: number;
|
|
46
46
|
toolCount: number;
|
|
47
|
-
owners:
|
|
48
|
-
writers:
|
|
49
|
-
readers:
|
|
50
|
-
/** The caller has an OPEN join change request for this
|
|
47
|
+
owners: PluginPrincipals;
|
|
48
|
+
writers: PluginPrincipals;
|
|
49
|
+
readers: PluginReaders;
|
|
50
|
+
/** The caller has an OPEN join change request for this plugin. */
|
|
51
51
|
hasRequested: boolean;
|
|
52
52
|
/** That CR's number when `hasRequested` (deep-links the review UI). */
|
|
53
53
|
requestNumber: number | null;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
export async function
|
|
57
|
-
const res = await authFetch('/api/
|
|
58
|
-
if (!res.ok) throw new Error("Couldn't load
|
|
59
|
-
const data = (await res.json()) as {
|
|
60
|
-
return data.
|
|
56
|
+
export async function listPlugins(): Promise<PluginSummary[]> {
|
|
57
|
+
const res = await authFetch('/api/plugins');
|
|
58
|
+
if (!res.ok) throw new Error("Couldn't load plugins.");
|
|
59
|
+
const data = (await res.json()) as { plugins: PluginSummary[] };
|
|
60
|
+
return data.plugins;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* Create a
|
|
64
|
+
* Create a plugin — the dedicated provisioning endpoint, not a workspace
|
|
65
65
|
* write. The server owns name validation and the collision verdict (its
|
|
66
66
|
* check is against the live tree, ours against a stale catalog), commits the
|
|
67
67
|
* seeded `access.md` before answering, and refuses with its own words —
|
|
68
68
|
* worth surfacing verbatim.
|
|
69
69
|
*/
|
|
70
|
-
export async function
|
|
71
|
-
const res = await authFetch('/api/
|
|
70
|
+
export async function createPlugin(name: string): Promise<{ folder: string }> {
|
|
71
|
+
const res = await authFetch('/api/plugins', {
|
|
72
72
|
method: 'POST',
|
|
73
73
|
headers: { 'Content-Type': 'application/json' },
|
|
74
74
|
body: JSON.stringify({ name }),
|
|
75
75
|
});
|
|
76
76
|
if (!res.ok) {
|
|
77
77
|
const body = (await res.json().catch(() => ({}))) as { error?: string };
|
|
78
|
-
throw new Error(body.error ?? "Couldn't create that
|
|
78
|
+
throw new Error(body.error ?? "Couldn't create that plugin.");
|
|
79
79
|
}
|
|
80
80
|
return (await res.json()) as { folder: string };
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
|
-
* Delete a
|
|
84
|
+
* Delete a plugin — the whole folder, skills and tools included, in one
|
|
85
85
|
* commit. Owner-gated server-side (the `owner` verdict on the folder); a
|
|
86
86
|
* refusal names the rule and is worth surfacing verbatim. Fail-closed: a
|
|
87
|
-
*
|
|
87
|
+
* plugin the caller doesn't own answers exactly like one that doesn't exist.
|
|
88
88
|
*/
|
|
89
|
-
export async function
|
|
90
|
-
const res = await authFetch(`/api/
|
|
89
|
+
export async function deletePlugin(name: string): Promise<void> {
|
|
90
|
+
const res = await authFetch(`/api/plugins/${encodeURIComponent(name)}`, { method: 'DELETE' });
|
|
91
91
|
if (!res.ok) {
|
|
92
92
|
const body = (await res.json().catch(() => ({}))) as { error?: string };
|
|
93
|
-
throw new Error(body.error ?? "Couldn't delete that
|
|
93
|
+
throw new Error(body.error ?? "Couldn't delete that plugin.");
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
|
-
* Ensure the caller's personal folder (`
|
|
98
|
+
* Ensure the caller's personal folder (`Plugins/personal-<id>/`) exists.
|
|
99
99
|
* Idempotent; the server answers only after the folder's access.md is
|
|
100
100
|
* COMMITTED, so a write into the folder may follow immediately.
|
|
101
101
|
*/
|
|
102
|
-
export async function
|
|
103
|
-
const res = await authFetch('/api/
|
|
102
|
+
export async function ensurePersonalPlugin(): Promise<{ folder: string; created: boolean }> {
|
|
103
|
+
const res = await authFetch('/api/plugins/personal', { method: 'POST' });
|
|
104
104
|
if (!res.ok) {
|
|
105
105
|
const body = (await res.json().catch(() => ({}))) as { error?: string };
|
|
106
106
|
throw new Error(body.error ?? "Couldn't prepare your personal folder.");
|
|
@@ -111,18 +111,18 @@ export async function ensurePersonalGroup(): Promise<{ folder: string; created:
|
|
|
111
111
|
/**
|
|
112
112
|
* Thrown when a join request is refused because access already landed —
|
|
113
113
|
* between the page load and the click. Not an error to show: the right
|
|
114
|
-
* response is to reload the library and let the
|
|
114
|
+
* response is to reload the library and let the plugin appear unlocked.
|
|
115
115
|
*/
|
|
116
116
|
export class AlreadyReadableError extends Error {
|
|
117
117
|
constructor() {
|
|
118
|
-
super('You can already read this
|
|
118
|
+
super('You can already read this plugin');
|
|
119
119
|
this.name = 'AlreadyReadableError';
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/** Open (or return the existing) join change request. Idempotent server-side. */
|
|
124
|
-
export async function
|
|
125
|
-
const res = await authFetch(`/api/
|
|
124
|
+
export async function requestPluginAccess(name: string): Promise<{ number: number }> {
|
|
125
|
+
const res = await authFetch(`/api/plugins/${encodeURIComponent(name)}/join-request`, {
|
|
126
126
|
method: 'POST',
|
|
127
127
|
});
|
|
128
128
|
if (res.status === 409) {
|
|
@@ -162,13 +162,13 @@ export interface JoinRequest {
|
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
/**
|
|
165
|
-
* Open join requests for a
|
|
165
|
+
* Open join requests for a plugin the caller MANAGES, each with what it still
|
|
166
166
|
* proposes. Non-managers get `[]` (never a 403), so the caller may ask
|
|
167
|
-
* unconditionally — the same posture every other
|
|
167
|
+
* unconditionally — the same posture every other plugin surface takes.
|
|
168
168
|
*/
|
|
169
169
|
export async function listJoinRequests(name: string): Promise<JoinRequest[]> {
|
|
170
170
|
const data = await handleApiResponse<{ requests: JoinRequest[] }>(
|
|
171
|
-
await authFetch(`/api/
|
|
171
|
+
await authFetch(`/api/plugins/${encodeURIComponent(name)}/join-requests`),
|
|
172
172
|
);
|
|
173
173
|
return data.requests;
|
|
174
174
|
}
|
|
@@ -181,7 +181,7 @@ export async function listJoinRequests(name: string): Promise<JoinRequest[]> {
|
|
|
181
181
|
export async function reconcileJoinRequest(name: string, number: number): Promise<boolean> {
|
|
182
182
|
const data = await handleApiResponse<{ closed: boolean }>(
|
|
183
183
|
await authFetch(
|
|
184
|
-
`/api/
|
|
184
|
+
`/api/plugins/${encodeURIComponent(name)}/join-requests/${number}/reconcile`,
|
|
185
185
|
{ method: 'POST' },
|
|
186
186
|
),
|
|
187
187
|
);
|
|
@@ -58,3 +58,57 @@ export async function getToolDetail(slug: string): Promise<ToolManualDetail> {
|
|
|
58
58
|
if (!res.ok) await unwrap(res, "Couldn't load this tool.");
|
|
59
59
|
return ((await res.json()) as { tool: ToolManualDetail }).tool;
|
|
60
60
|
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The server-scoped view/edit surface for an mcp.json-backed tool. One
|
|
64
|
+
* server's truth spans two files (mcp.json + plugin.json's extensions block);
|
|
65
|
+
* these endpoints are the pair kept in step, so the form never shows a writer
|
|
66
|
+
* half of it. Absent (404) for `.tool`-backed manuals — those edit as files.
|
|
67
|
+
*/
|
|
68
|
+
export type McpTransport = 'streamable-http' | 'sse' | 'stdio';
|
|
69
|
+
|
|
70
|
+
export interface McpServerView {
|
|
71
|
+
name: string;
|
|
72
|
+
transport: McpTransport;
|
|
73
|
+
url?: string;
|
|
74
|
+
command?: string;
|
|
75
|
+
args?: string[];
|
|
76
|
+
cwd?: string;
|
|
77
|
+
env?: Record<string, string>;
|
|
78
|
+
literalHeaders: Record<string, string>;
|
|
79
|
+
authHeaders: Record<string, string>;
|
|
80
|
+
variables: { name: string; scope: 'admin' | 'user'; label?: string }[];
|
|
81
|
+
description?: string;
|
|
82
|
+
local: boolean;
|
|
83
|
+
canWrite: boolean;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export type McpServerWrite = Omit<Partial<McpServerView>, 'name' | 'canWrite'> & {
|
|
87
|
+
transport: McpTransport;
|
|
88
|
+
newName?: string;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export async function getMcpServer(slug: string): Promise<McpServerView | null> {
|
|
92
|
+
const res = await authFetch(`/api/tools/${encodeURIComponent(slug)}/server`);
|
|
93
|
+
if (res.status === 404) {
|
|
94
|
+
// Two 404s share this status and only ONE is an absence: `Not found` is
|
|
95
|
+
// the expected no-server-pair case (a .tool-backed manual), while `Not
|
|
96
|
+
// available` means the edit service isn't wired at all — a deployment
|
|
97
|
+
// fault that must surface, not render as a quietly server-less page.
|
|
98
|
+
const body = (await res.json().catch(() => null)) as { error?: string } | null;
|
|
99
|
+
if (body?.error === 'Not found') return null;
|
|
100
|
+
throw new Error(body?.error ?? "Couldn't load the server configuration.");
|
|
101
|
+
}
|
|
102
|
+
if (!res.ok) await unwrap(res, "Couldn't load the server configuration.");
|
|
103
|
+
return (await res.json()) as McpServerView;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export async function putMcpServer(slug: string, write: McpServerWrite): Promise<{ name: string }> {
|
|
107
|
+
const res = await authFetch(`/api/tools/${encodeURIComponent(slug)}/server`, {
|
|
108
|
+
method: 'PUT',
|
|
109
|
+
headers: { 'Content-Type': 'application/json' },
|
|
110
|
+
body: JSON.stringify(write),
|
|
111
|
+
});
|
|
112
|
+
if (!res.ok) await unwrap(res, "Couldn't save the server configuration.");
|
|
113
|
+
return (await res.json()) as { name: string };
|
|
114
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { useCallback, useContext, useEffect, useMemo, useState, type ReactNode, } from 'react';
|
|
2
2
|
import { LibraryContext } from './library-context';
|
|
3
|
-
import {
|
|
3
|
+
import { pluginOfPath, isPersonalPluginFolder } from '@bevel-software/platform-shared';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* The
|
|
7
|
-
* "yours alone" bucket. A personal folder (`
|
|
8
|
-
* a person's own skills live; it is a place, not a
|
|
6
|
+
* The plugin a card files under — with personal folders mapped to `null`, the
|
|
7
|
+
* "yours alone" bucket. A personal folder (`Plugins/personal-<id>/`) is where
|
|
8
|
+
* a person's own skills live; it is a place, not a plugin, and the only
|
|
9
9
|
* personal items a caller can ever read are their own (the folder's seeded
|
|
10
10
|
* access.md names nobody else), so `null` here always means "yours".
|
|
11
11
|
*/
|
|
12
|
-
function
|
|
13
|
-
const
|
|
14
|
-
return
|
|
12
|
+
function displayPluginOf(path: string): string | null {
|
|
13
|
+
const plugin = pluginOfPath(path);
|
|
14
|
+
return plugin !== null && isPersonalPluginFolder(plugin) ? null : plugin;
|
|
15
15
|
}
|
|
16
16
|
import { useLibraryData, type LibraryData } from '../hooks/useLibraryData';
|
|
17
|
-
import {
|
|
17
|
+
import { listPlugins, type PluginSummary } from '../services/plugins.api';
|
|
18
18
|
import {
|
|
19
19
|
neededToolsFor,
|
|
20
20
|
skillStatus,
|
|
@@ -25,8 +25,8 @@ import {
|
|
|
25
25
|
/**
|
|
26
26
|
* The Library's data host.
|
|
27
27
|
*
|
|
28
|
-
* Everything under `/skills-and-tools/*` — the gallery, the
|
|
29
|
-
* all-
|
|
28
|
+
* Everything under `/skills-and-tools/*` — the gallery, the plugin pages, the
|
|
29
|
+
* all-plugins index — reads the SAME catalog, so it is fetched once here rather
|
|
30
30
|
* than once per page. That matters more than it looks: `useLibraryData` pays an
|
|
31
31
|
* N+1 `getSkill` to read `allowed-tools` frontmatter, and mounting it per route
|
|
32
32
|
* would re-pay it on every navigation.
|
|
@@ -34,8 +34,8 @@ import {
|
|
|
34
34
|
* Two independent loads live side by side:
|
|
35
35
|
* - the catalog (`useLibraryData`), whose failure IS surfaced (the gallery
|
|
36
36
|
* shows a banner — an empty library is indistinguishable from a broken one);
|
|
37
|
-
* - the
|
|
38
|
-
* reported through `
|
|
37
|
+
* - the plugin index (`GET /api/plugins`), whose failure degrades to `[]` and is
|
|
38
|
+
* reported through `pluginsError` for the surfaces that want to say so.
|
|
39
39
|
*/
|
|
40
40
|
|
|
41
41
|
/** One card in the gallery — a skill or an integration, already status-derived. */
|
|
@@ -46,8 +46,8 @@ export interface LibraryItem {
|
|
|
46
46
|
description: string;
|
|
47
47
|
owned: boolean;
|
|
48
48
|
status: AttentionStatus;
|
|
49
|
-
/** Folder
|
|
50
|
-
|
|
49
|
+
/** Folder plugin from the KB path, or null when the item is in none. */
|
|
50
|
+
plugin: string | null;
|
|
51
51
|
/** Repo-root-relative path — the skill's folder, or the `.tool` file. */
|
|
52
52
|
path: string;
|
|
53
53
|
/**
|
|
@@ -77,41 +77,41 @@ export interface LibraryItem {
|
|
|
77
77
|
export interface LibraryContextValue extends LibraryData {
|
|
78
78
|
items: LibraryItem[];
|
|
79
79
|
/** `[]` until loaded, and on error. */
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
pluginSummaries: PluginSummary[];
|
|
81
|
+
pluginsLoading: boolean;
|
|
82
|
+
pluginsError: string | null;
|
|
83
|
+
reloadPlugins(): void;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
export function LibraryProvider({ children }: { children: ReactNode }) {
|
|
88
88
|
const data = useLibraryData();
|
|
89
|
-
const [
|
|
90
|
-
const [
|
|
91
|
-
const [
|
|
92
|
-
const [
|
|
89
|
+
const [pluginSummaries, setPluginSummaries] = useState<PluginSummary[]>([]);
|
|
90
|
+
const [pluginsLoading, setPluginsLoading] = useState(true);
|
|
91
|
+
const [pluginsError, setPluginsError] = useState<string | null>(null);
|
|
92
|
+
const [pluginsRevision, setPluginsRevision] = useState(0);
|
|
93
93
|
|
|
94
94
|
useEffect(() => {
|
|
95
95
|
let cancelled = false;
|
|
96
|
-
|
|
97
|
-
.then((
|
|
96
|
+
listPlugins()
|
|
97
|
+
.then((plugins) => {
|
|
98
98
|
if (cancelled) return;
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
setPluginSummaries(plugins);
|
|
100
|
+
setPluginsError(null);
|
|
101
101
|
})
|
|
102
102
|
.catch((err: unknown) => {
|
|
103
103
|
if (cancelled) return;
|
|
104
104
|
// Keep whatever we had: a transient failure on a manual reload should
|
|
105
105
|
// not blank a list the user is looking at.
|
|
106
|
-
|
|
106
|
+
setPluginsError(err instanceof Error ? err.message : "Couldn't load plugins.");
|
|
107
107
|
})
|
|
108
108
|
.finally(() => {
|
|
109
|
-
if (!cancelled)
|
|
109
|
+
if (!cancelled) setPluginsLoading(false);
|
|
110
110
|
});
|
|
111
111
|
return () => {
|
|
112
112
|
cancelled = true;
|
|
113
113
|
};
|
|
114
|
-
}, [
|
|
114
|
+
}, [pluginsRevision]);
|
|
115
115
|
|
|
116
116
|
const items: LibraryItem[] = useMemo(() => {
|
|
117
117
|
const skillItems: LibraryItem[] = data.skills.map((s) => ({
|
|
@@ -120,7 +120,7 @@ export function LibraryProvider({ children }: { children: ReactNode }) {
|
|
|
120
120
|
name: s.name,
|
|
121
121
|
description: s.description,
|
|
122
122
|
owned: data.ownedSkills.has(s.name),
|
|
123
|
-
|
|
123
|
+
plugin: displayPluginOf(s.path),
|
|
124
124
|
path: s.path,
|
|
125
125
|
version: s.version,
|
|
126
126
|
status: skillStatus(
|
|
@@ -130,13 +130,13 @@ export function LibraryProvider({ children }: { children: ReactNode }) {
|
|
|
130
130
|
/**
|
|
131
131
|
* Proposed skills, alongside the released ones rather than in a pile of
|
|
132
132
|
* their own. The question "is this skill available?" is asked in the same
|
|
133
|
-
* place as "does this
|
|
133
|
+
* place as "does this plugin have one?", and a separate shelf answers the
|
|
134
134
|
* second while hiding the first — which is exactly the failure this fixes:
|
|
135
135
|
* a skill an agent proposed was nowhere at all until it merged.
|
|
136
136
|
*
|
|
137
137
|
* `status` is the neutral `ok`: a proposal has no integrations resolved
|
|
138
138
|
* against it, and reporting `warn` would put it in the setup filter and the
|
|
139
|
-
*
|
|
139
|
+
* plugin's amber count as though something were broken.
|
|
140
140
|
*/
|
|
141
141
|
const pendingItems: LibraryItem[] = data.pendingSkills.map((s) => ({
|
|
142
142
|
kind: 'skill',
|
|
@@ -144,7 +144,7 @@ export function LibraryProvider({ children }: { children: ReactNode }) {
|
|
|
144
144
|
name: s.name,
|
|
145
145
|
description: s.description,
|
|
146
146
|
owned: false,
|
|
147
|
-
|
|
147
|
+
plugin: displayPluginOf(s.path),
|
|
148
148
|
path: s.path,
|
|
149
149
|
version: s.version,
|
|
150
150
|
status: { state: 'ok', text: 'In review' },
|
|
@@ -163,7 +163,7 @@ export function LibraryProvider({ children }: { children: ReactNode }) {
|
|
|
163
163
|
// manual yet (see report) — the card stays clean; detail lives behind it.
|
|
164
164
|
description: '',
|
|
165
165
|
owned: t.canWrite,
|
|
166
|
-
|
|
166
|
+
plugin: displayPluginOf(t.path),
|
|
167
167
|
path: t.path,
|
|
168
168
|
status: toolStatus(t),
|
|
169
169
|
}));
|
|
@@ -180,21 +180,21 @@ export function LibraryProvider({ children }: { children: ReactNode }) {
|
|
|
180
180
|
// already covers the first load, and flipping it from the event that asked
|
|
181
181
|
// for the refetch keeps the effect body free of synchronous setState (which
|
|
182
182
|
// costs a cascading render on every revision).
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
const reloadPlugins = useCallback(() => {
|
|
184
|
+
setPluginsLoading(true);
|
|
185
|
+
setPluginsRevision((r) => r + 1);
|
|
186
186
|
}, []);
|
|
187
187
|
|
|
188
188
|
const value = useMemo(
|
|
189
189
|
(): LibraryContextValue => ({
|
|
190
190
|
...data,
|
|
191
191
|
items,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
pluginSummaries,
|
|
193
|
+
pluginsLoading,
|
|
194
|
+
pluginsError,
|
|
195
|
+
reloadPlugins,
|
|
196
196
|
}),
|
|
197
|
-
[data, items,
|
|
197
|
+
[data, items, pluginSummaries, pluginsLoading, pluginsError, reloadPlugins],
|
|
198
198
|
);
|
|
199
199
|
|
|
200
200
|
return <LibraryContext.Provider value={value}>{children}</LibraryContext.Provider>;
|
|
@@ -207,8 +207,8 @@ export function useLibrary(): LibraryContextValue {
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
/**
|
|
210
|
-
* How many of a
|
|
211
|
-
* sidebar row and the
|
|
210
|
+
* How many of a plugin's integrations need setup — the amber count on the
|
|
211
|
+
* sidebar row and the plugin page's banner, computed from one place so the two
|
|
212
212
|
* can never disagree.
|
|
213
213
|
*
|
|
214
214
|
* Only integrations count. A skill that reports `warn` is warning about the
|
|
@@ -216,8 +216,8 @@ export function useLibrary(): LibraryContextValue {
|
|
|
216
216
|
* broken connection; pending change requests are a review concern, not a setup
|
|
217
217
|
* one, and belong to a different surface.
|
|
218
218
|
*/
|
|
219
|
-
export function attentionOf(items: LibraryItem[],
|
|
219
|
+
export function attentionOf(items: LibraryItem[], plugin: string): number {
|
|
220
220
|
return items.filter(
|
|
221
|
-
(i) => i.
|
|
221
|
+
(i) => i.plugin === plugin && i.kind === 'integration' && i.status.state !== 'ok',
|
|
222
222
|
).length;
|
|
223
223
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Rendering people's names the way a person says them.
|
|
3
3
|
*
|
|
4
|
-
* Shared by the locked-
|
|
4
|
+
* Shared by the locked-plugin view (its request toast) and the owner-side
|
|
5
5
|
* access-requests banner: both list requesters, and two copies of this drifted
|
|
6
6
|
* into place once already.
|
|
7
7
|
*/
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
* The name of a person's own space — the prototype's `MINE()` (line 2078),
|
|
3
3
|
* which reads `me().name.split(' ')[0] + "'s List"`.
|
|
4
4
|
*
|
|
5
|
-
* It is called a
|
|
6
|
-
* the same page, the same sections, the same card grid as `
|
|
5
|
+
* It is called a PLUGIN here rather than a list because that is what it now is:
|
|
6
|
+
* the same page, the same sections, the same card grid as `Plugins/Engineering`.
|
|
7
7
|
* The only difference is which items it holds, and that is a query, not a kind.
|
|
8
8
|
*
|
|
9
|
-
* First name only, deliberately. "Juan's
|
|
10
|
-
* it out loud; "Juan Viera's
|
|
9
|
+
* First name only, deliberately. "Juan's Plugin" is what a colleague would call
|
|
10
|
+
* it out loud; "Juan Viera's Plugin" is what a directory would call it.
|
|
11
11
|
*/
|
|
12
|
-
export function
|
|
12
|
+
export function personalPluginName(displayName: string | null | undefined): string {
|
|
13
13
|
const first = displayFirstName(displayName);
|
|
14
14
|
// Nobody signed in, or a user record with no name: the space still exists and
|
|
15
15
|
// still needs a heading, and "Yours" is true for whoever is reading it.
|
|
16
16
|
if (!first) return 'Yours';
|
|
17
|
-
return `${first}'s
|
|
17
|
+
return `${first}'s Plugin`;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -23,11 +23,11 @@ export function personalGroupName(displayName: string | null | undefined): strin
|
|
|
23
23
|
* Sign-in records are not a style guide — an account created from a lowercase
|
|
24
24
|
* email or a hastily typed name should still be greeted the way a person
|
|
25
25
|
* writes their own name. The capital belongs HERE rather than at each call
|
|
26
|
-
* site, so the welcome page and the
|
|
26
|
+
* site, so the welcome page and the plugin heading cannot disagree about how
|
|
27
27
|
* to spell the same person.
|
|
28
28
|
*
|
|
29
29
|
* Empty when there is no name to work with, and each caller picks its own
|
|
30
|
-
* fallback: the
|
|
30
|
+
* fallback: the plugin heading says "Yours", the welcome page says "there".
|
|
31
31
|
*/
|
|
32
32
|
export function displayFirstName(displayName: string | null | undefined): string {
|
|
33
33
|
const first = (displayName ?? '').trim().split(/\s+/)[0] ?? '';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PluginPrincipals, PluginSummary } from '../services/plugins.api';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* How a
|
|
4
|
+
* How a plugin describes its membership in prose.
|
|
5
5
|
*
|
|
6
6
|
* Membership is displayed as ACCESS-RULE PRINCIPALS — the roles and people
|
|
7
7
|
* `access.md` names — and never as a head-count of who can read the folder.
|
|
@@ -9,7 +9,7 @@ import type { GroupPrincipals, GroupSummary } from '../services/groups.api';
|
|
|
9
9
|
*
|
|
10
10
|
* 1. Expanding a role to its people needs the roster endpoint, which is
|
|
11
11
|
* admin-gated. A per-person list would render for admins and vanish for
|
|
12
|
-
* everyone else, so the same
|
|
12
|
+
* everyone else, so the same plugin would describe itself differently
|
|
13
13
|
* depending on who asked.
|
|
14
14
|
* 2. Resolution is closeness-first with per-file overrides, so "who can read
|
|
15
15
|
* this folder" is not well-defined AT folder granularity. A person list
|
|
@@ -21,25 +21,25 @@ import type { GroupPrincipals, GroupSummary } from '../services/groups.api';
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
/** Names as written, users before roles — the order the run-by line reads in. */
|
|
24
|
-
function usersThenRoles(p:
|
|
24
|
+
function usersThenRoles(p: PluginPrincipals): string[] {
|
|
25
25
|
return [...p.users.map((u) => u.name), ...p.roles].filter((s) => s.length > 0);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/** Roles before people — the order a share list reads in. */
|
|
29
|
-
function rolesThenUsers(p:
|
|
29
|
+
function rolesThenUsers(p: PluginPrincipals): string[] {
|
|
30
30
|
return [...p.roles, ...p.users.map((u) => u.name)].filter((s) => s.length > 0);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* Who runs the
|
|
34
|
+
* Who runs the plugin: owners, falling back to writers, falling back to the
|
|
35
35
|
* admins.
|
|
36
36
|
*
|
|
37
37
|
* The writer fallback is not a guess — owner ⊂ writer, and "who runs it" is
|
|
38
38
|
* really "who can change it". The final fallback is a fact rather than a
|
|
39
39
|
* placeholder: admin-rescue guarantees a platform Admin can always write an
|
|
40
|
-
* `access.md`, so a
|
|
40
|
+
* `access.md`, so a plugin with no named principals genuinely is run by them.
|
|
41
41
|
*/
|
|
42
|
-
export function ownersTextOf(summary: Pick<
|
|
42
|
+
export function ownersTextOf(summary: Pick<PluginSummary, 'owners' | 'writers'>): string {
|
|
43
43
|
const owners = usersThenRoles(summary.owners);
|
|
44
44
|
if (owners.length > 0) return owners.join(', ');
|
|
45
45
|
const writers = usersThenRoles(summary.writers);
|
|
@@ -48,13 +48,13 @@ export function ownersTextOf(summary: Pick<GroupSummary, 'owners' | 'writers'>):
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
* Who the
|
|
52
|
-
* — either the reader list was withheld (the caller cannot read the
|
|
53
|
-
* a locked
|
|
51
|
+
* Who the plugin is shared with, or `null` when there is nothing honest to say
|
|
52
|
+
* — either the reader list was withheld (the caller cannot read the plugin, and
|
|
53
|
+
* a locked plugin never advertises its share list) or it resolved empty.
|
|
54
54
|
* Callers drop the whole `· shared with …` clause on null rather than printing
|
|
55
55
|
* a dangling half-sentence.
|
|
56
56
|
*/
|
|
57
|
-
export function readersTextOf(summary: Pick<
|
|
57
|
+
export function readersTextOf(summary: Pick<PluginSummary, 'readers'>): string | null {
|
|
58
58
|
const readers = summary.readers;
|
|
59
59
|
if (!readers) return null;
|
|
60
60
|
if (!readers.restricted) return 'everyone here';
|
|
@@ -62,7 +62,7 @@ export function readersTextOf(summary: Pick<GroupSummary, 'readers'>): string |
|
|
|
62
62
|
return named.length > 0 ? named.join(', ') : null;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
/** The folder a
|
|
66
|
-
export function primaryFolderOf(summary: Pick<
|
|
65
|
+
/** The folder a plugin's writes and links point at — its single `Plugins/<G>` folder. */
|
|
66
|
+
export function primaryFolderOf(summary: Pick<PluginSummary, 'folders'>): string | null {
|
|
67
67
|
return summary.folders[0] ?? null;
|
|
68
68
|
}
|