@moldea.ai/cli 13.0.4 → 14.0.1
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 +5 -9
- package/dist/chunks/{composition-DfXcSF44.js → composition-D1OYuZ5d.js} +1 -1
- package/dist/chunks/{composition-DxVb23Ru.js → composition-_3bygS_a.js} +21 -23
- package/dist/chunks/composition-_3bygS_a.js.map +1 -0
- package/dist/chunks/{core-composition-D3haS6M3.js → core-composition-BKcJ--NX.js} +2 -2
- package/dist/chunks/{core-composition-D3haS6M3.js.map → core-composition-BKcJ--NX.js.map} +1 -1
- package/dist/moldea.js +7 -12
- package/dist/moldea.js.map +1 -1
- package/dist/portable/LICENSES.md +506 -0
- package/dist/portable/SHA256SUMS +17 -0
- package/dist/portable/analysis-worker.mjs +170 -0
- package/dist/portable/chunk-1306b995.mjs +2 -0
- package/dist/portable/chunk-24ea7c23.mjs +328 -0
- package/dist/portable/chunk-2cc3bf5c.mjs +399 -0
- package/dist/portable/chunk-2e9d4c63.mjs +95 -0
- package/dist/portable/chunk-43b8574a.mjs +1837 -0
- package/dist/portable/chunk-517c6bfb.mjs +2 -0
- package/dist/portable/chunk-8f198616.mjs +4414 -0
- package/dist/portable/chunk-936e5d09.mjs +112519 -0
- package/dist/portable/chunk-98d84174.mjs +422 -0
- package/dist/portable/chunk-9e42770a.mjs +3114 -0
- package/dist/portable/chunk-cea1378f.mjs +50 -0
- package/dist/portable/chunk-d6656fa6.mjs +14 -0
- package/dist/portable/chunk-d9e49acd.mjs +302 -0
- package/dist/portable/moldea.mjs +2656 -0
- package/dist/portable/node-runner.mjs +117 -0
- package/package.json +3 -3
- package/dist/chunks/composition-DxVb23Ru.js.map +0 -1
|
@@ -0,0 +1,2656 @@
|
|
|
1
|
+
import { c as e, d as t, f as n, l as r, m as i, n as a, t as o, u as s } from "./chunk-2cc3bf5c.mjs";
|
|
2
|
+
import { A as c, B as l, C as u, D as d, E as f, F as p, H as m, I as h, L as g, M as _, N as v, O as ee, P as y, R as b, S as te, T as ne, U as x, V as S, _ as re, a as ie, b as ae, c as oe, d as se, f as ce, g as le, h as ue, j as de, k as fe, l as pe, m as me, o as he, p as ge, s as _e, u as C, v as ve, w as ye, x as be, y as xe, z as Se } from "./chunk-43b8574a.mjs";
|
|
3
|
+
import { g as Ce } from "./chunk-8f198616.mjs";
|
|
4
|
+
import { n as we } from "./chunk-9e42770a.mjs";
|
|
5
|
+
import { a as Te, c as Ee, i as w, l as T, n as E, o as De, r as Oe } from "./chunk-98d84174.mjs";
|
|
6
|
+
import D from "node:path";
|
|
7
|
+
import O from "node:process";
|
|
8
|
+
import { fileURLToPath as ke } from "node:url";
|
|
9
|
+
import { constants as Ae } from "node:fs";
|
|
10
|
+
import { constants as je } from "node:os";
|
|
11
|
+
import { TextDecoder as Me } from "node:util";
|
|
12
|
+
import { createHash as Ne, createHmac as Pe, randomBytes as Fe, timingSafeEqual as Ie } from "node:crypto";
|
|
13
|
+
import { lstat as k, open as Le, opendir as Re, readdir as ze, readlink as Be, realpath as Ve, stat as He } from "node:fs/promises";
|
|
14
|
+
import { Buffer as Ue } from "node:buffer";
|
|
15
|
+
//#region ../../node_modules/.pnpm/jg-utilities@1.7.2/node_modules/jg-utilities/dist/utils/byte-cache.js
|
|
16
|
+
var We = (e) => new Uint8Array(e), Ge = ({ maxBytes: r, maxEntries: i }) => {
|
|
17
|
+
if (e(r), i !== void 0 && (!Number.isSafeInteger(i) || i < 1)) throw new n("The entry limit must be a positive safe integer.", {
|
|
18
|
+
code: t.INVALID_BYTE_LIMIT,
|
|
19
|
+
data: { maxEntries: String(i) }
|
|
20
|
+
});
|
|
21
|
+
let a = i ?? Infinity, o = new Map(), s = 0, c = 0, l = 0, u = (e, t) => {
|
|
22
|
+
o.delete(e), s -= t.bytes.byteLength;
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
get: (e) => {
|
|
26
|
+
let t = o.get(e);
|
|
27
|
+
if (t !== void 0) return o.delete(e), o.set(e, t), We(t.bytes);
|
|
28
|
+
},
|
|
29
|
+
set: (e, t) => {
|
|
30
|
+
let n = o.get(e);
|
|
31
|
+
if (n !== void 0 && n.retentions > 0 || c + t.byteLength > r || l + 1 > a) return !1;
|
|
32
|
+
n !== void 0 && u(e, n);
|
|
33
|
+
for (let [e, n] of o) {
|
|
34
|
+
if (s + t.byteLength <= r && o.size < a) break;
|
|
35
|
+
n.retentions === 0 && u(e, n);
|
|
36
|
+
}
|
|
37
|
+
return o.set(e, {
|
|
38
|
+
bytes: We(t),
|
|
39
|
+
retentions: 0
|
|
40
|
+
}), s += t.byteLength, !0;
|
|
41
|
+
},
|
|
42
|
+
retain: (e) => {
|
|
43
|
+
let t = o.get(e);
|
|
44
|
+
if (t !== void 0) return t.retentions === 0 && (c += t.bytes.byteLength, l += 1), t.retentions += 1, {
|
|
45
|
+
copyBytes: () => t === void 0 ? void 0 : We(t.bytes),
|
|
46
|
+
release: () => {
|
|
47
|
+
t !== void 0 && (--t.retentions, t.retentions === 0 && (c -= t.bytes.byteLength, --l), t = void 0);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
get byteLength() {
|
|
52
|
+
return s;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}, Ke = 2147483647, qe = (e, i) => {
|
|
56
|
+
if (!r(e, 0)) throw new n("The queue limit must be an integer of at least 0.", {
|
|
57
|
+
code: t.INVALID_QUEUE_LIMIT,
|
|
58
|
+
data: { [i]: String(e) }
|
|
59
|
+
});
|
|
60
|
+
}, Je = (e) => {
|
|
61
|
+
let r = e instanceof Date ? e.getTime() : e;
|
|
62
|
+
if (typeof r != "number" || Number.isNaN(new Date(r).getTime())) throw new n("The deadline must be a valid Date or epoch milliseconds a Date accepts.", {
|
|
63
|
+
code: t.INVALID_DATE,
|
|
64
|
+
data: { deadline: String(e) }
|
|
65
|
+
});
|
|
66
|
+
return r;
|
|
67
|
+
}, Ye = ({ maxConcurrent: e, maxQueued: i }) => {
|
|
68
|
+
if (!r(e, 1)) throw new n("The concurrency limit must be an integer of at least 1.", {
|
|
69
|
+
code: t.INVALID_CONCURRENCY_LIMIT,
|
|
70
|
+
data: { maxConcurrent: String(e) }
|
|
71
|
+
});
|
|
72
|
+
qe(i, "maxQueued");
|
|
73
|
+
let a = 0, o = 0, s, c = !1, l = [], u = () => new n("Requests are paused until the cooldown ends.", {
|
|
74
|
+
code: t.REQUEST_COOLDOWN_ACTIVE,
|
|
75
|
+
data: { retryAt: new Date(o).toISOString() }
|
|
76
|
+
}), d = () => new n("The request coordinator is closed.", { code: t.REQUEST_COORDINATOR_CLOSED }), f = () => {
|
|
77
|
+
s !== void 0 && (clearTimeout(s), s = void 0);
|
|
78
|
+
}, p = () => {
|
|
79
|
+
if (f(), l.length === 0) return;
|
|
80
|
+
let t = o - Date.now();
|
|
81
|
+
if (t > 0) {
|
|
82
|
+
for (let e = l.length - 1; e >= 0; --e) {
|
|
83
|
+
let t = l[e];
|
|
84
|
+
t?.rejectDuringCooldown === !0 && (l.splice(e, 1), t.detach(), t.reject(u()));
|
|
85
|
+
}
|
|
86
|
+
l.length > 0 && (s = setTimeout(p, Math.min(t, Ke)));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
for (; a < e;) {
|
|
90
|
+
let e = l.shift();
|
|
91
|
+
if (e === void 0) return;
|
|
92
|
+
e.detach(), e.signal?.aborted === !0 ? e.reject(e.signal.reason) : (a += 1, e.resolve());
|
|
93
|
+
}
|
|
94
|
+
}, m = ({ signal: r, caller: s, maxQueuedForCaller: f, rejectDuringCooldown: m = !1 }) => {
|
|
95
|
+
if (c) return Promise.reject(d());
|
|
96
|
+
if (r?.aborted === !0) return Promise.reject(r.reason);
|
|
97
|
+
f !== void 0 && qe(f, "maxQueuedForCaller");
|
|
98
|
+
let h = o > Date.now();
|
|
99
|
+
if (h && m) return Promise.reject(u());
|
|
100
|
+
if (!h && a < e && l.length === 0) return a += 1, Promise.resolve();
|
|
101
|
+
if (f !== void 0) {
|
|
102
|
+
let e = l.filter((e) => e.caller === s).length;
|
|
103
|
+
if (e >= f) return Promise.reject(new n("The request queue is full.", {
|
|
104
|
+
code: t.REQUEST_QUEUE_FULL,
|
|
105
|
+
data: {
|
|
106
|
+
scope: "caller",
|
|
107
|
+
queued: e,
|
|
108
|
+
limit: f
|
|
109
|
+
}
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
return l.length >= i ? Promise.reject(new n("The request queue is full.", {
|
|
113
|
+
code: t.REQUEST_QUEUE_FULL,
|
|
114
|
+
data: {
|
|
115
|
+
scope: "global",
|
|
116
|
+
queued: l.length,
|
|
117
|
+
limit: i
|
|
118
|
+
}
|
|
119
|
+
})) : new Promise((e, t) => {
|
|
120
|
+
let n = () => {
|
|
121
|
+
l.splice(l.indexOf(i), 1), i.detach(), p(), t(r?.reason);
|
|
122
|
+
}, i = {
|
|
123
|
+
caller: s,
|
|
124
|
+
signal: r,
|
|
125
|
+
rejectDuringCooldown: m,
|
|
126
|
+
resolve: e,
|
|
127
|
+
reject: t,
|
|
128
|
+
detach: () => r?.removeEventListener("abort", n)
|
|
129
|
+
};
|
|
130
|
+
l.push(i), r?.addEventListener("abort", n, { once: !0 }), p();
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
return {
|
|
134
|
+
run: async (e, t = {}) => {
|
|
135
|
+
await m(t);
|
|
136
|
+
try {
|
|
137
|
+
return await e();
|
|
138
|
+
} finally {
|
|
139
|
+
--a, p();
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
deferUntil: (e) => {
|
|
143
|
+
o = Math.max(o, Je(e)), p();
|
|
144
|
+
},
|
|
145
|
+
isIdle: () => a === 0 && l.length === 0 && o <= Date.now(),
|
|
146
|
+
close: () => {
|
|
147
|
+
c = !0, f();
|
|
148
|
+
for (let e of l.splice(0)) e.detach(), e.reject(d());
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}, Xe = ["SIGINT", "SIGTERM"], Ze = new Set(["SIGKILL", "SIGSTOP"]), Qe = () => new n("The shutdown needs a non-empty list of signals Node.js can listen for, such as SIGINT, other than SIGKILL and SIGSTOP, and an onSignal that's a function when it's given.", { code: x.INVALID_SIGNAL }), $e = (e) => {
|
|
152
|
+
let t = Array.isArray(e) ? [...new Set(e)] : [];
|
|
153
|
+
if (!(t.length > 0 && t.every((e) => typeof e == "string" && Object.hasOwn(je.signals, e) && !Ze.has(e)))) throw Qe();
|
|
154
|
+
return t;
|
|
155
|
+
}, et = ({ signals: e = Xe, onSignal: t, setExitCode: r = !0, forceOnRepeat: i = !1, disconnect: a = !1 } = {}) => {
|
|
156
|
+
if (t !== void 0 && typeof t != "function") throw Qe();
|
|
157
|
+
let o = $e(e), s = new AbortController(), c = null, l = !1, u = (e) => 128 + je.signals[e], d = () => {
|
|
158
|
+
f("SIGTERM");
|
|
159
|
+
}, f = (e) => {
|
|
160
|
+
if (c !== null) return;
|
|
161
|
+
c = e;
|
|
162
|
+
let a = u(e);
|
|
163
|
+
r && (process.exitCode = a), i && p(), s.abort(new n(`The process was interrupted by ${e}.`, {
|
|
164
|
+
code: x.PROCESS_INTERRUPTED,
|
|
165
|
+
data: {
|
|
166
|
+
signal: e,
|
|
167
|
+
exitCode: a
|
|
168
|
+
}
|
|
169
|
+
}));
|
|
170
|
+
try {
|
|
171
|
+
Promise.resolve(t?.(e)).catch(() => void 0);
|
|
172
|
+
} catch {}
|
|
173
|
+
}, p = () => {
|
|
174
|
+
if (!l) {
|
|
175
|
+
l = !0;
|
|
176
|
+
for (let e of o) process.off(e, f);
|
|
177
|
+
process.off("disconnect", d);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
for (let e of o) process.on(e, f);
|
|
181
|
+
return a && process.send !== void 0 && (process.connected ? process.on("disconnect", d) : d()), {
|
|
182
|
+
signal: s.signal,
|
|
183
|
+
receivedSignal: () => c,
|
|
184
|
+
exitCode: () => c === null ? null : u(c),
|
|
185
|
+
dispose: p
|
|
186
|
+
};
|
|
187
|
+
}, tt = ({ maxBytes: e, signal: t }) => new Promise((r, i) => {
|
|
188
|
+
if (!Number.isSafeInteger(e) || e <= 0) {
|
|
189
|
+
i(new n("The stdin limit must be a positive safe integer.", {
|
|
190
|
+
code: x.INVALID_PROCESS_OPTIONS,
|
|
191
|
+
data: { maxBytes: String(e) }
|
|
192
|
+
}));
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
let { stdin: a } = process, o = [], s = 0, c = () => {
|
|
196
|
+
a.off("data", u), a.off("end", d), a.off("error", f), t?.removeEventListener("abort", p);
|
|
197
|
+
}, l = (e) => {
|
|
198
|
+
c(), a.destroy(), i(e);
|
|
199
|
+
}, u = (t) => {
|
|
200
|
+
if (s += t.length, s > e) {
|
|
201
|
+
l(new n(`The input on stdin is larger than ${e} bytes.`, {
|
|
202
|
+
code: x.STDIN_TOO_LARGE,
|
|
203
|
+
data: { maxBytes: e }
|
|
204
|
+
}));
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
o.push(t);
|
|
208
|
+
}, d = () => {
|
|
209
|
+
c(), r(Buffer.concat(o));
|
|
210
|
+
}, f = (e) => {
|
|
211
|
+
l(e);
|
|
212
|
+
}, p = () => {
|
|
213
|
+
l(t?.reason);
|
|
214
|
+
};
|
|
215
|
+
if (t?.aborted) {
|
|
216
|
+
l(t.reason);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
t?.addEventListener("abort", p, { once: !0 }), a.on("data", u), a.once("end", d), a.once("error", f);
|
|
220
|
+
}), A = {
|
|
221
|
+
Interrupted: 130,
|
|
222
|
+
OperationalError: 3,
|
|
223
|
+
StructuralInvalid: 1,
|
|
224
|
+
Success: 0,
|
|
225
|
+
Terminated: 143,
|
|
226
|
+
UsageError: 2
|
|
227
|
+
}, nt = /^[0-9a-f]{64}$/, rt = (e, t, { domain: r }) => {
|
|
228
|
+
if (!((typeof t == "string" || t instanceof Uint8Array) && t.length > 0)) throw new n("The HMAC secret must be a non-empty string or byte array.", { code: l.INVALID_HMAC_SECRET });
|
|
229
|
+
if (r !== void 0 && (typeof r != "string" || r.length === 0)) throw new n("The HMAC domain must be a non-empty string when it's given.", { code: l.INVALID_HMAC_DOMAIN });
|
|
230
|
+
let i = r === void 0 ? t : Pe("sha256", t).update(r).digest();
|
|
231
|
+
return Pe("sha256", i).update(e).digest();
|
|
232
|
+
}, it = (e, t, n = {}) => rt(e, t, n).toString("hex"), at = (e, t, n, r = {}) => {
|
|
233
|
+
let i = rt(e, n, r);
|
|
234
|
+
return typeof t != "string" || !nt.test(t) ? !1 : Ie(Buffer.from(t, "hex"), i);
|
|
235
|
+
}, ot = (e, t = []) => {
|
|
236
|
+
let n = [e], r = new Set(), i = new Set(t.filter((e) => e.length > 0));
|
|
237
|
+
for (; n.length > 0;) {
|
|
238
|
+
let e = n.pop();
|
|
239
|
+
if (typeof e == "string") {
|
|
240
|
+
if (i.has(e)) throw TypeError("A non-content CLI result contains canonical document text.");
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
if (typeof e != "object" || !e || r.has(e)) continue;
|
|
244
|
+
if (r.add(e), Array.isArray(e)) {
|
|
245
|
+
for (let t of e) n.push(t);
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
let t = e;
|
|
249
|
+
if (Object.hasOwn(t, "content")) throw TypeError("A non-content CLI result contains a content property.");
|
|
250
|
+
n.push(...Object.values(t));
|
|
251
|
+
}
|
|
252
|
+
}, st = 262144, ct = [
|
|
253
|
+
239,
|
|
254
|
+
187,
|
|
255
|
+
191
|
|
256
|
+
], lt = (e) => {
|
|
257
|
+
if (e.byteLength === 0 || e.byteLength > 262144 || ct.every((t, n) => e[n] === t)) return null;
|
|
258
|
+
let t;
|
|
259
|
+
try {
|
|
260
|
+
t = new TextDecoder("utf-8", {
|
|
261
|
+
fatal: !0,
|
|
262
|
+
ignoreBOM: !0
|
|
263
|
+
}).decode(e);
|
|
264
|
+
} catch {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
return t.includes("\0") || !t.isWellFormed() ? null : t;
|
|
268
|
+
}, ut = (e) => {
|
|
269
|
+
let t = lt(e);
|
|
270
|
+
if (t === null || !t.endsWith("\n")) return null;
|
|
271
|
+
let n = O.platform === "win32" && t.endsWith("\r\n") ? t.slice(0, -2) : t.slice(0, -1);
|
|
272
|
+
return n.length === 0 ? null : n;
|
|
273
|
+
}, dt = (e) => {
|
|
274
|
+
let t = ut(e);
|
|
275
|
+
return t === null || !D.isAbsolute(t) ? null : t;
|
|
276
|
+
}, ft = (e) => {
|
|
277
|
+
let t = e?.code?.toUpperCase();
|
|
278
|
+
return Object.freeze(t === "ENOENT" || t === "ENOTDIR" ? {
|
|
279
|
+
errorCode: "GIT_REPOSITORY_NOT_FOUND",
|
|
280
|
+
kind: "failed"
|
|
281
|
+
} : t === "EACCES" || t === "EPERM" ? {
|
|
282
|
+
errorCode: "GIT_ACCESS_DENIED",
|
|
283
|
+
kind: "failed"
|
|
284
|
+
} : {
|
|
285
|
+
errorCode: "GIT_COMMAND_FAILED",
|
|
286
|
+
kind: "failed"
|
|
287
|
+
});
|
|
288
|
+
}, pt = ((e = He) => async (t) => {
|
|
289
|
+
if (!D.isAbsolute(t.invocationDirectory) || t.invocationDirectory.includes("\0") || !t.invocationDirectory.isWellFormed() || t.repositoryDirectory !== null && !p(t.repositoryDirectory)) return Object.freeze({
|
|
290
|
+
errorCode: "GIT_REPOSITORY_NOT_FOUND",
|
|
291
|
+
kind: "failed"
|
|
292
|
+
});
|
|
293
|
+
let n = t.repositoryDirectory === null ? t.invocationDirectory : D.isAbsolute(t.repositoryDirectory) ? t.repositoryDirectory : D.resolve(t.invocationDirectory, t.repositoryDirectory);
|
|
294
|
+
try {
|
|
295
|
+
if (!(await e(n)).isDirectory()) return Object.freeze({
|
|
296
|
+
errorCode: "GIT_REPOSITORY_NOT_FOUND",
|
|
297
|
+
kind: "failed"
|
|
298
|
+
});
|
|
299
|
+
} catch (e) {
|
|
300
|
+
return ft(e);
|
|
301
|
+
}
|
|
302
|
+
return Object.freeze({
|
|
303
|
+
directory: n,
|
|
304
|
+
kind: "found"
|
|
305
|
+
});
|
|
306
|
+
})(), mt = async (e, { cwd: t, input: n, maxOutputBytes: r, signal: i }) => {
|
|
307
|
+
let a = e[0], o = await C(() => ue(e, {
|
|
308
|
+
cwd: t,
|
|
309
|
+
encoding: "buffer",
|
|
310
|
+
maxOutputBytes: r,
|
|
311
|
+
timeoutSeconds: 300,
|
|
312
|
+
...n === void 0 ? {} : { input: n },
|
|
313
|
+
...i === void 0 ? {} : { signal: i }
|
|
314
|
+
}), i, a);
|
|
315
|
+
if (o.kind === "failed") return o;
|
|
316
|
+
let s = oe(o.value, a ?? "");
|
|
317
|
+
return s === null ? Object.freeze({
|
|
318
|
+
kind: "completed",
|
|
319
|
+
value: o.value.stdout
|
|
320
|
+
}) : pe(s, a);
|
|
321
|
+
}, ht = Object.freeze({
|
|
322
|
+
readConfigBoolean: ce,
|
|
323
|
+
readTopLevel: me
|
|
324
|
+
}), gt = (e) => {
|
|
325
|
+
switch (e) {
|
|
326
|
+
case "aborted": return "GIT_OPERATION_ABORTED";
|
|
327
|
+
case "not-found": return "GIT_NOT_FOUND";
|
|
328
|
+
case "repository-not-found": return "GIT_REPOSITORY_NOT_FOUND";
|
|
329
|
+
case "access-denied": return "GIT_ACCESS_DENIED";
|
|
330
|
+
case "output-limit-exceeded":
|
|
331
|
+
case "output-invalid": return "GIT_OUTPUT_INVALID";
|
|
332
|
+
case "command-failed": return "GIT_COMMAND_FAILED";
|
|
333
|
+
}
|
|
334
|
+
}, j = (e) => Object.freeze({
|
|
335
|
+
errorCode: e,
|
|
336
|
+
kind: "failed"
|
|
337
|
+
}), _t = ((e = ht, t = pt, n = _e()) => async (r) => {
|
|
338
|
+
let i = await t(r);
|
|
339
|
+
if (i.kind === "failed") return j(i.errorCode);
|
|
340
|
+
let a = {
|
|
341
|
+
maxOutputBytes: st,
|
|
342
|
+
timeoutSeconds: 300,
|
|
343
|
+
...r.signal === void 0 ? {} : { signal: r.signal }
|
|
344
|
+
}, o = await C(() => e.readTopLevel(i.directory, a), r.signal);
|
|
345
|
+
if (o.kind === "failed") return j(gt(o.reason));
|
|
346
|
+
if (o.value === null) return j("GIT_WORK_TREE_REQUIRED");
|
|
347
|
+
let s = o.value;
|
|
348
|
+
if (!D.isAbsolute(s)) return j("GIT_OUTPUT_INVALID");
|
|
349
|
+
let c = await t({
|
|
350
|
+
invocationDirectory: i.directory,
|
|
351
|
+
repositoryDirectory: s
|
|
352
|
+
});
|
|
353
|
+
if (c.kind === "failed") return j(c.errorCode);
|
|
354
|
+
let l = await n(c.directory, r.signal);
|
|
355
|
+
if (l.kind === "failed") return j(l.errorCode);
|
|
356
|
+
let u = await C(() => e.readConfigBoolean(c.directory, "core.sparseCheckout", !1, a), r.signal);
|
|
357
|
+
return u.kind === "failed" ? j(gt(u.reason)) : u.value ? j("GIT_SPARSE_CHECKOUT_UNSUPPORTED") : Object.freeze({
|
|
358
|
+
kind: "discovered",
|
|
359
|
+
repositoryRoot: s
|
|
360
|
+
});
|
|
361
|
+
})(), vt = (e, t, n = D) => n.relative(n.resolve(e), n.resolve(t)) === "", yt = (e, t) => e.ino !== 0n && e.dev === t.dev && e.ino === t.ino, bt = (e, t) => yt(e, t), xt = (e, t) => bt(e.repositoryRoot, t.repositoryRoot) && bt(e.gitDirectory, t.gitDirectory) && bt(e.commonDirectory, t.commonDirectory), St = Object.freeze({
|
|
362
|
+
CommonDirectory: Object.freeze(["rev-parse", "--git-common-dir"]),
|
|
363
|
+
GitDirectory: Object.freeze(["rev-parse", "--absolute-git-dir"]),
|
|
364
|
+
RepositoryRoot: Object.freeze(["rev-parse", "--show-toplevel"])
|
|
365
|
+
}), Ct = async (e) => He(e, { bigint: !0 }), M = (e) => Object.freeze({
|
|
366
|
+
errorCode: e,
|
|
367
|
+
kind: "failed"
|
|
368
|
+
}), wt = (e) => {
|
|
369
|
+
switch (e) {
|
|
370
|
+
case "aborted": return "GIT_OPERATION_ABORTED";
|
|
371
|
+
case "not-found": return "GIT_NOT_FOUND";
|
|
372
|
+
case "repository-not-found": return "GIT_REPOSITORY_NOT_FOUND";
|
|
373
|
+
case "access-denied": return "GIT_ACCESS_DENIED";
|
|
374
|
+
case "output-limit-exceeded":
|
|
375
|
+
case "output-invalid": return "GIT_OUTPUT_INVALID";
|
|
376
|
+
case "command-failed": return "GIT_COMMAND_FAILED";
|
|
377
|
+
}
|
|
378
|
+
}, Tt = (e) => {
|
|
379
|
+
let t;
|
|
380
|
+
try {
|
|
381
|
+
if (typeof e == "object" && e && "code" in e) {
|
|
382
|
+
let n = e.code;
|
|
383
|
+
t = typeof n == "string" ? n.toUpperCase() : void 0;
|
|
384
|
+
}
|
|
385
|
+
} catch {
|
|
386
|
+
return "GIT_COMMAND_FAILED";
|
|
387
|
+
}
|
|
388
|
+
return t === "ENOENT" || t === "ENOTDIR" ? "GIT_REPOSITORY_NOT_FOUND" : t === "EACCES" || t === "EPERM" ? "GIT_ACCESS_DENIED" : "GIT_COMMAND_FAILED";
|
|
389
|
+
}, Et = async (e, t, n, r, i) => {
|
|
390
|
+
let a = await e(n, {
|
|
391
|
+
cwd: t,
|
|
392
|
+
maxOutputBytes: st,
|
|
393
|
+
...i === void 0 ? {} : { signal: i }
|
|
394
|
+
});
|
|
395
|
+
return a.kind === "failed" ? M(wt(a.reason)) : (r ? dt(a.value) : ut(a.value)) ?? M("GIT_OUTPUT_INVALID");
|
|
396
|
+
}, Dt = async (e, t, n) => {
|
|
397
|
+
try {
|
|
398
|
+
let r = await e(t);
|
|
399
|
+
return !r.isDirectory() || r.ino === 0n ? M(n) : Object.freeze({
|
|
400
|
+
dev: r.dev,
|
|
401
|
+
ino: r.ino,
|
|
402
|
+
path: t
|
|
403
|
+
});
|
|
404
|
+
} catch (e) {
|
|
405
|
+
return M(Tt(e));
|
|
406
|
+
}
|
|
407
|
+
}, N = (e) => typeof e == "object" && "kind" in e && e.kind === "failed", Ot = ((e = mt, t = Ct) => async (n) => {
|
|
408
|
+
if (!D.isAbsolute(n.repositoryRoot) || n.repositoryRoot.includes("\0") || !n.repositoryRoot.isWellFormed()) return M("GIT_OUTPUT_INVALID");
|
|
409
|
+
let r = await Et(e, n.repositoryRoot, St.RepositoryRoot, !0, n.signal);
|
|
410
|
+
if (N(r)) return r;
|
|
411
|
+
let i = await Dt(t, r, "GIT_WORK_TREE_REQUIRED");
|
|
412
|
+
if (n.signal?.aborted) return M("GIT_OPERATION_ABORTED");
|
|
413
|
+
if (N(i)) return i;
|
|
414
|
+
if (!vt(r, n.repositoryRoot)) {
|
|
415
|
+
let e = await Dt(t, n.repositoryRoot, "GIT_WORK_TREE_REQUIRED");
|
|
416
|
+
if (n.signal?.aborted) return M("GIT_OPERATION_ABORTED");
|
|
417
|
+
if (N(e)) return e;
|
|
418
|
+
if (!yt(i, e)) return Object.freeze({ kind: "mismatched" });
|
|
419
|
+
}
|
|
420
|
+
let a = await Et(e, n.repositoryRoot, St.GitDirectory, !0, n.signal);
|
|
421
|
+
if (N(a)) return a;
|
|
422
|
+
let o = await Et(e, n.repositoryRoot, St.CommonDirectory, !1, n.signal);
|
|
423
|
+
if (N(o)) return o;
|
|
424
|
+
let s = D.isAbsolute(o) ? o : D.resolve(n.repositoryRoot, o), c = await Dt(t, a, "GIT_OUTPUT_INVALID");
|
|
425
|
+
if (n.signal?.aborted) return M("GIT_OPERATION_ABORTED");
|
|
426
|
+
if (N(c)) return c;
|
|
427
|
+
let l = await Dt(t, s, "GIT_OUTPUT_INVALID");
|
|
428
|
+
return n.signal?.aborted ? M("GIT_OPERATION_ABORTED") : N(l) ? l : Object.freeze({
|
|
429
|
+
identity: Object.freeze({
|
|
430
|
+
commonDirectory: l,
|
|
431
|
+
gitDirectory: c,
|
|
432
|
+
repositoryRoot: i
|
|
433
|
+
}),
|
|
434
|
+
kind: "inspected"
|
|
435
|
+
});
|
|
436
|
+
})(), kt = class extends Error {
|
|
437
|
+
code;
|
|
438
|
+
constructor(e) {
|
|
439
|
+
super(e), this.code = e, this.name = "MoldeaCliProjectContentException";
|
|
440
|
+
}
|
|
441
|
+
}, At = /^\/moldea\/context\/(?:[^/]+\/)*[^/]+\.md$/u, jt = /^\/moldea\/decisions\/[^/]+\.md$/u, Mt = /^\/moldea\/agents\/[^/]+\/(?:description|instruction)\.md$/u, Nt = (e) => /[?*[\]{}]/u.test(e) ? !1 : e === "/moldea/moldea.yaml" || e === "/moldea/project.md" || At.test(e) || jt.test(e) || Mt.test(e), Pt = (e) => {
|
|
442
|
+
let t;
|
|
443
|
+
try {
|
|
444
|
+
t = T(e);
|
|
445
|
+
} catch {
|
|
446
|
+
throw new kt("CONTENT_PATH_INVALID");
|
|
447
|
+
}
|
|
448
|
+
if (!Nt(t)) throw new kt("CONTENT_PATH_INVALID");
|
|
449
|
+
return t;
|
|
450
|
+
}, Ft = ((e = we) => async (t) => e({ limits: Object.freeze({
|
|
451
|
+
maxDiagnostics: t.resourceLimits.maxDiagnostics,
|
|
452
|
+
maxEntries: t.resourceLimits.maxEntries,
|
|
453
|
+
maxCoverage: t.resourceLimits.maxCoverage,
|
|
454
|
+
maxFileBytes: t.resourceLimits.maxFileBytes,
|
|
455
|
+
maxManifestBytes: t.resourceLimits.maxManifestBytes,
|
|
456
|
+
maxTotalBytesRead: t.resourceLimits.maxTotalBytes
|
|
457
|
+
}) }).readCanonicalContentPage({
|
|
458
|
+
maxBytes: t.maxBytes,
|
|
459
|
+
offset: t.offset,
|
|
460
|
+
path: t.path,
|
|
461
|
+
repository: t.repository,
|
|
462
|
+
...t.signal === void 0 ? {} : { signal: t.signal }
|
|
463
|
+
}))(), It = (e, t, n, r) => {
|
|
464
|
+
let i = t.slice(0, n).join(""), a = e.page.byteStart + Buffer.byteLength(i, "utf8"), o = a === e.page.totalBytes;
|
|
465
|
+
return {
|
|
466
|
+
asset: {
|
|
467
|
+
contentIdentity: e.page.contentIdentity,
|
|
468
|
+
path: e.page.path,
|
|
469
|
+
totalBytes: e.page.totalBytes
|
|
470
|
+
},
|
|
471
|
+
chunk: {
|
|
472
|
+
byteEnd: a,
|
|
473
|
+
byteStart: e.page.byteStart,
|
|
474
|
+
content: i
|
|
475
|
+
},
|
|
476
|
+
cursor: o ? null : Se("content", { path: e.page.path }, r, `byte:${a}`, `byte:${a}`),
|
|
477
|
+
snapshotDigest: r
|
|
478
|
+
};
|
|
479
|
+
}, Lt = (e) => g({
|
|
480
|
+
contentIdentity: e.page.contentIdentity,
|
|
481
|
+
path: e.page.path,
|
|
482
|
+
totalBytes: e.page.totalBytes
|
|
483
|
+
}), Rt = (e) => {
|
|
484
|
+
let t = Lt(e), n = e.cursor === null ? null : b({
|
|
485
|
+
command: "content",
|
|
486
|
+
cursor: e.cursor,
|
|
487
|
+
filters: { path: e.page.path },
|
|
488
|
+
snapshotDigest: t
|
|
489
|
+
}), r = `byte:${e.page.byteStart}`;
|
|
490
|
+
if (n === null && e.page.byteStart !== 0 || n !== null && n.sourceCursor !== r) throw new S("CURSOR_INVALID");
|
|
491
|
+
let i = Array.from(e.page.content), a = It(e, i, 0, t);
|
|
492
|
+
if (i.length === 0) {
|
|
493
|
+
if (!e.page.isComplete || e.measure(a) > e.maxOutputBytes) throw new S("OUTPUT_BUDGET_TOO_SMALL");
|
|
494
|
+
return Object.freeze({
|
|
495
|
+
...a,
|
|
496
|
+
asset: Object.freeze(a.asset),
|
|
497
|
+
chunk: Object.freeze(a.chunk)
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
let o = 1, s = i.length, c = null;
|
|
501
|
+
for (; o <= s;) {
|
|
502
|
+
let n = o + Math.floor((s - o) / 2), r = It(e, i, n, t);
|
|
503
|
+
e.measure(r) <= e.maxOutputBytes ? (c = r, o = n + 1) : s = n - 1;
|
|
504
|
+
}
|
|
505
|
+
if (c === null) throw new S("OUTPUT_BUDGET_TOO_SMALL");
|
|
506
|
+
return Object.freeze({
|
|
507
|
+
...c,
|
|
508
|
+
asset: Object.freeze(c.asset),
|
|
509
|
+
chunk: Object.freeze(c.chunk)
|
|
510
|
+
});
|
|
511
|
+
}, P = T("/moldea/moldea.yaml"), zt = class extends Error {
|
|
512
|
+
code;
|
|
513
|
+
constructor(e) {
|
|
514
|
+
super(e), this.code = e, this.name = "MoldeaCliProjectScopeException";
|
|
515
|
+
}
|
|
516
|
+
}, Bt = (e, t) => {
|
|
517
|
+
if (e.byteLength === 0) return Object.freeze([]);
|
|
518
|
+
let n;
|
|
519
|
+
try {
|
|
520
|
+
n = new TextDecoder("utf-8", { fatal: !0 }).decode(e);
|
|
521
|
+
} catch {
|
|
522
|
+
throw new zt("PATH_INPUT_INVALID");
|
|
523
|
+
}
|
|
524
|
+
if (!n.endsWith("\0")) throw new zt("PATH_INPUT_INVALID");
|
|
525
|
+
let r = n.slice(0, -1).split("\0");
|
|
526
|
+
if (r.length > t || r.some((e) => e.length === 0)) throw new zt("PATH_INPUT_INVALID");
|
|
527
|
+
return Object.freeze(r);
|
|
528
|
+
}, Vt = async (e) => {
|
|
529
|
+
let t = e.signal === void 0 ? void 0 : { signal: e.signal }, n = await e.repository.getEntry(P, t);
|
|
530
|
+
if (n === null) throw new w({
|
|
531
|
+
code: "ENTRY_NOT_FOUND",
|
|
532
|
+
operation: "read-file-page",
|
|
533
|
+
path: P,
|
|
534
|
+
retryable: !1
|
|
535
|
+
});
|
|
536
|
+
if (n.type !== "file" || n.byteLength === null) throw new w({
|
|
537
|
+
code: "ENTRY_NOT_FILE",
|
|
538
|
+
operation: "read-file-page",
|
|
539
|
+
path: P,
|
|
540
|
+
retryable: !1
|
|
541
|
+
});
|
|
542
|
+
let r = Math.min(e.resourceLimits.maxManifestBytes, e.resourceLimits.maxTotalBytes);
|
|
543
|
+
if (n.byteLength > r) throw new w({
|
|
544
|
+
code: "RESOURCE_LIMIT_EXCEEDED",
|
|
545
|
+
operation: "read-file-page",
|
|
546
|
+
path: P,
|
|
547
|
+
retryable: !1
|
|
548
|
+
});
|
|
549
|
+
let i = [], a = 0, o = 0, s = !1;
|
|
550
|
+
for (; !s;) {
|
|
551
|
+
let t = await e.repository.readFilePage(P, {
|
|
552
|
+
maxBytes: Math.max(1, n.byteLength - a),
|
|
553
|
+
offset: o,
|
|
554
|
+
...e.signal === void 0 ? {} : { signal: e.signal }
|
|
555
|
+
});
|
|
556
|
+
if (t.snapshot.id !== e.repository.snapshot.id || t.offset !== o || t.totalBytes !== n.byteLength || t.bytes.byteLength > n.byteLength - a || t.bytes.byteLength === 0 && !t.isComplete || !t.isComplete && t.nextOffset !== t.offset + t.bytes.byteLength) throw new w({
|
|
557
|
+
code: "INVALID_SOURCE_DATA",
|
|
558
|
+
operation: "read-file-page",
|
|
559
|
+
path: P,
|
|
560
|
+
retryable: !1
|
|
561
|
+
});
|
|
562
|
+
i.push(t.bytes), a += t.bytes.byteLength, o = t.nextOffset ?? a, s = t.isComplete;
|
|
563
|
+
}
|
|
564
|
+
if (a !== n.byteLength) throw new w({
|
|
565
|
+
code: "PROVIDER_INCOMPLETE",
|
|
566
|
+
operation: "read-file-page",
|
|
567
|
+
path: P,
|
|
568
|
+
retryable: !1
|
|
569
|
+
});
|
|
570
|
+
let c = new Uint8Array(a), l = 0;
|
|
571
|
+
for (let e of i) c.set(e, l), l += e.byteLength;
|
|
572
|
+
return c;
|
|
573
|
+
}, Ht = ((e = we) => async (t) => {
|
|
574
|
+
let n = await Vt(t), r = await e({ limits: Object.freeze({
|
|
575
|
+
maxDiagnostics: t.resourceLimits.maxDiagnostics,
|
|
576
|
+
maxEntries: t.resourceLimits.maxEntries,
|
|
577
|
+
maxCoverage: t.resourceLimits.maxCoverage,
|
|
578
|
+
maxFileBytes: t.resourceLimits.maxFileBytes,
|
|
579
|
+
maxManifestBytes: t.resourceLimits.maxManifestBytes,
|
|
580
|
+
maxTotalBytesRead: t.resourceLimits.maxTotalBytes
|
|
581
|
+
}) }).matchManifestScope({
|
|
582
|
+
manifest: {
|
|
583
|
+
content: n,
|
|
584
|
+
path: P
|
|
585
|
+
},
|
|
586
|
+
paths: t.paths
|
|
587
|
+
});
|
|
588
|
+
return Object.freeze({
|
|
589
|
+
manifestContent: new TextDecoder("utf-8").decode(n),
|
|
590
|
+
scope: r
|
|
591
|
+
});
|
|
592
|
+
})(), Ut = (e, t) => e.key < t.key ? -1 : +(e.key > t.key), Wt = (e) => JSON.stringify([
|
|
593
|
+
"match",
|
|
594
|
+
e.owner.kind,
|
|
595
|
+
e.owner.agentId,
|
|
596
|
+
e.owner.id,
|
|
597
|
+
e.field,
|
|
598
|
+
e.declaration.kind === "exact" ? e.declaration.path : e.declaration.pattern,
|
|
599
|
+
e.inputPath,
|
|
600
|
+
e.pointer
|
|
601
|
+
]), Gt = (e) => {
|
|
602
|
+
let t = [...e.scope.diagnostics.map((e, t) => le(e, t)), ...e.scope.matches.map((e) => ({
|
|
603
|
+
key: Wt(e),
|
|
604
|
+
kind: "match",
|
|
605
|
+
match: e
|
|
606
|
+
}))].sort(Ut), n = g({
|
|
607
|
+
inputDigest: e.scope.inputDigest,
|
|
608
|
+
manifestDigest: e.scope.manifestDigest,
|
|
609
|
+
records: t,
|
|
610
|
+
valid: e.scope.valid
|
|
611
|
+
});
|
|
612
|
+
return Object.freeze({
|
|
613
|
+
canonicalBodies: Object.freeze([e.manifestContent]),
|
|
614
|
+
counts: Object.freeze({
|
|
615
|
+
...e.scope.counts,
|
|
616
|
+
diagnostics: e.scope.diagnostics.length
|
|
617
|
+
}),
|
|
618
|
+
inputDigest: e.scope.inputDigest,
|
|
619
|
+
manifestDigest: e.scope.manifestDigest,
|
|
620
|
+
records: Object.freeze(t),
|
|
621
|
+
relevant: e.scope.relevant,
|
|
622
|
+
snapshotDigest: n,
|
|
623
|
+
valid: e.scope.valid
|
|
624
|
+
});
|
|
625
|
+
}, Kt = class extends w {
|
|
626
|
+
constructor(e) {
|
|
627
|
+
super({
|
|
628
|
+
code: "SOURCE_UNAVAILABLE",
|
|
629
|
+
operation: "read-file-page",
|
|
630
|
+
path: e,
|
|
631
|
+
retryable: !1
|
|
632
|
+
}), this.name = "GitContentTransformUnsupportedException";
|
|
633
|
+
}
|
|
634
|
+
}, qt = (e, t) => {
|
|
635
|
+
if (e?.aborted) throw new w({
|
|
636
|
+
cause: e.reason,
|
|
637
|
+
code: "ABORTED",
|
|
638
|
+
operation: "read-file-page",
|
|
639
|
+
path: t,
|
|
640
|
+
retryable: !1
|
|
641
|
+
});
|
|
642
|
+
}, Jt = (e) => new w({
|
|
643
|
+
code: "INVALID_SOURCE_DATA",
|
|
644
|
+
operation: "read-file-page",
|
|
645
|
+
path: e,
|
|
646
|
+
retryable: !1
|
|
647
|
+
}), Yt = class {
|
|
648
|
+
snapshot;
|
|
649
|
+
#e;
|
|
650
|
+
#t;
|
|
651
|
+
constructor(e, t) {
|
|
652
|
+
this.#t = e, this.#e = t, this.snapshot = e.snapshot;
|
|
653
|
+
}
|
|
654
|
+
compare(e, t) {
|
|
655
|
+
return De(this, e, t);
|
|
656
|
+
}
|
|
657
|
+
getEntry(e, t) {
|
|
658
|
+
return this.#t.getEntry(e, t);
|
|
659
|
+
}
|
|
660
|
+
async readFilePage(e, t) {
|
|
661
|
+
let n = T(e);
|
|
662
|
+
if (!this.#e.has(n)) return this.#t.readFilePage(n, t);
|
|
663
|
+
qt(t?.signal, n);
|
|
664
|
+
let r = await this.#t.getEntry(n, t);
|
|
665
|
+
if (qt(t?.signal, n), r !== null && (r.path !== n || r.type !== "file" && r.type !== "directory" && r.type !== "symlink")) throw Jt(n);
|
|
666
|
+
if (r?.type !== "file") return this.#t.readFilePage(n, t);
|
|
667
|
+
throw new Kt(n);
|
|
668
|
+
}
|
|
669
|
+
readLinkText(e, t) {
|
|
670
|
+
return this.#t.readLinkText(e, t);
|
|
671
|
+
}
|
|
672
|
+
listEntriesPage(e) {
|
|
673
|
+
return this.#t.listEntriesPage(e);
|
|
674
|
+
}
|
|
675
|
+
}, Xt = (e, t) => {
|
|
676
|
+
let n = new Set();
|
|
677
|
+
for (let e of t) {
|
|
678
|
+
let t = T(e);
|
|
679
|
+
if (t === E) throw new w({
|
|
680
|
+
code: "INVALID_SOURCE_DATA",
|
|
681
|
+
operation: "create-reader",
|
|
682
|
+
path: t,
|
|
683
|
+
retryable: !1
|
|
684
|
+
});
|
|
685
|
+
n.add(t);
|
|
686
|
+
}
|
|
687
|
+
return Object.freeze(new Yt(e, n));
|
|
688
|
+
}, Zt = Object.freeze({
|
|
689
|
+
ABORTED: "The repository operation was aborted.",
|
|
690
|
+
ACCESS_DENIED: "Access to the repository source was denied.",
|
|
691
|
+
ENTRY_NOT_DIRECTORY: "The requested repository entry is not a directory.",
|
|
692
|
+
ENTRY_NOT_FILE: "The requested repository entry is not a file.",
|
|
693
|
+
ENTRY_NOT_FOUND: "The requested repository entry was not found.",
|
|
694
|
+
ENTRY_NOT_LINK: "The requested repository entry is not a symlink.",
|
|
695
|
+
INVALID_PAGE_REQUEST: "The repository page request is invalid.",
|
|
696
|
+
INVALID_SOURCE_DATA: "The repository source returned invalid data.",
|
|
697
|
+
PROVIDER_INCOMPLETE: "The repository provider could not expose a complete result.",
|
|
698
|
+
RESOURCE_LIMIT_EXCEEDED: "A repository reading resource limit was exceeded.",
|
|
699
|
+
SNAPSHOT_CHANGED: "The repository snapshot changed during the operation.",
|
|
700
|
+
SOURCE_UNAVAILABLE: "The repository source is unavailable."
|
|
701
|
+
}), Qt = Object.freeze({ INVALID_RESOURCE_LIMIT: "A Core resource limit is invalid." }), $t = Object.freeze({
|
|
702
|
+
ABORTED: "The Core operation was aborted.",
|
|
703
|
+
CONTENT_INVALID: "The requested canonical content is invalid.",
|
|
704
|
+
INVALID_ARGUMENT: "The Core operation received an invalid argument.",
|
|
705
|
+
INSPECTION_BUSY: "Project inspection capacity is busy. Try again shortly.",
|
|
706
|
+
INSPECTION_TIMEOUT: "The isolated project inspection timed out.",
|
|
707
|
+
INSPECTION_PROCESS_FAILED: "The isolated project inspection failed.",
|
|
708
|
+
RESOURCE_LIMIT_EXCEEDED: "A Core resource limit was exceeded."
|
|
709
|
+
}), en = Object.freeze({}), tn = (e) => {
|
|
710
|
+
let t = { operation: e.operation };
|
|
711
|
+
return e instanceof a && (e.limit !== null && (t.limit = e.limit), e.limitMaximum !== null && (t.limitMaximum = e.limitMaximum), e.nextAction !== null && (t.nextAction = e.nextAction), (e.observedUsage !== null || e.nextAction === "review-inspection-capacity") && (t.observedUsage = e.observedUsage)), Object.freeze(t);
|
|
712
|
+
}, nn = (e) => e instanceof he || e instanceof S || e instanceof kt || e instanceof zt ? _(e.code) : e instanceof Kt ? Object.freeze({
|
|
713
|
+
..._("GIT_CONTENT_TRANSFORM_UNSUPPORTED"),
|
|
714
|
+
path: Ee(e.path) ? e.path : null
|
|
715
|
+
}) : e instanceof w ? Object.freeze({
|
|
716
|
+
code: e.code,
|
|
717
|
+
details: en,
|
|
718
|
+
message: Zt[e.code],
|
|
719
|
+
path: e.path !== null && Ee(e.path) ? e.path : null,
|
|
720
|
+
retryable: e.retryable,
|
|
721
|
+
source: "repository"
|
|
722
|
+
}) : e instanceof o ? Object.freeze({
|
|
723
|
+
code: e.code,
|
|
724
|
+
details: tn(e),
|
|
725
|
+
message: Qt[e.code],
|
|
726
|
+
path: null,
|
|
727
|
+
retryable: !1,
|
|
728
|
+
source: "core"
|
|
729
|
+
}) : e instanceof a ? Object.freeze({
|
|
730
|
+
code: e.code,
|
|
731
|
+
details: tn(e),
|
|
732
|
+
message: $t[e.code],
|
|
733
|
+
path: null,
|
|
734
|
+
retryable: e.retryable,
|
|
735
|
+
source: "core"
|
|
736
|
+
}) : _("INTERNAL_ERROR"), rn = [
|
|
737
|
+
"ls-files",
|
|
738
|
+
"--others",
|
|
739
|
+
"--ignored",
|
|
740
|
+
"--exclude-standard",
|
|
741
|
+
"--full-name",
|
|
742
|
+
"--no-recurse-submodules",
|
|
743
|
+
"-z",
|
|
744
|
+
"--"
|
|
745
|
+
], an = "ls-files", on = Object.freeze([
|
|
746
|
+
"/AGENTS.md",
|
|
747
|
+
"/CLAUDE.md",
|
|
748
|
+
"/.claude/CLAUDE.md",
|
|
749
|
+
"/CLAUDE.local.md"
|
|
750
|
+
].map((e) => T(e))), sn = [
|
|
751
|
+
"100644",
|
|
752
|
+
"100755",
|
|
753
|
+
"120000",
|
|
754
|
+
"160000"
|
|
755
|
+
], cn = [
|
|
756
|
+
"filter",
|
|
757
|
+
"working-tree-encoding",
|
|
758
|
+
"ident"
|
|
759
|
+
], ln = [
|
|
760
|
+
"check-attr",
|
|
761
|
+
"--stdin",
|
|
762
|
+
"-z",
|
|
763
|
+
...cn
|
|
764
|
+
], un = (e, t) => {
|
|
765
|
+
let n = new Uint8Array(t), r = 0;
|
|
766
|
+
for (let t of e) n.set(t, r), r += t.byteLength;
|
|
767
|
+
return n;
|
|
768
|
+
}, dn = (e) => {
|
|
769
|
+
try {
|
|
770
|
+
return new TextDecoder("utf-8", {
|
|
771
|
+
fatal: !0,
|
|
772
|
+
ignoreBOM: !0
|
|
773
|
+
}).decode(e);
|
|
774
|
+
} catch {
|
|
775
|
+
return null;
|
|
776
|
+
}
|
|
777
|
+
}, fn = (e) => cn.find((t) => t === e) ?? null, pn = (e, t, n) => {
|
|
778
|
+
let r = t === "working-tree-encoding" ? "workingTreeEncoding" : t;
|
|
779
|
+
return !Object.hasOwn(e, r) && (e[r] = n, !0);
|
|
780
|
+
}, mn = (e) => Object.hasOwn(e, "filter") && Object.hasOwn(e, "ident") && Object.hasOwn(e, "workingTreeEncoding"), hn = (e) => {
|
|
781
|
+
let t = [...e.paths], n = new Map(), r = [], i = !1, a = 0, o = [];
|
|
782
|
+
for (let e of t) {
|
|
783
|
+
if (e.length === 0 || e.includes("\0") || n.has(e)) {
|
|
784
|
+
i = !0;
|
|
785
|
+
continue;
|
|
786
|
+
}
|
|
787
|
+
n.set(e, {});
|
|
788
|
+
}
|
|
789
|
+
let s = () => {
|
|
790
|
+
if (i || r.length !== 3) return;
|
|
791
|
+
let e = dn(r[0] ?? new Uint8Array()), t = dn(r[1] ?? new Uint8Array()), a = dn(r[2] ?? new Uint8Array());
|
|
792
|
+
if (r = [], e === null || t === null || a === null) {
|
|
793
|
+
i = !0;
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
let o = fn(t), s = n.get(e);
|
|
797
|
+
(o === null || s === void 0 || !pn(s, o, a)) && (i = !0);
|
|
798
|
+
}, c = () => {
|
|
799
|
+
i || (r.push(un(o, a)), a = 0, o = [], r.length === 3 && s());
|
|
800
|
+
};
|
|
801
|
+
return {
|
|
802
|
+
consume: (e) => {
|
|
803
|
+
if (i) return;
|
|
804
|
+
let t = 0;
|
|
805
|
+
for (let n = 0; n < e.byteLength; n += 1) {
|
|
806
|
+
if (e[n] !== 0) continue;
|
|
807
|
+
let r = e.subarray(t, n);
|
|
808
|
+
if (o.push(Uint8Array.from(r)), a += r.byteLength, c(), i) return;
|
|
809
|
+
t = n + 1;
|
|
810
|
+
}
|
|
811
|
+
let n = e.subarray(t);
|
|
812
|
+
n.byteLength > 0 && (o.push(Uint8Array.from(n)), a += n.byteLength);
|
|
813
|
+
},
|
|
814
|
+
finish: () => {
|
|
815
|
+
if (i || a > 0 || r.length > 0) return Object.freeze({ kind: "failed" });
|
|
816
|
+
let e = [];
|
|
817
|
+
for (let r of t) {
|
|
818
|
+
let t = n.get(r);
|
|
819
|
+
if (t === void 0 || !mn(t)) return Object.freeze({ kind: "failed" });
|
|
820
|
+
e.push(Object.freeze({
|
|
821
|
+
filter: t.filter,
|
|
822
|
+
ident: t.ident,
|
|
823
|
+
path: r,
|
|
824
|
+
workingTreeEncoding: t.workingTreeEncoding
|
|
825
|
+
}));
|
|
826
|
+
}
|
|
827
|
+
return Object.freeze({
|
|
828
|
+
attributes: Object.freeze(e),
|
|
829
|
+
kind: "completed"
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
}, F = (e, t) => Object.freeze({
|
|
834
|
+
errorCode: e,
|
|
835
|
+
kind: "failed",
|
|
836
|
+
...t === void 0 ? {} : { subcommand: t }
|
|
837
|
+
}), gn = (e) => {
|
|
838
|
+
switch (e) {
|
|
839
|
+
case "aborted": return "GIT_OPERATION_ABORTED";
|
|
840
|
+
case "not-found": return "GIT_NOT_FOUND";
|
|
841
|
+
case "access-denied": return "GIT_ACCESS_DENIED";
|
|
842
|
+
case "repository-not-found": return "GIT_REPOSITORY_NOT_FOUND";
|
|
843
|
+
case "output-limit-exceeded": return "RESOURCE_LIMIT_EXCEEDED";
|
|
844
|
+
case "output-invalid": return "GIT_OUTPUT_INVALID";
|
|
845
|
+
case "command-failed": return "GIT_COMMAND_FAILED";
|
|
846
|
+
}
|
|
847
|
+
}, _n = (e) => e !== "unset" && e !== "unspecified", vn = (e) => {
|
|
848
|
+
let t = new TextEncoder(), n = [], r = 0;
|
|
849
|
+
for (let i of e) {
|
|
850
|
+
if (i.length === 0 || i.includes("\0")) return null;
|
|
851
|
+
let e = t.encode(i);
|
|
852
|
+
if (!Number.isSafeInteger(r + e.byteLength + 1)) return null;
|
|
853
|
+
n.push(e), r += e.byteLength + 1;
|
|
854
|
+
}
|
|
855
|
+
let i = new Uint8Array(r), a = 0;
|
|
856
|
+
for (let e of n) i.set(e, a), a += e.byteLength + 1;
|
|
857
|
+
return i;
|
|
858
|
+
}, yn = (e, t, n) => Object.freeze({
|
|
859
|
+
filter: e,
|
|
860
|
+
ident: t,
|
|
861
|
+
isGuarded: _n(e) || _n(t) || _n(n),
|
|
862
|
+
workingTreeEncoding: n
|
|
863
|
+
}), bn = (e = mt) => async (t) => {
|
|
864
|
+
if (t.signal?.aborted) return F("GIT_OPERATION_ABORTED");
|
|
865
|
+
if (!Number.isSafeInteger(t.maxMetadataBytes) || t.maxMetadataBytes < 0) return F("RESOURCE_LIMIT_EXCEEDED");
|
|
866
|
+
if (t.entries.length === 0) return Object.freeze({
|
|
867
|
+
entries: Object.freeze([]),
|
|
868
|
+
gitMetadataBytes: 0,
|
|
869
|
+
kind: "classified"
|
|
870
|
+
});
|
|
871
|
+
let n = t.entries.map((e) => e.path), r = vn(n);
|
|
872
|
+
if (r === null) return F("GIT_OUTPUT_INVALID");
|
|
873
|
+
let i = await e(ln, {
|
|
874
|
+
cwd: t.repositoryRoot,
|
|
875
|
+
input: r,
|
|
876
|
+
maxOutputBytes: Math.max(t.maxMetadataBytes, 1),
|
|
877
|
+
...t.signal === void 0 ? {} : { signal: t.signal }
|
|
878
|
+
});
|
|
879
|
+
if (i.kind === "failed") return F(gn(i.reason), i.subcommand);
|
|
880
|
+
if (i.value.byteLength > t.maxMetadataBytes) return F("RESOURCE_LIMIT_EXCEEDED");
|
|
881
|
+
let a = hn({ paths: n });
|
|
882
|
+
a.consume(i.value);
|
|
883
|
+
let o = a.finish();
|
|
884
|
+
if (o.kind === "failed" || o.attributes.length !== t.entries.length) return F("GIT_OUTPUT_INVALID");
|
|
885
|
+
let s = t.entries.map((e, t) => {
|
|
886
|
+
let n = o.attributes[t];
|
|
887
|
+
return n === void 0 || n.path !== e.path ? null : Object.freeze({
|
|
888
|
+
...e,
|
|
889
|
+
contentTransformation: yn(n.filter, n.ident, n.workingTreeEncoding)
|
|
890
|
+
});
|
|
891
|
+
});
|
|
892
|
+
return s.some((e) => e === null) ? F("GIT_OUTPUT_INVALID") : Object.freeze({
|
|
893
|
+
entries: Object.freeze(s.filter((e) => e !== null)),
|
|
894
|
+
gitMetadataBytes: i.value.byteLength,
|
|
895
|
+
kind: "classified"
|
|
896
|
+
});
|
|
897
|
+
}, I = () => Object.freeze({ kind: "failed" }), xn = (e) => {
|
|
898
|
+
let t = new Map();
|
|
899
|
+
for (let n of e) {
|
|
900
|
+
let e = t.get(n.path);
|
|
901
|
+
if (n.kind === "untracked") {
|
|
902
|
+
if (e !== void 0) return I();
|
|
903
|
+
t.set(n.path, {
|
|
904
|
+
kind: "untracked",
|
|
905
|
+
path: n.path
|
|
906
|
+
});
|
|
907
|
+
continue;
|
|
908
|
+
}
|
|
909
|
+
if (n.mode === "160000" || e?.kind === "untracked") return I();
|
|
910
|
+
let r = e ?? {
|
|
911
|
+
indexEntriesByStage: new Map(),
|
|
912
|
+
kind: "tracked",
|
|
913
|
+
path: n.path
|
|
914
|
+
};
|
|
915
|
+
if (r.indexEntriesByStage.has(n.stage)) return I();
|
|
916
|
+
r.indexEntriesByStage.set(n.stage, Object.freeze({
|
|
917
|
+
mode: n.mode,
|
|
918
|
+
stage: n.stage
|
|
919
|
+
})), t.set(n.path, r);
|
|
920
|
+
}
|
|
921
|
+
let n = [];
|
|
922
|
+
for (let e of t.values()) {
|
|
923
|
+
if (e.kind === "untracked") {
|
|
924
|
+
n.push(Object.freeze(e));
|
|
925
|
+
continue;
|
|
926
|
+
}
|
|
927
|
+
if (e.indexEntriesByStage.has(0) && e.indexEntriesByStage.size !== 1) return I();
|
|
928
|
+
let t = [...e.indexEntriesByStage.values()].sort((e, t) => e.stage - t.stage);
|
|
929
|
+
if (t.length === 0) return I();
|
|
930
|
+
n.push(Object.freeze({
|
|
931
|
+
indexEntries: Object.freeze(t),
|
|
932
|
+
kind: "tracked",
|
|
933
|
+
path: e.path
|
|
934
|
+
}));
|
|
935
|
+
}
|
|
936
|
+
return Object.freeze({
|
|
937
|
+
candidates: Object.freeze(n),
|
|
938
|
+
kind: "collapsed"
|
|
939
|
+
});
|
|
940
|
+
}, Sn = (e) => Object.freeze({
|
|
941
|
+
errorCode: e,
|
|
942
|
+
kind: "failed"
|
|
943
|
+
}), Cn = (e) => {
|
|
944
|
+
let t = e?.code?.toUpperCase();
|
|
945
|
+
return t === "ENOENT" || t === "ENOTDIR" ? null : Sn(t === "EACCES" || t === "EPERM" ? "GIT_ACCESS_DENIED" : t === "ELOOP" ? "GIT_OUTPUT_INVALID" : "GIT_COMMAND_FAILED");
|
|
946
|
+
}, wn = async (e) => k(e), Tn = ((e = wn) => async (t, n) => {
|
|
947
|
+
let r;
|
|
948
|
+
try {
|
|
949
|
+
r = await e(D.join(t, n));
|
|
950
|
+
} catch (e) {
|
|
951
|
+
return Cn(e) ?? Object.freeze({ kind: "missing" });
|
|
952
|
+
}
|
|
953
|
+
return r.isSymbolicLink() ? Object.freeze({
|
|
954
|
+
entryType: "symlink",
|
|
955
|
+
kind: "inspected"
|
|
956
|
+
}) : r.isFile() ? Object.freeze({
|
|
957
|
+
entryType: "file",
|
|
958
|
+
kind: "inspected"
|
|
959
|
+
}) : Object.freeze({
|
|
960
|
+
entryType: "unsupported",
|
|
961
|
+
kind: "inspected"
|
|
962
|
+
});
|
|
963
|
+
})(), En = "config", Dn = (e, t) => Object.freeze({
|
|
964
|
+
errorCode: e,
|
|
965
|
+
kind: "failed",
|
|
966
|
+
...t === void 0 ? {} : { subcommand: t }
|
|
967
|
+
}), On = (e) => {
|
|
968
|
+
switch (e) {
|
|
969
|
+
case "aborted": return "GIT_OPERATION_ABORTED";
|
|
970
|
+
case "not-found": return "GIT_NOT_FOUND";
|
|
971
|
+
case "access-denied": return "GIT_ACCESS_DENIED";
|
|
972
|
+
case "output-limit-exceeded": return "RESOURCE_LIMIT_EXCEEDED";
|
|
973
|
+
case "repository-not-found":
|
|
974
|
+
case "output-invalid": return "GIT_OUTPUT_INVALID";
|
|
975
|
+
case "command-failed": return "GIT_COMMAND_FAILED";
|
|
976
|
+
}
|
|
977
|
+
}, kn = (e = ce) => async (t) => {
|
|
978
|
+
if (t.signal?.aborted) return Dn("GIT_OPERATION_ABORTED");
|
|
979
|
+
if (!Number.isSafeInteger(t.maxMetadataBytes) || t.maxMetadataBytes < 0) return Dn("RESOURCE_LIMIT_EXCEEDED");
|
|
980
|
+
let n = await C(() => e(t.repositoryRoot, "core.symlinks", !0, {
|
|
981
|
+
maxOutputBytes: Math.max(t.maxMetadataBytes, 1),
|
|
982
|
+
timeoutSeconds: 300,
|
|
983
|
+
...t.signal === void 0 ? {} : { signal: t.signal }
|
|
984
|
+
}), t.signal, En);
|
|
985
|
+
if (n.kind === "failed") return Dn(On(n.reason), n.subcommand);
|
|
986
|
+
let r = n.value ? 5 : 6;
|
|
987
|
+
return r > t.maxMetadataBytes ? Dn("RESOURCE_LIMIT_EXCEEDED") : Object.freeze({
|
|
988
|
+
gitMetadataBytes: r,
|
|
989
|
+
isEnabled: n.value,
|
|
990
|
+
kind: "resolved"
|
|
991
|
+
});
|
|
992
|
+
}, An = kn(), L = (e) => Object.freeze({
|
|
993
|
+
errorCode: e,
|
|
994
|
+
kind: "failed"
|
|
995
|
+
}), jn = (e) => e.indexEntries.some(({ mode: e }) => e === "120000"), Mn = (e) => e.indexEntries.some(({ mode: e }) => e === "100644" || e === "100755"), Nn = (e = Tn, t = An) => async (n) => {
|
|
996
|
+
if (n.signal?.aborted) return L("GIT_OPERATION_ABORTED");
|
|
997
|
+
if (!Number.isSafeInteger(n.maxMetadataBytes) || n.maxMetadataBytes < 0) return L("RESOURCE_LIMIT_EXCEEDED");
|
|
998
|
+
let r = xn(n.candidates);
|
|
999
|
+
if (r.kind === "failed") return L("GIT_OUTPUT_INVALID");
|
|
1000
|
+
let i = [], a = null;
|
|
1001
|
+
for (let o of r.candidates) {
|
|
1002
|
+
if (n.signal?.aborted) return L("GIT_OPERATION_ABORTED");
|
|
1003
|
+
let r = await e(n.repositoryRoot, o.path);
|
|
1004
|
+
if (n.signal?.aborted) return L("GIT_OPERATION_ABORTED");
|
|
1005
|
+
if (r.kind === "failed") return r;
|
|
1006
|
+
if (r.kind === "missing") continue;
|
|
1007
|
+
if (r.entryType === "unsupported") return L("GIT_OUTPUT_INVALID");
|
|
1008
|
+
if (o.kind === "untracked") {
|
|
1009
|
+
i.push(Object.freeze({
|
|
1010
|
+
entryType: r.entryType,
|
|
1011
|
+
kind: "untracked",
|
|
1012
|
+
path: o.path,
|
|
1013
|
+
requiresSymlinkOverlay: !1
|
|
1014
|
+
}));
|
|
1015
|
+
continue;
|
|
1016
|
+
}
|
|
1017
|
+
if (r.entryType === "symlink" || !jn(o)) {
|
|
1018
|
+
i.push(Object.freeze({
|
|
1019
|
+
entryType: r.entryType,
|
|
1020
|
+
indexEntries: o.indexEntries,
|
|
1021
|
+
kind: "tracked",
|
|
1022
|
+
path: o.path,
|
|
1023
|
+
requiresSymlinkOverlay: !1
|
|
1024
|
+
}));
|
|
1025
|
+
continue;
|
|
1026
|
+
}
|
|
1027
|
+
if (a ??= await t({
|
|
1028
|
+
maxMetadataBytes: n.maxMetadataBytes,
|
|
1029
|
+
repositoryRoot: n.repositoryRoot,
|
|
1030
|
+
...n.signal === void 0 ? {} : { signal: n.signal }
|
|
1031
|
+
}), a.kind === "failed") return a;
|
|
1032
|
+
if (!Number.isSafeInteger(a.gitMetadataBytes) || a.gitMetadataBytes < 0 || a.gitMetadataBytes > n.maxMetadataBytes || !a.isEnabled && Mn(o)) return L("GIT_OUTPUT_INVALID");
|
|
1033
|
+
let s = !a.isEnabled;
|
|
1034
|
+
i.push(Object.freeze({
|
|
1035
|
+
entryType: s ? "symlink" : "file",
|
|
1036
|
+
indexEntries: o.indexEntries,
|
|
1037
|
+
kind: "tracked",
|
|
1038
|
+
path: o.path,
|
|
1039
|
+
requiresSymlinkOverlay: s
|
|
1040
|
+
}));
|
|
1041
|
+
}
|
|
1042
|
+
return Object.freeze({
|
|
1043
|
+
entries: Object.freeze(i),
|
|
1044
|
+
gitMetadataBytes: a?.kind === "resolved" ? a.gitMetadataBytes : 0,
|
|
1045
|
+
kind: "normalized"
|
|
1046
|
+
});
|
|
1047
|
+
}, Pn = () => Object.freeze({
|
|
1048
|
+
errorCode: "GIT_OPERATION_ABORTED",
|
|
1049
|
+
kind: "failed"
|
|
1050
|
+
}), Fn = (e) => {
|
|
1051
|
+
let t = e.replace(/\/$/u, "").split("/");
|
|
1052
|
+
return t.slice(0, -1).map((e, n) => t.slice(0, n + 1).join("/"));
|
|
1053
|
+
}, In = (e, t) => Fn(e).some((e) => t.has(e)), Ln = ((e = Tn) => async (t) => {
|
|
1054
|
+
if (t.signal?.aborted) return Pn();
|
|
1055
|
+
let n = [...new Set(t.candidates.flatMap(({ path: e }) => Fn(e)))].sort((e, t) => e.split("/").length - t.split("/").length), r = new Set();
|
|
1056
|
+
for (let i of n) {
|
|
1057
|
+
if (In(i, r)) continue;
|
|
1058
|
+
let n = await e(t.repositoryRoot, i);
|
|
1059
|
+
if (t.signal?.aborted) return Pn();
|
|
1060
|
+
if (n.kind === "failed") return n;
|
|
1061
|
+
n.kind === "inspected" && n.entryType === "symlink" && r.add(i);
|
|
1062
|
+
}
|
|
1063
|
+
if (r.size === 0) return Object.freeze({
|
|
1064
|
+
candidates: t.candidates,
|
|
1065
|
+
kind: "shadowed"
|
|
1066
|
+
});
|
|
1067
|
+
let i = t.candidates.filter(({ path: e }) => !In(e, r)), a = new Set(i.map(({ path: e }) => e)), o = [...r].filter((e) => !a.has(e)).map((e) => Object.freeze({
|
|
1068
|
+
kind: "untracked",
|
|
1069
|
+
path: e
|
|
1070
|
+
}));
|
|
1071
|
+
return Object.freeze({
|
|
1072
|
+
candidates: Object.freeze([...i, ...o]),
|
|
1073
|
+
kind: "shadowed"
|
|
1074
|
+
});
|
|
1075
|
+
})(), Rn = () => Object.freeze({
|
|
1076
|
+
errorCode: "GIT_OUTPUT_INVALID",
|
|
1077
|
+
kind: "failed"
|
|
1078
|
+
}), zn = (e) => {
|
|
1079
|
+
let t = `/${e}`;
|
|
1080
|
+
return t !== "/" && Ee(t) ? t : null;
|
|
1081
|
+
}, Bn = (e) => zn(e.kind === "untracked" && e.path.endsWith("/") ? e.path.slice(0, -1) : e.path), Vn = (e, t) => {
|
|
1082
|
+
let n = e[Symbol.iterator](), r = t[Symbol.iterator]();
|
|
1083
|
+
for (;;) {
|
|
1084
|
+
let e = n.next(), t = r.next();
|
|
1085
|
+
if (e.done === !0) return t.done === !0 ? 0 : -1;
|
|
1086
|
+
if (t.done === !0) return 1;
|
|
1087
|
+
let i = e.value.codePointAt(0) ?? 0, a = t.value.codePointAt(0) ?? 0;
|
|
1088
|
+
if (i !== a) return i < a ? -1 : 1;
|
|
1089
|
+
}
|
|
1090
|
+
}, Hn = (e) => {
|
|
1091
|
+
let t = [];
|
|
1092
|
+
for (let n of e.candidates) {
|
|
1093
|
+
if (Bn(n) === null) {
|
|
1094
|
+
if (n.path === "moldea" || n.path.startsWith("moldea/")) return Rn();
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
1097
|
+
t.push(n);
|
|
1098
|
+
}
|
|
1099
|
+
return Object.freeze({
|
|
1100
|
+
candidates: Object.freeze(t),
|
|
1101
|
+
kind: "filtered"
|
|
1102
|
+
});
|
|
1103
|
+
}, Un = (e) => {
|
|
1104
|
+
let t = [], n = new Set();
|
|
1105
|
+
for (let r of e.entries) {
|
|
1106
|
+
let e = zn(r.path);
|
|
1107
|
+
if (e === null || n.has(e)) return Rn();
|
|
1108
|
+
n.add(e), t.push(Object.freeze({
|
|
1109
|
+
...r,
|
|
1110
|
+
path: e
|
|
1111
|
+
}));
|
|
1112
|
+
}
|
|
1113
|
+
return t.sort((e, t) => Vn(e.path, t.path)), Object.freeze({
|
|
1114
|
+
entries: Object.freeze(t),
|
|
1115
|
+
kind: "normalized"
|
|
1116
|
+
});
|
|
1117
|
+
}, Wn = (e) => {
|
|
1118
|
+
if (e.byteLength === 0) return null;
|
|
1119
|
+
try {
|
|
1120
|
+
return new TextDecoder("utf-8", {
|
|
1121
|
+
fatal: !0,
|
|
1122
|
+
ignoreBOM: !0
|
|
1123
|
+
}).decode(e);
|
|
1124
|
+
} catch {
|
|
1125
|
+
return null;
|
|
1126
|
+
}
|
|
1127
|
+
}, Gn = (e, t) => {
|
|
1128
|
+
let n = new Uint8Array(t), r = 0;
|
|
1129
|
+
for (let t of e) n.set(t, r), r += t.byteLength;
|
|
1130
|
+
return n;
|
|
1131
|
+
}, Kn = (e) => {
|
|
1132
|
+
let t = Wn(e);
|
|
1133
|
+
return t === null || !t.isWellFormed() ? null : Object.freeze({
|
|
1134
|
+
kind: "untracked",
|
|
1135
|
+
path: t
|
|
1136
|
+
});
|
|
1137
|
+
}, qn = (e, t) => {
|
|
1138
|
+
let n = [], r = null, i = 0, a = [], o = () => {
|
|
1139
|
+
if (r !== null) return;
|
|
1140
|
+
if (n.length >= e) {
|
|
1141
|
+
r = "entry-limit-exceeded", i = 0, a = [];
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1144
|
+
let o = t(Gn(a, i));
|
|
1145
|
+
if (i = 0, a = [], o === null) {
|
|
1146
|
+
r = "invalid";
|
|
1147
|
+
return;
|
|
1148
|
+
}
|
|
1149
|
+
n.push(o);
|
|
1150
|
+
};
|
|
1151
|
+
return {
|
|
1152
|
+
consume: (e) => {
|
|
1153
|
+
if (r !== null) return;
|
|
1154
|
+
let t = 0;
|
|
1155
|
+
for (let n = 0; n < e.byteLength; n += 1) {
|
|
1156
|
+
if (e[n] !== 0) continue;
|
|
1157
|
+
let s = e.subarray(t, n);
|
|
1158
|
+
if (a.push(s), i += s.byteLength, o(), r !== null) return;
|
|
1159
|
+
t = n + 1;
|
|
1160
|
+
}
|
|
1161
|
+
let n = e.subarray(t);
|
|
1162
|
+
n.byteLength > 0 && (a.push(n), i += n.byteLength);
|
|
1163
|
+
},
|
|
1164
|
+
finish: () => (r === null && i > 0 && (r = "invalid"), Object.freeze(r === null ? {
|
|
1165
|
+
candidates: Object.freeze([...n]),
|
|
1166
|
+
kind: "completed"
|
|
1167
|
+
} : {
|
|
1168
|
+
kind: "failed",
|
|
1169
|
+
reason: r
|
|
1170
|
+
}))
|
|
1171
|
+
};
|
|
1172
|
+
}, Jn = (e) => qn(e, Kn), Yn = ".git", Xn = 6, Zn = (e) => "kind" in e, R = (e) => Object.freeze({
|
|
1173
|
+
errorCode: e,
|
|
1174
|
+
kind: "failed"
|
|
1175
|
+
}), Qn = (e) => {
|
|
1176
|
+
let t = e?.code?.toUpperCase();
|
|
1177
|
+
return t === "EACCES" || t === "EPERM" ? "GIT_ACCESS_DENIED" : t === "ENOENT" || t === "ENOTDIR" || t === "ELOOP" ? "GIT_OUTPUT_INVALID" : "GIT_COMMAND_FAILED";
|
|
1178
|
+
}, $n = (e) => {
|
|
1179
|
+
switch (e) {
|
|
1180
|
+
case "aborted": return "GIT_OPERATION_ABORTED";
|
|
1181
|
+
case "not-found": return "GIT_NOT_FOUND";
|
|
1182
|
+
case "access-denied": return "GIT_ACCESS_DENIED";
|
|
1183
|
+
case "output-limit-exceeded": return "RESOURCE_LIMIT_EXCEEDED";
|
|
1184
|
+
case "repository-not-found":
|
|
1185
|
+
case "output-invalid": return "GIT_OUTPUT_INVALID";
|
|
1186
|
+
case "command-failed": return "GIT_COMMAND_FAILED";
|
|
1187
|
+
}
|
|
1188
|
+
}, er = async (e, t) => {
|
|
1189
|
+
try {
|
|
1190
|
+
let n = await t(e);
|
|
1191
|
+
return Object.freeze({
|
|
1192
|
+
encodedNameKeys: new Set(n.map((e) => e.toString("hex"))),
|
|
1193
|
+
kind: "read"
|
|
1194
|
+
});
|
|
1195
|
+
} catch (e) {
|
|
1196
|
+
return R(Qn(e));
|
|
1197
|
+
}
|
|
1198
|
+
}, z = async (e, t) => {
|
|
1199
|
+
try {
|
|
1200
|
+
return Object.freeze({
|
|
1201
|
+
kind: "inspected",
|
|
1202
|
+
statistics: await t(e)
|
|
1203
|
+
});
|
|
1204
|
+
} catch (e) {
|
|
1205
|
+
return R(Qn(e));
|
|
1206
|
+
}
|
|
1207
|
+
}, tr = (e, t) => e.has(Ue.from(t, "utf8").toString("hex")), nr = (e, t) => e.isDirectory() && !e.isSymbolicLink() && t.isDirectory() && !t.isSymbolicLink() && e.dev === t.dev && e.ino === t.ino, rr = async (e, t, n, r, i, a, o) => {
|
|
1208
|
+
if (o?.aborted) return R("GIT_OPERATION_ABORTED");
|
|
1209
|
+
if (!Number.isSafeInteger(r) || r < 0) return R("RESOURCE_LIMIT_EXCEEDED");
|
|
1210
|
+
let s = await C(() => i(e, {
|
|
1211
|
+
maxOutputBytes: Math.max(r, 1),
|
|
1212
|
+
timeoutSeconds: 300,
|
|
1213
|
+
...o === void 0 ? {} : { signal: o }
|
|
1214
|
+
}), o);
|
|
1215
|
+
if (s.kind === "failed") return R($n(s.reason));
|
|
1216
|
+
if (s.value === null) return R("GIT_COMMAND_FAILED");
|
|
1217
|
+
let c = s.value, l = Xn + Ce(c);
|
|
1218
|
+
if (l > r) return R("RESOURCE_LIMIT_EXCEEDED");
|
|
1219
|
+
if (!D.isAbsolute(c)) return R("GIT_OUTPUT_INVALID");
|
|
1220
|
+
if (vt(c, e)) return Object.freeze({
|
|
1221
|
+
gitMetadataBytes: l,
|
|
1222
|
+
kind: "validated",
|
|
1223
|
+
ownership: "nested-repository"
|
|
1224
|
+
});
|
|
1225
|
+
if (vt(c, t)) return Object.freeze({
|
|
1226
|
+
gitMetadataBytes: l,
|
|
1227
|
+
kind: "validated",
|
|
1228
|
+
ownership: "selected-repository"
|
|
1229
|
+
});
|
|
1230
|
+
let u = await z(c, a);
|
|
1231
|
+
if (o?.aborted) return R("GIT_OPERATION_ABORTED");
|
|
1232
|
+
if (u.kind === "failed") return u;
|
|
1233
|
+
if (!u.statistics.isDirectory() || u.statistics.isSymbolicLink()) return R("GIT_OUTPUT_INVALID");
|
|
1234
|
+
if (yt(u.statistics, n)) return Object.freeze({
|
|
1235
|
+
gitMetadataBytes: l,
|
|
1236
|
+
kind: "validated",
|
|
1237
|
+
ownership: "nested-repository"
|
|
1238
|
+
});
|
|
1239
|
+
let d = await z(t, a);
|
|
1240
|
+
return o?.aborted ? R("GIT_OPERATION_ABORTED") : d.kind === "failed" ? d : d.statistics.isDirectory() && !d.statistics.isSymbolicLink() && yt(u.statistics, d.statistics) ? Object.freeze({
|
|
1241
|
+
gitMetadataBytes: l,
|
|
1242
|
+
kind: "validated",
|
|
1243
|
+
ownership: "selected-repository"
|
|
1244
|
+
}) : R("GIT_OUTPUT_INVALID");
|
|
1245
|
+
}, ir = async (e) => k(e, { bigint: !0 }), ar = async (e) => ze(e, { encoding: "buffer" }), or = (e = me, t = ir, n = ar) => async (r) => {
|
|
1246
|
+
if (r.signal?.aborted) return R("GIT_OPERATION_ABORTED");
|
|
1247
|
+
let i = new Map(), a = [], o = 0, s = null, c = async () => {
|
|
1248
|
+
if (r.signal?.aborted) return R("GIT_OPERATION_ABORTED");
|
|
1249
|
+
if (s !== null) return Object.freeze({
|
|
1250
|
+
encodedNameKeys: s,
|
|
1251
|
+
kind: "read"
|
|
1252
|
+
});
|
|
1253
|
+
let e = await er(r.repositoryRoot, n);
|
|
1254
|
+
return r.signal?.aborted ? R("GIT_OPERATION_ABORTED") : (e.kind === "read" && (s = e.encodedNameKeys), e);
|
|
1255
|
+
}, l = async (a, s, l) => {
|
|
1256
|
+
if (r.signal?.aborted) return R("GIT_OPERATION_ABORTED");
|
|
1257
|
+
let u = s.length === 0 ? l : `${s}/${l}`, d = i.get(u);
|
|
1258
|
+
if (d !== void 0) return d;
|
|
1259
|
+
let f = a === null ? await c() : Object.freeze({
|
|
1260
|
+
encodedNameKeys: a.encodedNameKeys,
|
|
1261
|
+
kind: "read"
|
|
1262
|
+
});
|
|
1263
|
+
if (f.kind === "failed") return f;
|
|
1264
|
+
if (!tr(f.encodedNameKeys, l)) return R("GIT_OUTPUT_INVALID");
|
|
1265
|
+
let p = a?.hostPath ?? r.repositoryRoot, m = D.join(p, l), h = await z(m, t);
|
|
1266
|
+
if (r.signal?.aborted) return R("GIT_OPERATION_ABORTED");
|
|
1267
|
+
if (h.kind === "failed") return h;
|
|
1268
|
+
if (!h.statistics.isDirectory() || h.statistics.isSymbolicLink()) return R("GIT_OUTPUT_INVALID");
|
|
1269
|
+
let g = await er(m, n);
|
|
1270
|
+
if (r.signal?.aborted) return R("GIT_OPERATION_ABORTED");
|
|
1271
|
+
if (g.kind === "failed") return g;
|
|
1272
|
+
let _ = await z(m, t);
|
|
1273
|
+
if (r.signal?.aborted) return R("GIT_OPERATION_ABORTED");
|
|
1274
|
+
if (_.kind === "failed") return _;
|
|
1275
|
+
if (!nr(h.statistics, _.statistics)) return R("GIT_OUTPUT_INVALID");
|
|
1276
|
+
let v = D.join(m, Yn), ee = tr(g.encodedNameKeys, Yn), y = "selected-repository";
|
|
1277
|
+
if (ee) {
|
|
1278
|
+
let n = await z(v, t);
|
|
1279
|
+
if (r.signal?.aborted) return R("GIT_OPERATION_ABORTED");
|
|
1280
|
+
if (n.kind === "failed") return n;
|
|
1281
|
+
if (n.statistics.isSymbolicLink() || !n.statistics.isDirectory() && !n.statistics.isFile()) return R("GIT_OUTPUT_INVALID");
|
|
1282
|
+
let i = await rr(m, r.repositoryRoot, _.statistics, r.maxMetadataBytes - o, e, t, r.signal);
|
|
1283
|
+
if (i.kind === "failed") return i;
|
|
1284
|
+
o += i.gitMetadataBytes, y = i.ownership;
|
|
1285
|
+
} else try {
|
|
1286
|
+
return await t(v), r.signal?.aborted ? R("GIT_OPERATION_ABORTED") : R("GIT_OUTPUT_INVALID");
|
|
1287
|
+
} catch (e) {
|
|
1288
|
+
let t = e?.code?.toUpperCase();
|
|
1289
|
+
if (t !== "ENOENT" && t !== "ENOTDIR") return R(Qn(e));
|
|
1290
|
+
}
|
|
1291
|
+
let b = Object.freeze({
|
|
1292
|
+
encodedNameKeys: g.encodedNameKeys,
|
|
1293
|
+
hostPath: m,
|
|
1294
|
+
ownership: y
|
|
1295
|
+
});
|
|
1296
|
+
return i.set(u, b), b;
|
|
1297
|
+
};
|
|
1298
|
+
for (let e of r.plans) {
|
|
1299
|
+
if (r.signal?.aborted) return R("GIT_OPERATION_ABORTED");
|
|
1300
|
+
let t = "selected-repository", n = null, i = "";
|
|
1301
|
+
for (let a of e.directorySegments) {
|
|
1302
|
+
if (r.signal?.aborted) return R("GIT_OPERATION_ABORTED");
|
|
1303
|
+
let e = await l(n, i, a);
|
|
1304
|
+
if (Zn(e)) return e;
|
|
1305
|
+
if (n = e, i = i.length === 0 ? a : `${i}/${a}`, e.ownership === "nested-repository") {
|
|
1306
|
+
t = "nested-repository";
|
|
1307
|
+
break;
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
if (e.isDirectoryRecord && t !== "nested-repository") return R("GIT_OUTPUT_INVALID");
|
|
1311
|
+
a.push(t);
|
|
1312
|
+
}
|
|
1313
|
+
return Object.freeze({
|
|
1314
|
+
gitMetadataBytes: o,
|
|
1315
|
+
kind: "inspected",
|
|
1316
|
+
ownership: Object.freeze([...a])
|
|
1317
|
+
});
|
|
1318
|
+
}, sr = or(), cr = (e) => {
|
|
1319
|
+
let t = e.path.endsWith("/");
|
|
1320
|
+
if (e.path.length === 0 || e.path.startsWith("/") || e.path.includes("\\") || e.kind === "tracked" && t) return Object.freeze({ kind: "failed" });
|
|
1321
|
+
let n = (t ? e.path.slice(0, -1) : e.path).split("/");
|
|
1322
|
+
if (n.length === 0 || n.some((e) => e.length === 0 || e === "." || e === "..")) return Object.freeze({ kind: "failed" });
|
|
1323
|
+
let r = Object.freeze([...n]), i = Object.freeze(t ? [...n] : n.slice(0, -1));
|
|
1324
|
+
return Object.freeze({
|
|
1325
|
+
kind: "planned",
|
|
1326
|
+
plan: Object.freeze({
|
|
1327
|
+
candidate: e,
|
|
1328
|
+
directorySegments: i,
|
|
1329
|
+
hasGitControlSegment: n.includes(".git"),
|
|
1330
|
+
isDirectoryRecord: t,
|
|
1331
|
+
segments: r
|
|
1332
|
+
})
|
|
1333
|
+
});
|
|
1334
|
+
}, lr = (e = "GIT_OUTPUT_INVALID") => Object.freeze({
|
|
1335
|
+
errorCode: e,
|
|
1336
|
+
kind: "failed"
|
|
1337
|
+
}), ur = (e) => {
|
|
1338
|
+
let t = {
|
|
1339
|
+
children: new Map(),
|
|
1340
|
+
isRoot: !1
|
|
1341
|
+
};
|
|
1342
|
+
for (let n of e) {
|
|
1343
|
+
let e = t;
|
|
1344
|
+
for (let t of n) {
|
|
1345
|
+
let n = e.children.get(t);
|
|
1346
|
+
n === void 0 && (n = {
|
|
1347
|
+
children: new Map(),
|
|
1348
|
+
isRoot: !1
|
|
1349
|
+
}, e.children.set(t, n)), e = n;
|
|
1350
|
+
}
|
|
1351
|
+
e.isRoot = !0;
|
|
1352
|
+
}
|
|
1353
|
+
return t;
|
|
1354
|
+
}, dr = (e, t) => {
|
|
1355
|
+
let n = t;
|
|
1356
|
+
for (let t of e) {
|
|
1357
|
+
let e = n.children.get(t);
|
|
1358
|
+
if (e === void 0) return !1;
|
|
1359
|
+
if (e.isRoot) return !0;
|
|
1360
|
+
n = e;
|
|
1361
|
+
}
|
|
1362
|
+
return !1;
|
|
1363
|
+
}, fr = (e = sr) => async (t) => {
|
|
1364
|
+
let n = [];
|
|
1365
|
+
for (let [e, r] of t.candidates.entries()) {
|
|
1366
|
+
if (t.signal?.aborted) return lr("GIT_OPERATION_ABORTED");
|
|
1367
|
+
let i = cr(r);
|
|
1368
|
+
if (i.kind === "failed") return lr();
|
|
1369
|
+
n.push({
|
|
1370
|
+
candidateIndex: e,
|
|
1371
|
+
plan: i.plan
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
let r = ur(n.filter(({ plan: e }) => !e.hasGitControlSegment && e.candidate.kind === "tracked" && e.candidate.mode === "160000").map(({ plan: e }) => e.segments)), i = Array.from({ length: t.candidates.length }, () => !1), a = [];
|
|
1375
|
+
for (let { candidateIndex: e, plan: t } of n) if (!(t.hasGitControlSegment || dr(t.segments, r))) {
|
|
1376
|
+
if (t.candidate.kind === "tracked") {
|
|
1377
|
+
i[e] = !0;
|
|
1378
|
+
continue;
|
|
1379
|
+
}
|
|
1380
|
+
a.push({
|
|
1381
|
+
candidate: t.candidate,
|
|
1382
|
+
candidateIndex: e,
|
|
1383
|
+
plan: t
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1386
|
+
let o = await e({
|
|
1387
|
+
maxMetadataBytes: t.maxMetadataBytes,
|
|
1388
|
+
plans: a.map(({ plan: e }) => e),
|
|
1389
|
+
repositoryRoot: t.repositoryRoot,
|
|
1390
|
+
...t.signal === void 0 ? {} : { signal: t.signal }
|
|
1391
|
+
});
|
|
1392
|
+
if (o.kind === "failed") return o;
|
|
1393
|
+
if (o.ownership.length !== a.length) return lr();
|
|
1394
|
+
for (let [e, n] of o.ownership.entries()) {
|
|
1395
|
+
if (t.signal?.aborted) return lr("GIT_OPERATION_ABORTED");
|
|
1396
|
+
let r = a[e];
|
|
1397
|
+
if (r === void 0) return lr();
|
|
1398
|
+
n === "selected-repository" && (i[r.candidateIndex] = !0);
|
|
1399
|
+
}
|
|
1400
|
+
let s = t.candidates.filter((e, t) => i[t] === !0);
|
|
1401
|
+
return Object.freeze({
|
|
1402
|
+
candidates: Object.freeze(s),
|
|
1403
|
+
gitMetadataBytes: o.gitMetadataBytes,
|
|
1404
|
+
kind: "filtered"
|
|
1405
|
+
});
|
|
1406
|
+
}, pr = Object.freeze({
|
|
1407
|
+
listUntrackedFiles: se,
|
|
1408
|
+
readIndexEntries: ge,
|
|
1409
|
+
runGit: mt
|
|
1410
|
+
}), mr = (e) => {
|
|
1411
|
+
switch (e) {
|
|
1412
|
+
case "aborted": return "GIT_OPERATION_ABORTED";
|
|
1413
|
+
case "not-found": return "GIT_NOT_FOUND";
|
|
1414
|
+
case "repository-not-found": return "GIT_REPOSITORY_NOT_FOUND";
|
|
1415
|
+
case "access-denied": return "GIT_ACCESS_DENIED";
|
|
1416
|
+
case "output-invalid": return "GIT_OUTPUT_INVALID";
|
|
1417
|
+
case "output-limit-exceeded": return "RESOURCE_LIMIT_EXCEEDED";
|
|
1418
|
+
case "command-failed": return "GIT_COMMAND_FAILED";
|
|
1419
|
+
}
|
|
1420
|
+
}, hr = (e) => sn.includes(e), gr = (e) => {
|
|
1421
|
+
let t = [];
|
|
1422
|
+
for (let { mode: n, path: r, stage: i } of e) {
|
|
1423
|
+
if (!hr(n)) return null;
|
|
1424
|
+
t.push(Object.freeze({
|
|
1425
|
+
kind: "tracked",
|
|
1426
|
+
mode: n,
|
|
1427
|
+
path: r,
|
|
1428
|
+
stage: i
|
|
1429
|
+
}));
|
|
1430
|
+
}
|
|
1431
|
+
return Object.freeze(t);
|
|
1432
|
+
}, _r = (e) => e.reduce((e, { path: t }) => e + 75 + Ce(t), 0), vr = (e) => e.reduce((e, t) => e + Ce(t) + 1, 0), B = (e, t) => Object.freeze({
|
|
1433
|
+
errorCode: e,
|
|
1434
|
+
kind: "failed",
|
|
1435
|
+
...t === void 0 ? {} : { subcommand: t }
|
|
1436
|
+
}), yr = (e) => e.kind === "completed" ? e.candidates : B(e.reason === "entry-limit-exceeded" ? "RESOURCE_LIMIT_EXCEEDED" : "GIT_OUTPUT_INVALID"), br = (e) => !Array.isArray(e), xr = ((e = pr, t = fr(or()), n = Nn(Tn, kn()), r = bn(), i = Un, a = Ln) => async (o) => {
|
|
1437
|
+
if (o.signal?.aborted) return B("GIT_OPERATION_ABORTED");
|
|
1438
|
+
let s = (o.selectionPaths ?? []).map((e) => e.slice(1)), c = o.maxMetadataBytes, l = () => ({
|
|
1439
|
+
maxOutputBytes: Math.max(c, 1),
|
|
1440
|
+
timeoutSeconds: 300,
|
|
1441
|
+
...s.length === 0 ? {} : { paths: s },
|
|
1442
|
+
...o.signal === void 0 ? {} : { signal: o.signal }
|
|
1443
|
+
}), u = await C(() => e.readIndexEntries(o.repositoryRoot, l()), o.signal, an);
|
|
1444
|
+
if (u.kind === "failed") return B(mr(u.reason), u.subcommand);
|
|
1445
|
+
if (c -= _r(u.value), u.value.length > o.maxEntries || c < 0) return B("RESOURCE_LIMIT_EXCEEDED");
|
|
1446
|
+
let d = gr(u.value);
|
|
1447
|
+
if (d === null) return B("GIT_OUTPUT_INVALID");
|
|
1448
|
+
let f = await C(() => e.listUntrackedFiles(o.repositoryRoot, l()), o.signal, an);
|
|
1449
|
+
if (f.kind === "failed") return B(mr(f.reason), f.subcommand);
|
|
1450
|
+
if (c -= vr(f.value), d.length + f.value.length > o.maxEntries || c < 0) return B("RESOURCE_LIMIT_EXCEEDED");
|
|
1451
|
+
if (f.value.some((e) => e.length === 0)) return B("GIT_OUTPUT_INVALID");
|
|
1452
|
+
let p = Object.freeze(f.value.map((e) => Object.freeze({
|
|
1453
|
+
kind: "untracked",
|
|
1454
|
+
path: e
|
|
1455
|
+
}))), m = [];
|
|
1456
|
+
if (o.includeIgnored === !0 && s.length > 0) {
|
|
1457
|
+
let t = await e.runGit([...rn, ...s], {
|
|
1458
|
+
cwd: o.repositoryRoot,
|
|
1459
|
+
maxOutputBytes: Math.max(c, 1),
|
|
1460
|
+
...o.signal === void 0 ? {} : { signal: o.signal }
|
|
1461
|
+
});
|
|
1462
|
+
if (t.kind === "failed") return B(mr(t.reason), t.subcommand);
|
|
1463
|
+
if (c -= t.value.byteLength, c < 0) return B("RESOURCE_LIMIT_EXCEEDED");
|
|
1464
|
+
let n = Jn(o.maxEntries - d.length - p.length);
|
|
1465
|
+
n.consume(t.value);
|
|
1466
|
+
let r = yr(n.finish());
|
|
1467
|
+
if (br(r)) return r;
|
|
1468
|
+
let i = new Set(p.map((e) => e.path));
|
|
1469
|
+
m = r.filter((e) => !i.has(e.path));
|
|
1470
|
+
}
|
|
1471
|
+
let h = Hn({ candidates: Object.freeze([
|
|
1472
|
+
...d,
|
|
1473
|
+
...p,
|
|
1474
|
+
...m
|
|
1475
|
+
]) });
|
|
1476
|
+
if (h.kind === "failed") return h;
|
|
1477
|
+
let g = await a({
|
|
1478
|
+
candidates: h.candidates,
|
|
1479
|
+
repositoryRoot: o.repositoryRoot,
|
|
1480
|
+
...o.signal === void 0 ? {} : { signal: o.signal }
|
|
1481
|
+
});
|
|
1482
|
+
if (g.kind === "failed") return g;
|
|
1483
|
+
let _ = await t({
|
|
1484
|
+
candidates: g.candidates,
|
|
1485
|
+
maxMetadataBytes: c,
|
|
1486
|
+
repositoryRoot: o.repositoryRoot,
|
|
1487
|
+
...o.signal === void 0 ? {} : { signal: o.signal }
|
|
1488
|
+
});
|
|
1489
|
+
if (_.kind === "failed") return _;
|
|
1490
|
+
let v = await n({
|
|
1491
|
+
candidates: _.candidates,
|
|
1492
|
+
maxMetadataBytes: c - _.gitMetadataBytes,
|
|
1493
|
+
repositoryRoot: o.repositoryRoot,
|
|
1494
|
+
...o.signal === void 0 ? {} : { signal: o.signal }
|
|
1495
|
+
});
|
|
1496
|
+
if (v.kind === "failed") return v;
|
|
1497
|
+
let ee = await r({
|
|
1498
|
+
entries: v.entries,
|
|
1499
|
+
maxMetadataBytes: c - _.gitMetadataBytes - v.gitMetadataBytes,
|
|
1500
|
+
repositoryRoot: o.repositoryRoot,
|
|
1501
|
+
...o.signal === void 0 ? {} : { signal: o.signal }
|
|
1502
|
+
});
|
|
1503
|
+
if (ee.kind === "failed") return ee;
|
|
1504
|
+
let y = i({ entries: ee.entries });
|
|
1505
|
+
return y.kind === "failed" ? y : Object.freeze({
|
|
1506
|
+
entries: y.entries,
|
|
1507
|
+
kind: "probed"
|
|
1508
|
+
});
|
|
1509
|
+
})(), Sr = (e, t) => e.filter === t.filter && e.ident === t.ident && e.isGuarded === t.isGuarded && e.workingTreeEncoding === t.workingTreeEncoding, Cr = (e, t) => e.length === t.length && e.every((e, n) => e.mode === t[n]?.mode && e.stage === t[n]?.stage), wr = (e, t) => e.kind !== t.kind || e.path !== t.path || e.entryType !== t.entryType || e.requiresSymlinkOverlay !== t.requiresSymlinkOverlay || !Sr(e.contentTransformation, t.contentTransformation) ? !1 : e.kind === "untracked" || t.kind === "untracked" ? e.kind === t.kind : Cr(e.indexEntries, t.indexEntries), Tr = (e, t) => e.length === t.length && e.every((e, n) => {
|
|
1510
|
+
let r = t[n];
|
|
1511
|
+
return r !== void 0 && wr(e, r);
|
|
1512
|
+
}), V = Object.freeze({
|
|
1513
|
+
maxCachedBytes: 67108864,
|
|
1514
|
+
maxConcurrentOperations: 16,
|
|
1515
|
+
maxDirectoryEntries: 131072,
|
|
1516
|
+
maxEntries: 131072,
|
|
1517
|
+
maxPageEntries: 4096,
|
|
1518
|
+
maxQueuedOperations: 256,
|
|
1519
|
+
maxReadBytes: 1048576
|
|
1520
|
+
}), Er = (e) => typeof e == "string" && e.length > 0 && !e.includes("\0") && e.isWellFormed() && D.isAbsolute(e), Dr = new Set([
|
|
1521
|
+
"limits",
|
|
1522
|
+
"rootDirectory",
|
|
1523
|
+
"selection",
|
|
1524
|
+
"signal"
|
|
1525
|
+
]), Or = new Set(["kind"]), kr = new Set(["kind", "paths"]), Ar = [
|
|
1526
|
+
"maxCachedBytes",
|
|
1527
|
+
"maxConcurrentOperations",
|
|
1528
|
+
"maxDirectoryEntries",
|
|
1529
|
+
"maxEntries",
|
|
1530
|
+
"maxPageEntries",
|
|
1531
|
+
"maxQueuedOperations",
|
|
1532
|
+
"maxReadBytes"
|
|
1533
|
+
], jr = new Set(Ar), H = (e = null) => {
|
|
1534
|
+
throw new w({
|
|
1535
|
+
code: "INVALID_SOURCE_DATA",
|
|
1536
|
+
operation: "create-reader",
|
|
1537
|
+
path: e,
|
|
1538
|
+
retryable: !1
|
|
1539
|
+
});
|
|
1540
|
+
}, Mr = (e) => {
|
|
1541
|
+
try {
|
|
1542
|
+
return Array.isArray(e);
|
|
1543
|
+
} catch {
|
|
1544
|
+
return H();
|
|
1545
|
+
}
|
|
1546
|
+
}, Nr = (e) => typeof e == "object" && !!e && !Mr(e), Pr = (e, t) => {
|
|
1547
|
+
try {
|
|
1548
|
+
return Reflect.ownKeys(e).every((e) => typeof e == "string" && t.has(e));
|
|
1549
|
+
} catch {
|
|
1550
|
+
return H();
|
|
1551
|
+
}
|
|
1552
|
+
}, U = (e, t) => {
|
|
1553
|
+
try {
|
|
1554
|
+
return Object.hasOwn(e, t);
|
|
1555
|
+
} catch {
|
|
1556
|
+
return H();
|
|
1557
|
+
}
|
|
1558
|
+
}, W = (e, t) => {
|
|
1559
|
+
try {
|
|
1560
|
+
return Reflect.get(e, t);
|
|
1561
|
+
} catch {
|
|
1562
|
+
return H();
|
|
1563
|
+
}
|
|
1564
|
+
}, Fr = (e) => {
|
|
1565
|
+
if (typeof e != "string") throw new Oe();
|
|
1566
|
+
return T(e);
|
|
1567
|
+
}, Ir = (e) => {
|
|
1568
|
+
if (!Pr(e, kr) || !U(e, "paths")) return H();
|
|
1569
|
+
let t = W(e, "paths");
|
|
1570
|
+
if (!Mr(t)) return H();
|
|
1571
|
+
let n = W(t, "length");
|
|
1572
|
+
if (typeof n != "number" || !Number.isSafeInteger(n) || n < 0) return H();
|
|
1573
|
+
let r = [];
|
|
1574
|
+
for (let e = 0; e < n; e += 1) {
|
|
1575
|
+
let n = String(e);
|
|
1576
|
+
if (!U(t, n)) return H();
|
|
1577
|
+
r.push(Fr(W(t, n)));
|
|
1578
|
+
}
|
|
1579
|
+
let i = new Set();
|
|
1580
|
+
for (let e of r) {
|
|
1581
|
+
if (e === E || i.has(e)) return H();
|
|
1582
|
+
i.add(e);
|
|
1583
|
+
}
|
|
1584
|
+
return r.sort(), Object.freeze({
|
|
1585
|
+
kind: "paths",
|
|
1586
|
+
paths: Object.freeze(r)
|
|
1587
|
+
});
|
|
1588
|
+
}, Lr = (e) => {
|
|
1589
|
+
if (!Nr(e) || !U(e, "kind")) return H();
|
|
1590
|
+
let t = W(e, "kind");
|
|
1591
|
+
return t === "directory" ? Pr(e, Or) ? Object.freeze({ kind: "directory" }) : H() : t === "paths" ? Ir(e) : H();
|
|
1592
|
+
}, Rr = (e) => typeof e == "number" && Number.isSafeInteger(e) && e > 0, zr = (e) => {
|
|
1593
|
+
if (e === void 0) return V;
|
|
1594
|
+
if (!Nr(e) || !Pr(e, jr)) return H();
|
|
1595
|
+
let t = {
|
|
1596
|
+
maxCachedBytes: V.maxCachedBytes,
|
|
1597
|
+
maxConcurrentOperations: V.maxConcurrentOperations,
|
|
1598
|
+
maxDirectoryEntries: V.maxDirectoryEntries,
|
|
1599
|
+
maxEntries: V.maxEntries,
|
|
1600
|
+
maxPageEntries: V.maxPageEntries,
|
|
1601
|
+
maxQueuedOperations: V.maxQueuedOperations,
|
|
1602
|
+
maxReadBytes: V.maxReadBytes
|
|
1603
|
+
};
|
|
1604
|
+
for (let n of Ar) {
|
|
1605
|
+
if (!U(e, n)) continue;
|
|
1606
|
+
let r = W(e, n);
|
|
1607
|
+
if (!Rr(r)) return H();
|
|
1608
|
+
t[n] = r;
|
|
1609
|
+
}
|
|
1610
|
+
return Object.freeze(t);
|
|
1611
|
+
}, Br = (e) => {
|
|
1612
|
+
try {
|
|
1613
|
+
if (e === void 0 || e instanceof AbortSignal) return e;
|
|
1614
|
+
} catch {
|
|
1615
|
+
return H();
|
|
1616
|
+
}
|
|
1617
|
+
return H();
|
|
1618
|
+
}, Vr = (e) => {
|
|
1619
|
+
let t;
|
|
1620
|
+
try {
|
|
1621
|
+
if (!Nr(e) || !Pr(e, Dr) || !U(e, "rootDirectory") || !U(e, "selection")) return H();
|
|
1622
|
+
let n = W(e, "rootDirectory"), r = W(e, "selection"), i = U(e, "limits") ? W(e, "limits") : void 0, a = U(e, "signal") ? W(e, "signal") : void 0;
|
|
1623
|
+
if (!Er(n)) return H();
|
|
1624
|
+
t = {
|
|
1625
|
+
limits: zr(i),
|
|
1626
|
+
rootDirectory: n,
|
|
1627
|
+
selection: Lr(r),
|
|
1628
|
+
signal: Br(a)
|
|
1629
|
+
};
|
|
1630
|
+
} catch (e) {
|
|
1631
|
+
if (e instanceof Oe) throw e;
|
|
1632
|
+
return H();
|
|
1633
|
+
}
|
|
1634
|
+
if (t.selection.kind === "paths") {
|
|
1635
|
+
for (let e of t.selection.paths) if (e.slice(1).split("/").includes(".git")) return H(e);
|
|
1636
|
+
}
|
|
1637
|
+
return Object.freeze(t);
|
|
1638
|
+
}, Hr = new Me("utf-8", {
|
|
1639
|
+
fatal: !0,
|
|
1640
|
+
ignoreBOM: !0
|
|
1641
|
+
}), Ur = 65536, Wr = new Set([
|
|
1642
|
+
"frames",
|
|
1643
|
+
"kind",
|
|
1644
|
+
"prefix",
|
|
1645
|
+
"snapshotId",
|
|
1646
|
+
"version"
|
|
1647
|
+
]), Gr = new Set([
|
|
1648
|
+
"lastName",
|
|
1649
|
+
"namesIdentity",
|
|
1650
|
+
"path",
|
|
1651
|
+
"pathIdentity"
|
|
1652
|
+
]), Kr = new Set([
|
|
1653
|
+
"kind",
|
|
1654
|
+
"lastPath",
|
|
1655
|
+
"prefix",
|
|
1656
|
+
"snapshotId",
|
|
1657
|
+
"version"
|
|
1658
|
+
]), qr = (e, t) => Reflect.ownKeys(e).every((e) => typeof e == "string" && t.has(e)), Jr = (e) => {
|
|
1659
|
+
let t = Ne("sha256");
|
|
1660
|
+
for (let n of e) t.update(n), t.update("\0");
|
|
1661
|
+
return `sha256:${t.digest("hex")}`;
|
|
1662
|
+
}, Yr = (e) => {
|
|
1663
|
+
if (typeof e != "object" || !e || !("code" in e)) return;
|
|
1664
|
+
let t = e.code;
|
|
1665
|
+
return typeof t == "string" ? t : void 0;
|
|
1666
|
+
}, G = (e, t, n, r, i, a) => {
|
|
1667
|
+
throw new w({
|
|
1668
|
+
cause: i,
|
|
1669
|
+
code: e,
|
|
1670
|
+
operation: t,
|
|
1671
|
+
path: n,
|
|
1672
|
+
...a === void 0 ? {} : { resource: a },
|
|
1673
|
+
retryable: r
|
|
1674
|
+
});
|
|
1675
|
+
}, K = (e, t, n) => {
|
|
1676
|
+
let r = Yr(e);
|
|
1677
|
+
return G(r === "EACCES" || r === "EPERM" ? "ACCESS_DENIED" : t !== "create-reader" && (r === "ENOENT" || r === "ENOTDIR" || r === "ELOOP") ? "SNAPSHOT_CHANGED" : t === "create-reader" && (r === "ENOENT" || r === "ENOTDIR") ? "ENTRY_NOT_FOUND" : "SOURCE_UNAVAILABLE", t, n, !0, e);
|
|
1678
|
+
}, q = (e, t, n) => {
|
|
1679
|
+
e?.aborted && G("ABORTED", t, n, !1, e.reason);
|
|
1680
|
+
}, J = (e, t) => Jr([
|
|
1681
|
+
t,
|
|
1682
|
+
e.dev.toString(),
|
|
1683
|
+
e.ino.toString(),
|
|
1684
|
+
e.mode.toString(),
|
|
1685
|
+
e.size.toString(),
|
|
1686
|
+
e.mtimeNs.toString(),
|
|
1687
|
+
e.ctimeNs.toString()
|
|
1688
|
+
]), Xr = (e, t, n) => e.isFile() ? "file" : e.isDirectory() ? "directory" : e.isSymbolicLink() ? "symlink" : G("INVALID_SOURCE_DATA", t, n, !1), Zr = (e, t, n) => {
|
|
1689
|
+
try {
|
|
1690
|
+
let t = Hr.decode(e);
|
|
1691
|
+
return T(n === E ? `/${t}` : `${n}/${t}`), t;
|
|
1692
|
+
} catch (e) {
|
|
1693
|
+
return G("INVALID_SOURCE_DATA", t, n, !1, e);
|
|
1694
|
+
}
|
|
1695
|
+
}, Qr = async (e) => await Re(e, { encoding: "buffer" }), $r = (e) => {
|
|
1696
|
+
let t = e.slice(1).split("/"), n = [E];
|
|
1697
|
+
for (let e = 1; e < t.length; e += 1) n.push(T(`/${t.slice(0, e).join("/")}`));
|
|
1698
|
+
return n;
|
|
1699
|
+
}, ei = (e, t) => {
|
|
1700
|
+
let n = 0, r = e.length;
|
|
1701
|
+
for (; n < r;) {
|
|
1702
|
+
let i = n + Math.floor((r - n) / 2), a = e[i];
|
|
1703
|
+
a !== void 0 && Te(a, t) <= 0 ? n = i + 1 : r = i;
|
|
1704
|
+
}
|
|
1705
|
+
return n;
|
|
1706
|
+
}, ti = (e, t) => {
|
|
1707
|
+
let n = 0, r = e.length;
|
|
1708
|
+
for (; n < r;) {
|
|
1709
|
+
let i = n + Math.floor((r - n) / 2), a = e[i];
|
|
1710
|
+
a !== void 0 && a < t ? n = i + 1 : r = i;
|
|
1711
|
+
}
|
|
1712
|
+
return e[n] === t ? n : -1;
|
|
1713
|
+
}, ni = class {
|
|
1714
|
+
snapshot;
|
|
1715
|
+
#e;
|
|
1716
|
+
#t = Fe(32);
|
|
1717
|
+
#n;
|
|
1718
|
+
#r;
|
|
1719
|
+
#i = new Map();
|
|
1720
|
+
#a;
|
|
1721
|
+
#o;
|
|
1722
|
+
#s;
|
|
1723
|
+
#c;
|
|
1724
|
+
#l;
|
|
1725
|
+
#u = new Map();
|
|
1726
|
+
#d = new Map();
|
|
1727
|
+
constructor(e, t, n) {
|
|
1728
|
+
this.#r = e.limits, this.#a = t, this.#o = e.selection, this.#e = Ge({
|
|
1729
|
+
maxBytes: e.limits.maxCachedBytes,
|
|
1730
|
+
maxEntries: 4096
|
|
1731
|
+
}), this.#n = Ye({
|
|
1732
|
+
maxConcurrent: e.limits.maxConcurrentOperations,
|
|
1733
|
+
maxQueued: e.limits.maxQueuedOperations
|
|
1734
|
+
}), this.snapshot = Object.freeze({
|
|
1735
|
+
id: Jr([n, Fe(32)]),
|
|
1736
|
+
sourceKind: "filesystem"
|
|
1737
|
+
}), this.#i.set(E, n), this.#s = e.selection.kind === "paths" ? this.#p(e.selection.paths) : [], this.#c = new Set(this.#s), this.#l = new Set(e.selection.kind === "paths" ? e.selection.paths : []);
|
|
1738
|
+
for (let e of this.#s) {
|
|
1739
|
+
if (e === E) continue;
|
|
1740
|
+
let t = e.lastIndexOf("/"), n = T(e.slice(0, t) || "/"), r = this.#u.get(n) ?? new Set();
|
|
1741
|
+
r.add(e.slice(t + 1)), this.#u.set(n, r);
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
async initialize(e) {
|
|
1745
|
+
if (this.#o.kind === "paths") for (let t of this.#s) {
|
|
1746
|
+
q(e, "create-reader", t);
|
|
1747
|
+
let n = await this.#O(t, "create-reader", void 0, e);
|
|
1748
|
+
if (n === null) return G("ENTRY_NOT_FOUND", "create-reader", t, !0);
|
|
1749
|
+
t !== E && !this.#l.has(t) && n.type !== "directory" && G("ENTRY_NOT_DIRECTORY", "create-reader", t, !1);
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
async compare(e, t) {
|
|
1753
|
+
return De(this, e, t);
|
|
1754
|
+
}
|
|
1755
|
+
async getEntry(e, t) {
|
|
1756
|
+
let n = T(e);
|
|
1757
|
+
return this.#_(n) ? this.#A("get-entry", n, t?.signal, () => this.#O(n, "get-entry", void 0, t?.signal)) : null;
|
|
1758
|
+
}
|
|
1759
|
+
async listEntriesPage(e) {
|
|
1760
|
+
let t = e.prefix === void 0 ? E : T(e.prefix);
|
|
1761
|
+
return this.#A("list-entries-page", t, e.signal, async () => {
|
|
1762
|
+
let n = this.#b(e.maxEntries, this.#r.maxPageEntries, "pageEntries", "list-entries-page", t), r = await this.#O(t, "list-entries-page", void 0, e.signal);
|
|
1763
|
+
return r === null || !this.#_(t) ? G("ENTRY_NOT_FOUND", "list-entries-page", t, !1) : (r.type !== "directory" && G("ENTRY_NOT_DIRECTORY", "list-entries-page", t, !1), this.#o.kind === "paths" ? this.#y(t, n, e.cursor, e.signal) : this.#v(t, n, e.cursor, e.signal));
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
async readFilePage(e, t) {
|
|
1767
|
+
let n = T(e);
|
|
1768
|
+
return this.#A("read-file-page", n, t.signal, async () => {
|
|
1769
|
+
let e = this.#x(t.offset, n), r = this.#b(t.maxBytes, this.#r.maxReadBytes, "readBytes", "read-file-page", n);
|
|
1770
|
+
this.#_(n) || G("ENTRY_NOT_FOUND", "read-file-page", n, !1);
|
|
1771
|
+
let i = await this.#O(n, "read-file-page", void 0, t.signal);
|
|
1772
|
+
if (i === null) return G("ENTRY_NOT_FOUND", "read-file-page", n, !1);
|
|
1773
|
+
if (i.type !== "file" || i.byteLength === null) return G("ENTRY_NOT_FILE", "read-file-page", n, !1);
|
|
1774
|
+
let a = this.#i.get(n);
|
|
1775
|
+
if (a === void 0) return G("INVALID_SOURCE_DATA", "read-file-page", n, !1);
|
|
1776
|
+
e > i.byteLength && G("INVALID_PAGE_REQUEST", "read-file-page", n, !1);
|
|
1777
|
+
let o = Math.min(r, i.byteLength - e), s = `${n}\0${a}\0${e}\0${o}`, c = this.#e.get(s);
|
|
1778
|
+
if (c !== void 0) return this.#f(c, i.byteLength, e);
|
|
1779
|
+
let l = await this.#k(n, a, e, o, t.signal);
|
|
1780
|
+
return l.byteLength > 0 && this.#e.set(s, l), this.#f(l, i.byteLength, e);
|
|
1781
|
+
});
|
|
1782
|
+
}
|
|
1783
|
+
async readLinkText(e, t) {
|
|
1784
|
+
let n = T(e);
|
|
1785
|
+
return this.#A("read-link-text", n, t?.signal, async () => {
|
|
1786
|
+
if (!this.#_(n)) return G("ENTRY_NOT_FOUND", "read-link-text", n, !1);
|
|
1787
|
+
let e = await this.#O(n, "read-link-text", void 0, t?.signal);
|
|
1788
|
+
if (e === null) return G("ENTRY_NOT_FOUND", "read-link-text", n, !1);
|
|
1789
|
+
if (e.type !== "symlink") return G("ENTRY_NOT_LINK", "read-link-text", n, !1);
|
|
1790
|
+
let r;
|
|
1791
|
+
try {
|
|
1792
|
+
r = await Be(this.#g(n), { encoding: "buffer" });
|
|
1793
|
+
} catch (e) {
|
|
1794
|
+
return K(e, "read-link-text", n);
|
|
1795
|
+
}
|
|
1796
|
+
if (await this.#O(n, "read-link-text", void 0, t?.signal), r.byteLength > 4096) return null;
|
|
1797
|
+
let i;
|
|
1798
|
+
try {
|
|
1799
|
+
i = Hr.decode(r);
|
|
1800
|
+
} catch {
|
|
1801
|
+
return null;
|
|
1802
|
+
}
|
|
1803
|
+
return process.platform === "win32" ? i.replaceAll("\\", "/") : i;
|
|
1804
|
+
});
|
|
1805
|
+
}
|
|
1806
|
+
#f(e, t, n) {
|
|
1807
|
+
let r = n + e.byteLength, i = r === t;
|
|
1808
|
+
return {
|
|
1809
|
+
bytes: e,
|
|
1810
|
+
isComplete: i,
|
|
1811
|
+
nextOffset: i ? null : r,
|
|
1812
|
+
offset: n,
|
|
1813
|
+
snapshot: this.snapshot,
|
|
1814
|
+
totalBytes: t
|
|
1815
|
+
};
|
|
1816
|
+
}
|
|
1817
|
+
#p(e) {
|
|
1818
|
+
let t = new Set([E]);
|
|
1819
|
+
for (let n of e) {
|
|
1820
|
+
t.add(n);
|
|
1821
|
+
for (let e of $r(n)) t.add(e);
|
|
1822
|
+
}
|
|
1823
|
+
return t.size - 1 > this.#r.maxEntries && G("RESOURCE_LIMIT_EXCEEDED", "create-reader", null, !1, void 0, {
|
|
1824
|
+
dimension: "selectedEntries",
|
|
1825
|
+
limit: this.#r.maxEntries,
|
|
1826
|
+
observed: t.size - 1
|
|
1827
|
+
}), Object.freeze([...t].sort(Te));
|
|
1828
|
+
}
|
|
1829
|
+
#m(e, t) {
|
|
1830
|
+
try {
|
|
1831
|
+
if (Buffer.byteLength(e, "utf8") > Ur) throw Error("cursor exceeds the encoded limit");
|
|
1832
|
+
let n = e.lastIndexOf(".");
|
|
1833
|
+
if (n <= 0) throw Error("cursor signature is missing");
|
|
1834
|
+
let r = e.slice(0, n);
|
|
1835
|
+
if (!at(r, e.slice(n + 1), this.#t)) throw Error("cursor signature does not match");
|
|
1836
|
+
let i = JSON.parse(Buffer.from(r, "base64url").toString("utf8"));
|
|
1837
|
+
if (!s(i, !0) || i.version !== 1 || i.snapshotId !== this.snapshot.id || i.prefix !== t) throw Error("cursor belongs to another snapshot or prefix");
|
|
1838
|
+
if (i.kind === "paths" && qr(i, Kr)) {
|
|
1839
|
+
let e = T(i.lastPath), n = t === E ? E : `${t}/`;
|
|
1840
|
+
if (e === t || !e.startsWith(n)) throw Error("cursor path is outside the requested prefix");
|
|
1841
|
+
return {
|
|
1842
|
+
kind: "paths",
|
|
1843
|
+
lastPath: e,
|
|
1844
|
+
prefix: t,
|
|
1845
|
+
snapshotId: this.snapshot.id,
|
|
1846
|
+
version: 1
|
|
1847
|
+
};
|
|
1848
|
+
}
|
|
1849
|
+
if (i.kind === "directory" && qr(i, Wr) && Array.isArray(i.frames)) return {
|
|
1850
|
+
frames: i.frames.map((e) => {
|
|
1851
|
+
if (!s(e, !0)) throw Error("cursor frame is invalid");
|
|
1852
|
+
let t = e;
|
|
1853
|
+
if (!qr(t, Gr) || typeof t.lastName != "string" && t.lastName !== null || typeof t.namesIdentity != "string" || typeof t.path != "string" || typeof t.pathIdentity != "string") throw Error("cursor frame is invalid");
|
|
1854
|
+
return {
|
|
1855
|
+
lastName: t.lastName,
|
|
1856
|
+
namesIdentity: t.namesIdentity,
|
|
1857
|
+
path: T(t.path),
|
|
1858
|
+
pathIdentity: t.pathIdentity
|
|
1859
|
+
};
|
|
1860
|
+
}),
|
|
1861
|
+
kind: "directory",
|
|
1862
|
+
prefix: t,
|
|
1863
|
+
snapshotId: this.snapshot.id,
|
|
1864
|
+
version: 1
|
|
1865
|
+
};
|
|
1866
|
+
throw Error("cursor payload is invalid");
|
|
1867
|
+
} catch (e) {
|
|
1868
|
+
return G("INVALID_PAGE_REQUEST", "list-entries-page", t, !1, e);
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
#h(e) {
|
|
1872
|
+
let t = Buffer.from(JSON.stringify(e), "utf8").toString("base64url"), n = `${t}.${it(t, this.#t)}`;
|
|
1873
|
+
return Buffer.byteLength(n, "utf8") > Ur && G("RESOURCE_LIMIT_EXCEEDED", "list-entries-page", e.prefix, !1, void 0, {
|
|
1874
|
+
dimension: "cursorBytes",
|
|
1875
|
+
limit: Ur,
|
|
1876
|
+
observed: Buffer.byteLength(n, "utf8")
|
|
1877
|
+
}), n;
|
|
1878
|
+
}
|
|
1879
|
+
#g(e) {
|
|
1880
|
+
if (e === E) return this.#a;
|
|
1881
|
+
let t = D.resolve(this.#a, ...e.slice(1).split("/")), n = D.relative(this.#a, t);
|
|
1882
|
+
return (n === "" || n === ".." || n.startsWith(`..${D.sep}`) || D.isAbsolute(n)) && G("INVALID_SOURCE_DATA", "get-entry", e, !1), t;
|
|
1883
|
+
}
|
|
1884
|
+
#_(e) {
|
|
1885
|
+
return this.#o.kind === "directory" || this.#c.has(e);
|
|
1886
|
+
}
|
|
1887
|
+
async #v(e, t, n, r) {
|
|
1888
|
+
let i, a = new Map();
|
|
1889
|
+
if (n === void 0) {
|
|
1890
|
+
let t = await this.#S(e, null, "list-entries-page", a, r);
|
|
1891
|
+
i = [t], a.set(e, t);
|
|
1892
|
+
} else {
|
|
1893
|
+
let t = this.#m(n, e);
|
|
1894
|
+
if (t.kind !== "directory" || t.frames.length === 0) return G("INVALID_PAGE_REQUEST", "list-entries-page", e, !1);
|
|
1895
|
+
i = [];
|
|
1896
|
+
for (let e of t.frames) {
|
|
1897
|
+
let t = await this.#C(e, a, r);
|
|
1898
|
+
i.push(t), a.set(t.path, t);
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
let o = [];
|
|
1902
|
+
for (; i.length > 0 && o.length < t;) {
|
|
1903
|
+
q(r, "list-entries-page", e);
|
|
1904
|
+
let t = i.at(-1);
|
|
1905
|
+
if (t === void 0) break;
|
|
1906
|
+
if (t.nextIndex >= t.names.length) {
|
|
1907
|
+
i.pop(), a.delete(t.path);
|
|
1908
|
+
continue;
|
|
1909
|
+
}
|
|
1910
|
+
let n = t.names[t.nextIndex];
|
|
1911
|
+
if (n === void 0) return G("INVALID_SOURCE_DATA", "list-entries-page", t.path, !1);
|
|
1912
|
+
i[i.length - 1] = {
|
|
1913
|
+
...t,
|
|
1914
|
+
lastName: n,
|
|
1915
|
+
nextIndex: t.nextIndex + 1
|
|
1916
|
+
};
|
|
1917
|
+
let s = T(t.path === E ? `/${n}` : `${t.path}/${n}`), c = await this.#O(s, "list-entries-page", a, r);
|
|
1918
|
+
if (c === null) return G("SNAPSHOT_CHANGED", "list-entries-page", s, !0);
|
|
1919
|
+
if (o.push(c), c.type === "directory") {
|
|
1920
|
+
let e = await this.#S(s, null, "list-entries-page", a, r);
|
|
1921
|
+
i.push(e), a.set(s, e);
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
let s = i.length === 0;
|
|
1925
|
+
return {
|
|
1926
|
+
entries: o,
|
|
1927
|
+
isComplete: s,
|
|
1928
|
+
nextCursor: s ? null : this.#h({
|
|
1929
|
+
frames: i.map(({ lastName: e, namesIdentity: t, path: n, pathIdentity: r }) => ({
|
|
1930
|
+
lastName: e,
|
|
1931
|
+
namesIdentity: t,
|
|
1932
|
+
path: n,
|
|
1933
|
+
pathIdentity: r
|
|
1934
|
+
})),
|
|
1935
|
+
kind: "directory",
|
|
1936
|
+
prefix: e,
|
|
1937
|
+
snapshotId: this.snapshot.id,
|
|
1938
|
+
version: 1
|
|
1939
|
+
}),
|
|
1940
|
+
snapshot: this.snapshot
|
|
1941
|
+
};
|
|
1942
|
+
}
|
|
1943
|
+
async #y(e, t, n, r) {
|
|
1944
|
+
let i = null;
|
|
1945
|
+
if (n !== void 0) {
|
|
1946
|
+
let t = this.#m(n, e);
|
|
1947
|
+
if (t.kind !== "paths" || !this.#c.has(t.lastPath)) return G("INVALID_PAGE_REQUEST", "list-entries-page", e, !1);
|
|
1948
|
+
i = t.lastPath;
|
|
1949
|
+
}
|
|
1950
|
+
let a = e === E ? E : `${e}/`, o = ei(this.#s, i ?? e), s = [];
|
|
1951
|
+
for (; s.length < t;) {
|
|
1952
|
+
q(r, "list-entries-page", e);
|
|
1953
|
+
let t = this.#s[o];
|
|
1954
|
+
if (t === void 0 || !t.startsWith(a)) break;
|
|
1955
|
+
let n = await this.#O(t, "list-entries-page", void 0, r);
|
|
1956
|
+
if (n === null) return G("SNAPSHOT_CHANGED", "list-entries-page", t, !0);
|
|
1957
|
+
s.push(n), o += 1;
|
|
1958
|
+
}
|
|
1959
|
+
let c = this.#s[o], l = c === void 0 || !c.startsWith(a), u = s.at(-1);
|
|
1960
|
+
return !l && u === void 0 ? G("INVALID_SOURCE_DATA", "list-entries-page", e, !1) : {
|
|
1961
|
+
entries: s,
|
|
1962
|
+
isComplete: l,
|
|
1963
|
+
nextCursor: l ? null : this.#h({
|
|
1964
|
+
kind: "paths",
|
|
1965
|
+
lastPath: u?.path ?? e,
|
|
1966
|
+
prefix: e,
|
|
1967
|
+
snapshotId: this.snapshot.id,
|
|
1968
|
+
version: 1
|
|
1969
|
+
}),
|
|
1970
|
+
snapshot: this.snapshot
|
|
1971
|
+
};
|
|
1972
|
+
}
|
|
1973
|
+
#b(e, t, n, r, i) {
|
|
1974
|
+
return (!Number.isSafeInteger(e) || e <= 0) && G("INVALID_PAGE_REQUEST", r, i, !1), e > t && G("RESOURCE_LIMIT_EXCEEDED", r, i, !1, void 0, {
|
|
1975
|
+
dimension: n,
|
|
1976
|
+
limit: t,
|
|
1977
|
+
observed: e
|
|
1978
|
+
}), e;
|
|
1979
|
+
}
|
|
1980
|
+
#x(e, t) {
|
|
1981
|
+
return (!Number.isSafeInteger(e) || e < 0) && G("INVALID_PAGE_REQUEST", "read-file-page", t, !1), e;
|
|
1982
|
+
}
|
|
1983
|
+
async #S(e, t, n, r, i) {
|
|
1984
|
+
let a = await this.#O(e, n, r, i);
|
|
1985
|
+
(a === null || a.type !== "directory") && G("SNAPSHOT_CHANGED", n, e, !0);
|
|
1986
|
+
let o = await this.#w(e, n, r, i), s = t === null ? 0 : ti(o, t) + 1;
|
|
1987
|
+
return s === 0 && t !== null && G("SNAPSHOT_CHANGED", n, e, !0), {
|
|
1988
|
+
lastName: t,
|
|
1989
|
+
names: o,
|
|
1990
|
+
namesIdentity: Jr(o),
|
|
1991
|
+
nextIndex: s,
|
|
1992
|
+
path: e,
|
|
1993
|
+
pathIdentity: this.#i.get(e) ?? ""
|
|
1994
|
+
};
|
|
1995
|
+
}
|
|
1996
|
+
async #C(e, t, n) {
|
|
1997
|
+
let r = await this.#S(T(e.path), e.lastName, "list-entries-page", t, n);
|
|
1998
|
+
return (r.pathIdentity !== e.pathIdentity || r.namesIdentity !== e.namesIdentity) && G("SNAPSHOT_CHANGED", "list-entries-page", e.path, !0), r;
|
|
1999
|
+
}
|
|
2000
|
+
async #w(e, t, n, r) {
|
|
2001
|
+
try {
|
|
2002
|
+
let i = await Qr(this.#g(e)), a = [], o = 0;
|
|
2003
|
+
for await (let n of i) {
|
|
2004
|
+
q(r, t, e), o += 1, o > this.#r.maxDirectoryEntries && G("RESOURCE_LIMIT_EXCEEDED", t, e, !1, void 0, {
|
|
2005
|
+
dimension: "directoryEntries",
|
|
2006
|
+
limit: this.#r.maxDirectoryEntries,
|
|
2007
|
+
observed: o
|
|
2008
|
+
});
|
|
2009
|
+
let i = Zr(n.name, t, e);
|
|
2010
|
+
i !== ".git" && a.push(i);
|
|
2011
|
+
}
|
|
2012
|
+
return await this.#O(e, t, n, r), a.sort();
|
|
2013
|
+
} catch (n) {
|
|
2014
|
+
if (n instanceof w) throw n;
|
|
2015
|
+
return K(n, t, e);
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
async #T(e, t, n, r, i, a) {
|
|
2019
|
+
let o = i?.get(e);
|
|
2020
|
+
if (o !== void 0) return o.pathIdentity !== r && G("SNAPSHOT_CHANGED", n, e, !0), ti(o.names, t) >= 0;
|
|
2021
|
+
let s = this.#u.get(e), c = s?.has(t) === !0, l = c ? this.#d.get(e) : void 0;
|
|
2022
|
+
if (l !== void 0) return l.identity !== r && G("SNAPSHOT_CHANGED", n, e, !0), q(a, n, e), l.names.has(t);
|
|
2023
|
+
try {
|
|
2024
|
+
let i = await Qr(this.#g(e)), o = c && s !== void 0 ? s : new Set([t]), l = new Set(), u = 0;
|
|
2025
|
+
for await (let t of i) {
|
|
2026
|
+
q(a, n, e), u += 1, u > this.#r.maxDirectoryEntries && G("RESOURCE_LIMIT_EXCEEDED", n, e, !1, void 0, {
|
|
2027
|
+
dimension: "directoryEntries",
|
|
2028
|
+
limit: this.#r.maxDirectoryEntries,
|
|
2029
|
+
observed: u
|
|
2030
|
+
});
|
|
2031
|
+
let r;
|
|
2032
|
+
try {
|
|
2033
|
+
r = Zr(t.name, n, e);
|
|
2034
|
+
} catch (e) {
|
|
2035
|
+
if (e instanceof w && e.code === "INVALID_SOURCE_DATA") continue;
|
|
2036
|
+
throw e;
|
|
2037
|
+
}
|
|
2038
|
+
if (r !== ".git" && o.has(r) && (l.add(r), l.size === o.size)) break;
|
|
2039
|
+
}
|
|
2040
|
+
if (c) {
|
|
2041
|
+
let t = await k(this.#g(e), { bigint: !0 });
|
|
2042
|
+
(!t.isDirectory() || J(t, "directory") !== r) && G("SNAPSHOT_CHANGED", n, e, !0), this.#d.set(e, {
|
|
2043
|
+
identity: r,
|
|
2044
|
+
names: l
|
|
2045
|
+
});
|
|
2046
|
+
}
|
|
2047
|
+
return q(a, n, e), l.has(t);
|
|
2048
|
+
} catch (t) {
|
|
2049
|
+
if (t instanceof w) throw t;
|
|
2050
|
+
return K(t, n, e);
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
async #E(e, t, n, r) {
|
|
2054
|
+
let i = await this.#D(t, e);
|
|
2055
|
+
if (e === E) return i;
|
|
2056
|
+
let a = e.slice(1).split("/"), o = E, s = null, c = [];
|
|
2057
|
+
for (let [l, u] of a.entries()) {
|
|
2058
|
+
q(r, t, e);
|
|
2059
|
+
let d = J(s ?? i, "directory");
|
|
2060
|
+
if (!await this.#T(o, u, t, d, n, r)) return null;
|
|
2061
|
+
o = T(o === E ? `/${u}` : `${o}/${u}`);
|
|
2062
|
+
try {
|
|
2063
|
+
s = await k(this.#g(o), { bigint: !0 });
|
|
2064
|
+
} catch (e) {
|
|
2065
|
+
return K(e, t, o);
|
|
2066
|
+
}
|
|
2067
|
+
if (l < a.length - 1 && !s.isDirectory()) return null;
|
|
2068
|
+
l < a.length - 1 && c.push({
|
|
2069
|
+
identity: J(s, "directory"),
|
|
2070
|
+
path: o
|
|
2071
|
+
});
|
|
2072
|
+
}
|
|
2073
|
+
for (let n of c) {
|
|
2074
|
+
q(r, t, e);
|
|
2075
|
+
let i;
|
|
2076
|
+
try {
|
|
2077
|
+
i = await k(this.#g(n.path), { bigint: !0 });
|
|
2078
|
+
} catch (e) {
|
|
2079
|
+
return K(e, t, n.path);
|
|
2080
|
+
}
|
|
2081
|
+
if (!i.isDirectory() || J(i, "directory") !== n.identity) return G("SNAPSHOT_CHANGED", t, n.path, !0);
|
|
2082
|
+
}
|
|
2083
|
+
return await this.#D(t, e), s;
|
|
2084
|
+
}
|
|
2085
|
+
async #D(e, t) {
|
|
2086
|
+
try {
|
|
2087
|
+
let n = await k(this.#a, { bigint: !0 }), r = this.#i.get(E);
|
|
2088
|
+
return !n.isDirectory() || r === void 0 || J(n, "directory") !== r ? G("SNAPSHOT_CHANGED", e, t, !0) : n;
|
|
2089
|
+
} catch (n) {
|
|
2090
|
+
if (n instanceof w) throw n;
|
|
2091
|
+
return K(n, e, t);
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
async #O(e, t, n, r) {
|
|
2095
|
+
let i = await this.#E(e, t, n, r);
|
|
2096
|
+
if (q(r, t, e), i === null) return this.#i.has(e) ? G("SNAPSHOT_CHANGED", t, e, !0) : null;
|
|
2097
|
+
let a = Xr(i, t, e), o = J(i, a), s = this.#i.get(e);
|
|
2098
|
+
return s !== void 0 && s !== o && G("SNAPSHOT_CHANGED", t, e, !0), s === void 0 && (this.#i.size - 1 >= this.#r.maxEntries && G("RESOURCE_LIMIT_EXCEEDED", t, e, !1, void 0, {
|
|
2099
|
+
dimension: "observedEntries",
|
|
2100
|
+
limit: this.#r.maxEntries,
|
|
2101
|
+
observed: this.#i.size
|
|
2102
|
+
}), this.#i.set(e, o)), {
|
|
2103
|
+
byteLength: a === "file" ? Number(i.size) : null,
|
|
2104
|
+
contentIdentity: null,
|
|
2105
|
+
path: e,
|
|
2106
|
+
type: a
|
|
2107
|
+
};
|
|
2108
|
+
}
|
|
2109
|
+
async #k(e, t, n, r, i) {
|
|
2110
|
+
let a;
|
|
2111
|
+
try {
|
|
2112
|
+
let o = "O_NOFOLLOW" in Ae ? Ae.O_NOFOLLOW : 0;
|
|
2113
|
+
a = await Le(this.#g(e), Ae.O_RDONLY | o);
|
|
2114
|
+
let s = await a.stat({ bigint: !0 });
|
|
2115
|
+
J(s, Xr(s, "read-file-page", e)) !== t && G("SNAPSHOT_CHANGED", "read-file-page", e, !0);
|
|
2116
|
+
let c = new Uint8Array(r), l = 0;
|
|
2117
|
+
for (; l < r;) {
|
|
2118
|
+
q(i, "read-file-page", e);
|
|
2119
|
+
let t = await a.read(c, l, r - l, n + l);
|
|
2120
|
+
t.bytesRead === 0 && G("SNAPSHOT_CHANGED", "read-file-page", e, !0), l += t.bytesRead;
|
|
2121
|
+
}
|
|
2122
|
+
let u = await a.stat({ bigint: !0 });
|
|
2123
|
+
return J(u, Xr(u, "read-file-page", e)) !== t && G("SNAPSHOT_CHANGED", "read-file-page", e, !0), await this.#O(e, "read-file-page"), c;
|
|
2124
|
+
} catch (t) {
|
|
2125
|
+
if (t instanceof w) throw t;
|
|
2126
|
+
return K(t, "read-file-page", e);
|
|
2127
|
+
} finally {
|
|
2128
|
+
await a?.close().catch(() => void 0);
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
async #A(e, n, r, i) {
|
|
2132
|
+
let a = !1;
|
|
2133
|
+
try {
|
|
2134
|
+
return await this.#n.run(async () => (a = !0, q(r, e, n), i()), r === void 0 ? {} : { signal: r });
|
|
2135
|
+
} catch (r) {
|
|
2136
|
+
if (a) throw r;
|
|
2137
|
+
return Yr(r) === t.REQUEST_QUEUE_FULL ? G("RESOURCE_LIMIT_EXCEEDED", e, n, !0, void 0, {
|
|
2138
|
+
dimension: "queuedOperations",
|
|
2139
|
+
limit: this.#r.maxQueuedOperations,
|
|
2140
|
+
observed: this.#r.maxQueuedOperations + 1
|
|
2141
|
+
}) : G("ABORTED", e, n, !1, r);
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
}, ri = async (e) => {
|
|
2145
|
+
q(e.signal, "create-reader", null);
|
|
2146
|
+
try {
|
|
2147
|
+
let t = await Ve(e.rootDirectory), n = await k(t, { bigint: !0 });
|
|
2148
|
+
return n.isDirectory() || G("ENTRY_NOT_DIRECTORY", "create-reader", null, !1), {
|
|
2149
|
+
identity: J(n, "directory"),
|
|
2150
|
+
rootDirectory: t
|
|
2151
|
+
};
|
|
2152
|
+
} catch (e) {
|
|
2153
|
+
if (e instanceof w) throw e;
|
|
2154
|
+
return K(e, "create-reader", null);
|
|
2155
|
+
}
|
|
2156
|
+
}, ii = async (e) => {
|
|
2157
|
+
let t = Vr(e), n = await ri(t), r = new ni(t, n.rootDirectory, n.identity);
|
|
2158
|
+
return await r.initialize(t.signal), q(t.signal, "create-reader", null), Object.freeze(r);
|
|
2159
|
+
}, ai = new TextDecoder("utf-8", {
|
|
2160
|
+
fatal: !0,
|
|
2161
|
+
ignoreBOM: !0
|
|
2162
|
+
}), Y = (e, t, n) => {
|
|
2163
|
+
if (e?.aborted) throw new w({
|
|
2164
|
+
cause: e.reason,
|
|
2165
|
+
code: "ABORTED",
|
|
2166
|
+
operation: t,
|
|
2167
|
+
path: n,
|
|
2168
|
+
retryable: !1
|
|
2169
|
+
});
|
|
2170
|
+
}, oi = (e, t) => new w({
|
|
2171
|
+
code: "INVALID_SOURCE_DATA",
|
|
2172
|
+
operation: e,
|
|
2173
|
+
path: t,
|
|
2174
|
+
retryable: !1
|
|
2175
|
+
}), si = (e, t, n) => {
|
|
2176
|
+
if (e?.type !== "file" || e.path !== n) throw oi(t, n);
|
|
2177
|
+
}, ci = (e, t, n) => (si(e, t, n), Object.freeze({
|
|
2178
|
+
byteLength: null,
|
|
2179
|
+
contentIdentity: null,
|
|
2180
|
+
path: n,
|
|
2181
|
+
type: "symlink"
|
|
2182
|
+
})), li = class {
|
|
2183
|
+
snapshot;
|
|
2184
|
+
#e;
|
|
2185
|
+
#t;
|
|
2186
|
+
constructor(e, t) {
|
|
2187
|
+
this.#t = e, this.#e = t, this.snapshot = e.snapshot;
|
|
2188
|
+
}
|
|
2189
|
+
compare(e, t) {
|
|
2190
|
+
return De(this, e, t);
|
|
2191
|
+
}
|
|
2192
|
+
async getEntry(e, t) {
|
|
2193
|
+
let n = await this.#t.getEntry(e, t);
|
|
2194
|
+
return this.#e.has(e) ? ci(n, "get-entry", e) : n;
|
|
2195
|
+
}
|
|
2196
|
+
async readFilePage(e, t) {
|
|
2197
|
+
let n = T(e);
|
|
2198
|
+
if (!this.#e.has(n)) return this.#t.readFilePage(n, t);
|
|
2199
|
+
throw Y(t.signal, "read-file-page", n), si(await this.#t.getEntry(n, t), "read-file-page", n), Y(t.signal, "read-file-page", n), new w({
|
|
2200
|
+
code: "ENTRY_NOT_FILE",
|
|
2201
|
+
operation: "read-file-page",
|
|
2202
|
+
path: n,
|
|
2203
|
+
retryable: !1
|
|
2204
|
+
});
|
|
2205
|
+
}
|
|
2206
|
+
async readLinkText(e, t) {
|
|
2207
|
+
let n = T(e);
|
|
2208
|
+
if (!this.#e.has(n)) return this.#t.readLinkText(n, t);
|
|
2209
|
+
Y(t?.signal, "read-link-text", n);
|
|
2210
|
+
let r = await this.#t.getEntry(n, t);
|
|
2211
|
+
si(r, "read-link-text", n), Y(t?.signal, "read-link-text", n);
|
|
2212
|
+
let i = r?.byteLength ?? null;
|
|
2213
|
+
if (i === null) throw oi("read-link-text", n);
|
|
2214
|
+
if (i > 4096) return null;
|
|
2215
|
+
if (i === 0) return "";
|
|
2216
|
+
let a = await this.#t.readFilePage(n, {
|
|
2217
|
+
maxBytes: i,
|
|
2218
|
+
offset: 0,
|
|
2219
|
+
...t?.signal === void 0 ? {} : { signal: t.signal }
|
|
2220
|
+
});
|
|
2221
|
+
if (Y(t?.signal, "read-link-text", n), !a.isComplete || a.totalBytes !== i || a.bytes.byteLength !== i) throw oi("read-link-text", n);
|
|
2222
|
+
try {
|
|
2223
|
+
return ai.decode(a.bytes);
|
|
2224
|
+
} catch {
|
|
2225
|
+
return null;
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
async listEntriesPage(e) {
|
|
2229
|
+
let t = e.prefix === void 0 ? E : T(e.prefix);
|
|
2230
|
+
if (this.#e.has(t)) {
|
|
2231
|
+
Y(e.signal, "list-entries-page", t);
|
|
2232
|
+
let n = e.signal === void 0 ? void 0 : { signal: e.signal };
|
|
2233
|
+
throw si(await this.#t.getEntry(t, n), "list-entries-page", t), Y(e.signal, "list-entries-page", t), new w({
|
|
2234
|
+
code: "ENTRY_NOT_DIRECTORY",
|
|
2235
|
+
operation: "list-entries-page",
|
|
2236
|
+
path: t,
|
|
2237
|
+
retryable: !1
|
|
2238
|
+
});
|
|
2239
|
+
}
|
|
2240
|
+
let n = await this.#t.listEntriesPage(e), r = n.entries.map((e) => this.#e.has(e.path) ? ci(e, "list-entries-page", e.path) : e);
|
|
2241
|
+
return Object.freeze({
|
|
2242
|
+
entries: Object.freeze(r),
|
|
2243
|
+
isComplete: n.isComplete,
|
|
2244
|
+
nextCursor: n.nextCursor,
|
|
2245
|
+
snapshot: this.snapshot
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
}, ui = (e, t) => {
|
|
2249
|
+
let n = new Set();
|
|
2250
|
+
for (let e of t) {
|
|
2251
|
+
let t = T(e);
|
|
2252
|
+
if (t === E) throw new w({
|
|
2253
|
+
code: "INVALID_SOURCE_DATA",
|
|
2254
|
+
operation: "create-reader",
|
|
2255
|
+
path: t,
|
|
2256
|
+
retryable: !1
|
|
2257
|
+
});
|
|
2258
|
+
n.add(t);
|
|
2259
|
+
}
|
|
2260
|
+
return Object.freeze(new li(e, n));
|
|
2261
|
+
}, di = async (e, t, n, r) => {
|
|
2262
|
+
let i = Object.freeze(e.entries.map((e) => e.path)), a = Object.freeze(e.entries.reduce((e, t) => (t.requiresSymlinkOverlay && e.push(t.path), e), [])), o = Object.freeze(e.entries.reduce((e, t) => (t.contentTransformation.isGuarded && e.push(t.path), e), []));
|
|
2263
|
+
return r(n(await t({
|
|
2264
|
+
limits: Object.freeze({
|
|
2265
|
+
maxCachedBytes: e.resourceLimits.maxTotalBytes,
|
|
2266
|
+
maxDirectoryEntries: e.resourceLimits.maxEntries,
|
|
2267
|
+
maxEntries: e.resourceLimits.maxEntries,
|
|
2268
|
+
maxPageEntries: Math.min(4096, e.resourceLimits.maxEntries),
|
|
2269
|
+
maxReadBytes: e.resourceLimits.maxFileBytes
|
|
2270
|
+
}),
|
|
2271
|
+
rootDirectory: e.repositoryRoot,
|
|
2272
|
+
selection: Object.freeze({
|
|
2273
|
+
kind: "paths",
|
|
2274
|
+
paths: i
|
|
2275
|
+
}),
|
|
2276
|
+
...e.signal === void 0 ? {} : { signal: e.signal }
|
|
2277
|
+
}), a), o);
|
|
2278
|
+
}, fi = ((e = ii, t = ui, n = Xt) => (r) => di(r, e, t, n))(), pi = ((e = ii, t = ui, n = Xt) => (r) => di(r, e, t, n))(), X = (e, t) => Object.freeze({
|
|
2279
|
+
errorCode: e,
|
|
2280
|
+
kind: "failed",
|
|
2281
|
+
...t === void 0 ? {} : { subcommand: t }
|
|
2282
|
+
}), mi = (e) => e instanceof w && e.code === "SNAPSHOT_CHANGED", hi = (e) => e instanceof w && e.operation === "create-reader" && (e.code === "ENTRY_NOT_FOUND" || e.code === "ENTRY_NOT_DIRECTORY"), gi = (e) => e === "GIT_REPOSITORY_NOT_FOUND" || e === "GIT_WORK_TREE_REQUIRED", _i = ((e = Ot, t = xr, n = fi, r = Tr, i = pi) => async (a) => {
|
|
2283
|
+
if (a.signal?.aborted) return X("GIT_OPERATION_ABORTED");
|
|
2284
|
+
let o = a.repositoryRoot, s = Object.freeze({ ...a.resourceLimits }), c = await e({
|
|
2285
|
+
repositoryRoot: o,
|
|
2286
|
+
...a.signal === void 0 ? {} : { signal: a.signal }
|
|
2287
|
+
});
|
|
2288
|
+
if (a.signal?.aborted) return X("GIT_OPERATION_ABORTED");
|
|
2289
|
+
if (c.kind === "failed") return X(c.errorCode);
|
|
2290
|
+
if (c.kind === "mismatched") return X("GIT_OUTPUT_INVALID");
|
|
2291
|
+
let l = c.identity, u = async () => {
|
|
2292
|
+
let e = await t({
|
|
2293
|
+
maxEntries: s.maxEntries,
|
|
2294
|
+
maxMetadataBytes: s.maxTotalBytes,
|
|
2295
|
+
repositoryRoot: o,
|
|
2296
|
+
...a.selectionPaths === void 0 ? {} : { selectionPaths: a.selectionPaths },
|
|
2297
|
+
...a.signal === void 0 ? {} : { signal: a.signal }
|
|
2298
|
+
});
|
|
2299
|
+
return e.kind === "failed" ? X(e.errorCode, e.subcommand) : e;
|
|
2300
|
+
}, d = async () => {
|
|
2301
|
+
if (a.includeInstructions !== !0) return null;
|
|
2302
|
+
let e = await t({
|
|
2303
|
+
includeIgnored: !0,
|
|
2304
|
+
maxEntries: s.maxEntries,
|
|
2305
|
+
maxMetadataBytes: s.maxTotalBytes,
|
|
2306
|
+
repositoryRoot: o,
|
|
2307
|
+
selectionPaths: on,
|
|
2308
|
+
...a.signal === void 0 ? {} : { signal: a.signal }
|
|
2309
|
+
});
|
|
2310
|
+
return e.kind === "failed" ? X(e.errorCode, e.subcommand) : e;
|
|
2311
|
+
};
|
|
2312
|
+
for (let t = 0; t < 3; t += 1) {
|
|
2313
|
+
if (a.signal?.aborted) return X("GIT_OPERATION_ABORTED");
|
|
2314
|
+
let t = await e({
|
|
2315
|
+
repositoryRoot: o,
|
|
2316
|
+
...a.signal === void 0 ? {} : { signal: a.signal }
|
|
2317
|
+
});
|
|
2318
|
+
if (a.signal?.aborted) return X("GIT_OPERATION_ABORTED");
|
|
2319
|
+
if (t.kind === "failed") return X(gi(t.errorCode) ? "WORKING_TREE_UNSTABLE" : t.errorCode);
|
|
2320
|
+
if (t.kind === "mismatched" || !xt(l, t.identity)) return X("WORKING_TREE_UNSTABLE");
|
|
2321
|
+
let c = await u();
|
|
2322
|
+
if (a.signal?.aborted) return X("GIT_OPERATION_ABORTED");
|
|
2323
|
+
if (c.kind === "failed") return c;
|
|
2324
|
+
let f = await d();
|
|
2325
|
+
if (a.signal?.aborted) return X("GIT_OPERATION_ABORTED");
|
|
2326
|
+
if (f?.kind === "failed") return f;
|
|
2327
|
+
let p, m;
|
|
2328
|
+
try {
|
|
2329
|
+
p = await n({
|
|
2330
|
+
entries: c.entries,
|
|
2331
|
+
repositoryRoot: o,
|
|
2332
|
+
resourceLimits: s,
|
|
2333
|
+
...a.signal === void 0 ? {} : { signal: a.signal }
|
|
2334
|
+
}), m = f === null ? void 0 : await i({
|
|
2335
|
+
entries: f.entries,
|
|
2336
|
+
repositoryRoot: o,
|
|
2337
|
+
resourceLimits: s,
|
|
2338
|
+
...a.signal === void 0 ? {} : { signal: a.signal }
|
|
2339
|
+
});
|
|
2340
|
+
} catch (e) {
|
|
2341
|
+
if (a.signal?.aborted) return X("GIT_OPERATION_ABORTED");
|
|
2342
|
+
if (mi(e)) continue;
|
|
2343
|
+
if (!hi(e)) throw e;
|
|
2344
|
+
let t = await u();
|
|
2345
|
+
if (a.signal?.aborted) return X("GIT_OPERATION_ABORTED");
|
|
2346
|
+
if (t.kind === "failed") return t;
|
|
2347
|
+
let n = await d();
|
|
2348
|
+
if (a.signal?.aborted) return X("GIT_OPERATION_ABORTED");
|
|
2349
|
+
if (n?.kind === "failed") return n;
|
|
2350
|
+
if (!r(c.entries, t.entries) || f !== null && n !== null && !r(f.entries, n.entries)) continue;
|
|
2351
|
+
throw e;
|
|
2352
|
+
}
|
|
2353
|
+
let h = await u();
|
|
2354
|
+
if (a.signal?.aborted) return X("GIT_OPERATION_ABORTED");
|
|
2355
|
+
if (h.kind === "failed") return h;
|
|
2356
|
+
if (!r(c.entries, h.entries)) continue;
|
|
2357
|
+
let g = await d();
|
|
2358
|
+
if (a.signal?.aborted) return X("GIT_OPERATION_ABORTED");
|
|
2359
|
+
if (g?.kind === "failed") return g;
|
|
2360
|
+
if (!(f !== null && g !== null && !r(f.entries, g.entries))) try {
|
|
2361
|
+
if (a.signal?.aborted) return X("GIT_OPERATION_ABORTED");
|
|
2362
|
+
let e = m === void 0 ? a.signal === void 0 ? await a.operation(p) : await a.operation(p, a.signal) : await a.operation(p, a.signal, m);
|
|
2363
|
+
return a.signal?.aborted ? X("GIT_OPERATION_ABORTED") : Object.freeze({
|
|
2364
|
+
kind: "completed",
|
|
2365
|
+
result: e
|
|
2366
|
+
});
|
|
2367
|
+
} catch (e) {
|
|
2368
|
+
if (a.signal?.aborted) return X("GIT_OPERATION_ABORTED");
|
|
2369
|
+
if (!mi(e)) throw e;
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
return X("WORKING_TREE_UNSTABLE");
|
|
2373
|
+
})(), vi = (e) => Buffer.byteLength(e, "utf8"), yi = (e, t, n, r, i) => n ? vi(r(Object.freeze({
|
|
2374
|
+
cursor: e.cursor,
|
|
2375
|
+
records: Object.freeze([])
|
|
2376
|
+
}))) - 2 + t : vi(i(e)), bi = (e, t, n) => Object.freeze({
|
|
2377
|
+
exitCode: A.Success,
|
|
2378
|
+
stderr: "",
|
|
2379
|
+
stdout: n ? f(e, t) : ae(e, t)
|
|
2380
|
+
}), Z = (e, t, n, r, i) => Object.freeze(r ? {
|
|
2381
|
+
exitCode: i,
|
|
2382
|
+
stderr: "",
|
|
2383
|
+
stdout: ee(e, t, n)
|
|
2384
|
+
} : {
|
|
2385
|
+
exitCode: i,
|
|
2386
|
+
stderr: te(e),
|
|
2387
|
+
stdout: ""
|
|
2388
|
+
}), xi = (e, t, n, r, i) => {
|
|
2389
|
+
let a = ve(e), o = (e) => ({
|
|
2390
|
+
diagnosticCount: a.diagnosticCount,
|
|
2391
|
+
acceptedWarningCount: a.acceptedWarningCount,
|
|
2392
|
+
errorCount: a.errorCount,
|
|
2393
|
+
formatVersion: a.formatVersion,
|
|
2394
|
+
page: e,
|
|
2395
|
+
snapshotDigest: a.snapshotDigest,
|
|
2396
|
+
source: a.source,
|
|
2397
|
+
coverageCounts: a.coverageCounts,
|
|
2398
|
+
valid: a.valid,
|
|
2399
|
+
warningCount: a.warningCount
|
|
2400
|
+
}), s = h({
|
|
2401
|
+
command: "validate",
|
|
2402
|
+
cursor: r,
|
|
2403
|
+
filters: {},
|
|
2404
|
+
maxOutputBytes: i,
|
|
2405
|
+
measure: (e, r) => yi(e, r, n, (e) => de(o(e), t), (e) => ne(o(e))),
|
|
2406
|
+
records: a.records,
|
|
2407
|
+
snapshotDigest: a.snapshotDigest
|
|
2408
|
+
}), c = Object.freeze(o(s));
|
|
2409
|
+
return ot(c), Object.freeze({
|
|
2410
|
+
exitCode: c.valid ? A.Success : A.StructuralInvalid,
|
|
2411
|
+
stderr: "",
|
|
2412
|
+
stdout: n ? de(c, t) : ne(c)
|
|
2413
|
+
});
|
|
2414
|
+
}, Si = (e, t, n, r, i) => {
|
|
2415
|
+
let a = re(e), o = (e) => ({
|
|
2416
|
+
counts: a.counts,
|
|
2417
|
+
formatVersion: a.formatVersion,
|
|
2418
|
+
page: e,
|
|
2419
|
+
project: a.project,
|
|
2420
|
+
snapshotDigest: a.snapshotDigest,
|
|
2421
|
+
source: a.source,
|
|
2422
|
+
coverageCounts: a.coverageCounts,
|
|
2423
|
+
valid: a.valid,
|
|
2424
|
+
view: a.view
|
|
2425
|
+
}), s = h({
|
|
2426
|
+
command: "inspect",
|
|
2427
|
+
cursor: r,
|
|
2428
|
+
filters: {},
|
|
2429
|
+
maxOutputBytes: i,
|
|
2430
|
+
measure: (e, r) => yi(e, r, n, (e) => fe(o(e), t), (e) => u(o(e))),
|
|
2431
|
+
records: a.records,
|
|
2432
|
+
sourceCursorForRecord: a.getSourceCursor,
|
|
2433
|
+
snapshotDigest: a.snapshotDigest
|
|
2434
|
+
}), c = Object.freeze(o(s));
|
|
2435
|
+
return ot(c), Object.freeze({
|
|
2436
|
+
exitCode: e.valid ? A.Success : A.StructuralInvalid,
|
|
2437
|
+
stderr: "",
|
|
2438
|
+
stdout: n ? fe(c, t) : u(c)
|
|
2439
|
+
});
|
|
2440
|
+
}, Ci = (e, t, n, r, i) => {
|
|
2441
|
+
let a = Gt(e), o = (e) => ({
|
|
2442
|
+
counts: a.counts,
|
|
2443
|
+
inputDigest: a.inputDigest,
|
|
2444
|
+
manifestDigest: a.manifestDigest,
|
|
2445
|
+
page: e,
|
|
2446
|
+
relevant: a.relevant,
|
|
2447
|
+
snapshotDigest: a.snapshotDigest,
|
|
2448
|
+
source: v,
|
|
2449
|
+
valid: a.valid
|
|
2450
|
+
}), s = h({
|
|
2451
|
+
command: "scope",
|
|
2452
|
+
cursor: r,
|
|
2453
|
+
filters: { inputDigest: a.inputDigest },
|
|
2454
|
+
maxOutputBytes: i,
|
|
2455
|
+
measure: (e, r) => yi(e, r, n, (e) => c(o(e), t), (e) => ye(o(e))),
|
|
2456
|
+
records: a.records,
|
|
2457
|
+
snapshotDigest: a.snapshotDigest
|
|
2458
|
+
}), l = Object.freeze(o(s));
|
|
2459
|
+
return ot(l, a.canonicalBodies), Object.freeze({
|
|
2460
|
+
exitCode: a.valid ? A.Success : A.StructuralInvalid,
|
|
2461
|
+
stderr: "",
|
|
2462
|
+
stdout: n ? c(l, t) : ye(l)
|
|
2463
|
+
});
|
|
2464
|
+
}, wi = (e, t, n, r, i) => {
|
|
2465
|
+
let a = Rt({
|
|
2466
|
+
cursor: r,
|
|
2467
|
+
maxOutputBytes: i,
|
|
2468
|
+
measure: (e) => vi(n ? d(e, t) : be(e)),
|
|
2469
|
+
page: e
|
|
2470
|
+
});
|
|
2471
|
+
return Object.freeze({
|
|
2472
|
+
exitCode: A.Success,
|
|
2473
|
+
stderr: "",
|
|
2474
|
+
stdout: n ? d(a, t) : be(a)
|
|
2475
|
+
});
|
|
2476
|
+
}, Ti = async (e) => {
|
|
2477
|
+
let { executeMoldeaCliCoreInspection: t } = await import("./chunk-d9e49acd.mjs");
|
|
2478
|
+
return t(e);
|
|
2479
|
+
}, Ei = async (e) => {
|
|
2480
|
+
let { resolveInstalledMoldeaCliComposition: t } = await import("./chunk-517c6bfb.mjs");
|
|
2481
|
+
return t(e);
|
|
2482
|
+
}, Q = (e, t, n) => Z(_(e, n), t.invocation.command, t.packageMetadata.version, t.invocation.options.isJson, A.OperationalError), Di = ((e = _t, t = _i, n = Ti, r = Ei, i = Ht, a = Ft) => async (o) => {
|
|
2483
|
+
let s = o.invocation.command, c = o.invocation.options;
|
|
2484
|
+
try {
|
|
2485
|
+
if (s === m.Composition || s === m.Inspect || s === m.Validate) {
|
|
2486
|
+
let e = await r({
|
|
2487
|
+
packageMetadata: o.packageMetadata,
|
|
2488
|
+
...o.signal === void 0 ? {} : { signal: o.signal }
|
|
2489
|
+
});
|
|
2490
|
+
if (e.kind === "invalid") return Q("COMPOSITION_STATE_INVALID", o);
|
|
2491
|
+
if (s === m.Composition) return bi(e.result, o.packageMetadata.version, c.isJson);
|
|
2492
|
+
}
|
|
2493
|
+
let l = null, u = null, d = 0, f = s === m.Inspect && c.cursor !== null ? b({
|
|
2494
|
+
command: "inspect",
|
|
2495
|
+
cursor: c.cursor,
|
|
2496
|
+
filters: {}
|
|
2497
|
+
}).sourceCursor : null;
|
|
2498
|
+
if (s === m.Scope) {
|
|
2499
|
+
if (c.pathsInput === "path" && c.path !== null) l = Object.freeze([c.path]);
|
|
2500
|
+
else if (c.pathsInput === "stdin" && o.stdin !== void 0) {
|
|
2501
|
+
if (o.stdin.byteLength > c.resourceLimits.maxTotalBytes) return Q("RESOURCE_LIMIT_EXCEEDED", o);
|
|
2502
|
+
l = Bt(o.stdin, c.resourceLimits.maxEntries);
|
|
2503
|
+
} else return Q("PATH_INPUT_INVALID", o);
|
|
2504
|
+
if (l.some((e) => !Ee(e))) return Q("PATH_INPUT_INVALID", o);
|
|
2505
|
+
}
|
|
2506
|
+
if (s === m.Content) {
|
|
2507
|
+
if (c.path === null) return Q("CONTENT_PATH_INVALID", o);
|
|
2508
|
+
if (u = Pt(c.path), c.cursor !== null) {
|
|
2509
|
+
let e = b({
|
|
2510
|
+
command: "content",
|
|
2511
|
+
cursor: c.cursor,
|
|
2512
|
+
filters: { path: u }
|
|
2513
|
+
}).sourceCursor, t = e === null ? null : /^byte:(0|[1-9][0-9]*)$/u.exec(e);
|
|
2514
|
+
if (t === null || (d = Number(t[1]), !Number.isSafeInteger(d))) throw new S("CURSOR_INVALID");
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
let p = await e({
|
|
2518
|
+
invocationDirectory: o.invocationDirectory,
|
|
2519
|
+
repositoryDirectory: c.repositoryDirectory,
|
|
2520
|
+
...o.signal === void 0 ? {} : { signal: o.signal }
|
|
2521
|
+
});
|
|
2522
|
+
if (p.kind === "failed") return Q(p.errorCode, o);
|
|
2523
|
+
let h = c.resourceLimits, g = await t({
|
|
2524
|
+
operation: async (e, t, r) => s === m.Scope && l !== null ? i({
|
|
2525
|
+
paths: l,
|
|
2526
|
+
repository: e,
|
|
2527
|
+
resourceLimits: h,
|
|
2528
|
+
...t === void 0 ? {} : { signal: t }
|
|
2529
|
+
}) : s === m.Content && u !== null ? a({
|
|
2530
|
+
maxBytes: Math.min(h.maxFileBytes, h.maxTotalBytes, Math.max(1, Math.floor(c.maxOutputBytes / 2))),
|
|
2531
|
+
offset: d,
|
|
2532
|
+
path: u,
|
|
2533
|
+
repository: e,
|
|
2534
|
+
resourceLimits: h,
|
|
2535
|
+
...t === void 0 ? {} : { signal: t }
|
|
2536
|
+
}) : n({
|
|
2537
|
+
packageMetadata: o.packageMetadata,
|
|
2538
|
+
command: s === m.Inspect ? "inspect" : "validate",
|
|
2539
|
+
...f === null ? {} : { cursor: f },
|
|
2540
|
+
...r === void 0 ? {} : { instructions: r },
|
|
2541
|
+
repository: e,
|
|
2542
|
+
resourceLimits: h,
|
|
2543
|
+
...t === void 0 ? {} : { signal: t }
|
|
2544
|
+
}),
|
|
2545
|
+
repositoryRoot: p.repositoryRoot,
|
|
2546
|
+
resourceLimits: h,
|
|
2547
|
+
...s === m.Validate || s === m.Inspect ? { includeInstructions: !0 } : {},
|
|
2548
|
+
...s === m.Scope ? { selectionPaths: [P] } : u === null ? {} : { selectionPaths: [u] },
|
|
2549
|
+
...o.signal === void 0 ? {} : { signal: o.signal }
|
|
2550
|
+
});
|
|
2551
|
+
return g.kind === "failed" ? Q(g.errorCode, o, g.subcommand === void 0 ? void 0 : { subcommand: g.subcommand }) : s === m.Validate ? xi(g.result, o.packageMetadata.version, c.isJson, c.cursor, c.maxOutputBytes) : s === m.Inspect ? Si(g.result, o.packageMetadata.version, c.isJson, c.cursor, c.maxOutputBytes) : s === m.Scope ? Ci(g.result, o.packageMetadata.version, c.isJson, c.cursor, c.maxOutputBytes) : wi(g.result, o.packageMetadata.version, c.isJson, c.cursor, c.maxOutputBytes);
|
|
2552
|
+
} catch (e) {
|
|
2553
|
+
return Z(nn(e), s, o.packageMetadata.version, c.isJson, A.OperationalError);
|
|
2554
|
+
}
|
|
2555
|
+
})(), Oi = async (e) => {
|
|
2556
|
+
let t = y(e.commandLineArguments);
|
|
2557
|
+
if (t.kind === "help") return {
|
|
2558
|
+
exitCode: A.Success,
|
|
2559
|
+
stderr: "",
|
|
2560
|
+
stdout: xe(t.command)
|
|
2561
|
+
};
|
|
2562
|
+
if (t.kind === "version") return {
|
|
2563
|
+
exitCode: A.Success,
|
|
2564
|
+
stderr: "",
|
|
2565
|
+
stdout: `${e.packageMetadata.version}\n`
|
|
2566
|
+
};
|
|
2567
|
+
if (t.kind === "error") return Z(_(t.code), t.command, e.packageMetadata.version, t.isJson, A.UsageError);
|
|
2568
|
+
let n = e.executeCommand ?? Di;
|
|
2569
|
+
try {
|
|
2570
|
+
let r;
|
|
2571
|
+
if (t.invocation.options.pathsInput === "stdin") {
|
|
2572
|
+
if (e.readStdin === void 0) return Z(_("PATH_INPUT_INVALID"), t.invocation.command, e.packageMetadata.version, t.invocation.options.isJson, A.UsageError);
|
|
2573
|
+
let n = await e.readStdin(t.invocation.options.resourceLimits.maxTotalBytes, e.signal);
|
|
2574
|
+
if (n.kind === "limit-exceeded") return Z(_("RESOURCE_LIMIT_EXCEEDED"), t.invocation.command, e.packageMetadata.version, t.invocation.options.isJson, A.OperationalError);
|
|
2575
|
+
r = n.bytes;
|
|
2576
|
+
}
|
|
2577
|
+
return await n({
|
|
2578
|
+
invocationDirectory: e.invocationDirectory,
|
|
2579
|
+
invocation: t.invocation,
|
|
2580
|
+
packageMetadata: e.packageMetadata,
|
|
2581
|
+
...e.signal === void 0 ? {} : { signal: e.signal },
|
|
2582
|
+
...r === void 0 ? {} : { stdin: r }
|
|
2583
|
+
});
|
|
2584
|
+
} catch {
|
|
2585
|
+
return Z(_("INTERNAL_ERROR"), t.invocation.command, e.packageMetadata.version, t.invocation.options.isJson, A.OperationalError);
|
|
2586
|
+
}
|
|
2587
|
+
};
|
|
2588
|
+
ie();
|
|
2589
|
+
//#endregion
|
|
2590
|
+
//#region src/bin/index.ts
|
|
2591
|
+
var ki = D.dirname(ke(import.meta.url));
|
|
2592
|
+
D.resolve(ki, "..", "package.json");
|
|
2593
|
+
var $ = et({ setExitCode: !1 }), Ai = async (e, t) => {
|
|
2594
|
+
try {
|
|
2595
|
+
return {
|
|
2596
|
+
bytes: await tt({
|
|
2597
|
+
maxBytes: e,
|
|
2598
|
+
signal: t
|
|
2599
|
+
}),
|
|
2600
|
+
kind: "completed"
|
|
2601
|
+
};
|
|
2602
|
+
} catch (e) {
|
|
2603
|
+
if (i(e, x.STDIN_TOO_LARGE)) return { kind: "limit-exceeded" };
|
|
2604
|
+
if (t?.aborted === !0) return {
|
|
2605
|
+
bytes: new Uint8Array(),
|
|
2606
|
+
kind: "completed"
|
|
2607
|
+
};
|
|
2608
|
+
throw e;
|
|
2609
|
+
}
|
|
2610
|
+
}, ji = async (e, t) => {
|
|
2611
|
+
t.length !== 0 && await new Promise((n, r) => {
|
|
2612
|
+
e.write(t, (e) => {
|
|
2613
|
+
if (e) {
|
|
2614
|
+
r(e);
|
|
2615
|
+
return;
|
|
2616
|
+
}
|
|
2617
|
+
n();
|
|
2618
|
+
});
|
|
2619
|
+
});
|
|
2620
|
+
};
|
|
2621
|
+
try {
|
|
2622
|
+
let e = O.cwd(), t = await Oi({
|
|
2623
|
+
commandLineArguments: O.argv.slice(2),
|
|
2624
|
+
invocationDirectory: e,
|
|
2625
|
+
packageMetadata: {
|
|
2626
|
+
dependencies: {
|
|
2627
|
+
"@moldea.ai/core": "workspace:^10.0.0",
|
|
2628
|
+
"@moldea.ai/repository": "workspace:^4.0.0",
|
|
2629
|
+
"@moldea.ai/repository-fs": "workspace:^4.0.0",
|
|
2630
|
+
"jg-crypto": "0.3.0",
|
|
2631
|
+
"jg-exception": "1.7.1",
|
|
2632
|
+
"jg-git-commands": "0.4.0",
|
|
2633
|
+
"jg-process": "1.6.2",
|
|
2634
|
+
"jg-utilities": "1.7.2",
|
|
2635
|
+
semver: "7.8.5"
|
|
2636
|
+
},
|
|
2637
|
+
installedPackageVersions: {
|
|
2638
|
+
"@moldea.ai/core": "10.0.0",
|
|
2639
|
+
"@moldea.ai/repository": "4.0.1",
|
|
2640
|
+
"@moldea.ai/repository-fs": "4.0.1"
|
|
2641
|
+
},
|
|
2642
|
+
supportedNodeRange: ">=22.17.0",
|
|
2643
|
+
version: "14.0.1"
|
|
2644
|
+
},
|
|
2645
|
+
readStdin: Ai,
|
|
2646
|
+
signal: $.signal
|
|
2647
|
+
});
|
|
2648
|
+
$.receivedSignal() === null && (await ji(O.stdout, t.stdout), $.receivedSignal() === null && await ji(O.stderr, t.stderr)), O.exitCode = $.exitCode() ?? t.exitCode;
|
|
2649
|
+
} catch {
|
|
2650
|
+
let e = $.exitCode();
|
|
2651
|
+
e === null && await ji(O.stderr, te(_("INTERNAL_ERROR"))).catch(() => void 0), O.exitCode = e ?? 3;
|
|
2652
|
+
} finally {
|
|
2653
|
+
$.dispose();
|
|
2654
|
+
}
|
|
2655
|
+
//#endregion
|
|
2656
|
+
export {};
|