@moldea.ai/cli 9.0.1 → 10.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 +8 -6
- package/dist/adapter-registry.js +28 -0
- package/dist/adapter-registry.js.map +1 -0
- package/dist/chunks/composition-B1VCddjs.js +3 -0
- package/dist/chunks/{semver-BzaJzKRS.js → composition-DIN3r5rw.js} +1085 -2
- package/dist/chunks/composition-DIN3r5rw.js.map +1 -0
- package/dist/chunks/core-composition-CWyDX8h6.js +130 -0
- package/dist/chunks/core-composition-CWyDX8h6.js.map +1 -0
- package/dist/moldea.js +31 -934
- package/dist/moldea.js.map +1 -1
- package/package.json +16 -13
- package/dist/chunks/composition-Ck3cXQUk.js +0 -142
- package/dist/chunks/composition-Ck3cXQUk.js.map +0 -1
- package/dist/chunks/core-composition-CgaKOyog.js +0 -3
- package/dist/chunks/core-composition-CttwXtDG.js +0 -92
- package/dist/chunks/core-composition-CttwXtDG.js.map +0 -1
- package/dist/chunks/semver-BzaJzKRS.js.map +0 -1
package/dist/moldea.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as
|
|
2
|
+
import { A as hasOnlyUnicodeScalarValues$1, C as formatMoldeaCliJsonError, D as createMoldeaCliOwnedError, E as formatMoldeaCliJsonValidateResult, F as encodeMoldeaCliCursor, I as MoldeaCliOutputPageException, L as MOLDEA_CLI_COMMANDS, M as createMoldeaCliOutputPage, N as calculateMoldeaCliJsonDigest, O as MOLDEA_CLI_GIT_WORKING_TREE_SOURCE, P as decodeMoldeaCliCursor, S as formatMoldeaCliJsonContentResult, T as formatMoldeaCliJsonScopeResult, _ as formatMoldeaCliHumanError, a as require_semver, b as formatMoldeaCliHumanValidateResult, c as executeGitStreamingProcess, d as createMoldeaCliDiagnosticRecord, f as createMoldeaCliInspectProjection, g as formatMoldeaCliHumanContentResult, h as formatMoldeaCliHumanCompositionResult, j as isRepositoryDirectoryInputValid, k as parseMoldeaCliArguments, l as executeGitProcess, m as formatMoldeaCliHelp, o as MoldeaCliCompositionException, p as createMoldeaCliValidateProjection, s as createGitVersionPreflight, u as MAX_GIT_PROCESS_DIAGNOSTIC_BYTES, v as formatMoldeaCliHumanInspectResult, w as formatMoldeaCliJsonInspectResult, x as formatMoldeaCliJsonCompositionResult, y as formatMoldeaCliHumanScopeResult } from "./chunks/composition-DIN3r5rw.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import process from "node:process";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { createHash, timingSafeEqual } from "node:crypto";
|
|
7
6
|
import { REPOSITORY_ROOT, RepositorySourceException, createRepositoryComparison, isRepositoryPath, parseRepositoryPath } from "@moldea.ai/repository";
|
|
8
7
|
import { lstat, readFile, readdir, stat } from "node:fs/promises";
|
|
9
8
|
import { CoreConfigurationException, CoreOperationException, createCore } from "@moldea.ai/core";
|
|
@@ -19,668 +18,6 @@ var MOLDEA_CLI_EXIT_CODES = {
|
|
|
19
18
|
UsageError: 2
|
|
20
19
|
};
|
|
21
20
|
//#endregion
|
|
22
|
-
//#region src/command-line/constants.ts
|
|
23
|
-
var MOLDEA_CLI_COMMANDS = {
|
|
24
|
-
Composition: "composition",
|
|
25
|
-
Content: "content",
|
|
26
|
-
Inspect: "inspect",
|
|
27
|
-
Scope: "scope",
|
|
28
|
-
Validate: "validate"
|
|
29
|
-
};
|
|
30
|
-
var MOLDEA_CLI_OPTIONS = {
|
|
31
|
-
Help: "--help",
|
|
32
|
-
Json: "--json",
|
|
33
|
-
Cursor: "--cursor",
|
|
34
|
-
MaxDiagnostics: "--max-diagnostics",
|
|
35
|
-
MaxEntries: "--max-entries",
|
|
36
|
-
MaxEvidence: "--max-evidence",
|
|
37
|
-
MaxFileBytes: "--max-file-bytes",
|
|
38
|
-
MaxManifestBytes: "--max-manifest-bytes",
|
|
39
|
-
MaxOutputBytes: "--max-output-bytes",
|
|
40
|
-
MaxTotalBytes: "--max-total-bytes",
|
|
41
|
-
NoColor: "--no-color",
|
|
42
|
-
Path: "--path",
|
|
43
|
-
PathsStdin: "--paths-stdin",
|
|
44
|
-
Repository: "--repository",
|
|
45
|
-
Version: "--version"
|
|
46
|
-
};
|
|
47
|
-
var DEFAULT_MOLDEA_CLI_RESOURCE_LIMITS = Object.freeze({
|
|
48
|
-
maxDiagnostics: 1e4,
|
|
49
|
-
maxEntries: 1e5,
|
|
50
|
-
maxEvidence: 1e4,
|
|
51
|
-
maxFileBytes: 8388608,
|
|
52
|
-
maxManifestBytes: 2097152,
|
|
53
|
-
maxTotalBytes: 134217728
|
|
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
|
-
};
|
|
265
|
-
//#endregion
|
|
266
|
-
//#region src/command-line/validations.ts
|
|
267
|
-
var POSITIVE_INTEGER_PATTERN = /^\d+$/u;
|
|
268
|
-
/**
|
|
269
|
-
* Determines whether text contains only Unicode scalar values.
|
|
270
|
-
* @param text The text to validate.
|
|
271
|
-
* @returns Whether the text contains no unpaired UTF-16 surrogate.
|
|
272
|
-
*/
|
|
273
|
-
var hasOnlyUnicodeScalarValues$1 = (text) => {
|
|
274
|
-
for (let index = 0; index < text.length; index += 1) {
|
|
275
|
-
const codeUnit = text.charCodeAt(index);
|
|
276
|
-
if (codeUnit >= 55296 && codeUnit <= 56319) {
|
|
277
|
-
if (index + 1 >= text.length) return false;
|
|
278
|
-
const trailingCodeUnit = text.charCodeAt(index + 1);
|
|
279
|
-
if (trailingCodeUnit < 56320 || trailingCodeUnit > 57343) return false;
|
|
280
|
-
index += 1;
|
|
281
|
-
continue;
|
|
282
|
-
}
|
|
283
|
-
if (codeUnit >= 56320 && codeUnit <= 57343) return false;
|
|
284
|
-
}
|
|
285
|
-
return true;
|
|
286
|
-
};
|
|
287
|
-
/**
|
|
288
|
-
* Parses one strict base-10 positive safe integer option value.
|
|
289
|
-
* @param input The untrusted command-line token.
|
|
290
|
-
* @returns The parsed integer, or null when the token is invalid.
|
|
291
|
-
*/
|
|
292
|
-
var parsePositiveSafeInteger = (input) => {
|
|
293
|
-
if (!POSITIVE_INTEGER_PATTERN.test(input)) return null;
|
|
294
|
-
const parsedInteger = Number(input);
|
|
295
|
-
return Number.isSafeInteger(parsedInteger) && parsedInteger > 0 ? parsedInteger : null;
|
|
296
|
-
};
|
|
297
|
-
/** Parses one output byte budget inside the schema 5 transport bounds. */
|
|
298
|
-
var parseMoldeaCliOutputByteLimit = (input) => {
|
|
299
|
-
const parsed = parsePositiveSafeInteger(input);
|
|
300
|
-
return parsed !== null && parsed >= 4096 && parsed <= 1048576 ? parsed : null;
|
|
301
|
-
};
|
|
302
|
-
/**
|
|
303
|
-
* Validates the cross-limit ordering required by the CLI composition.
|
|
304
|
-
* @param limits The effective resource limits.
|
|
305
|
-
* @returns Whether manifest, file, and total byte limits are consistently ordered.
|
|
306
|
-
*/
|
|
307
|
-
var areMoldeaCliResourceLimitsConsistent = (limits) => {
|
|
308
|
-
return limits.maxManifestBytes <= limits.maxFileBytes && limits.maxFileBytes <= limits.maxTotalBytes;
|
|
309
|
-
};
|
|
310
|
-
/**
|
|
311
|
-
* Determines whether one repository option is safe scalar host-path text.
|
|
312
|
-
* @param input The untrusted command-line token.
|
|
313
|
-
* @returns Whether the token is non-empty scalar text without NUL.
|
|
314
|
-
*/
|
|
315
|
-
var isRepositoryDirectoryInputValid = (input) => {
|
|
316
|
-
return input.length > 0 && !input.includes("\0") && hasOnlyUnicodeScalarValues$1(input);
|
|
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
|
-
};
|
|
322
|
-
//#endregion
|
|
323
|
-
//#region src/command-line/parser.ts
|
|
324
|
-
var COMMAND_NAMES = new Set(Object.values(MOLDEA_CLI_COMMANDS));
|
|
325
|
-
var RESOURCE_OPTION_FIELDS = {
|
|
326
|
-
[MOLDEA_CLI_OPTIONS.MaxDiagnostics]: "maxDiagnostics",
|
|
327
|
-
[MOLDEA_CLI_OPTIONS.MaxEntries]: "maxEntries",
|
|
328
|
-
[MOLDEA_CLI_OPTIONS.MaxEvidence]: "maxEvidence",
|
|
329
|
-
[MOLDEA_CLI_OPTIONS.MaxFileBytes]: "maxFileBytes",
|
|
330
|
-
[MOLDEA_CLI_OPTIONS.MaxManifestBytes]: "maxManifestBytes",
|
|
331
|
-
[MOLDEA_CLI_OPTIONS.MaxTotalBytes]: "maxTotalBytes"
|
|
332
|
-
};
|
|
333
|
-
var createArgumentError = (code, command, isJson) => ({
|
|
334
|
-
code,
|
|
335
|
-
command,
|
|
336
|
-
isJson,
|
|
337
|
-
kind: "error"
|
|
338
|
-
});
|
|
339
|
-
var isMoldeaCliCommand = (input) => {
|
|
340
|
-
return input !== void 0 && COMMAND_NAMES.has(input);
|
|
341
|
-
};
|
|
342
|
-
/**
|
|
343
|
-
* Parses the complete schema 5 command grammar without mutating caller arguments.
|
|
344
|
-
* @param commandLineArguments The process arguments after the executable path.
|
|
345
|
-
* @returns A normalized command, informational request, or safe invocation error.
|
|
346
|
-
*/
|
|
347
|
-
var parseMoldeaCliArguments = (commandLineArguments) => {
|
|
348
|
-
const isJson = commandLineArguments.includes(MOLDEA_CLI_OPTIONS.Json);
|
|
349
|
-
if (commandLineArguments.length === 0) return {
|
|
350
|
-
command: null,
|
|
351
|
-
kind: "help"
|
|
352
|
-
};
|
|
353
|
-
const firstArgument = commandLineArguments[0];
|
|
354
|
-
if (firstArgument === MOLDEA_CLI_OPTIONS.Help) return commandLineArguments.length === 1 ? {
|
|
355
|
-
command: null,
|
|
356
|
-
kind: "help"
|
|
357
|
-
} : createArgumentError("INVALID_ARGUMENT", null, isJson);
|
|
358
|
-
if (firstArgument === MOLDEA_CLI_OPTIONS.Version) return commandLineArguments.length === 1 ? { kind: "version" } : createArgumentError("INVALID_ARGUMENT", null, isJson);
|
|
359
|
-
const command = isMoldeaCliCommand(firstArgument) ? firstArgument : null;
|
|
360
|
-
if (command === null) return createArgumentError("INVALID_ARGUMENT", null, isJson);
|
|
361
|
-
if (commandLineArguments.length === 2 && commandLineArguments[1] === MOLDEA_CLI_OPTIONS.Help) return {
|
|
362
|
-
command,
|
|
363
|
-
kind: "help"
|
|
364
|
-
};
|
|
365
|
-
const seenOptions = /* @__PURE__ */ new Set();
|
|
366
|
-
const resourceLimits = { ...DEFAULT_MOLDEA_CLI_RESOURCE_LIMITS };
|
|
367
|
-
let isColorDisabled = false;
|
|
368
|
-
let cursor = null;
|
|
369
|
-
let maxOutputBytes = MOLDEA_CLI_DEFAULT_OUTPUT_BYTES;
|
|
370
|
-
let path = null;
|
|
371
|
-
let pathsInput = "none";
|
|
372
|
-
let repositoryDirectory = null;
|
|
373
|
-
for (let index = 1; index < commandLineArguments.length; index += 1) {
|
|
374
|
-
const option = commandLineArguments[index];
|
|
375
|
-
if (option === void 0 || seenOptions.has(option)) return createArgumentError("INVALID_ARGUMENT", command, isJson);
|
|
376
|
-
seenOptions.add(option);
|
|
377
|
-
if (option === MOLDEA_CLI_OPTIONS.Json) continue;
|
|
378
|
-
if (option === MOLDEA_CLI_OPTIONS.NoColor) {
|
|
379
|
-
isColorDisabled = true;
|
|
380
|
-
continue;
|
|
381
|
-
}
|
|
382
|
-
if (option === MOLDEA_CLI_OPTIONS.PathsStdin) {
|
|
383
|
-
pathsInput = "stdin";
|
|
384
|
-
continue;
|
|
385
|
-
}
|
|
386
|
-
if (option === MOLDEA_CLI_OPTIONS.Help || option === MOLDEA_CLI_OPTIONS.Version) return createArgumentError("INVALID_ARGUMENT", command, isJson);
|
|
387
|
-
const resourceField = RESOURCE_OPTION_FIELDS[option];
|
|
388
|
-
const isRepositoryOption = option === MOLDEA_CLI_OPTIONS.Repository;
|
|
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);
|
|
393
|
-
if (command === MOLDEA_CLI_COMMANDS.Composition) return createArgumentError("INVALID_ARGUMENT", command, isJson);
|
|
394
|
-
const optionValue = commandLineArguments[index + 1];
|
|
395
|
-
if (optionValue === void 0 || optionValue.startsWith("--")) return createArgumentError("INVALID_ARGUMENT", command, isJson);
|
|
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
|
-
}
|
|
414
|
-
if (isRepositoryOption) {
|
|
415
|
-
if (!isRepositoryDirectoryInputValid(optionValue)) return createArgumentError("INVALID_ARGUMENT", command, isJson);
|
|
416
|
-
repositoryDirectory = optionValue;
|
|
417
|
-
continue;
|
|
418
|
-
}
|
|
419
|
-
const parsedLimit = parsePositiveSafeInteger(optionValue);
|
|
420
|
-
if (parsedLimit === null || resourceField === void 0) return createArgumentError("RESOURCE_LIMIT_CONFIGURATION_INVALID", command, isJson);
|
|
421
|
-
resourceLimits[resourceField] = parsedLimit;
|
|
422
|
-
}
|
|
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);
|
|
438
|
-
const options = {
|
|
439
|
-
cursor,
|
|
440
|
-
isColorDisabled,
|
|
441
|
-
isJson,
|
|
442
|
-
maxOutputBytes,
|
|
443
|
-
path,
|
|
444
|
-
pathsInput,
|
|
445
|
-
repositoryDirectory,
|
|
446
|
-
resourceLimits: Object.freeze({ ...resourceLimits })
|
|
447
|
-
};
|
|
448
|
-
return {
|
|
449
|
-
invocation: Object.freeze({
|
|
450
|
-
command,
|
|
451
|
-
options: Object.freeze(options)
|
|
452
|
-
}),
|
|
453
|
-
kind: "command"
|
|
454
|
-
};
|
|
455
|
-
};
|
|
456
|
-
//#endregion
|
|
457
|
-
//#region src/presentation/constants.ts
|
|
458
|
-
var MOLDEA_CLI_ERROR_DEFINITIONS = Object.freeze({
|
|
459
|
-
COMPOSITION_STATE_INVALID: Object.freeze({
|
|
460
|
-
message: "The installed composition state is invalid.",
|
|
461
|
-
retryable: false,
|
|
462
|
-
source: "cli"
|
|
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
|
-
}),
|
|
484
|
-
GIT_ACCESS_DENIED: Object.freeze({
|
|
485
|
-
message: "Git access was denied.",
|
|
486
|
-
retryable: true,
|
|
487
|
-
source: "git"
|
|
488
|
-
}),
|
|
489
|
-
GIT_COMMAND_FAILED: Object.freeze({
|
|
490
|
-
message: "The Git command failed.",
|
|
491
|
-
retryable: true,
|
|
492
|
-
source: "git"
|
|
493
|
-
}),
|
|
494
|
-
GIT_CONTENT_TRANSFORM_UNSUPPORTED: Object.freeze({
|
|
495
|
-
message: "The requested file uses an unsupported Git content transformation.",
|
|
496
|
-
retryable: false,
|
|
497
|
-
source: "git"
|
|
498
|
-
}),
|
|
499
|
-
GIT_NOT_FOUND: Object.freeze({
|
|
500
|
-
message: "The Git executable is unavailable.",
|
|
501
|
-
retryable: false,
|
|
502
|
-
source: "git"
|
|
503
|
-
}),
|
|
504
|
-
GIT_OPERATION_ABORTED: Object.freeze({
|
|
505
|
-
message: "The Git operation was aborted.",
|
|
506
|
-
retryable: true,
|
|
507
|
-
source: "git"
|
|
508
|
-
}),
|
|
509
|
-
GIT_OUTPUT_INVALID: Object.freeze({
|
|
510
|
-
message: "Git returned invalid output.",
|
|
511
|
-
retryable: false,
|
|
512
|
-
source: "git"
|
|
513
|
-
}),
|
|
514
|
-
GIT_REPOSITORY_NOT_FOUND: Object.freeze({
|
|
515
|
-
message: "The selected path is not inside a Git repository.",
|
|
516
|
-
retryable: false,
|
|
517
|
-
source: "git"
|
|
518
|
-
}),
|
|
519
|
-
GIT_SPARSE_CHECKOUT_UNSUPPORTED: Object.freeze({
|
|
520
|
-
message: "Sparse Git checkouts are unsupported.",
|
|
521
|
-
retryable: false,
|
|
522
|
-
source: "git"
|
|
523
|
-
}),
|
|
524
|
-
GIT_VERSION_INVALID: Object.freeze({
|
|
525
|
-
message: "The Git version output is invalid.",
|
|
526
|
-
retryable: false,
|
|
527
|
-
source: "git"
|
|
528
|
-
}),
|
|
529
|
-
GIT_VERSION_UNSUPPORTED: Object.freeze({
|
|
530
|
-
message: "The installed Git version is unsupported.",
|
|
531
|
-
retryable: false,
|
|
532
|
-
source: "git"
|
|
533
|
-
}),
|
|
534
|
-
GIT_WORK_TREE_REQUIRED: Object.freeze({
|
|
535
|
-
message: "A usable Git working tree is required.",
|
|
536
|
-
retryable: false,
|
|
537
|
-
source: "git"
|
|
538
|
-
}),
|
|
539
|
-
INTERNAL_ERROR: Object.freeze({
|
|
540
|
-
message: "The command could not be completed.",
|
|
541
|
-
retryable: false,
|
|
542
|
-
source: "cli"
|
|
543
|
-
}),
|
|
544
|
-
INVALID_ARGUMENT: Object.freeze({
|
|
545
|
-
message: "The command invocation is invalid.",
|
|
546
|
-
retryable: false,
|
|
547
|
-
source: "cli"
|
|
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 scope path input is invalid. Use leading-slash repository-logical paths and NUL-delimited UTF-8 on stdin.",
|
|
556
|
-
retryable: false,
|
|
557
|
-
source: "cli"
|
|
558
|
-
}),
|
|
559
|
-
RESOURCE_LIMIT_CONFIGURATION_INVALID: Object.freeze({
|
|
560
|
-
message: "The resource-limit configuration is invalid.",
|
|
561
|
-
retryable: false,
|
|
562
|
-
source: "cli"
|
|
563
|
-
}),
|
|
564
|
-
RESOURCE_LIMIT_EXCEEDED: Object.freeze({
|
|
565
|
-
message: "A resource limit was exceeded.",
|
|
566
|
-
retryable: false,
|
|
567
|
-
source: "cli"
|
|
568
|
-
}),
|
|
569
|
-
WORKING_TREE_UNSTABLE: Object.freeze({
|
|
570
|
-
message: "The working tree did not remain stable.",
|
|
571
|
-
retryable: true,
|
|
572
|
-
source: "cli"
|
|
573
|
-
})
|
|
574
|
-
});
|
|
575
|
-
var MOLDEA_CLI_GIT_WORKING_TREE_SOURCE = Object.freeze({ kind: "git-working-tree" });
|
|
576
|
-
var MOLDEA_CLI_TOP_LEVEL_HELP = `Usage: moldea <command> [options]
|
|
577
|
-
|
|
578
|
-
Commands:
|
|
579
|
-
validate Validate the current moldea project.
|
|
580
|
-
inspect Inspect content-free project metadata.
|
|
581
|
-
scope Match changed paths to declared moldea relationships.
|
|
582
|
-
content Read one canonical moldea asset explicitly.
|
|
583
|
-
composition Report the installed CLI composition state.
|
|
584
|
-
|
|
585
|
-
Global options:
|
|
586
|
-
--help Show top-level help.
|
|
587
|
-
--version Show the CLI version.
|
|
588
|
-
|
|
589
|
-
Run "moldea <command> --help" for command-specific options.
|
|
590
|
-
`;
|
|
591
|
-
var REPOSITORY_OPTIONS_HELP = ` --repository <path> Select a Git working-tree directory.
|
|
592
|
-
--json Emit one machine-readable JSON result.
|
|
593
|
-
--no-color Disable ANSI styling in human output.
|
|
594
|
-
`;
|
|
595
|
-
var BASE_RESOURCE_OPTIONS_HELP = ` --max-entries <integer> Override the repository entry limit.
|
|
596
|
-
--max-file-bytes <integer> Override the per-file byte limit.
|
|
597
|
-
--max-total-bytes <integer> Override the total cached-byte limit.
|
|
598
|
-
`;
|
|
599
|
-
var INSPECTION_RESOURCE_OPTIONS_HELP = `${BASE_RESOURCE_OPTIONS_HELP} --max-manifest-bytes <integer> Override the manifest byte limit.
|
|
600
|
-
--max-diagnostics <integer> Override the diagnostic count limit.
|
|
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}`;
|
|
609
|
-
var MOLDEA_CLI_COMMAND_HELP = {
|
|
610
|
-
[MOLDEA_CLI_COMMANDS.Composition]: `Usage: moldea composition [options]
|
|
611
|
-
|
|
612
|
-
Report the installed CLI composition state.
|
|
613
|
-
|
|
614
|
-
Options:
|
|
615
|
-
--json Emit one machine-readable JSON result.
|
|
616
|
-
--no-color Disable ANSI styling in human output.
|
|
617
|
-
--help Show this help.
|
|
618
|
-
`,
|
|
619
|
-
[MOLDEA_CLI_COMMANDS.Inspect]: `Usage: moldea inspect [options]
|
|
620
|
-
|
|
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.
|
|
638
|
-
|
|
639
|
-
Options:
|
|
640
|
-
${CONTENT_OPTIONS_HELP} --path <canonical-logical-path> Select exactly one canonical moldea file.
|
|
641
|
-
--help Show this help.
|
|
642
|
-
`,
|
|
643
|
-
[MOLDEA_CLI_COMMANDS.Validate]: `Usage: moldea validate [options]
|
|
644
|
-
|
|
645
|
-
Validate the current moldea project.
|
|
646
|
-
|
|
647
|
-
Options:
|
|
648
|
-
${COMPLETE_INSPECTION_OPTIONS_HELP} --help Show this help.
|
|
649
|
-
`
|
|
650
|
-
};
|
|
651
|
-
//#endregion
|
|
652
|
-
//#region src/presentation/errors.ts
|
|
653
|
-
var EMPTY_ERROR_DETAILS$1 = Object.freeze({});
|
|
654
|
-
/**
|
|
655
|
-
* Creates one immutable safe error from a CLI- or Git-owned definition.
|
|
656
|
-
* @param code The stable executable-owned error code.
|
|
657
|
-
* @returns The complete safe error object.
|
|
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
|
|
668
|
-
});
|
|
669
|
-
};
|
|
670
|
-
//#endregion
|
|
671
|
-
//#region src/json-output-contract/document.ts
|
|
672
|
-
/** Creates one strict schema 5 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: 5,
|
|
679
|
-
status: input.status
|
|
680
|
-
});
|
|
681
|
-
/** Serializes one schema 5 envelope with its required trailing line feed. */
|
|
682
|
-
var serializeMoldeaCliJsonEnvelope = (input) => `${serializeJsonDeterministically(createMoldeaCliJsonEnvelope(input))}\n`;
|
|
683
|
-
//#endregion
|
|
684
21
|
//#region src/json-output-contract/guard.ts
|
|
685
22
|
/** Rejects canonical bodies and content fields from a non-content JSON result. */
|
|
686
23
|
var assertMoldeaCliJsonResultIsContentFree = (value, canonicalBodies = []) => {
|
|
@@ -705,269 +42,6 @@ var assertMoldeaCliJsonResultIsContentFree = (value, canonicalBodies = []) => {
|
|
|
705
42
|
}
|
|
706
43
|
};
|
|
707
44
|
//#endregion
|
|
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
|
-
if (diagnostic.severity === "warning") {
|
|
729
|
-
lines.push(` unverified relationship: ${diagnostic.details.relationship}`);
|
|
730
|
-
lines.push(` reason: ${diagnostic.details.reason.replaceAll("-", " ")}`);
|
|
731
|
-
if (diagnostic.details.reason === "version-dependent-behavior") {
|
|
732
|
-
lines.push(` package: ${diagnostic.details.packageName}`);
|
|
733
|
-
lines.push(` declared range: ${diagnostic.details.declaredRange ?? "unavailable"}`);
|
|
734
|
-
lines.push(` behavior boundary: ${diagnostic.details.boundaryVersion}`);
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
return lines.join("\n");
|
|
738
|
-
};
|
|
739
|
-
/** Creates shared human status lines for one completed repository command. */
|
|
740
|
-
var createMoldeaCliHumanStatusLines = (isValid, formatVersion, warningCount = 0) => {
|
|
741
|
-
const lines = [`The moldea project is ${isValid ? warningCount > 0 ? "valid with warnings" : "valid" : "invalid"}.`];
|
|
742
|
-
if (formatVersion !== null) lines.push(`Repository format: ${formatVersion}`);
|
|
743
|
-
return lines;
|
|
744
|
-
};
|
|
745
|
-
/** Formats one count label with correct singular or plural grammar. */
|
|
746
|
-
var formatMoldeaCliHumanCount = (count, singularLabel, pluralLabel) => `${count === 1 ? singularLabel : pluralLabel}: ${count}`;
|
|
747
|
-
/** Formats top-level or command-specific help with its required trailing line feed. */
|
|
748
|
-
var formatMoldeaCliHelp = (command) => {
|
|
749
|
-
return command === null ? MOLDEA_CLI_TOP_LEVEL_HELP : MOLDEA_CLI_COMMAND_HELP[command];
|
|
750
|
-
};
|
|
751
|
-
/** Formats one safe CLI error for human stderr output. */
|
|
752
|
-
var formatMoldeaCliHumanError = (error) => `${error.source}:${error.code} ${error.message}\n`;
|
|
753
|
-
/** Formats any strict schema 5 JSON envelope. */
|
|
754
|
-
var formatMoldeaCliJsonResult = (command, result, error, status, cliVersion) => serializeMoldeaCliJsonEnvelope({
|
|
755
|
-
cliVersion,
|
|
756
|
-
command,
|
|
757
|
-
error,
|
|
758
|
-
result,
|
|
759
|
-
status
|
|
760
|
-
});
|
|
761
|
-
/** Formats one safe schema 5 JSON error envelope. */
|
|
762
|
-
var formatMoldeaCliJsonError = (error, command, cliVersion) => formatMoldeaCliJsonResult(command, null, error, "error", cliVersion);
|
|
763
|
-
/** Formats one valid composition result for human stdout. */
|
|
764
|
-
var formatMoldeaCliHumanCompositionResult = (result, cliVersion) => {
|
|
765
|
-
return `${[
|
|
766
|
-
"The installed CLI composition state is valid.",
|
|
767
|
-
`CLI version: ${cliVersion}`,
|
|
768
|
-
`Supported Node.js: ${result.supportedNodeRange}`,
|
|
769
|
-
`JSON output schema: 5`,
|
|
770
|
-
`Minimum Git: ${result.minimumGitVersion}`,
|
|
771
|
-
`Repository formats: ${result.repositoryFormatVersions.join(", ")}`,
|
|
772
|
-
"Packages:",
|
|
773
|
-
...result.packages.map(({ name, version }) => ` ${name}: ${version}`),
|
|
774
|
-
"Adapters:",
|
|
775
|
-
...result.adapters.map(({ id, repositoryFormatVersions }) => ` ${id}: repository formats ${repositoryFormatVersions.join(", ")}`)
|
|
776
|
-
].join("\n")}\n`;
|
|
777
|
-
};
|
|
778
|
-
/** Formats one composition result in the strict schema 5 envelope. */
|
|
779
|
-
var formatMoldeaCliJsonCompositionResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Composition, result, null, "valid", cliVersion);
|
|
780
|
-
/** Formats one completed validation result for human stdout. */
|
|
781
|
-
var formatMoldeaCliHumanValidateResult = (result) => {
|
|
782
|
-
const lines = createMoldeaCliHumanStatusLines(result.valid, result.formatVersion, result.warningCount);
|
|
783
|
-
for (const diagnostic of result.page.records) lines.push(formatMoldeaCliHumanDiagnostic(diagnostic));
|
|
784
|
-
lines.push(formatMoldeaCliHumanCount(result.diagnosticCount, "Diagnostic", "Diagnostics"));
|
|
785
|
-
lines.push(formatMoldeaCliHumanCount(result.errorCount, "Error", "Errors"));
|
|
786
|
-
lines.push(formatMoldeaCliHumanCount(result.warningCount, "Warning", "Warnings"));
|
|
787
|
-
if (result.page.cursor !== null) lines.push("Additional diagnostics are available through JSON pagination.");
|
|
788
|
-
return `${lines.join("\n")}\n`;
|
|
789
|
-
};
|
|
790
|
-
/** Formats one validation result in the strict schema 5 envelope. */
|
|
791
|
-
var formatMoldeaCliJsonValidateResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Validate, result, null, result.valid ? "valid" : "invalid", cliVersion);
|
|
792
|
-
/** Formats one completed metadata inspection for human stdout. */
|
|
793
|
-
var formatMoldeaCliHumanInspectResult = (result) => {
|
|
794
|
-
const lines = createMoldeaCliHumanStatusLines(result.valid, result.formatVersion, result.counts.warnings);
|
|
795
|
-
for (const [label, count] of Object.entries(result.counts)) lines.push(`${label}: ${count}`);
|
|
796
|
-
return `${lines.join("\n")}\n`;
|
|
797
|
-
};
|
|
798
|
-
/** Formats one metadata inspection in the strict schema 5 envelope. */
|
|
799
|
-
var formatMoldeaCliJsonInspectResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Inspect, result, null, result.valid ? "valid" : "invalid", cliVersion);
|
|
800
|
-
/** Formats one changed-path scope result for human stdout. */
|
|
801
|
-
var formatMoldeaCliHumanScopeResult = (result) => {
|
|
802
|
-
return `${[
|
|
803
|
-
`The moldea scope result is ${result.valid ? "valid" : "invalid"}.`,
|
|
804
|
-
`Relevant: ${result.relevant ? "yes" : "no"}`,
|
|
805
|
-
...Object.entries(result.counts).map(([label, count]) => `${label}: ${count}`)
|
|
806
|
-
].join("\n")}\n`;
|
|
807
|
-
};
|
|
808
|
-
/** Formats one changed-path scope result in the strict schema 5 envelope. */
|
|
809
|
-
var formatMoldeaCliJsonScopeResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Scope, result, null, result.valid ? "valid" : "invalid", cliVersion);
|
|
810
|
-
/** Formats one explicit canonical content chunk for human stdout. */
|
|
811
|
-
var formatMoldeaCliHumanContentResult = (result) => {
|
|
812
|
-
return `${[
|
|
813
|
-
`Path: ${result.asset.path}`,
|
|
814
|
-
`Content identity: ${result.asset.contentIdentity ?? "unavailable"}`,
|
|
815
|
-
`Bytes: ${result.chunk.byteStart}-${result.chunk.byteEnd} of ${result.asset.totalBytes}`,
|
|
816
|
-
result.cursor === null ? "Cursor: none" : `Cursor: ${result.cursor}`,
|
|
817
|
-
...result.cursor === null ? [] : ["Continue this asset by passing the cursor to a JSON content request."],
|
|
818
|
-
"",
|
|
819
|
-
result.chunk.content
|
|
820
|
-
].join("\n")}\n`;
|
|
821
|
-
};
|
|
822
|
-
/** Formats one explicit canonical content chunk in the strict schema 5 envelope. */
|
|
823
|
-
var formatMoldeaCliJsonContentResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Content, result, null, "valid", cliVersion);
|
|
824
|
-
//#endregion
|
|
825
|
-
//#region src/presentation/transformers.ts
|
|
826
|
-
/** Rejects a Core validation result whose completion fields contradict its validity. */
|
|
827
|
-
var assertProjectValidationInvariant = (validation) => {
|
|
828
|
-
const observedErrorCount = validation.diagnostics.filter((diagnostic) => diagnostic.severity === "error").length;
|
|
829
|
-
if (!(Number.isSafeInteger(validation.errorCount) && Number.isSafeInteger(validation.warningCount) && validation.errorCount === observedErrorCount && validation.warningCount === validation.diagnostics.length - observedErrorCount && validation.valid === (validation.summary !== null && validation.errorCount === 0) && (validation.valid || validation.errorCount > 0))) throw new TypeError("The Core validation result is internally inconsistent.");
|
|
830
|
-
};
|
|
831
|
-
/** Creates one stable composite record key. */
|
|
832
|
-
var createRecordKey = (kind, ...parts) => JSON.stringify([kind, ...parts]);
|
|
833
|
-
/** Projects one diagnostic without retaining arbitrary detail payloads. */
|
|
834
|
-
var createMoldeaCliDiagnosticRecord = (diagnostic, occurrence = 0) => {
|
|
835
|
-
const record = {
|
|
836
|
-
code: diagnostic.code,
|
|
837
|
-
entity: diagnostic.entity,
|
|
838
|
-
key: createRecordKey("diagnostic", diagnostic.source, diagnostic.severity, diagnostic.code, diagnostic.path, diagnostic.pointer, diagnostic.severity === "warning" ? diagnostic.details : null, occurrence),
|
|
839
|
-
kind: "diagnostic",
|
|
840
|
-
message: diagnostic.message,
|
|
841
|
-
path: diagnostic.path,
|
|
842
|
-
pointer: diagnostic.pointer,
|
|
843
|
-
range: diagnostic.range,
|
|
844
|
-
source: diagnostic.source
|
|
845
|
-
};
|
|
846
|
-
if (diagnostic.severity === "warning") {
|
|
847
|
-
const details = diagnostic.details.reason === "version-dependent-behavior" ? Object.freeze({
|
|
848
|
-
boundaryVersion: diagnostic.details.boundaryVersion,
|
|
849
|
-
declaredRange: diagnostic.details.declaredRange,
|
|
850
|
-
packageName: diagnostic.details.packageName,
|
|
851
|
-
reason: diagnostic.details.reason,
|
|
852
|
-
relationship: diagnostic.details.relationship
|
|
853
|
-
}) : Object.freeze({
|
|
854
|
-
reason: diagnostic.details.reason,
|
|
855
|
-
relationship: diagnostic.details.relationship
|
|
856
|
-
});
|
|
857
|
-
return Object.freeze({
|
|
858
|
-
...record,
|
|
859
|
-
details,
|
|
860
|
-
severity: "warning"
|
|
861
|
-
});
|
|
862
|
-
}
|
|
863
|
-
return Object.freeze({
|
|
864
|
-
...record,
|
|
865
|
-
severity: "error"
|
|
866
|
-
});
|
|
867
|
-
};
|
|
868
|
-
/** Projects one bounded Core inspection item through the schema 5 allowlist. */
|
|
869
|
-
var createInspectRecord = (item, index) => {
|
|
870
|
-
const order = index.toString().padStart(6, "0");
|
|
871
|
-
if (item.kind === "agent") {
|
|
872
|
-
const record = {
|
|
873
|
-
agentId: item.agent.agentId,
|
|
874
|
-
key: createRecordKey(order, "agent", item.agent.agentId, item.agent.runtimeId),
|
|
875
|
-
kind: "agent",
|
|
876
|
-
runtimeId: item.agent.runtimeId
|
|
877
|
-
};
|
|
878
|
-
return Object.freeze(record);
|
|
879
|
-
}
|
|
880
|
-
if (item.kind === "diagnostic") return Object.freeze({
|
|
881
|
-
...createMoldeaCliDiagnosticRecord(item.diagnostic, index),
|
|
882
|
-
key: createRecordKey(order, "diagnostic", item.diagnostic.source, item.diagnostic.severity, item.diagnostic.code, item.diagnostic.severity === "warning" ? item.diagnostic.details : null)
|
|
883
|
-
});
|
|
884
|
-
if (item.kind === "evidence") {
|
|
885
|
-
const evidence = item.evidence;
|
|
886
|
-
const record = {
|
|
887
|
-
agentId: evidence.agentId,
|
|
888
|
-
capabilityId: evidence.capabilityId,
|
|
889
|
-
capabilityKind: evidence.capabilityKind,
|
|
890
|
-
evidenceKind: evidence.kind,
|
|
891
|
-
key: createRecordKey(order, "evidence", evidence.source, evidence.kind, evidence.agentId, evidence.capabilityKind, evidence.capabilityId, evidence.runtimeName),
|
|
892
|
-
kind: "evidence",
|
|
893
|
-
references: Object.freeze(evidence.references.map((reference) => Object.freeze({
|
|
894
|
-
path: reference.path,
|
|
895
|
-
symbol: reference.symbol ?? null
|
|
896
|
-
}))),
|
|
897
|
-
runtimeName: evidence.runtimeName,
|
|
898
|
-
source: evidence.source
|
|
899
|
-
};
|
|
900
|
-
return Object.freeze(record);
|
|
901
|
-
}
|
|
902
|
-
const metadata = item.metadata;
|
|
903
|
-
const record = {
|
|
904
|
-
agentId: metadata.agentId,
|
|
905
|
-
byteLength: metadata.byteLength,
|
|
906
|
-
canonicalDigest: metadata.canonicalDigest,
|
|
907
|
-
decisionId: metadata.decisionId,
|
|
908
|
-
digest: metadata.digest,
|
|
909
|
-
key: createRecordKey(order, "metadata", metadata.path, metadata.kind, metadata.agentId),
|
|
910
|
-
kind: "metadata",
|
|
911
|
-
metadataKind: metadata.kind,
|
|
912
|
-
path: metadata.path,
|
|
913
|
-
scalarLength: metadata.scalarLength
|
|
914
|
-
};
|
|
915
|
-
return Object.freeze(record);
|
|
916
|
-
};
|
|
917
|
-
/** Creates content-free validation metadata and ordered diagnostic records. */
|
|
918
|
-
var createMoldeaCliValidateProjection = (validation) => {
|
|
919
|
-
assertProjectValidationInvariant(validation);
|
|
920
|
-
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));
|
|
921
|
-
const snapshotDigest = calculateMoldeaCliJsonDigest({
|
|
922
|
-
diagnostics,
|
|
923
|
-
errorCount: validation.errorCount,
|
|
924
|
-
formatVersion: validation.formatVersion,
|
|
925
|
-
summary: validation.summary,
|
|
926
|
-
valid: validation.valid,
|
|
927
|
-
warningCount: validation.warningCount
|
|
928
|
-
});
|
|
929
|
-
return Object.freeze({
|
|
930
|
-
diagnostics,
|
|
931
|
-
errorCount: validation.errorCount,
|
|
932
|
-
formatVersion: validation.formatVersion,
|
|
933
|
-
snapshotDigest,
|
|
934
|
-
source: MOLDEA_CLI_GIT_WORKING_TREE_SOURCE,
|
|
935
|
-
valid: validation.valid,
|
|
936
|
-
warningCount: validation.warningCount
|
|
937
|
-
});
|
|
938
|
-
};
|
|
939
|
-
/** Projects one bounded Core page through the content-free schema 5 allowlist. */
|
|
940
|
-
var createMoldeaCliInspectProjection = (inspection) => {
|
|
941
|
-
const project = inspection.summary === null ? null : Object.freeze({
|
|
942
|
-
manifest: Object.freeze({
|
|
943
|
-
digest: inspection.summary.manifestDigest,
|
|
944
|
-
path: inspection.summary.manifestPath
|
|
945
|
-
}),
|
|
946
|
-
project: Object.freeze({
|
|
947
|
-
digest: inspection.summary.projectDigest,
|
|
948
|
-
path: inspection.summary.projectPath
|
|
949
|
-
})
|
|
950
|
-
});
|
|
951
|
-
const records = Object.freeze(inspection.page.records.map(({ item }, index) => createInspectRecord(item, index)));
|
|
952
|
-
const sourceCursors = new Map(inspection.page.records.map((record, index) => {
|
|
953
|
-
const projected = records[index];
|
|
954
|
-
if (projected === void 0) throw new TypeError("A projected inspection record is missing.");
|
|
955
|
-
return [projected.key, record.nextCursor];
|
|
956
|
-
}));
|
|
957
|
-
const snapshotDigest = inspection.inspectionDigest;
|
|
958
|
-
return Object.freeze({
|
|
959
|
-
counts: inspection.counts,
|
|
960
|
-
formatVersion: inspection.formatVersion,
|
|
961
|
-
getSourceCursor: (record) => sourceCursors.get(record.key) ?? null,
|
|
962
|
-
project,
|
|
963
|
-
records,
|
|
964
|
-
snapshotDigest,
|
|
965
|
-
source: MOLDEA_CLI_GIT_WORKING_TREE_SOURCE,
|
|
966
|
-
valid: inspection.valid,
|
|
967
|
-
view: inspection.view
|
|
968
|
-
});
|
|
969
|
-
};
|
|
970
|
-
//#endregion
|
|
971
45
|
//#region src/git-working-tree/constants.ts
|
|
972
46
|
var MAX_GIT_DISCOVERY_OUTPUT_BYTES = 262144;
|
|
973
47
|
//#endregion
|
|
@@ -1760,6 +834,9 @@ var CORE_OPERATION_ERROR_MESSAGES = Object.freeze({
|
|
|
1760
834
|
ADAPTER_EXECUTION_FAILED: "A runtime adapter failed during inspection.",
|
|
1761
835
|
CONTENT_INVALID: "The requested canonical content is invalid.",
|
|
1762
836
|
INVALID_ARGUMENT: "The Core operation received an invalid argument.",
|
|
837
|
+
INSPECTION_BUSY: "Project inspection capacity is busy. Try again shortly.",
|
|
838
|
+
INSPECTION_TIMEOUT: "The isolated project inspection timed out.",
|
|
839
|
+
INSPECTION_PROCESS_FAILED: "The isolated project inspection failed.",
|
|
1763
840
|
RESOURCE_LIMIT_EXCEEDED: "A Core resource limit was exceeded."
|
|
1764
841
|
});
|
|
1765
842
|
//#endregion
|
|
@@ -1774,7 +851,7 @@ var createCoreErrorDetails = (error) => {
|
|
|
1774
851
|
if (error.limit !== null) details["limit"] = error.limit;
|
|
1775
852
|
if (error.limitMaximum !== null) details["limitMaximum"] = error.limitMaximum;
|
|
1776
853
|
if (error.nextAction !== null) details["nextAction"] = error.nextAction;
|
|
1777
|
-
if (error.observedUsage !== null) details["observedUsage"] = error.observedUsage;
|
|
854
|
+
if (error.observedUsage !== null || error.nextAction === "review-inspection-capacity") details["observedUsage"] = error.observedUsage;
|
|
1778
855
|
}
|
|
1779
856
|
return Object.freeze(details);
|
|
1780
857
|
};
|
|
@@ -1784,7 +861,7 @@ var createCoreErrorDetails = (error) => {
|
|
|
1784
861
|
* @returns A complete immutable operational error without causes or private host data.
|
|
1785
862
|
*/
|
|
1786
863
|
var mapMoldeaCliOperationalError = (error) => {
|
|
1787
|
-
if (error instanceof MoldeaCliOutputPageException || error instanceof MoldeaCliProjectContentException || error instanceof MoldeaCliProjectScopeException) return createMoldeaCliOwnedError(error.code);
|
|
864
|
+
if (error instanceof MoldeaCliCompositionException || error instanceof MoldeaCliOutputPageException || error instanceof MoldeaCliProjectContentException || error instanceof MoldeaCliProjectScopeException) return createMoldeaCliOwnedError(error.code);
|
|
1788
865
|
if (error instanceof GitContentTransformUnsupportedException) return Object.freeze({
|
|
1789
866
|
...createMoldeaCliOwnedError("GIT_CONTENT_TRANSFORM_UNSUPPORTED"),
|
|
1790
867
|
path: isRepositoryPath(error.path) ? error.path : null
|
|
@@ -3324,6 +2401,7 @@ var createMoldeaCliValidateExecutionResult = (inspection, cliVersion, isJson, cu
|
|
|
3324
2401
|
page,
|
|
3325
2402
|
snapshotDigest: projection.snapshotDigest,
|
|
3326
2403
|
source: projection.source,
|
|
2404
|
+
runtimeInspection: projection.runtimeInspection,
|
|
3327
2405
|
valid: projection.valid,
|
|
3328
2406
|
warningCount: projection.warningCount
|
|
3329
2407
|
});
|
|
@@ -3360,6 +2438,7 @@ var createMoldeaCliInspectExecutionResult = (inspection, cliVersion, isJson, cur
|
|
|
3360
2438
|
project: projection.project,
|
|
3361
2439
|
snapshotDigest: projection.snapshotDigest,
|
|
3362
2440
|
source: projection.source,
|
|
2441
|
+
runtimeInspection: projection.runtimeInspection,
|
|
3363
2442
|
valid: projection.valid,
|
|
3364
2443
|
view: projection.view
|
|
3365
2444
|
});
|
|
@@ -3441,11 +2520,15 @@ var createMoldeaCliContentExecutionResult = (pageResult, cliVersion, isJson, cur
|
|
|
3441
2520
|
//#region src/cli-execution/command-executor.ts
|
|
3442
2521
|
/** Loads adapter-backed Core inspection only for commands that need it. */
|
|
3443
2522
|
var executeLazyCoreInspection = async (input) => {
|
|
3444
|
-
const { executeMoldeaCliCoreInspection } = await import("./chunks/core-composition-
|
|
2523
|
+
const { executeMoldeaCliCoreInspection } = await import("./chunks/core-composition-CWyDX8h6.js");
|
|
3445
2524
|
return executeMoldeaCliCoreInspection(input);
|
|
3446
2525
|
};
|
|
3447
2526
|
var loadInstalledComposition = async (input) => {
|
|
3448
|
-
|
|
2527
|
+
if (input.verifyRuntime === true) {
|
|
2528
|
+
const { inspectMoldeaCliComposition } = await import("./chunks/core-composition-CWyDX8h6.js");
|
|
2529
|
+
return inspectMoldeaCliComposition(input);
|
|
2530
|
+
}
|
|
2531
|
+
const { resolveInstalledMoldeaCliComposition } = await import("./chunks/composition-B1VCddjs.js");
|
|
3449
2532
|
return resolveInstalledMoldeaCliComposition(input);
|
|
3450
2533
|
};
|
|
3451
2534
|
/** Creates one operational error result without exposing caught failure details. */
|
|
@@ -3458,7 +2541,7 @@ var createOperationalErrorResult = (code, input) => createMoldeaCliErrorResult(c
|
|
|
3458
2541
|
* @param compositionLoader The installed executable-integrity composition boundary.
|
|
3459
2542
|
* @param projectScopeExecutor The adapter-free manifest scope operation.
|
|
3460
2543
|
* @param projectContentExecutor The adapter-free canonical content operation.
|
|
3461
|
-
* @returns A command executor for the schema
|
|
2544
|
+
* @returns A command executor for the schema 6 CLI.
|
|
3462
2545
|
*/
|
|
3463
2546
|
var createMoldeaCliCommandExecutor = (workingTreeDiscovery = discoverGitWorkingTree, workingTreeSnapshotExecutor = executeWorkingTreeSnapshot, coreInspectionExecutor = executeLazyCoreInspection, compositionLoader = loadInstalledComposition, projectScopeExecutor = executeMoldeaCliProjectScope, projectContentExecutor = executeMoldeaCliProjectContent) => {
|
|
3464
2547
|
return async (input) => {
|
|
@@ -3466,7 +2549,11 @@ var createMoldeaCliCommandExecutor = (workingTreeDiscovery = discoverGitWorkingT
|
|
|
3466
2549
|
const options = input.invocation.options;
|
|
3467
2550
|
try {
|
|
3468
2551
|
if (command === MOLDEA_CLI_COMMANDS.Composition || command === MOLDEA_CLI_COMMANDS.Inspect || command === MOLDEA_CLI_COMMANDS.Validate) {
|
|
3469
|
-
const compositionResolution = await compositionLoader({
|
|
2552
|
+
const compositionResolution = await compositionLoader({
|
|
2553
|
+
packageMetadata: input.packageMetadata,
|
|
2554
|
+
verifyRuntime: command === MOLDEA_CLI_COMMANDS.Composition,
|
|
2555
|
+
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
2556
|
+
});
|
|
3470
2557
|
if (compositionResolution.kind === "invalid") return createOperationalErrorResult("COMPOSITION_STATE_INVALID", input);
|
|
3471
2558
|
if (command === MOLDEA_CLI_COMMANDS.Composition) return createMoldeaCliCompositionExecutionResult(compositionResolution.result, input.packageMetadata.version, options.isJson);
|
|
3472
2559
|
}
|
|
@@ -3525,6 +2612,7 @@ var createMoldeaCliCommandExecutor = (workingTreeDiscovery = discoverGitWorkingT
|
|
|
3525
2612
|
...signal === void 0 ? {} : { signal }
|
|
3526
2613
|
});
|
|
3527
2614
|
return coreInspectionExecutor({
|
|
2615
|
+
packageMetadata: input.packageMetadata,
|
|
3528
2616
|
command: command === MOLDEA_CLI_COMMANDS.Inspect ? "inspect" : "validate",
|
|
3529
2617
|
...inspectionCursor === null ? {} : { cursor: inspectionCursor },
|
|
3530
2618
|
repository,
|
|
@@ -3680,7 +2768,11 @@ var PROCESS_SIGNAL_SOURCE = Object.freeze({
|
|
|
3680
2768
|
},
|
|
3681
2769
|
removeListener: (signal, listener) => {
|
|
3682
2770
|
process.off(signal, listener);
|
|
3683
|
-
}
|
|
2771
|
+
},
|
|
2772
|
+
closeIpc: () => {
|
|
2773
|
+
if (process.connected) process.disconnect();
|
|
2774
|
+
},
|
|
2775
|
+
hasDisconnectedLauncher: () => typeof process.send === "function" && !process.connected
|
|
3684
2776
|
});
|
|
3685
2777
|
/**
|
|
3686
2778
|
* Creates one process-signal session around an operation-scoped abort controller.
|
|
@@ -3699,8 +2791,11 @@ var createMoldeaCliProcessSignalSession = (signalSource = PROCESS_SIGNAL_SOURCE)
|
|
|
3699
2791
|
};
|
|
3700
2792
|
const handleSigint = () => handleSignal("SIGINT");
|
|
3701
2793
|
const handleSigterm = () => handleSignal("SIGTERM");
|
|
2794
|
+
const handleDisconnect = () => handleSignal("SIGTERM");
|
|
3702
2795
|
signalSource.addListener("SIGINT", handleSigint);
|
|
3703
2796
|
signalSource.addListener("SIGTERM", handleSigterm);
|
|
2797
|
+
signalSource.addListener("disconnect", handleDisconnect);
|
|
2798
|
+
if (signalSource.hasDisconnectedLauncher()) handleDisconnect();
|
|
3704
2799
|
return Object.freeze({
|
|
3705
2800
|
completeOutput: () => {
|
|
3706
2801
|
isOutputComplete = true;
|
|
@@ -3710,6 +2805,8 @@ var createMoldeaCliProcessSignalSession = (signalSource = PROCESS_SIGNAL_SOURCE)
|
|
|
3710
2805
|
isDisposed = true;
|
|
3711
2806
|
signalSource.removeListener("SIGINT", handleSigint);
|
|
3712
2807
|
signalSource.removeListener("SIGTERM", handleSigterm);
|
|
2808
|
+
signalSource.removeListener("disconnect", handleDisconnect);
|
|
2809
|
+
signalSource.closeIpc();
|
|
3713
2810
|
},
|
|
3714
2811
|
get exitCode() {
|
|
3715
2812
|
return exitCode;
|