@remixhq/core 0.1.10 → 0.1.11
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/api.d.ts +29 -0
- package/dist/api.js +1 -1
- package/dist/binding.d.ts +9 -4
- package/dist/binding.js +3 -1
- package/dist/chunk-4L3ZBZUQ.js +281 -0
- package/dist/chunk-BNKPTE2U.js +401 -0
- package/dist/chunk-C5NBNU32.js +240 -0
- package/dist/chunk-DXCL6I4Q.js +399 -0
- package/dist/chunk-HZNEDSRS.js +0 -0
- package/dist/chunk-K54U353Z.js +691 -0
- package/dist/chunk-RM2BGDBB.js +400 -0
- package/dist/chunk-ZXP6ENQY.js +244 -0
- package/dist/collab.d.ts +44 -6
- package/dist/collab.js +740 -129
- package/dist/index.js +1 -1
- package/dist/repo.js +2 -1
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -302,6 +302,30 @@ type ApiClient = {
|
|
|
302
302
|
resolveProjectBinding(params: {
|
|
303
303
|
repoFingerprint?: string;
|
|
304
304
|
remoteUrl?: string;
|
|
305
|
+
branchName?: string;
|
|
306
|
+
}): Promise<Json>;
|
|
307
|
+
resolveProjectLaneBinding(params: {
|
|
308
|
+
projectId?: string;
|
|
309
|
+
repoFingerprint?: string;
|
|
310
|
+
remoteUrl?: string;
|
|
311
|
+
defaultBranch?: string;
|
|
312
|
+
branchName: string;
|
|
313
|
+
}): Promise<Json>;
|
|
314
|
+
ensureProjectLaneBinding(payload: {
|
|
315
|
+
projectId?: string;
|
|
316
|
+
repoFingerprint?: string;
|
|
317
|
+
remoteUrl?: string;
|
|
318
|
+
defaultBranch?: string;
|
|
319
|
+
branchName: string;
|
|
320
|
+
seedAppId?: string;
|
|
321
|
+
}): Promise<Json>;
|
|
322
|
+
bootstrapFreshProjectLane(payload: {
|
|
323
|
+
projectId?: string;
|
|
324
|
+
repoFingerprint?: string;
|
|
325
|
+
remoteUrl?: string;
|
|
326
|
+
defaultBranch?: string;
|
|
327
|
+
branchName: string;
|
|
328
|
+
seedAppId: string;
|
|
305
329
|
}): Promise<Json>;
|
|
306
330
|
autoEnableDeveloper(): Promise<Json>;
|
|
307
331
|
listClientApps(params?: {
|
|
@@ -373,6 +397,7 @@ type ApiClient = {
|
|
|
373
397
|
uploadId: string;
|
|
374
398
|
appName?: string;
|
|
375
399
|
threadId?: string;
|
|
400
|
+
branch?: string;
|
|
376
401
|
path?: string;
|
|
377
402
|
platform?: string;
|
|
378
403
|
isPublic?: boolean;
|
|
@@ -398,6 +423,7 @@ type ApiClient = {
|
|
|
398
423
|
name?: string;
|
|
399
424
|
platform?: string;
|
|
400
425
|
forkedFromCommitId?: string;
|
|
426
|
+
branchName?: string;
|
|
401
427
|
}): Promise<Json>;
|
|
402
428
|
downloadAppBundle(appId: string): Promise<{
|
|
403
429
|
data: Buffer;
|
|
@@ -406,6 +432,7 @@ type ApiClient = {
|
|
|
406
432
|
}>;
|
|
407
433
|
createChangeStep(appId: string, payload: {
|
|
408
434
|
threadId?: string;
|
|
435
|
+
collabLaneId?: string;
|
|
409
436
|
prompt: string;
|
|
410
437
|
assistantResponse?: string;
|
|
411
438
|
diff: string;
|
|
@@ -443,6 +470,7 @@ type ApiClient = {
|
|
|
443
470
|
getChangeStepReplayDiff(appId: string, replayId: string): Promise<Json>;
|
|
444
471
|
createCollabTurn(appId: string, payload: {
|
|
445
472
|
threadId?: string;
|
|
473
|
+
collabLaneId?: string;
|
|
446
474
|
prompt: string;
|
|
447
475
|
assistantResponse: string;
|
|
448
476
|
actor?: {
|
|
@@ -459,6 +487,7 @@ type ApiClient = {
|
|
|
459
487
|
offset?: number;
|
|
460
488
|
changeStepId?: string;
|
|
461
489
|
threadId?: string;
|
|
490
|
+
collabLaneId?: string;
|
|
462
491
|
createdAfter?: string;
|
|
463
492
|
createdBefore?: string;
|
|
464
493
|
}): Promise<Json>;
|
package/dist/api.js
CHANGED
package/dist/binding.d.ts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
+
type BranchBindingMode = "legacy" | "lane";
|
|
1
2
|
type CollabBinding = {
|
|
2
|
-
schemaVersion:
|
|
3
|
-
projectId: string;
|
|
3
|
+
schemaVersion: 3;
|
|
4
|
+
projectId: string | null;
|
|
4
5
|
currentAppId: string;
|
|
5
6
|
upstreamAppId: string;
|
|
6
7
|
threadId: string | null;
|
|
7
8
|
repoFingerprint: string | null;
|
|
8
9
|
remoteUrl: string | null;
|
|
9
10
|
defaultBranch: string | null;
|
|
10
|
-
|
|
11
|
+
laneId: string | null;
|
|
12
|
+
branchName: string | null;
|
|
13
|
+
bindingMode: BranchBindingMode;
|
|
11
14
|
};
|
|
12
15
|
declare function getCollabBindingPath(repoRoot: string): string;
|
|
13
16
|
declare function readCollabBinding(repoRoot: string): Promise<CollabBinding | null>;
|
|
14
|
-
declare function writeCollabBinding(repoRoot: string, binding: Omit<CollabBinding, "schemaVersion">
|
|
17
|
+
declare function writeCollabBinding(repoRoot: string, binding: Omit<CollabBinding, "schemaVersion" | "branchName"> & {
|
|
18
|
+
branchName?: string | null;
|
|
19
|
+
}): Promise<string>;
|
|
15
20
|
|
|
16
21
|
export { type CollabBinding, getCollabBindingPath, readCollabBinding, writeCollabBinding };
|
package/dist/binding.js
CHANGED
|
@@ -2,7 +2,9 @@ import {
|
|
|
2
2
|
getCollabBindingPath,
|
|
3
3
|
readCollabBinding,
|
|
4
4
|
writeCollabBinding
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-4L3ZBZUQ.js";
|
|
6
|
+
import "./chunk-RREREIGW.js";
|
|
7
|
+
import "./chunk-GC2MOT3U.js";
|
|
6
8
|
import "./chunk-YZ34ICNN.js";
|
|
7
9
|
export {
|
|
8
10
|
getCollabBindingPath,
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getCurrentBranch
|
|
3
|
+
} from "./chunk-RREREIGW.js";
|
|
4
|
+
import {
|
|
5
|
+
RemixError
|
|
6
|
+
} from "./chunk-YZ34ICNN.js";
|
|
7
|
+
|
|
8
|
+
// src/infrastructure/binding/collabBindingStore.ts
|
|
9
|
+
import fs2 from "fs/promises";
|
|
10
|
+
import path2 from "path";
|
|
11
|
+
|
|
12
|
+
// src/shared/fs.ts
|
|
13
|
+
import fs from "fs/promises";
|
|
14
|
+
import path from "path";
|
|
15
|
+
async function reserveDirectory(targetDir) {
|
|
16
|
+
try {
|
|
17
|
+
await fs.mkdir(targetDir);
|
|
18
|
+
return targetDir;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
if (error?.code === "EEXIST") {
|
|
21
|
+
throw new RemixError("Output directory already exists.", {
|
|
22
|
+
exitCode: 2,
|
|
23
|
+
hint: `Choose an empty destination path: ${targetDir}`
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async function reserveAvailableDirPath(preferredDir) {
|
|
30
|
+
const parent = path.dirname(preferredDir);
|
|
31
|
+
const base = path.basename(preferredDir);
|
|
32
|
+
for (let i = 1; i <= 1e3; i += 1) {
|
|
33
|
+
const candidate = i === 1 ? preferredDir : path.join(parent, `${base}-${i}`);
|
|
34
|
+
try {
|
|
35
|
+
await fs.mkdir(candidate);
|
|
36
|
+
return candidate;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (error?.code === "EEXIST") continue;
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
throw new RemixError("No available output directory name.", {
|
|
43
|
+
exitCode: 2,
|
|
44
|
+
hint: `Tried ${base} through ${base}-1000 under ${parent}.`
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async function writeJsonAtomic(filePath, value) {
|
|
48
|
+
const dir = path.dirname(filePath);
|
|
49
|
+
await fs.mkdir(dir, { recursive: true });
|
|
50
|
+
const tmp = `${filePath}.tmp-${Date.now()}`;
|
|
51
|
+
await fs.writeFile(tmp, `${JSON.stringify(value, null, 2)}
|
|
52
|
+
`, "utf8");
|
|
53
|
+
await fs.rename(tmp, filePath);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/infrastructure/binding/collabBindingStore.ts
|
|
57
|
+
function getCollabBindingPath(repoRoot) {
|
|
58
|
+
return path2.join(repoRoot, ".remix", "config.json");
|
|
59
|
+
}
|
|
60
|
+
function buildBindingFileV3(params) {
|
|
61
|
+
return {
|
|
62
|
+
schemaVersion: 3,
|
|
63
|
+
repoFingerprint: params.repoFingerprint,
|
|
64
|
+
remoteUrl: params.remoteUrl,
|
|
65
|
+
defaultBranch: params.defaultBranch,
|
|
66
|
+
branchBindings: params.branchBindings
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function normalizeBranchName(value) {
|
|
70
|
+
const normalized = String(value ?? "").trim();
|
|
71
|
+
return normalized || null;
|
|
72
|
+
}
|
|
73
|
+
function normalizeProjectId(value) {
|
|
74
|
+
const normalized = String(value ?? "").trim();
|
|
75
|
+
return normalized || null;
|
|
76
|
+
}
|
|
77
|
+
function normalizeBranchBinding(value) {
|
|
78
|
+
if (!value?.currentAppId || !value?.upstreamAppId) return null;
|
|
79
|
+
return {
|
|
80
|
+
projectId: normalizeProjectId(value.projectId),
|
|
81
|
+
currentAppId: value.currentAppId,
|
|
82
|
+
upstreamAppId: value.upstreamAppId,
|
|
83
|
+
threadId: value.threadId ?? null,
|
|
84
|
+
laneId: value.laneId ?? null,
|
|
85
|
+
bindingMode: value.bindingMode === "legacy" ? "legacy" : "lane"
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function buildResolvedBinding(params) {
|
|
89
|
+
if (!params.binding) return null;
|
|
90
|
+
return {
|
|
91
|
+
schemaVersion: 3,
|
|
92
|
+
projectId: params.binding.projectId ?? params.fallbackProjectId,
|
|
93
|
+
currentAppId: params.binding.currentAppId,
|
|
94
|
+
upstreamAppId: params.binding.upstreamAppId,
|
|
95
|
+
threadId: params.binding.threadId,
|
|
96
|
+
repoFingerprint: params.repoFingerprint,
|
|
97
|
+
remoteUrl: params.remoteUrl,
|
|
98
|
+
defaultBranch: params.defaultBranch,
|
|
99
|
+
laneId: params.binding.laneId,
|
|
100
|
+
branchName: params.branchName,
|
|
101
|
+
bindingMode: params.binding.bindingMode
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function deriveFallbackProjectId(params) {
|
|
105
|
+
const candidates = [
|
|
106
|
+
params.currentBranch ? params.branchBindings[params.currentBranch]?.projectId ?? null : null,
|
|
107
|
+
params.defaultBranch ? params.branchBindings[params.defaultBranch]?.projectId ?? null : null,
|
|
108
|
+
...Object.values(params.branchBindings).map((binding) => binding.projectId),
|
|
109
|
+
params.legacyProjectId
|
|
110
|
+
];
|
|
111
|
+
for (const candidate of candidates) {
|
|
112
|
+
if (candidate) return candidate;
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
async function readCollabBindingState(repoRoot, options) {
|
|
117
|
+
try {
|
|
118
|
+
const persist = options?.persist === true;
|
|
119
|
+
const filePath = getCollabBindingPath(repoRoot);
|
|
120
|
+
const raw = await fs2.readFile(filePath, "utf8");
|
|
121
|
+
const parsed = JSON.parse(raw);
|
|
122
|
+
if (!parsed || typeof parsed !== "object") return null;
|
|
123
|
+
const currentBranch = normalizeBranchName(await getCurrentBranch(repoRoot).catch(() => null));
|
|
124
|
+
if (parsed.schemaVersion === 1) {
|
|
125
|
+
if (!parsed.currentAppId || !parsed.upstreamAppId) return null;
|
|
126
|
+
const projectId = normalizeProjectId(parsed.projectId);
|
|
127
|
+
const preferredBranch = normalizeBranchName(parsed.preferredBranch ?? parsed.defaultBranch ?? null);
|
|
128
|
+
const branchKey = preferredBranch ?? currentBranch ?? null;
|
|
129
|
+
const branchBindings2 = branchKey ? {
|
|
130
|
+
[branchKey]: {
|
|
131
|
+
projectId,
|
|
132
|
+
currentAppId: parsed.currentAppId,
|
|
133
|
+
upstreamAppId: parsed.upstreamAppId,
|
|
134
|
+
threadId: parsed.threadId ?? null,
|
|
135
|
+
laneId: null,
|
|
136
|
+
bindingMode: "legacy"
|
|
137
|
+
}
|
|
138
|
+
} : {};
|
|
139
|
+
const migratedFile = buildBindingFileV3({
|
|
140
|
+
repoFingerprint: parsed.repoFingerprint ?? null,
|
|
141
|
+
remoteUrl: parsed.remoteUrl ?? null,
|
|
142
|
+
defaultBranch: parsed.defaultBranch ?? null,
|
|
143
|
+
branchBindings: branchBindings2
|
|
144
|
+
});
|
|
145
|
+
if (persist) {
|
|
146
|
+
try {
|
|
147
|
+
await writeJsonAtomic(filePath, migratedFile);
|
|
148
|
+
} catch {
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
schemaVersion: 3,
|
|
153
|
+
projectId,
|
|
154
|
+
repoFingerprint: migratedFile.repoFingerprint,
|
|
155
|
+
remoteUrl: migratedFile.remoteUrl,
|
|
156
|
+
defaultBranch: migratedFile.defaultBranch,
|
|
157
|
+
currentBranch,
|
|
158
|
+
branchBindings: migratedFile.branchBindings,
|
|
159
|
+
binding: buildResolvedBinding({
|
|
160
|
+
fallbackProjectId: projectId,
|
|
161
|
+
repoFingerprint: migratedFile.repoFingerprint,
|
|
162
|
+
remoteUrl: migratedFile.remoteUrl,
|
|
163
|
+
defaultBranch: migratedFile.defaultBranch,
|
|
164
|
+
branchName: branchKey,
|
|
165
|
+
binding: branchKey ? migratedFile.branchBindings[branchKey] : null
|
|
166
|
+
})
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
if (parsed.schemaVersion !== 2 && parsed.schemaVersion !== 3) return null;
|
|
170
|
+
const file = parsed;
|
|
171
|
+
let shouldPersistNormalizedBranchBindings = false;
|
|
172
|
+
const legacyProjectId = normalizeProjectId(file.projectId);
|
|
173
|
+
const branchBindings = Object.fromEntries(
|
|
174
|
+
Object.entries(file.branchBindings ?? {}).map(([branchName, branchBinding]) => {
|
|
175
|
+
const normalized = normalizeBranchBinding(branchBinding);
|
|
176
|
+
const rawProjectId = branchBinding && typeof branchBinding === "object" && "projectId" in branchBinding ? normalizeProjectId(branchBinding.projectId) : null;
|
|
177
|
+
const rawBindingMode = branchBinding && typeof branchBinding === "object" && "bindingMode" in branchBinding ? branchBinding.bindingMode : null;
|
|
178
|
+
const hasLegacyPreferredBranch = Boolean(branchBinding) && typeof branchBinding === "object" && "preferredBranch" in branchBinding;
|
|
179
|
+
let normalizedWithProject = normalized;
|
|
180
|
+
if (normalizedWithProject && !normalizedWithProject.projectId && legacyProjectId) {
|
|
181
|
+
normalizedWithProject = {
|
|
182
|
+
...normalizedWithProject,
|
|
183
|
+
projectId: legacyProjectId
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
if (normalizedWithProject && (rawBindingMode !== normalizedWithProject.bindingMode || hasLegacyPreferredBranch || rawProjectId !== normalizedWithProject.projectId)) {
|
|
187
|
+
shouldPersistNormalizedBranchBindings = true;
|
|
188
|
+
}
|
|
189
|
+
return [branchName, normalizedWithProject];
|
|
190
|
+
}).filter((entry) => Boolean(entry[1]))
|
|
191
|
+
);
|
|
192
|
+
const legacyExplicitBinding = normalizeBranchBinding(file.explicitBinding ?? null);
|
|
193
|
+
const legacyExplicitBranch = currentBranch ?? normalizeBranchName(file.defaultBranch);
|
|
194
|
+
if (legacyExplicitBinding && legacyExplicitBranch) {
|
|
195
|
+
branchBindings[legacyExplicitBranch] = {
|
|
196
|
+
...legacyExplicitBinding,
|
|
197
|
+
projectId: legacyExplicitBinding.projectId ?? branchBindings[legacyExplicitBranch]?.projectId ?? legacyProjectId,
|
|
198
|
+
bindingMode: "lane"
|
|
199
|
+
};
|
|
200
|
+
shouldPersistNormalizedBranchBindings = true;
|
|
201
|
+
}
|
|
202
|
+
if (persist && ("explicitBinding" in file || shouldPersistNormalizedBranchBindings || parsed.schemaVersion === 2)) {
|
|
203
|
+
try {
|
|
204
|
+
await writeJsonAtomic(
|
|
205
|
+
filePath,
|
|
206
|
+
buildBindingFileV3({
|
|
207
|
+
repoFingerprint: file.repoFingerprint ?? null,
|
|
208
|
+
remoteUrl: file.remoteUrl ?? null,
|
|
209
|
+
defaultBranch: file.defaultBranch ?? null,
|
|
210
|
+
branchBindings
|
|
211
|
+
})
|
|
212
|
+
);
|
|
213
|
+
} catch {
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const resolvedBranch = currentBranch ?? normalizeBranchName(file.defaultBranch);
|
|
217
|
+
const fallbackProjectId = deriveFallbackProjectId({
|
|
218
|
+
branchBindings,
|
|
219
|
+
currentBranch: resolvedBranch,
|
|
220
|
+
defaultBranch: normalizeBranchName(file.defaultBranch),
|
|
221
|
+
legacyProjectId
|
|
222
|
+
});
|
|
223
|
+
return {
|
|
224
|
+
schemaVersion: parsed.schemaVersion,
|
|
225
|
+
projectId: fallbackProjectId,
|
|
226
|
+
repoFingerprint: file.repoFingerprint ?? null,
|
|
227
|
+
remoteUrl: file.remoteUrl ?? null,
|
|
228
|
+
defaultBranch: file.defaultBranch ?? null,
|
|
229
|
+
currentBranch,
|
|
230
|
+
branchBindings,
|
|
231
|
+
binding: buildResolvedBinding({
|
|
232
|
+
fallbackProjectId,
|
|
233
|
+
repoFingerprint: file.repoFingerprint ?? null,
|
|
234
|
+
remoteUrl: file.remoteUrl ?? null,
|
|
235
|
+
defaultBranch: file.defaultBranch ?? null,
|
|
236
|
+
branchName: resolvedBranch,
|
|
237
|
+
binding: resolvedBranch ? branchBindings[resolvedBranch] ?? null : null
|
|
238
|
+
})
|
|
239
|
+
};
|
|
240
|
+
} catch {
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
async function readCollabBinding(repoRoot) {
|
|
245
|
+
const state = await readCollabBindingState(repoRoot);
|
|
246
|
+
return state?.binding ?? null;
|
|
247
|
+
}
|
|
248
|
+
async function writeCollabBinding(repoRoot, binding) {
|
|
249
|
+
const filePath = getCollabBindingPath(repoRoot);
|
|
250
|
+
const currentBranch = normalizeBranchName(await getCurrentBranch(repoRoot).catch(() => null));
|
|
251
|
+
const branchName = normalizeBranchName(binding.branchName) ?? currentBranch ?? binding.defaultBranch ?? "main";
|
|
252
|
+
const existing = await readCollabBindingState(repoRoot, { persist: true });
|
|
253
|
+
const branchBindings = { ...existing?.branchBindings ?? {} };
|
|
254
|
+
branchBindings[branchName] = {
|
|
255
|
+
projectId: normalizeProjectId(binding.projectId) ?? branchBindings[branchName]?.projectId ?? existing?.projectId ?? null,
|
|
256
|
+
currentAppId: binding.currentAppId,
|
|
257
|
+
upstreamAppId: binding.upstreamAppId,
|
|
258
|
+
threadId: binding.threadId ?? null,
|
|
259
|
+
laneId: binding.laneId ?? null,
|
|
260
|
+
bindingMode: binding.bindingMode ?? "lane"
|
|
261
|
+
};
|
|
262
|
+
await writeJsonAtomic(
|
|
263
|
+
filePath,
|
|
264
|
+
buildBindingFileV3({
|
|
265
|
+
repoFingerprint: binding.repoFingerprint ?? null,
|
|
266
|
+
remoteUrl: binding.remoteUrl ?? null,
|
|
267
|
+
defaultBranch: binding.defaultBranch ?? null,
|
|
268
|
+
branchBindings
|
|
269
|
+
})
|
|
270
|
+
);
|
|
271
|
+
return filePath;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export {
|
|
275
|
+
reserveDirectory,
|
|
276
|
+
reserveAvailableDirPath,
|
|
277
|
+
getCollabBindingPath,
|
|
278
|
+
readCollabBindingState,
|
|
279
|
+
readCollabBinding,
|
|
280
|
+
writeCollabBinding
|
|
281
|
+
};
|