@moldea.ai/cli 5.0.2 → 6.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/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$1 from "node:process";
4
+ import process from "node:process";
4
5
  import { fileURLToPath } from "node:url";
5
- import { CoreConfigurationException, CoreOperationException, SUPPORTED_REPOSITORY_FORMAT_VERSIONS, createCore } from "@moldea.ai/core";
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";
8
+ import { CoreConfigurationException, CoreOperationException, createCore } from "@moldea.ai/core";
19
9
  import { REPOSITORY_ROOT, RepositorySourceException, 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,209 @@ 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
+ "version"
132
+ ]);
133
+ /** Calculates one stable SHA-256 identifier for deterministic JSON text. */
134
+ var calculateMoldeaCliJsonDigest = (value) => {
135
+ return `sha256:${createHash("sha256").update(serializeJsonDeterministically(value), "utf8").digest("hex")}`;
136
+ };
137
+ /** Calculates the checksum for one cursor payload without its checksum field. */
138
+ var calculateCursorChecksum = (payload) => {
139
+ return calculateMoldeaCliJsonDigest(payload);
140
+ };
141
+ /** Compares fixed-format checksums without data-dependent early termination. */
142
+ var areChecksumsEqual = (left, right) => {
143
+ const leftBytes = Buffer.from(left, "utf8");
144
+ const rightBytes = Buffer.from(right, "utf8");
145
+ return leftBytes.length === rightBytes.length && timingSafeEqual(leftBytes, rightBytes);
146
+ };
147
+ /** Determines whether an unknown value is one strict cursor document. */
148
+ var isCursorDocument = (value) => {
149
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
150
+ const record = value;
151
+ const keys = Object.keys(record).sort();
152
+ return keys.length === CURSOR_DOCUMENT_KEYS.length && keys.every((key, index) => key === CURSOR_DOCUMENT_KEYS[index]) && record["version"] === 1 && (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 && typeof record["snapshotDigest"] === "string" && SHA256_PATTERN.test(record["snapshotDigest"]) && typeof record["checksum"] === "string" && SHA256_PATTERN.test(record["checksum"]);
153
+ };
154
+ /** Encodes one command-, filter-, and snapshot-bound continuation cursor. */
155
+ var encodeMoldeaCliCursor = (command, filters, snapshotDigest, lastKey) => {
156
+ const payload = {
157
+ command,
158
+ filtersDigest: calculateMoldeaCliJsonDigest(filters),
159
+ lastKey,
160
+ snapshotDigest,
161
+ version: 1
162
+ };
163
+ const document = {
164
+ ...payload,
165
+ checksum: calculateCursorChecksum(payload)
166
+ };
167
+ return Buffer.from(serializeJsonDeterministically(document), "utf8").toString("base64url");
168
+ };
169
+ /**
170
+ * Decodes and validates one opaque continuation cursor.
171
+ * @param input The current command state and untrusted cursor.
172
+ * @returns The validated last composite record key.
173
+ * @throws
174
+ * - CURSOR_INVALID: The continuation cursor is invalid for this request.
175
+ * - CURSOR_SNAPSHOT_CHANGED: The continuation cursor belongs to a different repository snapshot.
176
+ */
177
+ var decodeMoldeaCliCursor = (input) => {
178
+ let decoded;
179
+ try {
180
+ if (!BASE64URL_PATTERN.test(input.cursor)) throw new TypeError("The cursor is not canonical base64url.");
181
+ const bytes = Buffer.from(input.cursor, "base64url");
182
+ if (bytes.toString("base64url") !== input.cursor) throw new TypeError("The cursor is not canonical base64url.");
183
+ const text = bytes.toString("utf8");
184
+ decoded = JSON.parse(text);
185
+ } catch {
186
+ throw new MoldeaCliOutputPageException("CURSOR_INVALID");
187
+ }
188
+ if (!isCursorDocument(decoded)) throw new MoldeaCliOutputPageException("CURSOR_INVALID");
189
+ const { checksum, ...payload } = decoded;
190
+ if (!areChecksumsEqual(checksum, calculateCursorChecksum(payload)) || decoded.command !== input.command || decoded.filtersDigest !== calculateMoldeaCliJsonDigest(input.filters)) throw new MoldeaCliOutputPageException("CURSOR_INVALID");
191
+ if (decoded.snapshotDigest !== input.snapshotDigest) throw new MoldeaCliOutputPageException("CURSOR_SNAPSHOT_CHANGED");
192
+ return Object.freeze({ lastKey: decoded.lastKey });
193
+ };
194
+ //#endregion
195
+ //#region src/output-page/page.ts
196
+ /** Ensures records have unique keys in strict ascending order. */
197
+ var assertRecordOrder = (records) => {
198
+ for (let index = 0; index < records.length; index += 1) {
199
+ const key = records[index]?.key;
200
+ const previousKey = records[index - 1]?.key;
201
+ if (key === void 0 || key.length === 0 || previousKey !== void 0 && key <= previousKey) throw new TypeError("Output records must have unique keys in ascending order.");
202
+ }
203
+ };
204
+ /**
205
+ * Selects the largest exact serialized output page that fits its byte budget.
206
+ * @param input Ordered records, continuation state, and an exact final-document measurement.
207
+ * @returns A frozen record page with a snapshot-bound continuation cursor when needed.
208
+ * @throws
209
+ * - CURSOR_INVALID: The continuation cursor is invalid for this request.
210
+ * - CURSOR_SNAPSHOT_CHANGED: The continuation cursor belongs to a different repository snapshot.
211
+ * - OUTPUT_BUDGET_TOO_SMALL: The output byte budget cannot contain the next complete result.
212
+ */
213
+ var createMoldeaCliOutputPage = (input) => {
214
+ assertRecordOrder(input.records);
215
+ const cursorState = input.cursor === null ? null : decodeMoldeaCliCursor({
216
+ command: input.command,
217
+ cursor: input.cursor,
218
+ filters: input.filters,
219
+ snapshotDigest: input.snapshotDigest
220
+ });
221
+ const startIndex = cursorState === null ? 0 : input.records.findIndex(({ key }) => key === cursorState.lastKey) + 1;
222
+ if (cursorState !== null && startIndex === 0) throw new MoldeaCliOutputPageException("CURSOR_INVALID");
223
+ const emptyRecords = Object.freeze([]);
224
+ const emptyPage = Object.freeze({
225
+ cursor: null,
226
+ records: emptyRecords
227
+ });
228
+ if (startIndex === input.records.length) {
229
+ if (input.measure(emptyPage, 2) > input.maxOutputBytes) throw new MoldeaCliOutputPageException("OUTPUT_BUDGET_TOO_SMALL");
230
+ return emptyPage;
231
+ }
232
+ const selectedRecords = [];
233
+ let selectedCursor = null;
234
+ let serializedRecordsUtf8Bytes = 2;
235
+ for (let endIndex = startIndex + 1; endIndex <= input.records.length; endIndex += 1) {
236
+ const record = input.records[endIndex - 1];
237
+ if (record === void 0) throw new TypeError("An output page record is missing.");
238
+ const serializedRecordUtf8Bytes = Buffer.byteLength(serializeJsonDeterministically(record), "utf8");
239
+ serializedRecordsUtf8Bytes += serializedRecordUtf8Bytes + (endIndex > startIndex + 1 ? 1 : 0);
240
+ selectedRecords.push(record);
241
+ const cursor = endIndex < input.records.length ? encodeMoldeaCliCursor(input.command, input.filters, input.snapshotDigest, record.key) : null;
242
+ const candidate = Object.freeze({
243
+ cursor,
244
+ records: selectedRecords
245
+ });
246
+ if (input.measure(candidate, serializedRecordsUtf8Bytes) > input.maxOutputBytes) {
247
+ selectedRecords.pop();
248
+ break;
249
+ }
250
+ selectedCursor = cursor;
251
+ }
252
+ if (selectedRecords.length === 0) throw new MoldeaCliOutputPageException("OUTPUT_BUDGET_TOO_SMALL");
253
+ return Object.freeze({
254
+ cursor: selectedCursor,
255
+ records: Object.freeze([...selectedRecords])
256
+ });
257
+ };
62
258
  //#endregion
63
259
  //#region src/command-line/validations.ts
64
260
  var POSITIVE_INTEGER_PATTERN = /^\d+$/u;
@@ -91,6 +287,11 @@ var parsePositiveSafeInteger = (input) => {
91
287
  const parsedInteger = Number(input);
92
288
  return Number.isSafeInteger(parsedInteger) && parsedInteger > 0 ? parsedInteger : null;
93
289
  };
290
+ /** Parses one output byte budget inside the schema 3 transport bounds. */
291
+ var parseMoldeaCliOutputByteLimit = (input) => {
292
+ const parsed = parsePositiveSafeInteger(input);
293
+ return parsed !== null && parsed >= 4096 && parsed <= 1048576 ? parsed : null;
294
+ };
94
295
  /**
95
296
  * Validates the cross-limit ordering required by the CLI composition.
96
297
  * @param limits The effective resource limits.
@@ -107,6 +308,10 @@ var areMoldeaCliResourceLimitsConsistent = (limits) => {
107
308
  var isRepositoryDirectoryInputValid = (input) => {
108
309
  return input.length > 0 && !input.includes("\0") && hasOnlyUnicodeScalarValues$1(input);
109
310
  };
311
+ /** Determines whether one opaque cursor token is bounded safe scalar text. */
312
+ var isMoldeaCliCursorInputValid = (input) => {
313
+ return input.length > 0 && input.length <= 16384 && !input.includes("\0") && hasOnlyUnicodeScalarValues$1(input);
314
+ };
110
315
  //#endregion
111
316
  //#region src/command-line/parser.ts
112
317
  var COMMAND_NAMES = new Set(Object.values(MOLDEA_CLI_COMMANDS));
@@ -128,7 +333,7 @@ var isMoldeaCliCommand = (input) => {
128
333
  return input !== void 0 && COMMAND_NAMES.has(input);
129
334
  };
130
335
  /**
131
- * Parses the complete version 1 command grammar without mutating caller arguments.
336
+ * Parses the complete schema 3 command grammar without mutating caller arguments.
132
337
  * @param commandLineArguments The process arguments after the executable path.
133
338
  * @returns A normalized command, informational request, or safe invocation error.
134
339
  */
@@ -153,6 +358,10 @@ var parseMoldeaCliArguments = (commandLineArguments) => {
153
358
  const seenOptions = /* @__PURE__ */ new Set();
154
359
  const resourceLimits = { ...DEFAULT_MOLDEA_CLI_RESOURCE_LIMITS };
155
360
  let isColorDisabled = false;
361
+ let cursor = null;
362
+ let maxOutputBytes = MOLDEA_CLI_DEFAULT_OUTPUT_BYTES;
363
+ let path = null;
364
+ let pathsInput = "none";
156
365
  let repositoryDirectory = null;
157
366
  for (let index = 1; index < commandLineArguments.length; index += 1) {
158
367
  const option = commandLineArguments[index];
@@ -163,14 +372,38 @@ var parseMoldeaCliArguments = (commandLineArguments) => {
163
372
  isColorDisabled = true;
164
373
  continue;
165
374
  }
375
+ if (option === MOLDEA_CLI_OPTIONS.PathsStdin) {
376
+ pathsInput = "stdin";
377
+ continue;
378
+ }
166
379
  if (option === MOLDEA_CLI_OPTIONS.Help || option === MOLDEA_CLI_OPTIONS.Version) return createArgumentError("INVALID_ARGUMENT", command, isJson);
167
380
  const resourceField = RESOURCE_OPTION_FIELDS[option];
168
381
  const isRepositoryOption = option === MOLDEA_CLI_OPTIONS.Repository;
169
- if (resourceField === void 0 && !isRepositoryOption) return createArgumentError("INVALID_ARGUMENT", command, isJson);
382
+ const isCursorOption = option === MOLDEA_CLI_OPTIONS.Cursor;
383
+ const isOutputLimitOption = option === MOLDEA_CLI_OPTIONS.MaxOutputBytes;
384
+ const isPathOption = option === MOLDEA_CLI_OPTIONS.Path;
385
+ if (resourceField === void 0 && !isRepositoryOption && !isCursorOption && !isOutputLimitOption && !isPathOption) return createArgumentError("INVALID_ARGUMENT", command, isJson);
170
386
  if (command === MOLDEA_CLI_COMMANDS.Composition) return createArgumentError("INVALID_ARGUMENT", command, isJson);
171
387
  const optionValue = commandLineArguments[index + 1];
172
388
  if (optionValue === void 0 || optionValue.startsWith("--")) return createArgumentError("INVALID_ARGUMENT", command, isJson);
173
389
  index += 1;
390
+ if (isCursorOption) {
391
+ if (!isMoldeaCliCursorInputValid(optionValue)) return createArgumentError("INVALID_ARGUMENT", command, isJson);
392
+ cursor = optionValue;
393
+ continue;
394
+ }
395
+ if (isOutputLimitOption) {
396
+ const parsedOutputLimit = parseMoldeaCliOutputByteLimit(optionValue);
397
+ if (parsedOutputLimit === null) return createArgumentError("RESOURCE_LIMIT_CONFIGURATION_INVALID", command, isJson);
398
+ maxOutputBytes = parsedOutputLimit;
399
+ continue;
400
+ }
401
+ if (isPathOption) {
402
+ if (!isRepositoryDirectoryInputValid(optionValue)) return createArgumentError("INVALID_ARGUMENT", command, isJson);
403
+ path = optionValue;
404
+ pathsInput = "path";
405
+ continue;
406
+ }
174
407
  if (isRepositoryOption) {
175
408
  if (!isRepositoryDirectoryInputValid(optionValue)) return createArgumentError("INVALID_ARGUMENT", command, isJson);
176
409
  repositoryDirectory = optionValue;
@@ -181,9 +414,27 @@ var parseMoldeaCliArguments = (commandLineArguments) => {
181
414
  resourceLimits[resourceField] = parsedLimit;
182
415
  }
183
416
  if (!areMoldeaCliResourceLimitsConsistent(resourceLimits)) return createArgumentError("RESOURCE_LIMIT_CONFIGURATION_INVALID", command, isJson);
417
+ const isScope = command === MOLDEA_CLI_COMMANDS.Scope;
418
+ const isContent = command === MOLDEA_CLI_COMMANDS.Content;
419
+ const hasPathInput = path !== null;
420
+ const hasStdinInput = seenOptions.has(MOLDEA_CLI_OPTIONS.PathsStdin);
421
+ if ((hasPathInput || hasStdinInput) && !isScope && !isContent) return createArgumentError("INVALID_ARGUMENT", command, isJson);
422
+ if (isScope && hasPathInput === hasStdinInput) return createArgumentError("INVALID_ARGUMENT", command, isJson);
423
+ if (isContent && (!hasPathInput || hasStdinInput)) return createArgumentError("INVALID_ARGUMENT", command, isJson);
424
+ if (isScope && seenOptions.has(MOLDEA_CLI_OPTIONS.MaxEvidence)) return createArgumentError("INVALID_ARGUMENT", command, isJson);
425
+ if (isContent && [
426
+ MOLDEA_CLI_OPTIONS.MaxDiagnostics,
427
+ MOLDEA_CLI_OPTIONS.MaxEvidence,
428
+ MOLDEA_CLI_OPTIONS.MaxManifestBytes
429
+ ].some((option) => seenOptions.has(option))) return createArgumentError("INVALID_ARGUMENT", command, isJson);
430
+ if (!isJson && (cursor !== null || seenOptions.has(MOLDEA_CLI_OPTIONS.MaxOutputBytes))) return createArgumentError("INVALID_ARGUMENT", command, isJson);
184
431
  const options = {
432
+ cursor,
185
433
  isColorDisabled,
186
434
  isJson,
435
+ maxOutputBytes,
436
+ path,
437
+ pathsInput,
187
438
  repositoryDirectory,
188
439
  resourceLimits: Object.freeze({ ...resourceLimits })
189
440
  };
@@ -203,6 +454,26 @@ var MOLDEA_CLI_ERROR_DEFINITIONS = Object.freeze({
203
454
  retryable: false,
204
455
  source: "cli"
205
456
  }),
457
+ CONTENT_INVALID: Object.freeze({
458
+ message: "The requested canonical asset is not valid moldea text.",
459
+ retryable: false,
460
+ source: "cli"
461
+ }),
462
+ CONTENT_PATH_INVALID: Object.freeze({
463
+ message: "The content path must identify one canonical moldea text asset.",
464
+ retryable: false,
465
+ source: "cli"
466
+ }),
467
+ CURSOR_INVALID: Object.freeze({
468
+ message: "The continuation cursor is invalid for this request.",
469
+ retryable: false,
470
+ source: "cli"
471
+ }),
472
+ CURSOR_SNAPSHOT_CHANGED: Object.freeze({
473
+ message: "The continuation cursor belongs to a different repository snapshot.",
474
+ retryable: true,
475
+ source: "cli"
476
+ }),
206
477
  GIT_ACCESS_DENIED: Object.freeze({
207
478
  message: "Git access was denied.",
208
479
  retryable: true,
@@ -268,6 +539,16 @@ var MOLDEA_CLI_ERROR_DEFINITIONS = Object.freeze({
268
539
  retryable: false,
269
540
  source: "cli"
270
541
  }),
542
+ OUTPUT_BUDGET_TOO_SMALL: Object.freeze({
543
+ message: "The output byte budget cannot contain the next complete result.",
544
+ retryable: false,
545
+ source: "cli"
546
+ }),
547
+ PATH_INPUT_INVALID: Object.freeze({
548
+ message: "The NUL-delimited changed-path input is invalid.",
549
+ retryable: false,
550
+ source: "cli"
551
+ }),
271
552
  RESOURCE_LIMIT_CONFIGURATION_INVALID: Object.freeze({
272
553
  message: "The resource-limit configuration is invalid.",
273
554
  retryable: false,
@@ -289,7 +570,9 @@ var MOLDEA_CLI_TOP_LEVEL_HELP = `Usage: moldea <command> [options]
289
570
 
290
571
  Commands:
291
572
  validate Validate the current moldea project.
292
- inspect Inspect the current moldea project.
573
+ inspect Inspect content-free project metadata.
574
+ scope Match changed paths to declared moldea relationships.
575
+ content Read one canonical moldea asset explicitly.
293
576
  composition Report the installed CLI composition state.
294
577
 
295
578
  Global options:
@@ -298,18 +581,24 @@ Global options:
298
581
 
299
582
  Run "moldea <command> --help" for command-specific options.
300
583
  `;
301
- var INSPECTION_OPTIONS_HELP = `Options:
302
- --repository <path> Select a Git working-tree directory.
584
+ var REPOSITORY_OPTIONS_HELP = ` --repository <path> Select a Git working-tree directory.
303
585
  --json Emit one machine-readable JSON result.
304
586
  --no-color Disable ANSI styling in human output.
305
- --max-entries <integer> Override the repository entry limit.
587
+ `;
588
+ var BASE_RESOURCE_OPTIONS_HELP = ` --max-entries <integer> Override the repository entry limit.
306
589
  --max-file-bytes <integer> Override the per-file byte limit.
307
590
  --max-total-bytes <integer> Override the total cached-byte limit.
308
- --max-manifest-bytes <integer> Override the manifest byte limit.
591
+ `;
592
+ var INSPECTION_RESOURCE_OPTIONS_HELP = `${BASE_RESOURCE_OPTIONS_HELP} --max-manifest-bytes <integer> Override the manifest byte limit.
309
593
  --max-diagnostics <integer> Override the diagnostic count limit.
310
- --max-evidence <integer> Override the adapter evidence count limit.
311
- --help Show this help.
312
594
  `;
595
+ var PAGINATION_OPTIONS_HELP = ` --max-output-bytes <integer> Bound JSON output from 4096 to 1048576 bytes.
596
+ --cursor <opaque-cursor> Continue a prior JSON result page.
597
+ `;
598
+ var COMPLETE_INSPECTION_OPTIONS_HELP = `${REPOSITORY_OPTIONS_HELP}${INSPECTION_RESOURCE_OPTIONS_HELP} --max-evidence <integer> Override the adapter evidence count limit.
599
+ ${PAGINATION_OPTIONS_HELP}`;
600
+ var SCOPE_OPTIONS_HELP = `${REPOSITORY_OPTIONS_HELP}${INSPECTION_RESOURCE_OPTIONS_HELP}${PAGINATION_OPTIONS_HELP}`;
601
+ var CONTENT_OPTIONS_HELP = `${REPOSITORY_OPTIONS_HELP}${BASE_RESOURCE_OPTIONS_HELP}${PAGINATION_OPTIONS_HELP}`;
313
602
  var MOLDEA_CLI_COMMAND_HELP = {
314
603
  [MOLDEA_CLI_COMMANDS.Composition]: `Usage: moldea composition [options]
315
604
 
@@ -322,14 +611,35 @@ Options:
322
611
  `,
323
612
  [MOLDEA_CLI_COMMANDS.Inspect]: `Usage: moldea inspect [options]
324
613
 
325
- Inspect the current moldea project.
614
+ Inspect content-free metadata for the current moldea project.
615
+
616
+ Options:
617
+ ${COMPLETE_INSPECTION_OPTIONS_HELP} --help Show this help.
618
+ `,
619
+ [MOLDEA_CLI_COMMANDS.Scope]: `Usage: moldea scope (--path <logical-path> | --paths-stdin) [options]
620
+
621
+ Match changed repository paths to declared moldea relationships. The stdin form accepts NUL-delimited UTF-8 logical paths.
622
+
623
+ Options:
624
+ ${SCOPE_OPTIONS_HELP} --path <logical-path> Match one repository-logical path.
625
+ --paths-stdin Read NUL-delimited paths from stdin.
626
+ --help Show this help.
627
+ `,
628
+ [MOLDEA_CLI_COMMANDS.Content]: `Usage: moldea content --path <canonical-logical-path> [options]
629
+
630
+ Read one canonical moldea text asset in bounded Unicode-safe chunks.
326
631
 
327
- ${INSPECTION_OPTIONS_HELP}`,
632
+ Options:
633
+ ${CONTENT_OPTIONS_HELP} --path <canonical-logical-path> Select exactly one canonical moldea file.
634
+ --help Show this help.
635
+ `,
328
636
  [MOLDEA_CLI_COMMANDS.Validate]: `Usage: moldea validate [options]
329
637
 
330
638
  Validate the current moldea project.
331
639
 
332
- ${INSPECTION_OPTIONS_HELP}`
640
+ Options:
641
+ ${COMPLETE_INSPECTION_OPTIONS_HELP} --help Show this help.
642
+ `
333
643
  };
334
644
  //#endregion
335
645
  //#region src/presentation/errors.ts
@@ -351,58 +661,42 @@ var createMoldeaCliOwnedError = (code) => {
351
661
  });
352
662
  };
353
663
  //#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(",")}]`;
664
+ //#region src/json-output-contract/document.ts
665
+ /** Creates one strict schema 3 JSON envelope. */
666
+ var createMoldeaCliJsonEnvelope = (input) => Object.freeze({
667
+ cliVersion: input.cliVersion,
668
+ command: input.command,
669
+ error: input.error,
670
+ result: input.result,
671
+ schemaVersion: 3,
672
+ status: input.status
673
+ });
674
+ /** Serializes one schema 3 envelope with its required trailing line feed. */
675
+ var serializeMoldeaCliJsonEnvelope = (input) => `${serializeJsonDeterministically(createMoldeaCliJsonEnvelope(input))}\n`;
676
+ //#endregion
677
+ //#region src/json-output-contract/guard.ts
678
+ /** Rejects canonical bodies and content fields from a non-content JSON result. */
679
+ var assertMoldeaCliJsonResultIsContentFree = (value, canonicalBodies = []) => {
680
+ const pending = [value];
681
+ const visited = /* @__PURE__ */ new Set();
682
+ const bodies = new Set(canonicalBodies.filter((body) => body.length > 0));
683
+ while (pending.length > 0) {
684
+ const current = pending.pop();
685
+ if (typeof current === "string") {
686
+ if (bodies.has(current)) throw new TypeError("A non-content CLI result contains canonical document text.");
687
+ continue;
386
688
  }
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);
689
+ if (typeof current !== "object" || current === null || visited.has(current)) continue;
690
+ visited.add(current);
691
+ if (Array.isArray(current)) {
692
+ for (const item of current) pending.push(item);
693
+ continue;
694
+ }
695
+ const record = current;
696
+ if (Object.hasOwn(record, "content")) throw new TypeError("A non-content CLI result contains a content property.");
697
+ pending.push(...Object.values(record));
394
698
  }
395
699
  };
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
700
  //#endregion
407
701
  //#region src/presentation/formatters.ts
408
702
  var DIAGNOSTIC_ENTITY_KEYS = [
@@ -418,7 +712,7 @@ var formatMoldeaCliHumanDiagnosticEntity = (entity) => DIAGNOSTIC_ENTITY_KEYS.fl
418
712
  const identifier = entity[key];
419
713
  return identifier === void 0 ? [] : [`${key}=${identifier}`];
420
714
  }).join(", ");
421
- /** Formats one Core or adapter diagnostic without changing its order or meaning. */
715
+ /** Formats one projected diagnostic without exposing omitted arbitrary details. */
422
716
  var formatMoldeaCliHumanDiagnostic = (diagnostic) => {
423
717
  const location = diagnostic.path === null ? "" : diagnostic.range === null ? ` ${diagnostic.path}` : ` ${diagnostic.path}:${diagnostic.range.start.line}:${diagnostic.range.start.column}`;
424
718
  const lines = [`${diagnostic.source}:${diagnostic.code}${location} ${diagnostic.message}`];
@@ -426,2147 +720,374 @@ var formatMoldeaCliHumanDiagnostic = (diagnostic) => {
426
720
  if (diagnostic.entity !== null) lines.push(` entity: ${formatMoldeaCliHumanDiagnosticEntity(diagnostic.entity)}`);
427
721
  return lines.join("\n");
428
722
  };
429
- /** Creates the shared human summary lines for one completed inspection state. */
723
+ /** Creates shared human status lines for one completed repository command. */
430
724
  var createMoldeaCliHumanStatusLines = (isValid, formatVersion) => {
431
725
  const lines = [`The moldea project is ${isValid ? "valid" : "invalid"}.`];
432
726
  if (formatVersion !== null) lines.push(`Repository format: ${formatVersion}`);
433
727
  return lines;
434
728
  };
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
729
  /** Formats one count label with correct singular or plural grammar. */
442
730
  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
- */
731
+ /** Formats top-level or command-specific help with its required trailing line feed. */
448
732
  var formatMoldeaCliHelp = (command) => {
449
- if (command === null) return MOLDEA_CLI_TOP_LEVEL_HELP;
450
- return MOLDEA_CLI_COMMAND_HELP[command];
733
+ return command === null ? MOLDEA_CLI_TOP_LEVEL_HELP : MOLDEA_CLI_COMMAND_HELP[command];
451
734
  };
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
- */
735
+ /** Formats one safe CLI error for human stderr output. */
457
736
  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
- */
737
+ /** Formats any strict schema 3 JSON envelope. */
738
+ var formatMoldeaCliJsonResult = (command, result, error, status, cliVersion) => serializeMoldeaCliJsonEnvelope({
739
+ cliVersion,
740
+ command,
741
+ error,
742
+ result,
743
+ status
744
+ });
745
+ /** Formats one safe schema 3 JSON error envelope. */
746
+ var formatMoldeaCliJsonError = (error, command, cliVersion) => formatMoldeaCliJsonResult(command, null, error, "error", cliVersion);
747
+ /** Formats one valid composition result for human stdout. */
481
748
  var formatMoldeaCliHumanCompositionResult = (result, cliVersion) => {
482
- const lines = [
749
+ return `${[
483
750
  "The installed CLI composition state is valid.",
484
751
  `CLI version: ${cliVersion}`,
485
752
  `Supported Node.js: ${result.supportedNodeRange}`,
486
- `JSON output schema: 2`,
753
+ `JSON output schema: 3`,
487
754
  `Minimum Git: ${result.minimumGitVersion}`,
488
755
  `Repository formats: ${result.repositoryFormatVersions.join(", ")}`,
489
756
  "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;
757
+ ...result.packages.map(({ name, version }) => ` ${name}: ${version}`),
758
+ "Adapters:",
759
+ ...result.adapters.map(({ id, repositoryFormatVersions }) => ` ${id}: repository formats ${repositoryFormatVersions.join(", ")}`)
760
+ ].join("\n")}\n`;
2183
761
  };
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
- });
762
+ /** Formats one composition result in the strict schema 3 envelope. */
763
+ var formatMoldeaCliJsonCompositionResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Composition, result, null, "valid", cliVersion);
764
+ /** Formats one completed validation result for human stdout. */
765
+ var formatMoldeaCliHumanValidateResult = (result) => {
766
+ const lines = createMoldeaCliHumanStatusLines(result.diagnosticCount === 0, result.formatVersion);
767
+ for (const diagnostic of result.page.records) lines.push(formatMoldeaCliHumanDiagnostic(diagnostic));
768
+ lines.push(formatMoldeaCliHumanCount(result.diagnosticCount, "Diagnostic", "Diagnostics"));
769
+ if (result.page.cursor !== null) lines.push("Additional diagnostics are available through JSON pagination.");
770
+ return `${lines.join("\n")}\n`;
2211
771
  };
772
+ /** Formats one validation result in the strict schema 3 envelope. */
773
+ var formatMoldeaCliJsonValidateResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Validate, result, null, result.diagnosticCount === 0 ? "valid" : "invalid", cliVersion);
774
+ /** Formats one completed metadata inspection for human stdout. */
775
+ var formatMoldeaCliHumanInspectResult = (result) => {
776
+ const lines = createMoldeaCliHumanStatusLines(result.project !== null && result.counts.diagnostics === 0, result.formatVersion);
777
+ for (const [label, count] of Object.entries(result.counts)) lines.push(`${label}: ${count}`);
778
+ return `${lines.join("\n")}\n`;
779
+ };
780
+ /** Formats one metadata inspection in the strict schema 3 envelope. */
781
+ var formatMoldeaCliJsonInspectResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Inspect, result, null, result.project !== null && result.counts.diagnostics === 0 ? "valid" : "invalid", cliVersion);
782
+ /** Formats one changed-path scope result for human stdout. */
783
+ var formatMoldeaCliHumanScopeResult = (result) => {
784
+ return `${[
785
+ `The moldea scope result is ${result.valid ? "valid" : "invalid"}.`,
786
+ `Relevant: ${result.relevant ? "yes" : "no"}`,
787
+ ...Object.entries(result.counts).map(([label, count]) => `${label}: ${count}`)
788
+ ].join("\n")}\n`;
789
+ };
790
+ /** Formats one changed-path scope result in the strict schema 3 envelope. */
791
+ var formatMoldeaCliJsonScopeResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Scope, result, null, result.valid ? "valid" : "invalid", cliVersion);
792
+ /** Formats one explicit canonical content chunk for human stdout. */
793
+ var formatMoldeaCliHumanContentResult = (result) => {
794
+ return `${[
795
+ `Path: ${result.asset.path}`,
796
+ `Digest: ${result.asset.digest}`,
797
+ `Scalars: ${result.chunk.scalarStart}-${result.chunk.scalarEnd} of ${result.asset.scalarLength}`,
798
+ result.cursor === null ? "Cursor: none" : `Cursor: ${result.cursor}`,
799
+ ...result.cursor === null ? [] : ["Continue this asset by passing the cursor to a JSON content request."],
800
+ "",
801
+ result.chunk.content
802
+ ].join("\n")}\n`;
803
+ };
804
+ /** Formats one explicit canonical content chunk in the strict schema 3 envelope. */
805
+ var formatMoldeaCliJsonContentResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Content, result, null, "valid", cliVersion);
2212
806
  //#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));
807
+ //#region src/presentation/transformers.ts
808
+ /** Rejects a Core result whose completion fields contradict its validity. */
809
+ var assertProjectInspectionInvariant = (inspection) => {
810
+ const hasDiagnostics = inspection.diagnostics.length > 0;
811
+ const hasProject = inspection.project !== null;
812
+ if (!(inspection.valid ? hasProject && !hasDiagnostics : !hasProject && hasDiagnostics)) throw new TypeError("The Core inspection result is internally inconsistent.");
2274
813
  };
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
814
+ /** Creates one stable composite key without exposing cursor internals. */
815
+ var createRecordKey = (kind, ...parts) => JSON.stringify([kind, ...parts]);
816
+ /** Compares projected records by their complete stable composite keys. */
817
+ var compareRecordKeys = (left, right) => left.key < right.key ? -1 : left.key > right.key ? 1 : 0;
818
+ /** Removes canonical text while retaining exact asset identity and size metadata. */
819
+ var createAssetMetadata = (asset) => Object.freeze({
820
+ digest: asset.digest,
821
+ path: asset.path,
822
+ scalarLength: asset.scalarLength,
823
+ utf8ByteLength: asset.utf8ByteLength
824
+ });
825
+ /** Projects one diagnostic without retaining arbitrary detail payloads. */
826
+ var createMoldeaCliDiagnosticRecord = (diagnostic, occurrence = 0) => Object.freeze({
827
+ code: diagnostic.code,
828
+ entity: diagnostic.entity,
829
+ key: createRecordKey("diagnostic", diagnostic.source, diagnostic.code, diagnostic.path, diagnostic.pointer, occurrence),
830
+ kind: "diagnostic",
831
+ message: diagnostic.message,
832
+ path: diagnostic.path,
833
+ pointer: diagnostic.pointer,
834
+ range: diagnostic.range,
835
+ source: diagnostic.source
836
+ });
837
+ /** Projects one adapter evidence item through its bounded metadata allowlist. */
838
+ var createEvidenceRecords = (evidence, occurrence) => {
839
+ const evidenceKey = createRecordKey("evidence", evidence.source, evidence.kind, evidence.agentId, evidence.capabilityKind, evidence.capabilityId, evidence.runtimeName, occurrence);
840
+ const summary = Object.freeze({
841
+ agentId: evidence.agentId,
842
+ capabilityId: evidence.capabilityId,
843
+ capabilityKind: evidence.capabilityKind,
844
+ evidenceKind: evidence.kind,
845
+ key: evidenceKey,
846
+ kind: "evidence",
847
+ referenceCount: evidence.references.length,
848
+ runtimeName: evidence.runtimeName,
849
+ source: evidence.source
2286
850
  });
851
+ return Object.freeze([summary, ...evidence.references.map((reference, index) => Object.freeze({
852
+ evidenceKey,
853
+ key: createRecordKey("evidence-reference", evidenceKey, reference.path, reference.symbol ?? null, index),
854
+ kind: "evidence-reference",
855
+ path: reference.path,
856
+ symbol: reference.symbol ?? null
857
+ }))]);
858
+ };
859
+ /** Adds one exact or glob relationship record to the projection. */
860
+ var addRelationship = (records, ownerKind, ownerId, agentId, field, path, symbol = null) => {
861
+ const declarationKind = path.includes("*") ? "glob" : "exact";
862
+ records.push(Object.freeze({
863
+ agentId,
864
+ declarationKind,
865
+ field,
866
+ key: createRecordKey("relationship", ownerKind, agentId, ownerId, field, declarationKind, path, symbol),
867
+ kind: "relationship",
868
+ ownerId,
869
+ ownerKind,
870
+ path,
871
+ symbol
872
+ }));
2287
873
  };
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"
874
+ /** Adds reference-list and impact relationships from a context or decision owner. */
875
+ var addRelationshipEntry = (records, ownerKind, ownerId, relationship) => {
876
+ for (const reference of relationship?.bindings ?? []) addRelationship(records, ownerKind, ownerId, null, "bindings", reference.path, reference.symbol ?? null);
877
+ for (const pattern of relationship?.affectedBy ?? []) addRelationship(records, ownerKind, ownerId, null, "affectedBy", pattern);
878
+ };
879
+ /** Adds unresolved requirement metadata and its related-path relationships. */
880
+ var addUnresolved = (records, relationships, unresolved, agentId) => {
881
+ for (const requirementId of Object.keys(unresolved ?? {}).sort()) {
882
+ const requirement = unresolved?.[requirementId];
883
+ if (requirement === void 0) continue;
884
+ records.push(Object.freeze({
885
+ agentId,
886
+ category: requirement.category,
887
+ effect: requirement.effect,
888
+ key: createRecordKey("unresolved", agentId, requirementId),
889
+ kind: "unresolved",
890
+ relatedCount: requirement.related?.length ?? 0,
891
+ requirementId
2318
892
  }));
2319
- return;
893
+ for (const reference of requirement.related ?? []) addRelationship(relationships, "unresolved", requirementId, agentId, "related", reference.path, reference.symbol ?? null);
2320
894
  }
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;
895
+ };
896
+ /** Adds one capability requirement and its complete repository relationships. */
897
+ var addCapability = (requirements, relationships, capabilityKind, capabilityId, capability, agentId) => {
898
+ requirements.push(Object.freeze({
899
+ agentId,
900
+ capabilityId,
901
+ capabilityKind,
902
+ implementationPath: capability.implementation.path,
903
+ implementationSymbol: capability.implementation.symbol ?? null,
904
+ key: createRecordKey("requirement", agentId, capabilityKind, capabilityId),
905
+ kind: "requirement",
906
+ name: capability.name,
907
+ registrationPath: capability.registration?.path ?? null
908
+ }));
909
+ const ownerKind = capabilityKind;
910
+ addRelationship(relationships, ownerKind, capabilityId, agentId, "implementation", capability.implementation.path, capability.implementation.symbol ?? null);
911
+ if (capability.registration !== void 0) addRelationship(relationships, ownerKind, capabilityId, agentId, "registration", capability.registration.path, capability.registration.symbol ?? null);
912
+ if (capabilityKind === "tool") {
913
+ const tool = capability;
914
+ for (const field of ["inputSchema", "outputSchema"]) {
915
+ const reference = tool[field];
916
+ if (reference !== void 0) addRelationship(relationships, ownerKind, capabilityId, agentId, field, reference.path, reference.symbol ?? null);
2342
917
  }
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
918
  }
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;
919
+ for (const pattern of capability.affectedBy ?? []) addRelationship(relationships, ownerKind, capabilityId, agentId, "affectedBy", pattern);
920
+ };
921
+ /** Adds all repository relationships declared by one indexed agent. */
922
+ var addAgentRelationships = (relationships, requirements, agentId, declaration) => {
923
+ const ownerKind = "agent";
924
+ for (const field of [
925
+ "runtimeAgent",
926
+ "inputSchema",
927
+ "outputSchema",
928
+ "instructionLoader"
929
+ ]) {
930
+ const reference = declaration.bindings?.[field];
931
+ if (reference !== void 0) addRelationship(relationships, ownerKind, agentId, agentId, field, reference.path, reference.symbol ?? null);
2393
932
  }
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);
933
+ for (const variableId of Object.keys(declaration.bindings?.variableProviders ?? {}).sort()) {
934
+ const reference = declaration.bindings?.variableProviders?.[variableId];
935
+ if (reference !== void 0) addRelationship(relationships, ownerKind, agentId, agentId, `variableProvider:${variableId}`, reference.path, reference.symbol ?? null);
936
+ }
937
+ for (const pattern of declaration.affectedBy ?? []) addRelationship(relationships, ownerKind, agentId, agentId, "affectedBy", pattern);
938
+ for (const capabilityId of Object.keys(declaration.tools ?? {}).sort()) {
939
+ const capability = declaration.tools?.[capabilityId];
940
+ if (capability !== void 0) addCapability(requirements, relationships, "tool", capabilityId, capability, agentId);
941
+ }
942
+ for (const capabilityId of Object.keys(declaration.skills ?? {}).sort()) {
943
+ const capability = declaration.skills?.[capabilityId];
944
+ if (capability !== void 0) addCapability(requirements, relationships, "skill", capabilityId, capability, agentId);
945
+ }
946
+ };
947
+ /** Collects every canonical body used to assert that projections remain content-free. */
948
+ var collectCanonicalBodies = (inspection) => {
949
+ const project = inspection.project;
950
+ if (project === null) return Object.freeze([]);
951
+ return Object.freeze([
952
+ project.manifest.asset.content,
953
+ project.project.content,
954
+ ...project.context.map(({ asset }) => asset.content),
955
+ ...project.decisions.flatMap(({ decision }) => [decision.asset.content, decision.body]),
956
+ ...project.runtimes.map(({ asset }) => asset.content),
957
+ ...project.agents.flatMap(({ description, instruction, handoffDescription }) => [
958
+ description.asset.content,
959
+ description.value,
960
+ instruction.content,
961
+ ...handoffDescription === null ? [] : [handoffDescription.asset.content, handoffDescription.value]
962
+ ])
963
+ ]);
964
+ };
965
+ /** Creates content-free validation metadata and ordered diagnostic records. */
966
+ var createMoldeaCliValidateProjection = (inspection) => {
967
+ assertProjectInspectionInvariant(inspection);
968
+ const diagnostics = Object.freeze(inspection.diagnostics.map((diagnostic, index) => createMoldeaCliDiagnosticRecord(diagnostic, index)));
969
+ const snapshotDigest = calculateMoldeaCliJsonDigest({
970
+ diagnostics,
971
+ formatVersion: inspection.formatVersion
2419
972
  });
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
- }));
973
+ return Object.freeze({
974
+ canonicalBodies: collectCanonicalBodies(inspection),
975
+ diagnostics,
976
+ formatVersion: inspection.formatVersion,
977
+ snapshotDigest,
978
+ source: MOLDEA_CLI_GIT_WORKING_TREE_SOURCE
2427
979
  });
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
980
+ };
981
+ /**
982
+ * Projects one complete Core inspection through the schema 3 metadata allowlist.
983
+ * @param inspection The immutable Core inspection result.
984
+ * @returns Ordered metadata records, aggregate counts, and canonical-body guard seeds.
985
+ * @throws If the Core result contradicts its valid, project, and diagnostic invariants.
986
+ */
987
+ var createMoldeaCliInspectProjection = (inspection) => {
988
+ assertProjectInspectionInvariant(inspection);
989
+ const project = inspection.project;
990
+ const relationships = [];
991
+ const requirements = [];
992
+ const unresolved = [];
993
+ const records = [...inspection.diagnostics.map((diagnostic, index) => createMoldeaCliDiagnosticRecord(diagnostic, index)), ...inspection.evidence.flatMap(createEvidenceRecords)];
994
+ if (project !== null) {
995
+ for (const context of project.context) {
996
+ records.push(Object.freeze({
997
+ asset: createAssetMetadata(context.asset),
998
+ key: createRecordKey("context", context.asset.path),
999
+ kind: "context"
2435
1000
  }));
2436
- return;
2437
- }
2438
- if (options.signal?.aborted) {
2439
- resolve(Object.freeze({
2440
- kind: "failed",
2441
- reason: "aborted"
1001
+ addRelationshipEntry(relationships, "context", context.asset.path, context.relationships);
1002
+ }
1003
+ for (const indexedDecision of project.decisions) {
1004
+ const { decision } = indexedDecision;
1005
+ records.push(Object.freeze({
1006
+ asset: createAssetMetadata(decision.asset),
1007
+ createdAt: decision.createdAt,
1008
+ decisionId: decision.id,
1009
+ key: createRecordKey("decision", decision.id, decision.path),
1010
+ kind: "decision",
1011
+ status: decision.status,
1012
+ supersedesCount: decision.supersedes.length
2442
1013
  }));
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)
1014
+ for (const supersededDecisionId of decision.supersedes) records.push(Object.freeze({
1015
+ decisionId: decision.id,
1016
+ key: createRecordKey("decision-supersession", decision.id, supersededDecisionId),
1017
+ kind: "decision-supersession",
1018
+ supersededDecisionId
2450
1019
  }));
2451
- return;
1020
+ addRelationshipEntry(relationships, "decision", decision.id, indexedDecision.relationships);
2452
1021
  }
2453
- resolve(Object.freeze({
2454
- kind: "completed",
2455
- stderr,
2456
- stdoutBytes
1022
+ for (const runtime of project.runtimes) records.push(Object.freeze({
1023
+ asset: createAssetMetadata(runtime.asset),
1024
+ key: createRecordKey("runtime", runtime.asset.path),
1025
+ kind: "runtime"
2457
1026
  }));
2458
- });
2459
- if (stdin !== null) {
2460
- if (childProcess.stdin === null) {
2461
- failureReason = "command-failed";
2462
- childProcess.kill();
2463
- return;
2464
- }
2465
- childProcess.stdin.on("error", () => {
2466
- if (failureReason !== null || isSettled) return;
2467
- failureReason = "command-failed";
2468
- childProcess.kill();
2469
- });
2470
- try {
2471
- childProcess.stdin.end(stdin);
2472
- } catch {
2473
- failureReason = "command-failed";
2474
- childProcess.kill();
1027
+ for (const agent of project.agents) {
1028
+ records.push(Object.freeze({
1029
+ agentId: agent.id,
1030
+ contextCount: agent.context.length,
1031
+ decisionCount: agent.decisions.length,
1032
+ description: createAssetMetadata(agent.description.asset),
1033
+ handoffDescription: agent.handoffDescription === null ? null : createAssetMetadata(agent.handoffDescription.asset),
1034
+ instruction: createAssetMetadata(agent.instruction),
1035
+ key: createRecordKey("agent", agent.id),
1036
+ kind: "agent",
1037
+ runtimeId: agent.declaration.runtime.id
1038
+ }));
1039
+ for (const contextPath of agent.context) addRelationship(relationships, "agent", agent.id, agent.id, "context", contextPath);
1040
+ for (const decisionPath of agent.decisions) addRelationship(relationships, "agent", agent.id, agent.id, "decisions", decisionPath);
1041
+ addAgentRelationships(relationships, requirements, agent.id, agent.declaration);
1042
+ for (const mirror of agent.mirrors) records.push(Object.freeze({
1043
+ agentId: agent.id,
1044
+ canonicalDigest: mirror.canonicalDigest,
1045
+ digest: mirror.digest,
1046
+ key: createRecordKey("mirror", agent.id, mirror.path),
1047
+ kind: "mirror",
1048
+ path: mirror.path
1049
+ }));
1050
+ addUnresolved(unresolved, relationships, agent.declaration.unresolved, agent.id);
2475
1051
  }
1052
+ addUnresolved(unresolved, relationships, project.unresolved, null);
1053
+ records.push(...relationships, ...requirements, ...unresolved);
2476
1054
  }
2477
- });
2478
- //#endregion
2479
- //#region src/git-version/preflight.ts
2480
- /**
2481
- * Maps process failures to stable safe CLI errors.
2482
- * @param reason The normalized subprocess failure reason.
2483
- * @returns The public Git error code.
2484
- */
2485
- var mapGitProcessFailure$6 = (reason) => {
2486
- switch (reason) {
2487
- case "aborted": return "GIT_OPERATION_ABORTED";
2488
- case "not-found": return "GIT_NOT_FOUND";
2489
- case "repository-not-found": return "GIT_COMMAND_FAILED";
2490
- case "access-denied": return "GIT_ACCESS_DENIED";
2491
- case "output-limit-exceeded": return "GIT_VERSION_INVALID";
2492
- case "command-failed": return "GIT_COMMAND_FAILED";
2493
- }
2494
- };
2495
- /**
2496
- * Determines whether a parsed Git version meets the supported minimum.
2497
- * @param version The parsed Git version.
2498
- * @returns Whether the numeric version is supported.
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;
2504
- };
2505
- /**
2506
- * Creates a Git prerequisite check around an injectable process boundary.
2507
- * @param processExecutor The normalized Git subprocess executor.
2508
- * @returns A preflight that validates the installed Git version.
2509
- */
2510
- var createGitVersionPreflight = (processExecutor = executeGitProcess) => async (signal) => {
2511
- const processResult = await processExecutor({
2512
- arguments: ["--version"],
2513
- maxBufferBytes: MAX_GIT_VERSION_OUTPUT_BYTES,
2514
- ...signal === void 0 ? {} : { signal }
2515
- });
2516
- if (processResult.kind === "failed") return Object.freeze({
2517
- errorCode: mapGitProcessFailure$6(processResult.reason),
2518
- kind: "failed"
2519
- });
2520
- if (processResult.stderr.byteLength > 0) return Object.freeze({
2521
- errorCode: "GIT_VERSION_INVALID",
2522
- kind: "failed"
1055
+ records.sort(compareRecordKeys);
1056
+ const counts = Object.freeze({
1057
+ agents: records.filter(({ kind }) => kind === "agent").length,
1058
+ context: records.filter(({ kind }) => kind === "context").length,
1059
+ decisions: records.filter(({ kind }) => kind === "decision").length,
1060
+ decisionSupersessions: records.filter(({ kind }) => kind === "decision-supersession").length,
1061
+ diagnostics: records.filter(({ kind }) => kind === "diagnostic").length,
1062
+ evidence: records.filter(({ kind }) => kind === "evidence").length,
1063
+ evidenceReferences: records.filter(({ kind }) => kind === "evidence-reference").length,
1064
+ mirrors: records.filter(({ kind }) => kind === "mirror").length,
1065
+ relationships: relationships.length,
1066
+ requirements: requirements.length,
1067
+ runtimes: records.filter(({ kind }) => kind === "runtime").length,
1068
+ unresolved: unresolved.length
2523
1069
  });
2524
- const version = parseGitVersionOutput(processResult.stdout);
2525
- if (version === null) return Object.freeze({
2526
- errorCode: "GIT_VERSION_INVALID",
2527
- kind: "failed"
1070
+ const projectMetadata = project === null ? null : Object.freeze({
1071
+ manifest: createAssetMetadata(project.manifest.asset),
1072
+ project: createAssetMetadata(project.project)
2528
1073
  });
2529
- if (!isGitVersionSupported(version)) return Object.freeze({
2530
- errorCode: "GIT_VERSION_UNSUPPORTED",
2531
- kind: "failed"
1074
+ const snapshotDigest = calculateMoldeaCliJsonDigest({
1075
+ counts,
1076
+ formatVersion: inspection.formatVersion,
1077
+ project: projectMetadata,
1078
+ records
2532
1079
  });
2533
1080
  return Object.freeze({
2534
- kind: "supported",
2535
- version
1081
+ canonicalBodies: collectCanonicalBodies(inspection),
1082
+ counts,
1083
+ formatVersion: inspection.formatVersion,
1084
+ project: projectMetadata,
1085
+ records: Object.freeze(records),
1086
+ snapshotDigest,
1087
+ source: MOLDEA_CLI_GIT_WORKING_TREE_SOURCE
2536
1088
  });
2537
1089
  };
2538
1090
  //#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
1091
  //#region src/git-working-tree/constants.ts
2571
1092
  var MAX_GIT_DISCOVERY_OUTPUT_BYTES = 262144;
2572
1093
  //#endregion
@@ -2614,7 +1135,7 @@ var parseGitBooleanOutput = (output) => {
2614
1135
  var parseGitPathOutput = (output) => {
2615
1136
  const decodedOutput = decodeGitOutput(output);
2616
1137
  if (decodedOutput === null || !decodedOutput.endsWith("\n")) return null;
2617
- const gitPath = process$1.platform === "win32" && decodedOutput.endsWith("\r\n") ? decodedOutput.slice(0, -2) : decodedOutput.slice(0, -1);
1138
+ const gitPath = process.platform === "win32" && decodedOutput.endsWith("\r\n") ? decodedOutput.slice(0, -2) : decodedOutput.slice(0, -1);
2618
1139
  return gitPath.length === 0 ? null : gitPath;
2619
1140
  };
2620
1141
  /**
@@ -2906,6 +1427,248 @@ var createGitWorkingTreeIdentityInspector = (processExecutor = executeGitProcess
2906
1427
  };
2907
1428
  var inspectGitWorkingTreeIdentity = createGitWorkingTreeIdentityInspector();
2908
1429
  //#endregion
1430
+ //#region src/project-content/exception.ts
1431
+ /** Represents an invalid explicit canonical content request. */
1432
+ var MoldeaCliProjectContentException = class extends Error {
1433
+ code;
1434
+ /** Creates one content request failure with a stable public code. */
1435
+ constructor(code) {
1436
+ super(code);
1437
+ this.code = code;
1438
+ this.name = "MoldeaCliProjectContentException";
1439
+ }
1440
+ };
1441
+ //#endregion
1442
+ //#region src/project-content/validations.ts
1443
+ var CONTEXT_PATH_PATTERN = /^\/moldea\/context\/(?:[^/]+\/)*[^/]+\.md$/u;
1444
+ var DECISION_PATH_PATTERN = /^\/moldea\/decisions\/[^/]+\.md$/u;
1445
+ var RUNTIME_PATH_PATTERN = /^\/moldea\/runtimes\/(?:[^/]+\/)*[^/]+\.md$/u;
1446
+ var AGENT_PATH_PATTERN = /^\/moldea\/agents\/[^/]+\/(?:description|instruction|handoff-description)\.md$/u;
1447
+ /** Determines whether a logical path names one canonical moldea text asset. */
1448
+ var isMoldeaCliCanonicalContentPath = (path) => {
1449
+ if (/[?*[\]{}]/u.test(path)) return false;
1450
+ 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);
1451
+ };
1452
+ /**
1453
+ * Parses one untrusted path and restricts it to the canonical text layout.
1454
+ * @param input The command-line logical path.
1455
+ * @returns The validated canonical repository path.
1456
+ * @throws
1457
+ * - CONTENT_PATH_INVALID: The content path must identify one canonical moldea text asset.
1458
+ */
1459
+ var parseMoldeaCliCanonicalContentPath = (input) => {
1460
+ let path;
1461
+ try {
1462
+ path = parseRepositoryPath(input);
1463
+ } catch {
1464
+ throw new MoldeaCliProjectContentException("CONTENT_PATH_INVALID");
1465
+ }
1466
+ if (!isMoldeaCliCanonicalContentPath(path)) throw new MoldeaCliProjectContentException("CONTENT_PATH_INVALID");
1467
+ return path;
1468
+ };
1469
+ //#endregion
1470
+ //#region src/project-content/executor.ts
1471
+ /** Creates an adapter-free executor for one explicit canonical content asset. */
1472
+ var createMoldeaCliProjectContentExecutor = (coreFactory = createCore) => {
1473
+ return async (input) => {
1474
+ const bytes = await input.repository.readFile(input.path, input.signal === void 0 ? void 0 : { signal: input.signal });
1475
+ const result = await coreFactory({ limits: Object.freeze({
1476
+ maxDiagnostics: input.resourceLimits.maxDiagnostics,
1477
+ maxEntries: input.resourceLimits.maxEntries,
1478
+ maxEvidence: input.resourceLimits.maxEvidence,
1479
+ maxFileBytes: input.resourceLimits.maxFileBytes,
1480
+ maxManifestBytes: input.resourceLimits.maxManifestBytes,
1481
+ maxTotalBytesRead: input.resourceLimits.maxTotalBytes
1482
+ }) }).calculateContentDigest({
1483
+ content: bytes,
1484
+ path: input.path
1485
+ });
1486
+ if (!result.valid || result.digest === null || result.text === null) throw new MoldeaCliProjectContentException("CONTENT_INVALID");
1487
+ return Object.freeze({
1488
+ content: result.text.value,
1489
+ digest: result.digest,
1490
+ path: input.path,
1491
+ scalarLength: result.text.scalarLength,
1492
+ utf8ByteLength: result.text.utf8ByteLength
1493
+ });
1494
+ };
1495
+ };
1496
+ /** Executes one adapter-free explicit canonical content read. */
1497
+ var executeMoldeaCliProjectContent = createMoldeaCliProjectContentExecutor();
1498
+ //#endregion
1499
+ //#region src/project-content/page.ts
1500
+ /** Creates public content metadata without retaining its body. */
1501
+ var createContentMetadata = (asset) => ({
1502
+ digest: asset.digest,
1503
+ path: asset.path,
1504
+ scalarLength: asset.scalarLength,
1505
+ utf8ByteLength: asset.utf8ByteLength
1506
+ });
1507
+ /** Creates one candidate content result ending at a scalar offset. */
1508
+ var createCandidate = (asset, scalars, scalarStart, scalarEnd) => ({
1509
+ asset: createContentMetadata(asset),
1510
+ chunk: {
1511
+ content: scalars.slice(scalarStart, scalarEnd).join(""),
1512
+ scalarEnd,
1513
+ scalarStart
1514
+ },
1515
+ cursor: scalarEnd < scalars.length ? encodeMoldeaCliCursor("content", { path: asset.path }, asset.digest, `scalar:${scalarEnd}`) : null,
1516
+ snapshotDigest: asset.digest
1517
+ });
1518
+ /**
1519
+ * Selects the largest Unicode-scalar-safe content chunk within an exact output budget.
1520
+ * @param input The canonical asset, cursor, byte budget, and final result measurement.
1521
+ * @returns A content result with a continuation cursor when more scalars remain.
1522
+ * @throws
1523
+ * - CURSOR_INVALID: The continuation cursor is invalid for this request.
1524
+ * - CURSOR_SNAPSHOT_CHANGED: The continuation cursor belongs to a different repository snapshot.
1525
+ * - OUTPUT_BUDGET_TOO_SMALL: The output byte budget cannot contain the next complete result.
1526
+ */
1527
+ var createMoldeaCliContentPage = (input) => {
1528
+ const scalars = Array.from(input.asset.content);
1529
+ const cursorState = input.cursor === null ? null : decodeMoldeaCliCursor({
1530
+ command: "content",
1531
+ cursor: input.cursor,
1532
+ filters: { path: input.asset.path },
1533
+ snapshotDigest: input.asset.digest
1534
+ });
1535
+ const scalarStart = cursorState === null || !/^scalar:\d+$/u.test(cursorState.lastKey) ? cursorState === null ? 0 : -1 : Number(cursorState.lastKey.slice(7));
1536
+ if (!Number.isSafeInteger(scalarStart) || scalarStart < 0 || scalarStart > scalars.length || input.cursor !== null && scalarStart === scalars.length) throw new MoldeaCliOutputPageException("CURSOR_INVALID");
1537
+ if (scalars.length === 0) {
1538
+ const emptyResult = createCandidate(input.asset, scalars, 0, 0);
1539
+ if (input.measure(emptyResult) > input.maxOutputBytes) throw new MoldeaCliOutputPageException("OUTPUT_BUDGET_TOO_SMALL");
1540
+ return Object.freeze({
1541
+ ...emptyResult,
1542
+ asset: Object.freeze(emptyResult.asset),
1543
+ chunk: Object.freeze(emptyResult.chunk)
1544
+ });
1545
+ }
1546
+ let lower = scalarStart + 1;
1547
+ let upper = scalars.length;
1548
+ let selected = null;
1549
+ while (lower <= upper) {
1550
+ const scalarEnd = lower + Math.floor((upper - lower) / 2);
1551
+ const candidate = createCandidate(input.asset, scalars, scalarStart, scalarEnd);
1552
+ if (input.measure(candidate) <= input.maxOutputBytes) {
1553
+ selected = candidate;
1554
+ lower = scalarEnd + 1;
1555
+ } else upper = scalarEnd - 1;
1556
+ }
1557
+ if (selected === null) throw new MoldeaCliOutputPageException("OUTPUT_BUDGET_TOO_SMALL");
1558
+ return Object.freeze({
1559
+ ...selected,
1560
+ asset: Object.freeze(selected.asset),
1561
+ chunk: Object.freeze(selected.chunk)
1562
+ });
1563
+ };
1564
+ //#endregion
1565
+ //#region src/project-scope/constants.ts
1566
+ var MOLDEA_MANIFEST_PATH = parseRepositoryPath("/moldea/moldea.yaml");
1567
+ //#endregion
1568
+ //#region src/project-scope/exception.ts
1569
+ /** Represents invalid NUL-delimited changed-path input owned by the CLI. */
1570
+ var MoldeaCliProjectScopeException = class extends Error {
1571
+ code;
1572
+ /** Creates one scope-input failure with a stable public code. */
1573
+ constructor(code) {
1574
+ super(code);
1575
+ this.code = code;
1576
+ this.name = "MoldeaCliProjectScopeException";
1577
+ }
1578
+ };
1579
+ //#endregion
1580
+ //#region src/project-scope/paths.ts
1581
+ /**
1582
+ * Parses bounded NUL-delimited UTF-8 changed paths without shell interpretation.
1583
+ * @param input Exact stdin bytes supplied to the scope command.
1584
+ * @param maxEntries Maximum changed-path records accepted by the operation.
1585
+ * @returns Detached path strings in supplied order for Core validation and normalization.
1586
+ * @throws
1587
+ * - PATH_INPUT_INVALID: The NUL-delimited changed-path input is invalid.
1588
+ */
1589
+ var parseMoldeaCliScopePathBytes = (input, maxEntries) => {
1590
+ if (input.byteLength === 0) return Object.freeze([]);
1591
+ let text;
1592
+ try {
1593
+ text = new TextDecoder("utf-8", { fatal: true }).decode(input);
1594
+ } catch {
1595
+ throw new MoldeaCliProjectScopeException("PATH_INPUT_INVALID");
1596
+ }
1597
+ if (!text.endsWith("\0")) throw new MoldeaCliProjectScopeException("PATH_INPUT_INVALID");
1598
+ const paths = text.slice(0, -1).split("\0");
1599
+ if (paths.length > maxEntries || paths.some((path) => path.length === 0)) throw new MoldeaCliProjectScopeException("PATH_INPUT_INVALID");
1600
+ return Object.freeze(paths);
1601
+ };
1602
+ //#endregion
1603
+ //#region src/project-scope/executor.ts
1604
+ /** Creates an adapter-free manifest-only Core scope executor. */
1605
+ var createMoldeaCliProjectScopeExecutor = (coreFactory = createCore) => {
1606
+ return async (input) => {
1607
+ const manifestBytes = await input.repository.readFile(MOLDEA_MANIFEST_PATH, input.signal === void 0 ? void 0 : { signal: input.signal });
1608
+ const scope = await coreFactory({ limits: Object.freeze({
1609
+ maxDiagnostics: input.resourceLimits.maxDiagnostics,
1610
+ maxEntries: input.resourceLimits.maxEntries,
1611
+ maxEvidence: input.resourceLimits.maxEvidence,
1612
+ maxFileBytes: input.resourceLimits.maxFileBytes,
1613
+ maxManifestBytes: input.resourceLimits.maxManifestBytes,
1614
+ maxTotalBytesRead: input.resourceLimits.maxTotalBytes
1615
+ }) }).matchManifestScope({
1616
+ manifest: {
1617
+ content: manifestBytes,
1618
+ path: MOLDEA_MANIFEST_PATH
1619
+ },
1620
+ paths: input.paths
1621
+ });
1622
+ return Object.freeze({
1623
+ manifestContent: new TextDecoder("utf-8").decode(manifestBytes),
1624
+ scope
1625
+ });
1626
+ };
1627
+ };
1628
+ /** Executes one adapter-free manifest-only changed-path scope match. */
1629
+ var executeMoldeaCliProjectScope = createMoldeaCliProjectScopeExecutor();
1630
+ //#endregion
1631
+ //#region src/project-scope/transformers.ts
1632
+ var compareKeys = (left, right) => left.key < right.key ? -1 : left.key > right.key ? 1 : 0;
1633
+ /** Creates one stable key for a relationship-match projection. */
1634
+ var createMatchKey = (match) => JSON.stringify([
1635
+ "match",
1636
+ match.owner.kind,
1637
+ match.owner.agentId,
1638
+ match.owner.id,
1639
+ match.field,
1640
+ match.declaration.kind === "exact" ? match.declaration.path : match.declaration.pattern,
1641
+ match.inputPath,
1642
+ match.pointer
1643
+ ]);
1644
+ /** Projects complete Core scope output into ordered content-free CLI records. */
1645
+ var createMoldeaCliScopeProjection = (execution) => {
1646
+ const records = [...execution.scope.diagnostics.map((diagnostic, index) => createMoldeaCliDiagnosticRecord(diagnostic, index)), ...execution.scope.matches.map((match) => ({
1647
+ key: createMatchKey(match),
1648
+ kind: "match",
1649
+ match
1650
+ }))].sort(compareKeys);
1651
+ const snapshotDigest = calculateMoldeaCliJsonDigest({
1652
+ inputDigest: execution.scope.inputDigest,
1653
+ manifestDigest: execution.scope.manifestDigest,
1654
+ records,
1655
+ valid: execution.scope.valid
1656
+ });
1657
+ return Object.freeze({
1658
+ canonicalBodies: Object.freeze([execution.manifestContent]),
1659
+ counts: Object.freeze({
1660
+ ...execution.scope.counts,
1661
+ diagnostics: execution.scope.diagnostics.length
1662
+ }),
1663
+ inputDigest: execution.scope.inputDigest,
1664
+ manifestDigest: execution.scope.manifestDigest,
1665
+ records: Object.freeze(records),
1666
+ relevant: execution.scope.relevant,
1667
+ snapshotDigest,
1668
+ valid: execution.scope.valid
1669
+ });
1670
+ };
1671
+ //#endregion
2909
1672
  //#region src/repository-content-transformation-guard/exception.ts
2910
1673
  /** Identifies a guarded logical file whose working-tree bytes are unsafe to inspect. */
2911
1674
  var GitContentTransformUnsupportedException = class extends RepositorySourceException {
@@ -3076,6 +1839,7 @@ var createCoreErrorDetails = (error) => {
3076
1839
  * @returns A complete immutable operational error without causes or private host data.
3077
1840
  */
3078
1841
  var mapMoldeaCliOperationalError = (error) => {
1842
+ if (error instanceof MoldeaCliOutputPageException || error instanceof MoldeaCliProjectContentException || error instanceof MoldeaCliProjectScopeException) return createMoldeaCliOwnedError(error.code);
3079
1843
  if (error instanceof GitContentTransformUnsupportedException) return Object.freeze({
3080
1844
  ...createMoldeaCliOwnedError("GIT_CONTENT_TRANSFORM_UNSUPPORTED"),
3081
1845
  path: isRepositoryPath(error.path) ? error.path : null
@@ -4194,12 +2958,14 @@ var isProbeFailure = (result) => !Array.isArray(result);
4194
2958
  */
4195
2959
  var createGitInventoryProbe = (processExecutor = executeGitStreamingProcess, ownershipFilter = createGitInventoryOwnershipFilter(createGitInventoryBoundaryInspector(processExecutor)), entryTypeNormalizer = createGitInventoryEntryTypeNormalizer(inspectGitInventoryEntry, createGitSymlinkConfigurationResolver(processExecutor)), contentTransformationClassifier = createGitContentTransformationClassifier(processExecutor), logicalPathNormalizer = normalizeGitInventoryLogicalPaths) => async (input) => {
4196
2960
  if (input.signal?.aborted) return createProbeFailure("GIT_OPERATION_ABORTED");
2961
+ const selectionPathspecs = (input.selectionPaths ?? []).map((selectionPath) => `:(top,literal)${selectionPath.slice(1)}`);
4197
2962
  const trackedParser = createTrackedGitInventoryParser(input.maxEntries);
4198
2963
  const trackedProcessResult = await processExecutor({
4199
2964
  arguments: [
4200
2965
  "-C",
4201
2966
  input.repositoryRoot,
4202
- ...GIT_TRACKED_INVENTORY_ARGUMENTS
2967
+ ...GIT_TRACKED_INVENTORY_ARGUMENTS,
2968
+ ...selectionPathspecs
4203
2969
  ],
4204
2970
  consumeStdout: (chunk) => trackedParser.consume(chunk),
4205
2971
  maxStderrBytes: MAX_GIT_PROCESS_DIAGNOSTIC_BYTES,
@@ -4215,7 +2981,8 @@ var createGitInventoryProbe = (processExecutor = executeGitStreamingProcess, own
4215
2981
  arguments: [
4216
2982
  "-C",
4217
2983
  input.repositoryRoot,
4218
- ...GIT_UNTRACKED_INVENTORY_ARGUMENTS
2984
+ ...GIT_UNTRACKED_INVENTORY_ARGUMENTS,
2985
+ ...selectionPathspecs
4219
2986
  ],
4220
2987
  consumeStdout: (chunk) => untrackedParser.consume(chunk),
4221
2988
  maxStderrBytes: MAX_GIT_PROCESS_DIAGNOSTIC_BYTES,
@@ -4506,6 +3273,7 @@ var createWorkingTreeSnapshotExecutor = (identityInspector = inspectGitWorkingTr
4506
3273
  maxEntries: resourceLimits.maxEntries,
4507
3274
  maxMetadataBytes: resourceLimits.maxTotalBytes,
4508
3275
  repositoryRoot,
3276
+ ...input.selectionPaths === void 0 ? {} : { selectionPaths: input.selectionPaths },
4509
3277
  ...input.signal === void 0 ? {} : { signal: input.signal }
4510
3278
  });
4511
3279
  return result.kind === "failed" ? createSnapshotFailure(result.errorCode) : result;
@@ -4564,27 +3332,22 @@ var createWorkingTreeSnapshotExecutor = (identityInspector = inspectGitWorkingTr
4564
3332
  var executeWorkingTreeSnapshot = createWorkingTreeSnapshotExecutor();
4565
3333
  //#endregion
4566
3334
  //#region src/cli-execution/results.ts
4567
- /**
4568
- * Creates one process-neutral result for a valid installed composition.
4569
- * @param result The exact installed composition result.
4570
- * @param cliVersion The installed CLI package version.
4571
- * @param isJson Whether machine-readable output was requested.
4572
- * @returns The complete immutable successful process output.
4573
- */
3335
+ var measureOutput = (output) => Buffer.byteLength(output, "utf8");
3336
+ /** Measures a paged result without repeatedly serializing its accumulated JSON records. */
3337
+ var measurePagedOutput = (page, serializedRecordsUtf8Bytes, isJson, formatJson, formatHuman) => {
3338
+ if (!isJson) return measureOutput(formatHuman(page));
3339
+ return measureOutput(formatJson(Object.freeze({
3340
+ cursor: page.cursor,
3341
+ records: Object.freeze([])
3342
+ }))) - 2 + serializedRecordsUtf8Bytes;
3343
+ };
3344
+ /** Creates one process-neutral result for a valid installed composition. */
4574
3345
  var createMoldeaCliCompositionExecutionResult = (result, cliVersion, isJson) => Object.freeze({
4575
3346
  exitCode: MOLDEA_CLI_EXIT_CODES.Success,
4576
3347
  stderr: "",
4577
3348
  stdout: isJson ? formatMoldeaCliJsonCompositionResult(result, cliVersion) : formatMoldeaCliHumanCompositionResult(result, cliVersion)
4578
3349
  });
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
- */
3350
+ /** Creates one safe process-neutral error result in the requested output mode. */
4588
3351
  var createMoldeaCliErrorResult = (error, command, cliVersion, isJson, exitCode) => Object.freeze(isJson ? {
4589
3352
  exitCode,
4590
3353
  stderr: "",
@@ -4595,75 +3358,215 @@ var createMoldeaCliErrorResult = (error, command, cliVersion, isJson, exitCode)
4595
3358
  stdout: ""
4596
3359
  });
4597
3360
  /**
4598
- * Creates one process-neutral result for a completed validate command.
4599
- * @param inspection The complete immutable Core inspection.
4600
- * @param cliVersion The installed CLI package version.
4601
- * @param isJson Whether machine-readable output was requested.
4602
- * @returns The complete immutable process output.
4603
- */
4604
- var createMoldeaCliValidateExecutionResult = (inspection, cliVersion, isJson) => {
4605
- const result = createMoldeaCliValidateResult(inspection);
4606
- const exitCode = result.diagnostics.length === 0 ? MOLDEA_CLI_EXIT_CODES.Success : MOLDEA_CLI_EXIT_CODES.StructuralInvalid;
3361
+ * Creates one bounded process-neutral result for a completed validate command.
3362
+ * @throws
3363
+ * - CURSOR_INVALID: The continuation cursor is invalid for this request.
3364
+ * - CURSOR_SNAPSHOT_CHANGED: The continuation cursor belongs to a different repository snapshot.
3365
+ * - OUTPUT_BUDGET_TOO_SMALL: The output byte budget cannot contain the next complete result.
3366
+ */
3367
+ var createMoldeaCliValidateExecutionResult = (inspection, cliVersion, isJson, cursor, maxOutputBytes) => {
3368
+ const projection = createMoldeaCliValidateProjection(inspection);
3369
+ const createResult = (page) => ({
3370
+ diagnosticCount: projection.diagnostics.length,
3371
+ formatVersion: projection.formatVersion,
3372
+ page,
3373
+ snapshotDigest: projection.snapshotDigest,
3374
+ source: projection.source
3375
+ });
3376
+ const page = createMoldeaCliOutputPage({
3377
+ command: "validate",
3378
+ cursor,
3379
+ filters: {},
3380
+ maxOutputBytes,
3381
+ measure: (candidate, serializedRecordsUtf8Bytes) => measurePagedOutput(candidate, serializedRecordsUtf8Bytes, isJson, (page) => formatMoldeaCliJsonValidateResult(createResult(page), cliVersion), (page) => formatMoldeaCliHumanValidateResult(createResult(page))),
3382
+ records: projection.diagnostics,
3383
+ snapshotDigest: projection.snapshotDigest
3384
+ });
3385
+ const result = Object.freeze(createResult(page));
3386
+ assertMoldeaCliJsonResultIsContentFree(result, projection.canonicalBodies);
4607
3387
  return Object.freeze({
4608
- exitCode,
3388
+ exitCode: result.diagnosticCount === 0 ? MOLDEA_CLI_EXIT_CODES.Success : MOLDEA_CLI_EXIT_CODES.StructuralInvalid,
4609
3389
  stderr: "",
4610
3390
  stdout: isJson ? formatMoldeaCliJsonValidateResult(result, cliVersion) : formatMoldeaCliHumanValidateResult(result)
4611
3391
  });
4612
3392
  };
4613
3393
  /**
4614
- * Creates one process-neutral result for a completed inspect command.
4615
- * @param inspection The complete immutable Core inspection.
4616
- * @param cliVersion The installed CLI package version.
4617
- * @param isJson Whether machine-readable output was requested.
4618
- * @returns The complete immutable process output.
4619
- * @throws If the Core result contradicts its valid, project, and diagnostic invariants.
4620
- */
4621
- var createMoldeaCliInspectExecutionResult = (inspection, cliVersion, isJson) => {
4622
- const result = createMoldeaCliInspectResult(inspection);
3394
+ * Creates one bounded content-free result for a completed inspect command.
3395
+ * @throws
3396
+ * - CURSOR_INVALID: The continuation cursor is invalid for this request.
3397
+ * - CURSOR_SNAPSHOT_CHANGED: The continuation cursor belongs to a different repository snapshot.
3398
+ * - OUTPUT_BUDGET_TOO_SMALL: The output byte budget cannot contain the next complete result.
3399
+ */
3400
+ var createMoldeaCliInspectExecutionResult = (inspection, cliVersion, isJson, cursor, maxOutputBytes) => {
3401
+ const projection = createMoldeaCliInspectProjection(inspection);
3402
+ const createResult = (page) => ({
3403
+ counts: projection.counts,
3404
+ formatVersion: projection.formatVersion,
3405
+ page,
3406
+ project: projection.project,
3407
+ snapshotDigest: projection.snapshotDigest,
3408
+ source: projection.source
3409
+ });
3410
+ const page = createMoldeaCliOutputPage({
3411
+ command: "inspect",
3412
+ cursor,
3413
+ filters: {},
3414
+ maxOutputBytes,
3415
+ measure: (candidate, serializedRecordsUtf8Bytes) => measurePagedOutput(candidate, serializedRecordsUtf8Bytes, isJson, (page) => formatMoldeaCliJsonInspectResult(createResult(page), cliVersion), (page) => formatMoldeaCliHumanInspectResult(createResult(page))),
3416
+ records: projection.records,
3417
+ snapshotDigest: projection.snapshotDigest
3418
+ });
3419
+ const result = Object.freeze(createResult(page));
3420
+ assertMoldeaCliJsonResultIsContentFree(result, projection.canonicalBodies);
4623
3421
  return Object.freeze({
4624
3422
  exitCode: inspection.valid ? MOLDEA_CLI_EXIT_CODES.Success : MOLDEA_CLI_EXIT_CODES.StructuralInvalid,
4625
3423
  stderr: "",
4626
3424
  stdout: isJson ? formatMoldeaCliJsonInspectResult(result, cliVersion) : formatMoldeaCliHumanInspectResult(result)
4627
3425
  });
4628
3426
  };
3427
+ /**
3428
+ * Creates one bounded content-free result for changed-path relationship scope.
3429
+ * @throws
3430
+ * - CURSOR_INVALID: The continuation cursor is invalid for this request.
3431
+ * - CURSOR_SNAPSHOT_CHANGED: The continuation cursor belongs to a different repository snapshot.
3432
+ * - OUTPUT_BUDGET_TOO_SMALL: The output byte budget cannot contain the next complete result.
3433
+ */
3434
+ var createMoldeaCliScopeExecutionResult = (execution, cliVersion, isJson, cursor, maxOutputBytes) => {
3435
+ const projection = createMoldeaCliScopeProjection(execution);
3436
+ const createResult = (page) => ({
3437
+ counts: projection.counts,
3438
+ inputDigest: projection.inputDigest,
3439
+ manifestDigest: projection.manifestDigest,
3440
+ page,
3441
+ relevant: projection.relevant,
3442
+ snapshotDigest: projection.snapshotDigest,
3443
+ source: MOLDEA_CLI_GIT_WORKING_TREE_SOURCE,
3444
+ valid: projection.valid
3445
+ });
3446
+ const page = createMoldeaCliOutputPage({
3447
+ command: "scope",
3448
+ cursor,
3449
+ filters: { inputDigest: projection.inputDigest },
3450
+ maxOutputBytes,
3451
+ measure: (candidate, serializedRecordsUtf8Bytes) => measurePagedOutput(candidate, serializedRecordsUtf8Bytes, isJson, (page) => formatMoldeaCliJsonScopeResult(createResult(page), cliVersion), (page) => formatMoldeaCliHumanScopeResult(createResult(page))),
3452
+ records: projection.records,
3453
+ snapshotDigest: projection.snapshotDigest
3454
+ });
3455
+ const result = Object.freeze(createResult(page));
3456
+ assertMoldeaCliJsonResultIsContentFree(result, projection.canonicalBodies);
3457
+ return Object.freeze({
3458
+ exitCode: projection.valid ? MOLDEA_CLI_EXIT_CODES.Success : MOLDEA_CLI_EXIT_CODES.StructuralInvalid,
3459
+ stderr: "",
3460
+ stdout: isJson ? formatMoldeaCliJsonScopeResult(result, cliVersion) : formatMoldeaCliHumanScopeResult(result)
3461
+ });
3462
+ };
3463
+ /**
3464
+ * Creates one bounded Unicode-safe explicit canonical content result.
3465
+ * @throws
3466
+ * - CURSOR_INVALID: The continuation cursor is invalid for this request.
3467
+ * - CURSOR_SNAPSHOT_CHANGED: The continuation cursor belongs to a different repository snapshot.
3468
+ * - OUTPUT_BUDGET_TOO_SMALL: The output byte budget cannot contain the next complete result.
3469
+ */
3470
+ var createMoldeaCliContentExecutionResult = (asset, cliVersion, isJson, cursor, maxOutputBytes) => {
3471
+ const result = createMoldeaCliContentPage({
3472
+ asset,
3473
+ cursor,
3474
+ maxOutputBytes,
3475
+ measure: (candidate) => measureOutput(isJson ? formatMoldeaCliJsonContentResult(candidate, cliVersion) : formatMoldeaCliHumanContentResult(candidate))
3476
+ });
3477
+ return Object.freeze({
3478
+ exitCode: MOLDEA_CLI_EXIT_CODES.Success,
3479
+ stderr: "",
3480
+ stdout: isJson ? formatMoldeaCliJsonContentResult(result, cliVersion) : formatMoldeaCliHumanContentResult(result)
3481
+ });
3482
+ };
4629
3483
  //#endregion
4630
3484
  //#region src/cli-execution/command-executor.ts
3485
+ /** Loads adapter-backed Core inspection only for commands that need it. */
3486
+ var executeLazyCoreInspection = async (input) => {
3487
+ const { executeMoldeaCliCoreInspection } = await import("./chunks/core-composition-bX-2XB4n.js");
3488
+ return executeMoldeaCliCoreInspection(input);
3489
+ };
3490
+ var loadInstalledComposition = async (input) => {
3491
+ const { resolveInstalledMoldeaCliComposition } = await import("./chunks/composition-CIrgnSN8.js");
3492
+ return resolveInstalledMoldeaCliComposition(input);
3493
+ };
3494
+ /** Creates one operational error result without exposing caught failure details. */
3495
+ var createOperationalErrorResult = (code, input) => createMoldeaCliErrorResult(createMoldeaCliOwnedError(code), input.invocation.command, input.packageMetadata.version, input.invocation.options.isJson, MOLDEA_CLI_EXIT_CODES.OperationalError);
4631
3496
  /**
4632
- * Creates the private command dispatcher around discovery and bounded snapshot execution.
3497
+ * Creates command dispatch with lazy adapter composition and bounded working-tree snapshots.
4633
3498
  * @param workingTreeDiscovery The Git working-tree discovery operation.
4634
3499
  * @param workingTreeSnapshotExecutor The complete working-tree snapshot operation.
4635
- * @param coreInspectionExecutor The attempt-local Core inspection composition.
4636
- * @param compositionResolver The installed executable-integrity and composition boundary.
4637
- * @returns A command executor for the current behavioral slice.
3500
+ * @param coreInspectionExecutor The adapter-backed Core inspection operation.
3501
+ * @param compositionLoader The installed executable-integrity composition boundary.
3502
+ * @param projectScopeExecutor The adapter-free manifest scope operation.
3503
+ * @param projectContentExecutor The adapter-free canonical content operation.
3504
+ * @returns A command executor for the schema 3 CLI.
4638
3505
  */
4639
- var createMoldeaCliCommandExecutor = (workingTreeDiscovery = discoverGitWorkingTree, workingTreeSnapshotExecutor = executeWorkingTreeSnapshot, coreInspectionExecutor = executeMoldeaCliCoreInspection, compositionResolver = resolveInstalledMoldeaCliComposition) => async (input) => {
4640
- const compositionResolution = compositionResolver({ packageMetadata: input.packageMetadata });
4641
- if (compositionResolution.kind === "invalid") return createMoldeaCliErrorResult(createMoldeaCliOwnedError("COMPOSITION_STATE_INVALID"), input.invocation.command, input.packageMetadata.version, input.invocation.options.isJson, MOLDEA_CLI_EXIT_CODES.OperationalError);
4642
- if (input.invocation.command === MOLDEA_CLI_COMMANDS.Composition) return createMoldeaCliCompositionExecutionResult(compositionResolution.result, input.packageMetadata.version, input.invocation.options.isJson);
4643
- const discoveryResult = await workingTreeDiscovery({
4644
- invocationDirectory: input.invocationDirectory,
4645
- repositoryDirectory: input.invocation.options.repositoryDirectory,
4646
- ...input.signal === void 0 ? {} : { signal: input.signal }
4647
- });
4648
- if (discoveryResult.kind === "failed") return createMoldeaCliErrorResult(createMoldeaCliOwnedError(discoveryResult.errorCode), input.invocation.command, input.packageMetadata.version, input.invocation.options.isJson, MOLDEA_CLI_EXIT_CODES.OperationalError);
4649
- try {
4650
- const resourceLimits = input.invocation.options.resourceLimits;
4651
- const snapshotResult = await workingTreeSnapshotExecutor({
4652
- operation: (repository, signal) => coreInspectionExecutor({
4653
- repository,
3506
+ var createMoldeaCliCommandExecutor = (workingTreeDiscovery = discoverGitWorkingTree, workingTreeSnapshotExecutor = executeWorkingTreeSnapshot, coreInspectionExecutor = executeLazyCoreInspection, compositionLoader = loadInstalledComposition, projectScopeExecutor = executeMoldeaCliProjectScope, projectContentExecutor = executeMoldeaCliProjectContent) => {
3507
+ return async (input) => {
3508
+ const command = input.invocation.command;
3509
+ const options = input.invocation.options;
3510
+ try {
3511
+ if (command === MOLDEA_CLI_COMMANDS.Composition || command === MOLDEA_CLI_COMMANDS.Inspect || command === MOLDEA_CLI_COMMANDS.Validate) {
3512
+ const compositionResolution = await compositionLoader({ packageMetadata: input.packageMetadata });
3513
+ if (compositionResolution.kind === "invalid") return createOperationalErrorResult("COMPOSITION_STATE_INVALID", input);
3514
+ if (command === MOLDEA_CLI_COMMANDS.Composition) return createMoldeaCliCompositionExecutionResult(compositionResolution.result, input.packageMetadata.version, options.isJson);
3515
+ }
3516
+ let scopePaths = null;
3517
+ let contentPath = null;
3518
+ if (command === MOLDEA_CLI_COMMANDS.Scope) {
3519
+ if (options.pathsInput === "path" && options.path !== null) scopePaths = Object.freeze([options.path]);
3520
+ else if (options.pathsInput === "stdin" && input.stdin !== void 0) {
3521
+ if (input.stdin.byteLength > options.resourceLimits.maxTotalBytes) return createOperationalErrorResult("RESOURCE_LIMIT_EXCEEDED", input);
3522
+ scopePaths = parseMoldeaCliScopePathBytes(input.stdin, options.resourceLimits.maxEntries);
3523
+ } else return createOperationalErrorResult("PATH_INPUT_INVALID", input);
3524
+ }
3525
+ if (command === MOLDEA_CLI_COMMANDS.Content) {
3526
+ if (options.path === null) return createOperationalErrorResult("CONTENT_PATH_INVALID", input);
3527
+ contentPath = parseMoldeaCliCanonicalContentPath(options.path);
3528
+ }
3529
+ const discoveryResult = await workingTreeDiscovery({
3530
+ invocationDirectory: input.invocationDirectory,
3531
+ repositoryDirectory: options.repositoryDirectory,
3532
+ ...input.signal === void 0 ? {} : { signal: input.signal }
3533
+ });
3534
+ if (discoveryResult.kind === "failed") return createOperationalErrorResult(discoveryResult.errorCode, input);
3535
+ const resourceLimits = options.resourceLimits;
3536
+ const snapshotResult = await workingTreeSnapshotExecutor({
3537
+ operation: async (repository, signal) => {
3538
+ if (command === MOLDEA_CLI_COMMANDS.Scope && scopePaths !== null) return projectScopeExecutor({
3539
+ paths: scopePaths,
3540
+ repository,
3541
+ resourceLimits,
3542
+ ...signal === void 0 ? {} : { signal }
3543
+ });
3544
+ if (command === MOLDEA_CLI_COMMANDS.Content && contentPath !== null) return projectContentExecutor({
3545
+ path: contentPath,
3546
+ repository,
3547
+ resourceLimits,
3548
+ ...signal === void 0 ? {} : { signal }
3549
+ });
3550
+ return coreInspectionExecutor({
3551
+ repository,
3552
+ resourceLimits,
3553
+ ...signal === void 0 ? {} : { signal }
3554
+ });
3555
+ },
3556
+ repositoryRoot: discoveryResult.repositoryRoot,
4654
3557
  resourceLimits,
4655
- ...signal === void 0 ? {} : { signal }
4656
- }),
4657
- repositoryRoot: discoveryResult.repositoryRoot,
4658
- resourceLimits,
4659
- ...input.signal === void 0 ? {} : { signal: input.signal }
4660
- });
4661
- if (snapshotResult.kind === "failed") return createMoldeaCliErrorResult(createMoldeaCliOwnedError(snapshotResult.errorCode), input.invocation.command, input.packageMetadata.version, input.invocation.options.isJson, MOLDEA_CLI_EXIT_CODES.OperationalError);
4662
- if (input.invocation.command === MOLDEA_CLI_COMMANDS.Validate) return createMoldeaCliValidateExecutionResult(snapshotResult.result, input.packageMetadata.version, input.invocation.options.isJson);
4663
- return createMoldeaCliInspectExecutionResult(snapshotResult.result, input.packageMetadata.version, input.invocation.options.isJson);
4664
- } catch (error) {
4665
- return createMoldeaCliErrorResult(mapMoldeaCliOperationalError(error), input.invocation.command, input.packageMetadata.version, input.invocation.options.isJson, MOLDEA_CLI_EXIT_CODES.OperationalError);
4666
- }
3558
+ ...command === MOLDEA_CLI_COMMANDS.Scope ? { selectionPaths: [MOLDEA_MANIFEST_PATH] } : contentPath === null ? {} : { selectionPaths: [contentPath] },
3559
+ ...input.signal === void 0 ? {} : { signal: input.signal }
3560
+ });
3561
+ if (snapshotResult.kind === "failed") return createOperationalErrorResult(snapshotResult.errorCode, input);
3562
+ if (command === MOLDEA_CLI_COMMANDS.Validate) return createMoldeaCliValidateExecutionResult(snapshotResult.result, input.packageMetadata.version, options.isJson, options.cursor, options.maxOutputBytes);
3563
+ if (command === MOLDEA_CLI_COMMANDS.Inspect) return createMoldeaCliInspectExecutionResult(snapshotResult.result, input.packageMetadata.version, options.isJson, options.cursor, options.maxOutputBytes);
3564
+ if (command === MOLDEA_CLI_COMMANDS.Scope) return createMoldeaCliScopeExecutionResult(snapshotResult.result, input.packageMetadata.version, options.isJson, options.cursor, options.maxOutputBytes);
3565
+ return createMoldeaCliContentExecutionResult(snapshotResult.result, input.packageMetadata.version, options.isJson, options.cursor, options.maxOutputBytes);
3566
+ } catch (error) {
3567
+ return createMoldeaCliErrorResult(mapMoldeaCliOperationalError(error), command, input.packageMetadata.version, options.isJson, MOLDEA_CLI_EXIT_CODES.OperationalError);
3568
+ }
3569
+ };
4667
3570
  };
4668
3571
  var executeMoldeaCliCommand = createMoldeaCliCommandExecutor();
4669
3572
  //#endregion
@@ -4688,11 +3591,19 @@ var runMoldeaCli = async (options) => {
4688
3591
  if (parseResult.kind === "error") return createMoldeaCliErrorResult(createMoldeaCliOwnedError(parseResult.code), parseResult.command, options.packageMetadata.version, parseResult.isJson, MOLDEA_CLI_EXIT_CODES.UsageError);
4689
3592
  const executeCommand = options.executeCommand ?? executeMoldeaCliCommand;
4690
3593
  try {
3594
+ let stdin;
3595
+ if (parseResult.invocation.options.pathsInput === "stdin") {
3596
+ 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);
3597
+ const stdinResult = await options.readStdin(parseResult.invocation.options.resourceLimits.maxTotalBytes, options.signal);
3598
+ 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);
3599
+ stdin = stdinResult.bytes;
3600
+ }
4691
3601
  return await executeCommand({
4692
3602
  invocationDirectory: options.invocationDirectory,
4693
3603
  invocation: parseResult.invocation,
4694
3604
  packageMetadata: options.packageMetadata,
4695
- ...options.signal === void 0 ? {} : { signal: options.signal }
3605
+ ...options.signal === void 0 ? {} : { signal: options.signal },
3606
+ ...stdin === void 0 ? {} : { stdin }
4696
3607
  });
4697
3608
  } catch {
4698
3609
  return createMoldeaCliErrorResult(createMoldeaCliOwnedError("INTERNAL_ERROR"), parseResult.invocation.command, options.packageMetadata.version, parseResult.invocation.options.isJson, MOLDEA_CLI_EXIT_CODES.OperationalError);
@@ -4700,6 +3611,7 @@ var runMoldeaCli = async (options) => {
4700
3611
  };
4701
3612
  //#endregion
4702
3613
  //#region src/package-metadata/loader.ts
3614
+ var import_semver = require_semver();
4703
3615
  var MOLDEA_CLI_PACKAGE_NAME = "@moldea.ai/cli";
4704
3616
  /** Checks exact SemVer syntax without accepting normalized prefixes or surrounding whitespace. */
4705
3617
  var isExactSemanticVersion = (version) => version === version.trim() && /^[0-9]/u.test(version) && (0, import_semver.valid)(version) !== null;
@@ -4785,10 +3697,10 @@ var SIGNAL_EXIT_CODES = Object.freeze({
4785
3697
  });
4786
3698
  var PROCESS_SIGNAL_SOURCE = Object.freeze({
4787
3699
  addListener: (signal, listener) => {
4788
- process$1.on(signal, listener);
3700
+ process.on(signal, listener);
4789
3701
  },
4790
3702
  removeListener: (signal, listener) => {
4791
- process$1.off(signal, listener);
3703
+ process.off(signal, listener);
4792
3704
  }
4793
3705
  });
4794
3706
  /**
@@ -4834,6 +3746,28 @@ var createMoldeaCliProcessSignalSession = (signalSource = PROCESS_SIGNAL_SOURCE)
4834
3746
  var executableDirectory = path.dirname(fileURLToPath(import.meta.url));
4835
3747
  var packageManifestPath = path.resolve(executableDirectory, "..", "package.json");
4836
3748
  var signalSession = createMoldeaCliProcessSignalSession();
3749
+ /** Reads process stdin incrementally without retaining bytes above the requested limit. */
3750
+ var readProcessStdin = async (maxBytes, signal) => {
3751
+ const chunks = [];
3752
+ let totalBytes = 0;
3753
+ for await (const chunk of process.stdin) {
3754
+ if (signal?.aborted) return {
3755
+ bytes: /* @__PURE__ */ new Uint8Array(),
3756
+ kind: "completed"
3757
+ };
3758
+ const bytes = typeof chunk === "string" ? Buffer.from(chunk, "utf8") : new Uint8Array(chunk);
3759
+ totalBytes += bytes.byteLength;
3760
+ if (totalBytes > maxBytes) {
3761
+ process.stdin.pause();
3762
+ return { kind: "limit-exceeded" };
3763
+ }
3764
+ chunks.push(bytes);
3765
+ }
3766
+ return {
3767
+ bytes: Buffer.concat(chunks, totalBytes),
3768
+ kind: "completed"
3769
+ };
3770
+ };
4837
3771
  /**
4838
3772
  * Writes one complete process output string.
4839
3773
  * @param outputStream The destination process stream.
@@ -4853,27 +3787,28 @@ var writeProcessOutput = async (outputStream, output) => {
4853
3787
  });
4854
3788
  };
4855
3789
  try {
4856
- const invocationDirectory = process$1.cwd();
3790
+ const invocationDirectory = process.cwd();
4857
3791
  const packageMetadata = await loadMoldeaCliPackageMetadata(packageManifestPath);
4858
3792
  const executionResult = await runMoldeaCli({
4859
- commandLineArguments: process$1.argv.slice(2),
3793
+ commandLineArguments: process.argv.slice(2),
4860
3794
  invocationDirectory,
4861
3795
  packageMetadata,
3796
+ readStdin: readProcessStdin,
4862
3797
  signal: signalSession.signal
4863
3798
  });
4864
- if (signalSession.hasReceivedSignal) process$1.exitCode = signalSession.exitCode;
3799
+ if (signalSession.hasReceivedSignal) process.exitCode = signalSession.exitCode;
4865
3800
  else {
4866
- await writeProcessOutput(process$1.stdout, executionResult.stdout);
4867
- if (!signalSession.hasReceivedSignal) await writeProcessOutput(process$1.stderr, executionResult.stderr);
3801
+ await writeProcessOutput(process.stdout, executionResult.stdout);
3802
+ if (!signalSession.hasReceivedSignal) await writeProcessOutput(process.stderr, executionResult.stderr);
4868
3803
  if (!signalSession.hasReceivedSignal) signalSession.completeOutput();
4869
- process$1.exitCode = signalSession.exitCode ?? executionResult.exitCode;
3804
+ process.exitCode = signalSession.exitCode ?? executionResult.exitCode;
4870
3805
  }
4871
3806
  } catch {
4872
- if (signalSession.hasReceivedSignal) process$1.exitCode = signalSession.exitCode;
3807
+ if (signalSession.hasReceivedSignal) process.exitCode = signalSession.exitCode;
4873
3808
  else {
4874
- await writeProcessOutput(process$1.stderr, formatMoldeaCliHumanError(createMoldeaCliOwnedError("INTERNAL_ERROR"))).catch(() => void 0);
3809
+ await writeProcessOutput(process.stderr, formatMoldeaCliHumanError(createMoldeaCliOwnedError("INTERNAL_ERROR"))).catch(() => void 0);
4875
3810
  signalSession.completeOutput();
4876
- process$1.exitCode = 3;
3811
+ process.exitCode = 3;
4877
3812
  }
4878
3813
  } finally {
4879
3814
  signalSession.dispose();