@cassiomc1/forgeloop 2.0.0 → 2.1.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.
@@ -1526,6 +1526,175 @@ export const E_BASELINE_RECORD_DURING_ACTIVE_TASK = "E_BASELINE_RECORD_DURING_AC
1526
1526
  export const E_POLICY_INITIALIZATION_FAILED = "E_POLICY_INITIALIZATION_FAILED";
1527
1527
  export const E_INIT_KIT_CONFLICT = "E_INIT_KIT_CONFLICT";
1528
1528
 
1529
+ /**
1530
+ * Codes emitted by runtime modules that do not yet have curated metadata.
1531
+ * They are published so integrators can recognise every code ForgeLoop can
1532
+ * return, but they carry no stable compatibility promise until promoted into
1533
+ * PUBLIC_ERROR_CODES. tests/error-registry-coverage.test.js keeps this list in
1534
+ * sync with the codes emitted under src/.
1535
+ */
1536
+ export const EMITTED_UNCLASSIFIED_ERROR_CODES = Object.freeze([
1537
+ "E_ACTION_AUTHORIZATION_REQUIRED",
1538
+ "E_ACTION_CAPABILITY_INVALID",
1539
+ "E_AUDIT_UX_INPUT_INVALID",
1540
+ "E_AUDIT_UX_INVALID_ERROR",
1541
+ "E_AUDIT_UX_OUTPUT_LIMIT",
1542
+ "E_BENCHMARK_INVALID",
1543
+ "E_BUNDLE_DIGEST_INVALID",
1544
+ "E_BUNDLE_PATH_INVALID",
1545
+ "E_BUNDLE_TASK_MISMATCH",
1546
+ "E_CHECK_BLOCKED",
1547
+ "E_CHECK_EXECUTION_PROVENANCE_MISSING",
1548
+ "E_CHECK_FAILED",
1549
+ "E_CHECK_REQUIRED",
1550
+ "E_COMMAND_EXECUTION_FAILED",
1551
+ "E_COMMAND_PROVENANCE_UNATTESTED",
1552
+ "E_COMMAND_UNSUPPORTED",
1553
+ "E_CONFIG_INVALID",
1554
+ "E_CONTINUITY_INCONSISTENT",
1555
+ "E_CONTRACT_INPUT_CONFLICT",
1556
+ "E_CONTRACT_PRESET_UNKNOWN",
1557
+ "E_CONTRACT_PROFILE_STRICT_UNVERIFIED",
1558
+ "E_CONTRACT_REVISION_UNSAFE",
1559
+ "E_CYCLE_CLOSED",
1560
+ "E_DECISION_BINDING_INVALID",
1561
+ "E_DECISION_IMMUTABLE",
1562
+ "E_DECISION_LEDGER_INVALID",
1563
+ "E_DISCOVERY_REQUIRED",
1564
+ "E_DUPLICATE_PROFILE_SOURCE",
1565
+ "E_EMULATED_SERVICES_CANCELLED",
1566
+ "E_EMULATED_SERVICES_CLEANUP_FAILED",
1567
+ "E_EMULATED_SERVICES_CONFIG_INVALID",
1568
+ "E_EMULATED_SERVICES_ENDPOINT_INVALID",
1569
+ "E_EMULATED_SERVICES_EXECUTION_FAILED",
1570
+ "E_EMULATED_SERVICES_OUTPUT_INVALID",
1571
+ "E_EMULATED_SERVICES_OUTPUT_LIMIT",
1572
+ "E_EMULATED_SERVICES_TIMEOUT",
1573
+ "E_EMULATED_SERVICES_UNAVAILABLE",
1574
+ "E_EMULATED_SERVICES_VERSION_UNSUPPORTED",
1575
+ "E_EVENT_INVALID",
1576
+ "E_EVIDENCE_BLOCKED",
1577
+ "E_EVIDENCE_MISSING",
1578
+ "E_EXECUTION_INVALID",
1579
+ "E_EXECUTION_PROFILE_CONTEXT_INVALID",
1580
+ "E_GATE_REVALIDATION_ACK_REQUIRED",
1581
+ "E_GATE_REVALIDATION_INVALID",
1582
+ "E_GATE_REVALIDATION_NOT_STALE",
1583
+ "E_GATE_REVALIDATION_PHASE_INVALID",
1584
+ "E_GATE_REVALIDATION_UNSAFE",
1585
+ "E_GATE_TASK_MISMATCH",
1586
+ "E_HIDDEN_KIT_MIGRATION_CONFLICT",
1587
+ "E_INITIAL_LIFECYCLE_INVALID",
1588
+ "E_INPUT_CONFLICT",
1589
+ "E_INSTALLATION_INVALID",
1590
+ "E_INTEGRATION_RESOURCE_UNKNOWN",
1591
+ "E_LEDGER_HASH_INVALID",
1592
+ "E_LEDGER_INVALID",
1593
+ "E_LEDGER_RELATION_INVALID",
1594
+ "E_LEDGER_SOURCE_INVALID",
1595
+ "E_LEDGER_STALE",
1596
+ "E_LEGACY_FILE_MIGRATION_CONFLICT",
1597
+ "E_MODEL_ROUTE_SAFETY_FLOOR_INVALID",
1598
+ "E_NATIVE_ADAPTER_MIGRATION_CONFLICT",
1599
+ "E_NEXT_ACTION_BLOCKED",
1600
+ "E_NO_INFORMATION_GAIN",
1601
+ "E_PHASE_ARTIFACT_STALE",
1602
+ "E_PHASE_EVIDENCE_MISSING",
1603
+ "E_PHASE_UNKNOWN",
1604
+ "E_PHASE_UNSUPPORTED",
1605
+ "E_POLICY_UNKNOWN",
1606
+ "E_PREFLIGHT_CONTRACT_STALE",
1607
+ "E_PREFLIGHT_READY_INCONSISTENT",
1608
+ "E_PREFLIGHT_ROUTE_STALE",
1609
+ "E_PREFLIGHT_TASK_MISMATCH",
1610
+ "E_PRODUCTION_READINESS_REQUIREMENT_PENDING",
1611
+ "E_PROFILE_MIGRATION_CONFLICT",
1612
+ "E_PROFILE_SOURCE_INVALID",
1613
+ "E_PROVIDER_AUTHORITY_ESCALATION",
1614
+ "E_PROVIDER_CAPABILITY_UNSUPPORTED",
1615
+ "E_PROVIDER_EXECUTION_FAILED",
1616
+ "E_PROVIDER_INVALID",
1617
+ "E_PROVIDER_OUTPUT_INVALID",
1618
+ "E_PROVIDER_OUTPUT_LIMIT",
1619
+ "E_PROVIDER_TIMEOUT",
1620
+ "E_PROVIDER_UNAVAILABLE",
1621
+ "E_REPOSITORY_GIT_COMMAND_FAILED",
1622
+ "E_REQUIRED_ARTIFACT_STALE",
1623
+ "E_REQUIREMENT_UNMET",
1624
+ "E_REVIEW_FINDING_REQUIRED",
1625
+ "E_ROUTE_PHASE_UNSUPPORTED",
1626
+ "E_STATE_INVALID",
1627
+ "E_STATE_LEDGER_MISMATCH",
1628
+ "E_STATE_REVISION_CONFLICT",
1629
+ "E_STATE_UNREADABLE",
1630
+ "E_STORAGE_ARTIFACT_BYTES_UNAVAILABLE",
1631
+ "E_STORAGE_ARTIFACT_INVALID",
1632
+ "E_STORAGE_ASYNC_TRANSACTION",
1633
+ "E_STORAGE_ATTACHMENT_INVALID",
1634
+ "E_STORAGE_BACKUP_INVALID",
1635
+ "E_STORAGE_BUSY",
1636
+ "E_STORAGE_CATALOG_CHANGED",
1637
+ "E_STORAGE_CONFIGURATION_INVALID",
1638
+ "E_STORAGE_CORRUPT",
1639
+ "E_STORAGE_EXPORT_DESTINATION",
1640
+ "E_STORAGE_EXPORT_IDENTITY",
1641
+ "E_STORAGE_EXPORT_UNSUPPORTED",
1642
+ "E_STORAGE_FULL",
1643
+ "E_STORAGE_IMPORT_ABORTED",
1644
+ "E_STORAGE_IMPORT_DESTINATION_EXISTS",
1645
+ "E_STORAGE_IMPORT_FAILED",
1646
+ "E_STORAGE_IMPORT_IDENTITY_COLLISION",
1647
+ "E_STORAGE_IMPORT_NAMESPACE_INVALID",
1648
+ "E_STORAGE_IMPORT_SIGNATURE_UNMAPPED",
1649
+ "E_STORAGE_IMPORT_SINGLETON_UNSUPPORTED",
1650
+ "E_STORAGE_INTEGRITY_INVALID",
1651
+ "E_STORAGE_INTERRUPTED",
1652
+ "E_STORAGE_MAINTENANCE_IN_PROGRESS",
1653
+ "E_STORAGE_MAINTENANCE_OWNER_INVALID",
1654
+ "E_STORAGE_METADATA_INVALID",
1655
+ "E_STORAGE_MIGRATION_ACTIVATION_INVALID",
1656
+ "E_STORAGE_MIGRATION_ARCHIVE_INVALID",
1657
+ "E_STORAGE_MIGRATION_BUSY",
1658
+ "E_STORAGE_MIGRATION_CAPTURE_INVALID",
1659
+ "E_STORAGE_MIGRATION_DESTINATION_INVALID",
1660
+ "E_STORAGE_MIGRATION_PARITY_INVALID",
1661
+ "E_STORAGE_MIGRATION_PUBLICATION_INVALID",
1662
+ "E_STORAGE_MIGRATION_QUIESCENCE_REQUIRED",
1663
+ "E_STORAGE_MIGRATION_REQUIRED",
1664
+ "E_STORAGE_MIGRATION_SOURCE_CHANGED",
1665
+ "E_STORAGE_MIGRATION_SOURCE_INVALID",
1666
+ "E_STORAGE_MIGRATION_TERMINAL_INVALID",
1667
+ "E_STORAGE_MIGRATION_UNMAPPED_SOURCE",
1668
+ "E_STORAGE_MIGRATION_VALIDATION_FAILED",
1669
+ "E_STORAGE_OBSERVATION_INCOMPLETE",
1670
+ "E_STORAGE_OPERATION_UNSUPPORTED",
1671
+ "E_STORAGE_PAYLOAD_MISMATCH",
1672
+ "E_STORAGE_READ_ONLY",
1673
+ "E_STORAGE_RESTORE_INVALID",
1674
+ "E_STORAGE_RUNTIME_CLOSED",
1675
+ "E_STORAGE_RUNTIME_CONFIGURATION_INVALID",
1676
+ "E_STORAGE_SNAPSHOT_TRANSACTION",
1677
+ "E_STORAGE_SOURCE_ROLLBACK_INVALID",
1678
+ "E_STORAGE_SOURCE_ROLLBACK_VALIDATION_INVALID",
1679
+ "E_STORAGE_TOPOLOGY_UNSUPPORTED",
1680
+ "E_STORAGE_TRANSACTION_EXPIRED",
1681
+ "E_STORAGE_TRANSACTION_INVALID",
1682
+ "E_STORAGE_TRANSACTION_LEAKED",
1683
+ "E_STORAGE_UNSUPPORTED_RUNTIME",
1684
+ "E_STORAGE_VERSION_MARKER_INVALID",
1685
+ "E_STORAGE_VERSION_UNSUPPORTED",
1686
+ "E_TARGET_REQUIRED",
1687
+ "E_TASK_CLAIM_CONFLICT",
1688
+ "E_TASK_ID_MISMATCH",
1689
+ "E_TASK_LOCK_STATE_UNKNOWN",
1690
+ "E_TASK_PHASE_INVALID",
1691
+ "E_TEST_ID_UNKNOWN",
1692
+ "E_TEST_PRUNE_BLOCKED",
1693
+ "E_TRANSACTION_INCOMPLETE",
1694
+ "E_UNRESOLVED_DECISION",
1695
+ "E_VERIFICATION_CHECK_REQUIRED",
1696
+ ]);
1697
+
1529
1698
  export const ALL_KNOWN_ERROR_CODES = Object.freeze(new Set([
1530
1699
  ...FAILURE_CODES,
1531
1700
  E_VERIFICATION_TOOL_UNAVAILABLE,
@@ -1791,20 +1960,29 @@ export const ALL_KNOWN_ERROR_CODES = Object.freeze(new Set([
1791
1960
  E_HANDOFF_STALE,
1792
1961
  E_HANDOFF_ALREADY_ACCEPTED,
1793
1962
  E_HANDOFF_ACCEPTANCE_INCONSISTENT,
1963
+ ...EMITTED_UNCLASSIFIED_ERROR_CODES,
1794
1964
  ]));
1795
1965
 
1966
+ const UNCLASSIFIED_ERROR_CODES = new Set(EMITTED_UNCLASSIFIED_ERROR_CODES);
1967
+
1796
1968
  /**
1797
1969
  * Complete public registry. Older callers can retain PUBLIC_ERROR_CODES while
1798
1970
  * documentation and compatibility handshakes enumerate every stable code.
1799
1971
  */
1800
1972
  export const PUBLIC_ERROR_REGISTRY = Object.freeze(
1801
1973
  Object.fromEntries([...ALL_KNOWN_ERROR_CODES].sort().map((code) => [code, Object.freeze(
1802
- PUBLIC_ERROR_CODES[code] ?? {
1974
+ PUBLIC_ERROR_CODES[code] ?? (UNCLASSIFIED_ERROR_CODES.has(code) ? {
1975
+ code,
1976
+ category: "protocol",
1977
+ classification: "PUBLIC_UNCLASSIFIED",
1978
+ meaning: "Emitted by ForgeLoop but not yet curated; the code name is the contract and it carries no stable compatibility promise.",
1979
+ safeResolution: "Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json.",
1980
+ } : {
1803
1981
  code,
1804
1982
  category: "protocol",
1805
1983
  classification: "PUBLIC_STABLE",
1806
1984
  meaning: "A ForgeLoop protocol validation or lifecycle condition was not satisfied.",
1807
1985
  safeResolution: "Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json.",
1808
- },
1986
+ }),
1809
1987
  )])),
1810
1988
  );
@@ -8,6 +8,19 @@ import { NEXT_ACTIONS, commandFor, decision, recordTerminalResultCommandSpec, re
8
8
  import { artifactError, checkListReasons, loadArtifact, requirementsAndCoverage } from "./next-action-artifacts.js";
9
9
  import { reviewCorrectionAction } from "./next-action-review-correction.js";
10
10
 
11
+
12
+ // Only an absent receipt is an expected recovery input; corrupt or unreadable
13
+ // storage propagates so the caller fails closed.
14
+ async function readRecoveryReceipt(target, receiptRel, packageRoot) {
15
+ try {
16
+ const receiptArtifact = await readJsonArtifact(target, receiptRel, "execution-receipt", packageRoot);
17
+ return receiptArtifact?.value ?? null;
18
+ } catch (error) {
19
+ if (error?.code !== "ARTIFACT_MISSING") throw error;
20
+ return null;
21
+ }
22
+ }
23
+
11
24
  export async function resolveReviewingPhase(options) {
12
25
  const { target, packageRoot, explicitTaskId, state, context, requiredArtifacts } = options;
13
26
  const invalidChecks = checkListReasons(state);
@@ -40,11 +53,7 @@ async function resolveReviewingEvidence({ state, context, requiredArtifacts, tar
40
53
  if (state.lastCompletionAttempt?.status === "REJECTED") {
41
54
  try {
42
55
  const ledger = await validateEventLedger(target, packageRoot, { taskId: explicitTaskId, eventsPath: eventsRel });
43
- let currentReceipt = null;
44
- try {
45
- const receiptArtifact = await readJsonArtifact(target, receiptRel, "execution-receipt", packageRoot);
46
- currentReceipt = receiptArtifact?.value;
47
- } catch {}
56
+ const currentReceipt = await readRecoveryReceipt(target, receiptRel, packageRoot);
48
57
  const recoveryAuth = validateCompletionRecoveryAuthorization({
49
58
  state,
50
59
  receipt: currentReceipt,
@@ -0,0 +1,221 @@
1
+ // Bounded parsers for untrusted repository manifest text. They never throw on
2
+ // malformed input: every entry point returns an `invalid` shape instead.
3
+ import { PROJECT_DETECTION_LIMITS } from "./limits.js";
4
+ import { uniqueSorted } from "./shared.js";
5
+
6
+ const MAX_MANIFEST_BYTES = PROJECT_DETECTION_LIMITS.maxManifestBytes;
7
+ const MAX_XML_TEXT_LENGTH = 4096;
8
+ export const DOTNET_SDKS = new Set([
9
+ "Microsoft.NET.Sdk",
10
+ "Microsoft.NET.Sdk.Web",
11
+ "Microsoft.NET.Sdk.Worker",
12
+ "Microsoft.NET.Sdk.Razor",
13
+ "Microsoft.NET.Sdk.BlazorWebAssembly",
14
+ "Aspire.AppHost.Sdk",
15
+ "MSTest.Sdk",
16
+ ]);
17
+ const ASPNETCORE_SDKS = new Set([
18
+ "Microsoft.NET.Sdk.Web",
19
+ "Microsoft.NET.Sdk.Razor",
20
+ "Microsoft.NET.Sdk.BlazorWebAssembly",
21
+ ]);
22
+
23
+ function invalidDotNetProject() {
24
+ return {
25
+ valid: false,
26
+ sdkStyle: false,
27
+ projectSdks: [],
28
+ targetFrameworks: [],
29
+ frameworkReferences: [],
30
+ packageReferences: [],
31
+ projectReferences: [],
32
+ dotnet: false,
33
+ aspnetcore: false,
34
+ abp: false,
35
+ };
36
+ }
37
+
38
+ function findXmlTagEnd(text, start) {
39
+ let quote = null;
40
+ for (let index = start; index < text.length; index += 1) {
41
+ const character = text[index];
42
+ if (quote) {
43
+ if (character === quote) quote = null;
44
+ } else if (character === "\"" || character === "'") {
45
+ quote = character;
46
+ } else if (character === ">") {
47
+ return index;
48
+ }
49
+ }
50
+ return -1;
51
+ }
52
+
53
+ function parseXmlAttributes(text) {
54
+ const attributes = {};
55
+ let index = 0;
56
+ while (index < text.length) {
57
+ while (index < text.length && /\s/u.test(text[index])) index += 1;
58
+ if (index >= text.length) break;
59
+ const name = text.slice(index).match(/^[A-Za-z_][A-Za-z0-9_.:-]*/u)?.[0];
60
+ if (!name) return null;
61
+ index += name.length;
62
+ while (index < text.length && /\s/u.test(text[index])) index += 1;
63
+ if (text[index] !== "=") return null;
64
+ index += 1;
65
+ while (index < text.length && /\s/u.test(text[index])) index += 1;
66
+ const quote = text[index];
67
+ if (quote !== "\"" && quote !== "'") return null;
68
+ index += 1;
69
+ const end = text.indexOf(quote, index);
70
+ if (end < 0 || Object.prototype.hasOwnProperty.call(attributes, name)) return null;
71
+ attributes[name] = text.slice(index, end);
72
+ index = end + 1;
73
+ }
74
+ return attributes;
75
+ }
76
+
77
+ function appendXmlText(stack, value) {
78
+ if (value === "") return true;
79
+ const current = stack[stack.length - 1];
80
+ if (!current) return value.trim() === "";
81
+ current.textParts.push(value);
82
+ return true;
83
+ }
84
+
85
+ function consumeXmlSpecialToken(text, tagStart, stack) {
86
+ if (text.startsWith("<!--", tagStart)) {
87
+ const end = text.indexOf("-->", tagStart + 4);
88
+ return end < 0 ? { valid: false } : { valid: true, nextIndex: end + 3 };
89
+ }
90
+ if (text.startsWith("<![CDATA[", tagStart)) {
91
+ const end = text.indexOf("]]>", tagStart + 9);
92
+ if (end < 0 || stack.length === 0) return { valid: false };
93
+ stack[stack.length - 1].textParts.push(text.slice(tagStart + 9, end));
94
+ return { valid: true, nextIndex: end + 3 };
95
+ }
96
+ if (text.startsWith("<?", tagStart)) {
97
+ const end = text.indexOf("?>", tagStart + 2);
98
+ return end < 0 ? { valid: false } : { valid: true, nextIndex: end + 2 };
99
+ }
100
+ if (text.startsWith("<!", tagStart)) return { valid: false };
101
+ return null;
102
+ }
103
+
104
+ function closeXmlNode(raw, state) {
105
+ const closing = raw.slice(1).trim().match(/^([A-Za-z_][A-Za-z0-9_.:-]*)\s*$/u)?.[1];
106
+ const open = state.stack.pop();
107
+ if (!closing || !open || open.name !== closing) return false;
108
+ open.text = open.textParts.join("");
109
+ if (state.stack.length === 0) {
110
+ if (state.rootClosed || open !== state.root) return false;
111
+ state.rootClosed = true;
112
+ }
113
+ return true;
114
+ }
115
+
116
+ function openXmlNode(raw, state) {
117
+ const selfClosing = /\/\s*$/u.test(raw);
118
+ const body = selfClosing ? raw.replace(/\/\s*$/u, "").trimEnd() : raw;
119
+ const name = body.match(/^([A-Za-z_][A-Za-z0-9_.:-]*)/u)?.[1];
120
+ if (!name) return false;
121
+ if (state.stack.length === 0 && (state.root || state.rootClosed)) return false;
122
+ if (!state.root && state.expectedRoot && name !== state.expectedRoot) return false;
123
+ const attributes = parseXmlAttributes(body.slice(name.length).trim());
124
+ if (!attributes) return false;
125
+ const node = { name, attributes, textParts: [], children: [], text: "" };
126
+ state.nodes.push(node);
127
+ if (state.stack.length > 0) state.stack[state.stack.length - 1].children.push(node);
128
+ if (!state.root) state.root = node;
129
+ if (!selfClosing) state.stack.push(node);
130
+ else if (node === state.root) state.rootClosed = true;
131
+ return true;
132
+ }
133
+
134
+ function consumeXmlTag(text, tagStart, state) {
135
+ const tagEnd = findXmlTagEnd(text, tagStart + 1);
136
+ if (tagEnd < 0) return null;
137
+ const raw = text.slice(tagStart + 1, tagEnd).trim();
138
+ if (raw === "") return null;
139
+ const valid = raw.startsWith("/") ? closeXmlNode(raw, state) : openXmlNode(raw, state);
140
+ return { valid, nextIndex: tagEnd + 1 };
141
+ }
142
+
143
+ export function parseXmlStructure(text, expectedRoot = null) {
144
+ if (typeof text !== "string" || text.length > MAX_MANIFEST_BYTES || /\r(?!\n)/u.test(text)) return null;
145
+ const state = { nodes: [], stack: [], root: null, rootClosed: false, expectedRoot };
146
+ let index = 0;
147
+ while (index < text.length) {
148
+ const tagStart = text.indexOf("<", index);
149
+ if (tagStart < 0) break;
150
+ if (!appendXmlText(state.stack, text.slice(index, tagStart))) return null;
151
+ const special = consumeXmlSpecialToken(text, tagStart, state.stack);
152
+ if (special) {
153
+ if (!special.valid) return null;
154
+ index = special.nextIndex;
155
+ continue;
156
+ }
157
+ const tag = consumeXmlTag(text, tagStart, state);
158
+ if (!tag?.valid) return null;
159
+ index = tag.nextIndex;
160
+ }
161
+ if (!appendXmlText(state.stack, text.slice(index))) return null;
162
+ if (!state.root || state.stack.length > 0 || !state.rootClosed) return null;
163
+ return { root: state.root, nodes: state.nodes };
164
+ }
165
+
166
+ function normalizeSdkName(value) {
167
+ return typeof value === "string" ? value.trim().split("/")[0] : "";
168
+ }
169
+
170
+ function xmlValues(nodes, name, attribute = "Include") {
171
+ return uniqueSorted(nodes
172
+ .filter((node) => node.name === name && typeof node.attributes?.[attribute] === "string")
173
+ .map((node) => node.attributes[attribute].trim())
174
+ .filter(Boolean));
175
+ }
176
+
177
+ function targetFrameworkValues(nodes) {
178
+ return uniqueSorted(nodes
179
+ .filter((node) => (node.name === "TargetFramework" || node.name === "TargetFrameworks")
180
+ && node.children.length === 0
181
+ && node.text.length <= MAX_XML_TEXT_LENGTH)
182
+ .flatMap((node) => node.text.split(";"))
183
+ .map((value) => value.trim())
184
+ .filter(Boolean));
185
+ }
186
+
187
+ export function parseDotNetProject(text) {
188
+ const invalid = invalidDotNetProject();
189
+ if (typeof text !== "string" || text.length > MAX_MANIFEST_BYTES) return invalid;
190
+ const document = parseXmlStructure(text, "Project");
191
+ if (!document) return invalid;
192
+
193
+ const sdkValues = [
194
+ document.root.attributes.Sdk ?? "",
195
+ ...document.nodes.filter((node) => node.name === "Sdk").map((node) => node.attributes.Name ?? ""),
196
+ ];
197
+ const projectSdks = uniqueSorted(sdkValues
198
+ .flatMap((value) => value.split(";"))
199
+ .map(normalizeSdkName)
200
+ .filter(Boolean));
201
+ const recognizedSdks = projectSdks.filter((sdk) => DOTNET_SDKS.has(sdk));
202
+ const frameworkReferences = xmlValues(document.nodes, "FrameworkReference");
203
+ const packageReferences = xmlValues(document.nodes, "PackageReference");
204
+ const projectReferences = xmlValues(document.nodes, "ProjectReference");
205
+ const dotnet = recognizedSdks.length > 0;
206
+ const aspnetcore = dotnet && (recognizedSdks.some((sdk) => ASPNETCORE_SDKS.has(sdk))
207
+ || frameworkReferences.some((reference) => reference.toLowerCase() === "microsoft.aspnetcore.app"));
208
+ const abp = dotnet && packageReferences.some((reference) => reference.toLowerCase().startsWith("volo.abp."));
209
+ return {
210
+ valid: true,
211
+ sdkStyle: dotnet,
212
+ projectSdks,
213
+ targetFrameworks: targetFrameworkValues(document.nodes),
214
+ frameworkReferences,
215
+ packageReferences,
216
+ projectReferences,
217
+ dotnet,
218
+ aspnetcore,
219
+ abp,
220
+ };
221
+ }
@@ -0,0 +1,9 @@
1
+ export const PROJECT_DETECTION_LIMITS = Object.freeze({
2
+ maxManifests: 256,
3
+ maxSolutionFiles: 64,
4
+ maxManifestBytes: 1024 * 1024,
5
+ maxSourceFiles: 256,
6
+ maxSourceBytes: 512 * 1024,
7
+ maxVisitedDirectories: 4096,
8
+ maxVisitedEntries: 20000,
9
+ });