@moldea.ai/cli 6.0.0 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -8
- package/dist/chunks/{composition-CIrgnSN8.js → composition-7d632gM8.js} +22 -6
- package/dist/chunks/composition-7d632gM8.js.map +1 -0
- package/dist/chunks/{core-composition-sKWsd1Aj.js → core-composition-6wOvReoY.js} +11 -4
- package/dist/chunks/core-composition-6wOvReoY.js.map +1 -0
- package/dist/chunks/{core-composition-bX-2XB4n.js → core-composition-Bb9OMTs-.js} +1 -1
- package/dist/moldea.js +298 -373
- package/dist/moldea.js.map +1 -1
- package/package.json +14 -14
- package/dist/chunks/composition-CIrgnSN8.js.map +0 -1
- package/dist/chunks/core-composition-sKWsd1Aj.js.map +0 -1
package/dist/moldea.js
CHANGED
|
@@ -6,7 +6,7 @@ import { fileURLToPath } from "node:url";
|
|
|
6
6
|
import { createHash, timingSafeEqual } from "node:crypto";
|
|
7
7
|
import { lstat, readFile, readdir, stat } from "node:fs/promises";
|
|
8
8
|
import { CoreConfigurationException, CoreOperationException, createCore } from "@moldea.ai/core";
|
|
9
|
-
import { REPOSITORY_ROOT, RepositorySourceException, isRepositoryPath, parseRepositoryPath } from "@moldea.ai/repository";
|
|
9
|
+
import { REPOSITORY_ROOT, RepositorySourceException, createRepositoryComparison, isRepositoryPath, parseRepositoryPath } from "@moldea.ai/repository";
|
|
10
10
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
11
11
|
import { createFilesystemRepositoryReader } from "@moldea.ai/repository-fs";
|
|
12
12
|
//#region src/cli-execution/constants.ts
|
|
@@ -128,6 +128,7 @@ var CURSOR_DOCUMENT_KEYS = Object.freeze([
|
|
|
128
128
|
"filtersDigest",
|
|
129
129
|
"lastKey",
|
|
130
130
|
"snapshotDigest",
|
|
131
|
+
"sourceCursor",
|
|
131
132
|
"version"
|
|
132
133
|
]);
|
|
133
134
|
/** Calculates one stable SHA-256 identifier for deterministic JSON text. */
|
|
@@ -149,16 +150,17 @@ var isCursorDocument = (value) => {
|
|
|
149
150
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
150
151
|
const record = value;
|
|
151
152
|
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"] ===
|
|
153
|
+
return keys.length === CURSOR_DOCUMENT_KEYS.length && keys.every((key, index) => key === CURSOR_DOCUMENT_KEYS[index]) && record["version"] === 2 && (record["command"] === "content" || record["command"] === "inspect" || record["command"] === "scope" || record["command"] === "validate") && typeof record["filtersDigest"] === "string" && SHA256_PATTERN.test(record["filtersDigest"]) && typeof record["lastKey"] === "string" && record["lastKey"].length > 0 && (record["sourceCursor"] === null || typeof record["sourceCursor"] === "string") && typeof record["snapshotDigest"] === "string" && SHA256_PATTERN.test(record["snapshotDigest"]) && typeof record["checksum"] === "string" && SHA256_PATTERN.test(record["checksum"]);
|
|
153
154
|
};
|
|
154
155
|
/** Encodes one command-, filter-, and snapshot-bound continuation cursor. */
|
|
155
|
-
var encodeMoldeaCliCursor = (command, filters, snapshotDigest, lastKey) => {
|
|
156
|
+
var encodeMoldeaCliCursor = (command, filters, snapshotDigest, lastKey, sourceCursor = null) => {
|
|
156
157
|
const payload = {
|
|
157
158
|
command,
|
|
158
159
|
filtersDigest: calculateMoldeaCliJsonDigest(filters),
|
|
159
160
|
lastKey,
|
|
161
|
+
sourceCursor,
|
|
160
162
|
snapshotDigest,
|
|
161
|
-
version:
|
|
163
|
+
version: 2
|
|
162
164
|
};
|
|
163
165
|
const document = {
|
|
164
166
|
...payload,
|
|
@@ -188,8 +190,12 @@ var decodeMoldeaCliCursor = (input) => {
|
|
|
188
190
|
if (!isCursorDocument(decoded)) throw new MoldeaCliOutputPageException("CURSOR_INVALID");
|
|
189
191
|
const { checksum, ...payload } = decoded;
|
|
190
192
|
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({
|
|
193
|
+
if (input.snapshotDigest !== void 0 && decoded.snapshotDigest !== input.snapshotDigest) throw new MoldeaCliOutputPageException("CURSOR_SNAPSHOT_CHANGED");
|
|
194
|
+
return Object.freeze({
|
|
195
|
+
lastKey: decoded.lastKey,
|
|
196
|
+
snapshotDigest: decoded.snapshotDigest,
|
|
197
|
+
sourceCursor: decoded.sourceCursor
|
|
198
|
+
});
|
|
193
199
|
};
|
|
194
200
|
//#endregion
|
|
195
201
|
//#region src/output-page/page.ts
|
|
@@ -218,8 +224,8 @@ var createMoldeaCliOutputPage = (input) => {
|
|
|
218
224
|
filters: input.filters,
|
|
219
225
|
snapshotDigest: input.snapshotDigest
|
|
220
226
|
});
|
|
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");
|
|
227
|
+
const startIndex = cursorState === null ? 0 : cursorState.sourceCursor !== null ? 0 : input.records.findIndex(({ key }) => key === cursorState.lastKey) + 1;
|
|
228
|
+
if (cursorState !== null && cursorState.sourceCursor === null && startIndex === 0) throw new MoldeaCliOutputPageException("CURSOR_INVALID");
|
|
223
229
|
const emptyRecords = Object.freeze([]);
|
|
224
230
|
const emptyPage = Object.freeze({
|
|
225
231
|
cursor: null,
|
|
@@ -238,7 +244,8 @@ var createMoldeaCliOutputPage = (input) => {
|
|
|
238
244
|
const serializedRecordUtf8Bytes = Buffer.byteLength(serializeJsonDeterministically(record), "utf8");
|
|
239
245
|
serializedRecordsUtf8Bytes += serializedRecordUtf8Bytes + (endIndex > startIndex + 1 ? 1 : 0);
|
|
240
246
|
selectedRecords.push(record);
|
|
241
|
-
const
|
|
247
|
+
const sourceCursor = input.sourceCursorForRecord?.(record) ?? null;
|
|
248
|
+
const cursor = (input.sourceCursorForRecord === void 0 ? endIndex < input.records.length : sourceCursor !== null) ? encodeMoldeaCliCursor(input.command, input.filters, input.snapshotDigest, record.key, sourceCursor) : null;
|
|
242
249
|
const candidate = Object.freeze({
|
|
243
250
|
cursor,
|
|
244
251
|
records: selectedRecords
|
|
@@ -287,7 +294,7 @@ var parsePositiveSafeInteger = (input) => {
|
|
|
287
294
|
const parsedInteger = Number(input);
|
|
288
295
|
return Number.isSafeInteger(parsedInteger) && parsedInteger > 0 ? parsedInteger : null;
|
|
289
296
|
};
|
|
290
|
-
/** Parses one output byte budget inside the schema
|
|
297
|
+
/** Parses one output byte budget inside the schema 4 transport bounds. */
|
|
291
298
|
var parseMoldeaCliOutputByteLimit = (input) => {
|
|
292
299
|
const parsed = parsePositiveSafeInteger(input);
|
|
293
300
|
return parsed !== null && parsed >= 4096 && parsed <= 1048576 ? parsed : null;
|
|
@@ -333,7 +340,7 @@ var isMoldeaCliCommand = (input) => {
|
|
|
333
340
|
return input !== void 0 && COMMAND_NAMES.has(input);
|
|
334
341
|
};
|
|
335
342
|
/**
|
|
336
|
-
* Parses the complete schema
|
|
343
|
+
* Parses the complete schema 4 command grammar without mutating caller arguments.
|
|
337
344
|
* @param commandLineArguments The process arguments after the executable path.
|
|
338
345
|
* @returns A normalized command, informational request, or safe invocation error.
|
|
339
346
|
*/
|
|
@@ -662,16 +669,16 @@ var createMoldeaCliOwnedError = (code) => {
|
|
|
662
669
|
};
|
|
663
670
|
//#endregion
|
|
664
671
|
//#region src/json-output-contract/document.ts
|
|
665
|
-
/** Creates one strict schema
|
|
672
|
+
/** Creates one strict schema 4 JSON envelope. */
|
|
666
673
|
var createMoldeaCliJsonEnvelope = (input) => Object.freeze({
|
|
667
674
|
cliVersion: input.cliVersion,
|
|
668
675
|
command: input.command,
|
|
669
676
|
error: input.error,
|
|
670
677
|
result: input.result,
|
|
671
|
-
schemaVersion:
|
|
678
|
+
schemaVersion: 4,
|
|
672
679
|
status: input.status
|
|
673
680
|
});
|
|
674
|
-
/** Serializes one schema
|
|
681
|
+
/** Serializes one schema 4 envelope with its required trailing line feed. */
|
|
675
682
|
var serializeMoldeaCliJsonEnvelope = (input) => `${serializeJsonDeterministically(createMoldeaCliJsonEnvelope(input))}\n`;
|
|
676
683
|
//#endregion
|
|
677
684
|
//#region src/json-output-contract/guard.ts
|
|
@@ -734,7 +741,7 @@ var formatMoldeaCliHelp = (command) => {
|
|
|
734
741
|
};
|
|
735
742
|
/** Formats one safe CLI error for human stderr output. */
|
|
736
743
|
var formatMoldeaCliHumanError = (error) => `${error.source}:${error.code} ${error.message}\n`;
|
|
737
|
-
/** Formats any strict schema
|
|
744
|
+
/** Formats any strict schema 4 JSON envelope. */
|
|
738
745
|
var formatMoldeaCliJsonResult = (command, result, error, status, cliVersion) => serializeMoldeaCliJsonEnvelope({
|
|
739
746
|
cliVersion,
|
|
740
747
|
command,
|
|
@@ -742,7 +749,7 @@ var formatMoldeaCliJsonResult = (command, result, error, status, cliVersion) =>
|
|
|
742
749
|
result,
|
|
743
750
|
status
|
|
744
751
|
});
|
|
745
|
-
/** Formats one safe schema
|
|
752
|
+
/** Formats one safe schema 4 JSON error envelope. */
|
|
746
753
|
var formatMoldeaCliJsonError = (error, command, cliVersion) => formatMoldeaCliJsonResult(command, null, error, "error", cliVersion);
|
|
747
754
|
/** Formats one valid composition result for human stdout. */
|
|
748
755
|
var formatMoldeaCliHumanCompositionResult = (result, cliVersion) => {
|
|
@@ -750,7 +757,7 @@ var formatMoldeaCliHumanCompositionResult = (result, cliVersion) => {
|
|
|
750
757
|
"The installed CLI composition state is valid.",
|
|
751
758
|
`CLI version: ${cliVersion}`,
|
|
752
759
|
`Supported Node.js: ${result.supportedNodeRange}`,
|
|
753
|
-
`JSON output schema:
|
|
760
|
+
`JSON output schema: 4`,
|
|
754
761
|
`Minimum Git: ${result.minimumGitVersion}`,
|
|
755
762
|
`Repository formats: ${result.repositoryFormatVersions.join(", ")}`,
|
|
756
763
|
"Packages:",
|
|
@@ -759,7 +766,7 @@ var formatMoldeaCliHumanCompositionResult = (result, cliVersion) => {
|
|
|
759
766
|
...result.adapters.map(({ id, repositoryFormatVersions }) => ` ${id}: repository formats ${repositoryFormatVersions.join(", ")}`)
|
|
760
767
|
].join("\n")}\n`;
|
|
761
768
|
};
|
|
762
|
-
/** Formats one composition result in the strict schema
|
|
769
|
+
/** Formats one composition result in the strict schema 4 envelope. */
|
|
763
770
|
var formatMoldeaCliJsonCompositionResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Composition, result, null, "valid", cliVersion);
|
|
764
771
|
/** Formats one completed validation result for human stdout. */
|
|
765
772
|
var formatMoldeaCliHumanValidateResult = (result) => {
|
|
@@ -769,16 +776,16 @@ var formatMoldeaCliHumanValidateResult = (result) => {
|
|
|
769
776
|
if (result.page.cursor !== null) lines.push("Additional diagnostics are available through JSON pagination.");
|
|
770
777
|
return `${lines.join("\n")}\n`;
|
|
771
778
|
};
|
|
772
|
-
/** Formats one validation result in the strict schema
|
|
773
|
-
var formatMoldeaCliJsonValidateResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Validate, result, null, result.
|
|
779
|
+
/** Formats one validation result in the strict schema 4 envelope. */
|
|
780
|
+
var formatMoldeaCliJsonValidateResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Validate, result, null, result.valid ? "valid" : "invalid", cliVersion);
|
|
774
781
|
/** Formats one completed metadata inspection for human stdout. */
|
|
775
782
|
var formatMoldeaCliHumanInspectResult = (result) => {
|
|
776
|
-
const lines = createMoldeaCliHumanStatusLines(result.
|
|
783
|
+
const lines = createMoldeaCliHumanStatusLines(result.valid, result.formatVersion);
|
|
777
784
|
for (const [label, count] of Object.entries(result.counts)) lines.push(`${label}: ${count}`);
|
|
778
785
|
return `${lines.join("\n")}\n`;
|
|
779
786
|
};
|
|
780
|
-
/** Formats one metadata inspection in the strict schema
|
|
781
|
-
var formatMoldeaCliJsonInspectResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Inspect, result, null, result.
|
|
787
|
+
/** Formats one metadata inspection in the strict schema 4 envelope. */
|
|
788
|
+
var formatMoldeaCliJsonInspectResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Inspect, result, null, result.valid ? "valid" : "invalid", cliVersion);
|
|
782
789
|
/** Formats one changed-path scope result for human stdout. */
|
|
783
790
|
var formatMoldeaCliHumanScopeResult = (result) => {
|
|
784
791
|
return `${[
|
|
@@ -787,41 +794,30 @@ var formatMoldeaCliHumanScopeResult = (result) => {
|
|
|
787
794
|
...Object.entries(result.counts).map(([label, count]) => `${label}: ${count}`)
|
|
788
795
|
].join("\n")}\n`;
|
|
789
796
|
};
|
|
790
|
-
/** Formats one changed-path scope result in the strict schema
|
|
797
|
+
/** Formats one changed-path scope result in the strict schema 4 envelope. */
|
|
791
798
|
var formatMoldeaCliJsonScopeResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Scope, result, null, result.valid ? "valid" : "invalid", cliVersion);
|
|
792
799
|
/** Formats one explicit canonical content chunk for human stdout. */
|
|
793
800
|
var formatMoldeaCliHumanContentResult = (result) => {
|
|
794
801
|
return `${[
|
|
795
802
|
`Path: ${result.asset.path}`,
|
|
796
|
-
`
|
|
797
|
-
`
|
|
803
|
+
`Content identity: ${result.asset.contentIdentity ?? "unavailable"}`,
|
|
804
|
+
`Bytes: ${result.chunk.byteStart}-${result.chunk.byteEnd} of ${result.asset.totalBytes}`,
|
|
798
805
|
result.cursor === null ? "Cursor: none" : `Cursor: ${result.cursor}`,
|
|
799
806
|
...result.cursor === null ? [] : ["Continue this asset by passing the cursor to a JSON content request."],
|
|
800
807
|
"",
|
|
801
808
|
result.chunk.content
|
|
802
809
|
].join("\n")}\n`;
|
|
803
810
|
};
|
|
804
|
-
/** Formats one explicit canonical content chunk in the strict schema
|
|
811
|
+
/** Formats one explicit canonical content chunk in the strict schema 4 envelope. */
|
|
805
812
|
var formatMoldeaCliJsonContentResult = (result, cliVersion) => formatMoldeaCliJsonResult(MOLDEA_CLI_COMMANDS.Content, result, null, "valid", cliVersion);
|
|
806
813
|
//#endregion
|
|
807
814
|
//#region src/presentation/transformers.ts
|
|
808
|
-
/** Rejects a Core result whose completion fields contradict its validity. */
|
|
809
|
-
var
|
|
810
|
-
|
|
811
|
-
const hasProject = inspection.project !== null;
|
|
812
|
-
if (!(inspection.valid ? hasProject && !hasDiagnostics : !hasProject && hasDiagnostics)) throw new TypeError("The Core inspection result is internally inconsistent.");
|
|
815
|
+
/** Rejects a Core validation result whose completion fields contradict its validity. */
|
|
816
|
+
var assertProjectValidationInvariant = (validation) => {
|
|
817
|
+
if (!(validation.valid ? validation.summary !== null && validation.diagnostics.length === 0 : validation.diagnostics.length > 0)) throw new TypeError("The Core validation result is internally inconsistent.");
|
|
813
818
|
};
|
|
814
|
-
/** Creates one stable composite key
|
|
819
|
+
/** Creates one stable composite record key. */
|
|
815
820
|
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
821
|
/** Projects one diagnostic without retaining arbitrary detail payloads. */
|
|
826
822
|
var createMoldeaCliDiagnosticRecord = (diagnostic, occurrence = 0) => Object.freeze({
|
|
827
823
|
code: diagnostic.code,
|
|
@@ -834,257 +830,93 @@ var createMoldeaCliDiagnosticRecord = (diagnostic, occurrence = 0) => Object.fre
|
|
|
834
830
|
range: diagnostic.range,
|
|
835
831
|
source: diagnostic.source
|
|
836
832
|
});
|
|
837
|
-
/** Projects one
|
|
838
|
-
var
|
|
839
|
-
const
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
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
|
|
892
|
-
}));
|
|
893
|
-
for (const reference of requirement.related ?? []) addRelationship(relationships, "unresolved", requirementId, agentId, "related", reference.path, reference.symbol ?? null);
|
|
894
|
-
}
|
|
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);
|
|
917
|
-
}
|
|
918
|
-
}
|
|
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);
|
|
932
|
-
}
|
|
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
|
-
]);
|
|
833
|
+
/** Projects one bounded Core inspection item through the schema 4 allowlist. */
|
|
834
|
+
var createInspectRecord = (item, index) => {
|
|
835
|
+
const order = index.toString().padStart(6, "0");
|
|
836
|
+
if (item.kind === "diagnostic") return Object.freeze({
|
|
837
|
+
...createMoldeaCliDiagnosticRecord(item.diagnostic, index),
|
|
838
|
+
key: createRecordKey(order, "diagnostic", item.diagnostic.source, item.diagnostic.code)
|
|
839
|
+
});
|
|
840
|
+
if (item.kind === "evidence") {
|
|
841
|
+
const evidence = item.evidence;
|
|
842
|
+
const record = {
|
|
843
|
+
agentId: evidence.agentId,
|
|
844
|
+
capabilityId: evidence.capabilityId,
|
|
845
|
+
capabilityKind: evidence.capabilityKind,
|
|
846
|
+
evidenceKind: evidence.kind,
|
|
847
|
+
key: createRecordKey(order, "evidence", evidence.source, evidence.kind, evidence.agentId, evidence.capabilityKind, evidence.capabilityId, evidence.runtimeName),
|
|
848
|
+
kind: "evidence",
|
|
849
|
+
references: Object.freeze(evidence.references.map((reference) => Object.freeze({
|
|
850
|
+
path: reference.path,
|
|
851
|
+
symbol: reference.symbol ?? null
|
|
852
|
+
}))),
|
|
853
|
+
runtimeName: evidence.runtimeName,
|
|
854
|
+
source: evidence.source
|
|
855
|
+
};
|
|
856
|
+
return Object.freeze(record);
|
|
857
|
+
}
|
|
858
|
+
const metadata = item.metadata;
|
|
859
|
+
const record = {
|
|
860
|
+
agentId: metadata.agentId,
|
|
861
|
+
byteLength: metadata.byteLength,
|
|
862
|
+
canonicalDigest: metadata.canonicalDigest,
|
|
863
|
+
decisionId: metadata.decisionId,
|
|
864
|
+
digest: metadata.digest,
|
|
865
|
+
key: createRecordKey(order, "metadata", metadata.path, metadata.kind, metadata.agentId),
|
|
866
|
+
kind: "metadata",
|
|
867
|
+
metadataKind: metadata.kind,
|
|
868
|
+
path: metadata.path,
|
|
869
|
+
scalarLength: metadata.scalarLength
|
|
870
|
+
};
|
|
871
|
+
return Object.freeze(record);
|
|
964
872
|
};
|
|
965
873
|
/** Creates content-free validation metadata and ordered diagnostic records. */
|
|
966
|
-
var createMoldeaCliValidateProjection = (
|
|
967
|
-
|
|
968
|
-
const diagnostics = Object.freeze(
|
|
874
|
+
var createMoldeaCliValidateProjection = (validation) => {
|
|
875
|
+
assertProjectValidationInvariant(validation);
|
|
876
|
+
const diagnostics = Object.freeze(validation.diagnostics.map((diagnostic, index) => createMoldeaCliDiagnosticRecord(diagnostic, index)).sort((left, right) => left.key < right.key ? -1 : left.key > right.key ? 1 : 0));
|
|
969
877
|
const snapshotDigest = calculateMoldeaCliJsonDigest({
|
|
970
878
|
diagnostics,
|
|
971
|
-
formatVersion:
|
|
879
|
+
formatVersion: validation.formatVersion,
|
|
880
|
+
summary: validation.summary,
|
|
881
|
+
valid: validation.valid
|
|
972
882
|
});
|
|
973
883
|
return Object.freeze({
|
|
974
|
-
canonicalBodies: collectCanonicalBodies(inspection),
|
|
975
884
|
diagnostics,
|
|
976
|
-
formatVersion:
|
|
885
|
+
formatVersion: validation.formatVersion,
|
|
977
886
|
snapshotDigest,
|
|
978
|
-
source: MOLDEA_CLI_GIT_WORKING_TREE_SOURCE
|
|
887
|
+
source: MOLDEA_CLI_GIT_WORKING_TREE_SOURCE,
|
|
888
|
+
valid: validation.valid
|
|
979
889
|
});
|
|
980
890
|
};
|
|
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
|
-
*/
|
|
891
|
+
/** Projects one bounded Core page through the content-free schema 4 allowlist. */
|
|
987
892
|
var createMoldeaCliInspectProjection = (inspection) => {
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
asset: createAssetMetadata(context.asset),
|
|
998
|
-
key: createRecordKey("context", context.asset.path),
|
|
999
|
-
kind: "context"
|
|
1000
|
-
}));
|
|
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
|
|
1013
|
-
}));
|
|
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
|
|
1019
|
-
}));
|
|
1020
|
-
addRelationshipEntry(relationships, "decision", decision.id, indexedDecision.relationships);
|
|
1021
|
-
}
|
|
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"
|
|
1026
|
-
}));
|
|
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);
|
|
1051
|
-
}
|
|
1052
|
-
addUnresolved(unresolved, relationships, project.unresolved, null);
|
|
1053
|
-
records.push(...relationships, ...requirements, ...unresolved);
|
|
1054
|
-
}
|
|
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
|
|
1069
|
-
});
|
|
1070
|
-
const projectMetadata = project === null ? null : Object.freeze({
|
|
1071
|
-
manifest: createAssetMetadata(project.manifest.asset),
|
|
1072
|
-
project: createAssetMetadata(project.project)
|
|
1073
|
-
});
|
|
1074
|
-
const snapshotDigest = calculateMoldeaCliJsonDigest({
|
|
1075
|
-
counts,
|
|
1076
|
-
formatVersion: inspection.formatVersion,
|
|
1077
|
-
project: projectMetadata,
|
|
1078
|
-
records
|
|
893
|
+
const project = inspection.summary === null ? null : Object.freeze({
|
|
894
|
+
manifest: Object.freeze({
|
|
895
|
+
digest: inspection.summary.manifestDigest,
|
|
896
|
+
path: inspection.summary.manifestPath
|
|
897
|
+
}),
|
|
898
|
+
project: Object.freeze({
|
|
899
|
+
digest: inspection.summary.projectDigest,
|
|
900
|
+
path: inspection.summary.projectPath
|
|
901
|
+
})
|
|
1079
902
|
});
|
|
903
|
+
const records = Object.freeze(inspection.page.records.map(({ item }, index) => createInspectRecord(item, index)));
|
|
904
|
+
const sourceCursors = new Map(inspection.page.records.map((record, index) => {
|
|
905
|
+
const projected = records[index];
|
|
906
|
+
if (projected === void 0) throw new TypeError("A projected inspection record is missing.");
|
|
907
|
+
return [projected.key, record.nextCursor];
|
|
908
|
+
}));
|
|
909
|
+
const snapshotDigest = inspection.inspectionDigest;
|
|
1080
910
|
return Object.freeze({
|
|
1081
|
-
|
|
1082
|
-
counts,
|
|
911
|
+
counts: inspection.counts,
|
|
1083
912
|
formatVersion: inspection.formatVersion,
|
|
1084
|
-
|
|
1085
|
-
|
|
913
|
+
getSourceCursor: (record) => sourceCursors.get(record.key) ?? null,
|
|
914
|
+
project,
|
|
915
|
+
records,
|
|
1086
916
|
snapshotDigest,
|
|
1087
|
-
source: MOLDEA_CLI_GIT_WORKING_TREE_SOURCE
|
|
917
|
+
source: MOLDEA_CLI_GIT_WORKING_TREE_SOURCE,
|
|
918
|
+
valid: inspection.valid,
|
|
919
|
+
view: inspection.view
|
|
1088
920
|
});
|
|
1089
921
|
};
|
|
1090
922
|
//#endregion
|
|
@@ -1468,87 +1300,82 @@ var parseMoldeaCliCanonicalContentPath = (input) => {
|
|
|
1468
1300
|
};
|
|
1469
1301
|
//#endregion
|
|
1470
1302
|
//#region src/project-content/executor.ts
|
|
1471
|
-
/** Creates an adapter-free executor for one
|
|
1303
|
+
/** Creates an adapter-free executor for one bounded canonical content range. */
|
|
1472
1304
|
var createMoldeaCliProjectContentExecutor = (coreFactory = createCore) => {
|
|
1473
1305
|
return async (input) => {
|
|
1474
|
-
|
|
1475
|
-
const result = await coreFactory({ limits: Object.freeze({
|
|
1306
|
+
return coreFactory({ limits: Object.freeze({
|
|
1476
1307
|
maxDiagnostics: input.resourceLimits.maxDiagnostics,
|
|
1477
1308
|
maxEntries: input.resourceLimits.maxEntries,
|
|
1478
1309
|
maxEvidence: input.resourceLimits.maxEvidence,
|
|
1479
1310
|
maxFileBytes: input.resourceLimits.maxFileBytes,
|
|
1480
1311
|
maxManifestBytes: input.resourceLimits.maxManifestBytes,
|
|
1481
1312
|
maxTotalBytesRead: input.resourceLimits.maxTotalBytes
|
|
1482
|
-
}) }).
|
|
1483
|
-
|
|
1484
|
-
|
|
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,
|
|
1313
|
+
}) }).readCanonicalContentPage({
|
|
1314
|
+
maxBytes: input.maxBytes,
|
|
1315
|
+
offset: input.offset,
|
|
1490
1316
|
path: input.path,
|
|
1491
|
-
|
|
1492
|
-
|
|
1317
|
+
repository: input.repository,
|
|
1318
|
+
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
1493
1319
|
});
|
|
1494
1320
|
};
|
|
1495
1321
|
};
|
|
1496
|
-
/** Executes one adapter-free explicit canonical content read. */
|
|
1322
|
+
/** Executes one adapter-free explicit canonical content range read. */
|
|
1497
1323
|
var executeMoldeaCliProjectContent = createMoldeaCliProjectContentExecutor();
|
|
1498
1324
|
//#endregion
|
|
1499
1325
|
//#region src/project-content/page.ts
|
|
1500
|
-
/** Creates
|
|
1501
|
-
var
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1326
|
+
/** Creates one candidate content result ending at a Unicode scalar boundary. */
|
|
1327
|
+
var createCandidate = (input, scalars, scalarEnd, snapshotDigest) => {
|
|
1328
|
+
const content = scalars.slice(0, scalarEnd).join("");
|
|
1329
|
+
const byteEnd = input.page.byteStart + Buffer.byteLength(content, "utf8");
|
|
1330
|
+
const isComplete = byteEnd === input.page.totalBytes;
|
|
1331
|
+
return {
|
|
1332
|
+
asset: {
|
|
1333
|
+
contentIdentity: input.page.contentIdentity,
|
|
1334
|
+
path: input.page.path,
|
|
1335
|
+
totalBytes: input.page.totalBytes
|
|
1336
|
+
},
|
|
1337
|
+
chunk: {
|
|
1338
|
+
byteEnd,
|
|
1339
|
+
byteStart: input.page.byteStart,
|
|
1340
|
+
content
|
|
1341
|
+
},
|
|
1342
|
+
cursor: isComplete ? null : encodeMoldeaCliCursor("content", { path: input.page.path }, snapshotDigest, `byte:${byteEnd}`, `byte:${byteEnd}`),
|
|
1343
|
+
snapshotDigest
|
|
1344
|
+
};
|
|
1345
|
+
};
|
|
1346
|
+
/** Creates the stable identity shared by every page of one canonical file snapshot. */
|
|
1347
|
+
var createSnapshotDigest = (input) => calculateMoldeaCliJsonDigest({
|
|
1348
|
+
contentIdentity: input.page.contentIdentity,
|
|
1349
|
+
path: input.page.path,
|
|
1350
|
+
totalBytes: input.page.totalBytes
|
|
1517
1351
|
});
|
|
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
|
-
*/
|
|
1352
|
+
/** Selects the largest Unicode-safe content prefix within the exact output budget. */
|
|
1527
1353
|
var createMoldeaCliContentPage = (input) => {
|
|
1528
|
-
const
|
|
1354
|
+
const snapshotDigest = createSnapshotDigest(input);
|
|
1529
1355
|
const cursorState = input.cursor === null ? null : decodeMoldeaCliCursor({
|
|
1530
1356
|
command: "content",
|
|
1531
1357
|
cursor: input.cursor,
|
|
1532
|
-
filters: { path: input.
|
|
1533
|
-
snapshotDigest
|
|
1358
|
+
filters: { path: input.page.path },
|
|
1359
|
+
snapshotDigest
|
|
1534
1360
|
});
|
|
1535
|
-
const
|
|
1536
|
-
if (
|
|
1361
|
+
const expectedSourceCursor = `byte:${input.page.byteStart}`;
|
|
1362
|
+
if (cursorState === null && input.page.byteStart !== 0 || cursorState !== null && cursorState.sourceCursor !== expectedSourceCursor) throw new MoldeaCliOutputPageException("CURSOR_INVALID");
|
|
1363
|
+
const scalars = Array.from(input.page.content);
|
|
1364
|
+
const emptyResult = createCandidate(input, scalars, 0, snapshotDigest);
|
|
1537
1365
|
if (scalars.length === 0) {
|
|
1538
|
-
|
|
1539
|
-
if (input.measure(emptyResult) > input.maxOutputBytes) throw new MoldeaCliOutputPageException("OUTPUT_BUDGET_TOO_SMALL");
|
|
1366
|
+
if (!input.page.isComplete || input.measure(emptyResult) > input.maxOutputBytes) throw new MoldeaCliOutputPageException("OUTPUT_BUDGET_TOO_SMALL");
|
|
1540
1367
|
return Object.freeze({
|
|
1541
1368
|
...emptyResult,
|
|
1542
1369
|
asset: Object.freeze(emptyResult.asset),
|
|
1543
1370
|
chunk: Object.freeze(emptyResult.chunk)
|
|
1544
1371
|
});
|
|
1545
1372
|
}
|
|
1546
|
-
let lower =
|
|
1373
|
+
let lower = 1;
|
|
1547
1374
|
let upper = scalars.length;
|
|
1548
1375
|
let selected = null;
|
|
1549
1376
|
while (lower <= upper) {
|
|
1550
1377
|
const scalarEnd = lower + Math.floor((upper - lower) / 2);
|
|
1551
|
-
const candidate = createCandidate(input
|
|
1378
|
+
const candidate = createCandidate(input, scalars, scalarEnd, snapshotDigest);
|
|
1552
1379
|
if (input.measure(candidate) <= input.maxOutputBytes) {
|
|
1553
1380
|
selected = candidate;
|
|
1554
1381
|
lower = scalarEnd + 1;
|
|
@@ -1601,10 +1428,68 @@ var parseMoldeaCliScopePathBytes = (input, maxEntries) => {
|
|
|
1601
1428
|
};
|
|
1602
1429
|
//#endregion
|
|
1603
1430
|
//#region src/project-scope/executor.ts
|
|
1431
|
+
/** Reads the complete manifest within its explicit small-file resource bound. */
|
|
1432
|
+
var readBoundedManifest = async (input) => {
|
|
1433
|
+
const operationOptions = input.signal === void 0 ? void 0 : { signal: input.signal };
|
|
1434
|
+
const entry = await input.repository.getEntry(MOLDEA_MANIFEST_PATH, operationOptions);
|
|
1435
|
+
if (entry === null) throw new RepositorySourceException({
|
|
1436
|
+
code: "ENTRY_NOT_FOUND",
|
|
1437
|
+
operation: "read-file-page",
|
|
1438
|
+
path: MOLDEA_MANIFEST_PATH,
|
|
1439
|
+
retryable: false
|
|
1440
|
+
});
|
|
1441
|
+
if (entry.type !== "file" || entry.byteLength === null) throw new RepositorySourceException({
|
|
1442
|
+
code: "ENTRY_NOT_FILE",
|
|
1443
|
+
operation: "read-file-page",
|
|
1444
|
+
path: MOLDEA_MANIFEST_PATH,
|
|
1445
|
+
retryable: false
|
|
1446
|
+
});
|
|
1447
|
+
const maxBytes = Math.min(input.resourceLimits.maxManifestBytes, input.resourceLimits.maxTotalBytes);
|
|
1448
|
+
if (entry.byteLength > maxBytes) throw new RepositorySourceException({
|
|
1449
|
+
code: "RESOURCE_LIMIT_EXCEEDED",
|
|
1450
|
+
operation: "read-file-page",
|
|
1451
|
+
path: MOLDEA_MANIFEST_PATH,
|
|
1452
|
+
retryable: false
|
|
1453
|
+
});
|
|
1454
|
+
const chunks = [];
|
|
1455
|
+
let byteLength = 0;
|
|
1456
|
+
let nextOffset = 0;
|
|
1457
|
+
let isComplete = false;
|
|
1458
|
+
while (!isComplete) {
|
|
1459
|
+
const page = await input.repository.readFilePage(MOLDEA_MANIFEST_PATH, {
|
|
1460
|
+
maxBytes: Math.max(1, entry.byteLength - byteLength),
|
|
1461
|
+
offset: nextOffset,
|
|
1462
|
+
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
1463
|
+
});
|
|
1464
|
+
if (page.snapshot.id !== input.repository.snapshot.id || page.offset !== nextOffset || page.totalBytes !== entry.byteLength || page.bytes.byteLength > entry.byteLength - byteLength || page.bytes.byteLength === 0 && !page.isComplete || !page.isComplete && page.nextOffset !== page.offset + page.bytes.byteLength) throw new RepositorySourceException({
|
|
1465
|
+
code: "INVALID_SOURCE_DATA",
|
|
1466
|
+
operation: "read-file-page",
|
|
1467
|
+
path: MOLDEA_MANIFEST_PATH,
|
|
1468
|
+
retryable: false
|
|
1469
|
+
});
|
|
1470
|
+
chunks.push(page.bytes);
|
|
1471
|
+
byteLength += page.bytes.byteLength;
|
|
1472
|
+
nextOffset = page.nextOffset ?? byteLength;
|
|
1473
|
+
isComplete = page.isComplete;
|
|
1474
|
+
}
|
|
1475
|
+
if (byteLength !== entry.byteLength) throw new RepositorySourceException({
|
|
1476
|
+
code: "PROVIDER_INCOMPLETE",
|
|
1477
|
+
operation: "read-file-page",
|
|
1478
|
+
path: MOLDEA_MANIFEST_PATH,
|
|
1479
|
+
retryable: false
|
|
1480
|
+
});
|
|
1481
|
+
const manifestBytes = new Uint8Array(byteLength);
|
|
1482
|
+
let writeOffset = 0;
|
|
1483
|
+
for (const chunk of chunks) {
|
|
1484
|
+
manifestBytes.set(chunk, writeOffset);
|
|
1485
|
+
writeOffset += chunk.byteLength;
|
|
1486
|
+
}
|
|
1487
|
+
return manifestBytes;
|
|
1488
|
+
};
|
|
1604
1489
|
/** Creates an adapter-free manifest-only Core scope executor. */
|
|
1605
1490
|
var createMoldeaCliProjectScopeExecutor = (coreFactory = createCore) => {
|
|
1606
1491
|
return async (input) => {
|
|
1607
|
-
const manifestBytes = await
|
|
1492
|
+
const manifestBytes = await readBoundedManifest(input);
|
|
1608
1493
|
const scope = await coreFactory({ limits: Object.freeze({
|
|
1609
1494
|
maxDiagnostics: input.resourceLimits.maxDiagnostics,
|
|
1610
1495
|
maxEntries: input.resourceLimits.maxEntries,
|
|
@@ -1676,7 +1561,7 @@ var GitContentTransformUnsupportedException = class extends RepositorySourceExce
|
|
|
1676
1561
|
constructor(path) {
|
|
1677
1562
|
super({
|
|
1678
1563
|
code: "SOURCE_UNAVAILABLE",
|
|
1679
|
-
operation: "read-file",
|
|
1564
|
+
operation: "read-file-page",
|
|
1680
1565
|
path,
|
|
1681
1566
|
retryable: false
|
|
1682
1567
|
});
|
|
@@ -1691,7 +1576,7 @@ var throwIfAborted$1 = (signal, path) => {
|
|
|
1691
1576
|
throw new RepositorySourceException({
|
|
1692
1577
|
cause: signal.reason,
|
|
1693
1578
|
code: "ABORTED",
|
|
1694
|
-
operation: "read-file",
|
|
1579
|
+
operation: "read-file-page",
|
|
1695
1580
|
path,
|
|
1696
1581
|
retryable: false
|
|
1697
1582
|
});
|
|
@@ -1699,16 +1584,22 @@ var throwIfAborted$1 = (signal, path) => {
|
|
|
1699
1584
|
/** Creates the common failure for contradictory underlying lookup data. */
|
|
1700
1585
|
var createInvalidSourceException = (path) => new RepositorySourceException({
|
|
1701
1586
|
code: "INVALID_SOURCE_DATA",
|
|
1702
|
-
operation: "read-file",
|
|
1587
|
+
operation: "read-file-page",
|
|
1703
1588
|
path,
|
|
1704
1589
|
retryable: false
|
|
1705
1590
|
});
|
|
1706
1591
|
var GitContentTransformationGuardRepositoryReader = class {
|
|
1592
|
+
snapshot;
|
|
1707
1593
|
#guardedPaths;
|
|
1708
1594
|
#reader;
|
|
1709
1595
|
constructor(reader, guardedPaths) {
|
|
1710
1596
|
this.#reader = reader;
|
|
1711
1597
|
this.#guardedPaths = guardedPaths;
|
|
1598
|
+
this.snapshot = reader.snapshot;
|
|
1599
|
+
}
|
|
1600
|
+
/** Creates a bounded comparison from this guarded logical snapshot. */
|
|
1601
|
+
compare(candidate, options) {
|
|
1602
|
+
return createRepositoryComparison(this, candidate, options);
|
|
1712
1603
|
}
|
|
1713
1604
|
/**
|
|
1714
1605
|
* Looks up an entry without changing the underlying logical inventory.
|
|
@@ -1743,14 +1634,14 @@ var GitContentTransformationGuardRepositoryReader = class {
|
|
|
1743
1634
|
* - RESOURCE_LIMIT_EXCEEDED: A repository reading resource limit was exceeded.
|
|
1744
1635
|
* - ABORTED: The repository operation was aborted.
|
|
1745
1636
|
*/
|
|
1746
|
-
async
|
|
1637
|
+
async readFilePage(path, options) {
|
|
1747
1638
|
const parsedPath = parseRepositoryPath(path);
|
|
1748
|
-
if (!this.#guardedPaths.has(parsedPath)) return this.#reader.
|
|
1639
|
+
if (!this.#guardedPaths.has(parsedPath)) return this.#reader.readFilePage(parsedPath, options);
|
|
1749
1640
|
throwIfAborted$1(options?.signal, parsedPath);
|
|
1750
1641
|
const entry = await this.#reader.getEntry(parsedPath, options);
|
|
1751
1642
|
throwIfAborted$1(options?.signal, parsedPath);
|
|
1752
1643
|
if (entry !== null && (entry.path !== parsedPath || entry.type !== "file" && entry.type !== "directory" && entry.type !== "symlink")) throw createInvalidSourceException(parsedPath);
|
|
1753
|
-
if (entry?.type !== "file") return this.#reader.
|
|
1644
|
+
if (entry?.type !== "file") return this.#reader.readFilePage(parsedPath, options);
|
|
1754
1645
|
throw new GitContentTransformUnsupportedException(parsedPath);
|
|
1755
1646
|
}
|
|
1756
1647
|
/**
|
|
@@ -1768,8 +1659,8 @@ var GitContentTransformationGuardRepositoryReader = class {
|
|
|
1768
1659
|
* - RESOURCE_LIMIT_EXCEEDED: A repository reading resource limit was exceeded.
|
|
1769
1660
|
* - ABORTED: The repository operation was aborted.
|
|
1770
1661
|
*/
|
|
1771
|
-
|
|
1772
|
-
return this.#reader.
|
|
1662
|
+
listEntriesPage(options) {
|
|
1663
|
+
return this.#reader.listEntriesPage(options);
|
|
1773
1664
|
}
|
|
1774
1665
|
};
|
|
1775
1666
|
/**
|
|
@@ -1803,7 +1694,9 @@ var REPOSITORY_SOURCE_ERROR_MESSAGES = Object.freeze({
|
|
|
1803
1694
|
ENTRY_NOT_DIRECTORY: "The requested repository entry is not a directory.",
|
|
1804
1695
|
ENTRY_NOT_FILE: "The requested repository entry is not a file.",
|
|
1805
1696
|
ENTRY_NOT_FOUND: "The requested repository entry was not found.",
|
|
1697
|
+
INVALID_PAGE_REQUEST: "The repository page request is invalid.",
|
|
1806
1698
|
INVALID_SOURCE_DATA: "The repository source returned invalid data.",
|
|
1699
|
+
PROVIDER_INCOMPLETE: "The repository provider could not expose a complete result.",
|
|
1807
1700
|
RESOURCE_LIMIT_EXCEEDED: "A repository reading resource limit was exceeded.",
|
|
1808
1701
|
SNAPSHOT_CHANGED: "The repository snapshot changed during the operation.",
|
|
1809
1702
|
SOURCE_UNAVAILABLE: "The repository source is unavailable."
|
|
@@ -1817,6 +1710,7 @@ var CORE_CONFIGURATION_ERROR_MESSAGES = Object.freeze({
|
|
|
1817
1710
|
var CORE_OPERATION_ERROR_MESSAGES = Object.freeze({
|
|
1818
1711
|
ABORTED: "The Core operation was aborted.",
|
|
1819
1712
|
ADAPTER_EXECUTION_FAILED: "A runtime adapter failed during inspection.",
|
|
1713
|
+
CONTENT_INVALID: "The requested canonical content is invalid.",
|
|
1820
1714
|
INVALID_ARGUMENT: "The Core operation received an invalid argument.",
|
|
1821
1715
|
RESOURCE_LIMIT_EXCEEDED: "A Core resource limit was exceeded."
|
|
1822
1716
|
});
|
|
@@ -3075,16 +2969,24 @@ var validateOverlayEntry = (entry, operation, path) => {
|
|
|
3075
2969
|
var overlayEntry = (entry, operation, path) => {
|
|
3076
2970
|
validateOverlayEntry(entry, operation, path);
|
|
3077
2971
|
return Object.freeze({
|
|
2972
|
+
byteLength: null,
|
|
2973
|
+
contentIdentity: null,
|
|
3078
2974
|
path,
|
|
3079
2975
|
type: "symlink"
|
|
3080
2976
|
});
|
|
3081
2977
|
};
|
|
3082
2978
|
var GitSymlinkOverlayRepositoryReader = class {
|
|
2979
|
+
snapshot;
|
|
3083
2980
|
#overlayPaths;
|
|
3084
2981
|
#reader;
|
|
3085
2982
|
constructor(reader, overlayPaths) {
|
|
3086
2983
|
this.#reader = reader;
|
|
3087
2984
|
this.#overlayPaths = overlayPaths;
|
|
2985
|
+
this.snapshot = reader.snapshot;
|
|
2986
|
+
}
|
|
2987
|
+
/** Creates a bounded comparison from this logical overlay snapshot. */
|
|
2988
|
+
compare(candidate, options) {
|
|
2989
|
+
return createRepositoryComparison(this, candidate, options);
|
|
3088
2990
|
}
|
|
3089
2991
|
/**
|
|
3090
2992
|
* Looks up an entry while replacing configured host files with logical symlinks.
|
|
@@ -3121,15 +3023,15 @@ var GitSymlinkOverlayRepositoryReader = class {
|
|
|
3121
3023
|
* - RESOURCE_LIMIT_EXCEEDED: A repository reading resource limit was exceeded.
|
|
3122
3024
|
* - ABORTED: The repository operation was aborted.
|
|
3123
3025
|
*/
|
|
3124
|
-
async
|
|
3026
|
+
async readFilePage(path, options) {
|
|
3125
3027
|
const parsedPath = parseRepositoryPath(path);
|
|
3126
|
-
if (!this.#overlayPaths.has(parsedPath)) return this.#reader.
|
|
3127
|
-
throwIfAborted(options
|
|
3128
|
-
validateOverlayEntry(await this.#reader.getEntry(parsedPath, options), "read-file", parsedPath);
|
|
3129
|
-
throwIfAborted(options
|
|
3028
|
+
if (!this.#overlayPaths.has(parsedPath)) return this.#reader.readFilePage(parsedPath, options);
|
|
3029
|
+
throwIfAborted(options.signal, "read-file-page", parsedPath);
|
|
3030
|
+
validateOverlayEntry(await this.#reader.getEntry(parsedPath, options), "read-file-page", parsedPath);
|
|
3031
|
+
throwIfAborted(options.signal, "read-file-page", parsedPath);
|
|
3130
3032
|
throw new RepositorySourceException({
|
|
3131
3033
|
code: "ENTRY_NOT_FILE",
|
|
3132
|
-
operation: "read-file",
|
|
3034
|
+
operation: "read-file-page",
|
|
3133
3035
|
path: parsedPath,
|
|
3134
3036
|
retryable: false
|
|
3135
3037
|
});
|
|
@@ -3149,32 +3051,28 @@ var GitSymlinkOverlayRepositoryReader = class {
|
|
|
3149
3051
|
* - RESOURCE_LIMIT_EXCEEDED: A repository reading resource limit was exceeded.
|
|
3150
3052
|
* - ABORTED: The repository operation was aborted.
|
|
3151
3053
|
*/
|
|
3152
|
-
async
|
|
3153
|
-
const prefix = options
|
|
3054
|
+
async listEntriesPage(options) {
|
|
3055
|
+
const prefix = options.prefix === void 0 ? REPOSITORY_ROOT : parseRepositoryPath(options.prefix);
|
|
3154
3056
|
if (this.#overlayPaths.has(prefix)) {
|
|
3155
|
-
throwIfAborted(options
|
|
3156
|
-
const operationOptions = options
|
|
3157
|
-
validateOverlayEntry(await this.#reader.getEntry(prefix, operationOptions), "list-entries", prefix);
|
|
3158
|
-
throwIfAborted(options
|
|
3057
|
+
throwIfAborted(options.signal, "list-entries-page", prefix);
|
|
3058
|
+
const operationOptions = options.signal === void 0 ? void 0 : { signal: options.signal };
|
|
3059
|
+
validateOverlayEntry(await this.#reader.getEntry(prefix, operationOptions), "list-entries-page", prefix);
|
|
3060
|
+
throwIfAborted(options.signal, "list-entries-page", prefix);
|
|
3159
3061
|
throw new RepositorySourceException({
|
|
3160
3062
|
code: "ENTRY_NOT_DIRECTORY",
|
|
3161
|
-
operation: "list-entries",
|
|
3063
|
+
operation: "list-entries-page",
|
|
3162
3064
|
path: prefix,
|
|
3163
3065
|
retryable: false
|
|
3164
3066
|
});
|
|
3165
3067
|
}
|
|
3166
|
-
const
|
|
3167
|
-
const
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
yield overlayEntry(entry, "list-entries", entry.path);
|
|
3175
|
-
}
|
|
3176
|
-
const missingOverlayPath = unmatchedOverlayPaths.values().next().value;
|
|
3177
|
-
if (missingOverlayPath !== void 0) throw createInvalidOverlayException("list-entries", missingOverlayPath);
|
|
3068
|
+
const page = await this.#reader.listEntriesPage(options);
|
|
3069
|
+
const entries = page.entries.map((entry) => this.#overlayPaths.has(entry.path) ? overlayEntry(entry, "list-entries-page", entry.path) : entry);
|
|
3070
|
+
return Object.freeze({
|
|
3071
|
+
entries: Object.freeze(entries),
|
|
3072
|
+
isComplete: page.isComplete,
|
|
3073
|
+
nextCursor: page.nextCursor,
|
|
3074
|
+
snapshot: this.snapshot
|
|
3075
|
+
});
|
|
3178
3076
|
}
|
|
3179
3077
|
};
|
|
3180
3078
|
/**
|
|
@@ -3222,8 +3120,10 @@ var createWorkingTreeRepositoryReaderFactory = (filesystemReaderFactory = create
|
|
|
3222
3120
|
return contentTransformationGuardFactory(symlinkOverlayFactory(await filesystemReaderFactory({
|
|
3223
3121
|
limits: Object.freeze({
|
|
3224
3122
|
maxCachedBytes: input.resourceLimits.maxTotalBytes,
|
|
3123
|
+
maxDirectoryEntries: input.resourceLimits.maxEntries,
|
|
3225
3124
|
maxEntries: input.resourceLimits.maxEntries,
|
|
3226
|
-
|
|
3125
|
+
maxPageEntries: Math.min(4096, input.resourceLimits.maxEntries),
|
|
3126
|
+
maxReadBytes: input.resourceLimits.maxFileBytes
|
|
3227
3127
|
}),
|
|
3228
3128
|
rootDirectory: input.repositoryRoot,
|
|
3229
3129
|
selection: Object.freeze({
|
|
@@ -3371,7 +3271,8 @@ var createMoldeaCliValidateExecutionResult = (inspection, cliVersion, isJson, cu
|
|
|
3371
3271
|
formatVersion: projection.formatVersion,
|
|
3372
3272
|
page,
|
|
3373
3273
|
snapshotDigest: projection.snapshotDigest,
|
|
3374
|
-
source: projection.source
|
|
3274
|
+
source: projection.source,
|
|
3275
|
+
valid: projection.valid
|
|
3375
3276
|
});
|
|
3376
3277
|
const page = createMoldeaCliOutputPage({
|
|
3377
3278
|
command: "validate",
|
|
@@ -3383,9 +3284,9 @@ var createMoldeaCliValidateExecutionResult = (inspection, cliVersion, isJson, cu
|
|
|
3383
3284
|
snapshotDigest: projection.snapshotDigest
|
|
3384
3285
|
});
|
|
3385
3286
|
const result = Object.freeze(createResult(page));
|
|
3386
|
-
assertMoldeaCliJsonResultIsContentFree(result
|
|
3287
|
+
assertMoldeaCliJsonResultIsContentFree(result);
|
|
3387
3288
|
return Object.freeze({
|
|
3388
|
-
exitCode: result.
|
|
3289
|
+
exitCode: result.valid ? MOLDEA_CLI_EXIT_CODES.Success : MOLDEA_CLI_EXIT_CODES.StructuralInvalid,
|
|
3389
3290
|
stderr: "",
|
|
3390
3291
|
stdout: isJson ? formatMoldeaCliJsonValidateResult(result, cliVersion) : formatMoldeaCliHumanValidateResult(result)
|
|
3391
3292
|
});
|
|
@@ -3405,7 +3306,9 @@ var createMoldeaCliInspectExecutionResult = (inspection, cliVersion, isJson, cur
|
|
|
3405
3306
|
page,
|
|
3406
3307
|
project: projection.project,
|
|
3407
3308
|
snapshotDigest: projection.snapshotDigest,
|
|
3408
|
-
source: projection.source
|
|
3309
|
+
source: projection.source,
|
|
3310
|
+
valid: projection.valid,
|
|
3311
|
+
view: projection.view
|
|
3409
3312
|
});
|
|
3410
3313
|
const page = createMoldeaCliOutputPage({
|
|
3411
3314
|
command: "inspect",
|
|
@@ -3414,10 +3317,11 @@ var createMoldeaCliInspectExecutionResult = (inspection, cliVersion, isJson, cur
|
|
|
3414
3317
|
maxOutputBytes,
|
|
3415
3318
|
measure: (candidate, serializedRecordsUtf8Bytes) => measurePagedOutput(candidate, serializedRecordsUtf8Bytes, isJson, (page) => formatMoldeaCliJsonInspectResult(createResult(page), cliVersion), (page) => formatMoldeaCliHumanInspectResult(createResult(page))),
|
|
3416
3319
|
records: projection.records,
|
|
3320
|
+
sourceCursorForRecord: projection.getSourceCursor,
|
|
3417
3321
|
snapshotDigest: projection.snapshotDigest
|
|
3418
3322
|
});
|
|
3419
3323
|
const result = Object.freeze(createResult(page));
|
|
3420
|
-
assertMoldeaCliJsonResultIsContentFree(result
|
|
3324
|
+
assertMoldeaCliJsonResultIsContentFree(result);
|
|
3421
3325
|
return Object.freeze({
|
|
3422
3326
|
exitCode: inspection.valid ? MOLDEA_CLI_EXIT_CODES.Success : MOLDEA_CLI_EXIT_CODES.StructuralInvalid,
|
|
3423
3327
|
stderr: "",
|
|
@@ -3467,12 +3371,12 @@ var createMoldeaCliScopeExecutionResult = (execution, cliVersion, isJson, cursor
|
|
|
3467
3371
|
* - CURSOR_SNAPSHOT_CHANGED: The continuation cursor belongs to a different repository snapshot.
|
|
3468
3372
|
* - OUTPUT_BUDGET_TOO_SMALL: The output byte budget cannot contain the next complete result.
|
|
3469
3373
|
*/
|
|
3470
|
-
var createMoldeaCliContentExecutionResult = (
|
|
3374
|
+
var createMoldeaCliContentExecutionResult = (pageResult, cliVersion, isJson, cursor, maxOutputBytes) => {
|
|
3471
3375
|
const result = createMoldeaCliContentPage({
|
|
3472
|
-
asset,
|
|
3473
3376
|
cursor,
|
|
3474
3377
|
maxOutputBytes,
|
|
3475
|
-
measure: (candidate) => measureOutput(isJson ? formatMoldeaCliJsonContentResult(candidate, cliVersion) : formatMoldeaCliHumanContentResult(candidate))
|
|
3378
|
+
measure: (candidate) => measureOutput(isJson ? formatMoldeaCliJsonContentResult(candidate, cliVersion) : formatMoldeaCliHumanContentResult(candidate)),
|
|
3379
|
+
page: pageResult
|
|
3476
3380
|
});
|
|
3477
3381
|
return Object.freeze({
|
|
3478
3382
|
exitCode: MOLDEA_CLI_EXIT_CODES.Success,
|
|
@@ -3484,11 +3388,11 @@ var createMoldeaCliContentExecutionResult = (asset, cliVersion, isJson, cursor,
|
|
|
3484
3388
|
//#region src/cli-execution/command-executor.ts
|
|
3485
3389
|
/** Loads adapter-backed Core inspection only for commands that need it. */
|
|
3486
3390
|
var executeLazyCoreInspection = async (input) => {
|
|
3487
|
-
const { executeMoldeaCliCoreInspection } = await import("./chunks/core-composition-
|
|
3391
|
+
const { executeMoldeaCliCoreInspection } = await import("./chunks/core-composition-Bb9OMTs-.js");
|
|
3488
3392
|
return executeMoldeaCliCoreInspection(input);
|
|
3489
3393
|
};
|
|
3490
3394
|
var loadInstalledComposition = async (input) => {
|
|
3491
|
-
const { resolveInstalledMoldeaCliComposition } = await import("./chunks/composition-
|
|
3395
|
+
const { resolveInstalledMoldeaCliComposition } = await import("./chunks/composition-7d632gM8.js");
|
|
3492
3396
|
return resolveInstalledMoldeaCliComposition(input);
|
|
3493
3397
|
};
|
|
3494
3398
|
/** Creates one operational error result without exposing caught failure details. */
|
|
@@ -3501,7 +3405,7 @@ var createOperationalErrorResult = (code, input) => createMoldeaCliErrorResult(c
|
|
|
3501
3405
|
* @param compositionLoader The installed executable-integrity composition boundary.
|
|
3502
3406
|
* @param projectScopeExecutor The adapter-free manifest scope operation.
|
|
3503
3407
|
* @param projectContentExecutor The adapter-free canonical content operation.
|
|
3504
|
-
* @returns A command executor for the schema
|
|
3408
|
+
* @returns A command executor for the schema 4 CLI.
|
|
3505
3409
|
*/
|
|
3506
3410
|
var createMoldeaCliCommandExecutor = (workingTreeDiscovery = discoverGitWorkingTree, workingTreeSnapshotExecutor = executeWorkingTreeSnapshot, coreInspectionExecutor = executeLazyCoreInspection, compositionLoader = loadInstalledComposition, projectScopeExecutor = executeMoldeaCliProjectScope, projectContentExecutor = executeMoldeaCliProjectContent) => {
|
|
3507
3411
|
return async (input) => {
|
|
@@ -3515,6 +3419,12 @@ var createMoldeaCliCommandExecutor = (workingTreeDiscovery = discoverGitWorkingT
|
|
|
3515
3419
|
}
|
|
3516
3420
|
let scopePaths = null;
|
|
3517
3421
|
let contentPath = null;
|
|
3422
|
+
let contentOffset = 0;
|
|
3423
|
+
const inspectionCursor = command === MOLDEA_CLI_COMMANDS.Inspect && options.cursor !== null ? decodeMoldeaCliCursor({
|
|
3424
|
+
command: "inspect",
|
|
3425
|
+
cursor: options.cursor,
|
|
3426
|
+
filters: {}
|
|
3427
|
+
}).sourceCursor : null;
|
|
3518
3428
|
if (command === MOLDEA_CLI_COMMANDS.Scope) {
|
|
3519
3429
|
if (options.pathsInput === "path" && options.path !== null) scopePaths = Object.freeze([options.path]);
|
|
3520
3430
|
else if (options.pathsInput === "stdin" && input.stdin !== void 0) {
|
|
@@ -3525,6 +3435,17 @@ var createMoldeaCliCommandExecutor = (workingTreeDiscovery = discoverGitWorkingT
|
|
|
3525
3435
|
if (command === MOLDEA_CLI_COMMANDS.Content) {
|
|
3526
3436
|
if (options.path === null) return createOperationalErrorResult("CONTENT_PATH_INVALID", input);
|
|
3527
3437
|
contentPath = parseMoldeaCliCanonicalContentPath(options.path);
|
|
3438
|
+
if (options.cursor !== null) {
|
|
3439
|
+
const sourceCursor = decodeMoldeaCliCursor({
|
|
3440
|
+
command: "content",
|
|
3441
|
+
cursor: options.cursor,
|
|
3442
|
+
filters: { path: contentPath }
|
|
3443
|
+
}).sourceCursor;
|
|
3444
|
+
const match = sourceCursor === null ? null : /^byte:(0|[1-9][0-9]*)$/u.exec(sourceCursor);
|
|
3445
|
+
if (match === null) throw new MoldeaCliOutputPageException("CURSOR_INVALID");
|
|
3446
|
+
contentOffset = Number(match[1]);
|
|
3447
|
+
if (!Number.isSafeInteger(contentOffset)) throw new MoldeaCliOutputPageException("CURSOR_INVALID");
|
|
3448
|
+
}
|
|
3528
3449
|
}
|
|
3529
3450
|
const discoveryResult = await workingTreeDiscovery({
|
|
3530
3451
|
invocationDirectory: input.invocationDirectory,
|
|
@@ -3542,12 +3463,16 @@ var createMoldeaCliCommandExecutor = (workingTreeDiscovery = discoverGitWorkingT
|
|
|
3542
3463
|
...signal === void 0 ? {} : { signal }
|
|
3543
3464
|
});
|
|
3544
3465
|
if (command === MOLDEA_CLI_COMMANDS.Content && contentPath !== null) return projectContentExecutor({
|
|
3466
|
+
maxBytes: Math.min(resourceLimits.maxFileBytes, resourceLimits.maxTotalBytes, Math.max(1, Math.floor(options.maxOutputBytes / 2))),
|
|
3467
|
+
offset: contentOffset,
|
|
3545
3468
|
path: contentPath,
|
|
3546
3469
|
repository,
|
|
3547
3470
|
resourceLimits,
|
|
3548
3471
|
...signal === void 0 ? {} : { signal }
|
|
3549
3472
|
});
|
|
3550
3473
|
return coreInspectionExecutor({
|
|
3474
|
+
command: command === MOLDEA_CLI_COMMANDS.Inspect ? "inspect" : "validate",
|
|
3475
|
+
...inspectionCursor === null ? {} : { cursor: inspectionCursor },
|
|
3551
3476
|
repository,
|
|
3552
3477
|
resourceLimits,
|
|
3553
3478
|
...signal === void 0 ? {} : { signal }
|