@remixhq/core 0.1.14 → 0.1.15

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.
Files changed (72) hide show
  1. package/dist/api.d.ts +1 -1
  2. package/dist/collab.d.ts +2 -2
  3. package/dist/collab.js +1 -1
  4. package/dist/{contracts-NbV3P_Rl.d.ts → contracts-CHmD-fMj.d.ts} +1 -1
  5. package/dist/history.d.ts +64 -0
  6. package/dist/history.js +529 -0
  7. package/dist/index.d.ts +1 -1
  8. package/package.json +6 -2
  9. package/dist/chunk-2WGZS7CD.js +0 -0
  10. package/dist/chunk-34WDQCPF.js +0 -242
  11. package/dist/chunk-4276ARDF.js +0 -303
  12. package/dist/chunk-4L3ZBZUQ.js +0 -281
  13. package/dist/chunk-54CBEP2W.js +0 -570
  14. package/dist/chunk-55K5GHAZ.js +0 -252
  15. package/dist/chunk-5H5CZKGN.js +0 -691
  16. package/dist/chunk-5NTOJXEZ.js +0 -223
  17. package/dist/chunk-7WUKH3ZD.js +0 -221
  18. package/dist/chunk-AE2HPMUZ.js +0 -80
  19. package/dist/chunk-AEAOYVIL.js +0 -200
  20. package/dist/chunk-B5S3PUIR.js +0 -388
  21. package/dist/chunk-BJFCN2C3.js +0 -46
  22. package/dist/chunk-BNKPTE2U.js +0 -401
  23. package/dist/chunk-C5NBNU32.js +0 -240
  24. package/dist/chunk-CJFGQE7D.js +0 -46
  25. package/dist/chunk-CUUXZSKW.js +0 -611
  26. package/dist/chunk-DCU3646I.js +0 -12
  27. package/dist/chunk-DEWAIK5X.js +0 -11
  28. package/dist/chunk-DRD6EVTT.js +0 -447
  29. package/dist/chunk-DXCL6I4Q.js +0 -399
  30. package/dist/chunk-E4KAGBU7.js +0 -134
  31. package/dist/chunk-E6AYE22H.js +0 -343
  32. package/dist/chunk-EF3677RE.js +0 -93
  33. package/dist/chunk-EVWDYCBL.js +0 -223
  34. package/dist/chunk-EW4PWFHB.js +0 -46
  35. package/dist/chunk-FAZUMWBS.js +0 -93
  36. package/dist/chunk-GEHSFPCD.js +0 -93
  37. package/dist/chunk-GFOBGYW4.js +0 -252
  38. package/dist/chunk-INDDXWAH.js +0 -92
  39. package/dist/chunk-IXWQWFYT.js +0 -342
  40. package/dist/chunk-J3J4PBQ7.js +0 -710
  41. package/dist/chunk-K54U353Z.js +0 -691
  42. package/dist/chunk-K57ZFDGC.js +0 -15
  43. package/dist/chunk-NDA7EJJA.js +0 -286
  44. package/dist/chunk-NK2DA4X6.js +0 -357
  45. package/dist/chunk-OBYR4JHZ.js +0 -374
  46. package/dist/chunk-OJMTW22J.js +0 -286
  47. package/dist/chunk-OMUDRPUI.js +0 -195
  48. package/dist/chunk-ONKKRS2C.js +0 -239
  49. package/dist/chunk-OWFBBWU7.js +0 -196
  50. package/dist/chunk-OZRXDDEL.js +0 -46
  51. package/dist/chunk-P7EM3N73.js +0 -46
  52. package/dist/chunk-POYB6MCQ.js +0 -373
  53. package/dist/chunk-PR5QKMHM.js +0 -46
  54. package/dist/chunk-R44EOUS4.js +0 -288
  55. package/dist/chunk-R7FVSCQW.js +0 -415
  56. package/dist/chunk-RIP2MIZL.js +0 -710
  57. package/dist/chunk-RKMMEML5.js +0 -46
  58. package/dist/chunk-RM2BGDBB.js +0 -400
  59. package/dist/chunk-RREREIGW.js +0 -710
  60. package/dist/chunk-TQHLFQY4.js +0 -448
  61. package/dist/chunk-TY3SSQQK.js +0 -688
  62. package/dist/chunk-UGKPOCN5.js +0 -710
  63. package/dist/chunk-UIGKSCTD.js +0 -406
  64. package/dist/chunk-UWIVJRTI.js +0 -343
  65. package/dist/chunk-VA6WXRWB.js +0 -636
  66. package/dist/chunk-XC2FV57P.js +0 -385
  67. package/dist/chunk-XOQIADCH.js +0 -223
  68. package/dist/chunk-ZAQZKEH4.js +0 -46
  69. package/dist/chunk-ZBMOGUSJ.js +0 -17
  70. package/dist/chunk-ZXP6ENQY.js +0 -244
  71. package/dist/index.cjs +0 -1269
  72. package/dist/index.d.cts +0 -482
@@ -1,93 +0,0 @@
1
- import {
2
- RemixError
3
- } from "./chunk-YZ34ICNN.js";
4
-
5
- // src/infrastructure/binding/collabBindingStore.ts
6
- import fs2 from "fs/promises";
7
- import path2 from "path";
8
-
9
- // src/shared/fs.ts
10
- import fs from "fs/promises";
11
- import path from "path";
12
- async function reserveDirectory(targetDir) {
13
- try {
14
- await fs.mkdir(targetDir);
15
- return targetDir;
16
- } catch (error) {
17
- if (error?.code === "EEXIST") {
18
- throw new RemixError("Output directory already exists.", {
19
- exitCode: 2,
20
- hint: `Choose an empty destination path: ${targetDir}`
21
- });
22
- }
23
- throw error;
24
- }
25
- }
26
- async function reserveAvailableDirPath(preferredDir) {
27
- const parent = path.dirname(preferredDir);
28
- const base = path.basename(preferredDir);
29
- for (let i = 1; i <= 1e3; i += 1) {
30
- const candidate = i === 1 ? preferredDir : path.join(parent, `${base}-${i}`);
31
- try {
32
- await fs.mkdir(candidate);
33
- return candidate;
34
- } catch (error) {
35
- if (error?.code === "EEXIST") continue;
36
- throw error;
37
- }
38
- }
39
- throw new RemixError("No available output directory name.", {
40
- exitCode: 2,
41
- hint: `Tried ${base} through ${base}-1000 under ${parent}.`
42
- });
43
- }
44
- async function writeJsonAtomic(filePath, value) {
45
- const dir = path.dirname(filePath);
46
- await fs.mkdir(dir, { recursive: true });
47
- const tmp = `${filePath}.tmp-${Date.now()}`;
48
- await fs.writeFile(tmp, `${JSON.stringify(value, null, 2)}
49
- `, "utf8");
50
- await fs.rename(tmp, filePath);
51
- }
52
-
53
- // src/infrastructure/binding/collabBindingStore.ts
54
- function getCollabBindingPath(repoRoot) {
55
- return path2.join(repoRoot, ".remix", "config.json");
56
- }
57
- async function readCollabBinding(repoRoot) {
58
- try {
59
- const raw = await fs2.readFile(getCollabBindingPath(repoRoot), "utf8");
60
- const parsed = JSON.parse(raw);
61
- if (parsed?.schemaVersion !== 1) return null;
62
- if (!parsed.projectId || !parsed.currentAppId || !parsed.upstreamAppId) return null;
63
- return {
64
- schemaVersion: 1,
65
- projectId: parsed.projectId,
66
- currentAppId: parsed.currentAppId,
67
- upstreamAppId: parsed.upstreamAppId,
68
- threadId: parsed.threadId ?? null,
69
- repoFingerprint: parsed.repoFingerprint ?? null,
70
- remoteUrl: parsed.remoteUrl ?? null,
71
- defaultBranch: parsed.defaultBranch ?? null,
72
- preferredBranch: parsed.preferredBranch ?? parsed.defaultBranch ?? null
73
- };
74
- } catch {
75
- return null;
76
- }
77
- }
78
- async function writeCollabBinding(repoRoot, binding) {
79
- const filePath = getCollabBindingPath(repoRoot);
80
- await writeJsonAtomic(filePath, {
81
- schemaVersion: 1,
82
- ...binding
83
- });
84
- return filePath;
85
- }
86
-
87
- export {
88
- reserveDirectory,
89
- reserveAvailableDirPath,
90
- getCollabBindingPath,
91
- readCollabBinding,
92
- writeCollabBinding
93
- };
@@ -1,93 +0,0 @@
1
- import {
2
- RemixError
3
- } from "./chunk-YZ34ICNN.js";
4
-
5
- // src/infrastructure/binding/collabBindingStore.ts
6
- import fs2 from "fs/promises";
7
- import path2 from "path";
8
-
9
- // src/shared/fs.ts
10
- import fs from "fs/promises";
11
- import path from "path";
12
- async function reserveDirectory(targetDir) {
13
- try {
14
- await fs.mkdir(targetDir);
15
- return targetDir;
16
- } catch (error) {
17
- if (error?.code === "EEXIST") {
18
- throw new RemixError("Output directory already exists.", {
19
- exitCode: 2,
20
- hint: `Choose an empty destination path: ${targetDir}`
21
- });
22
- }
23
- throw error;
24
- }
25
- }
26
- async function reserveAvailableDirPath(preferredDir) {
27
- const parent = path.dirname(preferredDir);
28
- const base = path.basename(preferredDir);
29
- for (let i = 1; i <= 1e3; i += 1) {
30
- const candidate = i === 1 ? preferredDir : path.join(parent, `${base}-${i}`);
31
- try {
32
- await fs.mkdir(candidate);
33
- return candidate;
34
- } catch (error) {
35
- if (error?.code === "EEXIST") continue;
36
- throw error;
37
- }
38
- }
39
- throw new RemixError("No available output directory name.", {
40
- exitCode: 2,
41
- hint: `Tried ${base} through ${base}-1000 under ${parent}.`
42
- });
43
- }
44
- async function writeJsonAtomic(filePath, value) {
45
- const dir = path.dirname(filePath);
46
- await fs.mkdir(dir, { recursive: true });
47
- const tmp = `${filePath}.tmp-${Date.now()}`;
48
- await fs.writeFile(tmp, `${JSON.stringify(value, null, 2)}
49
- `, "utf8");
50
- await fs.rename(tmp, filePath);
51
- }
52
-
53
- // src/infrastructure/binding/collabBindingStore.ts
54
- function getCollabBindingPath(repoRoot) {
55
- return path2.join(repoRoot, ".remix", "config.json");
56
- }
57
- async function readCollabBinding(repoRoot) {
58
- try {
59
- const raw = await fs2.readFile(getCollabBindingPath(repoRoot), "utf8");
60
- const parsed = JSON.parse(raw);
61
- if (parsed?.schemaVersion !== 1) return null;
62
- if (!parsed.projectId || !parsed.currentAppId || !parsed.upstreamAppId) return null;
63
- return {
64
- schemaVersion: 1,
65
- projectId: parsed.projectId,
66
- currentAppId: parsed.currentAppId,
67
- upstreamAppId: parsed.upstreamAppId,
68
- threadId: parsed.threadId ?? null,
69
- repoFingerprint: parsed.repoFingerprint ?? null,
70
- remoteUrl: parsed.remoteUrl ?? null,
71
- defaultBranch: parsed.defaultBranch ?? null,
72
- preferredBranch: parsed.preferredBranch ?? parsed.defaultBranch ?? null
73
- };
74
- } catch {
75
- return null;
76
- }
77
- }
78
- async function writeCollabBinding(repoRoot, binding) {
79
- const filePath = getCollabBindingPath(repoRoot);
80
- await writeJsonAtomic(filePath, {
81
- schemaVersion: 1,
82
- ...binding
83
- });
84
- return filePath;
85
- }
86
-
87
- export {
88
- reserveDirectory,
89
- reserveAvailableDirPath,
90
- getCollabBindingPath,
91
- readCollabBinding,
92
- writeCollabBinding
93
- };
@@ -1,252 +0,0 @@
1
- import {
2
- ComergeError
3
- } from "./chunk-K57ZFDGC.js";
4
-
5
- // src/api/client.ts
6
- async function readJsonSafe(res) {
7
- const ct = res.headers.get("content-type") ?? "";
8
- if (!ct.toLowerCase().includes("application/json")) return null;
9
- try {
10
- return await res.json();
11
- } catch {
12
- return null;
13
- }
14
- }
15
- function createApiClient(config, opts) {
16
- const apiKey = (opts?.apiKey ?? "").trim();
17
- const tokenProvider = opts?.tokenProvider;
18
- const CLIENT_KEY_HEADER = "x-comerge-api-key";
19
- async function request(path, init) {
20
- if (!tokenProvider) {
21
- throw new ComergeError("API client is missing a token provider.", {
22
- exitCode: 1,
23
- hint: "Configure auth before creating the Comerge API client."
24
- });
25
- }
26
- const auth = await tokenProvider();
27
- const url = new URL(path, config.apiUrl).toString();
28
- const doFetch = async (bearer) => fetch(url, {
29
- ...init,
30
- headers: {
31
- Accept: "application/json",
32
- "Content-Type": "application/json",
33
- ...init?.headers ?? {},
34
- Authorization: `Bearer ${bearer}`,
35
- ...apiKey ? { [CLIENT_KEY_HEADER]: apiKey } : {}
36
- }
37
- });
38
- let res = await doFetch(auth.token);
39
- if (res.status === 401 && !auth.fromEnv && auth.session?.refresh_token) {
40
- const refreshed = await tokenProvider({ forceRefresh: true });
41
- res = await doFetch(refreshed.token);
42
- }
43
- if (!res.ok) {
44
- const body = await readJsonSafe(res);
45
- const msg = (body && typeof body === "object" && body && "message" in body && typeof body.message === "string" ? body.message : null) ?? `Request failed (status ${res.status})`;
46
- throw new ComergeError(msg, { exitCode: 1, hint: body ? JSON.stringify(body, null, 2) : null });
47
- }
48
- const json = await readJsonSafe(res);
49
- return json ?? null;
50
- }
51
- async function requestBinary(path, init) {
52
- if (!tokenProvider) {
53
- throw new ComergeError("API client is missing a token provider.", {
54
- exitCode: 1,
55
- hint: "Configure auth before creating the Comerge API client."
56
- });
57
- }
58
- const auth = await tokenProvider();
59
- const url = new URL(path, config.apiUrl).toString();
60
- const doFetch = async (bearer) => fetch(url, {
61
- ...init,
62
- headers: {
63
- Accept: "*/*",
64
- ...init?.headers ?? {},
65
- Authorization: `Bearer ${bearer}`,
66
- ...apiKey ? { [CLIENT_KEY_HEADER]: apiKey } : {}
67
- }
68
- });
69
- let res = await doFetch(auth.token);
70
- if (res.status === 401 && !auth.fromEnv && auth.session?.refresh_token) {
71
- const refreshed = await tokenProvider({ forceRefresh: true });
72
- res = await doFetch(refreshed.token);
73
- }
74
- if (!res.ok) {
75
- const body = await readJsonSafe(res);
76
- const msg = (body && typeof body === "object" && body && "message" in body && typeof body.message === "string" ? body.message : null) ?? `Request failed (status ${res.status})`;
77
- throw new ComergeError(msg, { exitCode: 1, hint: body ? JSON.stringify(body, null, 2) : null });
78
- }
79
- const contentDisposition = res.headers.get("content-disposition") ?? "";
80
- const fileNameMatch = contentDisposition.match(/filename=\"([^\"]+)\"/i);
81
- return {
82
- data: Buffer.from(await res.arrayBuffer()),
83
- fileName: fileNameMatch?.[1] ?? null,
84
- contentType: res.headers.get("content-type")
85
- };
86
- }
87
- return {
88
- getMe: () => request("/v1/me", { method: "GET" }),
89
- listOrganizations: () => request("/v1/organizations", { method: "GET" }),
90
- listProjects: (params) => {
91
- const qs = new URLSearchParams();
92
- if (params?.organizationId) qs.set("organizationId", params.organizationId);
93
- if (params?.clientAppId) qs.set("clientAppId", params.clientAppId);
94
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
95
- return request(`/v1/projects${suffix}`, { method: "GET" });
96
- },
97
- resolveProjectBinding: (params) => {
98
- const qs = new URLSearchParams();
99
- if (params.repoFingerprint) qs.set("repoFingerprint", params.repoFingerprint);
100
- if (params.remoteUrl) qs.set("remoteUrl", params.remoteUrl);
101
- return request(`/v1/projects/bindings/resolve?${qs.toString()}`, { method: "GET" });
102
- },
103
- autoEnableDeveloper: () => request("/v1/developer/auto-enable", { method: "POST" }),
104
- listClientApps: (params) => {
105
- const qs = params?.orgId ? `?orgId=${encodeURIComponent(params.orgId)}` : "";
106
- return request(`/v1/developer/client-apps${qs}`, { method: "GET" });
107
- },
108
- createClientApp: (payload) => request("/v1/developer/client-apps", { method: "POST", body: JSON.stringify(payload) }),
109
- createClientAppKey: (clientAppId, payload) => request(`/v1/developer/client-apps/${encodeURIComponent(clientAppId)}/keys`, {
110
- method: "POST",
111
- body: JSON.stringify(payload ?? {})
112
- }),
113
- listApps: (params) => {
114
- const qs = new URLSearchParams();
115
- if (params?.projectId) qs.set("projectId", params.projectId);
116
- if (params?.organizationId) qs.set("organizationId", params.organizationId);
117
- if (params?.forked) qs.set("forked", params.forked);
118
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
119
- return request(`/v1/apps${suffix}`, { method: "GET" });
120
- },
121
- getApp: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}`, { method: "GET" }),
122
- getMergeRequest: (mrId) => request(`/v1/merge-requests/${encodeURIComponent(mrId)}`, { method: "GET" }),
123
- presignImportUpload: (payload) => request("/v1/apps/import/upload/presign", { method: "POST", body: JSON.stringify(payload) }),
124
- importFromUpload: (payload) => request("/v1/apps/import/upload", { method: "POST", body: JSON.stringify(payload) }),
125
- presignImportUploadFirstParty: (payload) => request("/v1/apps/import/upload/presign/first-party", { method: "POST", body: JSON.stringify(payload) }),
126
- importFromUploadFirstParty: (payload) => request("/v1/apps/import/upload/first-party", { method: "POST", body: JSON.stringify(payload) }),
127
- importFromGithubFirstParty: (payload) => request("/v1/apps/import/github/first-party", { method: "POST", body: JSON.stringify(payload) }),
128
- forkApp: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/fork`, { method: "POST", body: JSON.stringify(payload ?? {}) }),
129
- downloadAppBundle: (appId) => requestBinary(`/v1/apps/${encodeURIComponent(appId)}/download.bundle`, { method: "GET" }),
130
- createChangeStep: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps`, {
131
- method: "POST",
132
- body: JSON.stringify(payload)
133
- }),
134
- createCollabTurn: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns`, {
135
- method: "POST",
136
- body: JSON.stringify(payload)
137
- }),
138
- listCollabTurns: (appId, params) => {
139
- const qs = new URLSearchParams();
140
- if (params?.limit !== void 0) qs.set("limit", String(params.limit));
141
- if (params?.offset !== void 0) qs.set("offset", String(params.offset));
142
- if (params?.changeStepId) qs.set("changeStepId", params.changeStepId);
143
- if (params?.threadId) qs.set("threadId", params.threadId);
144
- if (params?.createdAfter) qs.set("createdAfter", params.createdAfter);
145
- if (params?.createdBefore) qs.set("createdBefore", params.createdBefore);
146
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
147
- return request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns${suffix}`, { method: "GET" });
148
- },
149
- getCollabTurn: (appId, collabTurnId) => request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns/${encodeURIComponent(collabTurnId)}`, {
150
- method: "GET"
151
- }),
152
- getAgentMemorySummary: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/agent-memory/summary`, { method: "GET" }),
153
- listAgentMemoryTimeline: (appId, params) => {
154
- const qs = new URLSearchParams();
155
- if (params?.limit !== void 0) qs.set("limit", String(params.limit));
156
- if (params?.offset !== void 0) qs.set("offset", String(params.offset));
157
- if (params?.createdAfter) qs.set("createdAfter", params.createdAfter);
158
- if (params?.createdBefore) qs.set("createdBefore", params.createdBefore);
159
- if (params?.kinds?.length) {
160
- for (const kind of params.kinds) qs.append("kinds", kind);
161
- }
162
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
163
- return request(`/v1/apps/${encodeURIComponent(appId)}/agent-memory/timeline${suffix}`, { method: "GET" });
164
- },
165
- searchAgentMemory: (appId, params) => {
166
- const qs = new URLSearchParams();
167
- qs.set("q", params.q);
168
- if (params.limit !== void 0) qs.set("limit", String(params.limit));
169
- if (params.offset !== void 0) qs.set("offset", String(params.offset));
170
- if (params.createdAfter) qs.set("createdAfter", params.createdAfter);
171
- if (params.createdBefore) qs.set("createdBefore", params.createdBefore);
172
- if (params.kinds?.length) {
173
- for (const kind of params.kinds) qs.append("kinds", kind);
174
- }
175
- return request(`/v1/apps/${encodeURIComponent(appId)}/agent-memory/search?${qs.toString()}`, { method: "GET" });
176
- },
177
- getChangeStep: (appId, changeStepId) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/${encodeURIComponent(changeStepId)}`, { method: "GET" }),
178
- getChangeStepDiff: (appId, changeStepId) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/${encodeURIComponent(changeStepId)}/diff`, {
179
- method: "GET"
180
- }),
181
- startChangeStepReplay: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/replays`, {
182
- method: "POST",
183
- body: JSON.stringify(payload)
184
- }),
185
- getChangeStepReplay: (appId, replayId) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/replays/${encodeURIComponent(replayId)}`, {
186
- method: "GET"
187
- }),
188
- getChangeStepReplayDiff: (appId, replayId) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/replays/${encodeURIComponent(replayId)}/diff`, {
189
- method: "GET"
190
- }),
191
- listMergeRequests: (params) => {
192
- const qs = new URLSearchParams();
193
- if (params?.sourceAppId) qs.set("sourceAppId", params.sourceAppId);
194
- if (params?.targetAppId) qs.set("targetAppId", params.targetAppId);
195
- if (Array.isArray(params?.status)) {
196
- for (const status of params.status) qs.append("status", status);
197
- } else if (typeof params?.status === "string") {
198
- qs.set("status", params.status);
199
- }
200
- if (params?.kind) qs.set("kind", params.kind);
201
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
202
- return request(`/v1/merge-requests${suffix}`, { method: "GET" });
203
- },
204
- openMergeRequest: (sourceAppId) => request("/v1/merge-requests", { method: "POST", body: JSON.stringify({ sourceAppId }) }),
205
- getMergeRequestReview: (mrId) => request(`/v1/merge-requests/${encodeURIComponent(mrId)}/review`, { method: "GET" }),
206
- updateMergeRequest: (mrId, payload) => request(`/v1/merge-requests/${encodeURIComponent(mrId)}`, { method: "PATCH", body: JSON.stringify(payload) }),
207
- createProjectInvite: (projectId, payload) => request(`/v1/projects/${encodeURIComponent(projectId)}/invitations`, {
208
- method: "POST",
209
- body: JSON.stringify(payload)
210
- }),
211
- syncUpstreamApp: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/sync-upstream`, {
212
- method: "POST",
213
- body: JSON.stringify({})
214
- }),
215
- preflightAppReconcile: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/reconcile/preflight`, {
216
- method: "POST",
217
- body: JSON.stringify(payload)
218
- }),
219
- startAppReconcile: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/reconcile/start`, {
220
- method: "POST",
221
- body: JSON.stringify(payload)
222
- }),
223
- getAppReconcile: (appId, reconcileId) => request(`/v1/apps/${encodeURIComponent(appId)}/reconcile/${encodeURIComponent(reconcileId)}`, { method: "GET" }),
224
- downloadAppReconcileBundle: (appId, reconcileId) => requestBinary(`/v1/apps/${encodeURIComponent(appId)}/reconcile/${encodeURIComponent(reconcileId)}/download.bundle`, {
225
- method: "GET"
226
- }),
227
- syncLocalApp: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/sync-local`, {
228
- method: "POST",
229
- body: JSON.stringify(payload)
230
- }),
231
- initiateBundle: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/bundles`, { method: "POST", body: JSON.stringify(payload) }),
232
- getBundle: (appId, bundleId) => request(`/v1/apps/${encodeURIComponent(appId)}/bundles/${encodeURIComponent(bundleId)}`, { method: "GET" }),
233
- getBundleDownloadUrl: (appId, bundleId, options) => request(
234
- `/v1/apps/${encodeURIComponent(appId)}/bundles/${encodeURIComponent(bundleId)}/download?redirect=${options?.redirect ?? false}`,
235
- { method: "GET" }
236
- ),
237
- getBundleAssetsDownloadUrl: (appId, bundleId, options) => {
238
- const qs = new URLSearchParams({
239
- redirect: String(options?.redirect ?? false),
240
- kind: options?.kind ?? "metro-assets"
241
- });
242
- return request(
243
- `/v1/apps/${encodeURIComponent(appId)}/bundles/${encodeURIComponent(bundleId)}/assets/download?${qs.toString()}`,
244
- { method: "GET" }
245
- );
246
- }
247
- };
248
- }
249
-
250
- export {
251
- createApiClient
252
- };
@@ -1,92 +0,0 @@
1
- import {
2
- ComergeError
3
- } from "./chunk-ZBMOGUSJ.js";
4
-
5
- // src/infrastructure/binding/collabBindingStore.ts
6
- import fs2 from "fs/promises";
7
- import path2 from "path";
8
-
9
- // src/shared/fs.ts
10
- import fs from "fs/promises";
11
- import path from "path";
12
- async function reserveDirectory(targetDir) {
13
- try {
14
- await fs.mkdir(targetDir);
15
- return targetDir;
16
- } catch (error) {
17
- if (error?.code === "EEXIST") {
18
- throw new ComergeError("Output directory already exists.", {
19
- exitCode: 2,
20
- hint: `Choose an empty destination path: ${targetDir}`
21
- });
22
- }
23
- throw error;
24
- }
25
- }
26
- async function reserveAvailableDirPath(preferredDir) {
27
- const parent = path.dirname(preferredDir);
28
- const base = path.basename(preferredDir);
29
- for (let i = 1; i <= 1e3; i += 1) {
30
- const candidate = i === 1 ? preferredDir : path.join(parent, `${base}-${i}`);
31
- try {
32
- await fs.mkdir(candidate);
33
- return candidate;
34
- } catch (error) {
35
- if (error?.code === "EEXIST") continue;
36
- throw error;
37
- }
38
- }
39
- throw new ComergeError("No available output directory name.", {
40
- exitCode: 2,
41
- hint: `Tried ${base} through ${base}-1000 under ${parent}.`
42
- });
43
- }
44
- async function writeJsonAtomic(filePath, value) {
45
- const dir = path.dirname(filePath);
46
- await fs.mkdir(dir, { recursive: true });
47
- const tmp = `${filePath}.tmp-${Date.now()}`;
48
- await fs.writeFile(tmp, `${JSON.stringify(value, null, 2)}
49
- `, "utf8");
50
- await fs.rename(tmp, filePath);
51
- }
52
-
53
- // src/infrastructure/binding/collabBindingStore.ts
54
- function getCollabBindingPath(repoRoot) {
55
- return path2.join(repoRoot, ".comerge", "config.json");
56
- }
57
- async function readCollabBinding(repoRoot) {
58
- try {
59
- const raw = await fs2.readFile(getCollabBindingPath(repoRoot), "utf8");
60
- const parsed = JSON.parse(raw);
61
- if (parsed?.schemaVersion !== 1) return null;
62
- if (!parsed.projectId || !parsed.currentAppId || !parsed.upstreamAppId) return null;
63
- return {
64
- schemaVersion: 1,
65
- projectId: parsed.projectId,
66
- currentAppId: parsed.currentAppId,
67
- upstreamAppId: parsed.upstreamAppId,
68
- threadId: parsed.threadId ?? null,
69
- repoFingerprint: parsed.repoFingerprint ?? null,
70
- remoteUrl: parsed.remoteUrl ?? null,
71
- defaultBranch: parsed.defaultBranch ?? null
72
- };
73
- } catch {
74
- return null;
75
- }
76
- }
77
- async function writeCollabBinding(repoRoot, binding) {
78
- const filePath = getCollabBindingPath(repoRoot);
79
- await writeJsonAtomic(filePath, {
80
- schemaVersion: 1,
81
- ...binding
82
- });
83
- return filePath;
84
- }
85
-
86
- export {
87
- reserveDirectory,
88
- reserveAvailableDirPath,
89
- getCollabBindingPath,
90
- readCollabBinding,
91
- writeCollabBinding
92
- };