@moldea.ai/cli 14.0.0 → 14.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +1 -1
  2. package/dist/chunks/{composition-_3bygS_a.js → composition-BzwNJ346.js} +2 -2
  3. package/dist/chunks/{composition-_3bygS_a.js.map → composition-BzwNJ346.js.map} +1 -1
  4. package/dist/chunks/{composition-D1OYuZ5d.js → composition-aJXeA6un.js} +1 -1
  5. package/dist/chunks/{core-composition-BKcJ--NX.js → core-composition-CzdeqYS9.js} +2 -2
  6. package/dist/chunks/{core-composition-BKcJ--NX.js.map → core-composition-CzdeqYS9.js.map} +1 -1
  7. package/dist/moldea.js +3 -3
  8. package/dist/portable/SHA256SUMS +16 -16
  9. package/dist/portable/analysis-worker.mjs +110 -133
  10. package/dist/portable/chunk-1b3c5f05.mjs +1837 -0
  11. package/dist/portable/chunk-24ea7c23.mjs +328 -0
  12. package/dist/portable/chunk-2cc3bf5c.mjs +399 -0
  13. package/dist/portable/chunk-2e9d4c63.mjs +95 -0
  14. package/dist/portable/chunk-8a1dadf9.mjs +2 -0
  15. package/dist/portable/chunk-8f198616.mjs +4414 -0
  16. package/dist/portable/chunk-936e5d09.mjs +112519 -0
  17. package/dist/portable/chunk-98d84174.mjs +422 -0
  18. package/dist/portable/chunk-a6007228.mjs +302 -0
  19. package/dist/portable/chunk-b1f86976.mjs +2 -0
  20. package/dist/portable/chunk-cea1378f.mjs +50 -0
  21. package/dist/portable/chunk-d372f5e0.mjs +3120 -0
  22. package/dist/portable/chunk-d6656fa6.mjs +14 -0
  23. package/dist/portable/moldea.mjs +1997 -2870
  24. package/dist/portable/node-runner.mjs +77 -106
  25. package/package.json +2 -2
  26. package/dist/portable/chunk-131f8005.mjs +0 -115
  27. package/dist/portable/chunk-2ba7e89e.mjs +0 -26
  28. package/dist/portable/chunk-459da9cf.mjs +0 -4138
  29. package/dist/portable/chunk-728df961.mjs +0 -544
  30. package/dist/portable/chunk-8d6114d2.mjs +0 -588
  31. package/dist/portable/chunk-90403e67.mjs +0 -2
  32. package/dist/portable/chunk-94b5ac22.mjs +0 -59
  33. package/dist/portable/chunk-a5514957.mjs +0 -5870
  34. package/dist/portable/chunk-b98ca669.mjs +0 -2
  35. package/dist/portable/chunk-c13db66a.mjs +0 -380
  36. package/dist/portable/chunk-d5af3eda.mjs +0 -2926
  37. package/dist/portable/chunk-ec3f49d3.mjs +0 -367
  38. package/dist/portable/chunk-fcbcf4e3.mjs +0 -147458
@@ -1,2 +0,0 @@
1
- import { t as core_exports } from "./chunk-459da9cf.mjs";
2
- export { core_exports as t };
@@ -1,380 +0,0 @@
1
- import { n as CoreOperationException, u as isObjectValid } from "./chunk-728df961.mjs";
2
- import { o as MoldeaCliCompositionException, t as resolveInstalledMoldeaCliComposition } from "./chunk-d5af3eda.mjs";
3
- import { p as deepFreeze, u as normalizeCoreOptions } from "./chunk-a5514957.mjs";
4
- import { i as RepositorySourceException } from "./chunk-8d6114d2.mjs";
5
- import { a as createInspectionProcessFailure, i as NODE_INSPECTION_TRANSPORT_BYTES, l as serializeInspectionFailure, n as NODE_INSPECTION_LIFETIME_MS, o as decodeInspectionMessage, s as deserializeInspectionFailure } from "./chunk-ec3f49d3.mjs";
6
- import { n as createInspectionSender, r as superviseInspectionChild, t as createInspectionEnvironment } from "./chunk-94b5ac22.mjs";
7
- import { t as executeRepositoryRpc } from "./chunk-131f8005.mjs";
8
- import { fileURLToPath } from "node:url";
9
- import { fork } from "node:child_process";
10
- import { randomBytes } from "node:crypto";
11
- //#region ../core/dist/node.js
12
- var activeInspectionCount = 0;
13
- var createCompletion = () => {
14
- const completion = Promise.withResolvers();
15
- completion.promise.catch(() => {});
16
- return completion;
17
- };
18
- var isSnapshot = (input) => isObjectValid(input, true) && typeof input["id"] === "string" && input["id"].length > 0 && typeof input["sourceKind"] === "string" && input["sourceKind"].length > 0;
19
- var describeInstructions = (instructions) => {
20
- if (instructions === void 0) return null;
21
- if (!isObjectValid(instructions, true) || typeof instructions["getEntry"] !== "function" || typeof instructions["readFilePage"] !== "function" || typeof instructions["readLinkText"] !== "function" || !isSnapshot(instructions["snapshot"])) return void 0;
22
- return { snapshot: {
23
- id: instructions["snapshot"].id,
24
- sourceKind: instructions["snapshot"].sourceKind
25
- } };
26
- };
27
- var aborted = (cause) => new CoreOperationException({
28
- code: "ABORTED",
29
- operation: "create-project-inspection",
30
- ...cause === void 0 ? {} : { cause }
31
- });
32
- var createNodeProjectInspection = async (input) => {
33
- if (input === null || typeof input !== "object" || input.repository === null || typeof input.repository !== "object" || typeof input.repository.getEntry !== "function" || typeof input.repository.listEntriesPage !== "function" || typeof input.repository.readFilePage !== "function" || typeof input.repository.readLinkText !== "function" || input.repository.snapshot === null || typeof input.repository.snapshot !== "object" || typeof input.repository.snapshot.id !== "string" || input.repository.snapshot.id.length === 0 || typeof input.repository.snapshot.sourceKind !== "string" || input.repository.snapshot.sourceKind.length === 0) throw new CoreOperationException({
34
- code: "INVALID_ARGUMENT",
35
- operation: "create-project-inspection"
36
- });
37
- const instructions = describeInstructions(input.instructions);
38
- if (instructions === void 0) throw new CoreOperationException({
39
- code: "INVALID_ARGUMENT",
40
- operation: "create-project-inspection"
41
- });
42
- let sources = {
43
- repository: input.repository,
44
- ...input.instructions === void 0 ? {} : { instructions: input.instructions }
45
- };
46
- const snapshot = {
47
- id: input.repository.snapshot.id,
48
- sourceKind: input.repository.snapshot.sourceKind
49
- };
50
- const signal = input.signal;
51
- if (signal !== void 0 && (signal === null || typeof signal !== "object" || typeof signal.aborted !== "boolean" || typeof signal.addEventListener !== "function" || typeof signal.removeEventListener !== "function")) throw new CoreOperationException({
52
- code: "INVALID_ARGUMENT",
53
- operation: "create-project-inspection"
54
- });
55
- const { limits } = normalizeCoreOptions({ ...input.limits === void 0 ? {} : { limits: input.limits } });
56
- if (input.deadline !== void 0 && (!Number.isSafeInteger(input.deadline) || input.deadline < 0)) throw new CoreOperationException({
57
- code: "INVALID_ARGUMENT",
58
- operation: "create-project-inspection"
59
- });
60
- const configuredMaximum = input.maxConcurrentInspections;
61
- const maxConcurrentInspections = configuredMaximum === void 0 ? 1 : configuredMaximum;
62
- if (!Number.isSafeInteger(maxConcurrentInspections) || maxConcurrentInspections < 1) throw new CoreOperationException({
63
- code: "INVALID_ARGUMENT",
64
- operation: "create-project-inspection"
65
- });
66
- if (signal?.aborted === true) throw aborted(signal.reason);
67
- if (activeInspectionCount >= maxConcurrentInspections) throw new CoreOperationException({
68
- code: "INSPECTION_BUSY",
69
- operation: "create-project-inspection"
70
- });
71
- if (limits.maxRetainedBytes <= 50331648) throw new CoreOperationException({
72
- code: "RESOURCE_LIMIT_EXCEEDED",
73
- operation: "create-project-inspection",
74
- limit: "maxRetainedBytes",
75
- limitMaximum: limits.maxRetainedBytes,
76
- observedUsage: NODE_INSPECTION_TRANSPORT_BYTES,
77
- nextAction: "reduce-input-or-increase-limit"
78
- });
79
- const deadline = Math.min(Date.now() + NODE_INSPECTION_LIFETIME_MS, input.deadline ?? Infinity);
80
- if (deadline <= Date.now()) throw new CoreOperationException({
81
- code: "INSPECTION_TIMEOUT",
82
- operation: "create-project-inspection"
83
- });
84
- activeInspectionCount++;
85
- const controller = new AbortController();
86
- const attemptId = randomBytes(16).toString("hex");
87
- const prepared = createCompletion();
88
- let pendingPage;
89
- let pageRequestId = 0;
90
- let lastReaderRequestId = -1;
91
- let hasAcknowledgedHeap = false;
92
- let heapMaximum;
93
- let hasPrepared = false;
94
- let isClosing = false;
95
- let failure;
96
- let cleanupPromise;
97
- const readerWork = new Set();
98
- const relayWork = new Set();
99
- const child = (() => {
100
- try {
101
- return fork(fileURLToPath(new URL("./node-runner.mjs", import.meta.url).href), [], {
102
- execPath: process.execPath,
103
- execArgv: [],
104
- env: createInspectionEnvironment(),
105
- serialization: "advanced",
106
- stdio: [
107
- "ignore",
108
- "ignore",
109
- "pipe",
110
- "ipc"
111
- ]
112
- });
113
- } catch (cause) {
114
- activeInspectionCount--;
115
- throw createInspectionProcessFailure(cause);
116
- }
117
- })();
118
- const send = createInspectionSender((frame, callback) => {
119
- if (!child.connected) throw createInspectionProcessFailure();
120
- child.send(frame, callback);
121
- });
122
- const supervision = superviseInspectionChild(child, () => {
123
- send({
124
- attemptId,
125
- kind: "dispose"
126
- }).catch(() => {
127
- child.kill("SIGKILL");
128
- });
129
- });
130
- const cleanup = () => {
131
- cleanupPromise ??= (async () => {
132
- isClosing = true;
133
- controller.abort(failure?.cause);
134
- supervision.terminate();
135
- await supervision.closed;
136
- await Promise.allSettled([...readerWork, ...relayWork]);
137
- sources = void 0;
138
- clearTimeout(timer);
139
- if (failure === void 0 && Date.now() >= deadline) fail(new CoreOperationException({
140
- code: "INSPECTION_TIMEOUT",
141
- operation: "create-project-inspection"
142
- }));
143
- signal?.removeEventListener("abort", handleAbort);
144
- child.removeAllListeners("message");
145
- child.removeAllListeners("error");
146
- child.stderr?.removeAllListeners("data");
147
- activeInspectionCount--;
148
- })();
149
- return cleanupPromise;
150
- };
151
- const fail = (cause) => {
152
- if (failure === void 0) failure = { cause: cause instanceof Error ? cause : createInspectionProcessFailure(cause) };
153
- prepared.reject(failure.cause);
154
- pendingPage?.reject(failure.cause);
155
- cleanup();
156
- };
157
- const getFailureCause = () => failure?.cause;
158
- const handleAbort = () => {
159
- fail(aborted(signal?.reason));
160
- };
161
- const timer = setTimeout(() => {
162
- fail(new CoreOperationException({
163
- code: "INSPECTION_TIMEOUT",
164
- operation: "create-project-inspection"
165
- }));
166
- }, Math.max(1, deadline - Date.now()));
167
- signal?.addEventListener("abort", handleAbort, { once: true });
168
- const isCallerAborted = () => signal?.aborted === true;
169
- if (isCallerAborted()) handleAbort();
170
- child.once("error", (cause) => {
171
- fail(createInspectionProcessFailure(cause));
172
- });
173
- supervision.closed.then(() => {
174
- if (!isClosing) fail(createInspectionProcessFailure());
175
- });
176
- let stderrBytes = 0;
177
- child.stderr?.on("data", (chunk) => {
178
- stderrBytes += chunk.byteLength;
179
- if (stderrBytes > 32768) fail(createInspectionProcessFailure());
180
- });
181
- child.on("message", (frame) => {
182
- if (isClosing) return;
183
- try {
184
- const message = decodeInspectionMessage(frame);
185
- if (message.attemptId !== attemptId) throw createInspectionProcessFailure();
186
- if (message.kind === "ready") {
187
- if (hasAcknowledgedHeap) throw createInspectionProcessFailure();
188
- heapMaximum = message.maxAnalysisHeapBytes;
189
- hasAcknowledgedHeap = true;
190
- send({
191
- attemptId,
192
- kind: "run"
193
- }).catch(fail);
194
- } else if (message.kind === "prepared") {
195
- if (!hasAcknowledgedHeap || hasPrepared || message.inspection.maxAnalysisHeapBytes !== heapMaximum || message.inspection.source.id !== snapshot.id || message.inspection.source.sourceKind !== snapshot.sourceKind) throw createInspectionProcessFailure();
196
- hasPrepared = true;
197
- prepared.resolve(deepFreeze(message.inspection));
198
- } else if (message.kind === "reader-request") {
199
- if (!hasAcknowledgedHeap || hasPrepared || message.requestId !== lastReaderRequestId + 1 || readerWork.size >= 4) throw createInspectionProcessFailure();
200
- lastReaderRequestId = message.requestId;
201
- if (sources === void 0) throw createInspectionProcessFailure();
202
- const work = executeRepositoryRpc(sources, message.request, controller.signal);
203
- readerWork.add(work);
204
- const relay = (async () => {
205
- try {
206
- const result = await work;
207
- readerWork.delete(work);
208
- if (!isClosing) await send({
209
- attemptId,
210
- kind: "reader-response",
211
- requestId: message.requestId,
212
- result
213
- });
214
- } catch (cause) {
215
- if (cause instanceof RepositorySourceException && [
216
- "ENTRY_NOT_FOUND",
217
- "ENTRY_NOT_FILE",
218
- "RESOURCE_LIMIT_EXCEEDED"
219
- ].includes(cause.code)) try {
220
- if (!isClosing) await send({
221
- attemptId,
222
- kind: "reader-failure",
223
- requestId: message.requestId,
224
- failure: serializeInspectionFailure(cause)
225
- });
226
- } catch (transportFailure) {
227
- fail(transportFailure);
228
- }
229
- else fail(cause);
230
- } finally {
231
- readerWork.delete(work);
232
- }
233
- })();
234
- relayWork.add(relay);
235
- relay.finally(() => relayWork.delete(relay));
236
- } else if (message.kind === "page") {
237
- if (!hasPrepared || pendingPage === void 0 || message.requestId !== pageRequestId) throw createInspectionProcessFailure();
238
- const completion = pendingPage;
239
- pendingPage = void 0;
240
- completion.resolve(deepFreeze(message.result));
241
- } else if (message.kind === "failure") {
242
- if (message.failure.options["nextAction"] === "review-inspection-capacity" && (heapMaximum === void 0 || message.failure.options["limitMaximum"] !== heapMaximum)) throw createInspectionProcessFailure();
243
- fail(deserializeInspectionFailure(message.failure));
244
- } else throw createInspectionProcessFailure();
245
- } catch (cause) {
246
- fail(cause);
247
- }
248
- });
249
- try {
250
- await send({
251
- attemptId,
252
- kind: "start",
253
- snapshot,
254
- instructions,
255
- limits,
256
- deadline
257
- });
258
- const metadata = await prepared.promise;
259
- if (Date.now() >= deadline) throw new CoreOperationException({
260
- code: "INSPECTION_TIMEOUT",
261
- operation: "create-project-inspection"
262
- });
263
- return Object.freeze({
264
- ...metadata,
265
- readPage: async (pageInput) => {
266
- if (failure !== void 0 || isClosing) throw failure?.cause ?? aborted();
267
- if (pendingPage !== void 0 || pageInput === null || typeof pageInput !== "object" || Reflect.ownKeys(pageInput).some((key) => key !== "cursor" && key !== "maxItems" && key !== "view") || !Number.isSafeInteger(pageInput.maxItems) || pageInput.maxItems < 1 || pageInput.maxItems > limits.maxEntries || ![
268
- "all",
269
- "diagnostics",
270
- "coverage",
271
- "metadata"
272
- ].includes(pageInput.view) || pageInput.cursor !== void 0 && typeof pageInput.cursor !== "string") throw new CoreOperationException({
273
- code: "INVALID_ARGUMENT",
274
- operation: "create-project-inspection"
275
- });
276
- const completion = createCompletion();
277
- pendingPage = completion;
278
- pageRequestId++;
279
- try {
280
- if (Date.now() >= deadline) throw new CoreOperationException({
281
- code: "INSPECTION_TIMEOUT",
282
- operation: "create-project-inspection"
283
- });
284
- await send({
285
- attemptId,
286
- kind: "read-page",
287
- requestId: pageRequestId,
288
- input: {
289
- maxItems: pageInput.maxItems,
290
- view: pageInput.view,
291
- ...pageInput.cursor === void 0 ? {} : { cursor: pageInput.cursor }
292
- }
293
- });
294
- const result = await completion.promise;
295
- if (Date.now() >= deadline) throw new CoreOperationException({
296
- code: "INSPECTION_TIMEOUT",
297
- operation: "create-project-inspection"
298
- });
299
- return result;
300
- } catch (cause) {
301
- fail(cause);
302
- await cleanup();
303
- throw getFailureCause() ?? createInspectionProcessFailure(cause);
304
- } finally {
305
- if (pendingPage === completion) pendingPage = void 0;
306
- }
307
- },
308
- dispose: async () => {
309
- pendingPage?.reject(failure?.cause ?? aborted());
310
- await cleanup();
311
- const cause = getFailureCause();
312
- if (cause !== void 0) throw cause;
313
- }
314
- });
315
- } catch (cause) {
316
- fail(cause);
317
- await cleanup();
318
- throw getFailureCause() ?? createInspectionProcessFailure(cause);
319
- }
320
- };
321
- //#endregion
322
- //#region src/core-composition/executor.ts
323
- var calculateRetainedByteLimit = (maxTotalBytes) => maxTotalBytes > Math.floor(Number.MAX_SAFE_INTEGER / 4) ? Number.MAX_SAFE_INTEGER : maxTotalBytes * 4;
324
- var createMoldeaCliCoreInspectionExecutor = (nodeInspectionFactory = createNodeProjectInspection) => async (input) => {
325
- const inspection = await nodeInspectionFactory({
326
- repository: input.repository,
327
- ...input.instructions === void 0 ? {} : { instructions: input.instructions },
328
- limits: {
329
- maxDiagnostics: input.resourceLimits.maxDiagnostics,
330
- maxEntries: input.resourceLimits.maxEntries,
331
- maxCoverage: input.resourceLimits.maxCoverage,
332
- maxFileBytes: input.resourceLimits.maxFileBytes,
333
- maxManifestBytes: input.resourceLimits.maxManifestBytes,
334
- maxRetainedBytes: calculateRetainedByteLimit(input.resourceLimits.maxTotalBytes),
335
- maxTotalBytesRead: input.resourceLimits.maxTotalBytes
336
- },
337
- ...input.signal === void 0 ? {} : { signal: input.signal }
338
- });
339
- try {
340
- if (resolveInstalledMoldeaCliComposition({ packageMetadata: input.packageMetadata }).kind === "invalid") throw new MoldeaCliCompositionException();
341
- if (input.command === "inspect") return await inspection.readPage({
342
- ...input.cursor === void 0 ? {} : { cursor: input.cursor },
343
- maxItems: Math.min(256, input.resourceLimits.maxEntries),
344
- view: "all"
345
- });
346
- const diagnostics = [];
347
- const coverage = [];
348
- for (const view of ["diagnostics", "coverage"]) {
349
- let cursor;
350
- do {
351
- const result = await inspection.readPage({
352
- view,
353
- maxItems: Math.min(256, input.resourceLimits.maxEntries),
354
- ...cursor === void 0 ? {} : { cursor }
355
- });
356
- for (const { item } of result.page.records) if (item.kind === "diagnostic") diagnostics.push(item.diagnostic);
357
- else if (item.kind === "coverage") coverage.push(item.coverage);
358
- cursor = result.page.nextCursor ?? void 0;
359
- } while (cursor !== void 0);
360
- }
361
- return Object.freeze({
362
- diagnostics: Object.freeze(diagnostics),
363
- coverage: Object.freeze(coverage),
364
- coverageCounts: inspection.coverageCounts,
365
- diagnosticCount: inspection.counts.diagnostics,
366
- acceptedWarningCount: inspection.counts.acceptedWarnings,
367
- errorCount: inspection.counts.errors,
368
- warningCount: inspection.counts.warnings,
369
- valid: inspection.valid,
370
- formatVersion: inspection.formatVersion,
371
- source: inspection.source,
372
- summary: inspection.summary
373
- });
374
- } finally {
375
- await inspection.dispose();
376
- }
377
- };
378
- var executeMoldeaCliCoreInspection = createMoldeaCliCoreInspectionExecutor();
379
- //#endregion
380
- export { executeMoldeaCliCoreInspection };