@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,146 +1,117 @@
1
- import { n as CoreOperationException } from "./chunk-728df961.mjs";
2
- import { a as createInspectionProcessFailure, c as encodeInspectionMessage, l as serializeInspectionFailure, n as NODE_INSPECTION_LIFETIME_MS, o as decodeInspectionMessage } from "./chunk-ec3f49d3.mjs";
3
- import { n as createInspectionSender } from "./chunk-94b5ac22.mjs";
4
- import process from "node:process";
5
- import { Worker } from "node:worker_threads";
1
+ import { n as e } from "./chunk-2cc3bf5c.mjs";
2
+ import { a as t, c as n, l as r, n as i, o as a } from "./chunk-24ea7c23.mjs";
3
+ import { n as o } from "./chunk-cea1378f.mjs";
4
+ import s from "node:process";
5
+ import { Worker as c } from "node:worker_threads";
6
6
  //#region ../core/dist/node-runner.js
7
- var worker;
8
- var attemptId;
9
- var heapMaximum;
10
- var deadlineTimer;
11
- var isClosing = false;
12
- var hasRun = false;
13
- var readerRequests = new Set();
14
- var send = createInspectionSender((frame, callback) => {
15
- if (process.send === void 0 || !process.connected) throw createInspectionProcessFailure();
16
- process.send(frame, callback);
17
- });
18
- var close = async (failure) => {
19
- if (isClosing) return;
20
- isClosing = true;
21
- clearTimeout(deadlineTimer);
22
- const termination = worker?.terminate();
23
- if (failure !== void 0 && attemptId !== void 0 && process.connected) try {
24
- await send({
25
- attemptId,
7
+ var l, u, d, f, p = !1, m = !1, h = new Set(), g = o((e, n) => {
8
+ if (s.send === void 0 || !s.connected) throw t();
9
+ s.send(e, n);
10
+ }), _ = async (e) => {
11
+ if (p) return;
12
+ p = !0, clearTimeout(f);
13
+ let t = l?.terminate();
14
+ if (e !== void 0 && u !== void 0 && s.connected) try {
15
+ await g({
16
+ attemptId: u,
26
17
  kind: "failure",
27
- failure: serializeInspectionFailure(failure)
18
+ failure: r(e)
28
19
  });
29
20
  } catch {}
30
- await termination;
31
- readerRequests.clear();
32
- process.removeListener("message", handleParentMessage);
33
- process.removeListener("disconnect", handleDisconnect);
34
- if (process.connected) process.disconnect();
35
- };
36
- var handleDisconnect = () => {
37
- close();
38
- };
39
- var handleWorkerMessage = (frame) => {
21
+ await t, h.clear(), s.removeListener("message", x), s.removeListener("disconnect", v), s.connected && s.disconnect();
22
+ }, v = () => {
23
+ _();
24
+ }, y = (e) => {
40
25
  try {
41
- const message = decodeInspectionMessage(frame);
42
- if (isClosing) return;
43
- if (message.attemptId !== attemptId) throw createInspectionProcessFailure();
44
- if (message.kind === "ready") {
45
- if (heapMaximum !== void 0 || hasRun) throw createInspectionProcessFailure();
46
- heapMaximum = message.maxAnalysisHeapBytes;
47
- } else if (message.kind === "reader-request") {
48
- if (!hasRun || readerRequests.has(message.requestId) || readerRequests.size >= 4) throw createInspectionProcessFailure();
49
- readerRequests.add(message.requestId);
50
- } else if (message.kind === "failure" && message.failure.options["limit"] === "maxAnalysisHeapBytes") throw createInspectionProcessFailure();
26
+ let n = a(e);
27
+ if (p) return;
28
+ if (n.attemptId !== u) throw t();
29
+ if (n.kind === "ready") {
30
+ if (d !== void 0 || m) throw t();
31
+ d = n.maxAnalysisHeapBytes;
32
+ } else if (n.kind === "reader-request") {
33
+ if (!m || h.has(n.requestId) || h.size >= 4) throw t();
34
+ h.add(n.requestId);
35
+ } else if (n.kind === "failure" && n.failure.options.limit === "maxAnalysisHeapBytes") throw t();
51
36
  else if (![
52
37
  "prepared",
53
38
  "page",
54
39
  "failure"
55
- ].includes(message.kind)) throw createInspectionProcessFailure();
56
- send(message).catch((cause) => close(cause));
57
- } catch (cause) {
58
- close(cause);
40
+ ].includes(n.kind)) throw t();
41
+ g(n).catch((e) => _(e));
42
+ } catch (e) {
43
+ _(e);
59
44
  }
60
- };
61
- var start = (message) => {
62
- if (attemptId !== void 0 || isClosing) throw createInspectionProcessFailure();
63
- attemptId = message.attemptId;
64
- clearTimeout(deadlineTimer);
65
- const remaining = Math.min(NODE_INSPECTION_LIFETIME_MS, message.deadline - Date.now());
66
- if (remaining <= 0) {
67
- close(new CoreOperationException({
45
+ }, b = (r) => {
46
+ if (u !== void 0 || p) throw t();
47
+ u = r.attemptId, clearTimeout(f);
48
+ let a = Math.min(i, r.deadline - Date.now());
49
+ if (a <= 0) {
50
+ _(new e({
68
51
  code: "INSPECTION_TIMEOUT",
69
52
  operation: "create-project-inspection"
70
53
  }));
71
54
  return;
72
55
  }
73
- deadlineTimer = setTimeout(() => {
74
- close(new CoreOperationException({
56
+ f = setTimeout(() => {
57
+ _(new e({
75
58
  code: "INSPECTION_TIMEOUT",
76
59
  operation: "create-project-inspection"
77
60
  }));
78
- }, remaining);
79
- worker = new Worker(new URL(new URL("./analysis-worker.mjs", import.meta.url).href), {
61
+ }, a), l = new c(new URL(new URL("./analysis-worker.mjs", import.meta.url).href), {
80
62
  execArgv: [],
81
- env: process.env,
82
- stdout: true,
83
- stderr: true,
63
+ env: s.env,
64
+ stdout: !0,
65
+ stderr: !0,
84
66
  resourceLimits: {
85
67
  maxOldGenerationSizeMb: 512,
86
68
  maxYoungGenerationSizeMb: 24
87
69
  },
88
- workerData: encodeInspectionMessage(message)
70
+ workerData: n(r)
89
71
  });
90
- let stdioBytes = 0;
91
- const consumeStdio = (chunk) => {
92
- stdioBytes += chunk.byteLength;
93
- if (stdioBytes > 32768) close(createInspectionProcessFailure());
72
+ let o = 0, m = (e) => {
73
+ o += e.byteLength, o > 32768 && _(t());
94
74
  };
95
- worker.stdout.on("data", consumeStdio);
96
- worker.stderr.on("data", consumeStdio);
97
- worker.on("message", handleWorkerMessage);
98
- worker.on("messageerror", (cause) => {
99
- close(createInspectionProcessFailure(cause));
100
- });
101
- worker.once("error", (error) => {
102
- close(error.code === "ERR_WORKER_OUT_OF_MEMORY" && heapMaximum !== void 0 ? new CoreOperationException({
75
+ l.stdout.on("data", m), l.stderr.on("data", m), l.on("message", y), l.on("messageerror", (e) => {
76
+ _(t(e));
77
+ }), l.once("error", (n) => {
78
+ _(n.code === "ERR_WORKER_OUT_OF_MEMORY" && d !== void 0 ? new e({
103
79
  code: "RESOURCE_LIMIT_EXCEEDED",
104
80
  operation: "create-project-inspection",
105
81
  limit: "maxAnalysisHeapBytes",
106
- limitMaximum: heapMaximum,
82
+ limitMaximum: d,
107
83
  observedUsage: null,
108
84
  nextAction: "review-inspection-capacity"
109
- }) : createInspectionProcessFailure(error));
110
- });
111
- worker.once("exit", () => {
112
- if (!isClosing) close(createInspectionProcessFailure());
85
+ }) : t(n));
86
+ }), l.once("exit", () => {
87
+ p || _(t());
113
88
  });
114
- };
115
- var handleParentMessage = (frame) => {
89
+ }, x = (e) => {
116
90
  try {
117
- const message = decodeInspectionMessage(frame);
118
- if (isClosing) return;
119
- if (message.kind === "start") {
120
- start(message);
91
+ let r = a(e);
92
+ if (p) return;
93
+ if (r.kind === "start") {
94
+ b(r);
121
95
  return;
122
96
  }
123
- if (message.attemptId !== attemptId || worker === void 0) throw createInspectionProcessFailure();
124
- if (message.kind === "dispose") {
125
- close();
97
+ if (r.attemptId !== u || l === void 0) throw t();
98
+ if (r.kind === "dispose") {
99
+ _();
126
100
  return;
127
101
  }
128
- if (message.kind === "run") {
129
- if (heapMaximum === void 0 || hasRun) throw createInspectionProcessFailure();
130
- hasRun = true;
131
- } else if (message.kind === "reader-response" || message.kind === "reader-failure") {
132
- if (!readerRequests.delete(message.requestId)) throw createInspectionProcessFailure();
133
- } else if (message.kind !== "read-page" || !hasRun) throw createInspectionProcessFailure();
134
- worker.postMessage(encodeInspectionMessage(message));
135
- } catch (cause) {
136
- close(cause);
102
+ if (r.kind === "run") {
103
+ if (d === void 0 || m) throw t();
104
+ m = !0;
105
+ } else if (r.kind === "reader-response" || r.kind === "reader-failure") {
106
+ if (!h.delete(r.requestId)) throw t();
107
+ } else if (r.kind !== "read-page" || !m) throw t();
108
+ l.postMessage(n(r));
109
+ } catch (e) {
110
+ _(e);
137
111
  }
138
112
  };
139
- process.on("disconnect", handleDisconnect);
140
- process.on("message", handleParentMessage);
141
- deadlineTimer = setTimeout(() => {
142
- close();
143
- }, NODE_INSPECTION_LIFETIME_MS);
144
- if (process.send === void 0 || !process.connected) close();
113
+ s.on("disconnect", v), s.on("message", x), f = setTimeout(() => {
114
+ _();
115
+ }, i), (s.send === void 0 || !s.connected) && _();
145
116
  //#endregion
146
117
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moldea.ai/cli",
3
- "version": "14.0.0",
3
+ "version": "14.0.2",
4
4
  "description": "The canonical read-only local command-line composition for moldea repositories.",
5
5
  "homepage": "https://github.com/moldea-ai/packages/tree/main/projects/cli#readme",
6
6
  "bugs": {
@@ -29,7 +29,7 @@
29
29
  "node": ">=22.17.0"
30
30
  },
31
31
  "dependencies": {
32
- "@moldea.ai/core": "^10.0.0",
32
+ "@moldea.ai/core": "^10.0.1",
33
33
  "@moldea.ai/repository": "^4.0.0",
34
34
  "@moldea.ai/repository-fs": "^4.0.0",
35
35
  "jg-crypto": "0.3.0",
@@ -1,115 +0,0 @@
1
- import { u as isObjectValid } from "./chunk-728df961.mjs";
2
- import { c as isRepositoryPath, i as RepositorySourceException, l as parseRepositoryPath } from "./chunk-8d6114d2.mjs";
3
- import { Buffer } from "node:buffer";
4
- //#region ../core/dist/chunks/repository-rpc-DVgCPLGx.js
5
- var invalidSource = () => {
6
- throw new RepositorySourceException({
7
- code: "INVALID_SOURCE_DATA",
8
- operation: "create-reader",
9
- path: null,
10
- retryable: false
11
- });
12
- };
13
- var isInteger = (input) => typeof input === "number" && Number.isSafeInteger(input) && input >= 0;
14
- var keysMatch = (input, keys) => Object.keys(input).length === keys.length && keys.every((key) => Object.hasOwn(input, key));
15
- var parseSnapshot = (input) => {
16
- if (!isObjectValid(input, true) || !keysMatch(input, ["id", "sourceKind"]) || typeof input["id"] !== "string" || input["id"].length === 0 || typeof input["sourceKind"] !== "string" || input["sourceKind"].length === 0) return invalidSource();
17
- return {
18
- id: input["id"],
19
- sourceKind: input["sourceKind"]
20
- };
21
- };
22
- var parseRpcEntry = (input) => {
23
- if (input === null) return null;
24
- if (!isObjectValid(input, true)) return invalidSource();
25
- const entry = input;
26
- if (!keysMatch(entry, [
27
- "path",
28
- "type",
29
- "byteLength",
30
- "contentIdentity"
31
- ]) || !isRepositoryPath(entry["path"]) || entry["type"] !== "file" && entry["type"] !== "directory" && entry["type"] !== "symlink" || entry["byteLength"] !== null && !isInteger(entry["byteLength"]) || entry["contentIdentity"] !== null && typeof entry["contentIdentity"] !== "string") return invalidSource();
32
- return {
33
- path: entry["path"],
34
- type: entry["type"],
35
- byteLength: entry["byteLength"],
36
- contentIdentity: entry["contentIdentity"]
37
- };
38
- };
39
- var parseRpcEntryPage = (input) => {
40
- if (!isObjectValid(input, true)) return invalidSource();
41
- const page = input;
42
- if (!keysMatch(page, [
43
- "entries",
44
- "isComplete",
45
- "nextCursor",
46
- "snapshot"
47
- ]) || !Array.isArray(page["entries"]) || page["entries"].length > 128 || typeof page["isComplete"] !== "boolean" || page["nextCursor"] !== null && typeof page["nextCursor"] !== "string") return invalidSource();
48
- const entries = [];
49
- for (const candidate of page["entries"]) {
50
- const entry = parseRpcEntry(candidate);
51
- if (entry === null) return invalidSource();
52
- entries.push(entry);
53
- }
54
- return {
55
- entries,
56
- isComplete: page["isComplete"],
57
- nextCursor: page["nextCursor"],
58
- snapshot: parseSnapshot(page["snapshot"])
59
- };
60
- };
61
- var parseRpcLinkText = (input) => {
62
- if (input === null) return null;
63
- if (typeof input !== "string" || Buffer.byteLength(input, "utf8") > 4096) return invalidSource();
64
- return input;
65
- };
66
- var parseRpcFilePage = (input) => {
67
- if (!isObjectValid(input, true)) return invalidSource();
68
- const filePage = input;
69
- if (!keysMatch(filePage, [
70
- "bytes",
71
- "isComplete",
72
- "nextOffset",
73
- "offset",
74
- "snapshot",
75
- "totalBytes"
76
- ]) || typeof filePage["bytes"] !== "string" || filePage["bytes"].length > Math.ceil(65536 / 3) * 4 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(filePage["bytes"]) || typeof filePage["isComplete"] !== "boolean" || !isInteger(filePage["offset"]) || !isInteger(filePage["totalBytes"]) || filePage["nextOffset"] !== null && !isInteger(filePage["nextOffset"])) return invalidSource();
77
- const bytes = Buffer.from(filePage["bytes"], "base64");
78
- if (bytes.byteLength > 65536 || bytes.toString("base64") !== filePage["bytes"]) return invalidSource();
79
- return {
80
- bytes,
81
- isComplete: filePage["isComplete"],
82
- nextOffset: filePage["nextOffset"],
83
- offset: filePage["offset"],
84
- snapshot: parseSnapshot(filePage["snapshot"]),
85
- totalBytes: filePage["totalBytes"]
86
- };
87
- };
88
- var encodeFilePage = (page, maxBytes) => {
89
- if (!(page.bytes instanceof Uint8Array) || page.bytes.byteLength > maxBytes) return invalidSource();
90
- const result = {
91
- ...page,
92
- bytes: Buffer.from(page.bytes.buffer, page.bytes.byteOffset, page.bytes.byteLength).toString("base64")
93
- };
94
- parseRpcFilePage(result);
95
- return result;
96
- };
97
- var executeRepositoryRpc = async (sources, request, signal) => {
98
- const getReader = (source) => source === "repository" ? sources.repository : sources.instructions ?? invalidSource();
99
- if (request.method === "readLinkText") return parseRpcLinkText(await getReader(request.source).readLinkText(parseRepositoryPath(request.path), { signal }));
100
- if (request.method === "getEntry") return parseRpcEntry(await getReader(request.source).getEntry(parseRepositoryPath(request.path), { signal }));
101
- const reader = sources.repository;
102
- if (request.method === "listEntriesPage") return parseRpcEntryPage(await reader.listEntriesPage({
103
- maxEntries: request.maxEntries,
104
- signal,
105
- ...request.prefix === void 0 ? {} : { prefix: parseRepositoryPath(request.prefix) },
106
- ...request.cursor === void 0 ? {} : { cursor: request.cursor }
107
- }));
108
- return encodeFilePage(await getReader(request.source).readFilePage(parseRepositoryPath(request.path), {
109
- maxBytes: request.maxBytes,
110
- offset: request.offset,
111
- signal
112
- }), request.maxBytes);
113
- };
114
- //#endregion
115
- export { parseRpcLinkText as a, parseRpcFilePage as i, parseRpcEntry as n, parseRpcEntryPage as r, executeRepositoryRpc as t };
@@ -1,26 +0,0 @@
1
- import { createRequire } from "node:module";
2
- //#region \0rolldown/runtime.js
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
- key = keys[i];
13
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
21
- value: mod,
22
- enumerable: true
23
- }) : target, mod));
24
- var __require = (() => createRequire(import.meta.url))();
25
- //#endregion
26
- export { __require as n, __toESM as r, __commonJSMin as t };