@bevel-software/platform-core-frontend 0.14.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/core/CoreAppShell.tsx +18 -17
- package/src/core/__tests__/bootstrap.test.ts +33 -1
- package/src/core/bootstrap.ts +30 -1
- package/src/lib/__tests__/api.test.ts +38 -0
- package/src/lib/api.ts +19 -2
- package/src/lib/utils.ts +2 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +111 -1
- package/src/modules/access/__tests__/plugin-token.test.ts +21 -0
- package/src/modules/access/api.ts +52 -4
- package/src/modules/access/components/ManageAccessDialog.tsx +112 -83
- package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +65 -1
- package/src/modules/git/components/GitSyncFailedBanner.tsx +68 -5
- package/src/modules/layout/components/SidebarFrame.tsx +1 -1
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +1 -1
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +1 -1
- package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +121 -0
- package/src/modules/library/__tests__/LockedPluginView.test.tsx +6 -0
- package/src/modules/library/__tests__/NewPluginDialog.test.tsx +5 -4
- package/src/modules/library/__tests__/PluginExtras.test.tsx +15 -0
- package/src/modules/library/__tests__/PluginPage.test.tsx +195 -1
- package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +1 -1
- package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +1 -1
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +64 -3
- package/src/modules/library/__tests__/SkillPage.test.tsx +9 -2
- package/src/modules/library/__tests__/SkillsTree.test.tsx +172 -0
- package/src/modules/library/__tests__/ToolPage.test.tsx +7 -0
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +115 -4
- package/src/modules/library/__tests__/library-data.stale.test.tsx +90 -0
- package/src/modules/library/__tests__/library-paths.test.ts +32 -0
- package/src/modules/library/__tests__/link-membership.test.ts +120 -0
- package/src/modules/library/__tests__/plugin-summary.test.ts +32 -0
- package/src/modules/library/__tests__/useJoinRequests.test.tsx +46 -0
- package/src/modules/library/components/AddToPluginDialog.tsx +33 -0
- package/src/modules/library/components/LibraryCard.tsx +14 -0
- package/src/modules/library/components/LibraryLayout.tsx +24 -14
- package/src/modules/library/components/LinkSkillPanel.tsx +171 -0
- package/src/modules/library/components/LockedPluginView.tsx +2 -2
- package/src/modules/library/components/NewPluginDialog.tsx +4 -4
- package/src/modules/library/components/PageActions.tsx +21 -1
- package/src/modules/library/components/PersonalPluginPage.tsx +2 -1
- package/src/modules/library/components/PluginExtras.tsx +3 -1
- package/src/modules/library/components/PluginPage.tsx +92 -12
- package/src/modules/library/components/PluginsIndexPage.tsx +11 -6
- package/src/modules/library/components/PluginsSidebar.tsx +110 -53
- package/src/modules/library/components/RenamePluginDialog.tsx +136 -0
- package/src/modules/library/components/SkillsTree.tsx +91 -0
- package/src/modules/library/components/StatusDot.tsx +1 -0
- package/src/modules/library/components/plugin-page-parts.tsx +32 -9
- package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +218 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +70 -6
- package/src/modules/library/components/tool-page/ToolPage.tsx +11 -2
- package/src/modules/library/hooks/useJoinRequests.ts +48 -18
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +180 -83
- package/src/modules/library/routes/library-paths.ts +21 -8
- package/src/modules/library/services/library.api.ts +55 -1
- package/src/modules/library/services/plugins.api.ts +94 -3
- package/src/modules/library/state/library-data.tsx +115 -22
- package/src/modules/library/utils/plugin-summary.ts +36 -0
- package/src/modules/library/utils/status.ts +74 -7
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +3 -2
- package/src/modules/settings/components/ClaudeConnectionCard.tsx +169 -0
- package/src/modules/settings/components/DeploymentPage.tsx +15 -1
- package/src/modules/settings/components/__tests__/ClaudeConnectionCard.test.tsx +63 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +10 -0
- package/src/modules/settings/services/github-facade.api.ts +43 -0
- package/src/modules/setup/__tests__/setup.test.tsx +118 -0
- package/src/modules/setup/components/SetupGate.tsx +1 -1
- package/src/modules/setup/components/SetupScreen.tsx +195 -2
- package/src/modules/setup/services/setup.api.ts +78 -0
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +295 -83
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +129 -6
- package/src/modules/toolbar/services/external-api-keys.api.ts +2 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +1 -0
- package/src/modules/workspace/components/FileExplorer.tsx +292 -236
- package/src/modules/workspace/components/FileRoute.tsx +37 -0
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +39 -0
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +1 -0
- package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +70 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +17 -3
- package/src/modules/workspace/routing/kb-routes.ts +1 -1
- package/src/modules/workspace/state/workspace.context.ts +8 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +15 -0
- package/src/modules/workspace/utils/fileTree.ts +14 -16
- package/src/shared/__tests__/marketplace-url.test.ts +54 -0
- package/src/shared/components/Badge.tsx +3 -1
- package/src/shared/components/Banner.tsx +5 -1
- package/src/shared/marketplace-url.ts +90 -0
- package/src/shared/theme/tokens.css +9 -0
|
@@ -1,21 +1,33 @@
|
|
|
1
|
+
import { PR_STALE_EVENT } from '../../../core/events';
|
|
1
2
|
import { useCallback, useContext, useEffect, useMemo, useState, type ReactNode, } from 'react';
|
|
2
3
|
import { LibraryContext } from './library-context';
|
|
3
|
-
import {
|
|
4
|
+
import { SKILLS_DIR } from '@bevel-software/platform-shared';
|
|
5
|
+
import { pluginNameForPath } from '../utils/plugin-summary';
|
|
6
|
+
import type { PluginMembership } from '../services/library.api';
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
|
-
* The plugin a card files under —
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* The plugin a card files under, by IDENTITY — the server's own answer for a
|
|
10
|
+
* skill it decorated (the inline membership), else the folder resolved
|
|
11
|
+
* through the plugin summaries (see `pluginNameForPath`). Personal folders
|
|
12
|
+
* map to `null`, the "yours alone" bucket: a personal folder is a place, not
|
|
13
|
+
* a plugin, and the only personal items a caller can ever read are their own.
|
|
11
14
|
*/
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
function pluginOfItem(
|
|
16
|
+
path: string,
|
|
17
|
+
memberships: readonly { name: string; linked: boolean }[] | undefined,
|
|
18
|
+
summaries: readonly PluginSummary[],
|
|
19
|
+
): string | null {
|
|
20
|
+
return memberships?.find((m) => !m.linked)?.name ?? pluginNameForPath(path, summaries);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Under the shared `Skills/` root — owned by a scope, not by a person or a plugin folder. */
|
|
24
|
+
function isSharedPath(path: string): boolean {
|
|
25
|
+
return path === SKILLS_DIR || path.startsWith(`${SKILLS_DIR}/`);
|
|
15
26
|
}
|
|
16
27
|
import { useLibraryData, type LibraryData } from '../hooks/useLibraryData';
|
|
17
28
|
import { listPlugins, type PluginSummary } from '../services/plugins.api';
|
|
18
29
|
import {
|
|
30
|
+
isInPlugin,
|
|
19
31
|
neededToolsFor,
|
|
20
32
|
skillStatus,
|
|
21
33
|
toolStatus,
|
|
@@ -48,6 +60,12 @@ export interface LibraryItem {
|
|
|
48
60
|
status: AttentionStatus;
|
|
49
61
|
/** Folder plugin from the KB path, or null when the item is in none. */
|
|
50
62
|
plugin: string | null;
|
|
63
|
+
/** Under the shared `Skills/` root — see `LibraryFilterable.shared`. */
|
|
64
|
+
shared?: boolean;
|
|
65
|
+
/** Every plugin holding a skill, inline or linked (skills only). */
|
|
66
|
+
plugins?: PluginMembership[];
|
|
67
|
+
/** A skill's governance lifecycle (`metadata.lifecycle`), when declared. */
|
|
68
|
+
lifecycle?: string;
|
|
51
69
|
/** Repo-root-relative path — the skill's folder, or the `.tool` file. */
|
|
52
70
|
path: string;
|
|
53
71
|
/**
|
|
@@ -86,6 +104,7 @@ export interface LibraryContextValue extends LibraryData {
|
|
|
86
104
|
|
|
87
105
|
export function LibraryProvider({ children }: { children: ReactNode }) {
|
|
88
106
|
const data = useLibraryData();
|
|
107
|
+
const { reload } = data;
|
|
89
108
|
const [pluginSummaries, setPluginSummaries] = useState<PluginSummary[]>([]);
|
|
90
109
|
const [pluginsLoading, setPluginsLoading] = useState(true);
|
|
91
110
|
const [pluginsError, setPluginsError] = useState<string | null>(null);
|
|
@@ -120,7 +139,10 @@ export function LibraryProvider({ children }: { children: ReactNode }) {
|
|
|
120
139
|
name: s.name,
|
|
121
140
|
description: s.description,
|
|
122
141
|
owned: data.ownedSkills.has(s.name),
|
|
123
|
-
plugin:
|
|
142
|
+
plugin: pluginOfItem(s.path, s.plugins, pluginSummaries),
|
|
143
|
+
shared: isSharedPath(s.path),
|
|
144
|
+
plugins: s.plugins ?? [],
|
|
145
|
+
lifecycle: s.lifecycle,
|
|
124
146
|
path: s.path,
|
|
125
147
|
version: s.version,
|
|
126
148
|
status: skillStatus(
|
|
@@ -144,7 +166,8 @@ export function LibraryProvider({ children }: { children: ReactNode }) {
|
|
|
144
166
|
name: s.name,
|
|
145
167
|
description: s.description,
|
|
146
168
|
owned: false,
|
|
147
|
-
plugin:
|
|
169
|
+
plugin: pluginOfItem(s.path, undefined, pluginSummaries),
|
|
170
|
+
shared: isSharedPath(s.path),
|
|
148
171
|
path: s.path,
|
|
149
172
|
version: s.version,
|
|
150
173
|
status: { state: 'ok', text: 'In review' },
|
|
@@ -163,7 +186,7 @@ export function LibraryProvider({ children }: { children: ReactNode }) {
|
|
|
163
186
|
// manual yet (see report) — the card stays clean; detail lives behind it.
|
|
164
187
|
description: '',
|
|
165
188
|
owned: t.canWrite,
|
|
166
|
-
plugin:
|
|
189
|
+
plugin: pluginOfItem(t.path, undefined, pluginSummaries),
|
|
167
190
|
path: t.path,
|
|
168
191
|
status: toolStatus(t),
|
|
169
192
|
}));
|
|
@@ -174,6 +197,7 @@ export function LibraryProvider({ children }: { children: ReactNode }) {
|
|
|
174
197
|
data.tools,
|
|
175
198
|
data.ownedSkills,
|
|
176
199
|
data.allowedToolsBySkill,
|
|
200
|
+
pluginSummaries,
|
|
177
201
|
]);
|
|
178
202
|
|
|
179
203
|
// The loading flag is raised HERE rather than in the effect: `useState(true)`
|
|
@@ -185,16 +209,39 @@ export function LibraryProvider({ children }: { children: ReactNode }) {
|
|
|
185
209
|
setPluginsRevision((r) => r + 1);
|
|
186
210
|
}, []);
|
|
187
211
|
|
|
212
|
+
// ONE reload for the whole Library. The plugin summaries carry counts and
|
|
213
|
+
// verdicts derived from the same knowledge base as the catalog — how many
|
|
214
|
+
// skills a plugin holds, how many of its links are broken, who may read
|
|
215
|
+
// it — so a page that refreshes the catalog after a link, a repair or an
|
|
216
|
+
// access edit must refresh the summaries too, or the sidebar count and the
|
|
217
|
+
// plugin page's banner keep the number from before the change.
|
|
218
|
+
const reloadAll = useCallback(() => {
|
|
219
|
+
reload();
|
|
220
|
+
reloadPlugins();
|
|
221
|
+
}, [reload, reloadPlugins]);
|
|
222
|
+
|
|
223
|
+
// The catalog carries its own view of open change requests (proposals,
|
|
224
|
+
// review boxes). The shell's change-request provider refreshes on this
|
|
225
|
+
// event; so does the whole Library, or the two would disagree after a
|
|
226
|
+
// proposal lands or is resolved — and a merged change can move plugin
|
|
227
|
+
// links and access, so the summaries refresh with the catalog here too.
|
|
228
|
+
useEffect(() => {
|
|
229
|
+
const onStale = () => reloadAll();
|
|
230
|
+
window.addEventListener(PR_STALE_EVENT, onStale);
|
|
231
|
+
return () => window.removeEventListener(PR_STALE_EVENT, onStale);
|
|
232
|
+
}, [reloadAll]);
|
|
233
|
+
|
|
188
234
|
const value = useMemo(
|
|
189
235
|
(): LibraryContextValue => ({
|
|
190
236
|
...data,
|
|
237
|
+
reload: reloadAll,
|
|
191
238
|
items,
|
|
192
239
|
pluginSummaries,
|
|
193
240
|
pluginsLoading,
|
|
194
241
|
pluginsError,
|
|
195
242
|
reloadPlugins,
|
|
196
243
|
}),
|
|
197
|
-
[data, items, pluginSummaries, pluginsLoading, pluginsError, reloadPlugins],
|
|
244
|
+
[data, reloadAll, items, pluginSummaries, pluginsLoading, pluginsError, reloadPlugins],
|
|
198
245
|
);
|
|
199
246
|
|
|
200
247
|
return <LibraryContext.Provider value={value}>{children}</LibraryContext.Provider>;
|
|
@@ -228,17 +275,63 @@ export function workspaceHasNoPlugins(lib: LibraryContextValue): boolean {
|
|
|
228
275
|
}
|
|
229
276
|
|
|
230
277
|
/**
|
|
231
|
-
* How
|
|
232
|
-
*
|
|
233
|
-
* can never disagree.
|
|
278
|
+
* How much of a plugin needs a person — the count on the sidebar row, the
|
|
279
|
+
* index badge and the plugin page's banners, computed from one place so they
|
|
280
|
+
* can never disagree. Two kinds, added together:
|
|
281
|
+
*
|
|
282
|
+
* - integrations that need setup (`brokenLinksOf` subtracted from this
|
|
283
|
+
* gives that number alone);
|
|
284
|
+
* - linked skills the plugin's members cannot read (`brokenLinksOf`).
|
|
285
|
+
*
|
|
286
|
+
* A skill that reports `warn` about a tool is NOT counted: it is warning
|
|
287
|
+
* about the very integration already counted here, so counting both would
|
|
288
|
+
* double every broken connection. Pending change requests are a review
|
|
289
|
+
* concern, not a setup one, and belong to a different surface.
|
|
290
|
+
*/
|
|
291
|
+
export interface PluginAttention {
|
|
292
|
+
/** Everything that needs a person: integrations to set up plus broken links. */
|
|
293
|
+
total: number;
|
|
294
|
+
/** The broken-link part alone — what turns the count orange. */
|
|
295
|
+
brokenLinks: number;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export function attentionOf(
|
|
299
|
+
items: LibraryItem[],
|
|
300
|
+
plugin: string,
|
|
301
|
+
summaries: readonly Pick<PluginSummary, 'name' | 'brokenLinks'>[] = [],
|
|
302
|
+
): PluginAttention {
|
|
303
|
+
// One pass for the links, returned beside the total: every caller wants
|
|
304
|
+
// both, and computing the part again for the tone would filter the whole
|
|
305
|
+
// catalog a second time per plugin.
|
|
306
|
+
const brokenLinks = brokenLinksOf(items, plugin, summaries);
|
|
307
|
+
const integrations = items.filter(
|
|
308
|
+
(i) => isInPlugin(i, plugin) && i.kind === 'integration' && i.status.state !== 'ok',
|
|
309
|
+
).length;
|
|
310
|
+
return { total: integrations + brokenLinks, brokenLinks };
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* How many of `plugin`'s LINKED skills its members cannot read: the link is
|
|
315
|
+
* in the manifest but the skill folder no longer grants the plugin's readers.
|
|
316
|
+
* Counted apart from the integrations because it is a different kind of
|
|
317
|
+
* problem — a tool that needs setup blocks the reader's own use; a link
|
|
318
|
+
* without its grant blocks every member of the plugin, right now — and the
|
|
319
|
+
* sidebar and the plugin page rank it above amber for that reason.
|
|
234
320
|
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
321
|
+
* The SERVER's count wins when the summary carries one: it comes from the
|
|
322
|
+
* unfiltered link index, so a manager whom the missing grant locks out of
|
|
323
|
+
* the skill still sees it. The caller's own catalog is only the fallback for
|
|
324
|
+
* an older server — it cannot list a skill the caller may not read, which is
|
|
325
|
+
* exactly the skill this is about.
|
|
239
326
|
*/
|
|
240
|
-
export function
|
|
327
|
+
export function brokenLinksOf(
|
|
328
|
+
items: LibraryItem[],
|
|
329
|
+
plugin: string,
|
|
330
|
+
summaries: readonly Pick<PluginSummary, 'name' | 'brokenLinks'>[] = [],
|
|
331
|
+
): number {
|
|
332
|
+
const served = summaries.find((s) => s.name === plugin)?.brokenLinks;
|
|
333
|
+
if (served !== undefined) return served;
|
|
241
334
|
return items.filter(
|
|
242
|
-
(i) => i.
|
|
335
|
+
(i) => i.kind === 'skill' && (i.plugins ?? []).some((m) => m.name === plugin && m.linked && m.granted === false),
|
|
243
336
|
).length;
|
|
244
337
|
}
|
|
@@ -1,5 +1,41 @@
|
|
|
1
|
+
import { isPersonalPluginFolder, pluginOfPath } from '@bevel-software/platform-shared';
|
|
1
2
|
import type { PluginPrincipals, PluginSummary } from '../services/plugins.api';
|
|
2
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The plugin a repository path sits in, by IDENTITY: the summary whose
|
|
6
|
+
* folder holds the path (deepest wins, so a nested plugin beats the scope
|
|
7
|
+
* around it). Before the summaries have loaded — or for a path under a
|
|
8
|
+
* folder the catalog does not list — the folder name stands in, which is
|
|
9
|
+
* what every plugin was called before the manifest became the identity. A
|
|
10
|
+
* personal folder is a place, not a plugin: null.
|
|
11
|
+
*/
|
|
12
|
+
export function pluginNameForPath(
|
|
13
|
+
repoPath: string,
|
|
14
|
+
summaries: readonly Pick<PluginSummary, 'name' | 'folders'>[],
|
|
15
|
+
): string | null {
|
|
16
|
+
const folder = pluginOfPath(repoPath);
|
|
17
|
+
if (folder === null) return null;
|
|
18
|
+
// The catalog is the authority: whatever folder it lists as holding the
|
|
19
|
+
// path names the plugin. Only a path no listed folder holds falls back to
|
|
20
|
+
// the folder name — and a personal shelf, which the catalog never lists,
|
|
21
|
+
// to null.
|
|
22
|
+
let best: { name: string; length: number } | null = null;
|
|
23
|
+
for (const s of summaries) {
|
|
24
|
+
for (const f of s.folders) {
|
|
25
|
+
if ((repoPath === f || repoPath.startsWith(`${f}/`)) && (!best || f.length > best.length)) {
|
|
26
|
+
best = { name: s.name, length: f.length };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (best) return best.name;
|
|
31
|
+
return isPersonalPluginFolder(folder) ? null : folder;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** What a plugin is called on screen — its display name, else its identity. */
|
|
35
|
+
export function pluginLabel(name: string, summaries: readonly Pick<PluginSummary, 'name' | 'displayName'>[]): string {
|
|
36
|
+
return summaries.find((s) => s.name === name)?.displayName || name;
|
|
37
|
+
}
|
|
38
|
+
|
|
3
39
|
/**
|
|
4
40
|
* How a plugin describes its membership in prose.
|
|
5
41
|
*
|
|
@@ -12,15 +12,20 @@ import type { ProbeVerdict, ToolSecrets, ToolVarStatus } from '../../secrets-vau
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Four states, and no fifth.
|
|
16
16
|
*
|
|
17
17
|
* There used to be an `off` — "not set up yet", drawn in grey. Grey reads as
|
|
18
18
|
* *disabled*, or as *not your problem*: an unconfigured integration looked like
|
|
19
19
|
* furniture next to the amber ones, when in fact it is the state that most
|
|
20
20
|
* needs somebody. Anything that needs a person is amber; anything that was
|
|
21
21
|
* working and stopped is red. Nothing that needs a person is grey.
|
|
22
|
+
*
|
|
23
|
+
* `urgent` sits between the two: it needs a person, like amber, but it is
|
|
24
|
+
* blocking OTHER people right now — a plugin's members locked out of a skill
|
|
25
|
+
* it ships — where amber blocks only the reader's own use. Orange, the same
|
|
26
|
+
* colour the sidebar count turns for it, so the card and the count agree.
|
|
22
27
|
*/
|
|
23
|
-
export type GemState = 'ok' | 'warn' | 'err';
|
|
28
|
+
export type GemState = 'ok' | 'warn' | 'urgent' | 'err';
|
|
24
29
|
|
|
25
30
|
export interface AttentionStatus {
|
|
26
31
|
state: GemState;
|
|
@@ -55,7 +60,7 @@ const SIGNED_IN: AttentionStatus = { state: 'ok', text: 'Signed in' };
|
|
|
55
60
|
const KEY_SAVED: AttentionStatus = { state: 'ok', text: 'Key saved' };
|
|
56
61
|
|
|
57
62
|
/** Severity order for aggregation: broken sign-in beats anything merely unset. */
|
|
58
|
-
const RANK: Record<GemState, number> = { ok: 0, warn: 1,
|
|
63
|
+
const RANK: Record<GemState, number> = { ok: 0, warn: 1, urgent: 2, err: 3 };
|
|
59
64
|
|
|
60
65
|
/**
|
|
61
66
|
* What ONE variable is: in place, or `Needs <the thing>`.
|
|
@@ -241,6 +246,67 @@ export interface LibraryFilterable {
|
|
|
241
246
|
owned: boolean;
|
|
242
247
|
/** Folder plugin from the item's KB path, or null when it sits in none. */
|
|
243
248
|
plugin: string | null;
|
|
249
|
+
/**
|
|
250
|
+
* Lives under the shared `Skills/` root rather than in a plugin folder.
|
|
251
|
+
* Such an item has no folder plugin, but it is not "yours alone" either —
|
|
252
|
+
* it is owned by a scope and shared into plugins by link — so the
|
|
253
|
+
* ungrouped view leaves it out and only the catalog-wide view lists it.
|
|
254
|
+
*/
|
|
255
|
+
shared?: boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Every plugin the item belongs to, inline or by link. `plugin` above is the
|
|
258
|
+
* FOLDER plugin only (routing, "yours alone"); this is what the plugin
|
|
259
|
+
* page and the sidebar counts go by.
|
|
260
|
+
*/
|
|
261
|
+
plugins?: { name: string }[];
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** "Yours alone": in no plugin folder AND not a shared skill. */
|
|
265
|
+
export function isUngrouped(item: Pick<LibraryFilterable, 'plugin' | 'shared'>): boolean {
|
|
266
|
+
return item.plugin === null && !item.shared;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** Whether an item belongs to `plugin` — by folder, or by a link from the plugin's manifest. */
|
|
270
|
+
export function isInPlugin(item: Pick<LibraryFilterable, 'plugin' | 'plugins'>, plugin: string): boolean {
|
|
271
|
+
return item.plugin === plugin || (item.plugins?.some((m) => m.name === plugin) ?? false);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* The item as the plugin page should show it: a LINK whose grant is missing
|
|
276
|
+
* gets the note in the tools' grammar — "Needs setup", and "share with plugin
|
|
277
|
+
* members" for someone who can edit the skill's rules — because until the
|
|
278
|
+
* grant is back, the plugin's members cannot read it. In ORANGE (`urgent`),
|
|
279
|
+
* not amber: it locks other people out, and the sidebar count for the plugin
|
|
280
|
+
* is the same colour. Healthy links are untouched.
|
|
281
|
+
*/
|
|
282
|
+
export function withLinkHealth<T extends LibraryFilterable & { status: AttentionStatus }>(
|
|
283
|
+
item: T,
|
|
284
|
+
plugin: string,
|
|
285
|
+
): T {
|
|
286
|
+
const membership = (item.plugins as { name: string; linked?: boolean; granted?: boolean }[] | undefined)?.find(
|
|
287
|
+
(m) => m.name === plugin,
|
|
288
|
+
);
|
|
289
|
+
if (!membership?.linked || membership.granted !== false) return item;
|
|
290
|
+
// One amber note at a time, and the card's own comes first: a skill whose
|
|
291
|
+
// tools need setup, or one under review, already says what to do — the
|
|
292
|
+
// broken link is reported once that is settled, not in its place.
|
|
293
|
+
if (item.status.state !== 'ok') return item;
|
|
294
|
+
return {
|
|
295
|
+
...item,
|
|
296
|
+
status: {
|
|
297
|
+
state: 'urgent',
|
|
298
|
+
text: item.owned ? 'Needs setup: share with plugin members' : 'Needs setup',
|
|
299
|
+
hint: `The skill's access rules no longer name ${plugin}'s members. Repair the link from the skill page.`,
|
|
300
|
+
},
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** The distinct plugin names an item belongs to. */
|
|
305
|
+
export function pluginsOfItem(item: Pick<LibraryFilterable, 'plugin' | 'plugins'>): string[] {
|
|
306
|
+
const names = new Set<string>();
|
|
307
|
+
if (item.plugin !== null) names.add(item.plugin);
|
|
308
|
+
for (const m of item.plugins ?? []) names.add(m.name);
|
|
309
|
+
return [...names];
|
|
244
310
|
}
|
|
245
311
|
|
|
246
312
|
/** Sidebar selection narrows; the query matches name/description within it. */
|
|
@@ -260,9 +326,9 @@ export function filterLibraryItems<T extends LibraryFilterable>(
|
|
|
260
326
|
case 'owned':
|
|
261
327
|
return item.owned;
|
|
262
328
|
case 'group':
|
|
263
|
-
return item
|
|
329
|
+
return isInPlugin(item, filter.plugin);
|
|
264
330
|
case 'ungrouped':
|
|
265
|
-
return item
|
|
331
|
+
return isUngrouped(item);
|
|
266
332
|
}
|
|
267
333
|
});
|
|
268
334
|
}
|
|
@@ -279,8 +345,9 @@ export function pluginCounts<T extends LibraryFilterable>(
|
|
|
279
345
|
): { plugin: string; count: number }[] {
|
|
280
346
|
const counts = new Map<string, number>();
|
|
281
347
|
for (const item of items) {
|
|
282
|
-
|
|
283
|
-
|
|
348
|
+
// A linked skill counts for every plugin that links it, like the plugin
|
|
349
|
+
// index's own totals.
|
|
350
|
+
for (const name of pluginsOfItem(item)) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
284
351
|
}
|
|
285
352
|
return [...counts.entries()]
|
|
286
353
|
.map(([plugin, count]) => ({ plugin, count }))
|
|
@@ -136,7 +136,7 @@ beforeEach(() => {
|
|
|
136
136
|
resetOnboardingForTests();
|
|
137
137
|
setSidebarCollapsed(false, true);
|
|
138
138
|
serviceMocks.createPlugin.mockReset();
|
|
139
|
-
serviceMocks.createPlugin.mockResolvedValue({ folder: 'Design' });
|
|
139
|
+
serviceMocks.createPlugin.mockResolvedValue({ folder: 'Design', name: 'design' });
|
|
140
140
|
serviceMocks.createEmptySkill.mockReset();
|
|
141
141
|
serviceMocks.createEmptySkill.mockResolvedValue({
|
|
142
142
|
repoRelativePath: 'Plugins/personal-u1/weekly-report/SKILL.md',
|
|
@@ -249,8 +249,9 @@ describe('creator welcome actions', () => {
|
|
|
249
249
|
// indexes -> navigate), so it is the settled state to wait for; asserting
|
|
250
250
|
// it immediately races the refresh microtasks and flakes under CI load.
|
|
251
251
|
await waitFor(() =>
|
|
252
|
+
// The new plugin's page is addressed by its identity, not its folder.
|
|
252
253
|
expect(screen.getByLabelText('pathname')).toHaveTextContent(
|
|
253
|
-
'/skills-and-tools/plugins/
|
|
254
|
+
'/skills-and-tools/plugins/design',
|
|
254
255
|
),
|
|
255
256
|
);
|
|
256
257
|
expect(data.reload).toHaveBeenCalledOnce();
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Banner, Button } from '../../../shared/components';
|
|
3
|
+
import { Dialog } from '../../../shared/components/Dialog';
|
|
4
|
+
import { CopyBlock } from '../../../shared/mcp';
|
|
5
|
+
import {
|
|
6
|
+
fetchGitHubFacade,
|
|
7
|
+
rotateGitHubFacade,
|
|
8
|
+
type GitHubFacadeCredentials,
|
|
9
|
+
} from '../services/github-facade.api';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The admin's half of "add this marketplace in Cowork or claude.ai".
|
|
13
|
+
*
|
|
14
|
+
* Those surfaces sync marketplaces only from hosts they know, and the one
|
|
15
|
+
* kind of host an organization can add itself is a GitHub Enterprise Server.
|
|
16
|
+
* Hexis presents itself as one: an Owner registers this deployment once in
|
|
17
|
+
* Claude's admin settings, pasting the fields below, and from then on every
|
|
18
|
+
* person connects their own claude.ai account through the ordinary hexis
|
|
19
|
+
* sign-in and gets the marketplace compiled for what they may read.
|
|
20
|
+
*
|
|
21
|
+
* The fields are exactly the ones the "Add manually" form asks for, in its
|
|
22
|
+
* order, so the card reads as a copy source, not a form of its own. Rotate
|
|
23
|
+
* replaces the generated ones: the registration on the Claude side stops
|
|
24
|
+
* matching until an Owner re-enters them, while people's existing
|
|
25
|
+
* connections — connection keys, ours — keep working.
|
|
26
|
+
*
|
|
27
|
+
* What is on screen is always the LATEST answer the server gave: a load
|
|
28
|
+
* that was in flight when a rotation returned is discarded, never applied
|
|
29
|
+
* over the new set — an admin copying pre-rotation values into Claude would
|
|
30
|
+
* register a secret that no longer exists.
|
|
31
|
+
*/
|
|
32
|
+
export function ClaudeConnectionCard() {
|
|
33
|
+
const [creds, setCreds] = useState<GitHubFacadeCredentials | null>(null);
|
|
34
|
+
const [error, setError] = useState<string | null>(null);
|
|
35
|
+
const [loaded, setLoaded] = useState(false);
|
|
36
|
+
const [confirmRotate, setConfirmRotate] = useState(false);
|
|
37
|
+
const [rotating, setRotating] = useState(false);
|
|
38
|
+
const [rotateError, setRotateError] = useState<string | null>(null);
|
|
39
|
+
// Every request takes a number; only the newest one's answer is applied.
|
|
40
|
+
const latest = useRef(0);
|
|
41
|
+
|
|
42
|
+
const refresh = useCallback(() => {
|
|
43
|
+
const seq = ++latest.current;
|
|
44
|
+
fetchGitHubFacade()
|
|
45
|
+
.then((c) => {
|
|
46
|
+
if (seq !== latest.current) return;
|
|
47
|
+
setCreds(c);
|
|
48
|
+
setError(null);
|
|
49
|
+
})
|
|
50
|
+
.catch((err: unknown) => {
|
|
51
|
+
if (seq !== latest.current) return;
|
|
52
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
53
|
+
})
|
|
54
|
+
.finally(() => {
|
|
55
|
+
if (seq === latest.current) setLoaded(true);
|
|
56
|
+
});
|
|
57
|
+
}, []);
|
|
58
|
+
|
|
59
|
+
useEffect(refresh, [refresh]);
|
|
60
|
+
|
|
61
|
+
const rotate = async () => {
|
|
62
|
+
const seq = ++latest.current;
|
|
63
|
+
setRotating(true);
|
|
64
|
+
setRotateError(null);
|
|
65
|
+
try {
|
|
66
|
+
const next = await rotateGitHubFacade();
|
|
67
|
+
if (seq !== latest.current) return;
|
|
68
|
+
setCreds(next);
|
|
69
|
+
setError(null);
|
|
70
|
+
setConfirmRotate(false);
|
|
71
|
+
} catch (err) {
|
|
72
|
+
// Inside the dialog, where the person is looking — not behind its scrim.
|
|
73
|
+
if (seq === latest.current) setRotateError(err instanceof Error ? err.message : String(err));
|
|
74
|
+
} finally {
|
|
75
|
+
setRotating(false);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const closeRotate = () => {
|
|
80
|
+
setConfirmRotate(false);
|
|
81
|
+
setRotateError(null);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<section aria-labelledby="claude-connection-heading" className="space-y-3">
|
|
86
|
+
<div>
|
|
87
|
+
<h2 id="claude-connection-heading" className="text-title font-semibold text-ink">
|
|
88
|
+
Claude connection
|
|
89
|
+
</h2>
|
|
90
|
+
<p className="mt-1 text-xs text-ink-muted leading-snug">
|
|
91
|
+
Lets people add this deployment's skills marketplace in Cowork and on claude.ai, which
|
|
92
|
+
accept marketplaces only from a GitHub Enterprise Server their organization registered.
|
|
93
|
+
Hexis answers as one. Register it once (Owner role, Team or Enterprise plan): in Claude's
|
|
94
|
+
admin settings, under Claude Code, GitHub Enterprise Server, choose <b>Add manually</b>{' '}
|
|
95
|
+
and paste the fields below. When it asks you to connect your GitHub Enterprise account,
|
|
96
|
+
you sign in here.
|
|
97
|
+
</p>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
{!loaded && <div className="text-xs text-ink-muted">Loading…</div>}
|
|
101
|
+
|
|
102
|
+
{error && (
|
|
103
|
+
<Banner tone="danger" role="alert">
|
|
104
|
+
{error}
|
|
105
|
+
<Button variant="outline" size="sm" className="ml-3" onClick={refresh}>
|
|
106
|
+
Try again
|
|
107
|
+
</Button>
|
|
108
|
+
</Banner>
|
|
109
|
+
)}
|
|
110
|
+
|
|
111
|
+
{creds && (
|
|
112
|
+
<div className="border border-line rounded p-3 space-y-3">
|
|
113
|
+
<CopyBlock label="Hostname" value={creds.host} rows={1} />
|
|
114
|
+
<CopyBlock label="App ID" value={creds.appId} rows={1} />
|
|
115
|
+
<CopyBlock label="Client ID" value={creds.clientId} rows={1} />
|
|
116
|
+
<CopyBlock label="Client secret" value={creds.clientSecret} rows={1} />
|
|
117
|
+
<CopyBlock label="Webhook secret" value={creds.webhookSecret} rows={1} />
|
|
118
|
+
<CopyBlock label="Private key" value={creds.privateKeyPem} rows={6} />
|
|
119
|
+
<p className="text-meta text-ink-muted leading-snug">
|
|
120
|
+
The webhook URL Claude generates after saving can be ignored: nothing here sends
|
|
121
|
+
webhooks yet. The private key is required by the form but not used by the
|
|
122
|
+
user-added marketplace flow.
|
|
123
|
+
</p>
|
|
124
|
+
<CopyBlock label="Marketplace URL people add" value={creds.marketplaceUrl} rows={1} />
|
|
125
|
+
<div className="flex items-center justify-between gap-3">
|
|
126
|
+
<span className="text-meta text-ink-muted">
|
|
127
|
+
{creds.rotatedAt
|
|
128
|
+
? `Rotated ${new Date(creds.rotatedAt).toLocaleString()}`
|
|
129
|
+
: `Generated ${new Date(creds.createdAt).toLocaleString()}`}
|
|
130
|
+
</span>
|
|
131
|
+
<Button variant="outline" size="sm" onClick={() => setConfirmRotate(true)}>
|
|
132
|
+
Rotate credentials
|
|
133
|
+
</Button>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
)}
|
|
137
|
+
|
|
138
|
+
<Dialog
|
|
139
|
+
open={confirmRotate}
|
|
140
|
+
onClose={closeRotate}
|
|
141
|
+
title="Rotate the Claude connection credentials?"
|
|
142
|
+
size="sm"
|
|
143
|
+
busy={rotating}
|
|
144
|
+
footer={
|
|
145
|
+
<>
|
|
146
|
+
<Button variant="outline" size="sm" onClick={closeRotate} disabled={rotating}>
|
|
147
|
+
Cancel
|
|
148
|
+
</Button>
|
|
149
|
+
<Button variant="danger" size="sm" onClick={() => void rotate()} disabled={rotating}>
|
|
150
|
+
{rotating ? 'Rotating…' : rotateError ? 'Try again' : 'Rotate'}
|
|
151
|
+
</Button>
|
|
152
|
+
</>
|
|
153
|
+
}
|
|
154
|
+
>
|
|
155
|
+
<p className="text-sm text-ink">
|
|
156
|
+
The App ID, Client ID, client secret, webhook secret and private key change; the
|
|
157
|
+
hostname and the marketplace URL stay the same. The registration in Claude's admin
|
|
158
|
+
settings stops working until an Owner enters the new values there. People who already
|
|
159
|
+
connected keep their connection.
|
|
160
|
+
</p>
|
|
161
|
+
{rotateError && (
|
|
162
|
+
<Banner tone="danger" role="alert" className="mt-3">
|
|
163
|
+
{rotateError}
|
|
164
|
+
</Banner>
|
|
165
|
+
)}
|
|
166
|
+
</Dialog>
|
|
167
|
+
</section>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
@@ -4,6 +4,7 @@ import { Banner, Button } from '../../../shared/components';
|
|
|
4
4
|
import { useAdmin } from '../../admin/state/admin.context';
|
|
5
5
|
import { fetchSetupStatus, type SetupStatus } from '../../setup/services/setup.api';
|
|
6
6
|
import { SetupScreen } from '../../setup/components/SetupScreen';
|
|
7
|
+
import { ClaudeConnectionCard } from './ClaudeConnectionCard';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Deployment settings, routed at `/deployment` — the first-run setup screen
|
|
@@ -82,7 +83,20 @@ export function DeploymentPage() {
|
|
|
82
83
|
|
|
83
84
|
{loaded && status?.settings && (
|
|
84
85
|
<div className="mt-6">
|
|
85
|
-
<SetupScreen
|
|
86
|
+
<SetupScreen
|
|
87
|
+
settings={status.settings}
|
|
88
|
+
sync={status.sync}
|
|
89
|
+
onSaved={refresh}
|
|
90
|
+
variant="settings"
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
)}
|
|
94
|
+
|
|
95
|
+
{/* Below the settings form, not inside it: these are generated, not
|
|
96
|
+
typed — a copy source for Claude's admin settings, with one verb. */}
|
|
97
|
+
{loaded && status?.settings && (
|
|
98
|
+
<div className="mt-10">
|
|
99
|
+
<ClaudeConnectionCard />
|
|
86
100
|
</div>
|
|
87
101
|
)}
|
|
88
102
|
</PageShell>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { ClaudeConnectionCard } from '../ClaudeConnectionCard';
|
|
5
|
+
|
|
6
|
+
const { fetchMock, rotateMock } = vi.hoisted(() => ({ fetchMock: vi.fn(), rotateMock: vi.fn() }));
|
|
7
|
+
vi.mock('../../services/github-facade.api', () => ({
|
|
8
|
+
fetchGitHubFacade: fetchMock,
|
|
9
|
+
rotateGitHubFacade: rotateMock,
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
const CREDS = {
|
|
13
|
+
host: 'kb.acme.com',
|
|
14
|
+
appId: '123456',
|
|
15
|
+
clientId: 'Iv1.0123456789abcdef',
|
|
16
|
+
clientSecret: 'secret-1',
|
|
17
|
+
webhookSecret: 'hook-1',
|
|
18
|
+
privateKeyPem: '-----BEGIN RSA PRIVATE KEY-----\nabc\n-----END RSA PRIVATE KEY-----\n',
|
|
19
|
+
marketplaceUrl: 'https://kb.acme.com/git/marketplace.git',
|
|
20
|
+
createdAt: Date.UTC(2026, 8, 7),
|
|
21
|
+
rotatedAt: null,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
fetchMock.mockReset().mockResolvedValue(CREDS);
|
|
26
|
+
rotateMock.mockReset().mockResolvedValue({ ...CREDS, clientId: 'Iv1.fedcba9876543210', clientSecret: 'secret-2', rotatedAt: Date.now() });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
/** Every textarea's value — the card is a copy source, so its values are its contract. */
|
|
30
|
+
const values = () => screen.getAllByRole('textbox').map((el) => (el as HTMLTextAreaElement).value);
|
|
31
|
+
|
|
32
|
+
describe('ClaudeConnectionCard', () => {
|
|
33
|
+
it("shows every field Claude's Add-manually form asks for, plus the URL people add", async () => {
|
|
34
|
+
render(<ClaudeConnectionCard />);
|
|
35
|
+
await screen.findByText('Hostname');
|
|
36
|
+
const shown = values();
|
|
37
|
+
for (const v of [CREDS.host, CREDS.appId, CREDS.clientId, CREDS.clientSecret, CREDS.webhookSecret, CREDS.privateKeyPem, CREDS.marketplaceUrl]) {
|
|
38
|
+
expect(shown).toContain(v);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('rotates only after a confirmation, and shows the new set', async () => {
|
|
43
|
+
const user = userEvent.setup();
|
|
44
|
+
render(<ClaudeConnectionCard />);
|
|
45
|
+
await screen.findByText('Hostname');
|
|
46
|
+
await user.click(screen.getByRole('button', { name: 'Rotate credentials' }));
|
|
47
|
+
expect(rotateMock).not.toHaveBeenCalled();
|
|
48
|
+
await user.click(screen.getByRole('button', { name: 'Rotate' }));
|
|
49
|
+
await waitFor(() => expect(rotateMock).toHaveBeenCalledTimes(1));
|
|
50
|
+
await waitFor(() => expect(values()).toContain('secret-2'));
|
|
51
|
+
expect(values()).not.toContain('secret-1');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('says what went wrong and offers a retry', async () => {
|
|
55
|
+
fetchMock.mockRejectedValueOnce(new Error('SECRETS_ENC_KEY is not set, so the Claude connection credentials cannot be stored.'));
|
|
56
|
+
const user = userEvent.setup();
|
|
57
|
+
render(<ClaudeConnectionCard />);
|
|
58
|
+
const alert = await screen.findByRole('alert');
|
|
59
|
+
expect(alert).toHaveTextContent('SECRETS_ENC_KEY');
|
|
60
|
+
await user.click(screen.getByRole('button', { name: 'Try again' }));
|
|
61
|
+
await screen.findByText('Hostname');
|
|
62
|
+
});
|
|
63
|
+
});
|