@myrialabs/clopen 0.4.4 → 0.4.6
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/backend/auth/permissions.ts +15 -1
- package/backend/database/migrations/044_create_skills_table.ts +29 -0
- package/backend/database/migrations/index.ts +7 -0
- package/backend/database/queries/index.ts +3 -1
- package/backend/database/queries/skill-queries.ts +105 -0
- package/backend/engine/adapters/claude/stream.ts +5 -0
- package/backend/engine/adapters/codex/credential.ts +120 -13
- package/backend/engine/adapters/codex/stream.ts +34 -8
- package/backend/engine/adapters/copilot/stream.ts +4 -0
- package/backend/engine/adapters/opencode/stream.ts +4 -0
- package/backend/engine/adapters/qwen/stream.ts +3 -0
- package/backend/engine/docs/lessons-learned.md +54 -50
- package/backend/git/git-service.ts +40 -0
- package/backend/index.ts +10 -1
- package/backend/mcp/README.md +77 -24
- package/backend/mcp/external/config.ts +82 -101
- package/backend/mcp/external/parse.test.ts +190 -0
- package/backend/mcp/external/parse.ts +293 -0
- package/backend/mcp/external/proxy.ts +202 -0
- package/backend/mcp/index.ts +6 -3
- package/backend/mcp/internal/remote-server.ts +103 -55
- package/backend/skills/index.ts +21 -0
- package/backend/skills/marketplace.ts +172 -0
- package/backend/skills/service.ts +245 -0
- package/backend/skills/spec.ts +214 -0
- package/backend/skills/store.ts +99 -0
- package/backend/skills/sync.ts +187 -0
- package/backend/snapshot/gitignore.ts +230 -7
- package/backend/snapshot/helpers.ts +34 -10
- package/backend/ws/files/read.ts +10 -1
- package/backend/ws/git/branch-name.ts +20 -4
- package/backend/ws/git/branch.ts +66 -11
- package/backend/ws/git/commit-message.ts +18 -3
- package/backend/ws/git/commit.ts +50 -16
- package/backend/ws/git/conflict.ts +47 -5
- package/backend/ws/git/diff.ts +38 -4
- package/backend/ws/git/log.ts +22 -2
- package/backend/ws/git/remote.ts +82 -33
- package/backend/ws/git/staging.ts +39 -9
- package/backend/ws/git/status.ts +52 -0
- package/backend/ws/index.ts +5 -1
- package/backend/ws/mcp/crud.ts +30 -1
- package/backend/ws/skills/catalog.ts +79 -0
- package/backend/ws/skills/crud.ts +123 -0
- package/backend/ws/skills/index.ts +15 -0
- package/backend/ws/snapshot/timeline.ts +1 -1
- package/dist/assets/main-BkMrek4_.css +1 -0
- package/dist/assets/{main-AqTMkV9D.js → main-TYNK6Orl.js} +332 -295
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/shared/types/git.ts +20 -0
- package/shared/utils/logger.ts +1 -0
- package/dist/assets/main-DJf71Zum.css +0 -1
package/backend/ws/git/remote.ts
CHANGED
|
@@ -3,14 +3,33 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { t } from 'elysia';
|
|
6
|
+
import path from 'node:path';
|
|
6
7
|
import { createRouter } from '$shared/utils/ws-server';
|
|
7
8
|
import { gitService } from '../../git/git-service';
|
|
8
9
|
import { requireProjectAccess } from '../access';
|
|
10
|
+
import { debug } from '$shared/utils/logger';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the working directory for a git operation. Defaults to the project
|
|
14
|
+
* root; when `repoPath` is provided it must already be inside the project.
|
|
15
|
+
*/
|
|
16
|
+
function resolveRepoCwd(projectPath: string, repoPath: string | undefined): string {
|
|
17
|
+
if (!repoPath) return projectPath;
|
|
18
|
+
const resolved = path.resolve(repoPath);
|
|
19
|
+
const projectRoot = path.resolve(projectPath);
|
|
20
|
+
const sep = path.sep;
|
|
21
|
+
if (resolved !== projectRoot && !resolved.startsWith(projectRoot + sep)) {
|
|
22
|
+
debug.warn('git', `Rejected nested repoPath outside project: ${resolved}`);
|
|
23
|
+
return projectPath;
|
|
24
|
+
}
|
|
25
|
+
return resolved;
|
|
26
|
+
}
|
|
9
27
|
|
|
10
28
|
export const remoteHandler = createRouter()
|
|
11
29
|
.http('git:remotes', {
|
|
12
30
|
data: t.Object({
|
|
13
|
-
projectId: t.String()
|
|
31
|
+
projectId: t.String(),
|
|
32
|
+
repoPath: t.Optional(t.String())
|
|
14
33
|
}),
|
|
15
34
|
response: t.Array(t.Object({
|
|
16
35
|
name: t.String(),
|
|
@@ -19,20 +38,23 @@ export const remoteHandler = createRouter()
|
|
|
19
38
|
}))
|
|
20
39
|
}, async ({ data, conn }) => {
|
|
21
40
|
const project = requireProjectAccess(conn, data.projectId);
|
|
22
|
-
|
|
41
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
42
|
+
return await gitService.getRemotes(cwd);
|
|
23
43
|
})
|
|
24
44
|
|
|
25
45
|
.http('git:fetch', {
|
|
26
46
|
data: t.Object({
|
|
27
47
|
projectId: t.String(),
|
|
28
|
-
remote: t.Optional(t.String())
|
|
48
|
+
remote: t.Optional(t.String()),
|
|
49
|
+
repoPath: t.Optional(t.String())
|
|
29
50
|
}),
|
|
30
51
|
response: t.Object({
|
|
31
52
|
message: t.String()
|
|
32
53
|
})
|
|
33
54
|
}, async ({ data, conn }) => {
|
|
34
55
|
const project = requireProjectAccess(conn, data.projectId);
|
|
35
|
-
const
|
|
56
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
57
|
+
const message = await gitService.fetch(cwd, data.remote);
|
|
36
58
|
return { message };
|
|
37
59
|
})
|
|
38
60
|
|
|
@@ -41,7 +63,8 @@ export const remoteHandler = createRouter()
|
|
|
41
63
|
projectId: t.String(),
|
|
42
64
|
remote: t.Optional(t.String()),
|
|
43
65
|
branch: t.Optional(t.String()),
|
|
44
|
-
rebase: t.Optional(t.Boolean())
|
|
66
|
+
rebase: t.Optional(t.Boolean()),
|
|
67
|
+
repoPath: t.Optional(t.String())
|
|
45
68
|
}),
|
|
46
69
|
response: t.Object({
|
|
47
70
|
success: t.Boolean(),
|
|
@@ -49,7 +72,8 @@ export const remoteHandler = createRouter()
|
|
|
49
72
|
})
|
|
50
73
|
}, async ({ data, conn }) => {
|
|
51
74
|
const project = requireProjectAccess(conn, data.projectId);
|
|
52
|
-
|
|
75
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
76
|
+
return await gitService.pull(cwd, data.remote, data.branch, data.rebase);
|
|
53
77
|
})
|
|
54
78
|
|
|
55
79
|
.http('git:push-advanced', {
|
|
@@ -62,7 +86,8 @@ export const remoteHandler = createRouter()
|
|
|
62
86
|
t.Literal('force')
|
|
63
87
|
]),
|
|
64
88
|
remote: t.Optional(t.String()),
|
|
65
|
-
branch: t.Optional(t.String())
|
|
89
|
+
branch: t.Optional(t.String()),
|
|
90
|
+
repoPath: t.Optional(t.String())
|
|
66
91
|
}),
|
|
67
92
|
response: t.Object({
|
|
68
93
|
success: t.Boolean(),
|
|
@@ -70,19 +95,22 @@ export const remoteHandler = createRouter()
|
|
|
70
95
|
})
|
|
71
96
|
}, async ({ data, conn }) => {
|
|
72
97
|
const project = requireProjectAccess(conn, data.projectId);
|
|
73
|
-
|
|
98
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
99
|
+
return await gitService.pushAdvanced(cwd, data.mode, data.remote, data.branch);
|
|
74
100
|
})
|
|
75
101
|
|
|
76
102
|
.http('git:fetch-all', {
|
|
77
103
|
data: t.Object({
|
|
78
|
-
projectId: t.String()
|
|
104
|
+
projectId: t.String(),
|
|
105
|
+
repoPath: t.Optional(t.String())
|
|
79
106
|
}),
|
|
80
107
|
response: t.Object({
|
|
81
108
|
message: t.String()
|
|
82
109
|
})
|
|
83
110
|
}, async ({ data, conn }) => {
|
|
84
111
|
const project = requireProjectAccess(conn, data.projectId);
|
|
85
|
-
const
|
|
112
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
113
|
+
const message = await gitService.fetchAll(cwd);
|
|
86
114
|
return { message };
|
|
87
115
|
})
|
|
88
116
|
|
|
@@ -91,7 +119,8 @@ export const remoteHandler = createRouter()
|
|
|
91
119
|
projectId: t.String(),
|
|
92
120
|
remote: t.Optional(t.String()),
|
|
93
121
|
branch: t.Optional(t.String()),
|
|
94
|
-
force: t.Optional(t.Boolean())
|
|
122
|
+
force: t.Optional(t.Boolean()),
|
|
123
|
+
repoPath: t.Optional(t.String())
|
|
95
124
|
}),
|
|
96
125
|
response: t.Object({
|
|
97
126
|
success: t.Boolean(),
|
|
@@ -99,7 +128,8 @@ export const remoteHandler = createRouter()
|
|
|
99
128
|
})
|
|
100
129
|
}, async ({ data, conn }) => {
|
|
101
130
|
const project = requireProjectAccess(conn, data.projectId);
|
|
102
|
-
|
|
131
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
132
|
+
return await gitService.push(cwd, data.remote, data.branch, data.force);
|
|
103
133
|
})
|
|
104
134
|
|
|
105
135
|
.http('git:add-remote', {
|
|
@@ -174,18 +204,21 @@ export const remoteHandler = createRouter()
|
|
|
174
204
|
data: t.Object({
|
|
175
205
|
projectId: t.String(),
|
|
176
206
|
remote: t.String(),
|
|
177
|
-
branch: t.String()
|
|
207
|
+
branch: t.String(),
|
|
208
|
+
repoPath: t.Optional(t.String())
|
|
178
209
|
}),
|
|
179
210
|
response: t.Object({ ok: t.Boolean() })
|
|
180
211
|
}, async ({ data, conn }) => {
|
|
181
212
|
const project = requireProjectAccess(conn, data.projectId);
|
|
182
|
-
|
|
213
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
214
|
+
await gitService.deleteRemoteBranch(cwd, data.remote, data.branch);
|
|
183
215
|
return { ok: true };
|
|
184
216
|
})
|
|
185
217
|
|
|
186
218
|
.http('git:stash-list', {
|
|
187
219
|
data: t.Object({
|
|
188
|
-
projectId: t.String()
|
|
220
|
+
projectId: t.String(),
|
|
221
|
+
repoPath: t.Optional(t.String())
|
|
189
222
|
}),
|
|
190
223
|
response: t.Array(t.Object({
|
|
191
224
|
index: t.Number(),
|
|
@@ -194,26 +227,30 @@ export const remoteHandler = createRouter()
|
|
|
194
227
|
}))
|
|
195
228
|
}, async ({ data, conn }) => {
|
|
196
229
|
const project = requireProjectAccess(conn, data.projectId);
|
|
197
|
-
|
|
230
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
231
|
+
return await gitService.stashList(cwd);
|
|
198
232
|
})
|
|
199
233
|
|
|
200
234
|
.http('git:stash-save', {
|
|
201
235
|
data: t.Object({
|
|
202
236
|
projectId: t.String(),
|
|
203
237
|
message: t.Optional(t.String()),
|
|
204
|
-
staged: t.Optional(t.Boolean())
|
|
238
|
+
staged: t.Optional(t.Boolean()),
|
|
239
|
+
repoPath: t.Optional(t.String())
|
|
205
240
|
}),
|
|
206
241
|
response: t.Object({ ok: t.Boolean() })
|
|
207
242
|
}, async ({ data, conn }) => {
|
|
208
243
|
const project = requireProjectAccess(conn, data.projectId);
|
|
209
|
-
|
|
244
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
245
|
+
await gitService.stashSave(cwd, data.message, data.staged);
|
|
210
246
|
return { ok: true };
|
|
211
247
|
})
|
|
212
248
|
|
|
213
249
|
.http('git:stash-pop', {
|
|
214
250
|
data: t.Object({
|
|
215
251
|
projectId: t.String(),
|
|
216
|
-
index: t.Optional(t.Number())
|
|
252
|
+
index: t.Optional(t.Number()),
|
|
253
|
+
repoPath: t.Optional(t.String())
|
|
217
254
|
}),
|
|
218
255
|
response: t.Object({
|
|
219
256
|
success: t.Boolean(),
|
|
@@ -222,25 +259,29 @@ export const remoteHandler = createRouter()
|
|
|
222
259
|
})
|
|
223
260
|
}, async ({ data, conn }) => {
|
|
224
261
|
const project = requireProjectAccess(conn, data.projectId);
|
|
225
|
-
|
|
262
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
263
|
+
return await gitService.stashPop(cwd, data.index);
|
|
226
264
|
})
|
|
227
265
|
|
|
228
266
|
.http('git:stash-drop', {
|
|
229
267
|
data: t.Object({
|
|
230
268
|
projectId: t.String(),
|
|
231
|
-
index: t.Optional(t.Number())
|
|
269
|
+
index: t.Optional(t.Number()),
|
|
270
|
+
repoPath: t.Optional(t.String())
|
|
232
271
|
}),
|
|
233
272
|
response: t.Object({ ok: t.Boolean() })
|
|
234
273
|
}, async ({ data, conn }) => {
|
|
235
274
|
const project = requireProjectAccess(conn, data.projectId);
|
|
236
|
-
|
|
275
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
276
|
+
await gitService.stashDrop(cwd, data.index);
|
|
237
277
|
return { ok: true };
|
|
238
278
|
})
|
|
239
279
|
|
|
240
280
|
.http('git:stash-diff', {
|
|
241
281
|
data: t.Object({
|
|
242
282
|
projectId: t.String(),
|
|
243
|
-
index: t.Optional(t.Number())
|
|
283
|
+
index: t.Optional(t.Number()),
|
|
284
|
+
repoPath: t.Optional(t.String())
|
|
244
285
|
}),
|
|
245
286
|
response: t.Array(t.Object({
|
|
246
287
|
oldPath: t.String(),
|
|
@@ -263,12 +304,14 @@ export const remoteHandler = createRouter()
|
|
|
263
304
|
}))
|
|
264
305
|
}, async ({ data, conn }) => {
|
|
265
306
|
const project = requireProjectAccess(conn, data.projectId);
|
|
266
|
-
|
|
307
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
308
|
+
return await gitService.stashDiff(cwd, data.index);
|
|
267
309
|
})
|
|
268
310
|
|
|
269
311
|
.http('git:tags', {
|
|
270
312
|
data: t.Object({
|
|
271
|
-
projectId: t.String()
|
|
313
|
+
projectId: t.String(),
|
|
314
|
+
repoPath: t.Optional(t.String())
|
|
272
315
|
}),
|
|
273
316
|
response: t.Array(t.Object({
|
|
274
317
|
name: t.String(),
|
|
@@ -279,7 +322,8 @@ export const remoteHandler = createRouter()
|
|
|
279
322
|
}))
|
|
280
323
|
}, async ({ data, conn }) => {
|
|
281
324
|
const project = requireProjectAccess(conn, data.projectId);
|
|
282
|
-
|
|
325
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
326
|
+
return await gitService.getTags(cwd);
|
|
283
327
|
})
|
|
284
328
|
|
|
285
329
|
.http('git:create-tag', {
|
|
@@ -287,24 +331,28 @@ export const remoteHandler = createRouter()
|
|
|
287
331
|
projectId: t.String(),
|
|
288
332
|
name: t.String({ minLength: 1 }),
|
|
289
333
|
message: t.Optional(t.String()),
|
|
290
|
-
commitHash: t.Optional(t.String())
|
|
334
|
+
commitHash: t.Optional(t.String()),
|
|
335
|
+
repoPath: t.Optional(t.String())
|
|
291
336
|
}),
|
|
292
337
|
response: t.Object({ ok: t.Boolean() })
|
|
293
338
|
}, async ({ data, conn }) => {
|
|
294
339
|
const project = requireProjectAccess(conn, data.projectId);
|
|
295
|
-
|
|
340
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
341
|
+
await gitService.createTag(cwd, data.name, data.message, data.commitHash);
|
|
296
342
|
return { ok: true };
|
|
297
343
|
})
|
|
298
344
|
|
|
299
345
|
.http('git:delete-tag', {
|
|
300
346
|
data: t.Object({
|
|
301
347
|
projectId: t.String(),
|
|
302
|
-
name: t.String()
|
|
348
|
+
name: t.String(),
|
|
349
|
+
repoPath: t.Optional(t.String())
|
|
303
350
|
}),
|
|
304
351
|
response: t.Object({ ok: t.Boolean() })
|
|
305
352
|
}, async ({ data, conn }) => {
|
|
306
353
|
const project = requireProjectAccess(conn, data.projectId);
|
|
307
|
-
|
|
354
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
355
|
+
await gitService.deleteTag(cwd, data.name);
|
|
308
356
|
return { ok: true };
|
|
309
357
|
})
|
|
310
358
|
|
|
@@ -312,7 +360,8 @@ export const remoteHandler = createRouter()
|
|
|
312
360
|
data: t.Object({
|
|
313
361
|
projectId: t.String(),
|
|
314
362
|
name: t.String(),
|
|
315
|
-
remote: t.Optional(t.String())
|
|
363
|
+
remote: t.Optional(t.String()),
|
|
364
|
+
repoPath: t.Optional(t.String())
|
|
316
365
|
}),
|
|
317
366
|
response: t.Object({
|
|
318
367
|
success: t.Boolean(),
|
|
@@ -320,6 +369,6 @@ export const remoteHandler = createRouter()
|
|
|
320
369
|
})
|
|
321
370
|
}, async ({ data, conn }) => {
|
|
322
371
|
const project = requireProjectAccess(conn, data.projectId);
|
|
323
|
-
|
|
372
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
373
|
+
return await gitService.pushTag(cwd, data.name, data.remote);
|
|
324
374
|
});
|
|
325
|
-
|
|
@@ -3,9 +3,24 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { t } from 'elysia';
|
|
6
|
+
import path from 'node:path';
|
|
6
7
|
import { createRouter } from '$shared/utils/ws-server';
|
|
7
8
|
import { gitService } from '../../git/git-service';
|
|
9
|
+
import { findRepoForFile } from '../../snapshot/gitignore';
|
|
8
10
|
import { requireProjectAccess } from '../access';
|
|
11
|
+
import { debug } from '$shared/utils/logger';
|
|
12
|
+
|
|
13
|
+
function resolveRepoCwd(projectPath: string, repoPath: string | undefined): string | null {
|
|
14
|
+
if (!repoPath) return null;
|
|
15
|
+
const resolved = path.resolve(repoPath);
|
|
16
|
+
const projectRoot = path.resolve(projectPath);
|
|
17
|
+
const sep = path.sep;
|
|
18
|
+
if (resolved !== projectRoot && !resolved.startsWith(projectRoot + sep)) {
|
|
19
|
+
debug.warn('git', `Rejected nested repoPath outside project: ${resolved}`);
|
|
20
|
+
return projectRoot;
|
|
21
|
+
}
|
|
22
|
+
return resolved;
|
|
23
|
+
}
|
|
9
24
|
|
|
10
25
|
export const stagingHandler = createRouter()
|
|
11
26
|
.http('git:stage', {
|
|
@@ -16,18 +31,23 @@ export const stagingHandler = createRouter()
|
|
|
16
31
|
response: t.Object({ ok: t.Boolean() })
|
|
17
32
|
}, async ({ data, conn }) => {
|
|
18
33
|
const project = requireProjectAccess(conn, data.projectId);
|
|
19
|
-
await
|
|
34
|
+
const repo = await findRepoForFile(project.path, data.filePath);
|
|
35
|
+
const cwd = repo?.repoPath ?? project.path;
|
|
36
|
+
const filePath = repo?.relativeFilePath ?? data.filePath;
|
|
37
|
+
await gitService.stageFile(cwd, filePath);
|
|
20
38
|
return { ok: true };
|
|
21
39
|
})
|
|
22
40
|
|
|
23
41
|
.http('git:stage-all', {
|
|
24
42
|
data: t.Object({
|
|
25
|
-
projectId: t.String()
|
|
43
|
+
projectId: t.String(),
|
|
44
|
+
repoPath: t.Optional(t.String())
|
|
26
45
|
}),
|
|
27
46
|
response: t.Object({ ok: t.Boolean() })
|
|
28
47
|
}, async ({ data, conn }) => {
|
|
29
48
|
const project = requireProjectAccess(conn, data.projectId);
|
|
30
|
-
|
|
49
|
+
const cwd = data.repoPath ? (resolveRepoCwd(project.path, data.repoPath) ?? project.path) : project.path;
|
|
50
|
+
await gitService.stageAll(cwd);
|
|
31
51
|
return { ok: true };
|
|
32
52
|
})
|
|
33
53
|
|
|
@@ -39,18 +59,23 @@ export const stagingHandler = createRouter()
|
|
|
39
59
|
response: t.Object({ ok: t.Boolean() })
|
|
40
60
|
}, async ({ data, conn }) => {
|
|
41
61
|
const project = requireProjectAccess(conn, data.projectId);
|
|
42
|
-
await
|
|
62
|
+
const repo = await findRepoForFile(project.path, data.filePath);
|
|
63
|
+
const cwd = repo?.repoPath ?? project.path;
|
|
64
|
+
const filePath = repo?.relativeFilePath ?? data.filePath;
|
|
65
|
+
await gitService.unstageFile(cwd, filePath);
|
|
43
66
|
return { ok: true };
|
|
44
67
|
})
|
|
45
68
|
|
|
46
69
|
.http('git:unstage-all', {
|
|
47
70
|
data: t.Object({
|
|
48
|
-
projectId: t.String()
|
|
71
|
+
projectId: t.String(),
|
|
72
|
+
repoPath: t.Optional(t.String())
|
|
49
73
|
}),
|
|
50
74
|
response: t.Object({ ok: t.Boolean() })
|
|
51
75
|
}, async ({ data, conn }) => {
|
|
52
76
|
const project = requireProjectAccess(conn, data.projectId);
|
|
53
|
-
|
|
77
|
+
const cwd = data.repoPath ? (resolveRepoCwd(project.path, data.repoPath) ?? project.path) : project.path;
|
|
78
|
+
await gitService.unstageAll(cwd);
|
|
54
79
|
return { ok: true };
|
|
55
80
|
})
|
|
56
81
|
|
|
@@ -62,17 +87,22 @@ export const stagingHandler = createRouter()
|
|
|
62
87
|
response: t.Object({ ok: t.Boolean() })
|
|
63
88
|
}, async ({ data, conn }) => {
|
|
64
89
|
const project = requireProjectAccess(conn, data.projectId);
|
|
65
|
-
await
|
|
90
|
+
const repo = await findRepoForFile(project.path, data.filePath);
|
|
91
|
+
const cwd = repo?.repoPath ?? project.path;
|
|
92
|
+
const filePath = repo?.relativeFilePath ?? data.filePath;
|
|
93
|
+
await gitService.discardFile(cwd, filePath);
|
|
66
94
|
return { ok: true };
|
|
67
95
|
})
|
|
68
96
|
|
|
69
97
|
.http('git:discard-all', {
|
|
70
98
|
data: t.Object({
|
|
71
|
-
projectId: t.String()
|
|
99
|
+
projectId: t.String(),
|
|
100
|
+
repoPath: t.Optional(t.String())
|
|
72
101
|
}),
|
|
73
102
|
response: t.Object({ ok: t.Boolean() })
|
|
74
103
|
}, async ({ data, conn }) => {
|
|
75
104
|
const project = requireProjectAccess(conn, data.projectId);
|
|
76
|
-
|
|
105
|
+
const cwd = data.repoPath ? (resolveRepoCwd(project.path, data.repoPath) ?? project.path) : project.path;
|
|
106
|
+
await gitService.discardAll(cwd);
|
|
77
107
|
return { ok: true };
|
|
78
108
|
});
|
package/backend/ws/git/status.ts
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
import { t } from 'elysia';
|
|
6
6
|
import { createRouter } from '$shared/utils/ws-server';
|
|
7
7
|
import { gitService } from '../../git/git-service';
|
|
8
|
+
import { findNestedRepoPaths } from '../../snapshot/gitignore';
|
|
8
9
|
import { requireProjectAccess } from '../access';
|
|
10
|
+
import { relative as pathRelative } from 'path';
|
|
9
11
|
|
|
10
12
|
export const statusHandler = createRouter()
|
|
11
13
|
.http('git:status', {
|
|
@@ -54,6 +56,56 @@ export const statusHandler = createRouter()
|
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
const status = await gitService.getStatus(project.path);
|
|
59
|
+
|
|
60
|
+
// Also aggregate status from nested git repos living inside the
|
|
61
|
+
// project (e.g. a theme extracted into its own repo, listed in the
|
|
62
|
+
// parent's .gitignore). The outer repo's `git status` skips them
|
|
63
|
+
// entirely, so without this aggregation the Changes tab would not
|
|
64
|
+
// show edits the AI made inside the nested repo.
|
|
65
|
+
try {
|
|
66
|
+
const nestedRepoPaths = await findNestedRepoPaths(project.path);
|
|
67
|
+
const nestedPrefixes = nestedRepoPaths.map(
|
|
68
|
+
(repoPath) => pathRelative(project.path, repoPath).replace(/\\/g, '/') + '/'
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// Drop outer-repo entries that fall under a nested repo's prefix.
|
|
72
|
+
// When the outer repo already tracked files inside what later became
|
|
73
|
+
// a nested repo (or reports the nested dir itself as a single
|
|
74
|
+
// untracked entry), it surfaces those paths too — colliding with the
|
|
75
|
+
// nested aggregation below and producing duplicate file entries. The
|
|
76
|
+
// nested repo is the source of truth for its own contents, so the
|
|
77
|
+
// outer view of them is dropped.
|
|
78
|
+
if (nestedPrefixes.length > 0) {
|
|
79
|
+
const underNested = (f: { path: string }) =>
|
|
80
|
+
nestedPrefixes.some((p) => f.path === p || f.path.startsWith(p));
|
|
81
|
+
status.staged = status.staged.filter((f) => !underNested(f));
|
|
82
|
+
status.unstaged = status.unstaged.filter((f) => !underNested(f));
|
|
83
|
+
status.untracked = status.untracked.filter((f) => !underNested(f));
|
|
84
|
+
status.conflicted = status.conflicted.filter((f) => !underNested(f));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
for (const repoPath of nestedRepoPaths) {
|
|
88
|
+
try {
|
|
89
|
+
const nestedStatus = await gitService.getStatus(repoPath);
|
|
90
|
+
const prefix = pathRelative(project.path, repoPath).replace(/\\/g, '/') + '/';
|
|
91
|
+
const withPrefix = (f: typeof nestedStatus.staged[number]) => ({
|
|
92
|
+
...f,
|
|
93
|
+
path: prefix + f.path,
|
|
94
|
+
oldPath: f.oldPath ? prefix + f.oldPath : undefined
|
|
95
|
+
});
|
|
96
|
+
status.staged.push(...nestedStatus.staged.map(withPrefix));
|
|
97
|
+
status.unstaged.push(...nestedStatus.unstaged.map(withPrefix));
|
|
98
|
+
status.untracked.push(...nestedStatus.untracked.map(withPrefix));
|
|
99
|
+
status.conflicted.push(...nestedStatus.conflicted.map(withPrefix));
|
|
100
|
+
} catch {
|
|
101
|
+
// Skip repos whose git status fails — don't break the
|
|
102
|
+
// whole response because one nested repo is broken.
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
} catch {
|
|
106
|
+
// If findNestedRepoPaths itself fails, just return outer status
|
|
107
|
+
}
|
|
108
|
+
|
|
57
109
|
return { isRepo: true, ...status };
|
|
58
110
|
})
|
|
59
111
|
|
package/backend/ws/index.ts
CHANGED
|
@@ -32,6 +32,7 @@ import { engineRouter } from './engine';
|
|
|
32
32
|
import { systemToolsRouter } from './system-tools';
|
|
33
33
|
import { dbClientRouter } from './db-client';
|
|
34
34
|
import { mcpRouter } from './mcp';
|
|
35
|
+
import { skillsRouter } from './skills';
|
|
35
36
|
|
|
36
37
|
// ============================================
|
|
37
38
|
// Main App Router - Merge All Module Routers
|
|
@@ -77,7 +78,10 @@ export const wsRouter = createRouter()
|
|
|
77
78
|
.merge(dbClientRouter)
|
|
78
79
|
|
|
79
80
|
// External MCP server management (install from the official registry)
|
|
80
|
-
.merge(mcpRouter)
|
|
81
|
+
.merge(mcpRouter)
|
|
82
|
+
|
|
83
|
+
// Agent Skills management (create, import, install from a marketplace)
|
|
84
|
+
.merge(skillsRouter);
|
|
81
85
|
|
|
82
86
|
// Export API type for frontend type-safe access
|
|
83
87
|
export type WSAPI = typeof wsRouter['$api'];
|
package/backend/ws/mcp/crud.ts
CHANGED
|
@@ -23,7 +23,8 @@ import {
|
|
|
23
23
|
resolveServerRow,
|
|
24
24
|
startAuthorization,
|
|
25
25
|
completeAuthorization,
|
|
26
|
-
getValidAccessToken
|
|
26
|
+
getValidAccessToken,
|
|
27
|
+
parseMcpConfig
|
|
27
28
|
} from '$backend/mcp';
|
|
28
29
|
|
|
29
30
|
const TRANSPORT_SCHEMA = t.Union([t.Literal('stdio'), t.Literal('http'), t.Literal('sse')]);
|
|
@@ -182,6 +183,34 @@ export const mcpCrudHandler = createRouter()
|
|
|
182
183
|
debug.log('mcp', `📥 Installed external MCP server: ${slug}`);
|
|
183
184
|
return { server: toDTO(row) };
|
|
184
185
|
})
|
|
186
|
+
.http('mcp:parse-config', {
|
|
187
|
+
// Normalise a pasted MCP JSON snippet (Claude/Cursor/VS Code/OpenCode/…)
|
|
188
|
+
// into reviewable servers. Pure transform — nothing is persisted here; the
|
|
189
|
+
// UI shows the result, the user fills any required secrets, then installs
|
|
190
|
+
// via `mcp:install` with `source: 'custom'`.
|
|
191
|
+
data: t.Object({ text: t.String() }),
|
|
192
|
+
response: t.Object({
|
|
193
|
+
servers: t.Array(t.Object({
|
|
194
|
+
name: t.String(),
|
|
195
|
+
slug: t.String(),
|
|
196
|
+
transport: TRANSPORT_SCHEMA,
|
|
197
|
+
command: t.Optional(t.String()),
|
|
198
|
+
args: t.Array(t.String()),
|
|
199
|
+
url: t.Optional(t.String()),
|
|
200
|
+
fields: t.Array(t.Object({
|
|
201
|
+
name: t.String(),
|
|
202
|
+
kind: t.Union([t.Literal('env'), t.Literal('header')]),
|
|
203
|
+
value: t.String(),
|
|
204
|
+
isPlaceholder: t.Boolean()
|
|
205
|
+
})),
|
|
206
|
+
warnings: t.Array(t.String())
|
|
207
|
+
})),
|
|
208
|
+
errors: t.Array(t.String())
|
|
209
|
+
})
|
|
210
|
+
}, async ({ data }) => {
|
|
211
|
+
debug.log('path', 'mcp:parse-config');
|
|
212
|
+
return parseMcpConfig(data.text);
|
|
213
|
+
})
|
|
185
214
|
.http('mcp:toggle', {
|
|
186
215
|
data: t.Object({ id: t.Number(), enabled: t.Boolean() }),
|
|
187
216
|
response: t.Object({ server: INSTALLED_SERVER_SCHEMA })
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill Marketplace Handlers
|
|
3
|
+
*
|
|
4
|
+
* - skills:catalog — browse the skill catalog (paginated, searchable)
|
|
5
|
+
* - skills:install — install a skill from the catalog into the canonical store
|
|
6
|
+
*
|
|
7
|
+
* Skills come from the community registry. See backend/skills/marketplace.ts.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { t } from 'elysia';
|
|
11
|
+
import { createRouter } from '$shared/utils/ws-server';
|
|
12
|
+
import { debug } from '$shared/utils/logger';
|
|
13
|
+
import { listMarketplaceSkills, skillService } from '$backend/skills';
|
|
14
|
+
|
|
15
|
+
const MARKETPLACE_SKILL_SCHEMA = t.Object({
|
|
16
|
+
ref: t.String(),
|
|
17
|
+
name: t.String(),
|
|
18
|
+
slug: t.String(),
|
|
19
|
+
description: t.String(),
|
|
20
|
+
stars: t.Optional(t.Number()),
|
|
21
|
+
verified: t.Optional(t.Boolean()),
|
|
22
|
+
homepage: t.Optional(t.String())
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const SKILL_SCHEMA = t.Object({
|
|
26
|
+
id: t.Number(),
|
|
27
|
+
slug: t.String(),
|
|
28
|
+
name: t.String(),
|
|
29
|
+
description: t.String(),
|
|
30
|
+
source: t.Union([t.Literal('custom'), t.Literal('imported'), t.Literal('marketplace')]),
|
|
31
|
+
marketplaceRef: t.Union([t.String(), t.Null()]),
|
|
32
|
+
version: t.Union([t.String(), t.Null()]),
|
|
33
|
+
license: t.Union([t.String(), t.Null()]),
|
|
34
|
+
enabled: t.Boolean(),
|
|
35
|
+
present: t.Boolean(),
|
|
36
|
+
createdAt: t.String()
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const skillCatalogHandler = createRouter()
|
|
40
|
+
.http('skills:catalog', {
|
|
41
|
+
data: t.Object({
|
|
42
|
+
search: t.Optional(t.String()),
|
|
43
|
+
cursor: t.Optional(t.String())
|
|
44
|
+
}),
|
|
45
|
+
response: t.Object({
|
|
46
|
+
skills: t.Array(MARKETPLACE_SKILL_SCHEMA),
|
|
47
|
+
nextCursor: t.Union([t.String(), t.Null()])
|
|
48
|
+
})
|
|
49
|
+
}, async ({ data }) => {
|
|
50
|
+
debug.log('path', `skills:catalog q="${data.search ?? ''}"`);
|
|
51
|
+
return listMarketplaceSkills(data.search ?? '', data.cursor ?? null);
|
|
52
|
+
})
|
|
53
|
+
.http('skills:marketplace-detail', {
|
|
54
|
+
data: t.Object({ ref: t.String() }),
|
|
55
|
+
response: t.Object({
|
|
56
|
+
name: t.String(),
|
|
57
|
+
description: t.String(),
|
|
58
|
+
license: t.Union([t.String(), t.Null()]),
|
|
59
|
+
body: t.String()
|
|
60
|
+
})
|
|
61
|
+
}, async ({ data }) => {
|
|
62
|
+
debug.log('path', `skills:marketplace-detail ${data.ref}`);
|
|
63
|
+
return skillService.previewInstall(data.ref);
|
|
64
|
+
})
|
|
65
|
+
.http('skills:install', {
|
|
66
|
+
data: t.Object({
|
|
67
|
+
ref: t.String(),
|
|
68
|
+
name: t.Optional(t.String()),
|
|
69
|
+
description: t.Optional(t.String()),
|
|
70
|
+
license: t.Optional(t.Union([t.String(), t.Null()])),
|
|
71
|
+
body: t.Optional(t.String())
|
|
72
|
+
}),
|
|
73
|
+
response: t.Object({ skill: SKILL_SCHEMA })
|
|
74
|
+
}, async ({ data }) => {
|
|
75
|
+
debug.log('path', `skills:install ${data.ref}`);
|
|
76
|
+
const { ref, ...override } = data;
|
|
77
|
+
const skill = await skillService.install(ref, override);
|
|
78
|
+
return { skill };
|
|
79
|
+
});
|