@myrialabs/clopen 0.4.3 → 0.4.5
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/README.md +2 -0
- package/backend/auth/permissions.ts +1 -0
- package/backend/database/migrations/043_relocate_engine_config_dirs.ts +71 -0
- package/backend/database/migrations/index.ts +7 -0
- package/backend/database/queries/mcp-server-queries.ts +14 -0
- package/backend/engine/README.md +12 -8
- package/backend/engine/adapters/claude/environment.ts +3 -3
- package/backend/engine/adapters/codex/credential.ts +12 -2
- package/backend/engine/adapters/codex/stream.ts +6 -0
- package/backend/engine/adapters/copilot/stream.ts +5 -1
- package/backend/engine/adapters/opencode/server.ts +36 -5
- package/backend/engine/adapters/qwen/environment.ts +7 -0
- package/backend/engine/adapters/qwen/session-fork.ts +13 -1
- package/backend/engine/docs/database.md +9 -6
- package/backend/engine/docs/lessons-learned.md +117 -16
- package/backend/git/git-service.ts +50 -1
- package/backend/mcp/external/parse.test.ts +190 -0
- package/backend/mcp/external/parse.ts +293 -0
- package/backend/mcp/external/probe.ts +55 -5
- package/backend/mcp/external/registry-client.ts +8 -1
- package/backend/mcp/index.ts +2 -0
- package/backend/snapshot/gitignore.ts +230 -7
- package/backend/snapshot/helpers.ts +34 -10
- package/backend/utils/paths.ts +16 -0
- package/backend/ws/engine/codex/accounts.ts +3 -0
- 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/mcp/crud.ts +42 -2
- package/backend/ws/snapshot/timeline.ts +1 -1
- package/dist/assets/main-gNUEJAC5.css +1 -0
- package/dist/assets/{main-D-AcjotJ.js → main-zXKH_C5O.js} +318 -290
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/shared/types/git.ts +20 -0
- package/dist/assets/main-DJf71Zum.css +0 -1
|
@@ -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/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 })
|
|
@@ -199,7 +228,11 @@ export const mcpCrudHandler = createRouter()
|
|
|
199
228
|
data: t.Object({
|
|
200
229
|
id: t.Number(),
|
|
201
230
|
env: t.Optional(t.Record(t.String(), t.String())),
|
|
202
|
-
headers: t.Optional(t.Record(t.String(), t.String()))
|
|
231
|
+
headers: t.Optional(t.Record(t.String(), t.String())),
|
|
232
|
+
// stdio only: repair an incomplete registry command (e.g. a missing
|
|
233
|
+
// `mcp` subcommand). Ignored for remote servers.
|
|
234
|
+
command: t.Optional(t.String()),
|
|
235
|
+
args: t.Optional(t.Array(t.String()))
|
|
203
236
|
}),
|
|
204
237
|
response: t.Object({ server: INSTALLED_SERVER_SCHEMA })
|
|
205
238
|
}, async ({ data }) => {
|
|
@@ -216,6 +249,13 @@ export const mcpCrudHandler = createRouter()
|
|
|
216
249
|
try { configSchema = JSON.parse(existing.config_schema); } catch { /* ignore */ }
|
|
217
250
|
assertRequiredConfig(configSchema, env, headers);
|
|
218
251
|
mcpServerQueries.updateConfig(data.id, env, headers);
|
|
252
|
+
// Persist an edited command/args for stdio servers (drop blank arg tokens).
|
|
253
|
+
if (existing.transport === 'stdio' && (data.command !== undefined || data.args !== undefined)) {
|
|
254
|
+
const command = (data.command ?? existing.command ?? '').trim();
|
|
255
|
+
if (!command) throw new Error('A stdio MCP server requires a command');
|
|
256
|
+
const args = (data.args ?? []).map(a => a.trim()).filter(a => a !== '');
|
|
257
|
+
mcpServerQueries.updateCommand(data.id, command, args);
|
|
258
|
+
}
|
|
219
259
|
debug.log('mcp', `🔧 Updated config for external MCP server: ${existing.slug}`);
|
|
220
260
|
return { server: toDTO(mcpServerQueries.getById(data.id)!) };
|
|
221
261
|
})
|
|
@@ -139,7 +139,7 @@ export const timelineHandler = createRouter()
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
// File stats from checkpoint's own snapshot
|
|
142
|
-
const stats = getCheckpointFileStats(cp);
|
|
142
|
+
const stats = await getCheckpointFileStats(cp);
|
|
143
143
|
|
|
144
144
|
const snapshot = snapshotQueries.getByMessageId(cp.id);
|
|
145
145
|
|