@getcatalystiq/agent-plane-ui 0.1.12 → 0.1.13
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/dist/chunk-HMB7OKXO.js +201 -0
- package/dist/chunk-TZGIXZON.cjs +242 -0
- package/dist/editor.cjs +551 -0
- package/dist/editor.d.cts +30 -1
- package/dist/editor.d.ts +30 -1
- package/dist/editor.js +545 -0
- package/dist/index.cjs +590 -458
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +306 -223
- package/package.json +2 -2
package/dist/editor.js
CHANGED
|
@@ -1 +1,546 @@
|
|
|
1
|
+
import { Badge, Button, Input, useNavigation, useAgentPlaneClient, useApi, Skeleton, Card, CardHeader, CardTitle, CardContent } from './chunk-HMB7OKXO.js';
|
|
2
|
+
import { useState, useEffect, useRef, useMemo, useCallback } from 'react';
|
|
3
|
+
import CodeMirror from '@uiw/react-codemirror';
|
|
4
|
+
import { markdown } from '@codemirror/lang-markdown';
|
|
5
|
+
import { javascript } from '@codemirror/lang-javascript';
|
|
6
|
+
import { json } from '@codemirror/lang-json';
|
|
7
|
+
import { oneDark } from '@codemirror/theme-one-dark';
|
|
8
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
1
9
|
|
|
10
|
+
function getLanguageExtension(filename) {
|
|
11
|
+
const ext = filename.split(".").pop()?.toLowerCase();
|
|
12
|
+
switch (ext) {
|
|
13
|
+
case "md":
|
|
14
|
+
return [markdown()];
|
|
15
|
+
case "json":
|
|
16
|
+
return [json()];
|
|
17
|
+
case "js":
|
|
18
|
+
case "ts":
|
|
19
|
+
case "jsx":
|
|
20
|
+
case "tsx":
|
|
21
|
+
return [javascript({ typescript: ext === "ts" || ext === "tsx", jsx: ext === "jsx" || ext === "tsx" })];
|
|
22
|
+
default:
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function buildTree(files) {
|
|
27
|
+
const rootFiles = [];
|
|
28
|
+
const dirMap = /* @__PURE__ */ new Map();
|
|
29
|
+
function ensureDir(dirPath) {
|
|
30
|
+
const existing = dirMap.get(dirPath);
|
|
31
|
+
if (existing) return existing;
|
|
32
|
+
const parts = dirPath.split("/");
|
|
33
|
+
const node = {
|
|
34
|
+
name: parts[parts.length - 1] ?? dirPath,
|
|
35
|
+
fullPath: dirPath,
|
|
36
|
+
children: [],
|
|
37
|
+
files: []
|
|
38
|
+
};
|
|
39
|
+
dirMap.set(dirPath, node);
|
|
40
|
+
if (parts.length > 1) {
|
|
41
|
+
const parentPath = parts.slice(0, -1).join("/");
|
|
42
|
+
const parent = ensureDir(parentPath);
|
|
43
|
+
if (!parent.children.some((c) => c.fullPath === dirPath)) {
|
|
44
|
+
parent.children.push(node);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return node;
|
|
48
|
+
}
|
|
49
|
+
for (const file of files) {
|
|
50
|
+
const slashIdx = file.path.lastIndexOf("/");
|
|
51
|
+
if (slashIdx === -1) {
|
|
52
|
+
rootFiles.push(file);
|
|
53
|
+
} else {
|
|
54
|
+
const dirPath = file.path.slice(0, slashIdx);
|
|
55
|
+
const dir = ensureDir(dirPath);
|
|
56
|
+
dir.files.push(file);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const topLevel = [];
|
|
60
|
+
for (const node of dirMap.values()) {
|
|
61
|
+
if (!node.fullPath.includes("/")) {
|
|
62
|
+
topLevel.push(node);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function sortNode(node) {
|
|
66
|
+
node.children.sort((a, b) => a.name.localeCompare(b.name));
|
|
67
|
+
node.files.sort((a, b) => a.path.localeCompare(b.path));
|
|
68
|
+
node.children.forEach(sortNode);
|
|
69
|
+
}
|
|
70
|
+
topLevel.forEach(sortNode);
|
|
71
|
+
topLevel.sort((a, b) => a.name.localeCompare(b.name));
|
|
72
|
+
rootFiles.sort((a, b) => a.path.localeCompare(b.path));
|
|
73
|
+
return { rootFiles, rootDirs: topLevel };
|
|
74
|
+
}
|
|
75
|
+
function collectAllDirPaths(nodes) {
|
|
76
|
+
const paths = /* @__PURE__ */ new Set();
|
|
77
|
+
function walk(node) {
|
|
78
|
+
paths.add(node.fullPath);
|
|
79
|
+
node.children.forEach(walk);
|
|
80
|
+
}
|
|
81
|
+
nodes.forEach(walk);
|
|
82
|
+
return paths;
|
|
83
|
+
}
|
|
84
|
+
function FileTreeEditor({
|
|
85
|
+
initialFiles,
|
|
86
|
+
onSave,
|
|
87
|
+
onChange,
|
|
88
|
+
readOnly = false,
|
|
89
|
+
hideSave = false,
|
|
90
|
+
title = "Files",
|
|
91
|
+
saveLabel = "Save",
|
|
92
|
+
addFolderLabel = "Folder",
|
|
93
|
+
newFileTemplate = { filename: "SKILL.md", content: "# New\n\nDescribe this...\n" },
|
|
94
|
+
savedVersion
|
|
95
|
+
}) {
|
|
96
|
+
const [files, setFiles] = useState(initialFiles);
|
|
97
|
+
const [selectedPath, setSelectedPath] = useState(
|
|
98
|
+
initialFiles.length > 0 ? initialFiles[0]?.path ?? null : null
|
|
99
|
+
);
|
|
100
|
+
const [saving, setSaving] = useState(false);
|
|
101
|
+
const [expanded, setExpanded] = useState(() => {
|
|
102
|
+
const { rootDirs } = buildTree(initialFiles);
|
|
103
|
+
return collectAllDirPaths(rootDirs);
|
|
104
|
+
});
|
|
105
|
+
const [showAddFolder, setShowAddFolder] = useState(false);
|
|
106
|
+
const [newFolderName, setNewFolderName] = useState("");
|
|
107
|
+
const [addingFileInDir, setAddingFileInDir] = useState(null);
|
|
108
|
+
const [newFileName, setNewFileName] = useState("");
|
|
109
|
+
const [savedSnapshot, setSavedSnapshot] = useState(() => JSON.stringify(initialFiles));
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
const snap = JSON.stringify(initialFiles);
|
|
112
|
+
setSavedSnapshot(snap);
|
|
113
|
+
setFiles(initialFiles);
|
|
114
|
+
const { rootDirs } = buildTree(initialFiles);
|
|
115
|
+
setExpanded(collectAllDirPaths(rootDirs));
|
|
116
|
+
}, [initialFiles]);
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
if (savedVersion !== void 0 && savedVersion > 0) {
|
|
119
|
+
setSavedSnapshot(JSON.stringify(files));
|
|
120
|
+
}
|
|
121
|
+
}, [savedVersion]);
|
|
122
|
+
const onChangeRef = useRef(onChange);
|
|
123
|
+
onChangeRef.current = onChange;
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
if (onChangeRef.current && JSON.stringify(files) !== savedSnapshot) {
|
|
126
|
+
onChangeRef.current(files);
|
|
127
|
+
}
|
|
128
|
+
}, [files, savedSnapshot]);
|
|
129
|
+
const isDirty = useMemo(
|
|
130
|
+
() => JSON.stringify(files) !== savedSnapshot,
|
|
131
|
+
[files, savedSnapshot]
|
|
132
|
+
);
|
|
133
|
+
const tree = useMemo(() => buildTree(files), [files]);
|
|
134
|
+
const activeFile = useMemo(
|
|
135
|
+
() => selectedPath ? files.find((f) => f.path === selectedPath) ?? null : null,
|
|
136
|
+
[files, selectedPath]
|
|
137
|
+
);
|
|
138
|
+
const handleEditorChange = useCallback((value) => {
|
|
139
|
+
if (readOnly || !selectedPath) return;
|
|
140
|
+
setFiles((prev) => prev.map((f) => f.path === selectedPath ? { ...f, content: value } : f));
|
|
141
|
+
}, [readOnly, selectedPath]);
|
|
142
|
+
function toggleExpand(dirPath) {
|
|
143
|
+
setExpanded((prev) => {
|
|
144
|
+
const next = new Set(prev);
|
|
145
|
+
if (next.has(dirPath)) {
|
|
146
|
+
next.delete(dirPath);
|
|
147
|
+
} else {
|
|
148
|
+
next.add(dirPath);
|
|
149
|
+
}
|
|
150
|
+
return next;
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function addFolder() {
|
|
154
|
+
const name = newFolderName.trim();
|
|
155
|
+
if (!name) return;
|
|
156
|
+
const filePath = `${name}/${newFileTemplate.filename}`;
|
|
157
|
+
if (files.some((f) => f.path === filePath)) return;
|
|
158
|
+
const content = newFileTemplate.content.replace("# New", `# ${name}`);
|
|
159
|
+
setFiles((prev) => [...prev, { path: filePath, content }]);
|
|
160
|
+
setSelectedPath(filePath);
|
|
161
|
+
setExpanded((prev) => /* @__PURE__ */ new Set([...prev, name]));
|
|
162
|
+
setNewFolderName("");
|
|
163
|
+
setShowAddFolder(false);
|
|
164
|
+
}
|
|
165
|
+
function removeDir(dirPath) {
|
|
166
|
+
const prefix = dirPath + "/";
|
|
167
|
+
const affectedFiles = files.filter((f) => f.path.startsWith(prefix));
|
|
168
|
+
if (affectedFiles.length === 0) return;
|
|
169
|
+
if (!confirm(`Remove "${dirPath}" and all ${affectedFiles.length} file(s)?`)) return;
|
|
170
|
+
setFiles((prev) => prev.filter((f) => !f.path.startsWith(prefix)));
|
|
171
|
+
if (selectedPath && selectedPath.startsWith(prefix)) {
|
|
172
|
+
setSelectedPath(null);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function removeFile(filePath) {
|
|
176
|
+
const fileName = filePath.split("/").pop() ?? filePath;
|
|
177
|
+
if (!confirm(`Remove file "${fileName}"?`)) return;
|
|
178
|
+
setFiles((prev) => prev.filter((f) => f.path !== filePath));
|
|
179
|
+
if (selectedPath === filePath) {
|
|
180
|
+
setSelectedPath(null);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function addFileInDir(dirPath) {
|
|
184
|
+
const name = newFileName.trim();
|
|
185
|
+
if (!name) return;
|
|
186
|
+
const filePath = dirPath ? `${dirPath}/${name}` : name;
|
|
187
|
+
if (files.some((f) => f.path === filePath)) return;
|
|
188
|
+
setFiles((prev) => [...prev, { path: filePath, content: "" }]);
|
|
189
|
+
setSelectedPath(filePath);
|
|
190
|
+
setNewFileName("");
|
|
191
|
+
setAddingFileInDir(null);
|
|
192
|
+
}
|
|
193
|
+
async function handleSave() {
|
|
194
|
+
setSaving(true);
|
|
195
|
+
try {
|
|
196
|
+
await onSave(files);
|
|
197
|
+
} finally {
|
|
198
|
+
setSaving(false);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function renderTreeNode(node, depth) {
|
|
202
|
+
const isExpanded = expanded.has(node.fullPath);
|
|
203
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
204
|
+
/* @__PURE__ */ jsxs(
|
|
205
|
+
"div",
|
|
206
|
+
{
|
|
207
|
+
className: `flex items-center justify-between cursor-pointer hover:bg-muted/50 py-1 pr-2`,
|
|
208
|
+
style: { paddingLeft: `${depth * 16 + 8}px` },
|
|
209
|
+
onClick: () => toggleExpand(node.fullPath),
|
|
210
|
+
children: [
|
|
211
|
+
/* @__PURE__ */ jsxs("span", { className: "font-medium text-xs truncate flex items-center gap-1", children: [
|
|
212
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: isExpanded ? "\u25BE" : "\u25B8" }),
|
|
213
|
+
node.name,
|
|
214
|
+
"/"
|
|
215
|
+
] }),
|
|
216
|
+
!readOnly && /* @__PURE__ */ jsx(
|
|
217
|
+
"button",
|
|
218
|
+
{
|
|
219
|
+
onClick: (e) => {
|
|
220
|
+
e.stopPropagation();
|
|
221
|
+
removeDir(node.fullPath);
|
|
222
|
+
},
|
|
223
|
+
className: "text-muted-foreground hover:text-destructive text-xs ml-1 shrink-0",
|
|
224
|
+
children: "\xD7"
|
|
225
|
+
}
|
|
226
|
+
)
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
),
|
|
230
|
+
isExpanded && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
231
|
+
node.children.map((child) => renderTreeNode(child, depth + 1)),
|
|
232
|
+
node.files.map((file) => {
|
|
233
|
+
const fileName = file.path.split("/").pop() ?? file.path;
|
|
234
|
+
return /* @__PURE__ */ jsxs(
|
|
235
|
+
"div",
|
|
236
|
+
{
|
|
237
|
+
className: `flex items-center justify-between cursor-pointer hover:bg-muted/30 py-1 pr-2 ${selectedPath === file.path ? "bg-primary/10 text-primary" : ""}`,
|
|
238
|
+
style: { paddingLeft: `${(depth + 1) * 16 + 8}px` },
|
|
239
|
+
onClick: () => setSelectedPath(file.path),
|
|
240
|
+
children: [
|
|
241
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs truncate", children: fileName }),
|
|
242
|
+
!readOnly && /* @__PURE__ */ jsx(
|
|
243
|
+
"button",
|
|
244
|
+
{
|
|
245
|
+
onClick: (e) => {
|
|
246
|
+
e.stopPropagation();
|
|
247
|
+
removeFile(file.path);
|
|
248
|
+
},
|
|
249
|
+
className: "text-muted-foreground hover:text-destructive text-xs ml-1 shrink-0",
|
|
250
|
+
children: "\xD7"
|
|
251
|
+
}
|
|
252
|
+
)
|
|
253
|
+
]
|
|
254
|
+
},
|
|
255
|
+
file.path
|
|
256
|
+
);
|
|
257
|
+
}),
|
|
258
|
+
!readOnly && /* @__PURE__ */ jsx("div", { style: { paddingLeft: `${(depth + 1) * 16 + 8}px` }, className: "py-1 pr-2", children: addingFileInDir === node.fullPath ? /* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
|
|
259
|
+
/* @__PURE__ */ jsx(
|
|
260
|
+
Input,
|
|
261
|
+
{
|
|
262
|
+
value: newFileName,
|
|
263
|
+
onChange: (e) => setNewFileName(e.target.value),
|
|
264
|
+
placeholder: "file.md",
|
|
265
|
+
className: "h-6 text-xs",
|
|
266
|
+
onKeyDown: (e) => e.key === "Enter" && addFileInDir(node.fullPath),
|
|
267
|
+
autoFocus: true
|
|
268
|
+
}
|
|
269
|
+
),
|
|
270
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => addFileInDir(node.fullPath), size: "sm", className: "h-6 text-xs px-2", children: "+" })
|
|
271
|
+
] }) : /* @__PURE__ */ jsx(
|
|
272
|
+
"button",
|
|
273
|
+
{
|
|
274
|
+
onClick: () => {
|
|
275
|
+
setAddingFileInDir(node.fullPath);
|
|
276
|
+
setNewFileName("");
|
|
277
|
+
},
|
|
278
|
+
className: "text-xs text-primary hover:underline",
|
|
279
|
+
children: "+ File"
|
|
280
|
+
}
|
|
281
|
+
) })
|
|
282
|
+
] })
|
|
283
|
+
] }, node.fullPath);
|
|
284
|
+
}
|
|
285
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
286
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-3", children: [
|
|
287
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
288
|
+
/* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold", children: title }),
|
|
289
|
+
isDirty && !readOnly && /* @__PURE__ */ jsx(Badge, { variant: "destructive", className: "text-xs", children: "Unsaved changes" }),
|
|
290
|
+
readOnly && /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: "Read-only" })
|
|
291
|
+
] }),
|
|
292
|
+
!readOnly && !hideSave && /* @__PURE__ */ jsx(Button, { onClick: handleSave, disabled: saving || !isDirty, size: "sm", children: saving ? "Saving..." : saveLabel })
|
|
293
|
+
] }),
|
|
294
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: "flex gap-4 min-h-[500px]", children: [
|
|
295
|
+
/* @__PURE__ */ jsxs("div", { className: "w-64 shrink-0 border border-border rounded-md overflow-hidden", children: [
|
|
296
|
+
/* @__PURE__ */ jsxs("div", { className: "p-2 bg-muted/50 border-b border-border flex items-center justify-between", children: [
|
|
297
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: title }),
|
|
298
|
+
!readOnly && /* @__PURE__ */ jsxs(
|
|
299
|
+
"button",
|
|
300
|
+
{
|
|
301
|
+
onClick: () => setShowAddFolder(!showAddFolder),
|
|
302
|
+
className: "text-xs text-primary hover:underline",
|
|
303
|
+
children: [
|
|
304
|
+
"+ ",
|
|
305
|
+
addFolderLabel
|
|
306
|
+
]
|
|
307
|
+
}
|
|
308
|
+
)
|
|
309
|
+
] }),
|
|
310
|
+
showAddFolder && !readOnly && /* @__PURE__ */ jsxs("div", { className: "p-2 border-b border-border flex gap-1", children: [
|
|
311
|
+
/* @__PURE__ */ jsx(
|
|
312
|
+
Input,
|
|
313
|
+
{
|
|
314
|
+
value: newFolderName,
|
|
315
|
+
onChange: (e) => setNewFolderName(e.target.value),
|
|
316
|
+
placeholder: "folder-name",
|
|
317
|
+
className: "h-7 text-xs",
|
|
318
|
+
onKeyDown: (e) => e.key === "Enter" && addFolder(),
|
|
319
|
+
autoFocus: true
|
|
320
|
+
}
|
|
321
|
+
),
|
|
322
|
+
/* @__PURE__ */ jsx(Button, { onClick: addFolder, size: "sm", className: "h-7 text-xs px-2", children: "Add" })
|
|
323
|
+
] }),
|
|
324
|
+
/* @__PURE__ */ jsxs("div", { className: "text-sm overflow-y-auto", children: [
|
|
325
|
+
tree.rootFiles.map((file) => /* @__PURE__ */ jsxs(
|
|
326
|
+
"div",
|
|
327
|
+
{
|
|
328
|
+
className: `flex items-center justify-between cursor-pointer hover:bg-muted/30 py-1 pr-2 ${selectedPath === file.path ? "bg-primary/10 text-primary" : ""}`,
|
|
329
|
+
style: { paddingLeft: "8px" },
|
|
330
|
+
onClick: () => setSelectedPath(file.path),
|
|
331
|
+
children: [
|
|
332
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs truncate", children: file.path }),
|
|
333
|
+
!readOnly && /* @__PURE__ */ jsx(
|
|
334
|
+
"button",
|
|
335
|
+
{
|
|
336
|
+
onClick: (e) => {
|
|
337
|
+
e.stopPropagation();
|
|
338
|
+
removeFile(file.path);
|
|
339
|
+
},
|
|
340
|
+
className: "text-muted-foreground hover:text-destructive text-xs ml-1 shrink-0",
|
|
341
|
+
children: "\xD7"
|
|
342
|
+
}
|
|
343
|
+
)
|
|
344
|
+
]
|
|
345
|
+
},
|
|
346
|
+
file.path
|
|
347
|
+
)),
|
|
348
|
+
tree.rootDirs.map((node) => renderTreeNode(node, 0)),
|
|
349
|
+
files.length === 0 && /* @__PURE__ */ jsx("p", { className: "p-3 text-xs text-muted-foreground", children: readOnly ? "No files." : `No ${title.toLowerCase()} yet. Add a ${addFolderLabel.toLowerCase()} to get started.` })
|
|
350
|
+
] })
|
|
351
|
+
] }),
|
|
352
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 border border-border rounded-md overflow-hidden", children: activeFile ? /* @__PURE__ */ jsxs("div", { className: "h-full flex flex-col", children: [
|
|
353
|
+
/* @__PURE__ */ jsx("div", { className: "px-3 py-1.5 bg-muted/50 border-b border-border text-xs text-muted-foreground", children: activeFile.path }),
|
|
354
|
+
/* @__PURE__ */ jsx(
|
|
355
|
+
CodeMirror,
|
|
356
|
+
{
|
|
357
|
+
value: activeFile.content,
|
|
358
|
+
onChange: handleEditorChange,
|
|
359
|
+
readOnly,
|
|
360
|
+
theme: oneDark,
|
|
361
|
+
extensions: getLanguageExtension(activeFile.path),
|
|
362
|
+
height: "100%",
|
|
363
|
+
className: "flex-1 overflow-auto",
|
|
364
|
+
basicSetup: {
|
|
365
|
+
lineNumbers: true,
|
|
366
|
+
foldGutter: true,
|
|
367
|
+
bracketMatching: true
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
)
|
|
371
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "h-full flex items-center justify-center text-muted-foreground text-sm", children: [
|
|
372
|
+
"Select a file to ",
|
|
373
|
+
readOnly ? "view" : "edit"
|
|
374
|
+
] }) })
|
|
375
|
+
] }) })
|
|
376
|
+
] });
|
|
377
|
+
}
|
|
378
|
+
function PluginEditorPage({ marketplaceId, pluginName }) {
|
|
379
|
+
const { LinkComponent, basePath } = useNavigation();
|
|
380
|
+
const client = useAgentPlaneClient();
|
|
381
|
+
const { data: pluginFiles, error, isLoading } = useApi(
|
|
382
|
+
`marketplace-${marketplaceId}-plugin-files-${pluginName}`,
|
|
383
|
+
(c) => c.pluginMarketplaces.getPluginFiles(marketplaceId, pluginName)
|
|
384
|
+
);
|
|
385
|
+
const [skills, setSkills] = useState([]);
|
|
386
|
+
const [agents, setAgents] = useState([]);
|
|
387
|
+
const [mcpJson, setMcpJson] = useState("");
|
|
388
|
+
const [activeTab, setActiveTab] = useState("agents");
|
|
389
|
+
const [saving, setSaving] = useState(false);
|
|
390
|
+
const [saveError, setSaveError] = useState("");
|
|
391
|
+
const [success, setSuccess] = useState("");
|
|
392
|
+
const [savedVersion, setSavedVersion] = useState(0);
|
|
393
|
+
const [initialized, setInitialized] = useState(false);
|
|
394
|
+
if (pluginFiles && !initialized) {
|
|
395
|
+
setSkills(pluginFiles.skills);
|
|
396
|
+
setAgents(pluginFiles.agents);
|
|
397
|
+
setMcpJson(pluginFiles.mcpJson ?? "");
|
|
398
|
+
setInitialized(true);
|
|
399
|
+
}
|
|
400
|
+
const readOnly = pluginFiles ? !pluginFiles.isOwned : true;
|
|
401
|
+
const handleSkillsChange = useCallback((updated) => {
|
|
402
|
+
setSkills(updated);
|
|
403
|
+
}, []);
|
|
404
|
+
const handleAgentsChange = useCallback((updated) => {
|
|
405
|
+
setAgents(updated);
|
|
406
|
+
}, []);
|
|
407
|
+
const noopSave = useCallback(async () => {
|
|
408
|
+
}, []);
|
|
409
|
+
async function handleSaveAll() {
|
|
410
|
+
setSaving(true);
|
|
411
|
+
setSaveError("");
|
|
412
|
+
setSuccess("");
|
|
413
|
+
try {
|
|
414
|
+
const result = await client.pluginMarketplaces.savePluginFiles(
|
|
415
|
+
marketplaceId,
|
|
416
|
+
pluginName,
|
|
417
|
+
{
|
|
418
|
+
skills,
|
|
419
|
+
agents,
|
|
420
|
+
mcpJson: mcpJson || null
|
|
421
|
+
}
|
|
422
|
+
);
|
|
423
|
+
setSuccess(`Saved (commit ${result.commitSha.slice(0, 7)})`);
|
|
424
|
+
setSavedVersion((v) => v + 1);
|
|
425
|
+
} catch (err) {
|
|
426
|
+
setSaveError(err instanceof Error ? err.message : "Unknown error");
|
|
427
|
+
} finally {
|
|
428
|
+
setSaving(false);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
if (error) {
|
|
432
|
+
return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center min-h-[40vh]", children: /* @__PURE__ */ jsxs("p", { className: "text-destructive", children: [
|
|
433
|
+
"Failed to load plugin files: ",
|
|
434
|
+
error.message
|
|
435
|
+
] }) });
|
|
436
|
+
}
|
|
437
|
+
if (isLoading || !pluginFiles) {
|
|
438
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
439
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-48" }),
|
|
440
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-96" }),
|
|
441
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-[500px] rounded-lg" })
|
|
442
|
+
] });
|
|
443
|
+
}
|
|
444
|
+
const tabs = [
|
|
445
|
+
{ id: "agents", label: "Agents", count: agents.length },
|
|
446
|
+
{ id: "skills", label: "Skills", count: skills.length },
|
|
447
|
+
{ id: "connectors", label: "Connectors", count: mcpJson ? 1 : 0 }
|
|
448
|
+
];
|
|
449
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
450
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
451
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-3 mb-1", children: /* @__PURE__ */ jsx(
|
|
452
|
+
LinkComponent,
|
|
453
|
+
{
|
|
454
|
+
href: `${basePath}/plugin-marketplaces/${marketplaceId}`,
|
|
455
|
+
className: "text-muted-foreground hover:text-foreground text-sm",
|
|
456
|
+
children: "\u2190 Back to marketplace"
|
|
457
|
+
}
|
|
458
|
+
) }),
|
|
459
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
460
|
+
/* @__PURE__ */ jsx("h1", { className: "text-2xl font-semibold", children: pluginName }),
|
|
461
|
+
readOnly ? /* @__PURE__ */ jsx(Badge, { variant: "outline", children: "Read-only" }) : /* @__PURE__ */ jsx(Badge, { variant: "secondary", children: "Editable" })
|
|
462
|
+
] })
|
|
463
|
+
] }),
|
|
464
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-end border-b border-border", children: [
|
|
465
|
+
/* @__PURE__ */ jsx("div", { className: "flex gap-1", children: tabs.map((tab) => /* @__PURE__ */ jsxs(
|
|
466
|
+
"button",
|
|
467
|
+
{
|
|
468
|
+
onClick: () => setActiveTab(tab.id),
|
|
469
|
+
className: `px-4 py-2 text-sm font-medium border-b-2 transition-colors ${activeTab === tab.id ? "border-primary text-foreground" : "border-transparent text-muted-foreground hover:text-foreground hover:border-muted-foreground/50"}`,
|
|
470
|
+
children: [
|
|
471
|
+
tab.label,
|
|
472
|
+
tab.count > 0 && /* @__PURE__ */ jsxs("span", { className: "ml-1.5 text-xs text-muted-foreground", children: [
|
|
473
|
+
"(",
|
|
474
|
+
tab.count,
|
|
475
|
+
")"
|
|
476
|
+
] })
|
|
477
|
+
]
|
|
478
|
+
},
|
|
479
|
+
tab.id
|
|
480
|
+
)) }),
|
|
481
|
+
!readOnly && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 ml-auto pb-2", children: [
|
|
482
|
+
saveError && /* @__PURE__ */ jsx("span", { className: "text-xs text-destructive", children: saveError }),
|
|
483
|
+
success && /* @__PURE__ */ jsx("span", { className: "text-xs text-green-500", children: success }),
|
|
484
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", onClick: handleSaveAll, disabled: saving, children: saving ? "Pushing to GitHub..." : "Save All to GitHub" })
|
|
485
|
+
] })
|
|
486
|
+
] }),
|
|
487
|
+
activeTab === "agents" && /* @__PURE__ */ jsx(
|
|
488
|
+
FileTreeEditor,
|
|
489
|
+
{
|
|
490
|
+
initialFiles: pluginFiles.agents,
|
|
491
|
+
onSave: noopSave,
|
|
492
|
+
onChange: readOnly ? void 0 : handleAgentsChange,
|
|
493
|
+
readOnly,
|
|
494
|
+
hideSave: !readOnly,
|
|
495
|
+
title: "Agents",
|
|
496
|
+
addFolderLabel: "Agent",
|
|
497
|
+
newFileTemplate: { filename: "agent.md", content: "---\nname: new-agent\ndescription: Describe what this agent does\n---\n\nYou are a specialized agent.\n" },
|
|
498
|
+
savedVersion
|
|
499
|
+
}
|
|
500
|
+
),
|
|
501
|
+
activeTab === "skills" && /* @__PURE__ */ jsx(
|
|
502
|
+
FileTreeEditor,
|
|
503
|
+
{
|
|
504
|
+
initialFiles: pluginFiles.skills,
|
|
505
|
+
onSave: noopSave,
|
|
506
|
+
onChange: readOnly ? void 0 : handleSkillsChange,
|
|
507
|
+
readOnly,
|
|
508
|
+
hideSave: !readOnly,
|
|
509
|
+
title: "Skills",
|
|
510
|
+
addFolderLabel: "Skill",
|
|
511
|
+
newFileTemplate: { filename: "SKILL.md", content: "# New\n\nDescribe this skill...\n" },
|
|
512
|
+
savedVersion
|
|
513
|
+
}
|
|
514
|
+
),
|
|
515
|
+
activeTab === "connectors" && /* @__PURE__ */ jsxs(Card, { children: [
|
|
516
|
+
/* @__PURE__ */ jsx(CardHeader, { className: "flex flex-row items-center justify-between", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
517
|
+
/* @__PURE__ */ jsx(CardTitle, { className: "text-base", children: "Connectors (.mcp.json)" }),
|
|
518
|
+
readOnly && /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: "Read-only" })
|
|
519
|
+
] }) }),
|
|
520
|
+
/* @__PURE__ */ jsxs(CardContent, { children: [
|
|
521
|
+
/* @__PURE__ */ jsxs("div", { className: "border border-border rounded-md overflow-hidden", children: [
|
|
522
|
+
/* @__PURE__ */ jsx("div", { className: "px-3 py-1.5 bg-muted/50 border-b border-border text-xs text-muted-foreground", children: ".mcp.json" }),
|
|
523
|
+
/* @__PURE__ */ jsx(
|
|
524
|
+
CodeMirror,
|
|
525
|
+
{
|
|
526
|
+
value: mcpJson,
|
|
527
|
+
onChange: (val) => !readOnly && setMcpJson(val),
|
|
528
|
+
readOnly,
|
|
529
|
+
theme: oneDark,
|
|
530
|
+
extensions: [json()],
|
|
531
|
+
height: "200px",
|
|
532
|
+
basicSetup: {
|
|
533
|
+
lineNumbers: true,
|
|
534
|
+
foldGutter: true,
|
|
535
|
+
bracketMatching: true
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
)
|
|
539
|
+
] }),
|
|
540
|
+
!mcpJson && !readOnly && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-2", children: "No .mcp.json found. Add connector definitions to suggest MCP servers for agents using this plugin." })
|
|
541
|
+
] })
|
|
542
|
+
] })
|
|
543
|
+
] });
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
export { FileTreeEditor, PluginEditorPage };
|