@myrialabs/clopen 0.4.35 → 0.4.37
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/artifacts/sync.test.ts +63 -0
- package/backend/artifacts/sync.ts +56 -3
- package/backend/database/migrations/070_create_worktrees_table.ts +67 -0
- package/backend/database/migrations/index.ts +7 -0
- package/backend/database/queries/index.ts +1 -0
- package/backend/database/queries/session-queries.ts +50 -11
- package/backend/database/queries/worktree-queries.ts +148 -0
- package/backend/engine/adapters/opencode/server.ts +389 -83
- package/backend/engine/adapters/opencode/stream.ts +14 -14
- package/backend/engine/hot-reload.ts +25 -10
- package/backend/files/file-watcher.ts +35 -9
- package/backend/git/conflict-state.test.ts +396 -0
- package/backend/git/git-executor.ts +6 -0
- package/backend/git/git-parser.ts +144 -48
- package/backend/git/git-service.ts +727 -57
- package/backend/git/push-target.test.ts +264 -0
- package/backend/host/metrics.test.ts +110 -0
- package/backend/host/metrics.ts +235 -0
- package/backend/index.ts +5 -2
- package/backend/mcp/internal/servers/browser-automation/context.ts +16 -2
- package/backend/ports/attribute.test.ts +3 -2
- package/backend/ports/attribute.ts +5 -44
- package/backend/preview/browser/browser-pool.ts +81 -0
- package/backend/preview/browser/browser-preview-service.ts +142 -32
- package/backend/preview/browser/browser-tab-manager.ts +350 -113
- package/backend/preview/browser/types.ts +9 -0
- package/backend/project/status-manager.ts +20 -0
- package/backend/projects/project-cleanup.integration.test.ts +1 -1
- package/backend/projects/project-cleanup.ts +7 -1
- package/backend/projects/shell-ownership.ts +65 -0
- package/backend/snapshot/snapshot-service.ts +6 -2
- package/backend/terminal/ptykit.ts +35 -6
- package/backend/utils/ws.ts +21 -1
- package/backend/worktrees/clone.ts +222 -0
- package/backend/worktrees/index.ts +29 -0
- package/backend/worktrees/merge.test.ts +93 -0
- package/backend/worktrees/merge.ts +232 -0
- package/backend/worktrees/paths.test.ts +60 -0
- package/backend/worktrees/paths.ts +60 -0
- package/backend/worktrees/resolve.ts +67 -0
- package/backend/worktrees/service.ts +315 -0
- package/backend/worktrees/tree.ts +59 -0
- package/backend/ws/access.ts +18 -0
- package/backend/ws/artifacts/generate.ts +2 -2
- package/backend/ws/chat/stream.ts +9 -2
- package/backend/ws/files/panel-state-scope.test.ts +102 -0
- package/backend/ws/files/path-access.test.ts +93 -1
- package/backend/ws/files/path-access.ts +54 -5
- package/backend/ws/files/read.ts +15 -10
- package/backend/ws/files/search.ts +7 -7
- package/backend/ws/files/state.ts +70 -8
- package/backend/ws/files/watch.ts +16 -14
- package/backend/ws/git/branch-name.ts +9 -8
- package/backend/ws/git/branch.ts +58 -16
- package/backend/ws/git/commit-message.ts +16 -13
- package/backend/ws/git/commit.ts +17 -17
- package/backend/ws/git/conflict.ts +116 -13
- package/backend/ws/git/diff-budget.test.ts +125 -0
- package/backend/ws/git/diff-budget.ts +220 -0
- package/backend/ws/git/diff.ts +9 -9
- package/backend/ws/git/ignored.ts +9 -9
- package/backend/ws/git/log.ts +28 -3
- package/backend/ws/git/remote.ts +118 -44
- package/backend/ws/git/staging.ts +16 -16
- package/backend/ws/git/status.ts +13 -13
- package/backend/ws/index.ts +4 -0
- package/backend/ws/preview/access.ts +11 -3
- package/backend/ws/projects/index.ts +5 -1
- package/backend/ws/projects/info.test.ts +54 -0
- package/backend/ws/projects/info.ts +398 -0
- package/backend/ws/sessions/crud.ts +21 -6
- package/backend/ws/snapshot/restore.ts +11 -14
- package/backend/ws/system/device-info.ts +62 -144
- package/backend/ws/worktrees/crud.ts +187 -0
- package/backend/ws/worktrees/index.ts +33 -0
- package/backend/ws/worktrees/transfer.ts +88 -0
- package/dist/assets/{index-BRJqss6F.js → index-Bik9TCBi.js} +1 -1
- package/dist/assets/{index-B0iIhSO9.js → index-sJmS_CCm.js} +1 -1
- package/dist/assets/main-DLqolBI2.css +1 -0
- package/dist/assets/main-Df1I3hnw.js +1096 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/shared/types/database/schema.ts +26 -0
- package/shared/types/git.ts +123 -0
- package/shared/utils/logger.ts +1 -0
- package/shared/utils/workspace-scope.test.ts +80 -0
- package/shared/utils/workspace-scope.ts +57 -0
- package/shared/utils/ws-client.ts +25 -5
- package/shared/utils/ws-server.ts +19 -3
- package/dist/assets/main-Buko4D0t.css +0 -1
- package/dist/assets/main-C_iGUZyL.js +0 -1078
|
@@ -14,7 +14,8 @@ import type {
|
|
|
14
14
|
GitCommit,
|
|
15
15
|
GitRemote,
|
|
16
16
|
GitStashEntry,
|
|
17
|
-
GitConflictMarker
|
|
17
|
+
GitConflictMarker,
|
|
18
|
+
GitReflogEntry
|
|
18
19
|
} from '$shared/types/git';
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -120,10 +121,15 @@ export function parseBranches(localOutput: string, remoteOutput: string): GitBra
|
|
|
120
121
|
// Parse local branches
|
|
121
122
|
const localLines = localOutput.split('\n').filter(Boolean);
|
|
122
123
|
for (const line of localLines) {
|
|
123
|
-
|
|
124
|
+
// The upstream is appended after a 0x1F unit separator rather than another
|
|
125
|
+
// `|`, because the subject in the middle of the line can contain `|` and
|
|
126
|
+
// the legacy fields are still split positionally.
|
|
127
|
+
const [legacy, upstreamField = ''] = line.split('\x1f');
|
|
128
|
+
|
|
129
|
+
const dateSep = legacy.lastIndexOf('|');
|
|
124
130
|
if (dateSep === -1) continue;
|
|
125
|
-
const lastCommitDate =
|
|
126
|
-
const head =
|
|
131
|
+
const lastCommitDate = legacy.substring(dateSep + 1);
|
|
132
|
+
const head = legacy.substring(0, dateSep);
|
|
127
133
|
|
|
128
134
|
// head = "<*>|<name>|<hash>|<subject>"
|
|
129
135
|
const parts = head.split('|', 4);
|
|
@@ -135,7 +141,7 @@ export function parseBranches(localOutput: string, remoteOutput: string): GitBra
|
|
|
135
141
|
|
|
136
142
|
if (isCurrent) current = name;
|
|
137
143
|
|
|
138
|
-
|
|
144
|
+
const branch: GitBranch = {
|
|
139
145
|
name,
|
|
140
146
|
isCurrent,
|
|
141
147
|
isRemote: false,
|
|
@@ -144,7 +150,10 @@ export function parseBranches(localOutput: string, remoteOutput: string): GitBra
|
|
|
144
150
|
lastCommit,
|
|
145
151
|
lastCommitMessage,
|
|
146
152
|
lastCommitDate
|
|
147
|
-
}
|
|
153
|
+
};
|
|
154
|
+
if (upstreamField.trim()) branch.upstream = upstreamField.trim();
|
|
155
|
+
|
|
156
|
+
local.push(branch);
|
|
148
157
|
}
|
|
149
158
|
|
|
150
159
|
// Parse remote branches
|
|
@@ -394,58 +403,145 @@ export function parseStashList(output: string): GitStashEntry[] {
|
|
|
394
403
|
/**
|
|
395
404
|
* Parse conflict markers from file content
|
|
396
405
|
*/
|
|
406
|
+
/**
|
|
407
|
+
* Conflict markers are exactly seven repeated characters followed by a space or
|
|
408
|
+
* the end of the line. Matching a bare `startsWith('<<<<<<<')` also fires on
|
|
409
|
+
* ordinary content — an eight-arrow ASCII divider, a diff quoted inside a
|
|
410
|
+
* markdown file — and turns a clean file into a phantom conflict.
|
|
411
|
+
*/
|
|
412
|
+
const MARKER_OURS = /^<{7}(?:[ \t\r]|$)/;
|
|
413
|
+
const MARKER_BASE = /^\|{7}(?:[ \t\r]|$)/;
|
|
414
|
+
const MARKER_SEP = /^={7}(?:[ \t\r]|$)/;
|
|
415
|
+
const MARKER_THEIRS = /^>{7}(?:[ \t\r]|$)/;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* True when the text still contains an unresolved conflict block. Used as a
|
|
419
|
+
* guard before staging: `git add` happily records a file that still has markers
|
|
420
|
+
* in it, which silently commits `<<<<<<<` into the tree.
|
|
421
|
+
*/
|
|
422
|
+
export function hasConflictMarkers(content: string): boolean {
|
|
423
|
+
return parseConflictMarkers(content).length > 0;
|
|
424
|
+
}
|
|
425
|
+
|
|
397
426
|
export function parseConflictMarkers(content: string): GitConflictMarker[] {
|
|
398
427
|
const markers: GitConflictMarker[] = [];
|
|
399
428
|
const lines = content.split('\n');
|
|
400
429
|
|
|
401
430
|
let i = 0;
|
|
402
431
|
while (i < lines.length) {
|
|
403
|
-
if (lines[i]
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
let theirEnd = -1;
|
|
408
|
-
|
|
409
|
-
// Find the rest of the conflict
|
|
410
|
-
let j = i + 1;
|
|
411
|
-
while (j < lines.length) {
|
|
412
|
-
if (lines[j].startsWith('|||||||')) {
|
|
413
|
-
baseStart = j;
|
|
414
|
-
} else if (lines[j].startsWith('=======')) {
|
|
415
|
-
separatorIndex = j;
|
|
416
|
-
} else if (lines[j].startsWith('>>>>>>>')) {
|
|
417
|
-
theirEnd = j;
|
|
418
|
-
break;
|
|
419
|
-
}
|
|
420
|
-
j++;
|
|
421
|
-
}
|
|
432
|
+
if (!MARKER_OURS.test(lines[i])) {
|
|
433
|
+
i++;
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
422
436
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
if (baseStart !== undefined) {
|
|
438
|
-
marker.baseStart = baseStart;
|
|
439
|
-
marker.baseContent = lines.slice(baseStart + 1, separatorIndex).join('\n');
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
markers.push(marker);
|
|
443
|
-
i = theirEnd + 1;
|
|
444
|
-
continue;
|
|
437
|
+
const ourStart = i;
|
|
438
|
+
let baseStart: number | undefined;
|
|
439
|
+
let separatorIndex = -1;
|
|
440
|
+
let theirEnd = -1;
|
|
441
|
+
let restartAt = -1;
|
|
442
|
+
|
|
443
|
+
let j = i + 1;
|
|
444
|
+
while (j < lines.length) {
|
|
445
|
+
const line = lines[j];
|
|
446
|
+
if (MARKER_OURS.test(line)) {
|
|
447
|
+
// A second opener before this one closed means the first was never a
|
|
448
|
+
// real conflict. Drop it and re-scan from the opener we just found.
|
|
449
|
+
restartAt = j;
|
|
450
|
+
break;
|
|
445
451
|
}
|
|
452
|
+
if (MARKER_BASE.test(line)) baseStart = j;
|
|
453
|
+
else if (MARKER_SEP.test(line)) separatorIndex = j;
|
|
454
|
+
else if (MARKER_THEIRS.test(line)) {
|
|
455
|
+
theirEnd = j;
|
|
456
|
+
break;
|
|
457
|
+
}
|
|
458
|
+
j++;
|
|
446
459
|
}
|
|
447
|
-
|
|
460
|
+
|
|
461
|
+
if (restartAt >= 0) {
|
|
462
|
+
i = restartAt;
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
if (separatorIndex < 0 || theirEnd < 0) {
|
|
467
|
+
i = ourStart + 1;
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
const ourContentEnd = baseStart !== undefined ? baseStart : separatorIndex;
|
|
472
|
+
const marker: GitConflictMarker = {
|
|
473
|
+
ourStart,
|
|
474
|
+
ourEnd: separatorIndex,
|
|
475
|
+
theirStart: separatorIndex,
|
|
476
|
+
theirEnd,
|
|
477
|
+
ourContent: lines.slice(ourStart + 1, ourContentEnd).join('\n'),
|
|
478
|
+
theirContent: lines.slice(separatorIndex + 1, theirEnd).join('\n')
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
if (baseStart !== undefined) {
|
|
482
|
+
marker.baseStart = baseStart;
|
|
483
|
+
marker.baseContent = lines.slice(baseStart + 1, separatorIndex).join('\n');
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
markers.push(marker);
|
|
487
|
+
i = theirEnd + 1;
|
|
448
488
|
}
|
|
449
489
|
|
|
450
490
|
return markers;
|
|
451
491
|
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Parse `git reflog --format=%H|||%h|||%gd|||%gs|||%cI`.
|
|
495
|
+
*
|
|
496
|
+
* `%gs` (the reflog subject) already carries both halves — "commit: fix thing",
|
|
497
|
+
* "rebase (finish): returning to refs/heads/main" — so we split on the first
|
|
498
|
+
* ": " to separate the action from the description.
|
|
499
|
+
*/
|
|
500
|
+
export function parseReflog(output: string): GitReflogEntry[] {
|
|
501
|
+
const SEPARATOR = '|||';
|
|
502
|
+
const entries: GitReflogEntry[] = [];
|
|
503
|
+
|
|
504
|
+
for (const line of output.split('\n')) {
|
|
505
|
+
if (!line.trim()) continue;
|
|
506
|
+
const parts = line.split(SEPARATOR);
|
|
507
|
+
if (parts.length < 5) continue;
|
|
508
|
+
const [hash, hashShort, selector, gs, date] = parts;
|
|
509
|
+
const colon = gs.indexOf(': ');
|
|
510
|
+
entries.push({
|
|
511
|
+
hash,
|
|
512
|
+
hashShort,
|
|
513
|
+
selector,
|
|
514
|
+
action: colon >= 0 ? gs.slice(0, colon) : gs,
|
|
515
|
+
subject: colon >= 0 ? gs.slice(colon + 2) : '',
|
|
516
|
+
date
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
return entries;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Parse `git ls-files -u -z`: one row per unmerged *stage* (1 = base, 2 = ours,
|
|
525
|
+
* 3 = theirs), so a path shows up two or three times. Which stages are present
|
|
526
|
+
* is what distinguishes a both-modified conflict from a delete/modify one, and
|
|
527
|
+
* unlike `git status` this never omits a path whose working-tree file is gone.
|
|
528
|
+
*/
|
|
529
|
+
export function parseUnmergedStages(output: string): Map<string, Set<number>> {
|
|
530
|
+
const stages = new Map<string, Set<number>>();
|
|
531
|
+
|
|
532
|
+
for (const row of output.split('\0')) {
|
|
533
|
+
if (!row.trim()) continue;
|
|
534
|
+
// "<mode> <sha> <stage>\t<path>"
|
|
535
|
+
const tab = row.indexOf('\t');
|
|
536
|
+
if (tab < 0) continue;
|
|
537
|
+
const meta = row.slice(0, tab).trim().split(/\s+/);
|
|
538
|
+
const path = row.slice(tab + 1);
|
|
539
|
+
const stage = Number(meta[2]);
|
|
540
|
+
if (!path || !Number.isInteger(stage)) continue;
|
|
541
|
+
const set = stages.get(path) ?? new Set<number>();
|
|
542
|
+
set.add(stage);
|
|
543
|
+
stages.set(path, set);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
return stages;
|
|
547
|
+
}
|