@bevel-software/platform-core-frontend 0.7.5 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/core/registry.ts +16 -4
- 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/admin/state/admin.context.tsx +15 -0
- 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} +197 -106
- package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +363 -0
- package/src/modules/library/__tests__/{GroupsSidebar.contextmenu.test.tsx → PluginsSidebar.contextmenu.test.tsx} +32 -31
- package/src/modules/library/__tests__/{GroupsSidebar.locked.test.tsx → PluginsSidebar.locked.test.tsx} +29 -28
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +171 -0
- 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__/library-data.test.ts +82 -0
- 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 +80 -71
- 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 +23 -5
- package/src/modules/library/components/PageActions.tsx +34 -11
- package/src/modules/library/components/PersonalAddDialog.tsx +5 -5
- package/src/modules/library/components/{PersonalGroupPage.tsx → PersonalPluginPage.tsx} +29 -19
- 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/PluginJoinRequests.tsx +77 -0
- package/src/modules/library/components/{GroupPage.tsx → PluginPage.tsx} +112 -72
- package/src/modules/library/components/{GroupsIndexPage.tsx → PluginsIndexPage.tsx} +91 -48
- package/src/modules/library/components/{GroupsSidebar.tsx → PluginsSidebar.tsx} +105 -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} +218 -27
- 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 +32 -19
- 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 +67 -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__/creator-welcome.test.tsx +318 -0
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +86 -8
- package/src/modules/onboarding/agent-clients.ts +18 -14
- package/src/modules/onboarding/components/CreatorWelcomePage.tsx +143 -0
- package/src/modules/onboarding/components/WelcomePage.tsx +30 -22
- package/src/modules/onboarding/components/WelcomeRoute.tsx +57 -0
- package/src/modules/onboarding/welcome-state.ts +36 -0
- 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/setup/__tests__/setup.test.tsx +203 -0
- package/src/modules/setup/components/SetupScreen.tsx +235 -68
- 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/FileRoute.tsx +8 -1
- package/src/modules/workspace/components/FileViewer.tsx +95 -38
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +14 -14
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +20 -0
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +227 -18
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +7 -2
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +25 -0
- package/src/modules/workspace/routing/kb-routes.ts +23 -1
- package/src/modules/workspace/utils/__tests__/diff.test.ts +1 -1
- package/src/modules/workspace/utils/fileTree.ts +54 -3
- package/src/shared/components/Surface.tsx +15 -0
- 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
- package/src/modules/library/__tests__/GroupsIndexPage.test.tsx +0 -283
- package/src/modules/library/__tests__/GroupsSidebar.test.tsx +0 -142
- package/src/modules/library/components/GroupJoinRequests.tsx +0 -56
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useNavigate } from 'react-router-dom';
|
|
3
3
|
import { Check, Copy, X } from 'lucide-react';
|
|
4
4
|
import { cn } from '../../../lib/utils';
|
|
5
5
|
import { Button, IconButton } from '../../../shared/components';
|
|
@@ -8,10 +8,12 @@ import { useLibraryToast } from '../../library/state/toast.context';
|
|
|
8
8
|
import { copyToClipboard, COPY_FAILED_TOAST } from '../../library/utils/clipboard';
|
|
9
9
|
import { pathForLibraryFilter } from '../../library/routes/library-paths';
|
|
10
10
|
import { useAppRegistry } from '../../../core/registry';
|
|
11
|
-
import { displayFirstName } from '../../library/utils/personal-
|
|
11
|
+
import { displayFirstName } from '../../library/utils/personal-plugin';
|
|
12
12
|
import { setSidebarCollapsed } from '../../layout/state/sidebar';
|
|
13
|
-
import {
|
|
13
|
+
import { ClaudeInstallLink, mcpEndpointUrl } from '../../../shared/mcp';
|
|
14
|
+
import { AGENT_CLIENTS, type AgentClient } from '../agent-clients';
|
|
14
15
|
import { useOnboarding } from '../state/onboarding';
|
|
16
|
+
import { useWelcomeRouteState } from '../welcome-state';
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* The welcome page — the first thing a new account sees, once.
|
|
@@ -47,20 +49,16 @@ export function WelcomePage() {
|
|
|
47
49
|
}, []);
|
|
48
50
|
|
|
49
51
|
/**
|
|
50
|
-
* How you got here
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*
|
|
58
|
-
* deep link that survived the SSO round-trip (see `RootLanding`). Present
|
|
59
|
-
* only on the greeting arrival, and it retargets both exits: a welcome that
|
|
60
|
-
* concluded by discarding the page someone was sent is a greeting that cost
|
|
61
|
-
* them the reason they came.
|
|
52
|
+
* How you got here, and where you were going — read through the shared
|
|
53
|
+
* parser, so this page and `WelcomeRoute` cannot drift apart about what an
|
|
54
|
+
* arrival carries (see `welcome-state`).
|
|
55
|
+
*
|
|
56
|
+
* `greeting` is what everything ceremonial on this page hangs off.
|
|
57
|
+
* `returnTo` is the deep link that survived the SSO round-trip, and it
|
|
58
|
+
* retargets both exits: a welcome that concluded by discarding the page
|
|
59
|
+
* someone was sent is a greeting that cost them the reason they came.
|
|
62
60
|
*/
|
|
63
|
-
const
|
|
61
|
+
const { greeting, returnTo } = useWelcomeRouteState();
|
|
64
62
|
|
|
65
63
|
/**
|
|
66
64
|
* The entrance — and it belongs to the greeting alone.
|
|
@@ -153,9 +151,11 @@ export function WelcomePage() {
|
|
|
153
151
|
}, []);
|
|
154
152
|
|
|
155
153
|
const client = AGENT_CLIENTS.find((c) => c.id === clientId) ?? AGENT_CLIENTS[0]!;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
154
|
+
// The deployment's own address, not the browser's — see `shared/mcp`.
|
|
155
|
+
const mcpUrl = mcpEndpointUrl();
|
|
156
|
+
const snippet = client.snip(mcpUrl);
|
|
157
|
+
// Capitalized by the same function that spells the plugin heading — "Welcome,
|
|
158
|
+
// juan" over a sidebar reading "Juan's Plugin" is the app misspelling someone
|
|
159
159
|
// to their face on the one page addressed to them.
|
|
160
160
|
const firstName = displayFirstName(user?.name) || 'there';
|
|
161
161
|
|
|
@@ -168,13 +168,13 @@ export function WelcomePage() {
|
|
|
168
168
|
* defines how it is driven: arrows select, Tab leaves. Claiming the role
|
|
169
169
|
* while only answering clicks describes a control the keyboard cannot work.
|
|
170
170
|
*
|
|
171
|
-
* Selection FOLLOWS focus, which is the pattern's default for a
|
|
171
|
+
* Selection FOLLOWS focus, which is the pattern's default for a plugin this
|
|
172
172
|
* cheap to change — picking a client re-renders one snippet, nothing is
|
|
173
173
|
* submitted, so there is no cost to arriving on an option and no reason to
|
|
174
174
|
* make people confirm. Wraps at both ends: three options in a row have no
|
|
175
175
|
* meaningful edge to stop at.
|
|
176
176
|
*
|
|
177
|
-
* Paired with the roving `tabIndex` below — one stop for the whole
|
|
177
|
+
* Paired with the roving `tabIndex` below — one stop for the whole plugin,
|
|
178
178
|
* not one per option, so Tab moves past the picker rather than through it.
|
|
179
179
|
*/
|
|
180
180
|
function onRadioKeyDown(event: React.KeyboardEvent, index: number) {
|
|
@@ -292,7 +292,7 @@ export function WelcomePage() {
|
|
|
292
292
|
type="button"
|
|
293
293
|
role="radio"
|
|
294
294
|
aria-checked={c.id === client.id}
|
|
295
|
-
// Roving: only the chosen option is a tab stop, so the
|
|
295
|
+
// Roving: only the chosen option is a tab stop, so the plugin
|
|
296
296
|
// costs ONE Tab rather than one per client.
|
|
297
297
|
tabIndex={c.id === client.id ? 0 : -1}
|
|
298
298
|
ref={(el) => {
|
|
@@ -314,6 +314,14 @@ export function WelcomePage() {
|
|
|
314
314
|
|
|
315
315
|
<p className="mt-2.5 text-meta leading-normal text-ink-faint">{client.hint}</p>
|
|
316
316
|
|
|
317
|
+
{/* Claude only, because Claude is the only client with an install
|
|
318
|
+
link — and it renders nothing at all when this deployment is one
|
|
319
|
+
Anthropic could not reach, rather than offering a shortcut that
|
|
320
|
+
dead-ends. No `showHint`: the reader here is a new employee, and
|
|
321
|
+
naming an env var they cannot change is noise. The copy block
|
|
322
|
+
below is the route that always works. */}
|
|
323
|
+
{client.id === 'claude' && <ClaudeInstallLink mcpUrl={mcpUrl} className="mt-3.5" />}
|
|
324
|
+
|
|
317
325
|
{/* The copy rides the block it copies. */}
|
|
318
326
|
<div className="relative mt-3.5">
|
|
319
327
|
<div
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useLayoutEffect } from 'react';
|
|
2
|
+
import { useAdmin } from '../../admin/state/admin.context';
|
|
3
|
+
import { setSidebarCollapsed } from '../../layout/state/sidebar';
|
|
4
|
+
import { useLibrary } from '../../library/state/library-data';
|
|
5
|
+
import { useWelcomeRouteState } from '../welcome-state';
|
|
6
|
+
import { CreatorWelcomePage } from './CreatorWelcomePage';
|
|
7
|
+
import { WelcomePage } from './WelcomePage';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Chooses the first welcome without changing what the permanent reminder does.
|
|
11
|
+
*
|
|
12
|
+
* Only RootLanding sends `greeting: true`. A later visit from the Connect your
|
|
13
|
+
* agent reminder has no greeting state and must always reach its existing
|
|
14
|
+
* instructions, even when the admin has not created anything yet.
|
|
15
|
+
*/
|
|
16
|
+
export function WelcomeRoute() {
|
|
17
|
+
const { isAdmin, isAdminLoading = false } = useAdmin();
|
|
18
|
+
const data = useLibrary();
|
|
19
|
+
// The same reading `WelcomePage` gets — one parser, so the router and the
|
|
20
|
+
// page cannot disagree about whether a deep link was carried.
|
|
21
|
+
const { greeting, returnTo } = useWelcomeRouteState();
|
|
22
|
+
|
|
23
|
+
// Hold the sidebar out of the first painted frame while the admin and
|
|
24
|
+
// library checks settle. Both welcome pages use the full reading column.
|
|
25
|
+
useLayoutEffect(() => {
|
|
26
|
+
if (greeting) setSidebarCollapsed(true, true);
|
|
27
|
+
}, [greeting]);
|
|
28
|
+
|
|
29
|
+
// A carried deep link outranks the creator welcome, admin or not: only
|
|
30
|
+
// `WelcomePage` has the exit that honors `returnTo`, and a greeting that
|
|
31
|
+
// concluded by discarding the page someone was sent would cost them the
|
|
32
|
+
// reason they came. The library can be built after the link is kept.
|
|
33
|
+
if (!greeting || returnTo || (!isAdminLoading && !isAdmin)) return <WelcomePage />;
|
|
34
|
+
|
|
35
|
+
if (isAdminLoading || data.loading || data.pluginsLoading) {
|
|
36
|
+
// Two phases, two truths. While the ADMIN verdict is unknown the reader
|
|
37
|
+
// may be headed for the agent welcome, where their library is beside the
|
|
38
|
+
// point — so the hold says nothing about one. Once the verdict says
|
|
39
|
+
// admin, the remaining wait really is their library loading.
|
|
40
|
+
// A live region: the wait changes its own words as it advances from the
|
|
41
|
+
// admin check to the library load, and a silent swap is a change only
|
|
42
|
+
// sighted users are told about.
|
|
43
|
+
return (
|
|
44
|
+
<div role="status" className="py-16 text-center text-ui text-ink-faint">
|
|
45
|
+
{isAdminLoading ? 'One moment…' : 'Preparing your library…'}
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const libraryIsEmpty =
|
|
51
|
+
!data.error &&
|
|
52
|
+
!data.pluginsError &&
|
|
53
|
+
data.items.length === 0 &&
|
|
54
|
+
data.pluginSummaries.length === 0;
|
|
55
|
+
|
|
56
|
+
return libraryIsEmpty ? <CreatorWelcomePage /> : <WelcomePage />;
|
|
57
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useLocation } from 'react-router-dom';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What an arrival at the welcome route carries — parsed in ONE place.
|
|
5
|
+
*
|
|
6
|
+
* Two components read this state: `WelcomeRoute`, which decides WHICH welcome
|
|
7
|
+
* you get, and `WelcomePage`, which decides where its exits go. They have to
|
|
8
|
+
* agree — a router that preserves a deep link in front of a page that
|
|
9
|
+
* discards it (or the reverse) loses the destination silently, and neither
|
|
10
|
+
* side's tests would notice. So the shape and the rules live here rather than
|
|
11
|
+
* being re-derived from `location.state` at each call site.
|
|
12
|
+
*/
|
|
13
|
+
export interface WelcomeRouteState {
|
|
14
|
+
/**
|
|
15
|
+
* How you got here. The automatic redirect at first sign-in is the ONE
|
|
16
|
+
* navigation that sets it (see `RootLanding`); the sidebar pill and a typed
|
|
17
|
+
* URL do not. Everything ceremonial on the welcome hangs off this flag.
|
|
18
|
+
*/
|
|
19
|
+
greeting: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Where the person was actually GOING when the sign-in interrupted them — a
|
|
22
|
+
* deep link that survived the SSO round-trip (see `RootLanding`).
|
|
23
|
+
*
|
|
24
|
+
* Null unless this is the greeting arrival, and that condition is the rule
|
|
25
|
+
* worth centralising: a `returnTo` on a later, non-greeting visit is not a
|
|
26
|
+
* carried intention, it is stale state on a page someone opened themselves.
|
|
27
|
+
*/
|
|
28
|
+
returnTo: string | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Reads the welcome contract off the current location. */
|
|
32
|
+
export function useWelcomeRouteState(): WelcomeRouteState {
|
|
33
|
+
const state = useLocation().state as { greeting?: boolean; returnTo?: string | null } | null;
|
|
34
|
+
const greeting = state?.greeting === true;
|
|
35
|
+
return { greeting, returnTo: greeting ? (state?.returnTo ?? null) : null };
|
|
36
|
+
}
|
|
@@ -242,7 +242,7 @@ function FrontmatterDiffPanel({
|
|
|
242
242
|
// ── body diff helpers ───────────────────────────────────────────────────
|
|
243
243
|
|
|
244
244
|
/**
|
|
245
|
-
*
|
|
245
|
+
* Plugin consecutive same/changed runs into display blocks: runs of "same"
|
|
246
246
|
* lines, and "conflict" blocks bundling consecutive removed+added runs
|
|
247
247
|
* together — the same shape git uses for merge conflicts.
|
|
248
248
|
*/
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
stripJunkBeforeKbDir,
|
|
11
11
|
KB_ROUTE_PREFIX,
|
|
12
12
|
} from '../../workspace/routing/kb-routes';
|
|
13
|
-
import {
|
|
13
|
+
import { pluginOfPath, DEFAULT_BRANCH } from '@bevel-software/platform-shared';
|
|
14
14
|
import { cn } from '../../../lib/utils';
|
|
15
15
|
import { DOCUMENT_COLUMN, documentGutters } from '../../../shared/theme/measure';
|
|
16
16
|
import { ReviewFileRow } from './ReviewFileRow';
|
|
@@ -23,28 +23,28 @@ function isMarkdownPath(p: string): boolean {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* Whether a review-session path is a skill or tool — anything under `
|
|
26
|
+
* Whether a review-session path is a skill or tool — anything under `Plugins/`.
|
|
27
27
|
*
|
|
28
28
|
* The paths in a review session are WORKSPACE-relative: the diff module
|
|
29
29
|
* resolves them against the workspace directory, so they arrive carrying the
|
|
30
|
-
* KB clone as their first segment (`knowledge-base/
|
|
31
|
-
* `
|
|
30
|
+
* KB clone as their first segment (`knowledge-base/Plugins/GTM/x/SKILL.md`).
|
|
31
|
+
* `pluginOfPath` wants them REPO-relative, and `stripJunkBeforeKbDir` does not
|
|
32
32
|
* get there on its own — it only drops junk BEFORE the kb dir and keeps the
|
|
33
33
|
* segment itself, so it returns an already-well-formed path unchanged. Asking
|
|
34
|
-
* `
|
|
35
|
-
*
|
|
34
|
+
* `pluginOfPath` about the workspace-relative form gets `null` for every path,
|
|
35
|
+
* plugin or not, which is a check that silently never fires.
|
|
36
36
|
*
|
|
37
37
|
* Exported so it can be tested directly. The behaviour it guards lives behind
|
|
38
38
|
* a dropdown the component tests cannot open, and a first attempt at covering
|
|
39
39
|
* it through the UI passed with the guard deleted.
|
|
40
40
|
*/
|
|
41
|
-
export function
|
|
41
|
+
export function isPluginItemPath(path: string, kbDirName: string | null): boolean {
|
|
42
42
|
const withoutJunk = stripJunkBeforeKbDir(path, kbDirName);
|
|
43
43
|
const repoRelative =
|
|
44
44
|
kbDirName && withoutJunk.startsWith(`${kbDirName}/`)
|
|
45
45
|
? withoutJunk.slice(kbDirName.length + 1)
|
|
46
46
|
: withoutJunk;
|
|
47
|
-
return
|
|
47
|
+
return pluginOfPath(repoRelative) !== null;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
@@ -57,12 +57,12 @@ export function isGroupItemPath(path: string, kbDirName: string | null): boolean
|
|
|
57
57
|
* Two reasons not to:
|
|
58
58
|
* - DELETED: navigating to a missing path lands FileRoute on its
|
|
59
59
|
* file-not-found state.
|
|
60
|
-
* - a
|
|
60
|
+
* - a plugin item ON THE DEFAULT BRANCH: that URL is a library location, so
|
|
61
61
|
* opening it switches the whole shell to Skills & Tools and the panel,
|
|
62
62
|
* the diff and the review vanish because someone clicked a row in a list.
|
|
63
63
|
*
|
|
64
64
|
* The branch is part of it, and this is the easy half to get wrong: only the
|
|
65
|
-
* DEFAULT branch's `
|
|
65
|
+
* DEFAULT branch's `Plugins/` URLs are library locations (`isLibraryLocation`
|
|
66
66
|
* tests `segments[1] === DEFAULT_BRANCH`). The same skill on a draft branch
|
|
67
67
|
* opens in Knowledge like any other file and switches nothing, so refusing to
|
|
68
68
|
* open it there would cost the context this call exists to give and buy
|
|
@@ -78,7 +78,7 @@ export function shouldOpenBesideDiff(input: {
|
|
|
78
78
|
branch: string | null;
|
|
79
79
|
}): boolean {
|
|
80
80
|
if (input.kind === 'deleted') return false;
|
|
81
|
-
const switchesApp = input.branch === DEFAULT_BRANCH &&
|
|
81
|
+
const switchesApp = input.branch === DEFAULT_BRANCH && isPluginItemPath(input.path, input.kbDirName);
|
|
82
82
|
return !switchesApp;
|
|
83
83
|
}
|
|
84
84
|
|
package/src/modules/review/components/__tests__/{isGroupItemPath.test.ts → isPluginItemPath.test.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect, beforeEach } from 'vitest';
|
|
2
2
|
import { configureBranchModel } from '@bevel-software/platform-shared';
|
|
3
|
-
import {
|
|
3
|
+
import { isPluginItemPath, shouldOpenBesideDiff } from '../ReviewPanel';
|
|
4
4
|
|
|
5
5
|
const DEFAULT = 'target-company-state';
|
|
6
6
|
const DRAFT = 'razvan/onboarding-tweaks';
|
|
@@ -24,17 +24,17 @@ const KB = 'knowledge-base';
|
|
|
24
24
|
* The first version of this check shipped broken for exactly the reason the
|
|
25
25
|
* first case below pins: review-session paths are WORKSPACE-relative, so they
|
|
26
26
|
* carry the KB clone as their first segment, and `stripJunkBeforeKbDir` keeps
|
|
27
|
-
* that segment rather than removing it. `
|
|
28
|
-
* `knowledge-base` where it wanted `
|
|
27
|
+
* that segment rather than removing it. `pluginOfPath` then saw
|
|
28
|
+
* `knowledge-base` where it wanted `Plugins` and answered `null` for every
|
|
29
29
|
* path — a guard that could never fire.
|
|
30
30
|
*/
|
|
31
|
-
describe('
|
|
31
|
+
describe('isPluginItemPath', () => {
|
|
32
32
|
it.each([
|
|
33
|
-
['skill, workspace-relative', `${KB}/
|
|
34
|
-
['tool, workspace-relative', `${KB}/
|
|
35
|
-
['personal
|
|
33
|
+
['skill, workspace-relative', `${KB}/Plugins/GTM/update-website/SKILL.md`],
|
|
34
|
+
['tool, workspace-relative', `${KB}/Plugins/Engineering/notion.tool`],
|
|
35
|
+
['personal plugin', `${KB}/Plugins/personal-u1/my-skill/SKILL.md`],
|
|
36
36
|
])('recognises a %s', (_name, path) => {
|
|
37
|
-
expect(
|
|
37
|
+
expect(isPluginItemPath(path, KB)).toBe(true);
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
it.each([
|
|
@@ -42,7 +42,7 @@ describe('isGroupItemPath', () => {
|
|
|
42
42
|
['repo-root file', `${KB}/roles.yaml`],
|
|
43
43
|
['data record', `${KB}/Data/Engineering/Knowledge/Ticket.md`],
|
|
44
44
|
])('leaves a %s alone', (_name, path) => {
|
|
45
|
-
expect(
|
|
45
|
+
expect(isPluginItemPath(path, KB)).toBe(false);
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
/**
|
|
@@ -50,35 +50,35 @@ describe('isGroupItemPath', () => {
|
|
|
50
50
|
* fixtures use repo-relative ones — so both shapes have to work.
|
|
51
51
|
*/
|
|
52
52
|
it('accepts an already repo-relative path', () => {
|
|
53
|
-
expect(
|
|
54
|
-
expect(
|
|
53
|
+
expect(isPluginItemPath('Plugins/GTM/x/SKILL.md', KB)).toBe(true);
|
|
54
|
+
expect(isPluginItemPath('KnowledgeBase/Product/Thing.md', KB)).toBe(false);
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
it('tolerates junk before the kb dir, which is what strip exists for', () => {
|
|
58
|
-
expect(
|
|
58
|
+
expect(isPluginItemPath(`some/prefix/${KB}/Plugins/GTM/x/SKILL.md`, KB)).toBe(true);
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
it('does not treat the
|
|
62
|
-
// `
|
|
63
|
-
// folder, and a bare `
|
|
64
|
-
expect(
|
|
65
|
-
expect(
|
|
61
|
+
it('does not treat the Plugins folder itself as an item', () => {
|
|
62
|
+
// `pluginOfPath` needs a segment BELOW the plugin; `Plugins/GTM` is the
|
|
63
|
+
// folder, and a bare `Plugins/x.tool` names no plugin at all.
|
|
64
|
+
expect(isPluginItemPath(`${KB}/Plugins/GTM`, KB)).toBe(false);
|
|
65
|
+
expect(isPluginItemPath(`${KB}/Plugins/slack.tool`, KB)).toBe(false);
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* A sibling directory whose name merely STARTS with the kb dir is not the
|
|
70
|
-
* clone, so nothing inside it is a
|
|
70
|
+
* clone, so nothing inside it is a plugin item. Both the segment-exact match
|
|
71
71
|
* in `stripJunkBeforeKbDir` and the `${kbDirName}/` prefix test added here
|
|
72
72
|
* have to agree on that — a `startsWith(kbDirName)` in either would strip
|
|
73
|
-
* `-backup/…` down to `
|
|
73
|
+
* `-backup/…` down to `Plugins/…` and call a backup copy a live skill.
|
|
74
74
|
*/
|
|
75
75
|
it('is not fooled by a directory whose name merely starts with the kb dir', () => {
|
|
76
|
-
expect(
|
|
76
|
+
expect(isPluginItemPath(`${KB}-backup/Plugins/GTM/x/SKILL.md`, KB)).toBe(false);
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
it('handles a null kbDirName', () => {
|
|
80
|
-
expect(
|
|
81
|
-
expect(
|
|
80
|
+
expect(isPluginItemPath('Plugins/GTM/x/SKILL.md', null)).toBe(true);
|
|
81
|
+
expect(isPluginItemPath('KnowledgeBase/Thing.md', null)).toBe(false);
|
|
82
82
|
});
|
|
83
83
|
});
|
|
84
84
|
|
|
@@ -89,7 +89,7 @@ describe('isGroupItemPath', () => {
|
|
|
89
89
|
*/
|
|
90
90
|
describe('shouldOpenBesideDiff', () => {
|
|
91
91
|
const base = { kbDirName: KB, branch: DEFAULT } as const;
|
|
92
|
-
const SKILL = `${KB}/
|
|
92
|
+
const SKILL = `${KB}/Plugins/GTM/update-website/SKILL.md`;
|
|
93
93
|
const DOC = `${KB}/KnowledgeBase/Product/Thing.md`;
|
|
94
94
|
|
|
95
95
|
it('opens an ordinary knowledge document', () => {
|
|
@@ -101,7 +101,7 @@ describe('shouldOpenBesideDiff', () => {
|
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
|
-
* Only the DEFAULT branch's `
|
|
104
|
+
* Only the DEFAULT branch's `Plugins/` URLs are library locations
|
|
105
105
|
* (`isLibraryLocation` tests `segments[1] === DEFAULT_BRANCH`). On a draft
|
|
106
106
|
* branch the same skill opens in Knowledge and switches nothing, so the
|
|
107
107
|
* guard must not fire — refusing there would cost the context this call
|
|
@@ -53,7 +53,7 @@ export function ToolSecretsPanel({ tool, onChanged }: { tool: ToolSecrets; onCha
|
|
|
53
53
|
<div className="flex flex-col gap-3.5">
|
|
54
54
|
<SetupBanner setup={tool.setup} />
|
|
55
55
|
{adminVars.length > 0 && (
|
|
56
|
-
<
|
|
56
|
+
<VarPlugin
|
|
57
57
|
title="Set by the tool owner"
|
|
58
58
|
hint={tool.canWrite ? 'Shared by everyone who uses this tool.' : 'Only a tool writer can set these.'}
|
|
59
59
|
slug={tool.slug}
|
|
@@ -66,7 +66,7 @@ export function ToolSecretsPanel({ tool, onChanged }: { tool: ToolSecrets; onCha
|
|
|
66
66
|
/>
|
|
67
67
|
)}
|
|
68
68
|
{userVars.length > 0 && (
|
|
69
|
-
<
|
|
69
|
+
<VarPlugin
|
|
70
70
|
title="Set by you"
|
|
71
71
|
hint="Your own value: not shared with other users."
|
|
72
72
|
slug={tool.slug}
|
|
@@ -115,7 +115,7 @@ function SetupBanner({ setup }: { setup: ToolSetup | null }) {
|
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
function
|
|
118
|
+
function VarPlugin({
|
|
119
119
|
title,
|
|
120
120
|
hint,
|
|
121
121
|
slug,
|
|
@@ -22,7 +22,7 @@ import { SettingsNav, type LinkableItem } from './SettingsNav';
|
|
|
22
22
|
* something each page has to remember to render.
|
|
23
23
|
*
|
|
24
24
|
* It fills the app's ONE `SidebarFrame` — the third renderer of it, after
|
|
25
|
-
* Knowledge's file tree and Skills & Tools'
|
|
25
|
+
* Knowledge's file tree and Skills & Tools' plugin list. `sidebar.ts` already
|
|
26
26
|
* states the claim this relies on: there is one nav, in one place, holding a
|
|
27
27
|
* different list depending on where you are.
|
|
28
28
|
*
|
|
@@ -9,18 +9,18 @@ export type LinkableItem = AdminMenuItem & { path: string };
|
|
|
9
9
|
/**
|
|
10
10
|
* `rail` is the sidebar column; `strip` is the horizontal row it becomes below
|
|
11
11
|
* the `md` breakpoint. The rows are identical in both — only the axis and the
|
|
12
|
-
* section label change, because a label that introduces a group
|
|
13
|
-
* a vertical-list device and reads as noise inline.
|
|
12
|
+
* section label change, because a label that introduces a group of rows
|
|
13
|
+
* beneath it is a vertical-list device and reads as noise inline.
|
|
14
14
|
*/
|
|
15
15
|
export type SettingsNavOrientation = 'rail' | 'strip';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* The settings nav's CONTENTS — a pure view of the URL, in the same sense
|
|
19
|
-
* `
|
|
19
|
+
* `PluginsSidebar` is. It holds no state, decides no membership and fetches
|
|
20
20
|
* nothing; the layout works out which rows exist and which one is current,
|
|
21
21
|
* and this renders them.
|
|
22
22
|
*
|
|
23
|
-
* Row styling is `
|
|
23
|
+
* Row styling is `PluginsSidebar`'s declaration token for token, minus the
|
|
24
24
|
* count slot it has no use for, plus `FileExplorer`'s inset focus ring — the
|
|
25
25
|
* more complete of the two treatments. The two sidebars must not read as two
|
|
26
26
|
* products, and the class string is what that rule actually protects.
|
|
@@ -99,7 +99,7 @@ export function SettingsNav({
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
|
-
* Copied from `
|
|
102
|
+
* Copied from `PluginsSidebar`'s `SectionLabel` rather than extracted into a
|
|
103
103
|
* shared component — the same call `FileExplorer` made about its own row
|
|
104
104
|
* class. Three sidebars agreeing on a label's padding is not yet an
|
|
105
105
|
* abstraction, and hoisting it would put a shared dependency between two
|