@moldea.ai/cli 5.0.3 → 7.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.
- package/README.md +25 -18
- package/dist/chunks/composition-B9oqoRqn.js +126 -0
- package/dist/chunks/composition-B9oqoRqn.js.map +1 -0
- package/dist/chunks/core-composition-6wOvReoY.js +90 -0
- package/dist/chunks/core-composition-6wOvReoY.js.map +1 -0
- package/dist/chunks/core-composition-Bb9OMTs-.js +3 -0
- package/dist/chunks/semver-BzaJzKRS.js +1790 -0
- package/dist/chunks/semver-BzaJzKRS.js.map +1 -0
- package/dist/moldea.js +1219 -2359
- package/dist/moldea.js.map +1 -1
- package/package.json +14 -14
package/dist/moldea.js
CHANGED
|
@@ -1,27 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { a as executeGitProcess, i as executeGitStreamingProcess, n as createGitVersionPreflight, o as MAX_GIT_PROCESS_DIAGNOSTIC_BYTES, t as require_semver } from "./chunks/semver-BzaJzKRS.js";
|
|
2
3
|
import path from "node:path";
|
|
3
|
-
import process
|
|
4
|
+
import process from "node:process";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import {
|
|
6
|
-
import { anthropicAdapter } from "@moldea.ai/adapter-anthropic";
|
|
7
|
-
import { claudeAgentSdkAdapter } from "@moldea.ai/adapter-claude-agent-sdk";
|
|
8
|
-
import { cloudflareAgentsAdapter } from "@moldea.ai/adapter-cloudflare-agents";
|
|
9
|
-
import { eveAdapter } from "@moldea.ai/adapter-eve";
|
|
10
|
-
import { googleGenAiAdapter } from "@moldea.ai/adapter-google-genai";
|
|
11
|
-
import { langChainAdapter } from "@moldea.ai/adapter-langchain";
|
|
12
|
-
import { langGraphAdapter } from "@moldea.ai/adapter-langgraph";
|
|
13
|
-
import { openAiAdapter } from "@moldea.ai/adapter-openai";
|
|
14
|
-
import { openAiAgentsSdkAdapter } from "@moldea.ai/adapter-openai-agents-sdk";
|
|
15
|
-
import { vercelAiSdkAdapter } from "@moldea.ai/adapter-vercel-ai-sdk";
|
|
16
|
-
import { TextDecoder as TextDecoder$1 } from "node:util";
|
|
17
|
-
import { execFile, spawn } from "node:child_process";
|
|
6
|
+
import { createHash, timingSafeEqual } from "node:crypto";
|
|
18
7
|
import { lstat, readFile, readdir, stat } from "node:fs/promises";
|
|
19
|
-
import {
|
|
8
|
+
import { CoreConfigurationException, CoreOperationException, createCore } from "@moldea.ai/core";
|
|
9
|
+
import { REPOSITORY_ROOT, RepositorySourceException, createRepositoryComparison, isRepositoryPath, parseRepositoryPath } from "@moldea.ai/repository";
|
|
20
10
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
21
11
|
import { createFilesystemRepositoryReader } from "@moldea.ai/repository-fs";
|
|
22
|
-
//#region \0rolldown/runtime.js
|
|
23
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
24
|
-
//#endregion
|
|
25
12
|
//#region src/cli-execution/constants.ts
|
|
26
13
|
var MOLDEA_CLI_EXIT_CODES = {
|
|
27
14
|
Interrupted: 130,
|
|
@@ -35,19 +22,25 @@ var MOLDEA_CLI_EXIT_CODES = {
|
|
|
35
22
|
//#region src/command-line/constants.ts
|
|
36
23
|
var MOLDEA_CLI_COMMANDS = {
|
|
37
24
|
Composition: "composition",
|
|
25
|
+
Content: "content",
|
|
38
26
|
Inspect: "inspect",
|
|
27
|
+
Scope: "scope",
|
|
39
28
|
Validate: "validate"
|
|
40
29
|
};
|
|
41
30
|
var MOLDEA_CLI_OPTIONS = {
|
|
42
31
|
Help: "--help",
|
|
43
32
|
Json: "--json",
|
|
33
|
+
Cursor: "--cursor",
|
|
44
34
|
MaxDiagnostics: "--max-diagnostics",
|
|
45
35
|
MaxEntries: "--max-entries",
|
|
46
36
|
MaxEvidence: "--max-evidence",
|
|
47
37
|
MaxFileBytes: "--max-file-bytes",
|
|
48
38
|
MaxManifestBytes: "--max-manifest-bytes",
|
|
39
|
+
MaxOutputBytes: "--max-output-bytes",
|
|
49
40
|
MaxTotalBytes: "--max-total-bytes",
|
|
50
41
|
NoColor: "--no-color",
|
|
42
|
+
Path: "--path",
|
|
43
|
+
PathsStdin: "--paths-stdin",
|
|
51
44
|
Repository: "--repository",
|
|
52
45
|
Version: "--version"
|
|
53
46
|
};
|
|
@@ -59,6 +52,216 @@ var DEFAULT_MOLDEA_CLI_RESOURCE_LIMITS = Object.freeze({
|
|
|
59
52
|
maxManifestBytes: 2097152,
|
|
60
53
|
maxTotalBytes: 134217728
|
|
61
54
|
});
|
|
55
|
+
var MOLDEA_CLI_DEFAULT_OUTPUT_BYTES = 65536;
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/output-page/exception.ts
|
|
58
|
+
/** Represents a safe pagination or output-budget failure owned by the CLI. */
|
|
59
|
+
var MoldeaCliOutputPageException = class extends Error {
|
|
60
|
+
code;
|
|
61
|
+
/** Creates one output-page failure with a stable public code. */
|
|
62
|
+
constructor(code) {
|
|
63
|
+
super(code);
|
|
64
|
+
this.code = code;
|
|
65
|
+
this.name = "MoldeaCliOutputPageException";
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/json-serialization/serializer.ts
|
|
70
|
+
/** Compares strings by Unicode code point rather than UTF-16 code unit. */
|
|
71
|
+
var compareUnicodeCodePoints = (left, right) => {
|
|
72
|
+
const leftCodePoints = [...left];
|
|
73
|
+
const rightCodePoints = [...right];
|
|
74
|
+
const sharedLength = Math.min(leftCodePoints.length, rightCodePoints.length);
|
|
75
|
+
for (let index = 0; index < sharedLength; index += 1) {
|
|
76
|
+
const leftCodePoint = leftCodePoints[index]?.codePointAt(0);
|
|
77
|
+
const rightCodePoint = rightCodePoints[index]?.codePointAt(0);
|
|
78
|
+
if (leftCodePoint === void 0 || rightCodePoint === void 0) throw new TypeError("The JSON object key could not be compared.");
|
|
79
|
+
if (leftCodePoint !== rightCodePoint) return leftCodePoint - rightCodePoint;
|
|
80
|
+
}
|
|
81
|
+
return leftCodePoints.length - rightCodePoints.length;
|
|
82
|
+
};
|
|
83
|
+
/** Serializes one validated JSON value with recursively sorted object keys. */
|
|
84
|
+
var serializeJsonValue = (value, ancestors) => {
|
|
85
|
+
if (value === null || typeof value === "boolean" || typeof value === "string") return JSON.stringify(value);
|
|
86
|
+
if (typeof value === "number") {
|
|
87
|
+
if (!Number.isFinite(value)) throw new TypeError("The JSON number must be finite.");
|
|
88
|
+
return JSON.stringify(Object.is(value, -0) ? 0 : value);
|
|
89
|
+
}
|
|
90
|
+
if (typeof value !== "object") throw new TypeError("The value is not supported by the CLI JSON contract.");
|
|
91
|
+
if (ancestors.has(value)) throw new TypeError("The CLI JSON value must not contain a cycle.");
|
|
92
|
+
ancestors.add(value);
|
|
93
|
+
try {
|
|
94
|
+
if (Array.isArray(value)) {
|
|
95
|
+
const serializedEntries = [];
|
|
96
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
97
|
+
if (!Object.hasOwn(value, index)) throw new TypeError("The CLI JSON array must not contain empty slots.");
|
|
98
|
+
serializedEntries.push(serializeJsonValue(value[index], ancestors));
|
|
99
|
+
}
|
|
100
|
+
return `[${serializedEntries.join(",")}]`;
|
|
101
|
+
}
|
|
102
|
+
const prototype = Object.getPrototypeOf(value);
|
|
103
|
+
if (prototype !== Object.prototype && prototype !== null) throw new TypeError("The CLI JSON object must be a plain record.");
|
|
104
|
+
if (Object.getOwnPropertySymbols(value).length > 0) throw new TypeError("The CLI JSON object must not contain symbol keys.");
|
|
105
|
+
const record = value;
|
|
106
|
+
return `{${Object.keys(record).sort(compareUnicodeCodePoints).map((key) => `${JSON.stringify(key)}:${serializeJsonValue(record[key], ancestors)}`).join(",")}}`;
|
|
107
|
+
} finally {
|
|
108
|
+
ancestors.delete(value);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Serializes one CLI JSON value with exact recursive Unicode code-point key ordering.
|
|
113
|
+
* @param value The closed JSON value to serialize.
|
|
114
|
+
* @returns Compact deterministic JSON without a trailing line feed.
|
|
115
|
+
* @throws
|
|
116
|
+
* - If the value contains unsupported, non-finite, symbolic, class-backed, or cyclic data
|
|
117
|
+
*/
|
|
118
|
+
var serializeJsonDeterministically = (value) => {
|
|
119
|
+
return serializeJsonValue(value, /* @__PURE__ */ new Set());
|
|
120
|
+
};
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/output-page/cursor.ts
|
|
123
|
+
var SHA256_PATTERN = /^sha256:[0-9a-f]{64}$/u;
|
|
124
|
+
var BASE64URL_PATTERN = /^[A-Za-z0-9_-]+$/u;
|
|
125
|
+
var CURSOR_DOCUMENT_KEYS = Object.freeze([
|
|
126
|
+
"checksum",
|
|
127
|
+
"command",
|
|
128
|
+
"filtersDigest",
|
|
129
|
+
"lastKey",
|
|
130
|
+
"snapshotDigest",
|
|
131
|
+
"sourceCursor",
|
|
132
|
+
"version"
|
|
133
|
+
]);
|
|
134
|
+
/** Calculates one stable SHA-256 identifier for deterministic JSON text. */
|
|
135
|
+
var calculateMoldeaCliJsonDigest = (value) => {
|
|
136
|
+
return `sha256:${createHash("sha256").update(serializeJsonDeterministically(value), "utf8").digest("hex")}`;
|
|
137
|
+
};
|
|
138
|
+
/** Calculates the checksum for one cursor payload without its checksum field. */
|
|
139
|
+
var calculateCursorChecksum = (payload) => {
|
|
140
|
+
return calculateMoldeaCliJsonDigest(payload);
|
|
141
|
+
};
|
|
142
|
+
/** Compares fixed-format checksums without data-dependent early termination. */
|
|
143
|
+
var areChecksumsEqual = (left, right) => {
|
|
144
|
+
const leftBytes = Buffer.from(left, "utf8");
|
|
145
|
+
const rightBytes = Buffer.from(right, "utf8");
|
|
146
|
+
return leftBytes.length === rightBytes.length && timingSafeEqual(leftBytes, rightBytes);
|
|
147
|
+
};
|
|
148
|
+
/** Determines whether an unknown value is one strict cursor document. */
|
|
149
|
+
var isCursorDocument = (value) => {
|
|
150
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
151
|
+
const record = value;
|
|
152
|
+
const keys = Object.keys(record).sort();
|
|
153
|
+
return keys.length === CURSOR_DOCUMENT_KEYS.length && keys.every((key, index) => key === CURSOR_DOCUMENT_KEYS[index]) && record["version"] === 2 && (record["command"] === "content" || record["command"] === "inspect" || record["command"] === "scope" || record["command"] === "validate") && typeof record["filtersDigest"] === "string" && SHA256_PATTERN.test(record["filtersDigest"]) && typeof record["lastKey"] === "string" && record["lastKey"].length > 0 && (record["sourceCursor"] === null || typeof record["sourceCursor"] === "string") && typeof record["snapshotDigest"] === "string" && SHA256_PATTERN.test(record["snapshotDigest"]) && typeof record["checksum"] === "string" && SHA256_PATTERN.test(record["checksum"]);
|
|
154
|
+
};
|
|
155
|
+
/** Encodes one command-, filter-, and snapshot-bound continuation cursor. */
|
|
156
|
+
var encodeMoldeaCliCursor = (command, filters, snapshotDigest, lastKey, sourceCursor = null) => {
|
|
157
|
+
const payload = {
|
|
158
|
+
command,
|
|
159
|
+
filtersDigest: calculateMoldeaCliJsonDigest(filters),
|
|
160
|
+
lastKey,
|
|
161
|
+
sourceCursor,
|
|
162
|
+
snapshotDigest,
|
|
163
|
+
version: 2
|
|
164
|
+
};
|
|
165
|
+
const document = {
|
|
166
|
+
...payload,
|
|
167
|
+
checksum: calculateCursorChecksum(payload)
|
|
168
|
+
};
|
|
169
|
+
return Buffer.from(serializeJsonDeterministically(document), "utf8").toString("base64url");
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Decodes and validates one opaque continuation cursor.
|
|
173
|
+
* @param input The current command state and untrusted cursor.
|
|
174
|
+
* @returns The validated last composite record key.
|
|
175
|
+
* @throws
|
|
176
|
+
* - CURSOR_INVALID: The continuation cursor is invalid for this request.
|
|
177
|
+
* - CURSOR_SNAPSHOT_CHANGED: The continuation cursor belongs to a different repository snapshot.
|
|
178
|
+
*/
|
|
179
|
+
var decodeMoldeaCliCursor = (input) => {
|
|
180
|
+
let decoded;
|
|
181
|
+
try {
|
|
182
|
+
if (!BASE64URL_PATTERN.test(input.cursor)) throw new TypeError("The cursor is not canonical base64url.");
|
|
183
|
+
const bytes = Buffer.from(input.cursor, "base64url");
|
|
184
|
+
if (bytes.toString("base64url") !== input.cursor) throw new TypeError("The cursor is not canonical base64url.");
|
|
185
|
+
const text = bytes.toString("utf8");
|
|
186
|
+
decoded = JSON.parse(text);
|
|
187
|
+
} catch {
|
|
188
|
+
throw new MoldeaCliOutputPageException("CURSOR_INVALID");
|
|
189
|
+
}
|
|
190
|
+
if (!isCursorDocument(decoded)) throw new MoldeaCliOutputPageException("CURSOR_INVALID");
|
|
191
|
+
const { checksum, ...payload } = decoded;
|
|
192
|
+
if (!areChecksumsEqual(checksum, calculateCursorChecksum(payload)) || decoded.command !== input.command || decoded.filtersDigest !== calculateMoldeaCliJsonDigest(input.filters)) throw new MoldeaCliOutputPageException("CURSOR_INVALID");
|
|
193
|
+
if (input.snapshotDigest !== void 0 && decoded.snapshotDigest !== input.snapshotDigest) throw new MoldeaCliOutputPageException("CURSOR_SNAPSHOT_CHANGED");
|
|
194
|
+
return Object.freeze({
|
|
195
|
+
lastKey: decoded.lastKey,
|
|
196
|
+
snapshotDigest: decoded.snapshotDigest,
|
|
197
|
+
sourceCursor: decoded.sourceCursor
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/output-page/page.ts
|
|
202
|
+
/** Ensures records have unique keys in strict ascending order. */
|
|
203
|
+
var assertRecordOrder = (records) => {
|
|
204
|
+
for (let index = 0; index < records.length; index += 1) {
|
|
205
|
+
const key = records[index]?.key;
|
|
206
|
+
const previousKey = records[index - 1]?.key;
|
|
207
|
+
if (key === void 0 || key.length === 0 || previousKey !== void 0 && key <= previousKey) throw new TypeError("Output records must have unique keys in ascending order.");
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Selects the largest exact serialized output page that fits its byte budget.
|
|
212
|
+
* @param input Ordered records, continuation state, and an exact final-document measurement.
|
|
213
|
+
* @returns A frozen record page with a snapshot-bound continuation cursor when needed.
|
|
214
|
+
* @throws
|
|
215
|
+
* - CURSOR_INVALID: The continuation cursor is invalid for this request.
|
|
216
|
+
* - CURSOR_SNAPSHOT_CHANGED: The continuation cursor belongs to a different repository snapshot.
|
|
217
|
+
* - OUTPUT_BUDGET_TOO_SMALL: The output byte budget cannot contain the next complete result.
|
|
218
|
+
*/
|
|
219
|
+
var createMoldeaCliOutputPage = (input) => {
|
|
220
|
+
assertRecordOrder(input.records);
|
|
221
|
+
const cursorState = input.cursor === null ? null : decodeMoldeaCliCursor({
|
|
222
|
+
command: input.command,
|
|
223
|
+
cursor: input.cursor,
|
|
224
|
+
filters: input.filters,
|
|
225
|
+
snapshotDigest: input.snapshotDigest
|
|
226
|
+
});
|
|
227
|
+
const startIndex = cursorState === null ? 0 : cursorState.sourceCursor !== null ? 0 : input.records.findIndex(({ key }) => key === cursorState.lastKey) + 1;
|
|
228
|
+
if (cursorState !== null && cursorState.sourceCursor === null && startIndex === 0) throw new MoldeaCliOutputPageException("CURSOR_INVALID");
|
|
229
|
+
const emptyRecords = Object.freeze([]);
|
|
230
|
+
const emptyPage = Object.freeze({
|
|
231
|
+
cursor: null,
|
|
232
|
+
records: emptyRecords
|
|
233
|
+
});
|
|
234
|
+
if (startIndex === input.records.length) {
|
|
235
|
+
if (input.measure(emptyPage, 2) > input.maxOutputBytes) throw new MoldeaCliOutputPageException("OUTPUT_BUDGET_TOO_SMALL");
|
|
236
|
+
return emptyPage;
|
|
237
|
+
}
|
|
238
|
+
const selectedRecords = [];
|
|
239
|
+
let selectedCursor = null;
|
|
240
|
+
let serializedRecordsUtf8Bytes = 2;
|
|
241
|
+
for (let endIndex = startIndex + 1; endIndex <= input.records.length; endIndex += 1) {
|
|
242
|
+
const record = input.records[endIndex - 1];
|
|
243
|
+
if (record === void 0) throw new TypeError("An output page record is missing.");
|
|
244
|
+
const serializedRecordUtf8Bytes = Buffer.byteLength(serializeJsonDeterministically(record), "utf8");
|
|
245
|
+
serializedRecordsUtf8Bytes += serializedRecordUtf8Bytes + (endIndex > startIndex + 1 ? 1 : 0);
|
|
246
|
+
selectedRecords.push(record);
|
|
247
|
+
const sourceCursor = input.sourceCursorForRecord?.(record) ?? null;
|
|
248
|
+
const cursor = (input.sourceCursorForRecord === void 0 ? endIndex < input.records.length : sourceCursor !== null) ? encodeMoldeaCliCursor(input.command, input.filters, input.snapshotDigest, record.key, sourceCursor) : null;
|
|
249
|
+
const candidate = Object.freeze({
|
|
250
|
+
cursor,
|
|
251
|
+
records: selectedRecords
|
|
252
|
+
});
|
|
253
|
+
if (input.measure(candidate, serializedRecordsUtf8Bytes) > input.maxOutputBytes) {
|
|
254
|
+
selectedRecords.pop();
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
selectedCursor = cursor;
|
|
258
|
+
}
|
|
259
|
+
if (selectedRecords.length === 0) throw new MoldeaCliOutputPageException("OUTPUT_BUDGET_TOO_SMALL");
|
|
260
|
+
return Object.freeze({
|
|
261
|
+
cursor: selectedCursor,
|
|
262
|
+
records: Object.freeze([...selectedRecords])
|
|
263
|
+
});
|
|
264
|
+
};
|
|
62
265
|
//#endregion
|
|
63
266
|
//#region src/command-line/validations.ts
|
|
64
267
|
var POSITIVE_INTEGER_PATTERN = /^\d+$/u;
|
|
@@ -91,6 +294,11 @@ var parsePositiveSafeInteger = (input) => {
|
|
|
91
294
|
const parsedInteger = Number(input);
|
|
92
295
|
return Number.isSafeInteger(parsedInteger) && parsedInteger > 0 ? parsedInteger : null;
|
|
93
296
|
};
|
|
297
|
+
/** Parses one output byte budget inside the schema 4 transport bounds. */
|
|
298
|
+
var parseMoldeaCliOutputByteLimit = (input) => {
|
|
299
|
+
const parsed = parsePositiveSafeInteger(input);
|
|
300
|
+
return parsed !== null && parsed >= 4096 && parsed <= 1048576 ? parsed : null;
|
|
301
|
+
};
|
|
94
302
|
/**
|
|
95
303
|
* Validates the cross-limit ordering required by the CLI composition.
|
|
96
304
|
* @param limits The effective resource limits.
|
|
@@ -107,6 +315,10 @@ var areMoldeaCliResourceLimitsConsistent = (limits) => {
|
|
|
107
315
|
var isRepositoryDirectoryInputValid = (input) => {
|
|
108
316
|
return input.length > 0 && !input.includes("\0") && hasOnlyUnicodeScalarValues$1(input);
|
|
109
317
|
};
|
|
318
|
+
/** Determines whether one opaque cursor token is bounded safe scalar text. */
|
|
319
|
+
var isMoldeaCliCursorInputValid = (input) => {
|
|
320
|
+
return input.length > 0 && input.length <= 16384 && !input.includes("\0") && hasOnlyUnicodeScalarValues$1(input);
|
|
321
|
+
};
|
|
110
322
|
//#endregion
|
|
111
323
|
//#region src/command-line/parser.ts
|
|
112
324
|
var COMMAND_NAMES = new Set(Object.values(MOLDEA_CLI_COMMANDS));
|
|
@@ -128,7 +340,7 @@ var isMoldeaCliCommand = (input) => {
|
|
|
128
340
|
return input !== void 0 && COMMAND_NAMES.has(input);
|
|
129
341
|
};
|
|
130
342
|
/**
|
|
131
|
-
* Parses the complete
|
|
343
|
+
* Parses the complete schema 4 command grammar without mutating caller arguments.
|
|
132
344
|
* @param commandLineArguments The process arguments after the executable path.
|
|
133
345
|
* @returns A normalized command, informational request, or safe invocation error.
|
|
134
346
|
*/
|
|
@@ -153,6 +365,10 @@ var parseMoldeaCliArguments = (commandLineArguments) => {
|
|
|
153
365
|
const seenOptions = /* @__PURE__ */ new Set();
|
|
154
366
|
const resourceLimits = { ...DEFAULT_MOLDEA_CLI_RESOURCE_LIMITS };
|
|
155
367
|
let isColorDisabled = false;
|
|
368
|
+
let cursor = null;
|
|
369
|
+
let maxOutputBytes = MOLDEA_CLI_DEFAULT_OUTPUT_BYTES;
|
|
370
|
+
let path = null;
|
|
371
|
+
let pathsInput = "none";
|
|
156
372
|
let repositoryDirectory = null;
|
|
157
373
|
for (let index = 1; index < commandLineArguments.length; index += 1) {
|
|
158
374
|
const option = commandLineArguments[index];
|
|
@@ -163,14 +379,38 @@ var parseMoldeaCliArguments = (commandLineArguments) => {
|
|
|
163
379
|
isColorDisabled = true;
|
|
164
380
|
continue;
|
|
165
381
|
}
|
|
382
|
+
if (option === MOLDEA_CLI_OPTIONS.PathsStdin) {
|
|
383
|
+
pathsInput = "stdin";
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
166
386
|
if (option === MOLDEA_CLI_OPTIONS.Help || option === MOLDEA_CLI_OPTIONS.Version) return createArgumentError("INVALID_ARGUMENT", command, isJson);
|
|
167
387
|
const resourceField = RESOURCE_OPTION_FIELDS[option];
|
|
168
388
|
const isRepositoryOption = option === MOLDEA_CLI_OPTIONS.Repository;
|
|
169
|
-
|
|
389
|
+
const isCursorOption = option === MOLDEA_CLI_OPTIONS.Cursor;
|
|
390
|
+
const isOutputLimitOption = option === MOLDEA_CLI_OPTIONS.MaxOutputBytes;
|
|
391
|
+
const isPathOption = option === MOLDEA_CLI_OPTIONS.Path;
|
|
392
|
+
if (resourceField === void 0 && !isRepositoryOption && !isCursorOption && !isOutputLimitOption && !isPathOption) return createArgumentError("INVALID_ARGUMENT", command, isJson);
|
|
170
393
|
if (command === MOLDEA_CLI_COMMANDS.Composition) return createArgumentError("INVALID_ARGUMENT", command, isJson);
|
|
171
394
|
const optionValue = commandLineArguments[index + 1];
|
|
172
395
|
if (optionValue === void 0 || optionValue.startsWith("--")) return createArgumentError("INVALID_ARGUMENT", command, isJson);
|
|
173
396
|
index += 1;
|
|
397
|
+
if (isCursorOption) {
|
|
398
|
+
if (!isMoldeaCliCursorInputValid(optionValue)) return createArgumentError("INVALID_ARGUMENT", command, isJson);
|
|
399
|
+
cursor = optionValue;
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
if (isOutputLimitOption) {
|
|
403
|
+
const parsedOutputLimit = parseMoldeaCliOutputByteLimit(optionValue);
|
|
404
|
+
if (parsedOutputLimit === null) return createArgumentError("RESOURCE_LIMIT_CONFIGURATION_INVALID", command, isJson);
|
|
405
|
+
maxOutputBytes = parsedOutputLimit;
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
if (isPathOption) {
|
|
409
|
+
if (!isRepositoryDirectoryInputValid(optionValue)) return createArgumentError("INVALID_ARGUMENT", command, isJson);
|
|
410
|
+
path = optionValue;
|
|
411
|
+
pathsInput = "path";
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
174
414
|
if (isRepositoryOption) {
|
|
175
415
|
if (!isRepositoryDirectoryInputValid(optionValue)) return createArgumentError("INVALID_ARGUMENT", command, isJson);
|
|
176
416
|
repositoryDirectory = optionValue;
|
|
@@ -181,9 +421,27 @@ var parseMoldeaCliArguments = (commandLineArguments) => {
|
|
|
181
421
|
resourceLimits[resourceField] = parsedLimit;
|
|
182
422
|
}
|
|
183
423
|
if (!areMoldeaCliResourceLimitsConsistent(resourceLimits)) return createArgumentError("RESOURCE_LIMIT_CONFIGURATION_INVALID", command, isJson);
|
|
424
|
+
const isScope = command === MOLDEA_CLI_COMMANDS.Scope;
|
|
425
|
+
const isContent = command === MOLDEA_CLI_COMMANDS.Content;
|
|
426
|
+
const hasPathInput = path !== null;
|
|
427
|
+
const hasStdinInput = seenOptions.has(MOLDEA_CLI_OPTIONS.PathsStdin);
|
|
428
|
+
if ((hasPathInput || hasStdinInput) && !isScope && !isContent) return createArgumentError("INVALID_ARGUMENT", command, isJson);
|
|
429
|
+
if (isScope && hasPathInput === hasStdinInput) return createArgumentError("INVALID_ARGUMENT", command, isJson);
|
|
430
|
+
if (isContent && (!hasPathInput || hasStdinInput)) return createArgumentError("INVALID_ARGUMENT", command, isJson);
|
|
431
|
+
if (isScope && seenOptions.has(MOLDEA_CLI_OPTIONS.MaxEvidence)) return createArgumentError("INVALID_ARGUMENT", command, isJson);
|
|
432
|
+
if (isContent && [
|
|
433
|
+
MOLDEA_CLI_OPTIONS.MaxDiagnostics,
|
|
434
|
+
MOLDEA_CLI_OPTIONS.MaxEvidence,
|
|
435
|
+
MOLDEA_CLI_OPTIONS.MaxManifestBytes
|
|
436
|
+
].some((option) => seenOptions.has(option))) return createArgumentError("INVALID_ARGUMENT", command, isJson);
|
|
437
|
+
if (!isJson && (cursor !== null || seenOptions.has(MOLDEA_CLI_OPTIONS.MaxOutputBytes))) return createArgumentError("INVALID_ARGUMENT", command, isJson);
|
|
184
438
|
const options = {
|
|
439
|
+
cursor,
|
|
185
440
|
isColorDisabled,
|
|
186
441
|
isJson,
|
|
442
|
+
maxOutputBytes,
|
|
443
|
+
path,
|
|
444
|
+
pathsInput,
|
|
187
445
|
repositoryDirectory,
|
|
188
446
|
resourceLimits: Object.freeze({ ...resourceLimits })
|
|
189
447
|
};
|
|
@@ -203,6 +461,26 @@ var MOLDEA_CLI_ERROR_DEFINITIONS = Object.freeze({
|
|
|
203
461
|
retryable: false,
|
|
204
462
|
source: "cli"
|
|
205
463
|
}),
|
|
464
|
+
CONTENT_INVALID: Object.freeze({
|
|
465
|
+
message: "The requested canonical asset is not valid moldea text.",
|
|
466
|
+
retryable: false,
|
|
467
|
+
source: "cli"
|
|
468
|
+
}),
|
|
469
|
+
CONTENT_PATH_INVALID: Object.freeze({
|
|
470
|
+
message: "The content path must identify one canonical moldea text asset.",
|
|
471
|
+
retryable: false,
|
|
472
|
+
source: "cli"
|
|
473
|
+
}),
|
|
474
|
+
CURSOR_INVALID: Object.freeze({
|
|
475
|
+
message: "The continuation cursor is invalid for this request.",
|
|
476
|
+
retryable: false,
|
|
477
|
+
source: "cli"
|
|
478
|
+
}),
|
|
479
|
+
CURSOR_SNAPSHOT_CHANGED: Object.freeze({
|
|
480
|
+
message: "The continuation cursor belongs to a different repository snapshot.",
|
|
481
|
+
retryable: true,
|
|
482
|
+
source: "cli"
|
|
483
|
+
}),
|
|
206
484
|
GIT_ACCESS_DENIED: Object.freeze({
|
|
207
485
|
message: "Git access was denied.",
|
|
208
486
|
retryable: true,
|
|
@@ -268,6 +546,16 @@ var MOLDEA_CLI_ERROR_DEFINITIONS = Object.freeze({
|
|
|
268
546
|
retryable: false,
|
|
269
547
|
source: "cli"
|
|
270
548
|
}),
|
|
549
|
+
OUTPUT_BUDGET_TOO_SMALL: Object.freeze({
|
|
550
|
+
message: "The output byte budget cannot contain the next complete result.",
|
|
551
|
+
retryable: false,
|
|
552
|
+
source: "cli"
|
|
553
|
+
}),
|
|
554
|
+
PATH_INPUT_INVALID: Object.freeze({
|
|
555
|
+
message: "The NUL-delimited changed-path input is invalid.",
|
|
556
|
+
retryable: false,
|
|
557
|
+
source: "cli"
|
|
558
|
+
}),
|
|
271
559
|
RESOURCE_LIMIT_CONFIGURATION_INVALID: Object.freeze({
|
|
272
560
|
message: "The resource-limit configuration is invalid.",
|
|
273
561
|
retryable: false,
|
|
@@ -289,7 +577,9 @@ var MOLDEA_CLI_TOP_LEVEL_HELP = `Usage: moldea <command> [options]
|
|
|
289
577
|
|
|
290
578
|
Commands:
|
|
291
579
|
validate Validate the current moldea project.
|
|
292
|
-
inspect Inspect
|
|
580
|
+
inspect Inspect content-free project metadata.
|
|
581
|
+
scope Match changed paths to declared moldea relationships.
|
|
582
|
+
content Read one canonical moldea asset explicitly.
|
|
293
583
|
composition Report the installed CLI composition state.
|
|
294
584
|
|
|
295
585
|
Global options:
|
|
@@ -298,18 +588,24 @@ Global options:
|
|
|
298
588
|
|
|
299
589
|
Run "moldea <command> --help" for command-specific options.
|
|
300
590
|
`;
|
|
301
|
-
var
|
|
302
|
-
--repository <path> Select a Git working-tree directory.
|
|
591
|
+
var REPOSITORY_OPTIONS_HELP = ` --repository <path> Select a Git working-tree directory.
|
|
303
592
|
--json Emit one machine-readable JSON result.
|
|
304
593
|
--no-color Disable ANSI styling in human output.
|
|
305
|
-
|
|
594
|
+
`;
|
|
595
|
+
var BASE_RESOURCE_OPTIONS_HELP = ` --max-entries <integer> Override the repository entry limit.
|
|
306
596
|
--max-file-bytes <integer> Override the per-file byte limit.
|
|
307
597
|
--max-total-bytes <integer> Override the total cached-byte limit.
|
|
308
|
-
|
|
598
|
+
`;
|
|
599
|
+
var INSPECTION_RESOURCE_OPTIONS_HELP = `${BASE_RESOURCE_OPTIONS_HELP} --max-manifest-bytes <integer> Override the manifest byte limit.
|
|
309
600
|
--max-diagnostics <integer> Override the diagnostic count limit.
|
|
310
|
-
--max-evidence <integer> Override the adapter evidence count limit.
|
|
311
|
-
--help Show this help.
|
|
312
601
|
`;
|
|
602
|
+
var PAGINATION_OPTIONS_HELP = ` --max-output-bytes <integer> Bound JSON output from 4096 to 1048576 bytes.
|
|
603
|
+
--cursor <opaque-cursor> Continue a prior JSON result page.
|
|
604
|
+
`;
|
|
605
|
+
var COMPLETE_INSPECTION_OPTIONS_HELP = `${REPOSITORY_OPTIONS_HELP}${INSPECTION_RESOURCE_OPTIONS_HELP} --max-evidence <integer> Override the adapter evidence count limit.
|
|
606
|
+
${PAGINATION_OPTIONS_HELP}`;
|
|
607
|
+
var SCOPE_OPTIONS_HELP = `${REPOSITORY_OPTIONS_HELP}${INSPECTION_RESOURCE_OPTIONS_HELP}${PAGINATION_OPTIONS_HELP}`;
|
|
608
|
+
var CONTENT_OPTIONS_HELP = `${REPOSITORY_OPTIONS_HELP}${BASE_RESOURCE_OPTIONS_HELP}${PAGINATION_OPTIONS_HELP}`;
|
|
313
609
|
var MOLDEA_CLI_COMMAND_HELP = {
|
|
314
610
|
[MOLDEA_CLI_COMMANDS.Composition]: `Usage: moldea composition [options]
|
|
315
611
|
|
|
@@ -322,14 +618,35 @@ Options:
|
|
|
322
618
|
`,
|
|
323
619
|
[MOLDEA_CLI_COMMANDS.Inspect]: `Usage: moldea inspect [options]
|
|
324
620
|
|
|
325
|
-
Inspect the current moldea project.
|
|
621
|
+
Inspect content-free metadata for the current moldea project.
|
|
622
|
+
|
|
623
|
+
Options:
|
|
624
|
+
${COMPLETE_INSPECTION_OPTIONS_HELP} --help Show this help.
|
|
625
|
+
`,
|
|
626
|
+
[MOLDEA_CLI_COMMANDS.Scope]: `Usage: moldea scope (--path <logical-path> | --paths-stdin) [options]
|
|
627
|
+
|
|
628
|
+
Match changed repository paths to declared moldea relationships. The stdin form accepts NUL-delimited UTF-8 logical paths.
|
|
629
|
+
|
|
630
|
+
Options:
|
|
631
|
+
${SCOPE_OPTIONS_HELP} --path <logical-path> Match one repository-logical path.
|
|
632
|
+
--paths-stdin Read NUL-delimited paths from stdin.
|
|
633
|
+
--help Show this help.
|
|
634
|
+
`,
|
|
635
|
+
[MOLDEA_CLI_COMMANDS.Content]: `Usage: moldea content --path <canonical-logical-path> [options]
|
|
636
|
+
|
|
637
|
+
Read one canonical moldea text asset in bounded Unicode-safe chunks.
|
|
326
638
|
|
|
327
|
-
|
|
639
|
+
Options:
|
|
640
|
+
${CONTENT_OPTIONS_HELP} --path <canonical-logical-path> Select exactly one canonical moldea file.
|
|
641
|
+
--help Show this help.
|
|
642
|
+
`,
|
|
328
643
|
[MOLDEA_CLI_COMMANDS.Validate]: `Usage: moldea validate [options]
|
|
329
644
|
|
|
330
645
|
Validate the current moldea project.
|
|
331
646
|
|
|
332
|
-
|
|
647
|
+
Options:
|
|
648
|
+
${COMPLETE_INSPECTION_OPTIONS_HELP} --help Show this help.
|
|
649
|
+
`
|
|
333
650
|
};
|
|
334
651
|
//#endregion
|
|
335
652
|
//#region src/presentation/errors.ts
|
|
@@ -338,2235 +655,271 @@ var EMPTY_ERROR_DETAILS$1 = Object.freeze({});
|
|
|
338
655
|
* Creates one immutable safe error from a CLI- or Git-owned definition.
|
|
339
656
|
* @param code The stable executable-owned error code.
|
|
340
657
|
* @returns The complete safe error object.
|
|
341
|
-
*/
|
|
342
|
-
var createMoldeaCliOwnedError = (code) => {
|
|
343
|
-
const definition = MOLDEA_CLI_ERROR_DEFINITIONS[code];
|
|
344
|
-
return Object.freeze({
|
|
345
|
-
code,
|
|
346
|
-
details: EMPTY_ERROR_DETAILS$1,
|
|
347
|
-
message: definition.message,
|
|
348
|
-
path: null,
|
|
349
|
-
retryable: definition.retryable,
|
|
350
|
-
source: definition.source
|
|
351
|
-
});
|
|
352
|
-
};
|
|
353
|
-
//#endregion
|
|
354
|
-
//#region src/json-serialization/serializer.ts
|
|
355
|
-
/** Compares strings by Unicode code point rather than UTF-16 code unit. */
|
|
356
|
-
var compareUnicodeCodePoints = (left, right) => {
|
|
357
|
-
const leftCodePoints = [...left];
|
|
358
|
-
const rightCodePoints = [...right];
|
|
359
|
-
const sharedLength = Math.min(leftCodePoints.length, rightCodePoints.length);
|
|
360
|
-
for (let index = 0; index < sharedLength; index += 1) {
|
|
361
|
-
const leftCodePoint = leftCodePoints[index]?.codePointAt(0);
|
|
362
|
-
const rightCodePoint = rightCodePoints[index]?.codePointAt(0);
|
|
363
|
-
if (leftCodePoint === void 0 || rightCodePoint === void 0) throw new TypeError("The JSON object key could not be compared.");
|
|
364
|
-
if (leftCodePoint !== rightCodePoint) return leftCodePoint - rightCodePoint;
|
|
365
|
-
}
|
|
366
|
-
return leftCodePoints.length - rightCodePoints.length;
|
|
367
|
-
};
|
|
368
|
-
/** Serializes one validated JSON value with recursively sorted object keys. */
|
|
369
|
-
var serializeJsonValue = (value, ancestors) => {
|
|
370
|
-
if (value === null || typeof value === "boolean" || typeof value === "string") return JSON.stringify(value);
|
|
371
|
-
if (typeof value === "number") {
|
|
372
|
-
if (!Number.isFinite(value)) throw new TypeError("The JSON number must be finite.");
|
|
373
|
-
return JSON.stringify(Object.is(value, -0) ? 0 : value);
|
|
374
|
-
}
|
|
375
|
-
if (typeof value !== "object") throw new TypeError("The value is not supported by the CLI JSON contract.");
|
|
376
|
-
if (ancestors.has(value)) throw new TypeError("The CLI JSON value must not contain a cycle.");
|
|
377
|
-
ancestors.add(value);
|
|
378
|
-
try {
|
|
379
|
-
if (Array.isArray(value)) {
|
|
380
|
-
const serializedEntries = [];
|
|
381
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
382
|
-
if (!Object.hasOwn(value, index)) throw new TypeError("The CLI JSON array must not contain empty slots.");
|
|
383
|
-
serializedEntries.push(serializeJsonValue(value[index], ancestors));
|
|
384
|
-
}
|
|
385
|
-
return `[${serializedEntries.join(",")}]`;
|
|
386
|
-
}
|
|
387
|
-
const prototype = Object.getPrototypeOf(value);
|
|
388
|
-
if (prototype !== Object.prototype && prototype !== null) throw new TypeError("The CLI JSON object must be a plain record.");
|
|
389
|
-
if (Object.getOwnPropertySymbols(value).length > 0) throw new TypeError("The CLI JSON object must not contain symbol keys.");
|
|
390
|
-
const record = value;
|
|
391
|
-
return `{${Object.keys(record).sort(compareUnicodeCodePoints).map((key) => `${JSON.stringify(key)}:${serializeJsonValue(record[key], ancestors)}`).join(",")}}`;
|
|
392
|
-
} finally {
|
|
393
|
-
ancestors.delete(value);
|
|
394
|
-
}
|
|
395
|
-
};
|
|
396
|
-
/**
|
|
397
|
-
* Serializes one CLI JSON value with exact recursive Unicode code-point key ordering.
|
|
398
|
-
* @param value The closed JSON value to serialize.
|
|
399
|
-
* @returns Compact deterministic JSON without a trailing line feed.
|
|
400
|
-
* @throws
|
|
401
|
-
* - If the value contains unsupported, non-finite, symbolic, class-backed, or cyclic data
|
|
402
|
-
*/
|
|
403
|
-
var serializeJsonDeterministically = (value) => {
|
|
404
|
-
return serializeJsonValue(value, /* @__PURE__ */ new Set());
|
|
405
|
-
};
|
|
406
|
-
//#endregion
|
|
407
|
-
//#region src/presentation/formatters.ts
|
|
408
|
-
var DIAGNOSTIC_ENTITY_KEYS = [
|
|
409
|
-
"agentId",
|
|
410
|
-
"capabilityKind",
|
|
411
|
-
"capabilityId",
|
|
412
|
-
"decisionId",
|
|
413
|
-
"variableId",
|
|
414
|
-
"adapterId"
|
|
415
|
-
];
|
|
416
|
-
/** Formats one diagnostic entity in the canonical Core field order. */
|
|
417
|
-
var formatMoldeaCliHumanDiagnosticEntity = (entity) => DIAGNOSTIC_ENTITY_KEYS.flatMap((key) => {
|
|
418
|
-
const identifier = entity[key];
|
|
419
|
-
return identifier === void 0 ? [] : [`${key}=${identifier}`];
|
|
420
|
-
}).join(", ");
|
|
421
|
-
/** Formats one Core or adapter diagnostic without changing its order or meaning. */
|
|
422
|
-
var formatMoldeaCliHumanDiagnostic = (diagnostic) => {
|
|
423
|
-
const location = diagnostic.path === null ? "" : diagnostic.range === null ? ` ${diagnostic.path}` : ` ${diagnostic.path}:${diagnostic.range.start.line}:${diagnostic.range.start.column}`;
|
|
424
|
-
const lines = [`${diagnostic.source}:${diagnostic.code}${location} ${diagnostic.message}`];
|
|
425
|
-
if (diagnostic.pointer !== null) lines.push(` pointer: ${diagnostic.pointer}`);
|
|
426
|
-
if (diagnostic.entity !== null) lines.push(` entity: ${formatMoldeaCliHumanDiagnosticEntity(diagnostic.entity)}`);
|
|
427
|
-
return lines.join("\n");
|
|
428
|
-
};
|
|
429
|
-
/** Creates the shared human summary lines for one completed inspection state. */
|
|
430
|
-
var createMoldeaCliHumanStatusLines = (isValid, formatVersion) => {
|
|
431
|
-
const lines = [`The moldea project is ${isValid ? "valid" : "invalid"}.`];
|
|
432
|
-
if (formatVersion !== null) lines.push(`Repository format: ${formatVersion}`);
|
|
433
|
-
return lines;
|
|
434
|
-
};
|
|
435
|
-
/** Appends Core diagnostics and their final count without changing supplied order. */
|
|
436
|
-
var appendMoldeaCliHumanDiagnostics = (lines, diagnostics) => {
|
|
437
|
-
for (const diagnostic of diagnostics) lines.push(formatMoldeaCliHumanDiagnostic(diagnostic));
|
|
438
|
-
const diagnosticLabel = diagnostics.length === 1 ? "diagnostic" : "diagnostics";
|
|
439
|
-
lines.push(`${diagnostics.length} ${diagnosticLabel}.`);
|
|
440
|
-
};
|
|
441
|
-
/** Formats one count label with correct singular or plural grammar. */
|
|
442
|
-
var formatMoldeaCliHumanCount = (count, singularLabel, pluralLabel) => `${count === 1 ? singularLabel : pluralLabel}: ${count}`;
|
|
443
|
-
/**
|
|
444
|
-
* Formats top-level or command-specific help with its required trailing line feed.
|
|
445
|
-
* @param command The resolved command, or null for top-level help.
|
|
446
|
-
* @returns Human-readable help text.
|
|
447
|
-
*/
|
|
448
|
-
var formatMoldeaCliHelp = (command) => {
|
|
449
|
-
if (command === null) return MOLDEA_CLI_TOP_LEVEL_HELP;
|
|
450
|
-
return MOLDEA_CLI_COMMAND_HELP[command];
|
|
451
|
-
};
|
|
452
|
-
/**
|
|
453
|
-
* Formats one safe CLI error for human stderr output.
|
|
454
|
-
* @param error The complete safe operational error.
|
|
455
|
-
* @returns One concise line ending with LF.
|
|
456
|
-
*/
|
|
457
|
-
var formatMoldeaCliHumanError = (error) => `${error.source}:${error.code} ${error.message}\n`;
|
|
458
|
-
/**
|
|
459
|
-
* Formats one safe version 2 JSON error envelope.
|
|
460
|
-
* @param error The complete safe operational error.
|
|
461
|
-
* @param command The resolved command, or null when resolution failed.
|
|
462
|
-
* @param cliVersion The installed CLI package version.
|
|
463
|
-
* @returns One compact deterministic JSON document ending with LF.
|
|
464
|
-
*/
|
|
465
|
-
var formatMoldeaCliJsonError = (error, command, cliVersion) => {
|
|
466
|
-
return `${serializeJsonDeterministically({
|
|
467
|
-
cliVersion,
|
|
468
|
-
command,
|
|
469
|
-
error,
|
|
470
|
-
result: null,
|
|
471
|
-
schemaVersion: 2,
|
|
472
|
-
status: "error"
|
|
473
|
-
})}\n`;
|
|
474
|
-
};
|
|
475
|
-
/**
|
|
476
|
-
* Formats one valid composition result for human stdout.
|
|
477
|
-
* @param result The exact installed composition.
|
|
478
|
-
* @param cliVersion The installed CLI package version.
|
|
479
|
-
* @returns A deterministic complete human report ending with LF.
|
|
480
|
-
*/
|
|
481
|
-
var formatMoldeaCliHumanCompositionResult = (result, cliVersion) => {
|
|
482
|
-
const lines = [
|
|
483
|
-
"The installed CLI composition state is valid.",
|
|
484
|
-
`CLI version: ${cliVersion}`,
|
|
485
|
-
`Supported Node.js: ${result.supportedNodeRange}`,
|
|
486
|
-
`JSON output schema: 2`,
|
|
487
|
-
`Minimum Git: ${result.minimumGitVersion}`,
|
|
488
|
-
`Repository formats: ${result.repositoryFormatVersions.join(", ")}`,
|
|
489
|
-
"Packages:",
|
|
490
|
-
...result.packages.map(({ name, version }) => ` ${name}: ${version}`),
|
|
491
|
-
"Adapters:"
|
|
492
|
-
];
|
|
493
|
-
for (const adapter of result.adapters) lines.push(` ${adapter.id}: repository formats ${adapter.repositoryFormatVersions.join(", ")}`);
|
|
494
|
-
return `${lines.join("\n")}\n`;
|
|
495
|
-
};
|
|
496
|
-
/**
|
|
497
|
-
* Formats one valid composition result as a version 2 JSON envelope.
|
|
498
|
-
* @param result The exact installed composition.
|
|
499
|
-
* @param cliVersion The installed CLI package version.
|
|
500
|
-
* @returns One compact deterministic JSON document ending with LF.
|
|
501
|
-
*/
|
|
502
|
-
var formatMoldeaCliJsonCompositionResult = (result, cliVersion) => {
|
|
503
|
-
return `${serializeJsonDeterministically({
|
|
504
|
-
cliVersion,
|
|
505
|
-
command: MOLDEA_CLI_COMMANDS.Composition,
|
|
506
|
-
error: null,
|
|
507
|
-
result,
|
|
508
|
-
schemaVersion: 2,
|
|
509
|
-
status: "valid"
|
|
510
|
-
})}\n`;
|
|
511
|
-
};
|
|
512
|
-
/**
|
|
513
|
-
* Formats one completed validation result for human stdout.
|
|
514
|
-
* @param result The content-minimized validation result.
|
|
515
|
-
* @returns A deterministic summary and diagnostics ending with LF.
|
|
516
|
-
*/
|
|
517
|
-
var formatMoldeaCliHumanValidateResult = (result) => {
|
|
518
|
-
const isValid = result.diagnostics.length === 0;
|
|
519
|
-
const lines = createMoldeaCliHumanStatusLines(isValid, result.formatVersion);
|
|
520
|
-
if (!isValid) appendMoldeaCliHumanDiagnostics(lines, result.diagnostics);
|
|
521
|
-
return `${lines.join("\n")}\n`;
|
|
522
|
-
};
|
|
523
|
-
/**
|
|
524
|
-
* Formats one completed validation result as a version 2 JSON envelope.
|
|
525
|
-
* @param result The content-minimized validation result.
|
|
526
|
-
* @param cliVersion The installed CLI package version.
|
|
527
|
-
* @returns One compact deterministic JSON document ending with LF.
|
|
528
|
-
*/
|
|
529
|
-
var formatMoldeaCliJsonValidateResult = (result, cliVersion) => {
|
|
530
|
-
return `${serializeJsonDeterministically({
|
|
531
|
-
cliVersion,
|
|
532
|
-
command: MOLDEA_CLI_COMMANDS.Validate,
|
|
533
|
-
error: null,
|
|
534
|
-
result,
|
|
535
|
-
schemaVersion: 2,
|
|
536
|
-
status: result.diagnostics.length === 0 ? "valid" : "invalid"
|
|
537
|
-
})}\n`;
|
|
538
|
-
};
|
|
539
|
-
/**
|
|
540
|
-
* Formats one completed inspection result for human stdout.
|
|
541
|
-
* @param result The complete inspection result and its source descriptor.
|
|
542
|
-
* @returns A deterministic content-free summary or diagnostic report ending with LF.
|
|
543
|
-
* @throws If a Core-valid result does not include its complete project index.
|
|
544
|
-
*/
|
|
545
|
-
var formatMoldeaCliHumanInspectResult = (result) => {
|
|
546
|
-
const { inspection } = result;
|
|
547
|
-
const lines = createMoldeaCliHumanStatusLines(inspection.valid, inspection.formatVersion);
|
|
548
|
-
if (!inspection.valid) {
|
|
549
|
-
if (inspection.evidence.length > 0) lines.push(formatMoldeaCliHumanCount(inspection.evidence.length, "Adapter evidence item", "Adapter evidence items"));
|
|
550
|
-
appendMoldeaCliHumanDiagnostics(lines, inspection.diagnostics);
|
|
551
|
-
return `${lines.join("\n")}\n`;
|
|
552
|
-
}
|
|
553
|
-
if (inspection.project === null) throw new TypeError("A valid Core inspection must include its project index.");
|
|
554
|
-
const mirrorCount = inspection.project.agents.reduce((count, agent) => count + agent.mirrors.length, 0);
|
|
555
|
-
lines.push(formatMoldeaCliHumanCount(inspection.project.context.length, "Context asset", "Context assets"), formatMoldeaCliHumanCount(inspection.project.decisions.length, "Decision", "Decisions"), formatMoldeaCliHumanCount(inspection.project.runtimes.length, "Runtime-guidance asset", "Runtime-guidance assets"), formatMoldeaCliHumanCount(inspection.project.agents.length, "Agent", "Agents"), formatMoldeaCliHumanCount(mirrorCount, "Mirror", "Mirrors"), formatMoldeaCliHumanCount(inspection.evidence.length, "Adapter evidence item", "Adapter evidence items"));
|
|
556
|
-
return `${lines.join("\n")}\n`;
|
|
557
|
-
};
|
|
558
|
-
/**
|
|
559
|
-
* Formats one completed inspection result as a version 2 JSON envelope.
|
|
560
|
-
* @param result The complete inspection result and its source descriptor.
|
|
561
|
-
* @param cliVersion The installed CLI package version.
|
|
562
|
-
* @returns One compact deterministic JSON document ending with LF.
|
|
563
|
-
*/
|
|
564
|
-
var formatMoldeaCliJsonInspectResult = (result, cliVersion) => {
|
|
565
|
-
return `${serializeJsonDeterministically({
|
|
566
|
-
cliVersion,
|
|
567
|
-
command: MOLDEA_CLI_COMMANDS.Inspect,
|
|
568
|
-
error: null,
|
|
569
|
-
result,
|
|
570
|
-
schemaVersion: 2,
|
|
571
|
-
status: result.inspection.valid ? "valid" : "invalid"
|
|
572
|
-
})}\n`;
|
|
573
|
-
};
|
|
574
|
-
//#endregion
|
|
575
|
-
//#region src/presentation/transformers.ts
|
|
576
|
-
/** Rejects a Core result whose completion fields contradict its validity. */
|
|
577
|
-
var assertProjectInspectionInvariant = (inspection) => {
|
|
578
|
-
const hasDiagnostics = inspection.diagnostics.length > 0;
|
|
579
|
-
const hasProject = inspection.project !== null;
|
|
580
|
-
if (!(inspection.valid ? hasProject && !hasDiagnostics : !hasProject && hasDiagnostics)) throw new TypeError("The Core inspection result is internally inconsistent.");
|
|
581
|
-
};
|
|
582
|
-
/**
|
|
583
|
-
* Reduces one complete Core inspection to the content-minimized validate result.
|
|
584
|
-
* @param inspection The immutable Core inspection result.
|
|
585
|
-
* @returns A frozen validation result without project content or adapter evidence.
|
|
586
|
-
*/
|
|
587
|
-
var createMoldeaCliValidateResult = (inspection) => Object.freeze({
|
|
588
|
-
diagnostics: inspection.diagnostics,
|
|
589
|
-
formatVersion: inspection.formatVersion,
|
|
590
|
-
source: MOLDEA_CLI_GIT_WORKING_TREE_SOURCE
|
|
591
|
-
});
|
|
592
|
-
/**
|
|
593
|
-
* Pairs one complete Core inspection with its non-confidential source descriptor.
|
|
594
|
-
* @param inspection The immutable Core inspection result.
|
|
595
|
-
* @returns A frozen result preserving the exact complete Core inspection.
|
|
596
|
-
* @throws If the Core result contradicts its valid, project, and diagnostic invariants.
|
|
597
|
-
*/
|
|
598
|
-
var createMoldeaCliInspectResult = (inspection) => {
|
|
599
|
-
assertProjectInspectionInvariant(inspection);
|
|
600
|
-
return Object.freeze({
|
|
601
|
-
inspection,
|
|
602
|
-
source: MOLDEA_CLI_GIT_WORKING_TREE_SOURCE
|
|
603
|
-
});
|
|
604
|
-
};
|
|
605
|
-
//#endregion
|
|
606
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/constants.js
|
|
607
|
-
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
608
|
-
module.exports = {
|
|
609
|
-
MAX_LENGTH: 256,
|
|
610
|
-
MAX_SAFE_COMPONENT_LENGTH: 16,
|
|
611
|
-
MAX_SAFE_BUILD_LENGTH: 250,
|
|
612
|
-
MAX_SAFE_INTEGER: Number.MAX_SAFE_INTEGER ||
|
|
613
|
-
/* istanbul ignore next */ 9007199254740991,
|
|
614
|
-
RELEASE_TYPES: [
|
|
615
|
-
"major",
|
|
616
|
-
"premajor",
|
|
617
|
-
"minor",
|
|
618
|
-
"preminor",
|
|
619
|
-
"patch",
|
|
620
|
-
"prepatch",
|
|
621
|
-
"prerelease"
|
|
622
|
-
],
|
|
623
|
-
SEMVER_SPEC_VERSION: "2.0.0",
|
|
624
|
-
FLAG_INCLUDE_PRERELEASE: 1,
|
|
625
|
-
FLAG_LOOSE: 2
|
|
626
|
-
};
|
|
627
|
-
}));
|
|
628
|
-
//#endregion
|
|
629
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/debug.js
|
|
630
|
-
var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
631
|
-
module.exports = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
|
|
632
|
-
}));
|
|
633
|
-
//#endregion
|
|
634
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/re.js
|
|
635
|
-
var require_re = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
636
|
-
var { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH } = require_constants();
|
|
637
|
-
var debug = require_debug();
|
|
638
|
-
exports = module.exports = {};
|
|
639
|
-
var re = exports.re = [];
|
|
640
|
-
var safeRe = exports.safeRe = [];
|
|
641
|
-
var src = exports.src = [];
|
|
642
|
-
var safeSrc = exports.safeSrc = [];
|
|
643
|
-
var t = exports.t = {};
|
|
644
|
-
var R = 0;
|
|
645
|
-
var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
646
|
-
var safeRegexReplacements = [
|
|
647
|
-
["\\s", 1],
|
|
648
|
-
["\\d", MAX_LENGTH],
|
|
649
|
-
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
650
|
-
];
|
|
651
|
-
var makeSafeRegex = (value) => {
|
|
652
|
-
for (const [token, max] of safeRegexReplacements) value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
|
|
653
|
-
return value;
|
|
654
|
-
};
|
|
655
|
-
var createToken = (name, value, isGlobal) => {
|
|
656
|
-
const safe = makeSafeRegex(value);
|
|
657
|
-
const index = R++;
|
|
658
|
-
debug(name, index, value);
|
|
659
|
-
t[name] = index;
|
|
660
|
-
src[index] = value;
|
|
661
|
-
safeSrc[index] = safe;
|
|
662
|
-
re[index] = new RegExp(value, isGlobal ? "g" : void 0);
|
|
663
|
-
safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
|
|
664
|
-
};
|
|
665
|
-
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
666
|
-
createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
|
|
667
|
-
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
668
|
-
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
|
|
669
|
-
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
670
|
-
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
671
|
-
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
672
|
-
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
673
|
-
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
674
|
-
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
675
|
-
createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
676
|
-
createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
677
|
-
createToken("FULL", `^${src[t.FULLPLAIN]}$`);
|
|
678
|
-
createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
679
|
-
createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
|
|
680
|
-
createToken("GTLT", "((?:<|>)?=?)");
|
|
681
|
-
createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
682
|
-
createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
683
|
-
createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
|
|
684
|
-
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
|
|
685
|
-
createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
686
|
-
createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
687
|
-
createToken("COERCEPLAIN", `(^|[^\\d])(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
688
|
-
createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
689
|
-
createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
|
|
690
|
-
createToken("COERCERTL", src[t.COERCE], true);
|
|
691
|
-
createToken("COERCERTLFULL", src[t.COERCEFULL], true);
|
|
692
|
-
createToken("LONETILDE", "(?:~>?)");
|
|
693
|
-
createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
694
|
-
exports.tildeTrimReplace = "$1~";
|
|
695
|
-
createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
696
|
-
createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
697
|
-
createToken("LONECARET", "(?:\\^)");
|
|
698
|
-
createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
699
|
-
exports.caretTrimReplace = "$1^";
|
|
700
|
-
createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
701
|
-
createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
702
|
-
createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
703
|
-
createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
704
|
-
createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
705
|
-
exports.comparatorTrimReplace = "$1$2$3";
|
|
706
|
-
createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
|
|
707
|
-
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
|
|
708
|
-
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
709
|
-
createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
|
|
710
|
-
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
711
|
-
}));
|
|
712
|
-
//#endregion
|
|
713
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/parse-options.js
|
|
714
|
-
var require_parse_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
715
|
-
var looseOption = Object.freeze({ loose: true });
|
|
716
|
-
var emptyOpts = Object.freeze({});
|
|
717
|
-
var parseOptions = (options) => {
|
|
718
|
-
if (!options) return emptyOpts;
|
|
719
|
-
if (typeof options !== "object") return looseOption;
|
|
720
|
-
return options;
|
|
721
|
-
};
|
|
722
|
-
module.exports = parseOptions;
|
|
723
|
-
}));
|
|
724
|
-
//#endregion
|
|
725
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/identifiers.js
|
|
726
|
-
var require_identifiers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
727
|
-
var numeric = /^[0-9]+$/;
|
|
728
|
-
var compareIdentifiers = (a, b) => {
|
|
729
|
-
if (typeof a === "number" && typeof b === "number") return a === b ? 0 : a < b ? -1 : 1;
|
|
730
|
-
const anum = numeric.test(a);
|
|
731
|
-
const bnum = numeric.test(b);
|
|
732
|
-
if (anum && bnum) {
|
|
733
|
-
a = +a;
|
|
734
|
-
b = +b;
|
|
735
|
-
}
|
|
736
|
-
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
737
|
-
};
|
|
738
|
-
var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
739
|
-
module.exports = {
|
|
740
|
-
compareIdentifiers,
|
|
741
|
-
rcompareIdentifiers
|
|
742
|
-
};
|
|
743
|
-
}));
|
|
744
|
-
//#endregion
|
|
745
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/semver.js
|
|
746
|
-
var require_semver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
747
|
-
var debug = require_debug();
|
|
748
|
-
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
749
|
-
var { safeRe: re, t } = require_re();
|
|
750
|
-
var parseOptions = require_parse_options();
|
|
751
|
-
var { compareIdentifiers } = require_identifiers();
|
|
752
|
-
var isPrereleaseIdentifier = (prerelease, identifier) => {
|
|
753
|
-
const identifiers = identifier.split(".");
|
|
754
|
-
if (identifiers.length > prerelease.length) return false;
|
|
755
|
-
for (let i = 0; i < identifiers.length; i++) if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0) return false;
|
|
756
|
-
return true;
|
|
757
|
-
};
|
|
758
|
-
module.exports = class SemVer {
|
|
759
|
-
constructor(version, options) {
|
|
760
|
-
options = parseOptions(options);
|
|
761
|
-
if (version instanceof SemVer) {
|
|
762
|
-
if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) return version;
|
|
763
|
-
else version = version.version;
|
|
764
|
-
} else if (typeof version !== "string") throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
|
|
765
|
-
if (version.length > MAX_LENGTH) throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
|
|
766
|
-
debug("SemVer", version, options);
|
|
767
|
-
this.options = options;
|
|
768
|
-
this.loose = !!options.loose;
|
|
769
|
-
this.includePrerelease = !!options.includePrerelease;
|
|
770
|
-
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
771
|
-
if (!m) throw new TypeError(`Invalid Version: ${version}`);
|
|
772
|
-
this.raw = version;
|
|
773
|
-
this.major = +m[1];
|
|
774
|
-
this.minor = +m[2];
|
|
775
|
-
this.patch = +m[3];
|
|
776
|
-
if (this.major > MAX_SAFE_INTEGER || this.major < 0) throw new TypeError("Invalid major version");
|
|
777
|
-
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) throw new TypeError("Invalid minor version");
|
|
778
|
-
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) throw new TypeError("Invalid patch version");
|
|
779
|
-
if (!m[4]) this.prerelease = [];
|
|
780
|
-
else this.prerelease = m[4].split(".").map((id) => {
|
|
781
|
-
if (/^[0-9]+$/.test(id)) {
|
|
782
|
-
const num = +id;
|
|
783
|
-
if (num >= 0 && num < MAX_SAFE_INTEGER) return num;
|
|
784
|
-
}
|
|
785
|
-
return id;
|
|
786
|
-
});
|
|
787
|
-
this.build = m[5] ? m[5].split(".") : [];
|
|
788
|
-
this.format();
|
|
789
|
-
}
|
|
790
|
-
format() {
|
|
791
|
-
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
792
|
-
if (this.prerelease.length) this.version += `-${this.prerelease.join(".")}`;
|
|
793
|
-
return this.version;
|
|
794
|
-
}
|
|
795
|
-
toString() {
|
|
796
|
-
return this.version;
|
|
797
|
-
}
|
|
798
|
-
compare(other) {
|
|
799
|
-
debug("SemVer.compare", this.version, this.options, other);
|
|
800
|
-
if (!(other instanceof SemVer)) {
|
|
801
|
-
if (typeof other === "string" && other === this.version) return 0;
|
|
802
|
-
other = new SemVer(other, this.options);
|
|
803
|
-
}
|
|
804
|
-
if (other.version === this.version) return 0;
|
|
805
|
-
return this.compareMain(other) || this.comparePre(other);
|
|
806
|
-
}
|
|
807
|
-
compareMain(other) {
|
|
808
|
-
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
809
|
-
if (this.major < other.major) return -1;
|
|
810
|
-
if (this.major > other.major) return 1;
|
|
811
|
-
if (this.minor < other.minor) return -1;
|
|
812
|
-
if (this.minor > other.minor) return 1;
|
|
813
|
-
if (this.patch < other.patch) return -1;
|
|
814
|
-
if (this.patch > other.patch) return 1;
|
|
815
|
-
return 0;
|
|
816
|
-
}
|
|
817
|
-
comparePre(other) {
|
|
818
|
-
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
819
|
-
if (this.prerelease.length && !other.prerelease.length) return -1;
|
|
820
|
-
else if (!this.prerelease.length && other.prerelease.length) return 1;
|
|
821
|
-
else if (!this.prerelease.length && !other.prerelease.length) return 0;
|
|
822
|
-
let i = 0;
|
|
823
|
-
do {
|
|
824
|
-
const a = this.prerelease[i];
|
|
825
|
-
const b = other.prerelease[i];
|
|
826
|
-
debug("prerelease compare", i, a, b);
|
|
827
|
-
if (a === void 0 && b === void 0) return 0;
|
|
828
|
-
else if (b === void 0) return 1;
|
|
829
|
-
else if (a === void 0) return -1;
|
|
830
|
-
else if (a === b) continue;
|
|
831
|
-
else return compareIdentifiers(a, b);
|
|
832
|
-
} while (++i);
|
|
833
|
-
}
|
|
834
|
-
compareBuild(other) {
|
|
835
|
-
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
836
|
-
let i = 0;
|
|
837
|
-
do {
|
|
838
|
-
const a = this.build[i];
|
|
839
|
-
const b = other.build[i];
|
|
840
|
-
debug("build compare", i, a, b);
|
|
841
|
-
if (a === void 0 && b === void 0) return 0;
|
|
842
|
-
else if (b === void 0) return 1;
|
|
843
|
-
else if (a === void 0) return -1;
|
|
844
|
-
else if (a === b) continue;
|
|
845
|
-
else return compareIdentifiers(a, b);
|
|
846
|
-
} while (++i);
|
|
847
|
-
}
|
|
848
|
-
inc(release, identifier, identifierBase) {
|
|
849
|
-
if (release.startsWith("pre")) {
|
|
850
|
-
if (!identifier && identifierBase === false) throw new Error("invalid increment argument: identifier is empty");
|
|
851
|
-
if (identifier) {
|
|
852
|
-
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
|
|
853
|
-
if (!match || match[1] !== identifier) throw new Error(`invalid identifier: ${identifier}`);
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
switch (release) {
|
|
857
|
-
case "premajor":
|
|
858
|
-
this.prerelease.length = 0;
|
|
859
|
-
this.patch = 0;
|
|
860
|
-
this.minor = 0;
|
|
861
|
-
this.major++;
|
|
862
|
-
this.inc("pre", identifier, identifierBase);
|
|
863
|
-
break;
|
|
864
|
-
case "preminor":
|
|
865
|
-
this.prerelease.length = 0;
|
|
866
|
-
this.patch = 0;
|
|
867
|
-
this.minor++;
|
|
868
|
-
this.inc("pre", identifier, identifierBase);
|
|
869
|
-
break;
|
|
870
|
-
case "prepatch":
|
|
871
|
-
this.prerelease.length = 0;
|
|
872
|
-
this.inc("patch", identifier, identifierBase);
|
|
873
|
-
this.inc("pre", identifier, identifierBase);
|
|
874
|
-
break;
|
|
875
|
-
case "prerelease":
|
|
876
|
-
if (this.prerelease.length === 0) this.inc("patch", identifier, identifierBase);
|
|
877
|
-
this.inc("pre", identifier, identifierBase);
|
|
878
|
-
break;
|
|
879
|
-
case "release":
|
|
880
|
-
if (this.prerelease.length === 0) throw new Error(`version ${this.raw} is not a prerelease`);
|
|
881
|
-
this.prerelease.length = 0;
|
|
882
|
-
break;
|
|
883
|
-
case "major":
|
|
884
|
-
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) this.major++;
|
|
885
|
-
this.minor = 0;
|
|
886
|
-
this.patch = 0;
|
|
887
|
-
this.prerelease = [];
|
|
888
|
-
break;
|
|
889
|
-
case "minor":
|
|
890
|
-
if (this.patch !== 0 || this.prerelease.length === 0) this.minor++;
|
|
891
|
-
this.patch = 0;
|
|
892
|
-
this.prerelease = [];
|
|
893
|
-
break;
|
|
894
|
-
case "patch":
|
|
895
|
-
if (this.prerelease.length === 0) this.patch++;
|
|
896
|
-
this.prerelease = [];
|
|
897
|
-
break;
|
|
898
|
-
case "pre": {
|
|
899
|
-
const base = Number(identifierBase) ? 1 : 0;
|
|
900
|
-
if (this.prerelease.length === 0) this.prerelease = [base];
|
|
901
|
-
else {
|
|
902
|
-
let i = this.prerelease.length;
|
|
903
|
-
while (--i >= 0) if (typeof this.prerelease[i] === "number") {
|
|
904
|
-
this.prerelease[i]++;
|
|
905
|
-
i = -2;
|
|
906
|
-
}
|
|
907
|
-
if (i === -1) {
|
|
908
|
-
if (identifier === this.prerelease.join(".") && identifierBase === false) throw new Error("invalid increment argument: identifier already exists");
|
|
909
|
-
this.prerelease.push(base);
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
if (identifier) {
|
|
913
|
-
let prerelease = [identifier, base];
|
|
914
|
-
if (identifierBase === false) prerelease = [identifier];
|
|
915
|
-
if (isPrereleaseIdentifier(this.prerelease, identifier)) {
|
|
916
|
-
const prereleaseBase = this.prerelease[identifier.split(".").length];
|
|
917
|
-
if (isNaN(prereleaseBase)) this.prerelease = prerelease;
|
|
918
|
-
} else this.prerelease = prerelease;
|
|
919
|
-
}
|
|
920
|
-
break;
|
|
921
|
-
}
|
|
922
|
-
default: throw new Error(`invalid increment argument: ${release}`);
|
|
923
|
-
}
|
|
924
|
-
this.raw = this.format();
|
|
925
|
-
if (this.build.length) this.raw += `+${this.build.join(".")}`;
|
|
926
|
-
return this;
|
|
927
|
-
}
|
|
928
|
-
};
|
|
929
|
-
}));
|
|
930
|
-
//#endregion
|
|
931
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/parse.js
|
|
932
|
-
var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
933
|
-
var SemVer = require_semver$1();
|
|
934
|
-
var parse = (version, options, throwErrors = false) => {
|
|
935
|
-
if (version instanceof SemVer) return version;
|
|
936
|
-
try {
|
|
937
|
-
return new SemVer(version, options);
|
|
938
|
-
} catch (er) {
|
|
939
|
-
if (!throwErrors) return null;
|
|
940
|
-
throw er;
|
|
941
|
-
}
|
|
942
|
-
};
|
|
943
|
-
module.exports = parse;
|
|
944
|
-
}));
|
|
945
|
-
//#endregion
|
|
946
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/valid.js
|
|
947
|
-
var require_valid$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
948
|
-
var parse = require_parse();
|
|
949
|
-
var valid = (version, options) => {
|
|
950
|
-
const v = parse(version, options);
|
|
951
|
-
return v ? v.version : null;
|
|
952
|
-
};
|
|
953
|
-
module.exports = valid;
|
|
954
|
-
}));
|
|
955
|
-
//#endregion
|
|
956
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/clean.js
|
|
957
|
-
var require_clean = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
958
|
-
var parse = require_parse();
|
|
959
|
-
var clean = (version, options) => {
|
|
960
|
-
const s = parse(version.trim().replace(/^[=v]+/, ""), options);
|
|
961
|
-
return s ? s.version : null;
|
|
962
|
-
};
|
|
963
|
-
module.exports = clean;
|
|
964
|
-
}));
|
|
965
|
-
//#endregion
|
|
966
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/inc.js
|
|
967
|
-
var require_inc = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
968
|
-
var SemVer = require_semver$1();
|
|
969
|
-
var inc = (version, release, options, identifier, identifierBase) => {
|
|
970
|
-
if (typeof options === "string") {
|
|
971
|
-
identifierBase = identifier;
|
|
972
|
-
identifier = options;
|
|
973
|
-
options = void 0;
|
|
974
|
-
}
|
|
975
|
-
try {
|
|
976
|
-
return new SemVer(version instanceof SemVer ? version.version : version, options).inc(release, identifier, identifierBase).version;
|
|
977
|
-
} catch (er) {
|
|
978
|
-
return null;
|
|
979
|
-
}
|
|
980
|
-
};
|
|
981
|
-
module.exports = inc;
|
|
982
|
-
}));
|
|
983
|
-
//#endregion
|
|
984
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/diff.js
|
|
985
|
-
var require_diff = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
986
|
-
var parse = require_parse();
|
|
987
|
-
var diff = (version1, version2) => {
|
|
988
|
-
const v1 = parse(version1, null, true);
|
|
989
|
-
const v2 = parse(version2, null, true);
|
|
990
|
-
const comparison = v1.compare(v2);
|
|
991
|
-
if (comparison === 0) return null;
|
|
992
|
-
const v1Higher = comparison > 0;
|
|
993
|
-
const highVersion = v1Higher ? v1 : v2;
|
|
994
|
-
const lowVersion = v1Higher ? v2 : v1;
|
|
995
|
-
const highHasPre = !!highVersion.prerelease.length;
|
|
996
|
-
if (!!lowVersion.prerelease.length && !highHasPre) {
|
|
997
|
-
if (!lowVersion.patch && !lowVersion.minor) return "major";
|
|
998
|
-
if (lowVersion.compareMain(highVersion) === 0) {
|
|
999
|
-
if (lowVersion.minor && !lowVersion.patch) return "minor";
|
|
1000
|
-
return "patch";
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
const prefix = highHasPre ? "pre" : "";
|
|
1004
|
-
if (v1.major !== v2.major) return prefix + "major";
|
|
1005
|
-
if (v1.minor !== v2.minor) return prefix + "minor";
|
|
1006
|
-
if (v1.patch !== v2.patch) return prefix + "patch";
|
|
1007
|
-
return "prerelease";
|
|
1008
|
-
};
|
|
1009
|
-
module.exports = diff;
|
|
1010
|
-
}));
|
|
1011
|
-
//#endregion
|
|
1012
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/major.js
|
|
1013
|
-
var require_major = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1014
|
-
var SemVer = require_semver$1();
|
|
1015
|
-
var major = (a, loose) => new SemVer(a, loose).major;
|
|
1016
|
-
module.exports = major;
|
|
1017
|
-
}));
|
|
1018
|
-
//#endregion
|
|
1019
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/minor.js
|
|
1020
|
-
var require_minor = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1021
|
-
var SemVer = require_semver$1();
|
|
1022
|
-
var minor = (a, loose) => new SemVer(a, loose).minor;
|
|
1023
|
-
module.exports = minor;
|
|
1024
|
-
}));
|
|
1025
|
-
//#endregion
|
|
1026
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/patch.js
|
|
1027
|
-
var require_patch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1028
|
-
var SemVer = require_semver$1();
|
|
1029
|
-
var patch = (a, loose) => new SemVer(a, loose).patch;
|
|
1030
|
-
module.exports = patch;
|
|
1031
|
-
}));
|
|
1032
|
-
//#endregion
|
|
1033
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/prerelease.js
|
|
1034
|
-
var require_prerelease = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1035
|
-
var parse = require_parse();
|
|
1036
|
-
var prerelease = (version, options) => {
|
|
1037
|
-
const parsed = parse(version, options);
|
|
1038
|
-
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
1039
|
-
};
|
|
1040
|
-
module.exports = prerelease;
|
|
1041
|
-
}));
|
|
1042
|
-
//#endregion
|
|
1043
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare.js
|
|
1044
|
-
var require_compare = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1045
|
-
var SemVer = require_semver$1();
|
|
1046
|
-
var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
1047
|
-
module.exports = compare;
|
|
1048
|
-
}));
|
|
1049
|
-
//#endregion
|
|
1050
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/rcompare.js
|
|
1051
|
-
var require_rcompare = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1052
|
-
var compare = require_compare();
|
|
1053
|
-
var rcompare = (a, b, loose) => compare(b, a, loose);
|
|
1054
|
-
module.exports = rcompare;
|
|
1055
|
-
}));
|
|
1056
|
-
//#endregion
|
|
1057
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare-loose.js
|
|
1058
|
-
var require_compare_loose = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1059
|
-
var compare = require_compare();
|
|
1060
|
-
var compareLoose = (a, b) => compare(a, b, true);
|
|
1061
|
-
module.exports = compareLoose;
|
|
1062
|
-
}));
|
|
1063
|
-
//#endregion
|
|
1064
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare-build.js
|
|
1065
|
-
var require_compare_build = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1066
|
-
var SemVer = require_semver$1();
|
|
1067
|
-
var compareBuild = (a, b, loose) => {
|
|
1068
|
-
const versionA = new SemVer(a, loose);
|
|
1069
|
-
const versionB = new SemVer(b, loose);
|
|
1070
|
-
return versionA.compare(versionB) || versionA.compareBuild(versionB);
|
|
1071
|
-
};
|
|
1072
|
-
module.exports = compareBuild;
|
|
1073
|
-
}));
|
|
1074
|
-
//#endregion
|
|
1075
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/sort.js
|
|
1076
|
-
var require_sort = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1077
|
-
var compareBuild = require_compare_build();
|
|
1078
|
-
var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
|
|
1079
|
-
module.exports = sort;
|
|
1080
|
-
}));
|
|
1081
|
-
//#endregion
|
|
1082
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/rsort.js
|
|
1083
|
-
var require_rsort = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1084
|
-
var compareBuild = require_compare_build();
|
|
1085
|
-
var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
|
|
1086
|
-
module.exports = rsort;
|
|
1087
|
-
}));
|
|
1088
|
-
//#endregion
|
|
1089
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/gt.js
|
|
1090
|
-
var require_gt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1091
|
-
var compare = require_compare();
|
|
1092
|
-
var gt = (a, b, loose) => compare(a, b, loose) > 0;
|
|
1093
|
-
module.exports = gt;
|
|
1094
|
-
}));
|
|
1095
|
-
//#endregion
|
|
1096
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/lt.js
|
|
1097
|
-
var require_lt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1098
|
-
var compare = require_compare();
|
|
1099
|
-
var lt = (a, b, loose) => compare(a, b, loose) < 0;
|
|
1100
|
-
module.exports = lt;
|
|
1101
|
-
}));
|
|
1102
|
-
//#endregion
|
|
1103
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/eq.js
|
|
1104
|
-
var require_eq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1105
|
-
var compare = require_compare();
|
|
1106
|
-
var eq = (a, b, loose) => compare(a, b, loose) === 0;
|
|
1107
|
-
module.exports = eq;
|
|
1108
|
-
}));
|
|
1109
|
-
//#endregion
|
|
1110
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/neq.js
|
|
1111
|
-
var require_neq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1112
|
-
var compare = require_compare();
|
|
1113
|
-
var neq = (a, b, loose) => compare(a, b, loose) !== 0;
|
|
1114
|
-
module.exports = neq;
|
|
1115
|
-
}));
|
|
1116
|
-
//#endregion
|
|
1117
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/gte.js
|
|
1118
|
-
var require_gte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1119
|
-
var compare = require_compare();
|
|
1120
|
-
var gte = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
1121
|
-
module.exports = gte;
|
|
1122
|
-
}));
|
|
1123
|
-
//#endregion
|
|
1124
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/lte.js
|
|
1125
|
-
var require_lte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1126
|
-
var compare = require_compare();
|
|
1127
|
-
var lte = (a, b, loose) => compare(a, b, loose) <= 0;
|
|
1128
|
-
module.exports = lte;
|
|
1129
|
-
}));
|
|
1130
|
-
//#endregion
|
|
1131
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/cmp.js
|
|
1132
|
-
var require_cmp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1133
|
-
var eq = require_eq();
|
|
1134
|
-
var neq = require_neq();
|
|
1135
|
-
var gt = require_gt();
|
|
1136
|
-
var gte = require_gte();
|
|
1137
|
-
var lt = require_lt();
|
|
1138
|
-
var lte = require_lte();
|
|
1139
|
-
var cmp = (a, op, b, loose) => {
|
|
1140
|
-
switch (op) {
|
|
1141
|
-
case "===":
|
|
1142
|
-
if (typeof a === "object") a = a.version;
|
|
1143
|
-
if (typeof b === "object") b = b.version;
|
|
1144
|
-
return a === b;
|
|
1145
|
-
case "!==":
|
|
1146
|
-
if (typeof a === "object") a = a.version;
|
|
1147
|
-
if (typeof b === "object") b = b.version;
|
|
1148
|
-
return a !== b;
|
|
1149
|
-
case "":
|
|
1150
|
-
case "=":
|
|
1151
|
-
case "==": return eq(a, b, loose);
|
|
1152
|
-
case "!=": return neq(a, b, loose);
|
|
1153
|
-
case ">": return gt(a, b, loose);
|
|
1154
|
-
case ">=": return gte(a, b, loose);
|
|
1155
|
-
case "<": return lt(a, b, loose);
|
|
1156
|
-
case "<=": return lte(a, b, loose);
|
|
1157
|
-
default: throw new TypeError(`Invalid operator: ${op}`);
|
|
1158
|
-
}
|
|
1159
|
-
};
|
|
1160
|
-
module.exports = cmp;
|
|
1161
|
-
}));
|
|
1162
|
-
//#endregion
|
|
1163
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/coerce.js
|
|
1164
|
-
var require_coerce = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1165
|
-
var SemVer = require_semver$1();
|
|
1166
|
-
var parse = require_parse();
|
|
1167
|
-
var { safeRe: re, t } = require_re();
|
|
1168
|
-
var coerce = (version, options) => {
|
|
1169
|
-
if (version instanceof SemVer) return version;
|
|
1170
|
-
if (typeof version === "number") version = String(version);
|
|
1171
|
-
if (typeof version !== "string") return null;
|
|
1172
|
-
options = options || {};
|
|
1173
|
-
let match = null;
|
|
1174
|
-
if (!options.rtl) match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
|
|
1175
|
-
else {
|
|
1176
|
-
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
|
|
1177
|
-
let next;
|
|
1178
|
-
while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
|
|
1179
|
-
if (!match || next.index + next[0].length !== match.index + match[0].length) match = next;
|
|
1180
|
-
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
|
|
1181
|
-
}
|
|
1182
|
-
coerceRtlRegex.lastIndex = -1;
|
|
1183
|
-
}
|
|
1184
|
-
if (match === null) return null;
|
|
1185
|
-
const major = match[2];
|
|
1186
|
-
return parse(`${major}.${match[3] || "0"}.${match[4] || "0"}${options.includePrerelease && match[5] ? `-${match[5]}` : ""}${options.includePrerelease && match[6] ? `+${match[6]}` : ""}`, options);
|
|
1187
|
-
};
|
|
1188
|
-
module.exports = coerce;
|
|
1189
|
-
}));
|
|
1190
|
-
//#endregion
|
|
1191
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/truncate.js
|
|
1192
|
-
var require_truncate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1193
|
-
var parse = require_parse();
|
|
1194
|
-
var constants = require_constants();
|
|
1195
|
-
var SemVer = require_semver$1();
|
|
1196
|
-
var truncate = (version, truncation, options) => {
|
|
1197
|
-
if (!constants.RELEASE_TYPES.includes(truncation)) return null;
|
|
1198
|
-
const clonedVersion = cloneInputVersion(version, options);
|
|
1199
|
-
return clonedVersion && doTruncation(clonedVersion, truncation);
|
|
1200
|
-
};
|
|
1201
|
-
var cloneInputVersion = (version, options) => {
|
|
1202
|
-
return parse(version instanceof SemVer ? version.version : version, options);
|
|
1203
|
-
};
|
|
1204
|
-
var doTruncation = (version, truncation) => {
|
|
1205
|
-
if (isPrerelease(truncation)) return version.version;
|
|
1206
|
-
version.prerelease = [];
|
|
1207
|
-
switch (truncation) {
|
|
1208
|
-
case "major":
|
|
1209
|
-
version.minor = 0;
|
|
1210
|
-
version.patch = 0;
|
|
1211
|
-
break;
|
|
1212
|
-
case "minor": version.patch = 0;
|
|
1213
|
-
}
|
|
1214
|
-
return version.format();
|
|
1215
|
-
};
|
|
1216
|
-
var isPrerelease = (type) => {
|
|
1217
|
-
return type.startsWith("pre");
|
|
1218
|
-
};
|
|
1219
|
-
module.exports = truncate;
|
|
1220
|
-
}));
|
|
1221
|
-
//#endregion
|
|
1222
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/lrucache.js
|
|
1223
|
-
var require_lrucache = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1224
|
-
var LRUCache = class {
|
|
1225
|
-
constructor() {
|
|
1226
|
-
this.max = 1e3;
|
|
1227
|
-
this.map = /* @__PURE__ */ new Map();
|
|
1228
|
-
}
|
|
1229
|
-
get(key) {
|
|
1230
|
-
const value = this.map.get(key);
|
|
1231
|
-
if (value === void 0) return;
|
|
1232
|
-
else {
|
|
1233
|
-
this.map.delete(key);
|
|
1234
|
-
this.map.set(key, value);
|
|
1235
|
-
return value;
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
delete(key) {
|
|
1239
|
-
return this.map.delete(key);
|
|
1240
|
-
}
|
|
1241
|
-
set(key, value) {
|
|
1242
|
-
if (!this.delete(key) && value !== void 0) {
|
|
1243
|
-
if (this.map.size >= this.max) {
|
|
1244
|
-
const firstKey = this.map.keys().next().value;
|
|
1245
|
-
this.delete(firstKey);
|
|
1246
|
-
}
|
|
1247
|
-
this.map.set(key, value);
|
|
1248
|
-
}
|
|
1249
|
-
return this;
|
|
1250
|
-
}
|
|
1251
|
-
};
|
|
1252
|
-
module.exports = LRUCache;
|
|
1253
|
-
}));
|
|
1254
|
-
//#endregion
|
|
1255
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/range.js
|
|
1256
|
-
var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1257
|
-
var SPACE_CHARACTERS = /\s+/g;
|
|
1258
|
-
module.exports = class Range {
|
|
1259
|
-
constructor(range, options) {
|
|
1260
|
-
options = parseOptions(options);
|
|
1261
|
-
if (range instanceof Range) {
|
|
1262
|
-
if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) return range;
|
|
1263
|
-
else return new Range(range.raw, options);
|
|
1264
|
-
}
|
|
1265
|
-
if (range instanceof Comparator) {
|
|
1266
|
-
this.raw = range.value;
|
|
1267
|
-
this.set = [[range]];
|
|
1268
|
-
this.formatted = void 0;
|
|
1269
|
-
return this;
|
|
1270
|
-
}
|
|
1271
|
-
this.options = options;
|
|
1272
|
-
this.loose = !!options.loose;
|
|
1273
|
-
this.includePrerelease = !!options.includePrerelease;
|
|
1274
|
-
this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
|
|
1275
|
-
this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
|
|
1276
|
-
if (!this.set.length) throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
|
|
1277
|
-
if (this.set.length > 1) {
|
|
1278
|
-
const first = this.set[0];
|
|
1279
|
-
this.set = this.set.filter((c) => !isNullSet(c[0]));
|
|
1280
|
-
if (this.set.length === 0) this.set = [first];
|
|
1281
|
-
else if (this.set.length > 1) {
|
|
1282
|
-
for (const c of this.set) if (c.length === 1 && isAny(c[0])) {
|
|
1283
|
-
this.set = [c];
|
|
1284
|
-
break;
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
this.formatted = void 0;
|
|
1289
|
-
}
|
|
1290
|
-
get range() {
|
|
1291
|
-
if (this.formatted === void 0) {
|
|
1292
|
-
this.formatted = "";
|
|
1293
|
-
for (let i = 0; i < this.set.length; i++) {
|
|
1294
|
-
if (i > 0) this.formatted += "||";
|
|
1295
|
-
const comps = this.set[i];
|
|
1296
|
-
for (let k = 0; k < comps.length; k++) {
|
|
1297
|
-
if (k > 0) this.formatted += " ";
|
|
1298
|
-
this.formatted += comps[k].toString().trim();
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
return this.formatted;
|
|
1303
|
-
}
|
|
1304
|
-
format() {
|
|
1305
|
-
return this.range;
|
|
1306
|
-
}
|
|
1307
|
-
toString() {
|
|
1308
|
-
return this.range;
|
|
1309
|
-
}
|
|
1310
|
-
parseRange(range) {
|
|
1311
|
-
range = range.replace(BUILDSTRIPRE, "");
|
|
1312
|
-
const memoKey = ((this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE)) + ":" + range;
|
|
1313
|
-
const cached = cache.get(memoKey);
|
|
1314
|
-
if (cached) return cached;
|
|
1315
|
-
const loose = this.options.loose;
|
|
1316
|
-
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
1317
|
-
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
1318
|
-
debug("hyphen replace", range);
|
|
1319
|
-
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
1320
|
-
debug("comparator trim", range);
|
|
1321
|
-
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
1322
|
-
debug("tilde trim", range);
|
|
1323
|
-
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
1324
|
-
debug("caret trim", range);
|
|
1325
|
-
let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
|
|
1326
|
-
if (loose) rangeList = rangeList.filter((comp) => {
|
|
1327
|
-
debug("loose invalid filter", comp, this.options);
|
|
1328
|
-
return !!comp.match(re[t.COMPARATORLOOSE]);
|
|
1329
|
-
});
|
|
1330
|
-
debug("range list", rangeList);
|
|
1331
|
-
const rangeMap = /* @__PURE__ */ new Map();
|
|
1332
|
-
const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
|
|
1333
|
-
for (const comp of comparators) {
|
|
1334
|
-
if (isNullSet(comp)) return [comp];
|
|
1335
|
-
rangeMap.set(comp.value, comp);
|
|
1336
|
-
}
|
|
1337
|
-
if (rangeMap.size > 1 && rangeMap.has("")) rangeMap.delete("");
|
|
1338
|
-
const result = [...rangeMap.values()];
|
|
1339
|
-
cache.set(memoKey, result);
|
|
1340
|
-
return result;
|
|
1341
|
-
}
|
|
1342
|
-
intersects(range, options) {
|
|
1343
|
-
if (!(range instanceof Range)) throw new TypeError("a Range is required");
|
|
1344
|
-
return this.set.some((thisComparators) => {
|
|
1345
|
-
return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
|
|
1346
|
-
return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
|
|
1347
|
-
return rangeComparators.every((rangeComparator) => {
|
|
1348
|
-
return thisComparator.intersects(rangeComparator, options);
|
|
1349
|
-
});
|
|
1350
|
-
});
|
|
1351
|
-
});
|
|
1352
|
-
});
|
|
1353
|
-
}
|
|
1354
|
-
test(version) {
|
|
1355
|
-
if (!version) return false;
|
|
1356
|
-
if (typeof version === "string") try {
|
|
1357
|
-
version = new SemVer(version, this.options);
|
|
1358
|
-
} catch (er) {
|
|
1359
|
-
return false;
|
|
1360
|
-
}
|
|
1361
|
-
for (let i = 0; i < this.set.length; i++) if (testSet(this.set[i], version, this.options)) return true;
|
|
1362
|
-
return false;
|
|
1363
|
-
}
|
|
1364
|
-
};
|
|
1365
|
-
var cache = new (require_lrucache())();
|
|
1366
|
-
var parseOptions = require_parse_options();
|
|
1367
|
-
var Comparator = require_comparator();
|
|
1368
|
-
var debug = require_debug();
|
|
1369
|
-
var SemVer = require_semver$1();
|
|
1370
|
-
var { safeRe: re, src, t, comparatorTrimReplace, tildeTrimReplace, caretTrimReplace } = require_re();
|
|
1371
|
-
var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
|
|
1372
|
-
var BUILDSTRIPRE = new RegExp(src[t.BUILD], "g");
|
|
1373
|
-
var isNullSet = (c) => c.value === "<0.0.0-0";
|
|
1374
|
-
var isAny = (c) => c.value === "";
|
|
1375
|
-
var isSatisfiable = (comparators, options) => {
|
|
1376
|
-
let result = true;
|
|
1377
|
-
const remainingComparators = comparators.slice();
|
|
1378
|
-
let testComparator = remainingComparators.pop();
|
|
1379
|
-
while (result && remainingComparators.length) {
|
|
1380
|
-
result = remainingComparators.every((otherComparator) => {
|
|
1381
|
-
return testComparator.intersects(otherComparator, options);
|
|
1382
|
-
});
|
|
1383
|
-
testComparator = remainingComparators.pop();
|
|
1384
|
-
}
|
|
1385
|
-
return result;
|
|
1386
|
-
};
|
|
1387
|
-
var parseComparator = (comp, options) => {
|
|
1388
|
-
comp = comp.replace(re[t.BUILD], "");
|
|
1389
|
-
debug("comp", comp, options);
|
|
1390
|
-
comp = replaceCarets(comp, options);
|
|
1391
|
-
debug("caret", comp);
|
|
1392
|
-
comp = replaceTildes(comp, options);
|
|
1393
|
-
debug("tildes", comp);
|
|
1394
|
-
comp = replaceXRanges(comp, options);
|
|
1395
|
-
debug("xrange", comp);
|
|
1396
|
-
comp = replaceStars(comp, options);
|
|
1397
|
-
debug("stars", comp);
|
|
1398
|
-
return comp;
|
|
1399
|
-
};
|
|
1400
|
-
var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
|
|
1401
|
-
var invalidXRangeOrder = (M, m, p) => isX(M) && !isX(m) || isX(m) && p && !isX(p);
|
|
1402
|
-
var replaceTildes = (comp, options) => {
|
|
1403
|
-
return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
|
|
1404
|
-
};
|
|
1405
|
-
var replaceTilde = (comp, options) => {
|
|
1406
|
-
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
1407
|
-
const z = options.includePrerelease ? "-0" : "";
|
|
1408
|
-
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1409
|
-
debug("tilde", comp, _, M, m, p, pr);
|
|
1410
|
-
let ret;
|
|
1411
|
-
if (isX(M)) ret = "";
|
|
1412
|
-
else if (isX(m)) ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
1413
|
-
else if (isX(p)) ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
1414
|
-
else if (pr) {
|
|
1415
|
-
debug("replaceTilde pr", pr);
|
|
1416
|
-
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
1417
|
-
} else ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
1418
|
-
debug("tilde return", ret);
|
|
1419
|
-
return ret;
|
|
1420
|
-
});
|
|
1421
|
-
};
|
|
1422
|
-
var replaceCarets = (comp, options) => {
|
|
1423
|
-
return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
|
|
1424
|
-
};
|
|
1425
|
-
var replaceCaret = (comp, options) => {
|
|
1426
|
-
debug("caret", comp, options);
|
|
1427
|
-
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
1428
|
-
const z = options.includePrerelease ? "-0" : "";
|
|
1429
|
-
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1430
|
-
debug("caret", comp, _, M, m, p, pr);
|
|
1431
|
-
let ret;
|
|
1432
|
-
if (isX(M)) ret = "";
|
|
1433
|
-
else if (isX(m)) ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
1434
|
-
else if (isX(p)) {
|
|
1435
|
-
if (M === "0") ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
1436
|
-
else ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
|
|
1437
|
-
} else if (pr) {
|
|
1438
|
-
debug("replaceCaret pr", pr);
|
|
1439
|
-
if (M === "0") {
|
|
1440
|
-
if (m === "0") ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
|
|
1441
|
-
else ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
1442
|
-
} else ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
|
|
1443
|
-
} else {
|
|
1444
|
-
debug("no pr");
|
|
1445
|
-
if (M === "0") {
|
|
1446
|
-
if (m === "0") ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0`;
|
|
1447
|
-
else ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
1448
|
-
} else ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
|
|
1449
|
-
}
|
|
1450
|
-
debug("caret return", ret);
|
|
1451
|
-
return ret;
|
|
1452
|
-
});
|
|
1453
|
-
};
|
|
1454
|
-
var replaceXRanges = (comp, options) => {
|
|
1455
|
-
debug("replaceXRanges", comp, options);
|
|
1456
|
-
return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
|
|
1457
|
-
};
|
|
1458
|
-
var replaceXRange = (comp, options) => {
|
|
1459
|
-
comp = comp.trim();
|
|
1460
|
-
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
1461
|
-
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
1462
|
-
debug("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
1463
|
-
if (invalidXRangeOrder(M, m, p)) return comp;
|
|
1464
|
-
const xM = isX(M);
|
|
1465
|
-
const xm = xM || isX(m);
|
|
1466
|
-
const xp = xm || isX(p);
|
|
1467
|
-
const anyX = xp;
|
|
1468
|
-
if (gtlt === "=" && anyX) gtlt = "";
|
|
1469
|
-
pr = options.includePrerelease ? "-0" : "";
|
|
1470
|
-
if (xM) {
|
|
1471
|
-
if (gtlt === ">" || gtlt === "<") ret = "<0.0.0-0";
|
|
1472
|
-
else ret = "*";
|
|
1473
|
-
} else if (gtlt && anyX) {
|
|
1474
|
-
if (xm) m = 0;
|
|
1475
|
-
p = 0;
|
|
1476
|
-
if (gtlt === ">") {
|
|
1477
|
-
gtlt = ">=";
|
|
1478
|
-
if (xm) {
|
|
1479
|
-
M = +M + 1;
|
|
1480
|
-
m = 0;
|
|
1481
|
-
p = 0;
|
|
1482
|
-
} else {
|
|
1483
|
-
m = +m + 1;
|
|
1484
|
-
p = 0;
|
|
1485
|
-
}
|
|
1486
|
-
} else if (gtlt === "<=") {
|
|
1487
|
-
gtlt = "<";
|
|
1488
|
-
if (xm) M = +M + 1;
|
|
1489
|
-
else m = +m + 1;
|
|
1490
|
-
}
|
|
1491
|
-
if (gtlt === "<") pr = "-0";
|
|
1492
|
-
ret = `${gtlt + M}.${m}.${p}${pr}`;
|
|
1493
|
-
} else if (xm) ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
|
|
1494
|
-
else if (xp) ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
|
|
1495
|
-
debug("xRange return", ret);
|
|
1496
|
-
return ret;
|
|
1497
|
-
});
|
|
1498
|
-
};
|
|
1499
|
-
var replaceStars = (comp, options) => {
|
|
1500
|
-
debug("replaceStars", comp, options);
|
|
1501
|
-
return comp.trim().replace(re[t.STAR], "");
|
|
1502
|
-
};
|
|
1503
|
-
var replaceGTE0 = (comp, options) => {
|
|
1504
|
-
debug("replaceGTE0", comp, options);
|
|
1505
|
-
return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
|
|
1506
|
-
};
|
|
1507
|
-
var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
1508
|
-
if (isX(fM)) from = "";
|
|
1509
|
-
else if (isX(fm)) from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
|
|
1510
|
-
else if (isX(fp)) from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
|
|
1511
|
-
else if (fpr) from = `>=${from}`;
|
|
1512
|
-
else from = `>=${from}${incPr ? "-0" : ""}`;
|
|
1513
|
-
if (isX(tM)) to = "";
|
|
1514
|
-
else if (isX(tm)) to = `<${+tM + 1}.0.0-0`;
|
|
1515
|
-
else if (isX(tp)) to = `<${tM}.${+tm + 1}.0-0`;
|
|
1516
|
-
else if (tpr) to = `<=${tM}.${tm}.${tp}-${tpr}`;
|
|
1517
|
-
else if (incPr) to = `<${tM}.${tm}.${+tp + 1}-0`;
|
|
1518
|
-
else to = `<=${to}`;
|
|
1519
|
-
return `${from} ${to}`.trim();
|
|
1520
|
-
};
|
|
1521
|
-
var testSet = (set, version, options) => {
|
|
1522
|
-
for (let i = 0; i < set.length; i++) if (!set[i].test(version)) return false;
|
|
1523
|
-
if (version.prerelease.length && !options.includePrerelease) {
|
|
1524
|
-
for (let i = 0; i < set.length; i++) {
|
|
1525
|
-
debug(set[i].semver);
|
|
1526
|
-
if (set[i].semver === Comparator.ANY) continue;
|
|
1527
|
-
if (set[i].semver.prerelease.length > 0) {
|
|
1528
|
-
const allowed = set[i].semver;
|
|
1529
|
-
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) return true;
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
return false;
|
|
1533
|
-
}
|
|
1534
|
-
return true;
|
|
1535
|
-
};
|
|
1536
|
-
}));
|
|
1537
|
-
//#endregion
|
|
1538
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/comparator.js
|
|
1539
|
-
var require_comparator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1540
|
-
var ANY = Symbol("SemVer ANY");
|
|
1541
|
-
module.exports = class Comparator {
|
|
1542
|
-
static get ANY() {
|
|
1543
|
-
return ANY;
|
|
1544
|
-
}
|
|
1545
|
-
constructor(comp, options) {
|
|
1546
|
-
options = parseOptions(options);
|
|
1547
|
-
if (comp instanceof Comparator) {
|
|
1548
|
-
if (comp.loose === !!options.loose) return comp;
|
|
1549
|
-
else comp = comp.value;
|
|
1550
|
-
}
|
|
1551
|
-
comp = comp.trim().split(/\s+/).join(" ");
|
|
1552
|
-
debug("comparator", comp, options);
|
|
1553
|
-
this.options = options;
|
|
1554
|
-
this.loose = !!options.loose;
|
|
1555
|
-
this.parse(comp);
|
|
1556
|
-
if (this.semver === ANY) this.value = "";
|
|
1557
|
-
else this.value = this.operator + this.semver.version;
|
|
1558
|
-
debug("comp", this);
|
|
1559
|
-
}
|
|
1560
|
-
parse(comp) {
|
|
1561
|
-
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
1562
|
-
const m = comp.match(r);
|
|
1563
|
-
if (!m) throw new TypeError(`Invalid comparator: ${comp}`);
|
|
1564
|
-
this.operator = m[1] !== void 0 ? m[1] : "";
|
|
1565
|
-
if (this.operator === "=") this.operator = "";
|
|
1566
|
-
if (!m[2]) this.semver = ANY;
|
|
1567
|
-
else this.semver = new SemVer(m[2], this.options.loose);
|
|
1568
|
-
}
|
|
1569
|
-
toString() {
|
|
1570
|
-
return this.value;
|
|
1571
|
-
}
|
|
1572
|
-
test(version) {
|
|
1573
|
-
debug("Comparator.test", version, this.options.loose);
|
|
1574
|
-
if (this.semver === ANY || version === ANY) return true;
|
|
1575
|
-
if (typeof version === "string") try {
|
|
1576
|
-
version = new SemVer(version, this.options);
|
|
1577
|
-
} catch (er) {
|
|
1578
|
-
return false;
|
|
1579
|
-
}
|
|
1580
|
-
return cmp(version, this.operator, this.semver, this.options);
|
|
1581
|
-
}
|
|
1582
|
-
intersects(comp, options) {
|
|
1583
|
-
if (!(comp instanceof Comparator)) throw new TypeError("a Comparator is required");
|
|
1584
|
-
if (this.operator === "") {
|
|
1585
|
-
if (this.value === "") return true;
|
|
1586
|
-
return new Range(comp.value, options).test(this.value);
|
|
1587
|
-
} else if (comp.operator === "") {
|
|
1588
|
-
if (comp.value === "") return true;
|
|
1589
|
-
return new Range(this.value, options).test(comp.semver);
|
|
1590
|
-
}
|
|
1591
|
-
options = parseOptions(options);
|
|
1592
|
-
if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) return false;
|
|
1593
|
-
if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) return false;
|
|
1594
|
-
if (this.operator.startsWith(">") && comp.operator.startsWith(">")) return true;
|
|
1595
|
-
if (this.operator.startsWith("<") && comp.operator.startsWith("<")) return true;
|
|
1596
|
-
if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) return true;
|
|
1597
|
-
if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) return true;
|
|
1598
|
-
if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) return true;
|
|
1599
|
-
return false;
|
|
1600
|
-
}
|
|
1601
|
-
};
|
|
1602
|
-
var parseOptions = require_parse_options();
|
|
1603
|
-
var { safeRe: re, t } = require_re();
|
|
1604
|
-
var cmp = require_cmp();
|
|
1605
|
-
var debug = require_debug();
|
|
1606
|
-
var SemVer = require_semver$1();
|
|
1607
|
-
var Range = require_range();
|
|
1608
|
-
}));
|
|
1609
|
-
//#endregion
|
|
1610
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/satisfies.js
|
|
1611
|
-
var require_satisfies = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1612
|
-
var Range = require_range();
|
|
1613
|
-
var satisfies = (version, range, options) => {
|
|
1614
|
-
try {
|
|
1615
|
-
range = new Range(range, options);
|
|
1616
|
-
} catch (er) {
|
|
1617
|
-
return false;
|
|
1618
|
-
}
|
|
1619
|
-
return range.test(version);
|
|
1620
|
-
};
|
|
1621
|
-
module.exports = satisfies;
|
|
1622
|
-
}));
|
|
1623
|
-
//#endregion
|
|
1624
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/to-comparators.js
|
|
1625
|
-
var require_to_comparators = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1626
|
-
var Range = require_range();
|
|
1627
|
-
var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
|
|
1628
|
-
module.exports = toComparators;
|
|
1629
|
-
}));
|
|
1630
|
-
//#endregion
|
|
1631
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/max-satisfying.js
|
|
1632
|
-
var require_max_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1633
|
-
var SemVer = require_semver$1();
|
|
1634
|
-
var Range = require_range();
|
|
1635
|
-
var maxSatisfying = (versions, range, options) => {
|
|
1636
|
-
let max = null;
|
|
1637
|
-
let maxSV = null;
|
|
1638
|
-
let rangeObj = null;
|
|
1639
|
-
try {
|
|
1640
|
-
rangeObj = new Range(range, options);
|
|
1641
|
-
} catch (er) {
|
|
1642
|
-
return null;
|
|
1643
|
-
}
|
|
1644
|
-
versions.forEach((v) => {
|
|
1645
|
-
if (rangeObj.test(v)) {
|
|
1646
|
-
if (!max || maxSV.compare(v) === -1) {
|
|
1647
|
-
max = v;
|
|
1648
|
-
maxSV = new SemVer(max, options);
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
});
|
|
1652
|
-
return max;
|
|
1653
|
-
};
|
|
1654
|
-
module.exports = maxSatisfying;
|
|
1655
|
-
}));
|
|
1656
|
-
//#endregion
|
|
1657
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/min-satisfying.js
|
|
1658
|
-
var require_min_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1659
|
-
var SemVer = require_semver$1();
|
|
1660
|
-
var Range = require_range();
|
|
1661
|
-
var minSatisfying = (versions, range, options) => {
|
|
1662
|
-
let min = null;
|
|
1663
|
-
let minSV = null;
|
|
1664
|
-
let rangeObj = null;
|
|
1665
|
-
try {
|
|
1666
|
-
rangeObj = new Range(range, options);
|
|
1667
|
-
} catch (er) {
|
|
1668
|
-
return null;
|
|
1669
|
-
}
|
|
1670
|
-
versions.forEach((v) => {
|
|
1671
|
-
if (rangeObj.test(v)) {
|
|
1672
|
-
if (!min || minSV.compare(v) === 1) {
|
|
1673
|
-
min = v;
|
|
1674
|
-
minSV = new SemVer(min, options);
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
});
|
|
1678
|
-
return min;
|
|
1679
|
-
};
|
|
1680
|
-
module.exports = minSatisfying;
|
|
1681
|
-
}));
|
|
1682
|
-
//#endregion
|
|
1683
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/min-version.js
|
|
1684
|
-
var require_min_version = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1685
|
-
var SemVer = require_semver$1();
|
|
1686
|
-
var Range = require_range();
|
|
1687
|
-
var gt = require_gt();
|
|
1688
|
-
var minVersion = (range, loose) => {
|
|
1689
|
-
range = new Range(range, loose);
|
|
1690
|
-
let minver = new SemVer("0.0.0");
|
|
1691
|
-
if (range.test(minver)) return minver;
|
|
1692
|
-
minver = new SemVer("0.0.0-0");
|
|
1693
|
-
if (range.test(minver)) return minver;
|
|
1694
|
-
minver = null;
|
|
1695
|
-
for (let i = 0; i < range.set.length; ++i) {
|
|
1696
|
-
const comparators = range.set[i];
|
|
1697
|
-
let setMin = null;
|
|
1698
|
-
comparators.forEach((comparator) => {
|
|
1699
|
-
const compver = new SemVer(comparator.semver.version);
|
|
1700
|
-
switch (comparator.operator) {
|
|
1701
|
-
case ">":
|
|
1702
|
-
if (compver.prerelease.length === 0) compver.patch++;
|
|
1703
|
-
else compver.prerelease.push(0);
|
|
1704
|
-
compver.raw = compver.format();
|
|
1705
|
-
case "":
|
|
1706
|
-
case ">=":
|
|
1707
|
-
if (!setMin || gt(compver, setMin)) setMin = compver;
|
|
1708
|
-
break;
|
|
1709
|
-
case "<":
|
|
1710
|
-
case "<=": break;
|
|
1711
|
-
/* istanbul ignore next */
|
|
1712
|
-
default: throw new Error(`Unexpected operation: ${comparator.operator}`);
|
|
1713
|
-
}
|
|
1714
|
-
});
|
|
1715
|
-
if (setMin && (!minver || gt(minver, setMin))) minver = setMin;
|
|
1716
|
-
}
|
|
1717
|
-
if (minver && range.test(minver)) return minver;
|
|
1718
|
-
return null;
|
|
1719
|
-
};
|
|
1720
|
-
module.exports = minVersion;
|
|
1721
|
-
}));
|
|
1722
|
-
//#endregion
|
|
1723
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/valid.js
|
|
1724
|
-
var require_valid = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1725
|
-
var Range = require_range();
|
|
1726
|
-
var validRange = (range, options) => {
|
|
1727
|
-
try {
|
|
1728
|
-
return new Range(range, options).range || "*";
|
|
1729
|
-
} catch (er) {
|
|
1730
|
-
return null;
|
|
1731
|
-
}
|
|
1732
|
-
};
|
|
1733
|
-
module.exports = validRange;
|
|
1734
|
-
}));
|
|
1735
|
-
//#endregion
|
|
1736
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/outside.js
|
|
1737
|
-
var require_outside = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1738
|
-
var SemVer = require_semver$1();
|
|
1739
|
-
var Comparator = require_comparator();
|
|
1740
|
-
var { ANY } = Comparator;
|
|
1741
|
-
var Range = require_range();
|
|
1742
|
-
var satisfies = require_satisfies();
|
|
1743
|
-
var gt = require_gt();
|
|
1744
|
-
var lt = require_lt();
|
|
1745
|
-
var lte = require_lte();
|
|
1746
|
-
var gte = require_gte();
|
|
1747
|
-
var outside = (version, range, hilo, options) => {
|
|
1748
|
-
version = new SemVer(version, options);
|
|
1749
|
-
range = new Range(range, options);
|
|
1750
|
-
let gtfn, ltefn, ltfn, comp, ecomp;
|
|
1751
|
-
switch (hilo) {
|
|
1752
|
-
case ">":
|
|
1753
|
-
gtfn = gt;
|
|
1754
|
-
ltefn = lte;
|
|
1755
|
-
ltfn = lt;
|
|
1756
|
-
comp = ">";
|
|
1757
|
-
ecomp = ">=";
|
|
1758
|
-
break;
|
|
1759
|
-
case "<":
|
|
1760
|
-
gtfn = lt;
|
|
1761
|
-
ltefn = gte;
|
|
1762
|
-
ltfn = gt;
|
|
1763
|
-
comp = "<";
|
|
1764
|
-
ecomp = "<=";
|
|
1765
|
-
break;
|
|
1766
|
-
default: throw new TypeError("Must provide a hilo val of \"<\" or \">\"");
|
|
1767
|
-
}
|
|
1768
|
-
if (satisfies(version, range, options)) return false;
|
|
1769
|
-
for (let i = 0; i < range.set.length; ++i) {
|
|
1770
|
-
const comparators = range.set[i];
|
|
1771
|
-
let high = null;
|
|
1772
|
-
let low = null;
|
|
1773
|
-
comparators.forEach((comparator) => {
|
|
1774
|
-
if (comparator.semver === ANY) comparator = new Comparator(">=0.0.0");
|
|
1775
|
-
high = high || comparator;
|
|
1776
|
-
low = low || comparator;
|
|
1777
|
-
if (gtfn(comparator.semver, high.semver, options)) high = comparator;
|
|
1778
|
-
else if (ltfn(comparator.semver, low.semver, options)) low = comparator;
|
|
1779
|
-
});
|
|
1780
|
-
if (high.operator === comp || high.operator === ecomp) return false;
|
|
1781
|
-
if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) return false;
|
|
1782
|
-
else if (low.operator === ecomp && ltfn(version, low.semver)) return false;
|
|
1783
|
-
}
|
|
1784
|
-
return true;
|
|
1785
|
-
};
|
|
1786
|
-
module.exports = outside;
|
|
1787
|
-
}));
|
|
1788
|
-
//#endregion
|
|
1789
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/gtr.js
|
|
1790
|
-
var require_gtr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1791
|
-
var outside = require_outside();
|
|
1792
|
-
var gtr = (version, range, options) => outside(version, range, ">", options);
|
|
1793
|
-
module.exports = gtr;
|
|
1794
|
-
}));
|
|
1795
|
-
//#endregion
|
|
1796
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/ltr.js
|
|
1797
|
-
var require_ltr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1798
|
-
var outside = require_outside();
|
|
1799
|
-
var ltr = (version, range, options) => outside(version, range, "<", options);
|
|
1800
|
-
module.exports = ltr;
|
|
1801
|
-
}));
|
|
1802
|
-
//#endregion
|
|
1803
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/intersects.js
|
|
1804
|
-
var require_intersects = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1805
|
-
var Range = require_range();
|
|
1806
|
-
var intersects = (r1, r2, options) => {
|
|
1807
|
-
r1 = new Range(r1, options);
|
|
1808
|
-
r2 = new Range(r2, options);
|
|
1809
|
-
return r1.intersects(r2, options);
|
|
1810
|
-
};
|
|
1811
|
-
module.exports = intersects;
|
|
1812
|
-
}));
|
|
1813
|
-
//#endregion
|
|
1814
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/simplify.js
|
|
1815
|
-
var require_simplify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1816
|
-
var satisfies = require_satisfies();
|
|
1817
|
-
var compare = require_compare();
|
|
1818
|
-
module.exports = (versions, range, options) => {
|
|
1819
|
-
const set = [];
|
|
1820
|
-
let first = null;
|
|
1821
|
-
let prev = null;
|
|
1822
|
-
const v = versions.sort((a, b) => compare(a, b, options));
|
|
1823
|
-
for (const version of v) if (satisfies(version, range, options)) {
|
|
1824
|
-
prev = version;
|
|
1825
|
-
if (!first) first = version;
|
|
1826
|
-
} else {
|
|
1827
|
-
if (prev) set.push([first, prev]);
|
|
1828
|
-
prev = null;
|
|
1829
|
-
first = null;
|
|
1830
|
-
}
|
|
1831
|
-
if (first) set.push([first, null]);
|
|
1832
|
-
const ranges = [];
|
|
1833
|
-
for (const [min, max] of set) if (min === max) ranges.push(min);
|
|
1834
|
-
else if (!max && min === v[0]) ranges.push("*");
|
|
1835
|
-
else if (!max) ranges.push(`>=${min}`);
|
|
1836
|
-
else if (min === v[0]) ranges.push(`<=${max}`);
|
|
1837
|
-
else ranges.push(`${min} - ${max}`);
|
|
1838
|
-
const simplified = ranges.join(" || ");
|
|
1839
|
-
const original = typeof range.raw === "string" ? range.raw : String(range);
|
|
1840
|
-
return simplified.length < original.length ? simplified : range;
|
|
1841
|
-
};
|
|
1842
|
-
}));
|
|
1843
|
-
//#endregion
|
|
1844
|
-
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/subset.js
|
|
1845
|
-
var require_subset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1846
|
-
var Range = require_range();
|
|
1847
|
-
var Comparator = require_comparator();
|
|
1848
|
-
var { ANY } = Comparator;
|
|
1849
|
-
var satisfies = require_satisfies();
|
|
1850
|
-
var compare = require_compare();
|
|
1851
|
-
var subset = (sub, dom, options = {}) => {
|
|
1852
|
-
if (sub === dom) return true;
|
|
1853
|
-
sub = new Range(sub, options);
|
|
1854
|
-
dom = new Range(dom, options);
|
|
1855
|
-
let sawNonNull = false;
|
|
1856
|
-
OUTER: for (const simpleSub of sub.set) {
|
|
1857
|
-
for (const simpleDom of dom.set) {
|
|
1858
|
-
const isSub = simpleSubset(simpleSub, simpleDom, options);
|
|
1859
|
-
sawNonNull = sawNonNull || isSub !== null;
|
|
1860
|
-
if (isSub) continue OUTER;
|
|
1861
|
-
}
|
|
1862
|
-
if (sawNonNull) return false;
|
|
1863
|
-
}
|
|
1864
|
-
return true;
|
|
1865
|
-
};
|
|
1866
|
-
var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
|
|
1867
|
-
var minimumVersion = [new Comparator(">=0.0.0")];
|
|
1868
|
-
var simpleSubset = (sub, dom, options) => {
|
|
1869
|
-
if (sub === dom) return true;
|
|
1870
|
-
if (sub.length === 1 && sub[0].semver === ANY) {
|
|
1871
|
-
if (dom.length === 1 && dom[0].semver === ANY) return true;
|
|
1872
|
-
else if (options.includePrerelease) sub = minimumVersionWithPreRelease;
|
|
1873
|
-
else sub = minimumVersion;
|
|
1874
|
-
}
|
|
1875
|
-
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
1876
|
-
if (options.includePrerelease) return true;
|
|
1877
|
-
else dom = minimumVersion;
|
|
1878
|
-
}
|
|
1879
|
-
const eqSet = /* @__PURE__ */ new Set();
|
|
1880
|
-
let gt, lt;
|
|
1881
|
-
for (const c of sub) if (c.operator === ">" || c.operator === ">=") gt = higherGT(gt, c, options);
|
|
1882
|
-
else if (c.operator === "<" || c.operator === "<=") lt = lowerLT(lt, c, options);
|
|
1883
|
-
else eqSet.add(c.semver);
|
|
1884
|
-
if (eqSet.size > 1) return null;
|
|
1885
|
-
let gtltComp;
|
|
1886
|
-
if (gt && lt) {
|
|
1887
|
-
gtltComp = compare(gt.semver, lt.semver, options);
|
|
1888
|
-
if (gtltComp > 0) return null;
|
|
1889
|
-
else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) return null;
|
|
1890
|
-
}
|
|
1891
|
-
for (const eq of eqSet) {
|
|
1892
|
-
if (gt && !satisfies(eq, String(gt), options)) return null;
|
|
1893
|
-
if (lt && !satisfies(eq, String(lt), options)) return null;
|
|
1894
|
-
for (const c of dom) if (!satisfies(eq, String(c), options)) return false;
|
|
1895
|
-
return true;
|
|
1896
|
-
}
|
|
1897
|
-
let higher, lower;
|
|
1898
|
-
let hasDomLT, hasDomGT;
|
|
1899
|
-
let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
|
|
1900
|
-
let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
|
|
1901
|
-
if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) needDomLTPre = false;
|
|
1902
|
-
for (const c of dom) {
|
|
1903
|
-
hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
|
|
1904
|
-
hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
|
|
1905
|
-
if (gt) {
|
|
1906
|
-
if (needDomGTPre) {
|
|
1907
|
-
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) needDomGTPre = false;
|
|
1908
|
-
}
|
|
1909
|
-
if (c.operator === ">" || c.operator === ">=") {
|
|
1910
|
-
higher = higherGT(gt, c, options);
|
|
1911
|
-
if (higher === c && higher !== gt) return false;
|
|
1912
|
-
} else if (gt.operator === ">=" && !c.test(gt.semver)) return false;
|
|
1913
|
-
}
|
|
1914
|
-
if (lt) {
|
|
1915
|
-
if (needDomLTPre) {
|
|
1916
|
-
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) needDomLTPre = false;
|
|
1917
|
-
}
|
|
1918
|
-
if (c.operator === "<" || c.operator === "<=") {
|
|
1919
|
-
lower = lowerLT(lt, c, options);
|
|
1920
|
-
if (lower === c && lower !== lt) return false;
|
|
1921
|
-
} else if (lt.operator === "<=" && !c.test(lt.semver)) return false;
|
|
1922
|
-
}
|
|
1923
|
-
if (!c.operator && (lt || gt) && gtltComp !== 0) return false;
|
|
1924
|
-
}
|
|
1925
|
-
if (gt && hasDomLT && !lt && gtltComp !== 0) return false;
|
|
1926
|
-
if (lt && hasDomGT && !gt && gtltComp !== 0) return false;
|
|
1927
|
-
if (needDomGTPre || needDomLTPre) return false;
|
|
1928
|
-
return true;
|
|
1929
|
-
};
|
|
1930
|
-
var higherGT = (a, b, options) => {
|
|
1931
|
-
if (!a) return b;
|
|
1932
|
-
const comp = compare(a.semver, b.semver, options);
|
|
1933
|
-
return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
|
|
1934
|
-
};
|
|
1935
|
-
var lowerLT = (a, b, options) => {
|
|
1936
|
-
if (!a) return b;
|
|
1937
|
-
const comp = compare(a.semver, b.semver, options);
|
|
1938
|
-
return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
|
|
1939
|
-
};
|
|
1940
|
-
module.exports = subset;
|
|
1941
|
-
}));
|
|
1942
|
-
//#endregion
|
|
1943
|
-
//#region src/composition/constants.ts
|
|
1944
|
-
var import_semver = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1945
|
-
var internalRe = require_re();
|
|
1946
|
-
var constants = require_constants();
|
|
1947
|
-
var SemVer = require_semver$1();
|
|
1948
|
-
var identifiers = require_identifiers();
|
|
1949
|
-
module.exports = {
|
|
1950
|
-
parse: require_parse(),
|
|
1951
|
-
valid: require_valid$1(),
|
|
1952
|
-
clean: require_clean(),
|
|
1953
|
-
inc: require_inc(),
|
|
1954
|
-
diff: require_diff(),
|
|
1955
|
-
major: require_major(),
|
|
1956
|
-
minor: require_minor(),
|
|
1957
|
-
patch: require_patch(),
|
|
1958
|
-
prerelease: require_prerelease(),
|
|
1959
|
-
compare: require_compare(),
|
|
1960
|
-
rcompare: require_rcompare(),
|
|
1961
|
-
compareLoose: require_compare_loose(),
|
|
1962
|
-
compareBuild: require_compare_build(),
|
|
1963
|
-
sort: require_sort(),
|
|
1964
|
-
rsort: require_rsort(),
|
|
1965
|
-
gt: require_gt(),
|
|
1966
|
-
lt: require_lt(),
|
|
1967
|
-
eq: require_eq(),
|
|
1968
|
-
neq: require_neq(),
|
|
1969
|
-
gte: require_gte(),
|
|
1970
|
-
lte: require_lte(),
|
|
1971
|
-
cmp: require_cmp(),
|
|
1972
|
-
coerce: require_coerce(),
|
|
1973
|
-
truncate: require_truncate(),
|
|
1974
|
-
Comparator: require_comparator(),
|
|
1975
|
-
Range: require_range(),
|
|
1976
|
-
satisfies: require_satisfies(),
|
|
1977
|
-
toComparators: require_to_comparators(),
|
|
1978
|
-
maxSatisfying: require_max_satisfying(),
|
|
1979
|
-
minSatisfying: require_min_satisfying(),
|
|
1980
|
-
minVersion: require_min_version(),
|
|
1981
|
-
validRange: require_valid(),
|
|
1982
|
-
outside: require_outside(),
|
|
1983
|
-
gtr: require_gtr(),
|
|
1984
|
-
ltr: require_ltr(),
|
|
1985
|
-
intersects: require_intersects(),
|
|
1986
|
-
simplifyRange: require_simplify(),
|
|
1987
|
-
subset: require_subset(),
|
|
1988
|
-
SemVer,
|
|
1989
|
-
re: internalRe.re,
|
|
1990
|
-
src: internalRe.src,
|
|
1991
|
-
tokens: internalRe.t,
|
|
1992
|
-
SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
|
|
1993
|
-
RELEASE_TYPES: constants.RELEASE_TYPES,
|
|
1994
|
-
compareIdentifiers: identifiers.compareIdentifiers,
|
|
1995
|
-
rcompareIdentifiers: identifiers.rcompareIdentifiers
|
|
1996
|
-
};
|
|
1997
|
-
})))();
|
|
1998
|
-
var MOLDEA_CLI_FOUNDATIONAL_PACKAGE_NAMES = Object.freeze([
|
|
1999
|
-
"@moldea.ai/core",
|
|
2000
|
-
"@moldea.ai/repository",
|
|
2001
|
-
"@moldea.ai/repository-fs"
|
|
2002
|
-
]);
|
|
2003
|
-
var MOLDEA_CLI_ADAPTER_PACKAGE_PREFIX = "@moldea.ai/adapter-";
|
|
2004
|
-
var MOLDEA_CLI_CUSTOM_ADAPTER_ID = "custom";
|
|
2005
|
-
//#endregion
|
|
2006
|
-
//#region src/composition/validations.ts
|
|
2007
|
-
var ADAPTER_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
|
|
2008
|
-
var hasExactStringSet = (left, right) => {
|
|
2009
|
-
if (left.length !== right.length || new Set(left).size !== left.length || new Set(right).size !== right.length) return false;
|
|
2010
|
-
const rightValues = new Set(right);
|
|
2011
|
-
return left.every((entry) => rightValues.has(entry));
|
|
2012
|
-
};
|
|
2013
|
-
var hasUniquePositiveIntegers = (entries) => entries.length > 0 && entries.every((entry) => Number.isSafeInteger(entry) && entry > 0) && new Set(entries).size === entries.length;
|
|
2014
|
-
var createActiveAdapterMap = (adapters, coreRepositoryFormatVersions) => {
|
|
2015
|
-
const adapterMap = /* @__PURE__ */ new Map();
|
|
2016
|
-
for (const adapter of adapters) {
|
|
2017
|
-
if (adapterMap.has(adapter.id) || adapter.id === "custom" || !ADAPTER_ID_PATTERN.test(adapter.id) || !hasUniquePositiveIntegers(adapter.supportedRepositoryFormatVersions) || adapter.supportedRepositoryFormatVersions.some((version) => !coreRepositoryFormatVersions.includes(version))) return null;
|
|
2018
|
-
adapterMap.set(adapter.id, adapter);
|
|
2019
|
-
}
|
|
2020
|
-
return adapterMap;
|
|
2021
|
-
};
|
|
2022
|
-
/**
|
|
2023
|
-
* Verifies the installed package manifest and actual executable adapter composition.
|
|
2024
|
-
* @param input The installed package, Core, adapter, Git, and JSON-schema state.
|
|
2025
|
-
* @returns Whether every runtime composition invariant is satisfied.
|
|
2026
|
-
*/
|
|
2027
|
-
var isMoldeaCliCompositionStateValid = (input) => {
|
|
2028
|
-
const { dependencies, installedPackageVersions, supportedNodeRange, version } = input.packageMetadata;
|
|
2029
|
-
if ((0, import_semver.valid)(version) === null || supportedNodeRange === null || (0, import_semver.validRange)(supportedNodeRange) === null || (0, import_semver.valid)(input.minimumGitVersion) === null || input.outputSchemaVersion !== 2 || dependencies === null || installedPackageVersions === null || !hasUniquePositiveIntegers(input.coreSupportedRepositoryFormatVersions)) return false;
|
|
2030
|
-
const activeAdapterMap = createActiveAdapterMap(input.activeAdapters, input.coreSupportedRepositoryFormatVersions);
|
|
2031
|
-
if (activeAdapterMap === null) return false;
|
|
2032
|
-
const expectedPackageNames = [...MOLDEA_CLI_FOUNDATIONAL_PACKAGE_NAMES, ...[...activeAdapterMap.keys()].map((adapterId) => `${MOLDEA_CLI_ADAPTER_PACKAGE_PREFIX}${adapterId}`)];
|
|
2033
|
-
const declaredPackageNames = Object.keys(dependencies).filter((packageName) => packageName.startsWith("@moldea.ai/"));
|
|
2034
|
-
const resolvedPackageNames = Object.keys(installedPackageVersions);
|
|
2035
|
-
if (!hasExactStringSet(declaredPackageNames, expectedPackageNames) || !hasExactStringSet(resolvedPackageNames, expectedPackageNames)) return false;
|
|
2036
|
-
return expectedPackageNames.every((packageName) => {
|
|
2037
|
-
const resolvedVersion = installedPackageVersions[packageName];
|
|
2038
|
-
const declaredVersion = dependencies[packageName];
|
|
2039
|
-
return resolvedVersion !== void 0 && (0, import_semver.valid)(resolvedVersion) !== null && (declaredVersion === resolvedVersion || declaredVersion === `workspace:${resolvedVersion}`);
|
|
2040
|
-
});
|
|
2041
|
-
};
|
|
2042
|
-
//#endregion
|
|
2043
|
-
//#region src/composition/transformers.ts
|
|
2044
|
-
var compareIdentifiers = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
2045
|
-
/** Recursively freezes a composition result without retaining mutable input ownership. */
|
|
2046
|
-
var freezeCompositionValue = (value) => {
|
|
2047
|
-
const pendingValues = [value];
|
|
2048
|
-
const visitedValues = /* @__PURE__ */ new Set();
|
|
2049
|
-
while (pendingValues.length > 0) {
|
|
2050
|
-
const currentValue = pendingValues.pop();
|
|
2051
|
-
if (currentValue === void 0 || visitedValues.has(currentValue)) continue;
|
|
2052
|
-
visitedValues.add(currentValue);
|
|
2053
|
-
for (const nestedValue of Object.values(currentValue)) if (typeof nestedValue === "object" && nestedValue !== null) pendingValues.push(nestedValue);
|
|
2054
|
-
Object.freeze(currentValue);
|
|
2055
|
-
}
|
|
2056
|
-
return value;
|
|
2057
|
-
};
|
|
2058
|
-
/**
|
|
2059
|
-
* Creates the compact immutable composition result from validated installed state.
|
|
2060
|
-
* @param input The already validated installed and executable composition.
|
|
2061
|
-
* @returns A deeply immutable composition result in deterministic report order.
|
|
2062
|
-
*/
|
|
2063
|
-
var createMoldeaCliCompositionResult = (input) => {
|
|
2064
|
-
const adapters = [{
|
|
2065
|
-
id: MOLDEA_CLI_CUSTOM_ADAPTER_ID,
|
|
2066
|
-
repositoryFormatVersions: [...input.coreSupportedRepositoryFormatVersions].sort((left, right) => left - right)
|
|
2067
|
-
}, ...input.activeAdapters.map((adapter) => ({
|
|
2068
|
-
id: adapter.id,
|
|
2069
|
-
repositoryFormatVersions: [...adapter.supportedRepositoryFormatVersions].sort((left, right) => left - right)
|
|
2070
|
-
}))].sort((left, right) => compareIdentifiers(left.id, right.id));
|
|
2071
|
-
const packages = Object.entries(input.packageMetadata.installedPackageVersions ?? {}).map(([name, version]) => ({
|
|
2072
|
-
name,
|
|
2073
|
-
version
|
|
2074
|
-
})).sort((left, right) => compareIdentifiers(left.name, right.name));
|
|
2075
|
-
return freezeCompositionValue({
|
|
2076
|
-
adapters,
|
|
2077
|
-
minimumGitVersion: input.minimumGitVersion,
|
|
2078
|
-
packages,
|
|
2079
|
-
repositoryFormatVersions: [...input.coreSupportedRepositoryFormatVersions].sort((left, right) => left - right),
|
|
2080
|
-
supportedNodeRange: input.packageMetadata.supportedNodeRange ?? ""
|
|
2081
|
-
});
|
|
2082
|
-
};
|
|
2083
|
-
//#endregion
|
|
2084
|
-
//#region src/core-composition/constants.ts
|
|
2085
|
-
var ACTIVE_RUNTIME_ADAPTERS = Object.freeze([
|
|
2086
|
-
anthropicAdapter,
|
|
2087
|
-
claudeAgentSdkAdapter,
|
|
2088
|
-
cloudflareAgentsAdapter,
|
|
2089
|
-
eveAdapter,
|
|
2090
|
-
googleGenAiAdapter,
|
|
2091
|
-
langChainAdapter,
|
|
2092
|
-
langGraphAdapter,
|
|
2093
|
-
openAiAdapter,
|
|
2094
|
-
openAiAgentsSdkAdapter,
|
|
2095
|
-
vercelAiSdkAdapter
|
|
2096
|
-
]);
|
|
2097
|
-
//#endregion
|
|
2098
|
-
//#region src/core-composition/executor.ts
|
|
2099
|
-
var compareAdapterIds = (left, right) => {
|
|
2100
|
-
if (left.id < right.id) return -1;
|
|
2101
|
-
if (left.id > right.id) return 1;
|
|
2102
|
-
return 0;
|
|
2103
|
-
};
|
|
2104
|
-
/**
|
|
2105
|
-
* Creates the private attempt-local Core composition boundary.
|
|
2106
|
-
* @param coreFactory The immutable Core construction boundary.
|
|
2107
|
-
* @param activeAdapters The package-backed adapters active in this CLI release.
|
|
2108
|
-
* @returns An executor that creates and runs a fresh Core instance per snapshot attempt.
|
|
2109
|
-
*/
|
|
2110
|
-
var createMoldeaCliCoreInspectionExecutor = (coreFactory = createCore, activeAdapters = ACTIVE_RUNTIME_ADAPTERS) => {
|
|
2111
|
-
const normalizedAdapters = Object.freeze([...activeAdapters].sort(compareAdapterIds));
|
|
2112
|
-
return async (input) => {
|
|
2113
|
-
return coreFactory({
|
|
2114
|
-
adapters: normalizedAdapters,
|
|
2115
|
-
limits: Object.freeze({
|
|
2116
|
-
maxDiagnostics: input.resourceLimits.maxDiagnostics,
|
|
2117
|
-
maxEntries: input.resourceLimits.maxEntries,
|
|
2118
|
-
maxEvidence: input.resourceLimits.maxEvidence,
|
|
2119
|
-
maxFileBytes: input.resourceLimits.maxFileBytes,
|
|
2120
|
-
maxManifestBytes: input.resourceLimits.maxManifestBytes,
|
|
2121
|
-
maxTotalBytesRead: input.resourceLimits.maxTotalBytes
|
|
2122
|
-
})
|
|
2123
|
-
}).inspectProject({
|
|
2124
|
-
repository: input.repository,
|
|
2125
|
-
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
2126
|
-
});
|
|
2127
|
-
};
|
|
2128
|
-
};
|
|
2129
|
-
/**
|
|
2130
|
-
* Executes one project inspection through a fresh CLI-configured Core instance.
|
|
2131
|
-
* @returns A promise resolving to Core's complete immutable inspection result.
|
|
2132
|
-
* @throws
|
|
2133
|
-
* - DUPLICATE_ADAPTER_ID: A runtime adapter ID is registered more than once.
|
|
2134
|
-
* - RESERVED_ADAPTER_ID: A reserved runtime adapter ID was supplied.
|
|
2135
|
-
* - INVALID_ADAPTER_DEFINITION: A runtime adapter definition is invalid.
|
|
2136
|
-
* - INVALID_RESOURCE_LIMIT: A Core resource limit is invalid.
|
|
2137
|
-
* - INVALID_ARGUMENT: The Core operation received an invalid argument.
|
|
2138
|
-
* - INVALID_REPOSITORY_PATH: A repository path is invalid.
|
|
2139
|
-
* - ENTRY_NOT_FOUND: A discovered file disappeared from the reader snapshot.
|
|
2140
|
-
* - ENTRY_NOT_FILE: A discovered file changed type during inspection.
|
|
2141
|
-
* - ENTRY_NOT_DIRECTORY: A discovered directory changed type during inspection.
|
|
2142
|
-
* - ACCESS_DENIED: Access to the repository source was denied.
|
|
2143
|
-
* - SOURCE_UNAVAILABLE: The repository source is unavailable.
|
|
2144
|
-
* - SNAPSHOT_CHANGED: The repository snapshot changed during inspection.
|
|
2145
|
-
* - INVALID_SOURCE_DATA: The repository reader returned invalid contract data.
|
|
2146
|
-
* - RESOURCE_LIMIT_EXCEEDED: A Core or repository resource limit was exceeded.
|
|
2147
|
-
* - ABORTED: Project inspection or a repository operation was aborted.
|
|
2148
|
-
* - ADAPTER_EXECUTION_FAILED: A runtime adapter failed or returned an invalid result.
|
|
2149
|
-
*/
|
|
2150
|
-
var executeMoldeaCliCoreInspection = createMoldeaCliCoreInspectionExecutor();
|
|
2151
|
-
//#endregion
|
|
2152
|
-
//#region src/git-version/constants.ts
|
|
2153
|
-
var MINIMUM_GIT_VERSION_COMPONENTS = Object.freeze({
|
|
2154
|
-
major: 2,
|
|
2155
|
-
minor: 30,
|
|
2156
|
-
patch: 0
|
|
2157
|
-
});
|
|
2158
|
-
var MINIMUM_GIT_VERSION = `${MINIMUM_GIT_VERSION_COMPONENTS.major}.${MINIMUM_GIT_VERSION_COMPONENTS.minor}.${MINIMUM_GIT_VERSION_COMPONENTS.patch}`;
|
|
2159
|
-
var MAX_GIT_VERSION_OUTPUT_BYTES = 4096;
|
|
2160
|
-
//#endregion
|
|
2161
|
-
//#region src/git-version/parser.ts
|
|
2162
|
-
var GIT_VERSION_PATTERN = /^git version (0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:[.-][0-9A-Za-z]+)*(?: \([0-9A-Za-z](?:[0-9A-Za-z ._+/-]*[0-9A-Za-z])?\))?$/;
|
|
2163
|
-
var UTF8_DECODER = new TextDecoder$1("utf-8", {
|
|
2164
|
-
fatal: true,
|
|
2165
|
-
ignoreBOM: true
|
|
2166
|
-
});
|
|
2167
|
-
/**
|
|
2168
|
-
* Decodes one terminated Git version line as strict UTF-8.
|
|
2169
|
-
* @param output The bounded stdout bytes from `git --version`.
|
|
2170
|
-
* @returns The line without its terminator, or null when invalid.
|
|
2171
|
-
*/
|
|
2172
|
-
var decodeGitVersionLine = (output) => {
|
|
2173
|
-
let decodedOutput;
|
|
2174
|
-
try {
|
|
2175
|
-
decodedOutput = UTF8_DECODER.decode(output);
|
|
2176
|
-
} catch {
|
|
2177
|
-
return null;
|
|
2178
|
-
}
|
|
2179
|
-
if (decodedOutput.startsWith("")) return null;
|
|
2180
|
-
if (decodedOutput.endsWith("\r\n")) return decodedOutput.slice(0, -2);
|
|
2181
|
-
if (decodedOutput.endsWith("\n")) return decodedOutput.slice(0, -1);
|
|
2182
|
-
return null;
|
|
2183
|
-
};
|
|
2184
|
-
/**
|
|
2185
|
-
* Parses a strict `git --version` response without accepting arbitrary prose.
|
|
2186
|
-
* @param output The bounded stdout bytes from Git.
|
|
2187
|
-
* @returns The frozen numeric version, or null when the output is invalid.
|
|
2188
|
-
*/
|
|
2189
|
-
var parseGitVersionOutput = (output) => {
|
|
2190
|
-
const versionLine = decodeGitVersionLine(output);
|
|
2191
|
-
if (versionLine === null || versionLine.includes("\r") || versionLine.includes("\n")) return null;
|
|
2192
|
-
const match = GIT_VERSION_PATTERN.exec(versionLine);
|
|
2193
|
-
if (match === null) return null;
|
|
2194
|
-
const majorText = match[1];
|
|
2195
|
-
const minorText = match[2];
|
|
2196
|
-
const patchText = match[3];
|
|
2197
|
-
if (majorText === void 0 || minorText === void 0 || patchText === void 0) return null;
|
|
2198
|
-
const major = Number(majorText);
|
|
2199
|
-
const minor = Number(minorText);
|
|
2200
|
-
const patch = Number(patchText);
|
|
2201
|
-
if (![
|
|
2202
|
-
major,
|
|
2203
|
-
minor,
|
|
2204
|
-
patch
|
|
2205
|
-
].every(Number.isSafeInteger)) return null;
|
|
2206
|
-
return Object.freeze({
|
|
2207
|
-
major,
|
|
2208
|
-
minor,
|
|
2209
|
-
patch
|
|
2210
|
-
});
|
|
2211
|
-
};
|
|
2212
|
-
//#endregion
|
|
2213
|
-
//#region src/git-process/constants.ts
|
|
2214
|
-
var GIT_PROCESS_GLOBAL_ARGUMENTS = [
|
|
2215
|
-
"--no-pager",
|
|
2216
|
-
"-c",
|
|
2217
|
-
"color.ui=false",
|
|
2218
|
-
"-c",
|
|
2219
|
-
"core.fsmonitor=false",
|
|
2220
|
-
"-c",
|
|
2221
|
-
"submodule.recurse=false"
|
|
2222
|
-
];
|
|
2223
|
-
var MAX_GIT_PROCESS_DIAGNOSTIC_BYTES = 4096;
|
|
2224
|
-
var GIT_PROCESS_REMOVED_ENVIRONMENT_NAMES = [
|
|
2225
|
-
"GIT_DIR",
|
|
2226
|
-
"GIT_WORK_TREE",
|
|
2227
|
-
"GIT_INDEX_FILE",
|
|
2228
|
-
"GIT_OBJECT_DIRECTORY",
|
|
2229
|
-
"GIT_ALTERNATE_OBJECT_DIRECTORIES",
|
|
2230
|
-
"GIT_COMMON_DIR",
|
|
2231
|
-
"GIT_CEILING_DIRECTORIES",
|
|
2232
|
-
"GIT_DISCOVERY_ACROSS_FILESYSTEM",
|
|
2233
|
-
"GIT_NAMESPACE",
|
|
2234
|
-
"GIT_SHALLOW_FILE",
|
|
2235
|
-
"GIT_ATTR_SOURCE",
|
|
2236
|
-
"GIT_CONFIG",
|
|
2237
|
-
"GIT_CONFIG_SYSTEM",
|
|
2238
|
-
"GIT_CONFIG_GLOBAL",
|
|
2239
|
-
"GIT_CONFIG_NOSYSTEM",
|
|
2240
|
-
"GIT_CONFIG_PARAMETERS",
|
|
2241
|
-
"GIT_CONFIG_COUNT",
|
|
2242
|
-
"GIT_EXEC_PATH",
|
|
2243
|
-
"GIT_LITERAL_PATHSPECS",
|
|
2244
|
-
"GIT_GLOB_PATHSPECS",
|
|
2245
|
-
"GIT_NOGLOB_PATHSPECS",
|
|
2246
|
-
"GIT_ICASE_PATHSPECS"
|
|
2247
|
-
];
|
|
2248
|
-
var GIT_PROCESS_REMOVED_ENVIRONMENT_PREFIXES = [
|
|
2249
|
-
"GIT_CONFIG_KEY_",
|
|
2250
|
-
"GIT_CONFIG_VALUE_",
|
|
2251
|
-
"GIT_TRACE"
|
|
2252
|
-
];
|
|
2253
|
-
var GIT_PROCESS_ENVIRONMENT_OVERRIDES = Object.freeze({
|
|
2254
|
-
LC_ALL: "C",
|
|
2255
|
-
LANG: "C",
|
|
2256
|
-
LANGUAGE: "C",
|
|
2257
|
-
GIT_OPTIONAL_LOCKS: "0",
|
|
2258
|
-
GIT_PAGER: "",
|
|
2259
|
-
PAGER: "",
|
|
2260
|
-
GIT_TERMINAL_PROMPT: "0",
|
|
2261
|
-
NO_COLOR: "1"
|
|
2262
|
-
});
|
|
2263
|
-
//#endregion
|
|
2264
|
-
//#region src/git-process/environment.ts
|
|
2265
|
-
var REMOVED_ENVIRONMENT_NAMES = new Set(GIT_PROCESS_REMOVED_ENVIRONMENT_NAMES.map((name) => name.toUpperCase()));
|
|
2266
|
-
/**
|
|
2267
|
-
* Determines whether an inherited environment variable can alter Git behavior.
|
|
2268
|
-
* @param name The environment variable name.
|
|
2269
|
-
* @returns Whether the variable must be removed.
|
|
2270
|
-
*/
|
|
2271
|
-
var isRemovedEnvironmentVariable = (name) => {
|
|
2272
|
-
const normalizedName = name.toUpperCase();
|
|
2273
|
-
return REMOVED_ENVIRONMENT_NAMES.has(normalizedName) || GIT_PROCESS_REMOVED_ENVIRONMENT_PREFIXES.some((prefix) => normalizedName.startsWith(prefix));
|
|
2274
|
-
};
|
|
2275
|
-
/**
|
|
2276
|
-
* Creates the immutable, deterministic environment used by Git subprocesses.
|
|
2277
|
-
* @param environment The host environment to sanitize.
|
|
2278
|
-
* @returns A frozen environment that preserves unrelated variables.
|
|
2279
|
-
*/
|
|
2280
|
-
var createGitProcessEnvironment = (environment) => {
|
|
2281
|
-
const sanitizedEnvironment = {};
|
|
2282
|
-
for (const [name, environmentValue] of Object.entries(environment)) if (environmentValue !== void 0 && !isRemovedEnvironmentVariable(name) && !(name.toUpperCase() in GIT_PROCESS_ENVIRONMENT_OVERRIDES)) sanitizedEnvironment[name] = environmentValue;
|
|
2283
|
-
return Object.freeze({
|
|
2284
|
-
...sanitizedEnvironment,
|
|
2285
|
-
...GIT_PROCESS_ENVIRONMENT_OVERRIDES
|
|
2286
|
-
});
|
|
2287
|
-
};
|
|
2288
|
-
//#endregion
|
|
2289
|
-
//#region src/git-process/utilities.ts
|
|
2290
|
-
/**
|
|
2291
|
-
* Classifies a subprocess error without retaining provider diagnostics.
|
|
2292
|
-
* @param error The Node.js subprocess error, or null for a nonzero exit.
|
|
2293
|
-
* @param stderr The bounded process diagnostic used only for classification.
|
|
2294
|
-
* @returns The normalized failure reason.
|
|
2295
|
-
*/
|
|
2296
|
-
var classifyGitProcessError = (error, stderr) => {
|
|
2297
|
-
const errorCode = error instanceof Error && "code" in error && typeof error.code === "string" ? error.code.toUpperCase() : "";
|
|
2298
|
-
if (errorCode === "ENOENT") return "not-found";
|
|
2299
|
-
if (errorCode === "EACCES" || errorCode === "EPERM") return "access-denied";
|
|
2300
|
-
if (errorCode === "ERR_CHILD_PROCESS_STDIO_MAXBUFFER") return "output-limit-exceeded";
|
|
2301
|
-
const diagnostic = new TextDecoder().decode(stderr);
|
|
2302
|
-
if (diagnostic.startsWith("fatal: not a git repository")) return "repository-not-found";
|
|
2303
|
-
if (diagnostic.startsWith("fatal: detected dubious ownership in repository at ") || diagnostic.startsWith("fatal: ") && /: Permission denied(?:\r?\n)?$/u.test(diagnostic)) return "access-denied";
|
|
2304
|
-
return "command-failed";
|
|
2305
|
-
};
|
|
2306
|
-
//#endregion
|
|
2307
|
-
//#region src/git-process/executor.ts
|
|
2308
|
-
/**
|
|
2309
|
-
* Executes Git directly with trusted arguments, a sanitized environment, and bounded output.
|
|
2310
|
-
* @param options The trusted arguments, environment, output limit, and optional signal.
|
|
2311
|
-
* @returns A promise that resolves to normalized process output or failure.
|
|
2312
|
-
*/
|
|
2313
|
-
var executeGitProcess = async (options) => new Promise((resolve) => {
|
|
2314
|
-
if (options.signal?.aborted) {
|
|
2315
|
-
resolve(Object.freeze({
|
|
2316
|
-
kind: "failed",
|
|
2317
|
-
reason: "aborted"
|
|
2318
|
-
}));
|
|
2319
|
-
return;
|
|
2320
|
-
}
|
|
2321
|
-
execFile("git", [...GIT_PROCESS_GLOBAL_ARGUMENTS, ...options.arguments], {
|
|
2322
|
-
encoding: "buffer",
|
|
2323
|
-
env: createGitProcessEnvironment(options.environment ?? process$1.env),
|
|
2324
|
-
maxBuffer: options.maxBufferBytes,
|
|
2325
|
-
shell: false,
|
|
2326
|
-
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
2327
|
-
windowsHide: true
|
|
2328
|
-
}, (error, stdout, stderr) => {
|
|
2329
|
-
if (options.signal?.aborted) {
|
|
2330
|
-
resolve(Object.freeze({
|
|
2331
|
-
kind: "failed",
|
|
2332
|
-
reason: "aborted"
|
|
2333
|
-
}));
|
|
2334
|
-
return;
|
|
2335
|
-
}
|
|
2336
|
-
if (error) {
|
|
2337
|
-
resolve(Object.freeze({
|
|
2338
|
-
kind: "failed",
|
|
2339
|
-
reason: classifyGitProcessError(error, stderr)
|
|
2340
|
-
}));
|
|
2341
|
-
return;
|
|
2342
|
-
}
|
|
2343
|
-
resolve(Object.freeze({
|
|
2344
|
-
kind: "completed",
|
|
2345
|
-
stdout: Uint8Array.from(stdout),
|
|
2346
|
-
stderr: Uint8Array.from(stderr)
|
|
2347
|
-
}));
|
|
2348
|
-
});
|
|
2349
|
-
});
|
|
2350
|
-
//#endregion
|
|
2351
|
-
//#region src/git-process/streaming-executor.ts
|
|
2352
|
-
/** Concatenates the bounded stderr chunks retained for classification. */
|
|
2353
|
-
var concatenateChunks$2 = (chunks, byteLength) => Uint8Array.from(Buffer.concat(chunks, byteLength));
|
|
2354
|
-
/**
|
|
2355
|
-
* Executes Git directly while consuming bounded stdout incrementally.
|
|
2356
|
-
* @param options The trusted arguments, optional stdin and signal, consumer, environment, and limits.
|
|
2357
|
-
* @returns A promise that resolves to a normalized streamed process result.
|
|
2358
|
-
*/
|
|
2359
|
-
var executeGitStreamingProcess = async (options) => new Promise((resolve, reject) => {
|
|
2360
|
-
if (options.signal?.aborted) {
|
|
2361
|
-
resolve(Object.freeze({
|
|
2362
|
-
kind: "failed",
|
|
2363
|
-
reason: "aborted"
|
|
2364
|
-
}));
|
|
2365
|
-
return;
|
|
2366
|
-
}
|
|
2367
|
-
const stdin = options.stdin === void 0 ? null : Uint8Array.from(options.stdin);
|
|
2368
|
-
const stderrChunks = [];
|
|
2369
|
-
let failureReason = null;
|
|
2370
|
-
let isSettled = false;
|
|
2371
|
-
let stderrBytes = 0;
|
|
2372
|
-
let stdoutBytes = 0;
|
|
2373
|
-
const childProcess = spawn("git", [...GIT_PROCESS_GLOBAL_ARGUMENTS, ...options.arguments], {
|
|
2374
|
-
env: createGitProcessEnvironment(options.environment ?? process$1.env),
|
|
2375
|
-
shell: false,
|
|
2376
|
-
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
2377
|
-
stdio: [
|
|
2378
|
-
stdin === null ? "ignore" : "pipe",
|
|
2379
|
-
"pipe",
|
|
2380
|
-
"pipe"
|
|
2381
|
-
],
|
|
2382
|
-
windowsHide: true
|
|
2383
|
-
});
|
|
2384
|
-
const { stderr, stdout } = childProcess;
|
|
2385
|
-
if (stderr === null || stdout === null) {
|
|
2386
|
-
childProcess.on("error", () => void 0);
|
|
2387
|
-
childProcess.kill();
|
|
2388
|
-
resolve(Object.freeze({
|
|
2389
|
-
kind: "failed",
|
|
2390
|
-
reason: "command-failed"
|
|
2391
|
-
}));
|
|
2392
|
-
return;
|
|
2393
|
-
}
|
|
2394
|
-
stdout.on("data", (chunk) => {
|
|
2395
|
-
if (failureReason !== null || isSettled) return;
|
|
2396
|
-
if (stdoutBytes + chunk.byteLength > options.maxStdoutBytes) {
|
|
2397
|
-
failureReason = "stdout-limit-exceeded";
|
|
2398
|
-
childProcess.kill();
|
|
2399
|
-
return;
|
|
2400
|
-
}
|
|
2401
|
-
stdoutBytes += chunk.byteLength;
|
|
2402
|
-
try {
|
|
2403
|
-
options.consumeStdout(Uint8Array.from(chunk));
|
|
2404
|
-
} catch (error) {
|
|
2405
|
-
isSettled = true;
|
|
2406
|
-
childProcess.kill();
|
|
2407
|
-
reject(error instanceof Error ? error : new Error("The Git stdout consumer failed.", { cause: error }));
|
|
2408
|
-
}
|
|
2409
|
-
});
|
|
2410
|
-
stderr.on("data", (chunk) => {
|
|
2411
|
-
if (failureReason !== null || isSettled) return;
|
|
2412
|
-
if (stderrBytes + chunk.byteLength > options.maxStderrBytes) {
|
|
2413
|
-
failureReason = "stderr-limit-exceeded";
|
|
2414
|
-
childProcess.kill();
|
|
2415
|
-
return;
|
|
2416
|
-
}
|
|
2417
|
-
stderrBytes += chunk.byteLength;
|
|
2418
|
-
stderrChunks.push(chunk);
|
|
2419
|
-
});
|
|
2420
|
-
childProcess.on("error", (error) => {
|
|
2421
|
-
if (failureReason !== null || isSettled) return;
|
|
2422
|
-
isSettled = true;
|
|
2423
|
-
resolve(Object.freeze({
|
|
2424
|
-
kind: "failed",
|
|
2425
|
-
reason: options.signal?.aborted ? "aborted" : classifyGitProcessError(error, concatenateChunks$2(stderrChunks, stderrBytes))
|
|
2426
|
-
}));
|
|
2427
|
-
});
|
|
2428
|
-
childProcess.on("close", (exitCode) => {
|
|
2429
|
-
if (isSettled) return;
|
|
2430
|
-
isSettled = true;
|
|
2431
|
-
if (failureReason !== null) {
|
|
2432
|
-
resolve(Object.freeze({
|
|
2433
|
-
kind: "failed",
|
|
2434
|
-
reason: failureReason
|
|
2435
|
-
}));
|
|
2436
|
-
return;
|
|
2437
|
-
}
|
|
2438
|
-
if (options.signal?.aborted) {
|
|
2439
|
-
resolve(Object.freeze({
|
|
2440
|
-
kind: "failed",
|
|
2441
|
-
reason: "aborted"
|
|
2442
|
-
}));
|
|
2443
|
-
return;
|
|
2444
|
-
}
|
|
2445
|
-
const stderr = concatenateChunks$2(stderrChunks, stderrBytes);
|
|
2446
|
-
if (exitCode !== 0) {
|
|
2447
|
-
resolve(Object.freeze({
|
|
2448
|
-
kind: "failed",
|
|
2449
|
-
reason: classifyGitProcessError(null, stderr)
|
|
2450
|
-
}));
|
|
2451
|
-
return;
|
|
2452
|
-
}
|
|
2453
|
-
resolve(Object.freeze({
|
|
2454
|
-
kind: "completed",
|
|
2455
|
-
stderr,
|
|
2456
|
-
stdoutBytes
|
|
2457
|
-
}));
|
|
658
|
+
*/
|
|
659
|
+
var createMoldeaCliOwnedError = (code) => {
|
|
660
|
+
const definition = MOLDEA_CLI_ERROR_DEFINITIONS[code];
|
|
661
|
+
return Object.freeze({
|
|
662
|
+
code,
|
|
663
|
+
details: EMPTY_ERROR_DETAILS$1,
|
|
664
|
+
message: definition.message,
|
|
665
|
+
path: null,
|
|
666
|
+
retryable: definition.retryable,
|
|
667
|
+
source: definition.source
|
|
2458
668
|
});
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
669
|
+
};
|
|
670
|
+
//#endregion
|
|
671
|
+
//#region src/json-output-contract/document.ts
|
|
672
|
+
/** Creates one strict schema 4 JSON envelope. */
|
|
673
|
+
var createMoldeaCliJsonEnvelope = (input) => Object.freeze({
|
|
674
|
+
cliVersion: input.cliVersion,
|
|
675
|
+
command: input.command,
|
|
676
|
+
error: input.error,
|
|
677
|
+
result: input.result,
|
|
678
|
+
schemaVersion: 4,
|
|
679
|
+
status: input.status
|
|
680
|
+
});
|
|
681
|
+
/** Serializes one schema 4 envelope with its required trailing line feed. */
|
|
682
|
+
var serializeMoldeaCliJsonEnvelope = (input) => `${serializeJsonDeterministically(createMoldeaCliJsonEnvelope(input))}\n`;
|
|
683
|
+
//#endregion
|
|
684
|
+
//#region src/json-output-contract/guard.ts
|
|
685
|
+
/** Rejects canonical bodies and content fields from a non-content JSON result. */
|
|
686
|
+
var assertMoldeaCliJsonResultIsContentFree = (value, canonicalBodies = []) => {
|
|
687
|
+
const pending = [value];
|
|
688
|
+
const visited = /* @__PURE__ */ new Set();
|
|
689
|
+
const bodies = new Set(canonicalBodies.filter((body) => body.length > 0));
|
|
690
|
+
while (pending.length > 0) {
|
|
691
|
+
const current = pending.pop();
|
|
692
|
+
if (typeof current === "string") {
|
|
693
|
+
if (bodies.has(current)) throw new TypeError("A non-content CLI result contains canonical document text.");
|
|
694
|
+
continue;
|
|
2464
695
|
}
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
try {
|
|
2471
|
-
childProcess.stdin.end(stdin);
|
|
2472
|
-
} catch {
|
|
2473
|
-
failureReason = "command-failed";
|
|
2474
|
-
childProcess.kill();
|
|
696
|
+
if (typeof current !== "object" || current === null || visited.has(current)) continue;
|
|
697
|
+
visited.add(current);
|
|
698
|
+
if (Array.isArray(current)) {
|
|
699
|
+
for (const item of current) pending.push(item);
|
|
700
|
+
continue;
|
|
2475
701
|
}
|
|
702
|
+
const record = current;
|
|
703
|
+
if (Object.hasOwn(record, "content")) throw new TypeError("A non-content CLI result contains a content property.");
|
|
704
|
+
pending.push(...Object.values(record));
|
|
2476
705
|
}
|
|
2477
|
-
}
|
|
706
|
+
};
|
|
2478
707
|
//#endregion
|
|
2479
|
-
//#region src/
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
708
|
+
//#region src/presentation/formatters.ts
|
|
709
|
+
var DIAGNOSTIC_ENTITY_KEYS = [
|
|
710
|
+
"agentId",
|
|
711
|
+
"capabilityKind",
|
|
712
|
+
"capabilityId",
|
|
713
|
+
"decisionId",
|
|
714
|
+
"variableId",
|
|
715
|
+
"adapterId"
|
|
716
|
+
];
|
|
717
|
+
/** Formats one diagnostic entity in the canonical Core field order. */
|
|
718
|
+
var formatMoldeaCliHumanDiagnosticEntity = (entity) => DIAGNOSTIC_ENTITY_KEYS.flatMap((key) => {
|
|
719
|
+
const identifier = entity[key];
|
|
720
|
+
return identifier === void 0 ? [] : [`${key}=${identifier}`];
|
|
721
|
+
}).join(", ");
|
|
722
|
+
/** Formats one projected diagnostic without exposing omitted arbitrary details. */
|
|
723
|
+
var formatMoldeaCliHumanDiagnostic = (diagnostic) => {
|
|
724
|
+
const location = diagnostic.path === null ? "" : diagnostic.range === null ? ` ${diagnostic.path}` : ` ${diagnostic.path}:${diagnostic.range.start.line}:${diagnostic.range.start.column}`;
|
|
725
|
+
const lines = [`${diagnostic.source}:${diagnostic.code}${location} ${diagnostic.message}`];
|
|
726
|
+
if (diagnostic.pointer !== null) lines.push(` pointer: ${diagnostic.pointer}`);
|
|
727
|
+
if (diagnostic.entity !== null) lines.push(` entity: ${formatMoldeaCliHumanDiagnosticEntity(diagnostic.entity)}`);
|
|
728
|
+
return lines.join("\n");
|
|
2494
729
|
};
|
|
2495
|
-
/**
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
var isGitVersionSupported = (version) => {
|
|
2501
|
-
if (version.major !== MINIMUM_GIT_VERSION_COMPONENTS.major) return version.major > MINIMUM_GIT_VERSION_COMPONENTS.major;
|
|
2502
|
-
if (version.minor !== MINIMUM_GIT_VERSION_COMPONENTS.minor) return version.minor > MINIMUM_GIT_VERSION_COMPONENTS.minor;
|
|
2503
|
-
return version.patch >= MINIMUM_GIT_VERSION_COMPONENTS.patch;
|
|
730
|
+
/** Creates shared human status lines for one completed repository command. */
|
|
731
|
+
var createMoldeaCliHumanStatusLines = (isValid, formatVersion) => {
|
|
732
|
+
const lines = [`The moldea project is ${isValid ? "valid" : "invalid"}.`];
|
|
733
|
+
if (formatVersion !== null) lines.push(`Repository format: ${formatVersion}`);
|
|
734
|
+
return lines;
|
|
2504
735
|
};
|
|
2505
|
-
/**
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
736
|
+
/** Formats one count label with correct singular or plural grammar. */
|
|
737
|
+
var formatMoldeaCliHumanCount = (count, singularLabel, pluralLabel) => `${count === 1 ? singularLabel : pluralLabel}: ${count}`;
|
|
738
|
+
/** Formats top-level or command-specific help with its required trailing line feed. */
|
|
739
|
+
var formatMoldeaCliHelp = (command) => {
|
|
740
|
+
return command === null ? MOLDEA_CLI_TOP_LEVEL_HELP : MOLDEA_CLI_COMMAND_HELP[command];
|
|
741
|
+
};
|
|
742
|
+
/** Formats one safe CLI error for human stderr output. */
|
|
743
|
+
var formatMoldeaCliHumanError = (error) => `${error.source}:${error.code} ${error.message}\n`;
|
|
744
|
+
/** Formats any strict schema 4 JSON envelope. */
|
|
745
|
+
var formatMoldeaCliJsonResult = (command, result, error, status, cliVersion) => serializeMoldeaCliJsonEnvelope({
|
|
746
|
+
cliVersion,
|
|
747
|
+
command,
|
|
748
|
+
error,
|
|
749
|
+
result,
|
|
750
|
+
status
|
|
751
|
+
});
|
|
752
|
+
/** Formats one safe schema 4 JSON error envelope. */
|
|
753
|
+
var formatMoldeaCliJsonError = (error, command, cliVersion) => formatMoldeaCliJsonResult(command, null, error, "error", cliVersion);
|
|
754
|
+
/** Formats one valid composition result for human stdout. */
|
|
755
|
+
var formatMoldeaCliHumanCompositionResult = (result, cliVersion) => {
|
|
756
|
+
return `${[
|
|
757
|
+
"The installed CLI composition state is valid.",
|
|
758
|
+
`CLI version: ${cliVersion}`,
|
|
759
|
+
`Supported Node.js: ${result.supportedNodeRange}`,
|
|
760
|
+
`JSON output schema: 4`,
|
|
761
|
+
`Minimum Git: ${result.minimumGitVersion}`,
|
|
762
|
+
`Repository formats: ${result.repositoryFormatVersions.join(", ")}`,
|
|
763
|
+
"Packages:",
|
|
764
|
+
...result.packages.map(({ name, version }) => ` ${name}: ${version}`),
|
|
765
|
+
"Adapters:",
|
|
766
|
+
...result.adapters.map(({ id, repositoryFormatVersions }) => ` ${id}: repository formats ${repositoryFormatVersions.join(", ")}`)
|
|
767
|
+
].join("\n")}\n`;
|
|
768
|
+
};
|
|
769
|
+
/** Formats one composition result in the strict schema 4 envelope. */
|
|
770
|
+
var formatMoldeaCliJsonCompositionResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Composition, result, null, "valid", cliVersion);
|
|
771
|
+
/** Formats one completed validation result for human stdout. */
|
|
772
|
+
var formatMoldeaCliHumanValidateResult = (result) => {
|
|
773
|
+
const lines = createMoldeaCliHumanStatusLines(result.diagnosticCount === 0, result.formatVersion);
|
|
774
|
+
for (const diagnostic of result.page.records) lines.push(formatMoldeaCliHumanDiagnostic(diagnostic));
|
|
775
|
+
lines.push(formatMoldeaCliHumanCount(result.diagnosticCount, "Diagnostic", "Diagnostics"));
|
|
776
|
+
if (result.page.cursor !== null) lines.push("Additional diagnostics are available through JSON pagination.");
|
|
777
|
+
return `${lines.join("\n")}\n`;
|
|
778
|
+
};
|
|
779
|
+
/** Formats one validation result in the strict schema 4 envelope. */
|
|
780
|
+
var formatMoldeaCliJsonValidateResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Validate, result, null, result.valid ? "valid" : "invalid", cliVersion);
|
|
781
|
+
/** Formats one completed metadata inspection for human stdout. */
|
|
782
|
+
var formatMoldeaCliHumanInspectResult = (result) => {
|
|
783
|
+
const lines = createMoldeaCliHumanStatusLines(result.valid, result.formatVersion);
|
|
784
|
+
for (const [label, count] of Object.entries(result.counts)) lines.push(`${label}: ${count}`);
|
|
785
|
+
return `${lines.join("\n")}\n`;
|
|
786
|
+
};
|
|
787
|
+
/** Formats one metadata inspection in the strict schema 4 envelope. */
|
|
788
|
+
var formatMoldeaCliJsonInspectResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Inspect, result, null, result.valid ? "valid" : "invalid", cliVersion);
|
|
789
|
+
/** Formats one changed-path scope result for human stdout. */
|
|
790
|
+
var formatMoldeaCliHumanScopeResult = (result) => {
|
|
791
|
+
return `${[
|
|
792
|
+
`The moldea scope result is ${result.valid ? "valid" : "invalid"}.`,
|
|
793
|
+
`Relevant: ${result.relevant ? "yes" : "no"}`,
|
|
794
|
+
...Object.entries(result.counts).map(([label, count]) => `${label}: ${count}`)
|
|
795
|
+
].join("\n")}\n`;
|
|
796
|
+
};
|
|
797
|
+
/** Formats one changed-path scope result in the strict schema 4 envelope. */
|
|
798
|
+
var formatMoldeaCliJsonScopeResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Scope, result, null, result.valid ? "valid" : "invalid", cliVersion);
|
|
799
|
+
/** Formats one explicit canonical content chunk for human stdout. */
|
|
800
|
+
var formatMoldeaCliHumanContentResult = (result) => {
|
|
801
|
+
return `${[
|
|
802
|
+
`Path: ${result.asset.path}`,
|
|
803
|
+
`Content identity: ${result.asset.contentIdentity ?? "unavailable"}`,
|
|
804
|
+
`Bytes: ${result.chunk.byteStart}-${result.chunk.byteEnd} of ${result.asset.totalBytes}`,
|
|
805
|
+
result.cursor === null ? "Cursor: none" : `Cursor: ${result.cursor}`,
|
|
806
|
+
...result.cursor === null ? [] : ["Continue this asset by passing the cursor to a JSON content request."],
|
|
807
|
+
"",
|
|
808
|
+
result.chunk.content
|
|
809
|
+
].join("\n")}\n`;
|
|
810
|
+
};
|
|
811
|
+
/** Formats one explicit canonical content chunk in the strict schema 4 envelope. */
|
|
812
|
+
var formatMoldeaCliJsonContentResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Content, result, null, "valid", cliVersion);
|
|
813
|
+
//#endregion
|
|
814
|
+
//#region src/presentation/transformers.ts
|
|
815
|
+
/** Rejects a Core validation result whose completion fields contradict its validity. */
|
|
816
|
+
var assertProjectValidationInvariant = (validation) => {
|
|
817
|
+
if (!(validation.valid ? validation.summary !== null && validation.diagnostics.length === 0 : validation.diagnostics.length > 0)) throw new TypeError("The Core validation result is internally inconsistent.");
|
|
818
|
+
};
|
|
819
|
+
/** Creates one stable composite record key. */
|
|
820
|
+
var createRecordKey = (kind, ...parts) => JSON.stringify([kind, ...parts]);
|
|
821
|
+
/** Projects one diagnostic without retaining arbitrary detail payloads. */
|
|
822
|
+
var createMoldeaCliDiagnosticRecord = (diagnostic, occurrence = 0) => Object.freeze({
|
|
823
|
+
code: diagnostic.code,
|
|
824
|
+
entity: diagnostic.entity,
|
|
825
|
+
key: createRecordKey("diagnostic", diagnostic.source, diagnostic.code, diagnostic.path, diagnostic.pointer, occurrence),
|
|
826
|
+
kind: "diagnostic",
|
|
827
|
+
message: diagnostic.message,
|
|
828
|
+
path: diagnostic.path,
|
|
829
|
+
pointer: diagnostic.pointer,
|
|
830
|
+
range: diagnostic.range,
|
|
831
|
+
source: diagnostic.source
|
|
832
|
+
});
|
|
833
|
+
/** Projects one bounded Core inspection item through the schema 4 allowlist. */
|
|
834
|
+
var createInspectRecord = (item, index) => {
|
|
835
|
+
const order = index.toString().padStart(6, "0");
|
|
836
|
+
if (item.kind === "diagnostic") return Object.freeze({
|
|
837
|
+
...createMoldeaCliDiagnosticRecord(item.diagnostic, index),
|
|
838
|
+
key: createRecordKey(order, "diagnostic", item.diagnostic.source, item.diagnostic.code)
|
|
2519
839
|
});
|
|
2520
|
-
if (
|
|
2521
|
-
|
|
2522
|
-
|
|
840
|
+
if (item.kind === "evidence") {
|
|
841
|
+
const evidence = item.evidence;
|
|
842
|
+
const record = {
|
|
843
|
+
agentId: evidence.agentId,
|
|
844
|
+
capabilityId: evidence.capabilityId,
|
|
845
|
+
capabilityKind: evidence.capabilityKind,
|
|
846
|
+
evidenceKind: evidence.kind,
|
|
847
|
+
key: createRecordKey(order, "evidence", evidence.source, evidence.kind, evidence.agentId, evidence.capabilityKind, evidence.capabilityId, evidence.runtimeName),
|
|
848
|
+
kind: "evidence",
|
|
849
|
+
references: Object.freeze(evidence.references.map((reference) => Object.freeze({
|
|
850
|
+
path: reference.path,
|
|
851
|
+
symbol: reference.symbol ?? null
|
|
852
|
+
}))),
|
|
853
|
+
runtimeName: evidence.runtimeName,
|
|
854
|
+
source: evidence.source
|
|
855
|
+
};
|
|
856
|
+
return Object.freeze(record);
|
|
857
|
+
}
|
|
858
|
+
const metadata = item.metadata;
|
|
859
|
+
const record = {
|
|
860
|
+
agentId: metadata.agentId,
|
|
861
|
+
byteLength: metadata.byteLength,
|
|
862
|
+
canonicalDigest: metadata.canonicalDigest,
|
|
863
|
+
decisionId: metadata.decisionId,
|
|
864
|
+
digest: metadata.digest,
|
|
865
|
+
key: createRecordKey(order, "metadata", metadata.path, metadata.kind, metadata.agentId),
|
|
866
|
+
kind: "metadata",
|
|
867
|
+
metadataKind: metadata.kind,
|
|
868
|
+
path: metadata.path,
|
|
869
|
+
scalarLength: metadata.scalarLength
|
|
870
|
+
};
|
|
871
|
+
return Object.freeze(record);
|
|
872
|
+
};
|
|
873
|
+
/** Creates content-free validation metadata and ordered diagnostic records. */
|
|
874
|
+
var createMoldeaCliValidateProjection = (validation) => {
|
|
875
|
+
assertProjectValidationInvariant(validation);
|
|
876
|
+
const diagnostics = Object.freeze(validation.diagnostics.map((diagnostic, index) => createMoldeaCliDiagnosticRecord(diagnostic, index)).sort((left, right) => left.key < right.key ? -1 : left.key > right.key ? 1 : 0));
|
|
877
|
+
const snapshotDigest = calculateMoldeaCliJsonDigest({
|
|
878
|
+
diagnostics,
|
|
879
|
+
formatVersion: validation.formatVersion,
|
|
880
|
+
summary: validation.summary,
|
|
881
|
+
valid: validation.valid
|
|
2523
882
|
});
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
883
|
+
return Object.freeze({
|
|
884
|
+
diagnostics,
|
|
885
|
+
formatVersion: validation.formatVersion,
|
|
886
|
+
snapshotDigest,
|
|
887
|
+
source: MOLDEA_CLI_GIT_WORKING_TREE_SOURCE,
|
|
888
|
+
valid: validation.valid
|
|
2528
889
|
});
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
890
|
+
};
|
|
891
|
+
/** Projects one bounded Core page through the content-free schema 4 allowlist. */
|
|
892
|
+
var createMoldeaCliInspectProjection = (inspection) => {
|
|
893
|
+
const project = inspection.summary === null ? null : Object.freeze({
|
|
894
|
+
manifest: Object.freeze({
|
|
895
|
+
digest: inspection.summary.manifestDigest,
|
|
896
|
+
path: inspection.summary.manifestPath
|
|
897
|
+
}),
|
|
898
|
+
project: Object.freeze({
|
|
899
|
+
digest: inspection.summary.projectDigest,
|
|
900
|
+
path: inspection.summary.projectPath
|
|
901
|
+
})
|
|
2532
902
|
});
|
|
903
|
+
const records = Object.freeze(inspection.page.records.map(({ item }, index) => createInspectRecord(item, index)));
|
|
904
|
+
const sourceCursors = new Map(inspection.page.records.map((record, index) => {
|
|
905
|
+
const projected = records[index];
|
|
906
|
+
if (projected === void 0) throw new TypeError("A projected inspection record is missing.");
|
|
907
|
+
return [projected.key, record.nextCursor];
|
|
908
|
+
}));
|
|
909
|
+
const snapshotDigest = inspection.inspectionDigest;
|
|
2533
910
|
return Object.freeze({
|
|
2534
|
-
|
|
2535
|
-
|
|
911
|
+
counts: inspection.counts,
|
|
912
|
+
formatVersion: inspection.formatVersion,
|
|
913
|
+
getSourceCursor: (record) => sourceCursors.get(record.key) ?? null,
|
|
914
|
+
project,
|
|
915
|
+
records,
|
|
916
|
+
snapshotDigest,
|
|
917
|
+
source: MOLDEA_CLI_GIT_WORKING_TREE_SOURCE,
|
|
918
|
+
valid: inspection.valid,
|
|
919
|
+
view: inspection.view
|
|
2536
920
|
});
|
|
2537
921
|
};
|
|
2538
922
|
//#endregion
|
|
2539
|
-
//#region src/composition/composition.ts
|
|
2540
|
-
var INVALID_COMPOSITION_RESOLUTION = Object.freeze({ kind: "invalid" });
|
|
2541
|
-
/**
|
|
2542
|
-
* Resolves one explicit runtime composition without emitting a partial composition result.
|
|
2543
|
-
* @param input The installed and actual runtime state to compare.
|
|
2544
|
-
* @returns A valid immutable result or the single invalid-state outcome.
|
|
2545
|
-
*/
|
|
2546
|
-
var resolveMoldeaCliComposition = (input) => {
|
|
2547
|
-
try {
|
|
2548
|
-
if (!isMoldeaCliCompositionStateValid(input)) return INVALID_COMPOSITION_RESOLUTION;
|
|
2549
|
-
return Object.freeze({
|
|
2550
|
-
kind: "valid",
|
|
2551
|
-
result: createMoldeaCliCompositionResult(input)
|
|
2552
|
-
});
|
|
2553
|
-
} catch {
|
|
2554
|
-
return INVALID_COMPOSITION_RESOLUTION;
|
|
2555
|
-
}
|
|
2556
|
-
};
|
|
2557
|
-
/**
|
|
2558
|
-
* Resolves composition through the fixed package, Core, adapter, Git, and JSON composition.
|
|
2559
|
-
* @param input The installed package metadata.
|
|
2560
|
-
* @returns A valid immutable result or the single invalid-state outcome.
|
|
2561
|
-
*/
|
|
2562
|
-
var resolveInstalledMoldeaCliComposition = (input) => resolveMoldeaCliComposition({
|
|
2563
|
-
activeAdapters: ACTIVE_RUNTIME_ADAPTERS,
|
|
2564
|
-
coreSupportedRepositoryFormatVersions: SUPPORTED_REPOSITORY_FORMAT_VERSIONS,
|
|
2565
|
-
minimumGitVersion: MINIMUM_GIT_VERSION,
|
|
2566
|
-
outputSchemaVersion: 2,
|
|
2567
|
-
packageMetadata: input.packageMetadata
|
|
2568
|
-
});
|
|
2569
|
-
//#endregion
|
|
2570
923
|
//#region src/git-working-tree/constants.ts
|
|
2571
924
|
var MAX_GIT_DISCOVERY_OUTPUT_BYTES = 262144;
|
|
2572
925
|
//#endregion
|
|
@@ -2614,7 +967,7 @@ var parseGitBooleanOutput = (output) => {
|
|
|
2614
967
|
var parseGitPathOutput = (output) => {
|
|
2615
968
|
const decodedOutput = decodeGitOutput(output);
|
|
2616
969
|
if (decodedOutput === null || !decodedOutput.endsWith("\n")) return null;
|
|
2617
|
-
const gitPath = process
|
|
970
|
+
const gitPath = process.platform === "win32" && decodedOutput.endsWith("\r\n") ? decodedOutput.slice(0, -2) : decodedOutput.slice(0, -1);
|
|
2618
971
|
return gitPath.length === 0 ? null : gitPath;
|
|
2619
972
|
};
|
|
2620
973
|
/**
|
|
@@ -2906,6 +1259,301 @@ var createGitWorkingTreeIdentityInspector = (processExecutor = executeGitProcess
|
|
|
2906
1259
|
};
|
|
2907
1260
|
var inspectGitWorkingTreeIdentity = createGitWorkingTreeIdentityInspector();
|
|
2908
1261
|
//#endregion
|
|
1262
|
+
//#region src/project-content/exception.ts
|
|
1263
|
+
/** Represents an invalid explicit canonical content request. */
|
|
1264
|
+
var MoldeaCliProjectContentException = class extends Error {
|
|
1265
|
+
code;
|
|
1266
|
+
/** Creates one content request failure with a stable public code. */
|
|
1267
|
+
constructor(code) {
|
|
1268
|
+
super(code);
|
|
1269
|
+
this.code = code;
|
|
1270
|
+
this.name = "MoldeaCliProjectContentException";
|
|
1271
|
+
}
|
|
1272
|
+
};
|
|
1273
|
+
//#endregion
|
|
1274
|
+
//#region src/project-content/validations.ts
|
|
1275
|
+
var CONTEXT_PATH_PATTERN = /^\/moldea\/context\/(?:[^/]+\/)*[^/]+\.md$/u;
|
|
1276
|
+
var DECISION_PATH_PATTERN = /^\/moldea\/decisions\/[^/]+\.md$/u;
|
|
1277
|
+
var RUNTIME_PATH_PATTERN = /^\/moldea\/runtimes\/(?:[^/]+\/)*[^/]+\.md$/u;
|
|
1278
|
+
var AGENT_PATH_PATTERN = /^\/moldea\/agents\/[^/]+\/(?:description|instruction|handoff-description)\.md$/u;
|
|
1279
|
+
/** Determines whether a logical path names one canonical moldea text asset. */
|
|
1280
|
+
var isMoldeaCliCanonicalContentPath = (path) => {
|
|
1281
|
+
if (/[?*[\]{}]/u.test(path)) return false;
|
|
1282
|
+
return path === "/moldea/moldea.yaml" || path === "/moldea/project.md" || CONTEXT_PATH_PATTERN.test(path) || DECISION_PATH_PATTERN.test(path) || RUNTIME_PATH_PATTERN.test(path) || AGENT_PATH_PATTERN.test(path);
|
|
1283
|
+
};
|
|
1284
|
+
/**
|
|
1285
|
+
* Parses one untrusted path and restricts it to the canonical text layout.
|
|
1286
|
+
* @param input The command-line logical path.
|
|
1287
|
+
* @returns The validated canonical repository path.
|
|
1288
|
+
* @throws
|
|
1289
|
+
* - CONTENT_PATH_INVALID: The content path must identify one canonical moldea text asset.
|
|
1290
|
+
*/
|
|
1291
|
+
var parseMoldeaCliCanonicalContentPath = (input) => {
|
|
1292
|
+
let path;
|
|
1293
|
+
try {
|
|
1294
|
+
path = parseRepositoryPath(input);
|
|
1295
|
+
} catch {
|
|
1296
|
+
throw new MoldeaCliProjectContentException("CONTENT_PATH_INVALID");
|
|
1297
|
+
}
|
|
1298
|
+
if (!isMoldeaCliCanonicalContentPath(path)) throw new MoldeaCliProjectContentException("CONTENT_PATH_INVALID");
|
|
1299
|
+
return path;
|
|
1300
|
+
};
|
|
1301
|
+
//#endregion
|
|
1302
|
+
//#region src/project-content/executor.ts
|
|
1303
|
+
/** Creates an adapter-free executor for one bounded canonical content range. */
|
|
1304
|
+
var createMoldeaCliProjectContentExecutor = (coreFactory = createCore) => {
|
|
1305
|
+
return async (input) => {
|
|
1306
|
+
return coreFactory({ limits: Object.freeze({
|
|
1307
|
+
maxDiagnostics: input.resourceLimits.maxDiagnostics,
|
|
1308
|
+
maxEntries: input.resourceLimits.maxEntries,
|
|
1309
|
+
maxEvidence: input.resourceLimits.maxEvidence,
|
|
1310
|
+
maxFileBytes: input.resourceLimits.maxFileBytes,
|
|
1311
|
+
maxManifestBytes: input.resourceLimits.maxManifestBytes,
|
|
1312
|
+
maxTotalBytesRead: input.resourceLimits.maxTotalBytes
|
|
1313
|
+
}) }).readCanonicalContentPage({
|
|
1314
|
+
maxBytes: input.maxBytes,
|
|
1315
|
+
offset: input.offset,
|
|
1316
|
+
path: input.path,
|
|
1317
|
+
repository: input.repository,
|
|
1318
|
+
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
1319
|
+
});
|
|
1320
|
+
};
|
|
1321
|
+
};
|
|
1322
|
+
/** Executes one adapter-free explicit canonical content range read. */
|
|
1323
|
+
var executeMoldeaCliProjectContent = createMoldeaCliProjectContentExecutor();
|
|
1324
|
+
//#endregion
|
|
1325
|
+
//#region src/project-content/page.ts
|
|
1326
|
+
/** Creates one candidate content result ending at a Unicode scalar boundary. */
|
|
1327
|
+
var createCandidate = (input, scalars, scalarEnd, snapshotDigest) => {
|
|
1328
|
+
const content = scalars.slice(0, scalarEnd).join("");
|
|
1329
|
+
const byteEnd = input.page.byteStart + Buffer.byteLength(content, "utf8");
|
|
1330
|
+
const isComplete = byteEnd === input.page.totalBytes;
|
|
1331
|
+
return {
|
|
1332
|
+
asset: {
|
|
1333
|
+
contentIdentity: input.page.contentIdentity,
|
|
1334
|
+
path: input.page.path,
|
|
1335
|
+
totalBytes: input.page.totalBytes
|
|
1336
|
+
},
|
|
1337
|
+
chunk: {
|
|
1338
|
+
byteEnd,
|
|
1339
|
+
byteStart: input.page.byteStart,
|
|
1340
|
+
content
|
|
1341
|
+
},
|
|
1342
|
+
cursor: isComplete ? null : encodeMoldeaCliCursor("content", { path: input.page.path }, snapshotDigest, `byte:${byteEnd}`, `byte:${byteEnd}`),
|
|
1343
|
+
snapshotDigest
|
|
1344
|
+
};
|
|
1345
|
+
};
|
|
1346
|
+
/** Creates the stable identity shared by every page of one canonical file snapshot. */
|
|
1347
|
+
var createSnapshotDigest = (input) => calculateMoldeaCliJsonDigest({
|
|
1348
|
+
contentIdentity: input.page.contentIdentity,
|
|
1349
|
+
path: input.page.path,
|
|
1350
|
+
totalBytes: input.page.totalBytes
|
|
1351
|
+
});
|
|
1352
|
+
/** Selects the largest Unicode-safe content prefix within the exact output budget. */
|
|
1353
|
+
var createMoldeaCliContentPage = (input) => {
|
|
1354
|
+
const snapshotDigest = createSnapshotDigest(input);
|
|
1355
|
+
const cursorState = input.cursor === null ? null : decodeMoldeaCliCursor({
|
|
1356
|
+
command: "content",
|
|
1357
|
+
cursor: input.cursor,
|
|
1358
|
+
filters: { path: input.page.path },
|
|
1359
|
+
snapshotDigest
|
|
1360
|
+
});
|
|
1361
|
+
const expectedSourceCursor = `byte:${input.page.byteStart}`;
|
|
1362
|
+
if (cursorState === null && input.page.byteStart !== 0 || cursorState !== null && cursorState.sourceCursor !== expectedSourceCursor) throw new MoldeaCliOutputPageException("CURSOR_INVALID");
|
|
1363
|
+
const scalars = Array.from(input.page.content);
|
|
1364
|
+
const emptyResult = createCandidate(input, scalars, 0, snapshotDigest);
|
|
1365
|
+
if (scalars.length === 0) {
|
|
1366
|
+
if (!input.page.isComplete || input.measure(emptyResult) > input.maxOutputBytes) throw new MoldeaCliOutputPageException("OUTPUT_BUDGET_TOO_SMALL");
|
|
1367
|
+
return Object.freeze({
|
|
1368
|
+
...emptyResult,
|
|
1369
|
+
asset: Object.freeze(emptyResult.asset),
|
|
1370
|
+
chunk: Object.freeze(emptyResult.chunk)
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
let lower = 1;
|
|
1374
|
+
let upper = scalars.length;
|
|
1375
|
+
let selected = null;
|
|
1376
|
+
while (lower <= upper) {
|
|
1377
|
+
const scalarEnd = lower + Math.floor((upper - lower) / 2);
|
|
1378
|
+
const candidate = createCandidate(input, scalars, scalarEnd, snapshotDigest);
|
|
1379
|
+
if (input.measure(candidate) <= input.maxOutputBytes) {
|
|
1380
|
+
selected = candidate;
|
|
1381
|
+
lower = scalarEnd + 1;
|
|
1382
|
+
} else upper = scalarEnd - 1;
|
|
1383
|
+
}
|
|
1384
|
+
if (selected === null) throw new MoldeaCliOutputPageException("OUTPUT_BUDGET_TOO_SMALL");
|
|
1385
|
+
return Object.freeze({
|
|
1386
|
+
...selected,
|
|
1387
|
+
asset: Object.freeze(selected.asset),
|
|
1388
|
+
chunk: Object.freeze(selected.chunk)
|
|
1389
|
+
});
|
|
1390
|
+
};
|
|
1391
|
+
//#endregion
|
|
1392
|
+
//#region src/project-scope/constants.ts
|
|
1393
|
+
var MOLDEA_MANIFEST_PATH = parseRepositoryPath("/moldea/moldea.yaml");
|
|
1394
|
+
//#endregion
|
|
1395
|
+
//#region src/project-scope/exception.ts
|
|
1396
|
+
/** Represents invalid NUL-delimited changed-path input owned by the CLI. */
|
|
1397
|
+
var MoldeaCliProjectScopeException = class extends Error {
|
|
1398
|
+
code;
|
|
1399
|
+
/** Creates one scope-input failure with a stable public code. */
|
|
1400
|
+
constructor(code) {
|
|
1401
|
+
super(code);
|
|
1402
|
+
this.code = code;
|
|
1403
|
+
this.name = "MoldeaCliProjectScopeException";
|
|
1404
|
+
}
|
|
1405
|
+
};
|
|
1406
|
+
//#endregion
|
|
1407
|
+
//#region src/project-scope/paths.ts
|
|
1408
|
+
/**
|
|
1409
|
+
* Parses bounded NUL-delimited UTF-8 changed paths without shell interpretation.
|
|
1410
|
+
* @param input Exact stdin bytes supplied to the scope command.
|
|
1411
|
+
* @param maxEntries Maximum changed-path records accepted by the operation.
|
|
1412
|
+
* @returns Detached path strings in supplied order for Core validation and normalization.
|
|
1413
|
+
* @throws
|
|
1414
|
+
* - PATH_INPUT_INVALID: The NUL-delimited changed-path input is invalid.
|
|
1415
|
+
*/
|
|
1416
|
+
var parseMoldeaCliScopePathBytes = (input, maxEntries) => {
|
|
1417
|
+
if (input.byteLength === 0) return Object.freeze([]);
|
|
1418
|
+
let text;
|
|
1419
|
+
try {
|
|
1420
|
+
text = new TextDecoder("utf-8", { fatal: true }).decode(input);
|
|
1421
|
+
} catch {
|
|
1422
|
+
throw new MoldeaCliProjectScopeException("PATH_INPUT_INVALID");
|
|
1423
|
+
}
|
|
1424
|
+
if (!text.endsWith("\0")) throw new MoldeaCliProjectScopeException("PATH_INPUT_INVALID");
|
|
1425
|
+
const paths = text.slice(0, -1).split("\0");
|
|
1426
|
+
if (paths.length > maxEntries || paths.some((path) => path.length === 0)) throw new MoldeaCliProjectScopeException("PATH_INPUT_INVALID");
|
|
1427
|
+
return Object.freeze(paths);
|
|
1428
|
+
};
|
|
1429
|
+
//#endregion
|
|
1430
|
+
//#region src/project-scope/executor.ts
|
|
1431
|
+
/** Reads the complete manifest within its explicit small-file resource bound. */
|
|
1432
|
+
var readBoundedManifest = async (input) => {
|
|
1433
|
+
const operationOptions = input.signal === void 0 ? void 0 : { signal: input.signal };
|
|
1434
|
+
const entry = await input.repository.getEntry(MOLDEA_MANIFEST_PATH, operationOptions);
|
|
1435
|
+
if (entry === null) throw new RepositorySourceException({
|
|
1436
|
+
code: "ENTRY_NOT_FOUND",
|
|
1437
|
+
operation: "read-file-page",
|
|
1438
|
+
path: MOLDEA_MANIFEST_PATH,
|
|
1439
|
+
retryable: false
|
|
1440
|
+
});
|
|
1441
|
+
if (entry.type !== "file" || entry.byteLength === null) throw new RepositorySourceException({
|
|
1442
|
+
code: "ENTRY_NOT_FILE",
|
|
1443
|
+
operation: "read-file-page",
|
|
1444
|
+
path: MOLDEA_MANIFEST_PATH,
|
|
1445
|
+
retryable: false
|
|
1446
|
+
});
|
|
1447
|
+
const maxBytes = Math.min(input.resourceLimits.maxManifestBytes, input.resourceLimits.maxTotalBytes);
|
|
1448
|
+
if (entry.byteLength > maxBytes) throw new RepositorySourceException({
|
|
1449
|
+
code: "RESOURCE_LIMIT_EXCEEDED",
|
|
1450
|
+
operation: "read-file-page",
|
|
1451
|
+
path: MOLDEA_MANIFEST_PATH,
|
|
1452
|
+
retryable: false
|
|
1453
|
+
});
|
|
1454
|
+
const chunks = [];
|
|
1455
|
+
let byteLength = 0;
|
|
1456
|
+
let nextOffset = 0;
|
|
1457
|
+
let isComplete = false;
|
|
1458
|
+
while (!isComplete) {
|
|
1459
|
+
const page = await input.repository.readFilePage(MOLDEA_MANIFEST_PATH, {
|
|
1460
|
+
maxBytes: Math.max(1, entry.byteLength - byteLength),
|
|
1461
|
+
offset: nextOffset,
|
|
1462
|
+
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
1463
|
+
});
|
|
1464
|
+
if (page.snapshot.id !== input.repository.snapshot.id || page.offset !== nextOffset || page.totalBytes !== entry.byteLength || page.bytes.byteLength > entry.byteLength - byteLength || page.bytes.byteLength === 0 && !page.isComplete || !page.isComplete && page.nextOffset !== page.offset + page.bytes.byteLength) throw new RepositorySourceException({
|
|
1465
|
+
code: "INVALID_SOURCE_DATA",
|
|
1466
|
+
operation: "read-file-page",
|
|
1467
|
+
path: MOLDEA_MANIFEST_PATH,
|
|
1468
|
+
retryable: false
|
|
1469
|
+
});
|
|
1470
|
+
chunks.push(page.bytes);
|
|
1471
|
+
byteLength += page.bytes.byteLength;
|
|
1472
|
+
nextOffset = page.nextOffset ?? byteLength;
|
|
1473
|
+
isComplete = page.isComplete;
|
|
1474
|
+
}
|
|
1475
|
+
if (byteLength !== entry.byteLength) throw new RepositorySourceException({
|
|
1476
|
+
code: "PROVIDER_INCOMPLETE",
|
|
1477
|
+
operation: "read-file-page",
|
|
1478
|
+
path: MOLDEA_MANIFEST_PATH,
|
|
1479
|
+
retryable: false
|
|
1480
|
+
});
|
|
1481
|
+
const manifestBytes = new Uint8Array(byteLength);
|
|
1482
|
+
let writeOffset = 0;
|
|
1483
|
+
for (const chunk of chunks) {
|
|
1484
|
+
manifestBytes.set(chunk, writeOffset);
|
|
1485
|
+
writeOffset += chunk.byteLength;
|
|
1486
|
+
}
|
|
1487
|
+
return manifestBytes;
|
|
1488
|
+
};
|
|
1489
|
+
/** Creates an adapter-free manifest-only Core scope executor. */
|
|
1490
|
+
var createMoldeaCliProjectScopeExecutor = (coreFactory = createCore) => {
|
|
1491
|
+
return async (input) => {
|
|
1492
|
+
const manifestBytes = await readBoundedManifest(input);
|
|
1493
|
+
const scope = await coreFactory({ limits: Object.freeze({
|
|
1494
|
+
maxDiagnostics: input.resourceLimits.maxDiagnostics,
|
|
1495
|
+
maxEntries: input.resourceLimits.maxEntries,
|
|
1496
|
+
maxEvidence: input.resourceLimits.maxEvidence,
|
|
1497
|
+
maxFileBytes: input.resourceLimits.maxFileBytes,
|
|
1498
|
+
maxManifestBytes: input.resourceLimits.maxManifestBytes,
|
|
1499
|
+
maxTotalBytesRead: input.resourceLimits.maxTotalBytes
|
|
1500
|
+
}) }).matchManifestScope({
|
|
1501
|
+
manifest: {
|
|
1502
|
+
content: manifestBytes,
|
|
1503
|
+
path: MOLDEA_MANIFEST_PATH
|
|
1504
|
+
},
|
|
1505
|
+
paths: input.paths
|
|
1506
|
+
});
|
|
1507
|
+
return Object.freeze({
|
|
1508
|
+
manifestContent: new TextDecoder("utf-8").decode(manifestBytes),
|
|
1509
|
+
scope
|
|
1510
|
+
});
|
|
1511
|
+
};
|
|
1512
|
+
};
|
|
1513
|
+
/** Executes one adapter-free manifest-only changed-path scope match. */
|
|
1514
|
+
var executeMoldeaCliProjectScope = createMoldeaCliProjectScopeExecutor();
|
|
1515
|
+
//#endregion
|
|
1516
|
+
//#region src/project-scope/transformers.ts
|
|
1517
|
+
var compareKeys = (left, right) => left.key < right.key ? -1 : left.key > right.key ? 1 : 0;
|
|
1518
|
+
/** Creates one stable key for a relationship-match projection. */
|
|
1519
|
+
var createMatchKey = (match) => JSON.stringify([
|
|
1520
|
+
"match",
|
|
1521
|
+
match.owner.kind,
|
|
1522
|
+
match.owner.agentId,
|
|
1523
|
+
match.owner.id,
|
|
1524
|
+
match.field,
|
|
1525
|
+
match.declaration.kind === "exact" ? match.declaration.path : match.declaration.pattern,
|
|
1526
|
+
match.inputPath,
|
|
1527
|
+
match.pointer
|
|
1528
|
+
]);
|
|
1529
|
+
/** Projects complete Core scope output into ordered content-free CLI records. */
|
|
1530
|
+
var createMoldeaCliScopeProjection = (execution) => {
|
|
1531
|
+
const records = [...execution.scope.diagnostics.map((diagnostic, index) => createMoldeaCliDiagnosticRecord(diagnostic, index)), ...execution.scope.matches.map((match) => ({
|
|
1532
|
+
key: createMatchKey(match),
|
|
1533
|
+
kind: "match",
|
|
1534
|
+
match
|
|
1535
|
+
}))].sort(compareKeys);
|
|
1536
|
+
const snapshotDigest = calculateMoldeaCliJsonDigest({
|
|
1537
|
+
inputDigest: execution.scope.inputDigest,
|
|
1538
|
+
manifestDigest: execution.scope.manifestDigest,
|
|
1539
|
+
records,
|
|
1540
|
+
valid: execution.scope.valid
|
|
1541
|
+
});
|
|
1542
|
+
return Object.freeze({
|
|
1543
|
+
canonicalBodies: Object.freeze([execution.manifestContent]),
|
|
1544
|
+
counts: Object.freeze({
|
|
1545
|
+
...execution.scope.counts,
|
|
1546
|
+
diagnostics: execution.scope.diagnostics.length
|
|
1547
|
+
}),
|
|
1548
|
+
inputDigest: execution.scope.inputDigest,
|
|
1549
|
+
manifestDigest: execution.scope.manifestDigest,
|
|
1550
|
+
records: Object.freeze(records),
|
|
1551
|
+
relevant: execution.scope.relevant,
|
|
1552
|
+
snapshotDigest,
|
|
1553
|
+
valid: execution.scope.valid
|
|
1554
|
+
});
|
|
1555
|
+
};
|
|
1556
|
+
//#endregion
|
|
2909
1557
|
//#region src/repository-content-transformation-guard/exception.ts
|
|
2910
1558
|
/** Identifies a guarded logical file whose working-tree bytes are unsafe to inspect. */
|
|
2911
1559
|
var GitContentTransformUnsupportedException = class extends RepositorySourceException {
|
|
@@ -2913,7 +1561,7 @@ var GitContentTransformUnsupportedException = class extends RepositorySourceExce
|
|
|
2913
1561
|
constructor(path) {
|
|
2914
1562
|
super({
|
|
2915
1563
|
code: "SOURCE_UNAVAILABLE",
|
|
2916
|
-
operation: "read-file",
|
|
1564
|
+
operation: "read-file-page",
|
|
2917
1565
|
path,
|
|
2918
1566
|
retryable: false
|
|
2919
1567
|
});
|
|
@@ -2928,7 +1576,7 @@ var throwIfAborted$1 = (signal, path) => {
|
|
|
2928
1576
|
throw new RepositorySourceException({
|
|
2929
1577
|
cause: signal.reason,
|
|
2930
1578
|
code: "ABORTED",
|
|
2931
|
-
operation: "read-file",
|
|
1579
|
+
operation: "read-file-page",
|
|
2932
1580
|
path,
|
|
2933
1581
|
retryable: false
|
|
2934
1582
|
});
|
|
@@ -2936,16 +1584,22 @@ var throwIfAborted$1 = (signal, path) => {
|
|
|
2936
1584
|
/** Creates the common failure for contradictory underlying lookup data. */
|
|
2937
1585
|
var createInvalidSourceException = (path) => new RepositorySourceException({
|
|
2938
1586
|
code: "INVALID_SOURCE_DATA",
|
|
2939
|
-
operation: "read-file",
|
|
1587
|
+
operation: "read-file-page",
|
|
2940
1588
|
path,
|
|
2941
1589
|
retryable: false
|
|
2942
1590
|
});
|
|
2943
1591
|
var GitContentTransformationGuardRepositoryReader = class {
|
|
1592
|
+
snapshot;
|
|
2944
1593
|
#guardedPaths;
|
|
2945
1594
|
#reader;
|
|
2946
1595
|
constructor(reader, guardedPaths) {
|
|
2947
1596
|
this.#reader = reader;
|
|
2948
1597
|
this.#guardedPaths = guardedPaths;
|
|
1598
|
+
this.snapshot = reader.snapshot;
|
|
1599
|
+
}
|
|
1600
|
+
/** Creates a bounded comparison from this guarded logical snapshot. */
|
|
1601
|
+
compare(candidate, options) {
|
|
1602
|
+
return createRepositoryComparison(this, candidate, options);
|
|
2949
1603
|
}
|
|
2950
1604
|
/**
|
|
2951
1605
|
* Looks up an entry without changing the underlying logical inventory.
|
|
@@ -2980,14 +1634,14 @@ var GitContentTransformationGuardRepositoryReader = class {
|
|
|
2980
1634
|
* - RESOURCE_LIMIT_EXCEEDED: A repository reading resource limit was exceeded.
|
|
2981
1635
|
* - ABORTED: The repository operation was aborted.
|
|
2982
1636
|
*/
|
|
2983
|
-
async
|
|
1637
|
+
async readFilePage(path, options) {
|
|
2984
1638
|
const parsedPath = parseRepositoryPath(path);
|
|
2985
|
-
if (!this.#guardedPaths.has(parsedPath)) return this.#reader.
|
|
1639
|
+
if (!this.#guardedPaths.has(parsedPath)) return this.#reader.readFilePage(parsedPath, options);
|
|
2986
1640
|
throwIfAborted$1(options?.signal, parsedPath);
|
|
2987
1641
|
const entry = await this.#reader.getEntry(parsedPath, options);
|
|
2988
1642
|
throwIfAborted$1(options?.signal, parsedPath);
|
|
2989
1643
|
if (entry !== null && (entry.path !== parsedPath || entry.type !== "file" && entry.type !== "directory" && entry.type !== "symlink")) throw createInvalidSourceException(parsedPath);
|
|
2990
|
-
if (entry?.type !== "file") return this.#reader.
|
|
1644
|
+
if (entry?.type !== "file") return this.#reader.readFilePage(parsedPath, options);
|
|
2991
1645
|
throw new GitContentTransformUnsupportedException(parsedPath);
|
|
2992
1646
|
}
|
|
2993
1647
|
/**
|
|
@@ -3005,8 +1659,8 @@ var GitContentTransformationGuardRepositoryReader = class {
|
|
|
3005
1659
|
* - RESOURCE_LIMIT_EXCEEDED: A repository reading resource limit was exceeded.
|
|
3006
1660
|
* - ABORTED: The repository operation was aborted.
|
|
3007
1661
|
*/
|
|
3008
|
-
|
|
3009
|
-
return this.#reader.
|
|
1662
|
+
listEntriesPage(options) {
|
|
1663
|
+
return this.#reader.listEntriesPage(options);
|
|
3010
1664
|
}
|
|
3011
1665
|
};
|
|
3012
1666
|
/**
|
|
@@ -3040,7 +1694,9 @@ var REPOSITORY_SOURCE_ERROR_MESSAGES = Object.freeze({
|
|
|
3040
1694
|
ENTRY_NOT_DIRECTORY: "The requested repository entry is not a directory.",
|
|
3041
1695
|
ENTRY_NOT_FILE: "The requested repository entry is not a file.",
|
|
3042
1696
|
ENTRY_NOT_FOUND: "The requested repository entry was not found.",
|
|
1697
|
+
INVALID_PAGE_REQUEST: "The repository page request is invalid.",
|
|
3043
1698
|
INVALID_SOURCE_DATA: "The repository source returned invalid data.",
|
|
1699
|
+
PROVIDER_INCOMPLETE: "The repository provider could not expose a complete result.",
|
|
3044
1700
|
RESOURCE_LIMIT_EXCEEDED: "A repository reading resource limit was exceeded.",
|
|
3045
1701
|
SNAPSHOT_CHANGED: "The repository snapshot changed during the operation.",
|
|
3046
1702
|
SOURCE_UNAVAILABLE: "The repository source is unavailable."
|
|
@@ -3054,6 +1710,7 @@ var CORE_CONFIGURATION_ERROR_MESSAGES = Object.freeze({
|
|
|
3054
1710
|
var CORE_OPERATION_ERROR_MESSAGES = Object.freeze({
|
|
3055
1711
|
ABORTED: "The Core operation was aborted.",
|
|
3056
1712
|
ADAPTER_EXECUTION_FAILED: "A runtime adapter failed during inspection.",
|
|
1713
|
+
CONTENT_INVALID: "The requested canonical content is invalid.",
|
|
3057
1714
|
INVALID_ARGUMENT: "The Core operation received an invalid argument.",
|
|
3058
1715
|
RESOURCE_LIMIT_EXCEEDED: "A Core resource limit was exceeded."
|
|
3059
1716
|
});
|
|
@@ -3076,6 +1733,7 @@ var createCoreErrorDetails = (error) => {
|
|
|
3076
1733
|
* @returns A complete immutable operational error without causes or private host data.
|
|
3077
1734
|
*/
|
|
3078
1735
|
var mapMoldeaCliOperationalError = (error) => {
|
|
1736
|
+
if (error instanceof MoldeaCliOutputPageException || error instanceof MoldeaCliProjectContentException || error instanceof MoldeaCliProjectScopeException) return createMoldeaCliOwnedError(error.code);
|
|
3079
1737
|
if (error instanceof GitContentTransformUnsupportedException) return Object.freeze({
|
|
3080
1738
|
...createMoldeaCliOwnedError("GIT_CONTENT_TRANSFORM_UNSUPPORTED"),
|
|
3081
1739
|
path: isRepositoryPath(error.path) ? error.path : null
|
|
@@ -4194,12 +2852,14 @@ var isProbeFailure = (result) => !Array.isArray(result);
|
|
|
4194
2852
|
*/
|
|
4195
2853
|
var createGitInventoryProbe = (processExecutor = executeGitStreamingProcess, ownershipFilter = createGitInventoryOwnershipFilter(createGitInventoryBoundaryInspector(processExecutor)), entryTypeNormalizer = createGitInventoryEntryTypeNormalizer(inspectGitInventoryEntry, createGitSymlinkConfigurationResolver(processExecutor)), contentTransformationClassifier = createGitContentTransformationClassifier(processExecutor), logicalPathNormalizer = normalizeGitInventoryLogicalPaths) => async (input) => {
|
|
4196
2854
|
if (input.signal?.aborted) return createProbeFailure("GIT_OPERATION_ABORTED");
|
|
2855
|
+
const selectionPathspecs = (input.selectionPaths ?? []).map((selectionPath) => `:(top,literal)${selectionPath.slice(1)}`);
|
|
4197
2856
|
const trackedParser = createTrackedGitInventoryParser(input.maxEntries);
|
|
4198
2857
|
const trackedProcessResult = await processExecutor({
|
|
4199
2858
|
arguments: [
|
|
4200
2859
|
"-C",
|
|
4201
2860
|
input.repositoryRoot,
|
|
4202
|
-
...GIT_TRACKED_INVENTORY_ARGUMENTS
|
|
2861
|
+
...GIT_TRACKED_INVENTORY_ARGUMENTS,
|
|
2862
|
+
...selectionPathspecs
|
|
4203
2863
|
],
|
|
4204
2864
|
consumeStdout: (chunk) => trackedParser.consume(chunk),
|
|
4205
2865
|
maxStderrBytes: MAX_GIT_PROCESS_DIAGNOSTIC_BYTES,
|
|
@@ -4215,7 +2875,8 @@ var createGitInventoryProbe = (processExecutor = executeGitStreamingProcess, own
|
|
|
4215
2875
|
arguments: [
|
|
4216
2876
|
"-C",
|
|
4217
2877
|
input.repositoryRoot,
|
|
4218
|
-
...GIT_UNTRACKED_INVENTORY_ARGUMENTS
|
|
2878
|
+
...GIT_UNTRACKED_INVENTORY_ARGUMENTS,
|
|
2879
|
+
...selectionPathspecs
|
|
4219
2880
|
],
|
|
4220
2881
|
consumeStdout: (chunk) => untrackedParser.consume(chunk),
|
|
4221
2882
|
maxStderrBytes: MAX_GIT_PROCESS_DIAGNOSTIC_BYTES,
|
|
@@ -4308,16 +2969,24 @@ var validateOverlayEntry = (entry, operation, path) => {
|
|
|
4308
2969
|
var overlayEntry = (entry, operation, path) => {
|
|
4309
2970
|
validateOverlayEntry(entry, operation, path);
|
|
4310
2971
|
return Object.freeze({
|
|
2972
|
+
byteLength: null,
|
|
2973
|
+
contentIdentity: null,
|
|
4311
2974
|
path,
|
|
4312
2975
|
type: "symlink"
|
|
4313
2976
|
});
|
|
4314
2977
|
};
|
|
4315
2978
|
var GitSymlinkOverlayRepositoryReader = class {
|
|
2979
|
+
snapshot;
|
|
4316
2980
|
#overlayPaths;
|
|
4317
2981
|
#reader;
|
|
4318
2982
|
constructor(reader, overlayPaths) {
|
|
4319
2983
|
this.#reader = reader;
|
|
4320
2984
|
this.#overlayPaths = overlayPaths;
|
|
2985
|
+
this.snapshot = reader.snapshot;
|
|
2986
|
+
}
|
|
2987
|
+
/** Creates a bounded comparison from this logical overlay snapshot. */
|
|
2988
|
+
compare(candidate, options) {
|
|
2989
|
+
return createRepositoryComparison(this, candidate, options);
|
|
4321
2990
|
}
|
|
4322
2991
|
/**
|
|
4323
2992
|
* Looks up an entry while replacing configured host files with logical symlinks.
|
|
@@ -4354,15 +3023,15 @@ var GitSymlinkOverlayRepositoryReader = class {
|
|
|
4354
3023
|
* - RESOURCE_LIMIT_EXCEEDED: A repository reading resource limit was exceeded.
|
|
4355
3024
|
* - ABORTED: The repository operation was aborted.
|
|
4356
3025
|
*/
|
|
4357
|
-
async
|
|
3026
|
+
async readFilePage(path, options) {
|
|
4358
3027
|
const parsedPath = parseRepositoryPath(path);
|
|
4359
|
-
if (!this.#overlayPaths.has(parsedPath)) return this.#reader.
|
|
4360
|
-
throwIfAborted(options
|
|
4361
|
-
validateOverlayEntry(await this.#reader.getEntry(parsedPath, options), "read-file", parsedPath);
|
|
4362
|
-
throwIfAborted(options
|
|
3028
|
+
if (!this.#overlayPaths.has(parsedPath)) return this.#reader.readFilePage(parsedPath, options);
|
|
3029
|
+
throwIfAborted(options.signal, "read-file-page", parsedPath);
|
|
3030
|
+
validateOverlayEntry(await this.#reader.getEntry(parsedPath, options), "read-file-page", parsedPath);
|
|
3031
|
+
throwIfAborted(options.signal, "read-file-page", parsedPath);
|
|
4363
3032
|
throw new RepositorySourceException({
|
|
4364
3033
|
code: "ENTRY_NOT_FILE",
|
|
4365
|
-
operation: "read-file",
|
|
3034
|
+
operation: "read-file-page",
|
|
4366
3035
|
path: parsedPath,
|
|
4367
3036
|
retryable: false
|
|
4368
3037
|
});
|
|
@@ -4382,32 +3051,28 @@ var GitSymlinkOverlayRepositoryReader = class {
|
|
|
4382
3051
|
* - RESOURCE_LIMIT_EXCEEDED: A repository reading resource limit was exceeded.
|
|
4383
3052
|
* - ABORTED: The repository operation was aborted.
|
|
4384
3053
|
*/
|
|
4385
|
-
async
|
|
4386
|
-
const prefix = options
|
|
3054
|
+
async listEntriesPage(options) {
|
|
3055
|
+
const prefix = options.prefix === void 0 ? REPOSITORY_ROOT : parseRepositoryPath(options.prefix);
|
|
4387
3056
|
if (this.#overlayPaths.has(prefix)) {
|
|
4388
|
-
throwIfAborted(options
|
|
4389
|
-
const operationOptions = options
|
|
4390
|
-
validateOverlayEntry(await this.#reader.getEntry(prefix, operationOptions), "list-entries", prefix);
|
|
4391
|
-
throwIfAborted(options
|
|
3057
|
+
throwIfAborted(options.signal, "list-entries-page", prefix);
|
|
3058
|
+
const operationOptions = options.signal === void 0 ? void 0 : { signal: options.signal };
|
|
3059
|
+
validateOverlayEntry(await this.#reader.getEntry(prefix, operationOptions), "list-entries-page", prefix);
|
|
3060
|
+
throwIfAborted(options.signal, "list-entries-page", prefix);
|
|
4392
3061
|
throw new RepositorySourceException({
|
|
4393
3062
|
code: "ENTRY_NOT_DIRECTORY",
|
|
4394
|
-
operation: "list-entries",
|
|
3063
|
+
operation: "list-entries-page",
|
|
4395
3064
|
path: prefix,
|
|
4396
3065
|
retryable: false
|
|
4397
3066
|
});
|
|
4398
3067
|
}
|
|
4399
|
-
const
|
|
4400
|
-
const
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
yield overlayEntry(entry, "list-entries", entry.path);
|
|
4408
|
-
}
|
|
4409
|
-
const missingOverlayPath = unmatchedOverlayPaths.values().next().value;
|
|
4410
|
-
if (missingOverlayPath !== void 0) throw createInvalidOverlayException("list-entries", missingOverlayPath);
|
|
3068
|
+
const page = await this.#reader.listEntriesPage(options);
|
|
3069
|
+
const entries = page.entries.map((entry) => this.#overlayPaths.has(entry.path) ? overlayEntry(entry, "list-entries-page", entry.path) : entry);
|
|
3070
|
+
return Object.freeze({
|
|
3071
|
+
entries: Object.freeze(entries),
|
|
3072
|
+
isComplete: page.isComplete,
|
|
3073
|
+
nextCursor: page.nextCursor,
|
|
3074
|
+
snapshot: this.snapshot
|
|
3075
|
+
});
|
|
4411
3076
|
}
|
|
4412
3077
|
};
|
|
4413
3078
|
/**
|
|
@@ -4455,8 +3120,10 @@ var createWorkingTreeRepositoryReaderFactory = (filesystemReaderFactory = create
|
|
|
4455
3120
|
return contentTransformationGuardFactory(symlinkOverlayFactory(await filesystemReaderFactory({
|
|
4456
3121
|
limits: Object.freeze({
|
|
4457
3122
|
maxCachedBytes: input.resourceLimits.maxTotalBytes,
|
|
3123
|
+
maxDirectoryEntries: input.resourceLimits.maxEntries,
|
|
4458
3124
|
maxEntries: input.resourceLimits.maxEntries,
|
|
4459
|
-
|
|
3125
|
+
maxPageEntries: Math.min(4096, input.resourceLimits.maxEntries),
|
|
3126
|
+
maxReadBytes: input.resourceLimits.maxFileBytes
|
|
4460
3127
|
}),
|
|
4461
3128
|
rootDirectory: input.repositoryRoot,
|
|
4462
3129
|
selection: Object.freeze({
|
|
@@ -4506,6 +3173,7 @@ var createWorkingTreeSnapshotExecutor = (identityInspector = inspectGitWorkingTr
|
|
|
4506
3173
|
maxEntries: resourceLimits.maxEntries,
|
|
4507
3174
|
maxMetadataBytes: resourceLimits.maxTotalBytes,
|
|
4508
3175
|
repositoryRoot,
|
|
3176
|
+
...input.selectionPaths === void 0 ? {} : { selectionPaths: input.selectionPaths },
|
|
4509
3177
|
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
4510
3178
|
});
|
|
4511
3179
|
return result.kind === "failed" ? createSnapshotFailure(result.errorCode) : result;
|
|
@@ -4564,27 +3232,22 @@ var createWorkingTreeSnapshotExecutor = (identityInspector = inspectGitWorkingTr
|
|
|
4564
3232
|
var executeWorkingTreeSnapshot = createWorkingTreeSnapshotExecutor();
|
|
4565
3233
|
//#endregion
|
|
4566
3234
|
//#region src/cli-execution/results.ts
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
3235
|
+
var measureOutput = (output) => Buffer.byteLength(output, "utf8");
|
|
3236
|
+
/** Measures a paged result without repeatedly serializing its accumulated JSON records. */
|
|
3237
|
+
var measurePagedOutput = (page, serializedRecordsUtf8Bytes, isJson, formatJson, formatHuman) => {
|
|
3238
|
+
if (!isJson) return measureOutput(formatHuman(page));
|
|
3239
|
+
return measureOutput(formatJson(Object.freeze({
|
|
3240
|
+
cursor: page.cursor,
|
|
3241
|
+
records: Object.freeze([])
|
|
3242
|
+
}))) - 2 + serializedRecordsUtf8Bytes;
|
|
3243
|
+
};
|
|
3244
|
+
/** Creates one process-neutral result for a valid installed composition. */
|
|
4574
3245
|
var createMoldeaCliCompositionExecutionResult = (result, cliVersion, isJson) => Object.freeze({
|
|
4575
3246
|
exitCode: MOLDEA_CLI_EXIT_CODES.Success,
|
|
4576
3247
|
stderr: "",
|
|
4577
3248
|
stdout: isJson ? formatMoldeaCliJsonCompositionResult(result, cliVersion) : formatMoldeaCliHumanCompositionResult(result, cliVersion)
|
|
4578
3249
|
});
|
|
4579
|
-
/**
|
|
4580
|
-
* Creates one safe process-neutral error result in the requested output mode.
|
|
4581
|
-
* @param error The complete safe operational error.
|
|
4582
|
-
* @param command The resolved command, or null when resolution failed.
|
|
4583
|
-
* @param cliVersion The installed CLI package version.
|
|
4584
|
-
* @param isJson Whether machine-readable output was requested.
|
|
4585
|
-
* @param exitCode The handled process exit code.
|
|
4586
|
-
* @returns The complete immutable process output.
|
|
4587
|
-
*/
|
|
3250
|
+
/** Creates one safe process-neutral error result in the requested output mode. */
|
|
4588
3251
|
var createMoldeaCliErrorResult = (error, command, cliVersion, isJson, exitCode) => Object.freeze(isJson ? {
|
|
4589
3252
|
exitCode,
|
|
4590
3253
|
stderr: "",
|
|
@@ -4595,75 +3258,240 @@ var createMoldeaCliErrorResult = (error, command, cliVersion, isJson, exitCode)
|
|
|
4595
3258
|
stdout: ""
|
|
4596
3259
|
});
|
|
4597
3260
|
/**
|
|
4598
|
-
* Creates one process-neutral result for a completed validate command.
|
|
4599
|
-
* @
|
|
4600
|
-
*
|
|
4601
|
-
*
|
|
4602
|
-
*
|
|
4603
|
-
*/
|
|
4604
|
-
var createMoldeaCliValidateExecutionResult = (inspection, cliVersion, isJson) => {
|
|
4605
|
-
const
|
|
4606
|
-
const
|
|
3261
|
+
* Creates one bounded process-neutral result for a completed validate command.
|
|
3262
|
+
* @throws
|
|
3263
|
+
* - CURSOR_INVALID: The continuation cursor is invalid for this request.
|
|
3264
|
+
* - CURSOR_SNAPSHOT_CHANGED: The continuation cursor belongs to a different repository snapshot.
|
|
3265
|
+
* - OUTPUT_BUDGET_TOO_SMALL: The output byte budget cannot contain the next complete result.
|
|
3266
|
+
*/
|
|
3267
|
+
var createMoldeaCliValidateExecutionResult = (inspection, cliVersion, isJson, cursor, maxOutputBytes) => {
|
|
3268
|
+
const projection = createMoldeaCliValidateProjection(inspection);
|
|
3269
|
+
const createResult = (page) => ({
|
|
3270
|
+
diagnosticCount: projection.diagnostics.length,
|
|
3271
|
+
formatVersion: projection.formatVersion,
|
|
3272
|
+
page,
|
|
3273
|
+
snapshotDigest: projection.snapshotDigest,
|
|
3274
|
+
source: projection.source,
|
|
3275
|
+
valid: projection.valid
|
|
3276
|
+
});
|
|
3277
|
+
const page = createMoldeaCliOutputPage({
|
|
3278
|
+
command: "validate",
|
|
3279
|
+
cursor,
|
|
3280
|
+
filters: {},
|
|
3281
|
+
maxOutputBytes,
|
|
3282
|
+
measure: (candidate, serializedRecordsUtf8Bytes) => measurePagedOutput(candidate, serializedRecordsUtf8Bytes, isJson, (page) => formatMoldeaCliJsonValidateResult(createResult(page), cliVersion), (page) => formatMoldeaCliHumanValidateResult(createResult(page))),
|
|
3283
|
+
records: projection.diagnostics,
|
|
3284
|
+
snapshotDigest: projection.snapshotDigest
|
|
3285
|
+
});
|
|
3286
|
+
const result = Object.freeze(createResult(page));
|
|
3287
|
+
assertMoldeaCliJsonResultIsContentFree(result);
|
|
4607
3288
|
return Object.freeze({
|
|
4608
|
-
exitCode,
|
|
3289
|
+
exitCode: result.valid ? MOLDEA_CLI_EXIT_CODES.Success : MOLDEA_CLI_EXIT_CODES.StructuralInvalid,
|
|
4609
3290
|
stderr: "",
|
|
4610
3291
|
stdout: isJson ? formatMoldeaCliJsonValidateResult(result, cliVersion) : formatMoldeaCliHumanValidateResult(result)
|
|
4611
3292
|
});
|
|
4612
3293
|
};
|
|
4613
3294
|
/**
|
|
4614
|
-
* Creates one
|
|
4615
|
-
* @
|
|
4616
|
-
*
|
|
4617
|
-
*
|
|
4618
|
-
*
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
const
|
|
3295
|
+
* Creates one bounded content-free result for a completed inspect command.
|
|
3296
|
+
* @throws
|
|
3297
|
+
* - CURSOR_INVALID: The continuation cursor is invalid for this request.
|
|
3298
|
+
* - CURSOR_SNAPSHOT_CHANGED: The continuation cursor belongs to a different repository snapshot.
|
|
3299
|
+
* - OUTPUT_BUDGET_TOO_SMALL: The output byte budget cannot contain the next complete result.
|
|
3300
|
+
*/
|
|
3301
|
+
var createMoldeaCliInspectExecutionResult = (inspection, cliVersion, isJson, cursor, maxOutputBytes) => {
|
|
3302
|
+
const projection = createMoldeaCliInspectProjection(inspection);
|
|
3303
|
+
const createResult = (page) => ({
|
|
3304
|
+
counts: projection.counts,
|
|
3305
|
+
formatVersion: projection.formatVersion,
|
|
3306
|
+
page,
|
|
3307
|
+
project: projection.project,
|
|
3308
|
+
snapshotDigest: projection.snapshotDigest,
|
|
3309
|
+
source: projection.source,
|
|
3310
|
+
valid: projection.valid,
|
|
3311
|
+
view: projection.view
|
|
3312
|
+
});
|
|
3313
|
+
const page = createMoldeaCliOutputPage({
|
|
3314
|
+
command: "inspect",
|
|
3315
|
+
cursor,
|
|
3316
|
+
filters: {},
|
|
3317
|
+
maxOutputBytes,
|
|
3318
|
+
measure: (candidate, serializedRecordsUtf8Bytes) => measurePagedOutput(candidate, serializedRecordsUtf8Bytes, isJson, (page) => formatMoldeaCliJsonInspectResult(createResult(page), cliVersion), (page) => formatMoldeaCliHumanInspectResult(createResult(page))),
|
|
3319
|
+
records: projection.records,
|
|
3320
|
+
sourceCursorForRecord: projection.getSourceCursor,
|
|
3321
|
+
snapshotDigest: projection.snapshotDigest
|
|
3322
|
+
});
|
|
3323
|
+
const result = Object.freeze(createResult(page));
|
|
3324
|
+
assertMoldeaCliJsonResultIsContentFree(result);
|
|
4623
3325
|
return Object.freeze({
|
|
4624
3326
|
exitCode: inspection.valid ? MOLDEA_CLI_EXIT_CODES.Success : MOLDEA_CLI_EXIT_CODES.StructuralInvalid,
|
|
4625
3327
|
stderr: "",
|
|
4626
3328
|
stdout: isJson ? formatMoldeaCliJsonInspectResult(result, cliVersion) : formatMoldeaCliHumanInspectResult(result)
|
|
4627
3329
|
});
|
|
4628
3330
|
};
|
|
3331
|
+
/**
|
|
3332
|
+
* Creates one bounded content-free result for changed-path relationship scope.
|
|
3333
|
+
* @throws
|
|
3334
|
+
* - CURSOR_INVALID: The continuation cursor is invalid for this request.
|
|
3335
|
+
* - CURSOR_SNAPSHOT_CHANGED: The continuation cursor belongs to a different repository snapshot.
|
|
3336
|
+
* - OUTPUT_BUDGET_TOO_SMALL: The output byte budget cannot contain the next complete result.
|
|
3337
|
+
*/
|
|
3338
|
+
var createMoldeaCliScopeExecutionResult = (execution, cliVersion, isJson, cursor, maxOutputBytes) => {
|
|
3339
|
+
const projection = createMoldeaCliScopeProjection(execution);
|
|
3340
|
+
const createResult = (page) => ({
|
|
3341
|
+
counts: projection.counts,
|
|
3342
|
+
inputDigest: projection.inputDigest,
|
|
3343
|
+
manifestDigest: projection.manifestDigest,
|
|
3344
|
+
page,
|
|
3345
|
+
relevant: projection.relevant,
|
|
3346
|
+
snapshotDigest: projection.snapshotDigest,
|
|
3347
|
+
source: MOLDEA_CLI_GIT_WORKING_TREE_SOURCE,
|
|
3348
|
+
valid: projection.valid
|
|
3349
|
+
});
|
|
3350
|
+
const page = createMoldeaCliOutputPage({
|
|
3351
|
+
command: "scope",
|
|
3352
|
+
cursor,
|
|
3353
|
+
filters: { inputDigest: projection.inputDigest },
|
|
3354
|
+
maxOutputBytes,
|
|
3355
|
+
measure: (candidate, serializedRecordsUtf8Bytes) => measurePagedOutput(candidate, serializedRecordsUtf8Bytes, isJson, (page) => formatMoldeaCliJsonScopeResult(createResult(page), cliVersion), (page) => formatMoldeaCliHumanScopeResult(createResult(page))),
|
|
3356
|
+
records: projection.records,
|
|
3357
|
+
snapshotDigest: projection.snapshotDigest
|
|
3358
|
+
});
|
|
3359
|
+
const result = Object.freeze(createResult(page));
|
|
3360
|
+
assertMoldeaCliJsonResultIsContentFree(result, projection.canonicalBodies);
|
|
3361
|
+
return Object.freeze({
|
|
3362
|
+
exitCode: projection.valid ? MOLDEA_CLI_EXIT_CODES.Success : MOLDEA_CLI_EXIT_CODES.StructuralInvalid,
|
|
3363
|
+
stderr: "",
|
|
3364
|
+
stdout: isJson ? formatMoldeaCliJsonScopeResult(result, cliVersion) : formatMoldeaCliHumanScopeResult(result)
|
|
3365
|
+
});
|
|
3366
|
+
};
|
|
3367
|
+
/**
|
|
3368
|
+
* Creates one bounded Unicode-safe explicit canonical content result.
|
|
3369
|
+
* @throws
|
|
3370
|
+
* - CURSOR_INVALID: The continuation cursor is invalid for this request.
|
|
3371
|
+
* - CURSOR_SNAPSHOT_CHANGED: The continuation cursor belongs to a different repository snapshot.
|
|
3372
|
+
* - OUTPUT_BUDGET_TOO_SMALL: The output byte budget cannot contain the next complete result.
|
|
3373
|
+
*/
|
|
3374
|
+
var createMoldeaCliContentExecutionResult = (pageResult, cliVersion, isJson, cursor, maxOutputBytes) => {
|
|
3375
|
+
const result = createMoldeaCliContentPage({
|
|
3376
|
+
cursor,
|
|
3377
|
+
maxOutputBytes,
|
|
3378
|
+
measure: (candidate) => measureOutput(isJson ? formatMoldeaCliJsonContentResult(candidate, cliVersion) : formatMoldeaCliHumanContentResult(candidate)),
|
|
3379
|
+
page: pageResult
|
|
3380
|
+
});
|
|
3381
|
+
return Object.freeze({
|
|
3382
|
+
exitCode: MOLDEA_CLI_EXIT_CODES.Success,
|
|
3383
|
+
stderr: "",
|
|
3384
|
+
stdout: isJson ? formatMoldeaCliJsonContentResult(result, cliVersion) : formatMoldeaCliHumanContentResult(result)
|
|
3385
|
+
});
|
|
3386
|
+
};
|
|
4629
3387
|
//#endregion
|
|
4630
3388
|
//#region src/cli-execution/command-executor.ts
|
|
3389
|
+
/** Loads adapter-backed Core inspection only for commands that need it. */
|
|
3390
|
+
var executeLazyCoreInspection = async (input) => {
|
|
3391
|
+
const { executeMoldeaCliCoreInspection } = await import("./chunks/core-composition-Bb9OMTs-.js");
|
|
3392
|
+
return executeMoldeaCliCoreInspection(input);
|
|
3393
|
+
};
|
|
3394
|
+
var loadInstalledComposition = async (input) => {
|
|
3395
|
+
const { resolveInstalledMoldeaCliComposition } = await import("./chunks/composition-B9oqoRqn.js");
|
|
3396
|
+
return resolveInstalledMoldeaCliComposition(input);
|
|
3397
|
+
};
|
|
3398
|
+
/** Creates one operational error result without exposing caught failure details. */
|
|
3399
|
+
var createOperationalErrorResult = (code, input) => createMoldeaCliErrorResult(createMoldeaCliOwnedError(code), input.invocation.command, input.packageMetadata.version, input.invocation.options.isJson, MOLDEA_CLI_EXIT_CODES.OperationalError);
|
|
4631
3400
|
/**
|
|
4632
|
-
* Creates
|
|
3401
|
+
* Creates command dispatch with lazy adapter composition and bounded working-tree snapshots.
|
|
4633
3402
|
* @param workingTreeDiscovery The Git working-tree discovery operation.
|
|
4634
3403
|
* @param workingTreeSnapshotExecutor The complete working-tree snapshot operation.
|
|
4635
|
-
* @param coreInspectionExecutor The
|
|
4636
|
-
* @param
|
|
4637
|
-
* @
|
|
3404
|
+
* @param coreInspectionExecutor The adapter-backed Core inspection operation.
|
|
3405
|
+
* @param compositionLoader The installed executable-integrity composition boundary.
|
|
3406
|
+
* @param projectScopeExecutor The adapter-free manifest scope operation.
|
|
3407
|
+
* @param projectContentExecutor The adapter-free canonical content operation.
|
|
3408
|
+
* @returns A command executor for the schema 4 CLI.
|
|
4638
3409
|
*/
|
|
4639
|
-
var createMoldeaCliCommandExecutor = (workingTreeDiscovery = discoverGitWorkingTree, workingTreeSnapshotExecutor = executeWorkingTreeSnapshot, coreInspectionExecutor =
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
3410
|
+
var createMoldeaCliCommandExecutor = (workingTreeDiscovery = discoverGitWorkingTree, workingTreeSnapshotExecutor = executeWorkingTreeSnapshot, coreInspectionExecutor = executeLazyCoreInspection, compositionLoader = loadInstalledComposition, projectScopeExecutor = executeMoldeaCliProjectScope, projectContentExecutor = executeMoldeaCliProjectContent) => {
|
|
3411
|
+
return async (input) => {
|
|
3412
|
+
const command = input.invocation.command;
|
|
3413
|
+
const options = input.invocation.options;
|
|
3414
|
+
try {
|
|
3415
|
+
if (command === MOLDEA_CLI_COMMANDS.Composition || command === MOLDEA_CLI_COMMANDS.Inspect || command === MOLDEA_CLI_COMMANDS.Validate) {
|
|
3416
|
+
const compositionResolution = await compositionLoader({ packageMetadata: input.packageMetadata });
|
|
3417
|
+
if (compositionResolution.kind === "invalid") return createOperationalErrorResult("COMPOSITION_STATE_INVALID", input);
|
|
3418
|
+
if (command === MOLDEA_CLI_COMMANDS.Composition) return createMoldeaCliCompositionExecutionResult(compositionResolution.result, input.packageMetadata.version, options.isJson);
|
|
3419
|
+
}
|
|
3420
|
+
let scopePaths = null;
|
|
3421
|
+
let contentPath = null;
|
|
3422
|
+
let contentOffset = 0;
|
|
3423
|
+
const inspectionCursor = command === MOLDEA_CLI_COMMANDS.Inspect && options.cursor !== null ? decodeMoldeaCliCursor({
|
|
3424
|
+
command: "inspect",
|
|
3425
|
+
cursor: options.cursor,
|
|
3426
|
+
filters: {}
|
|
3427
|
+
}).sourceCursor : null;
|
|
3428
|
+
if (command === MOLDEA_CLI_COMMANDS.Scope) {
|
|
3429
|
+
if (options.pathsInput === "path" && options.path !== null) scopePaths = Object.freeze([options.path]);
|
|
3430
|
+
else if (options.pathsInput === "stdin" && input.stdin !== void 0) {
|
|
3431
|
+
if (input.stdin.byteLength > options.resourceLimits.maxTotalBytes) return createOperationalErrorResult("RESOURCE_LIMIT_EXCEEDED", input);
|
|
3432
|
+
scopePaths = parseMoldeaCliScopePathBytes(input.stdin, options.resourceLimits.maxEntries);
|
|
3433
|
+
} else return createOperationalErrorResult("PATH_INPUT_INVALID", input);
|
|
3434
|
+
}
|
|
3435
|
+
if (command === MOLDEA_CLI_COMMANDS.Content) {
|
|
3436
|
+
if (options.path === null) return createOperationalErrorResult("CONTENT_PATH_INVALID", input);
|
|
3437
|
+
contentPath = parseMoldeaCliCanonicalContentPath(options.path);
|
|
3438
|
+
if (options.cursor !== null) {
|
|
3439
|
+
const sourceCursor = decodeMoldeaCliCursor({
|
|
3440
|
+
command: "content",
|
|
3441
|
+
cursor: options.cursor,
|
|
3442
|
+
filters: { path: contentPath }
|
|
3443
|
+
}).sourceCursor;
|
|
3444
|
+
const match = sourceCursor === null ? null : /^byte:(0|[1-9][0-9]*)$/u.exec(sourceCursor);
|
|
3445
|
+
if (match === null) throw new MoldeaCliOutputPageException("CURSOR_INVALID");
|
|
3446
|
+
contentOffset = Number(match[1]);
|
|
3447
|
+
if (!Number.isSafeInteger(contentOffset)) throw new MoldeaCliOutputPageException("CURSOR_INVALID");
|
|
3448
|
+
}
|
|
3449
|
+
}
|
|
3450
|
+
const discoveryResult = await workingTreeDiscovery({
|
|
3451
|
+
invocationDirectory: input.invocationDirectory,
|
|
3452
|
+
repositoryDirectory: options.repositoryDirectory,
|
|
3453
|
+
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
3454
|
+
});
|
|
3455
|
+
if (discoveryResult.kind === "failed") return createOperationalErrorResult(discoveryResult.errorCode, input);
|
|
3456
|
+
const resourceLimits = options.resourceLimits;
|
|
3457
|
+
const snapshotResult = await workingTreeSnapshotExecutor({
|
|
3458
|
+
operation: async (repository, signal) => {
|
|
3459
|
+
if (command === MOLDEA_CLI_COMMANDS.Scope && scopePaths !== null) return projectScopeExecutor({
|
|
3460
|
+
paths: scopePaths,
|
|
3461
|
+
repository,
|
|
3462
|
+
resourceLimits,
|
|
3463
|
+
...signal === void 0 ? {} : { signal }
|
|
3464
|
+
});
|
|
3465
|
+
if (command === MOLDEA_CLI_COMMANDS.Content && contentPath !== null) return projectContentExecutor({
|
|
3466
|
+
maxBytes: Math.min(resourceLimits.maxFileBytes, resourceLimits.maxTotalBytes, Math.max(1, Math.floor(options.maxOutputBytes / 2))),
|
|
3467
|
+
offset: contentOffset,
|
|
3468
|
+
path: contentPath,
|
|
3469
|
+
repository,
|
|
3470
|
+
resourceLimits,
|
|
3471
|
+
...signal === void 0 ? {} : { signal }
|
|
3472
|
+
});
|
|
3473
|
+
return coreInspectionExecutor({
|
|
3474
|
+
command: command === MOLDEA_CLI_COMMANDS.Inspect ? "inspect" : "validate",
|
|
3475
|
+
...inspectionCursor === null ? {} : { cursor: inspectionCursor },
|
|
3476
|
+
repository,
|
|
3477
|
+
resourceLimits,
|
|
3478
|
+
...signal === void 0 ? {} : { signal }
|
|
3479
|
+
});
|
|
3480
|
+
},
|
|
3481
|
+
repositoryRoot: discoveryResult.repositoryRoot,
|
|
4654
3482
|
resourceLimits,
|
|
4655
|
-
...
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
}
|
|
3483
|
+
...command === MOLDEA_CLI_COMMANDS.Scope ? { selectionPaths: [MOLDEA_MANIFEST_PATH] } : contentPath === null ? {} : { selectionPaths: [contentPath] },
|
|
3484
|
+
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
3485
|
+
});
|
|
3486
|
+
if (snapshotResult.kind === "failed") return createOperationalErrorResult(snapshotResult.errorCode, input);
|
|
3487
|
+
if (command === MOLDEA_CLI_COMMANDS.Validate) return createMoldeaCliValidateExecutionResult(snapshotResult.result, input.packageMetadata.version, options.isJson, options.cursor, options.maxOutputBytes);
|
|
3488
|
+
if (command === MOLDEA_CLI_COMMANDS.Inspect) return createMoldeaCliInspectExecutionResult(snapshotResult.result, input.packageMetadata.version, options.isJson, options.cursor, options.maxOutputBytes);
|
|
3489
|
+
if (command === MOLDEA_CLI_COMMANDS.Scope) return createMoldeaCliScopeExecutionResult(snapshotResult.result, input.packageMetadata.version, options.isJson, options.cursor, options.maxOutputBytes);
|
|
3490
|
+
return createMoldeaCliContentExecutionResult(snapshotResult.result, input.packageMetadata.version, options.isJson, options.cursor, options.maxOutputBytes);
|
|
3491
|
+
} catch (error) {
|
|
3492
|
+
return createMoldeaCliErrorResult(mapMoldeaCliOperationalError(error), command, input.packageMetadata.version, options.isJson, MOLDEA_CLI_EXIT_CODES.OperationalError);
|
|
3493
|
+
}
|
|
3494
|
+
};
|
|
4667
3495
|
};
|
|
4668
3496
|
var executeMoldeaCliCommand = createMoldeaCliCommandExecutor();
|
|
4669
3497
|
//#endregion
|
|
@@ -4688,11 +3516,19 @@ var runMoldeaCli = async (options) => {
|
|
|
4688
3516
|
if (parseResult.kind === "error") return createMoldeaCliErrorResult(createMoldeaCliOwnedError(parseResult.code), parseResult.command, options.packageMetadata.version, parseResult.isJson, MOLDEA_CLI_EXIT_CODES.UsageError);
|
|
4689
3517
|
const executeCommand = options.executeCommand ?? executeMoldeaCliCommand;
|
|
4690
3518
|
try {
|
|
3519
|
+
let stdin;
|
|
3520
|
+
if (parseResult.invocation.options.pathsInput === "stdin") {
|
|
3521
|
+
if (options.readStdin === void 0) return createMoldeaCliErrorResult(createMoldeaCliOwnedError("PATH_INPUT_INVALID"), parseResult.invocation.command, options.packageMetadata.version, parseResult.invocation.options.isJson, MOLDEA_CLI_EXIT_CODES.UsageError);
|
|
3522
|
+
const stdinResult = await options.readStdin(parseResult.invocation.options.resourceLimits.maxTotalBytes, options.signal);
|
|
3523
|
+
if (stdinResult.kind === "limit-exceeded") return createMoldeaCliErrorResult(createMoldeaCliOwnedError("RESOURCE_LIMIT_EXCEEDED"), parseResult.invocation.command, options.packageMetadata.version, parseResult.invocation.options.isJson, MOLDEA_CLI_EXIT_CODES.OperationalError);
|
|
3524
|
+
stdin = stdinResult.bytes;
|
|
3525
|
+
}
|
|
4691
3526
|
return await executeCommand({
|
|
4692
3527
|
invocationDirectory: options.invocationDirectory,
|
|
4693
3528
|
invocation: parseResult.invocation,
|
|
4694
3529
|
packageMetadata: options.packageMetadata,
|
|
4695
|
-
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
3530
|
+
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
3531
|
+
...stdin === void 0 ? {} : { stdin }
|
|
4696
3532
|
});
|
|
4697
3533
|
} catch {
|
|
4698
3534
|
return createMoldeaCliErrorResult(createMoldeaCliOwnedError("INTERNAL_ERROR"), parseResult.invocation.command, options.packageMetadata.version, parseResult.invocation.options.isJson, MOLDEA_CLI_EXIT_CODES.OperationalError);
|
|
@@ -4700,6 +3536,7 @@ var runMoldeaCli = async (options) => {
|
|
|
4700
3536
|
};
|
|
4701
3537
|
//#endregion
|
|
4702
3538
|
//#region src/package-metadata/loader.ts
|
|
3539
|
+
var import_semver = require_semver();
|
|
4703
3540
|
var MOLDEA_CLI_PACKAGE_NAME = "@moldea.ai/cli";
|
|
4704
3541
|
/** Checks exact SemVer syntax without accepting normalized prefixes or surrounding whitespace. */
|
|
4705
3542
|
var isExactSemanticVersion = (version) => version === version.trim() && /^[0-9]/u.test(version) && (0, import_semver.valid)(version) !== null;
|
|
@@ -4785,10 +3622,10 @@ var SIGNAL_EXIT_CODES = Object.freeze({
|
|
|
4785
3622
|
});
|
|
4786
3623
|
var PROCESS_SIGNAL_SOURCE = Object.freeze({
|
|
4787
3624
|
addListener: (signal, listener) => {
|
|
4788
|
-
process
|
|
3625
|
+
process.on(signal, listener);
|
|
4789
3626
|
},
|
|
4790
3627
|
removeListener: (signal, listener) => {
|
|
4791
|
-
process
|
|
3628
|
+
process.off(signal, listener);
|
|
4792
3629
|
}
|
|
4793
3630
|
});
|
|
4794
3631
|
/**
|
|
@@ -4834,6 +3671,28 @@ var createMoldeaCliProcessSignalSession = (signalSource = PROCESS_SIGNAL_SOURCE)
|
|
|
4834
3671
|
var executableDirectory = path.dirname(fileURLToPath(import.meta.url));
|
|
4835
3672
|
var packageManifestPath = path.resolve(executableDirectory, "..", "package.json");
|
|
4836
3673
|
var signalSession = createMoldeaCliProcessSignalSession();
|
|
3674
|
+
/** Reads process stdin incrementally without retaining bytes above the requested limit. */
|
|
3675
|
+
var readProcessStdin = async (maxBytes, signal) => {
|
|
3676
|
+
const chunks = [];
|
|
3677
|
+
let totalBytes = 0;
|
|
3678
|
+
for await (const chunk of process.stdin) {
|
|
3679
|
+
if (signal?.aborted) return {
|
|
3680
|
+
bytes: /* @__PURE__ */ new Uint8Array(),
|
|
3681
|
+
kind: "completed"
|
|
3682
|
+
};
|
|
3683
|
+
const bytes = typeof chunk === "string" ? Buffer.from(chunk, "utf8") : new Uint8Array(chunk);
|
|
3684
|
+
totalBytes += bytes.byteLength;
|
|
3685
|
+
if (totalBytes > maxBytes) {
|
|
3686
|
+
process.stdin.pause();
|
|
3687
|
+
return { kind: "limit-exceeded" };
|
|
3688
|
+
}
|
|
3689
|
+
chunks.push(bytes);
|
|
3690
|
+
}
|
|
3691
|
+
return {
|
|
3692
|
+
bytes: Buffer.concat(chunks, totalBytes),
|
|
3693
|
+
kind: "completed"
|
|
3694
|
+
};
|
|
3695
|
+
};
|
|
4837
3696
|
/**
|
|
4838
3697
|
* Writes one complete process output string.
|
|
4839
3698
|
* @param outputStream The destination process stream.
|
|
@@ -4853,27 +3712,28 @@ var writeProcessOutput = async (outputStream, output) => {
|
|
|
4853
3712
|
});
|
|
4854
3713
|
};
|
|
4855
3714
|
try {
|
|
4856
|
-
const invocationDirectory = process
|
|
3715
|
+
const invocationDirectory = process.cwd();
|
|
4857
3716
|
const packageMetadata = await loadMoldeaCliPackageMetadata(packageManifestPath);
|
|
4858
3717
|
const executionResult = await runMoldeaCli({
|
|
4859
|
-
commandLineArguments: process
|
|
3718
|
+
commandLineArguments: process.argv.slice(2),
|
|
4860
3719
|
invocationDirectory,
|
|
4861
3720
|
packageMetadata,
|
|
3721
|
+
readStdin: readProcessStdin,
|
|
4862
3722
|
signal: signalSession.signal
|
|
4863
3723
|
});
|
|
4864
|
-
if (signalSession.hasReceivedSignal) process
|
|
3724
|
+
if (signalSession.hasReceivedSignal) process.exitCode = signalSession.exitCode;
|
|
4865
3725
|
else {
|
|
4866
|
-
await writeProcessOutput(process
|
|
4867
|
-
if (!signalSession.hasReceivedSignal) await writeProcessOutput(process
|
|
3726
|
+
await writeProcessOutput(process.stdout, executionResult.stdout);
|
|
3727
|
+
if (!signalSession.hasReceivedSignal) await writeProcessOutput(process.stderr, executionResult.stderr);
|
|
4868
3728
|
if (!signalSession.hasReceivedSignal) signalSession.completeOutput();
|
|
4869
|
-
process
|
|
3729
|
+
process.exitCode = signalSession.exitCode ?? executionResult.exitCode;
|
|
4870
3730
|
}
|
|
4871
3731
|
} catch {
|
|
4872
|
-
if (signalSession.hasReceivedSignal) process
|
|
3732
|
+
if (signalSession.hasReceivedSignal) process.exitCode = signalSession.exitCode;
|
|
4873
3733
|
else {
|
|
4874
|
-
await writeProcessOutput(process
|
|
3734
|
+
await writeProcessOutput(process.stderr, formatMoldeaCliHumanError(createMoldeaCliOwnedError("INTERNAL_ERROR"))).catch(() => void 0);
|
|
4875
3735
|
signalSession.completeOutput();
|
|
4876
|
-
process
|
|
3736
|
+
process.exitCode = 3;
|
|
4877
3737
|
}
|
|
4878
3738
|
} finally {
|
|
4879
3739
|
signalSession.dispose();
|