@moldea.ai/cli 14.0.1 → 15.0.0

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.
@@ -1,33 +1,33 @@
1
1
  import { n as e, u as t } from "./chunk-2cc3bf5c.mjs";
2
- import { o as n, t as r } from "./chunk-43b8574a.mjs";
3
- import { p as i, u as a } from "./chunk-8f198616.mjs";
4
- import { i as o } from "./chunk-98d84174.mjs";
5
- import { a as s, i as c, l, n as u, o as d, s as f } from "./chunk-24ea7c23.mjs";
6
- import { n as p, r as m, t as h } from "./chunk-cea1378f.mjs";
7
- import { t as g } from "./chunk-2e9d4c63.mjs";
8
- import { fileURLToPath as _ } from "node:url";
9
- import { fork as v } from "node:child_process";
10
- import { randomBytes as y } from "node:crypto";
2
+ import { I as n, V as r, o as i, t as a } from "./chunk-ad32cb41.mjs";
3
+ import { p as o, u as s } from "./chunk-8f198616.mjs";
4
+ import { i as c } from "./chunk-98d84174.mjs";
5
+ import { a as l, i as u, l as d, n as f, o as p, s as m } from "./chunk-24ea7c23.mjs";
6
+ import { n as h, r as g, t as _ } from "./chunk-cea1378f.mjs";
7
+ import { t as v } from "./chunk-2e9d4c63.mjs";
8
+ import { fileURLToPath as y } from "node:url";
9
+ import { fork as b } from "node:child_process";
10
+ import { randomBytes as x } from "node:crypto";
11
11
  //#region ../core/dist/node.js
12
- var b = 0, x = () => {
12
+ var S = 0, C = () => {
13
13
  let e = Promise.withResolvers();
14
14
  return e.promise.catch(() => {}), e;
15
- }, S = (e) => t(e, !0) && typeof e.id == "string" && e.id.length > 0 && typeof e.sourceKind == "string" && e.sourceKind.length > 0, C = (e) => {
15
+ }, w = (e) => t(e, !0) && typeof e.id == "string" && e.id.length > 0 && typeof e.sourceKind == "string" && e.sourceKind.length > 0, T = (e) => {
16
16
  if (e === void 0) return null;
17
- if (!(!t(e, !0) || typeof e.getEntry != "function" || typeof e.readFilePage != "function" || typeof e.readLinkText != "function" || !S(e.snapshot))) return { snapshot: {
17
+ if (!(!t(e, !0) || typeof e.getEntry != "function" || typeof e.readFilePage != "function" || typeof e.readLinkText != "function" || !w(e.snapshot))) return { snapshot: {
18
18
  id: e.snapshot.id,
19
19
  sourceKind: e.snapshot.sourceKind
20
20
  } };
21
- }, w = (t) => new e({
21
+ }, E = (t) => new e({
22
22
  code: "ABORTED",
23
23
  operation: "create-project-inspection",
24
24
  ...t === void 0 ? {} : { cause: t }
25
- }), T = async (t) => {
25
+ }), D = async (t) => {
26
26
  if (typeof t != "object" || !t || t.repository === null || typeof t.repository != "object" || typeof t.repository.getEntry != "function" || typeof t.repository.listEntriesPage != "function" || typeof t.repository.readFilePage != "function" || typeof t.repository.readLinkText != "function" || t.repository.snapshot === null || typeof t.repository.snapshot != "object" || typeof t.repository.snapshot.id != "string" || t.repository.snapshot.id.length === 0 || typeof t.repository.snapshot.sourceKind != "string" || t.repository.snapshot.sourceKind.length === 0) throw new e({
27
27
  code: "INVALID_ARGUMENT",
28
28
  operation: "create-project-inspection"
29
29
  });
30
- let n = C(t.instructions);
30
+ let n = T(t.instructions);
31
31
  if (n === void 0) throw new e({
32
32
  code: "INVALID_ARGUMENT",
33
33
  operation: "create-project-inspection"
@@ -35,15 +35,15 @@ var b = 0, x = () => {
35
35
  let r = {
36
36
  repository: t.repository,
37
37
  ...t.instructions === void 0 ? {} : { instructions: t.instructions }
38
- }, S = {
38
+ }, i = {
39
39
  id: t.repository.snapshot.id,
40
40
  sourceKind: t.repository.snapshot.sourceKind
41
- }, T = t.signal;
42
- if (T !== void 0 && (typeof T != "object" || !T || typeof T.aborted != "boolean" || typeof T.addEventListener != "function" || typeof T.removeEventListener != "function")) throw new e({
41
+ }, a = t.signal;
42
+ if (a !== void 0 && (typeof a != "object" || !a || typeof a.aborted != "boolean" || typeof a.addEventListener != "function" || typeof a.removeEventListener != "function")) throw new e({
43
43
  code: "INVALID_ARGUMENT",
44
44
  operation: "create-project-inspection"
45
45
  });
46
- let { limits: E } = a({ ...t.limits === void 0 ? {} : { limits: t.limits } });
46
+ let { limits: w } = s({ ...t.limits === void 0 ? {} : { limits: t.limits } });
47
47
  if (t.deadline !== void 0 && (!Number.isSafeInteger(t.deadline) || t.deadline < 0)) throw new e({
48
48
  code: "INVALID_ARGUMENT",
49
49
  operation: "create-project-inspection"
@@ -53,31 +53,31 @@ var b = 0, x = () => {
53
53
  code: "INVALID_ARGUMENT",
54
54
  operation: "create-project-inspection"
55
55
  });
56
- if (T?.aborted === !0) throw w(T.reason);
57
- if (b >= O) throw new e({
56
+ if (a?.aborted === !0) throw E(a.reason);
57
+ if (S >= O) throw new e({
58
58
  code: "INSPECTION_BUSY",
59
59
  operation: "create-project-inspection"
60
60
  });
61
- if (E.maxRetainedBytes <= 50331648) throw new e({
61
+ if (w.maxRetainedBytes <= 50331648) throw new e({
62
62
  code: "RESOURCE_LIMIT_EXCEEDED",
63
63
  operation: "create-project-inspection",
64
64
  limit: "maxRetainedBytes",
65
- limitMaximum: E.maxRetainedBytes,
66
- observedUsage: c,
65
+ limitMaximum: w.maxRetainedBytes,
66
+ observedUsage: u,
67
67
  nextAction: "reduce-input-or-increase-limit"
68
68
  });
69
- let k = Math.min(Date.now() + u, t.deadline ?? Infinity);
69
+ let k = Math.min(Date.now() + f, t.deadline ?? Infinity);
70
70
  if (k <= Date.now()) throw new e({
71
71
  code: "INSPECTION_TIMEOUT",
72
72
  operation: "create-project-inspection"
73
73
  });
74
- b++;
75
- let A = new AbortController(), j = y(16).toString("hex"), M = x(), N, P = 0, F = -1, I = !1, L, R = !1, z = !1, B, V, H = new Set(), U = new Set(), W = (() => {
74
+ S++;
75
+ let A = new AbortController(), j = x(16).toString("hex"), M = C(), N, P = 0, F = -1, I = !1, L, R = !1, z = !1, B, V, H = new Set(), U = new Set(), W = (() => {
76
76
  try {
77
- return v(_(new URL("./node-runner.mjs", import.meta.url).href), [], {
77
+ return b(y(new URL("./node-runner.mjs", import.meta.url).href), [], {
78
78
  execPath: process.execPath,
79
79
  execArgv: [],
80
- env: h(),
80
+ env: _(),
81
81
  serialization: "advanced",
82
82
  stdio: [
83
83
  "ignore",
@@ -87,12 +87,12 @@ var b = 0, x = () => {
87
87
  ]
88
88
  });
89
89
  } catch (e) {
90
- throw b--, s(e);
90
+ throw S--, l(e);
91
91
  }
92
- })(), G = p((e, t) => {
93
- if (!W.connected) throw s();
92
+ })(), G = h((e, t) => {
93
+ if (!W.connected) throw l();
94
94
  W.send(e, t);
95
- }), K = m(W, () => {
95
+ }), K = g(W, () => {
96
96
  G({
97
97
  attemptId: j,
98
98
  kind: "dispose"
@@ -103,41 +103,41 @@ var b = 0, x = () => {
103
103
  z = !0, A.abort(B?.cause), K.terminate(), await K.closed, await Promise.allSettled([...H, ...U]), r = void 0, clearTimeout(Z), B === void 0 && Date.now() >= k && J(new e({
104
104
  code: "INSPECTION_TIMEOUT",
105
105
  operation: "create-project-inspection"
106
- })), T?.removeEventListener("abort", X), W.removeAllListeners("message"), W.removeAllListeners("error"), W.stderr?.removeAllListeners("data"), b--;
106
+ })), a?.removeEventListener("abort", X), W.removeAllListeners("message"), W.removeAllListeners("error"), W.stderr?.removeAllListeners("data"), S--;
107
107
  })(), V), J = (e) => {
108
- B === void 0 && (B = { cause: e instanceof Error ? e : s(e) }), M.reject(B.cause), N?.reject(B.cause), q();
108
+ B === void 0 && (B = { cause: e instanceof Error ? e : l(e) }), M.reject(B.cause), N?.reject(B.cause), q();
109
109
  }, Y = () => B?.cause, X = () => {
110
- J(w(T?.reason));
110
+ J(E(a?.reason));
111
111
  }, Z = setTimeout(() => {
112
112
  J(new e({
113
113
  code: "INSPECTION_TIMEOUT",
114
114
  operation: "create-project-inspection"
115
115
  }));
116
116
  }, Math.max(1, k - Date.now()));
117
- T?.addEventListener("abort", X, { once: !0 }), T?.aborted === !0 && X(), W.once("error", (e) => {
118
- J(s(e));
117
+ a?.addEventListener("abort", X, { once: !0 }), a?.aborted === !0 && X(), W.once("error", (e) => {
118
+ J(l(e));
119
119
  }), K.closed.then(() => {
120
- z || J(s());
120
+ z || J(l());
121
121
  });
122
122
  let Q = 0;
123
123
  W.stderr?.on("data", (e) => {
124
- Q += e.byteLength, Q > 32768 && J(s());
124
+ Q += e.byteLength, Q > 32768 && J(l());
125
125
  }), W.on("message", (e) => {
126
126
  if (!z) try {
127
- let t = d(e);
128
- if (t.attemptId !== j) throw s();
127
+ let t = p(e);
128
+ if (t.attemptId !== j) throw l();
129
129
  if (t.kind === "ready") {
130
- if (I) throw s();
130
+ if (I) throw l();
131
131
  L = t.maxAnalysisHeapBytes, I = !0, G({
132
132
  attemptId: j,
133
133
  kind: "run"
134
134
  }).catch(J);
135
135
  } else if (t.kind === "prepared") {
136
- if (!I || R || t.inspection.maxAnalysisHeapBytes !== L || t.inspection.source.id !== S.id || t.inspection.source.sourceKind !== S.sourceKind) throw s();
137
- R = !0, M.resolve(i(t.inspection));
136
+ if (!I || R || t.inspection.maxAnalysisHeapBytes !== L || t.inspection.source.id !== i.id || t.inspection.source.sourceKind !== i.sourceKind) throw l();
137
+ R = !0, M.resolve(o(t.inspection));
138
138
  } else if (t.kind === "reader-request") {
139
- if (!I || R || t.requestId !== F + 1 || H.size >= 4 || (F = t.requestId, r === void 0)) throw s();
140
- let e = g(r, t.request, A.signal);
139
+ if (!I || R || t.requestId !== F + 1 || H.size >= 4 || (F = t.requestId, r === void 0)) throw l();
140
+ let e = v(r, t.request, A.signal);
141
141
  H.add(e);
142
142
  let n = (async () => {
143
143
  try {
@@ -149,7 +149,7 @@ var b = 0, x = () => {
149
149
  result: n
150
150
  });
151
151
  } catch (e) {
152
- if (e instanceof o && [
152
+ if (e instanceof c && [
153
153
  "ENTRY_NOT_FOUND",
154
154
  "ENTRY_NOT_FILE",
155
155
  "RESOURCE_LIMIT_EXCEEDED"
@@ -158,7 +158,7 @@ var b = 0, x = () => {
158
158
  attemptId: j,
159
159
  kind: "reader-failure",
160
160
  requestId: t.requestId,
161
- failure: l(e)
161
+ failure: d(e)
162
162
  });
163
163
  } catch (e) {
164
164
  J(e);
@@ -170,13 +170,13 @@ var b = 0, x = () => {
170
170
  })();
171
171
  U.add(n), n.finally(() => U.delete(n));
172
172
  } else if (t.kind === "page") {
173
- if (!R || N === void 0 || t.requestId !== P) throw s();
173
+ if (!R || N === void 0 || t.requestId !== P) throw l();
174
174
  let e = N;
175
- N = void 0, e.resolve(i(t.result));
175
+ N = void 0, e.resolve(o(t.result));
176
176
  } else if (t.kind === "failure") {
177
- if (t.failure.options.nextAction === "review-inspection-capacity" && (L === void 0 || t.failure.options.limitMaximum !== L)) throw s();
178
- J(f(t.failure));
179
- } else throw s();
177
+ if (t.failure.options.nextAction === "review-inspection-capacity" && (L === void 0 || t.failure.options.limitMaximum !== L)) throw l();
178
+ J(m(t.failure));
179
+ } else throw l();
180
180
  } catch (e) {
181
181
  J(e);
182
182
  }
@@ -185,9 +185,9 @@ var b = 0, x = () => {
185
185
  await G({
186
186
  attemptId: j,
187
187
  kind: "start",
188
- snapshot: S,
188
+ snapshot: i,
189
189
  instructions: n,
190
- limits: E,
190
+ limits: w,
191
191
  deadline: k
192
192
  });
193
193
  let t = await M.promise;
@@ -198,8 +198,8 @@ var b = 0, x = () => {
198
198
  return Object.freeze({
199
199
  ...t,
200
200
  readPage: async (t) => {
201
- if (B !== void 0 || z) throw B?.cause ?? w();
202
- if (N !== void 0 || typeof t != "object" || !t || Reflect.ownKeys(t).some((e) => e !== "cursor" && e !== "maxItems" && e !== "view") || !Number.isSafeInteger(t.maxItems) || t.maxItems < 1 || t.maxItems > E.maxEntries || ![
201
+ if (B !== void 0 || z) throw B?.cause ?? E();
202
+ if (N !== void 0 || typeof t != "object" || !t || Reflect.ownKeys(t).some((e) => e !== "cursor" && e !== "maxItems" && e !== "view") || !Number.isSafeInteger(t.maxItems) || t.maxItems < 1 || t.maxItems > w.maxEntries || ![
203
203
  "all",
204
204
  "diagnostics",
205
205
  "coverage",
@@ -208,7 +208,7 @@ var b = 0, x = () => {
208
208
  code: "INVALID_ARGUMENT",
209
209
  operation: "create-project-inspection"
210
210
  });
211
- let n = x();
211
+ let n = C();
212
212
  N = n, P++;
213
213
  try {
214
214
  if (Date.now() >= k) throw new e({
@@ -232,22 +232,61 @@ var b = 0, x = () => {
232
232
  });
233
233
  return r;
234
234
  } catch (e) {
235
- throw J(e), await q(), Y() ?? s(e);
235
+ throw J(e), await q(), Y() ?? l(e);
236
236
  } finally {
237
237
  N === n && (N = void 0);
238
238
  }
239
239
  },
240
240
  dispose: async () => {
241
- N?.reject(B?.cause ?? w()), await q();
241
+ N?.reject(B?.cause ?? E()), await q();
242
242
  let e = Y();
243
243
  if (e !== void 0) throw e;
244
244
  }
245
245
  });
246
246
  } catch (e) {
247
- throw J(e), await q(), Y() ?? s(e);
247
+ throw J(e), await q(), Y() ?? l(e);
248
248
  }
249
- }, E = (e) => e > Math.floor((2 ** 53 - 1) / 4) ? 2 ** 53 - 1 : e * 4, D = ((e = T) => async (t) => {
250
- let i = await e({
249
+ }, O = "diagnostics-start", k = async (t, i, a) => {
250
+ let { counts: o, coverageCounts: s, formatVersion: c, inspectionDigest: l, valid: u } = t, d = o.metadata + o.diagnostics, f = a === void 0 ? -1 : Number.parseInt(a.lastKey, 36), p = f + 1, m = a?.sourceCursor ?? null;
251
+ if (a !== void 0) {
252
+ if (a.snapshotDigest !== l) throw new r("CURSOR_SNAPSHOT_CHANGED");
253
+ if (!Number.isSafeInteger(f) || f < 0 || n(f) !== a.lastKey || p >= d || m === null || m === O != (p === o.metadata)) throw new r("CURSOR_INVALID");
254
+ }
255
+ m === O && (m = null);
256
+ let h = [];
257
+ for (let [n, a] of [["metadata", o.metadata], ["diagnostics", d]]) {
258
+ let s = p + h.length, c = Math.min(i - h.length, a - s);
259
+ if (c <= 0) continue;
260
+ let l = await t.readPage({
261
+ view: n,
262
+ maxItems: c,
263
+ ...m === null ? {} : { cursor: m }
264
+ }).catch((t) => {
265
+ throw m !== null && t instanceof e && t.code === "INVALID_ARGUMENT" ? new r("CURSOR_INVALID", { cause: t }) : t;
266
+ });
267
+ if (l.page.records.length !== c) throw m === null ? TypeError("The Core inspection view ended before its reported count.") : new r("CURSOR_INVALID");
268
+ for (let { item: e, nextCursor: t } of l.page.records) {
269
+ if (e.kind !== "metadata" && e.kind !== "diagnostic" || (n === "metadata" ? e.kind !== "metadata" : e.kind !== "diagnostic")) throw m === null ? TypeError("The Core inspection view returned an unexpected record.") : new r("CURSOR_INVALID");
270
+ let i = p + h.length + 1, a = i === d ? null : i === o.metadata ? O : t;
271
+ if (i < d && a === null) throw m === null ? TypeError("The Core inspection view is missing a continuation.") : new r("CURSOR_INVALID");
272
+ h.push({
273
+ item: e,
274
+ nextCursor: a
275
+ });
276
+ }
277
+ m = null;
278
+ }
279
+ return {
280
+ counts: o,
281
+ coverageCounts: s,
282
+ formatVersion: c,
283
+ inspectionDigest: l,
284
+ records: h,
285
+ startIndex: p,
286
+ valid: u
287
+ };
288
+ }, A = (e) => e > Math.floor((2 ** 53 - 1) / 4) ? 2 ** 53 - 1 : e * 4, j = ((e = D) => async (t) => {
289
+ let n = await e({
251
290
  repository: t.repository,
252
291
  ...t.instructions === void 0 ? {} : { instructions: t.instructions },
253
292
  limits: {
@@ -256,47 +295,47 @@ var b = 0, x = () => {
256
295
  maxCoverage: t.resourceLimits.maxCoverage,
257
296
  maxFileBytes: t.resourceLimits.maxFileBytes,
258
297
  maxManifestBytes: t.resourceLimits.maxManifestBytes,
259
- maxRetainedBytes: E(t.resourceLimits.maxTotalBytes),
298
+ maxRetainedBytes: A(t.resourceLimits.maxTotalBytes),
260
299
  maxTotalBytesRead: t.resourceLimits.maxTotalBytes
261
300
  },
262
301
  ...t.signal === void 0 ? {} : { signal: t.signal }
263
- });
302
+ }), o;
264
303
  try {
265
- if (r({ packageMetadata: t.packageMetadata }).kind === "invalid") throw new n();
266
- if (t.command === "inspect") return await i.readPage({
267
- ...t.cursor === void 0 ? {} : { cursor: t.cursor },
268
- maxItems: Math.min(256, t.resourceLimits.maxEntries),
269
- view: "all"
270
- });
271
- let e = [], a = [];
272
- for (let n of ["diagnostics", "coverage"]) {
273
- let r;
304
+ if (a({ packageMetadata: t.packageMetadata }).kind === "invalid") throw new i();
305
+ if (t.command === "inspect") return await k(n, Math.min(256, t.resourceLimits.maxEntries), t.cursor);
306
+ let e = [], r = [];
307
+ for (let i of ["diagnostics", "coverage"]) {
308
+ let a;
274
309
  do {
275
- let o = await i.readPage({
276
- view: n,
310
+ let o = await n.readPage({
311
+ view: i,
277
312
  maxItems: Math.min(256, t.resourceLimits.maxEntries),
278
- ...r === void 0 ? {} : { cursor: r }
313
+ ...a === void 0 ? {} : { cursor: a }
279
314
  });
280
- for (let { item: t } of o.page.records) t.kind === "diagnostic" ? e.push(t.diagnostic) : t.kind === "coverage" && a.push(t.coverage);
281
- r = o.page.nextCursor ?? void 0;
282
- } while (r !== void 0);
315
+ for (let { item: t } of o.page.records) t.kind === "diagnostic" ? e.push(t.diagnostic) : t.kind === "coverage" && r.push(t.coverage);
316
+ a = o.page.nextCursor ?? void 0;
317
+ } while (a !== void 0);
283
318
  }
284
319
  return Object.freeze({
285
320
  diagnostics: Object.freeze(e),
286
- coverage: Object.freeze(a),
287
- coverageCounts: i.coverageCounts,
288
- diagnosticCount: i.counts.diagnostics,
289
- acceptedWarningCount: i.counts.acceptedWarnings,
290
- errorCount: i.counts.errors,
291
- warningCount: i.counts.warnings,
292
- valid: i.valid,
293
- formatVersion: i.formatVersion,
294
- source: i.source,
295
- summary: i.summary
321
+ coverage: Object.freeze(r),
322
+ coverageCounts: n.coverageCounts,
323
+ diagnosticCount: n.counts.diagnostics,
324
+ acceptedWarningCount: n.counts.acceptedWarnings,
325
+ errorCount: n.counts.errors,
326
+ warningCount: n.counts.warnings,
327
+ valid: n.valid,
328
+ formatVersion: n.formatVersion,
329
+ source: n.source,
330
+ summary: n.summary
296
331
  });
332
+ } catch (e) {
333
+ throw e instanceof r && (o = e.cause), e;
297
334
  } finally {
298
- await i.dispose();
335
+ await n.dispose().catch((e) => {
336
+ if (o === void 0 || e !== o) throw e;
337
+ });
299
338
  }
300
339
  })();
301
340
  //#endregion
302
- export { D as executeMoldeaCliCoreInspection };
341
+ export { j as executeMoldeaCliCoreInspection };
@@ -0,0 +1,2 @@
1
+ import { t as e } from "./chunk-d372f5e0.mjs";
2
+ export { e as t };
@@ -1,2 +1,2 @@
1
- import { t as e } from "./chunk-43b8574a.mjs";
1
+ import { t as e } from "./chunk-ad32cb41.mjs";
2
2
  export { e as resolveInstalledMoldeaCliComposition };