@bevel-software/platform-core-frontend 0.13.6 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/__tests__/utils.test.ts +43 -0
- package/src/lib/api.ts +19 -2
- package/src/lib/utils.ts +17 -7
- 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 +2 -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__/McpServerSection.test.tsx +7 -1
- 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__/ToolConnectionSection.test.tsx +216 -8
- package/src/modules/library/__tests__/ToolPage.test.tsx +23 -3
- package/src/modules/library/__tests__/ToolVarRow.test.tsx +7 -7
- 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__/status.test.ts +84 -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 +21 -1
- 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 +75 -7
- package/src/modules/library/components/tool-page/McpServerSection.tsx +9 -1
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +223 -8
- package/src/modules/library/components/tool-page/ToolPage.tsx +30 -2
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +30 -8
- package/src/modules/library/hooks/useJoinRequests.ts +48 -18
- package/src/modules/library/hooks/useToolPage.ts +28 -11
- 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 +173 -17
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +3 -2
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +29 -14
- package/src/modules/secrets-vault/components/SecretsPage.tsx +4 -1
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +4 -1
- package/src/modules/secrets-vault/services/tool-secrets.api.ts +36 -0
- 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 +301 -93
- 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
|
@@ -4,8 +4,10 @@ import { useWorkspace } from '../state/workspace.context';
|
|
|
4
4
|
import { WorkspaceApiError } from '../services/workspace.api';
|
|
5
5
|
import { useGit } from '../../git/state/git.context';
|
|
6
6
|
import { readPersistedTabs } from '../utils/tab-persistence';
|
|
7
|
+
import { DEFAULT_BRANCH } from '@bevel-software/platform-shared';
|
|
7
8
|
import {
|
|
8
9
|
NODE_ID_LINK_RE,
|
|
10
|
+
kbFileUrl,
|
|
9
11
|
kbNodeUrl,
|
|
10
12
|
fetchNodeWorkspacePath,
|
|
11
13
|
fetchNodeId,
|
|
@@ -16,6 +18,8 @@ import { FileViewer } from './FileViewer';
|
|
|
16
18
|
type SyncError =
|
|
17
19
|
| { kind: 'dirty'; current: string; target: string; dirtyFilenames: string[] }
|
|
18
20
|
| { kind: 'file-missing'; path: string }
|
|
21
|
+
/** The branch itself is gone from the repository (deleted on the host). */
|
|
22
|
+
| { kind: 'branch-gone'; branch: string }
|
|
19
23
|
| { kind: 'file-denied'; path: string }
|
|
20
24
|
| { kind: 'file-load-failed'; path: string; message: string }
|
|
21
25
|
| null;
|
|
@@ -201,6 +205,10 @@ export function FileRoute() {
|
|
|
201
205
|
}
|
|
202
206
|
} catch (err) {
|
|
203
207
|
if (!cancelled) {
|
|
208
|
+
if (err instanceof WorkspaceApiError && err.status === 410) {
|
|
209
|
+
setError({ kind: 'branch-gone', branch: branchFromUrl });
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
204
212
|
const message = err instanceof Error ? err.message : 'Unknown error';
|
|
205
213
|
setError({ kind: 'file-load-failed', path: pathFromUrl, message });
|
|
206
214
|
}
|
|
@@ -221,6 +229,8 @@ export function FileRoute() {
|
|
|
221
229
|
setError({ kind: 'file-missing', path: pathFromUrl });
|
|
222
230
|
} else if (err instanceof WorkspaceApiError && err.status === 403) {
|
|
223
231
|
setError({ kind: 'file-denied', path: pathFromUrl });
|
|
232
|
+
} else if (err instanceof WorkspaceApiError && err.status === 410) {
|
|
233
|
+
setError({ kind: 'branch-gone', branch: branchFromUrl });
|
|
224
234
|
} else {
|
|
225
235
|
const message = err instanceof Error ? err.message : 'Unknown error';
|
|
226
236
|
setError({ kind: 'file-load-failed', path: pathFromUrl, message });
|
|
@@ -272,6 +282,8 @@ export function FileRoute() {
|
|
|
272
282
|
setError({ kind: 'file-missing', path });
|
|
273
283
|
} else if (err instanceof WorkspaceApiError && err.status === 403) {
|
|
274
284
|
setError({ kind: 'file-denied', path });
|
|
285
|
+
} else if (err instanceof WorkspaceApiError && err.status === 410) {
|
|
286
|
+
setError({ kind: 'branch-gone', branch: branchFromUrl });
|
|
275
287
|
} else {
|
|
276
288
|
const message = err instanceof Error ? err.message : 'Unknown error';
|
|
277
289
|
setError({ kind: 'file-load-failed', path, message });
|
|
@@ -318,6 +330,31 @@ export function FileRoute() {
|
|
|
318
330
|
);
|
|
319
331
|
}
|
|
320
332
|
|
|
333
|
+
// The branch was deleted on the git host and its clone retired; there is
|
|
334
|
+
// nothing here to load or to retry. Two ways to learn it: a file read on a
|
|
335
|
+
// workspace we already had (410 from the read → `error`), or the bootstrap
|
|
336
|
+
// of the branch itself failing before there was a workspace at all (410
|
|
337
|
+
// from `GET /workspace` → `bootstrapError`, matched to THIS branch so a
|
|
338
|
+
// stale failure from a branch we left cannot paint over the current one).
|
|
339
|
+
const goneBranch =
|
|
340
|
+
error?.kind === 'branch-gone'
|
|
341
|
+
? error.branch
|
|
342
|
+
: workspace.bootstrapError?.status === 410 && workspace.bootstrapError.branch === branchFromUrl
|
|
343
|
+
? branchFromUrl
|
|
344
|
+
: null;
|
|
345
|
+
if (goneBranch !== null) {
|
|
346
|
+
return (
|
|
347
|
+
<ErrorScreen title="This branch no longer exists">
|
|
348
|
+
<p className="text-ui text-ink-muted">
|
|
349
|
+
<span className="font-mono text-ink">{goneBranch}</span> was deleted in the git
|
|
350
|
+
repository. Anything merged from it lives on{' '}
|
|
351
|
+
<span className="font-mono text-ink">{DEFAULT_BRANCH}</span>.
|
|
352
|
+
</p>
|
|
353
|
+
<Button onClick={() => navigate(kbFileUrl(DEFAULT_BRANCH))}>Go to {DEFAULT_BRANCH}</Button>
|
|
354
|
+
</ErrorScreen>
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
|
|
321
358
|
if (error?.kind === 'file-missing') {
|
|
322
359
|
return (
|
|
323
360
|
<ErrorScreen title="File not found">
|
|
@@ -249,6 +249,45 @@ describe('FileRoute', () => {
|
|
|
249
249
|
expect(screen.queryByText(/File not found/i)).not.toBeInTheDocument();
|
|
250
250
|
});
|
|
251
251
|
|
|
252
|
+
it('renders the branch-gone screen when hydrate answers 410 — the branch was deleted on the host', async () => {
|
|
253
|
+
const hydrateTabs = vi.fn(async () => {
|
|
254
|
+
throw new WorkspaceApiError(410);
|
|
255
|
+
});
|
|
256
|
+
const workspace = makeWorkspace({ hydrateTabs });
|
|
257
|
+
const git = makeGit({ status: makeStatus('alice/draft') });
|
|
258
|
+
|
|
259
|
+
renderAt('/workspace/alice%2Fdraft/Knowledge/Foo.md', { git, workspace });
|
|
260
|
+
|
|
261
|
+
await waitFor(() => {
|
|
262
|
+
expect(screen.getByText(/This branch no longer exists/i)).toBeInTheDocument();
|
|
263
|
+
});
|
|
264
|
+
expect(screen.getByText('alice/draft')).toBeInTheDocument();
|
|
265
|
+
expect(screen.getByRole('button', { name: /Go to/ })).toBeInTheDocument();
|
|
266
|
+
expect(screen.queryByText(/Couldn't load this file/i)).not.toBeInTheDocument();
|
|
267
|
+
});
|
|
268
|
+
it('renders the branch-gone screen when the BOOTSTRAP of the URL branch answered 410', async () => {
|
|
269
|
+
// No workspace ever came up for this branch: GET /workspace said the
|
|
270
|
+
// branch is gone. The state surfaces that; the route must not sit waiting.
|
|
271
|
+
const workspace = makeWorkspace({ bootstrapError: { branch: 'alice/draft', status: 410 } });
|
|
272
|
+
const git = makeGit({ status: makeStatus('main') });
|
|
273
|
+
|
|
274
|
+
renderAt('/workspace/alice%2Fdraft/Knowledge/Foo.md', { git, workspace });
|
|
275
|
+
|
|
276
|
+
await waitFor(() => {
|
|
277
|
+
expect(screen.getByText(/This branch no longer exists/i)).toBeInTheDocument();
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it('a stale bootstrap failure from another branch does not paint over this one', async () => {
|
|
282
|
+
const workspace = makeWorkspace({ bootstrapError: { branch: 'someone/else', status: 410 } });
|
|
283
|
+
const git = makeGit({ status: makeStatus('alice/draft') });
|
|
284
|
+
|
|
285
|
+
renderAt('/workspace/alice%2Fdraft/Knowledge/Foo.md', { git, workspace });
|
|
286
|
+
|
|
287
|
+
await waitFor(() => {
|
|
288
|
+
expect(screen.queryByText(/This branch no longer exists/i)).not.toBeInTheDocument();
|
|
289
|
+
});
|
|
290
|
+
});
|
|
252
291
|
it('renders file-load-failed when hydrate throws a non-404 error', async () => {
|
|
253
292
|
const hydrateTabs = vi.fn(async () => {
|
|
254
293
|
throw new WorkspaceApiError(500);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import type { FileTreeEntry } from '@bevel-software/platform-shared';
|
|
3
|
+
import { useWorkspace, type PendingEntry } from '../state/workspace.context';
|
|
4
|
+
import { mergePendingIntoTree, pathExistsInTree } from '../utils/fileTree';
|
|
5
|
+
import { useOpenChangeRequests } from './useOpenChangeRequests';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The branch's tree with two overlays: the caller's pending uploads (a
|
|
9
|
+
* dropped file shows within a frame, before its commit echoes back) and the
|
|
10
|
+
* files their own open change requests propose that this branch does not have
|
|
11
|
+
* yet. ONE hook, because two navs read the same workspace — the Knowledge
|
|
12
|
+
* explorer and the Library's Skills tree — and an overlay one of them lacked
|
|
13
|
+
* would be a file that exists in one sidebar and not the other.
|
|
14
|
+
*/
|
|
15
|
+
export function useMergedWorkspaceTree(): {
|
|
16
|
+
tree: FileTreeEntry | null;
|
|
17
|
+
/** Paths synthesized from the caller's own requests → the request's number. */
|
|
18
|
+
suggestionOnlyPaths: ReadonlyMap<string, number>;
|
|
19
|
+
} {
|
|
20
|
+
const { fileTree, kbDirName, pendingUploads } = useWorkspace();
|
|
21
|
+
const serverTree = useMemo(
|
|
22
|
+
() => (fileTree ? mergePendingIntoTree(fileTree, pendingUploads) : null),
|
|
23
|
+
[fileTree, pendingUploads],
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// The caller's own proposed files that do NOT exist on this branch — they
|
|
27
|
+
// live only on the personal suggestions branch behind an open change
|
|
28
|
+
// request. The tree shows them beside the branch's real files (synthesized
|
|
29
|
+
// below), coloured differently, and clicking one opens the request.
|
|
30
|
+
const openChangeRequests = useOpenChangeRequests();
|
|
31
|
+
const suggestionOnlyPaths = useMemo(() => {
|
|
32
|
+
const map = new Map<string, number>();
|
|
33
|
+
if (!serverTree) return map;
|
|
34
|
+
/**
|
|
35
|
+
* "Not in the tree" has TWO causes, and only one earns a row: the file is
|
|
36
|
+
* new on the suggestions branch — or the server FILTERED it (.bevelignore,
|
|
37
|
+
* read gates). The client cannot evaluate those rules itself, but it can
|
|
38
|
+
* read their verdict off the tree: if the path's top-level folder under
|
|
39
|
+
* the repo root is absent, the whole subtree is hidden (a skill proposal
|
|
40
|
+
* under a bevelignored `Plugins/` was the observed leak), so the overlay
|
|
41
|
+
* must not resurrect it. The known cost: a proposal that CREATES a new
|
|
42
|
+
* top-level root folder shows no row until it merges.
|
|
43
|
+
*/
|
|
44
|
+
const hiddenRoot = (path: string): boolean => {
|
|
45
|
+
const prefix = kbDirName && path.startsWith(`${kbDirName}/`) ? `${kbDirName}/` : '';
|
|
46
|
+
const segments = path.slice(prefix.length).split('/');
|
|
47
|
+
if (segments.length < 2) return false; // directly under the repo root
|
|
48
|
+
return !pathExistsInTree(serverTree, `${prefix}${segments[0]}`);
|
|
49
|
+
};
|
|
50
|
+
for (const [path, crNumber] of openChangeRequests.minePaths) {
|
|
51
|
+
if (!pathExistsInTree(serverTree, path) && !hiddenRoot(path)) {
|
|
52
|
+
map.set(path, crNumber);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return map;
|
|
56
|
+
}, [serverTree, openChangeRequests, kbDirName]);
|
|
57
|
+
|
|
58
|
+
const tree = useMemo(() => {
|
|
59
|
+
if (!serverTree || suggestionOnlyPaths.size === 0) return serverTree;
|
|
60
|
+
// Reuses the pending-upload synthesizer: same parent-directory creation,
|
|
61
|
+
// same sort order, and a real entry always wins over a synthesized one.
|
|
62
|
+
const asEntries = new Map<string, PendingEntry>();
|
|
63
|
+
for (const path of suggestionOnlyPaths.keys()) {
|
|
64
|
+
asEntries.set(path, { fullPath: path, type: 'file' });
|
|
65
|
+
}
|
|
66
|
+
return mergePendingIntoTree(serverTree, asEntries);
|
|
67
|
+
}, [serverTree, suggestionOnlyPaths]);
|
|
68
|
+
|
|
69
|
+
return { tree, suggestionOnlyPaths };
|
|
70
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, useCallback, useContext, useEffect, useMemo, useRef } from 'react';
|
|
2
|
-
import { isProtectedBranch, type FileTreeEntry } from '@bevel-software/platform-shared';
|
|
2
|
+
import { DEFAULT_BRANCH, isProtectedBranch, type FileTreeEntry } from '@bevel-software/platform-shared';
|
|
3
3
|
import { useEventBus, canonicalizeWorkspaceId } from '../../workflow/state/event-bus.context';
|
|
4
4
|
import { AuthContext } from '../../auth/state/auth.context';
|
|
5
5
|
import { fetchFileAccess } from '../../access/api';
|
|
@@ -99,6 +99,7 @@ interface UseWorkspaceStateReturn extends WorkspaceContextValue {
|
|
|
99
99
|
|
|
100
100
|
export function useWorkspaceState(): UseWorkspaceStateReturn {
|
|
101
101
|
const [workspaceId, setWorkspaceId] = useState<string | null>(null);
|
|
102
|
+
const [bootstrapError, setBootstrapError] = useState<{ branch: string; status: number } | null>(null);
|
|
102
103
|
const [kbDirName, setKbDirName] = useState<string | null>(null);
|
|
103
104
|
const [fileTree, setFileTree] = useState<FileTreeEntry | null>(null);
|
|
104
105
|
const [openTabs, setOpenTabs] = useState<OpenTab[]>([]);
|
|
@@ -173,8 +174,20 @@ export function useWorkspaceState(): UseWorkspaceStateReturn {
|
|
|
173
174
|
setWorkspaceId(workspace.id);
|
|
174
175
|
setKbDirName(workspace.kbDirName);
|
|
175
176
|
setFileTree(tree);
|
|
177
|
+
setBootstrapError(null);
|
|
176
178
|
} catch (err) {
|
|
177
|
-
if (
|
|
179
|
+
if (cancelled) return;
|
|
180
|
+
console.error('Failed to bootstrap workspace:', err);
|
|
181
|
+
// Surfaced, not just logged: a bootstrap that fails leaves
|
|
182
|
+
// `workspaceId` where it was, and the route waiting on it needs to
|
|
183
|
+
// know why — a branch the host deleted (410) has its own screen.
|
|
184
|
+
// No persistence branch means the server bootstrapped the DEFAULT
|
|
185
|
+
// branch, so that is the branch this failure is about — an empty
|
|
186
|
+
// name would never match the URL a route is on.
|
|
187
|
+
setBootstrapError({
|
|
188
|
+
branch: branch ?? DEFAULT_BRANCH,
|
|
189
|
+
status: err instanceof WorkspaceApiError ? err.status : 0,
|
|
190
|
+
});
|
|
178
191
|
}
|
|
179
192
|
})();
|
|
180
193
|
return () => { cancelled = true; };
|
|
@@ -1371,6 +1384,7 @@ export function useWorkspaceState(): UseWorkspaceStateReturn {
|
|
|
1371
1384
|
workspaceId,
|
|
1372
1385
|
kbDirName,
|
|
1373
1386
|
fileTree,
|
|
1387
|
+
bootstrapError,
|
|
1374
1388
|
openTabs,
|
|
1375
1389
|
activeTab,
|
|
1376
1390
|
dirtyTabFilenames,
|
|
@@ -1412,7 +1426,7 @@ export function useWorkspaceState(): UseWorkspaceStateReturn {
|
|
|
1412
1426
|
setPersistenceBranch,
|
|
1413
1427
|
deleteWorkspace,
|
|
1414
1428
|
}), [
|
|
1415
|
-
workspaceId, kbDirName, fileTree, openTabs, activeTab, dirtyTabFilenames,
|
|
1429
|
+
workspaceId, kbDirName, fileTree, bootstrapError, openTabs, activeTab, dirtyTabFilenames,
|
|
1416
1430
|
openFilePath, openFileContent, openFileSavedContent, hasUnsavedFileChanges, pendingFileContent,
|
|
1417
1431
|
setHasUnsavedFileChanges, setActiveTabContent, fsRevision, uploadError, uploadNotice, clearUploadNotice, isUploading, uploadProgress, pendingUploads, refreshFileTree, bumpFs,
|
|
1418
1432
|
addTab, closeTab, activateTab, reorderTab, closeAllTabs, hydrateTabs,
|
|
@@ -143,7 +143,7 @@ export function useCanonicalFileUrl(workspacePath: string | null): string | null
|
|
|
143
143
|
return `${window.location.origin}${relative}`;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
function safeDecode(s: string): string {
|
|
146
|
+
export function safeDecode(s: string): string {
|
|
147
147
|
try {
|
|
148
148
|
return decodeURIComponent(s);
|
|
149
149
|
} catch {
|
|
@@ -59,6 +59,14 @@ export interface WorkspaceContextValue {
|
|
|
59
59
|
*/
|
|
60
60
|
kbDirName: string | null;
|
|
61
61
|
fileTree: FileTreeEntry | null;
|
|
62
|
+
/**
|
|
63
|
+
* Why the last workspace bootstrap failed, or null. A bootstrap that fails
|
|
64
|
+
* leaves `workspaceId` on whatever it was, so without this a route could
|
|
65
|
+
* only wait forever; `status` is the HTTP status the bootstrap answered
|
|
66
|
+
* (410: the branch no longer exists on the git host), 0 for a transport
|
|
67
|
+
* failure. Cleared by the next successful bootstrap.
|
|
68
|
+
*/
|
|
69
|
+
bootstrapError: { branch: string; status: number } | null;
|
|
62
70
|
|
|
63
71
|
/** All tabs currently open in the editor strip. */
|
|
64
72
|
openTabs: OpenTab[];
|
|
@@ -50,6 +50,21 @@ describe('suggestedPages', () => {
|
|
|
50
50
|
]);
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
+
it('skips a folder named after ANY reserved root, at any depth — the same set the root selection uses', () => {
|
|
54
|
+
const page = (rel: string) => ({ name: rel.split('/').pop()!, relativePath: rel, type: 'file' as const });
|
|
55
|
+
const tree = dir('', [
|
|
56
|
+
dir('knowledge-base', [
|
|
57
|
+
dir('knowledge-base/KnowledgeBase', [
|
|
58
|
+
dir('knowledge-base/KnowledgeBase/Data', [page('knowledge-base/KnowledgeBase/Data/rows.md')]),
|
|
59
|
+
dir('knowledge-base/KnowledgeBase/Pipelines', [page('knowledge-base/KnowledgeBase/Pipelines/run.md')]),
|
|
60
|
+
dir('knowledge-base/KnowledgeBase/Skills', [page('knowledge-base/KnowledgeBase/Skills/x.md')]),
|
|
61
|
+
dir('knowledge-base/KnowledgeBase/Team', [page('knowledge-base/KnowledgeBase/Team/People.md')]),
|
|
62
|
+
]),
|
|
63
|
+
]),
|
|
64
|
+
]);
|
|
65
|
+
expect(suggestedPages(tree, 10).map((e) => e.name)).toEqual(['People.md']);
|
|
66
|
+
});
|
|
67
|
+
|
|
53
68
|
it('honours the limit breadth-first and reports an empty knowledge base as such', () => {
|
|
54
69
|
expect(suggestedPages(TREE, 1).map((e) => e.name)).toEqual(['Onboarding.md']);
|
|
55
70
|
expect(suggestedPages(dir('', [dir('knowledge-base', [dir('knowledge-base/KnowledgeBase', [])])]), 3)).toEqual([]);
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
-
AGENTS_DIR,
|
|
3
|
-
DATA_DIR,
|
|
4
2
|
KNOWLEDGE_BASE_DIR,
|
|
5
|
-
|
|
6
|
-
PLUGINS_DIR,
|
|
3
|
+
reservedRootDirNames,
|
|
7
4
|
type FileTreeEntry,
|
|
8
5
|
} from '@bevel-software/platform-shared';
|
|
9
6
|
import type { PendingEntry } from '../state/workspace.context';
|
|
10
7
|
|
|
11
8
|
// RESERVED is not the same as CREATED (see kb-layout.ts): core only seeds
|
|
12
|
-
// KnowledgeBase/ and Plugins/, but every reserved name renders as its
|
|
13
|
-
// when present — a distribution that owns the execution layer seeds
|
|
14
|
-
// Agents/ and Pipelines/, and a KB that has them must not see them
|
|
15
|
-
// into Knowledge as stray content.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
PIPELINES_DIR,
|
|
21
|
-
PLUGINS_DIR,
|
|
22
|
-
]);
|
|
9
|
+
// KnowledgeBase/, Skills/ and Plugins/, but every reserved name renders as its
|
|
10
|
+
// own root when present — a distribution that owns the execution layer seeds
|
|
11
|
+
// Data/, Agents/ and Pipelines/, and a KB that has them must not see them
|
|
12
|
+
// folded into Knowledge as stray content. A function, not a module-scope set:
|
|
13
|
+
// three of the names are configurable and arrive after this module loads.
|
|
14
|
+
export const KB_ROOT_DIRS = {
|
|
15
|
+
has: (name: string): boolean => reservedRootDirNames().has(name),
|
|
16
|
+
};
|
|
23
17
|
|
|
24
18
|
/**
|
|
25
19
|
* Descend past the workspace / KB-clone wrapper levels to the node that holds
|
|
@@ -93,7 +87,11 @@ export function suggestedPages(tree: FileTreeEntry | null, limit: number): FileT
|
|
|
93
87
|
if (entry.name.startsWith('.')) continue;
|
|
94
88
|
if (entry.type === 'file') {
|
|
95
89
|
if (READABLE_PAGE.test(entry.name) && !isAccessRulesFile(entry)) pages.push(entry);
|
|
96
|
-
} else if (entry.name
|
|
90
|
+
} else if (level === roots || !KB_ROOT_DIRS.has(entry.name)) {
|
|
91
|
+
// Below the roots, the reserved SET decides — not two names: a folder
|
|
92
|
+
// named after any reserved root, at any depth, is the same kind of
|
|
93
|
+
// thing the root selection above keeps out. The roots themselves are
|
|
94
|
+
// the selection's own answer (Knowledge is a reserved name too).
|
|
97
95
|
next.push(...(entry.children ?? []));
|
|
98
96
|
}
|
|
99
97
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
configureMarketplaceGitUrl,
|
|
4
|
+
marketplaceCommands,
|
|
5
|
+
marketplaceGitUrl,
|
|
6
|
+
resetMarketplaceGitUrlForTests,
|
|
7
|
+
withConnectionKey,
|
|
8
|
+
} from '../marketplace-url';
|
|
9
|
+
|
|
10
|
+
afterEach(() => resetMarketplaceGitUrlForTests());
|
|
11
|
+
|
|
12
|
+
describe('marketplace git url', () => {
|
|
13
|
+
it('uses the server\'s address, with any credential stripped', () => {
|
|
14
|
+
configureMarketplaceGitUrl('https://user:hunter2@kb.acme.com/git/marketplace.git');
|
|
15
|
+
expect(marketplaceGitUrl()).toBe('https://kb.acme.com/git/marketplace.git');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('falls back to the origin when the server sends nothing usable', () => {
|
|
19
|
+
configureMarketplaceGitUrl(undefined);
|
|
20
|
+
expect(marketplaceGitUrl()).toBe(`${window.location.origin}/git/marketplace.git`);
|
|
21
|
+
configureMarketplaceGitUrl('javascript:alert(1)');
|
|
22
|
+
expect(marketplaceGitUrl()).toBe(`${window.location.origin}/git/marketplace.git`);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('puts the connection key in the URL the way git sends it', () => {
|
|
26
|
+
configureMarketplaceGitUrl('https://kb.acme.com/git/marketplace.git');
|
|
27
|
+
expect(withConnectionKey('bevel_abc')).toBe('https://key:bevel_abc@kb.acme.com/git/marketplace.git');
|
|
28
|
+
const cmds = marketplaceCommands('bevel_abc');
|
|
29
|
+
expect(cmds.claude).toBe(
|
|
30
|
+
'claude plugin marketplace add https://key:bevel_abc@kb.acme.com/git/marketplace.git && claude plugin install hexis-all@hexis',
|
|
31
|
+
);
|
|
32
|
+
expect(cmds.codex).toBe('codex plugin marketplace add https://key:bevel_abc@kb.acme.com/git/marketplace.git');
|
|
33
|
+
expect(cmds.skills).toBe('npx skills add https://key:bevel_abc@kb.acme.com/git/marketplace.git --all -y');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('shows a placeholder verbatim — never percent-encoded into something that looks like a key', () => {
|
|
37
|
+
configureMarketplaceGitUrl('https://kb.acme.com/git/marketplace.git');
|
|
38
|
+
expect(withConnectionKey('<external-api-key>')).toBe(
|
|
39
|
+
'https://key:<external-api-key>@kb.acme.com/git/marketplace.git',
|
|
40
|
+
);
|
|
41
|
+
expect(marketplaceCommands('<external-api-key>').claude).not.toContain('%3C');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('keeps a real key byte for byte — tenant prefix plus base64url, with its dashes and underscores', () => {
|
|
45
|
+
configureMarketplaceGitUrl('https://kb.acme.com/git/marketplace.git');
|
|
46
|
+
const key = 'corestaging_Ab-9_x2C9-Nmm_ic';
|
|
47
|
+
expect(withConnectionKey(key)).toBe(`https://key:${key}@kb.acme.com/git/marketplace.git`);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('keeps a non-default port in the remote', () => {
|
|
51
|
+
configureMarketplaceGitUrl('http://localhost:3000/git/marketplace.git');
|
|
52
|
+
expect(withConnectionKey('bevel_abc')).toBe('http://key:bevel_abc@localhost:3000/git/marketplace.git');
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -14,13 +14,15 @@ import { cn } from '../../lib/utils';
|
|
|
14
14
|
* tightened tracking so digits line up.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
export type BadgeTone = 'neutral' | 'ok' | 'wait' | 'danger' | 'outline';
|
|
17
|
+
export type BadgeTone = 'neutral' | 'ok' | 'wait' | 'urgent' | 'danger' | 'outline';
|
|
18
18
|
export type BadgeSize = 'sm' | 'xs';
|
|
19
19
|
|
|
20
20
|
const TONE: Record<BadgeTone, string> = {
|
|
21
21
|
neutral: 'bg-sunken text-ink-muted',
|
|
22
22
|
ok: 'bg-ok-soft text-ok',
|
|
23
23
|
wait: 'bg-wait-soft text-wait font-semibold',
|
|
24
|
+
// Above wait, below danger: blocking other people, not just the reader.
|
|
25
|
+
urgent: 'bg-urgent-soft text-urgent font-semibold',
|
|
24
26
|
danger: 'bg-danger-soft text-danger font-semibold',
|
|
25
27
|
outline: 'border border-line bg-transparent text-ink-muted',
|
|
26
28
|
};
|
|
@@ -16,10 +16,14 @@ import { cn } from '../../lib/utils';
|
|
|
16
16
|
* conditional element.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
export type BannerTone = 'wait' | 'ok' | 'danger' | 'neutral';
|
|
19
|
+
export type BannerTone = 'wait' | 'urgent' | 'ok' | 'danger' | 'neutral';
|
|
20
20
|
|
|
21
21
|
const TONE: Record<BannerTone, string> = {
|
|
22
22
|
wait: 'bg-wait-soft text-ink',
|
|
23
|
+
// Above wait, below danger: blocking other people, not just the reader.
|
|
24
|
+
// Orange ink, unlike wait's neutral ink: amber text on amber fails contrast
|
|
25
|
+
// (2.6:1), orange on its soft ground passes AA (5.1:1).
|
|
26
|
+
urgent: 'bg-urgent-soft text-urgent',
|
|
23
27
|
ok: 'bg-ok-soft text-ok',
|
|
24
28
|
danger: 'bg-danger-soft text-danger',
|
|
25
29
|
neutral: 'bg-sunken text-ink',
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The per-user marketplace git remote, as `/api/config` names it — the same
|
|
3
|
+
* "configured at boot, read through a function" shape as `mcpEndpointUrl`
|
|
4
|
+
* (see `shared/mcp/connect-snippets.ts` for why a module-scope constant would
|
|
5
|
+
* snapshot the wrong value).
|
|
6
|
+
*
|
|
7
|
+
* The URL never carries a credential: the person adds their own connection
|
|
8
|
+
* key when they paste the command, and `withConnectionKey` is how the
|
|
9
|
+
* settings card composes that.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const GIT_PATH = '/git/marketplace.git';
|
|
13
|
+
|
|
14
|
+
let configured: string | null = null;
|
|
15
|
+
|
|
16
|
+
/** Record what the server said; absent or unusable falls back to the origin. */
|
|
17
|
+
export function configureMarketplaceGitUrl(url: unknown): void {
|
|
18
|
+
if (typeof url !== 'string' || url.trim() === '') {
|
|
19
|
+
configured = null;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const parsed = new URL(url);
|
|
24
|
+
if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
|
|
25
|
+
configured = null;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
parsed.username = '';
|
|
29
|
+
parsed.password = '';
|
|
30
|
+
configured = parsed.toString();
|
|
31
|
+
} catch {
|
|
32
|
+
configured = null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The remote to show people, without any credential. */
|
|
37
|
+
export function marketplaceGitUrl(): string {
|
|
38
|
+
return configured ?? `${window.location.origin}${GIT_PATH}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The remote with a connection key in the userinfo — what git sends as HTTP
|
|
43
|
+
* Basic, and what Claude Code's background refresh needs because it disables
|
|
44
|
+
* credential helpers. `key` is the placeholder when the person has not
|
|
45
|
+
* minted one yet.
|
|
46
|
+
*
|
|
47
|
+
* Spliced as TEXT, not set through `URL.password`: the URL parser
|
|
48
|
+
* percent-encodes what it is given, and the placeholder `<external-api-key>`
|
|
49
|
+
* came out as `%3Cexternal-api-key%3E` — a thing to paste that looks like a
|
|
50
|
+
* secret. A real key never needs encoding: it is a tenant prefix plus base64url,
|
|
51
|
+
* all of it URL-safe by construction.
|
|
52
|
+
*/
|
|
53
|
+
export function withConnectionKey(key: string): string {
|
|
54
|
+
const { protocol, host, pathname } = new URL(marketplaceGitUrl());
|
|
55
|
+
return `${protocol}//key:${key}@${host}${pathname}`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The marketplace's registered name — what `plugin@<name>` refers to in Claude Code. */
|
|
59
|
+
export const MARKETPLACE_NAME = 'hexis';
|
|
60
|
+
/** The one-install bundle plugin every compiled marketplace carries. */
|
|
61
|
+
export const BUNDLE_PLUGIN = 'hexis-all';
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The KIND stored on a connection key minted when a person connects an
|
|
65
|
+
* account on a product that treats this deployment as a GitHub Enterprise
|
|
66
|
+
* host (claude.ai, Cowork) — the backend's `GITHUB_LINK_KEY_KIND`, spelled
|
|
67
|
+
* once more here so the key list can tell those links from keys people
|
|
68
|
+
* created by hand. The kind, never the label: a label is free text anyone
|
|
69
|
+
* can type.
|
|
70
|
+
*/
|
|
71
|
+
export const GITHUB_LINK_KIND = 'github-link';
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The three one-liners the settings page shows, with the key in the URL —
|
|
75
|
+
* Claude Code's background refresh disables credential helpers, so the key
|
|
76
|
+
* has nowhere else to live. `key` may be a placeholder.
|
|
77
|
+
*/
|
|
78
|
+
export function marketplaceCommands(key: string): { claude: string; codex: string; skills: string } {
|
|
79
|
+
const url = withConnectionKey(key);
|
|
80
|
+
return {
|
|
81
|
+
claude: `claude plugin marketplace add ${url} && claude plugin install ${BUNDLE_PLUGIN}@${MARKETPLACE_NAME}`,
|
|
82
|
+
codex: `codex plugin marketplace add ${url}`,
|
|
83
|
+
skills: `npx skills add ${url} --all -y`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** For tests — module-global state must not leak between them. */
|
|
88
|
+
export function resetMarketplaceGitUrlForTests(): void {
|
|
89
|
+
configured = null;
|
|
90
|
+
}
|
|
@@ -70,10 +70,19 @@
|
|
|
70
70
|
--color-ok: #337b58;
|
|
71
71
|
--color-wait: #c79100;
|
|
72
72
|
--color-wait-dot: #f2c100;
|
|
73
|
+
/* `urgent` sits between wait and danger: something that needs a person,
|
|
74
|
+
like wait, but is blocking OTHER people right now — a plugin's members
|
|
75
|
+
who cannot read a skill it ships — rather than only the reader's own
|
|
76
|
+
setup. Orange, so it ranks above amber at a glance without borrowing
|
|
77
|
+
red's "broken" claim. 5.1:1 on `urgent-soft`, 5.8:1 on white — it is
|
|
78
|
+
used as ink on both, unlike `wait`, which is too light for text on its
|
|
79
|
+
own soft ground. */
|
|
80
|
+
--color-urgent: #b8390a;
|
|
73
81
|
--color-danger: #b3261e;
|
|
74
82
|
|
|
75
83
|
--color-ok-soft: #ebf5ee;
|
|
76
84
|
--color-wait-soft: #fef8dc;
|
|
85
|
+
--color-urgent-soft: #fdeee4;
|
|
77
86
|
--color-danger-soft: #fdedeb;
|
|
78
87
|
|
|
79
88
|
/* word-level diff marks inside a document */
|