d365fo-mcp 1.22.0 → 1.24.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.
Files changed (316) hide show
  1. package/.github/copilot-instructions.md +2 -1
  2. package/README.md +1 -1
  3. package/dist/bridge/bridgeAdapter.d.ts +5 -4
  4. package/dist/bridge/bridgeAdapter.js +97 -30
  5. package/dist/bridge/bridgeClient.d.ts +1 -1
  6. package/dist/bridge/bridgeClient.js +11 -7
  7. package/dist/bridge/bridgeTypes.d.ts +13 -0
  8. package/dist/bridge/lineReader.d.ts +36 -0
  9. package/dist/bridge/lineReader.js +78 -0
  10. package/dist/cli/commands/doctor.d.ts +10 -0
  11. package/dist/cli/commands/doctor.js +49 -0
  12. package/dist/cli/commands/indexCmd.d.ts +15 -0
  13. package/dist/cli/commands/indexCmd.js +34 -1
  14. package/dist/cli/commands/setup.js +2 -0
  15. package/dist/config/settings.js +142 -4
  16. package/dist/index.js +29 -2
  17. package/dist/knowledge/formPatterns/catalog/subPatterns/customFilters.js +2 -2
  18. package/dist/knowledge/formPatterns/catalog/subPatterns/fields.js +13 -11
  19. package/dist/knowledge/formPatterns/catalog/subPatterns/toolbar.js +6 -6
  20. package/dist/knowledge/formPatterns/catalog/subPatterns/workspaceSections.d.ts +4 -3
  21. package/dist/knowledge/formPatterns/catalog/subPatterns/workspaceSections.js +14 -13
  22. package/dist/knowledge/formPatterns/catalog/topLevel/detailsMaster.js +2 -2
  23. package/dist/knowledge/formPatterns/catalog/topLevel/detailsTransaction.js +1 -1
  24. package/dist/knowledge/formPatterns/catalog/topLevel/dialog.js +7 -7
  25. package/dist/knowledge/formPatterns/catalog/topLevel/factBox.js +2 -2
  26. package/dist/knowledge/formPatterns/catalog/topLevel/listPage.js +1 -1
  27. package/dist/knowledge/formPatterns/catalog/topLevel/lookup.d.ts +0 -1
  28. package/dist/knowledge/formPatterns/catalog/topLevel/lookup.js +8 -20
  29. package/dist/knowledge/formPatterns/catalog/topLevel/simpleDetails.js +4 -4
  30. package/dist/knowledge/formPatterns/catalog/topLevel/simpleList.js +3 -2
  31. package/dist/knowledge/formPatterns/catalog/topLevel/simpleListDetails.js +2 -2
  32. package/dist/knowledge/formPatterns/catalog/topLevel/tableOfContents.js +1 -1
  33. package/dist/knowledge/formPatterns/catalog/topLevel/task.js +57 -12
  34. package/dist/knowledge/formPatterns/catalog/topLevel/wizard.js +1 -1
  35. package/dist/knowledge/formPatterns/index.js +1 -4
  36. package/dist/knowledge/formPatterns/platform.d.ts +87 -0
  37. package/dist/knowledge/formPatterns/platform.generated.d.ts +14 -0
  38. package/dist/knowledge/formPatterns/platform.generated.js +176 -0
  39. package/dist/knowledge/formPatterns/platform.js +149 -0
  40. package/dist/knowledge/formPatterns/platformDefaults.generated.d.ts +13 -0
  41. package/dist/knowledge/formPatterns/platformDefaults.generated.js +54 -0
  42. package/dist/metadata/binaryModelImport.d.ts +208 -0
  43. package/dist/metadata/binaryModelImport.js +311 -0
  44. package/dist/metadata/formPatternMiner.d.ts +6 -0
  45. package/dist/metadata/formPatternMiner.js +38 -11
  46. package/dist/metadata/labelParser.d.ts +12 -0
  47. package/dist/metadata/labelParser.js +27 -7
  48. package/dist/metadata/modelDescriptor.d.ts +22 -0
  49. package/dist/metadata/modelDescriptor.js +71 -4
  50. package/dist/metadata/objectSourceSetting.d.ts +9 -0
  51. package/dist/metadata/objectSourceSetting.js +11 -0
  52. package/dist/metadata/startupIndexing.d.ts +2 -0
  53. package/dist/metadata/startupIndexing.js +30 -7
  54. package/dist/metadata/symbolIndex.d.ts +189 -18
  55. package/dist/metadata/symbolIndex.js +445 -101
  56. package/dist/metadata/types.d.ts +13 -0
  57. package/dist/metadata/xmlParser.d.ts +21 -0
  58. package/dist/metadata/xmlParser.js +47 -2
  59. package/dist/metadata/xppDeclaration.d.ts +10 -0
  60. package/dist/metadata/xppDeclaration.js +1 -1
  61. package/dist/prompts/systemInstructions.d.ts +4 -2
  62. package/dist/prompts/systemInstructions.js +13 -6
  63. package/dist/scripts/build-database.js +904 -241
  64. package/dist/scripts/build-fts.js +548 -100
  65. package/dist/scripts/extract-metadata.js +259 -34
  66. package/dist/scripts/startupIndexWorker.js +1530 -175
  67. package/dist/server/mcpServer.js +3 -0
  68. package/dist/server/serverMode.d.ts +5 -0
  69. package/dist/server/serverMode.js +6 -0
  70. package/dist/server/toolAnnotations.d.ts +4 -3
  71. package/dist/server/toolAnnotations.js +9 -6
  72. package/dist/server/toolSchemas/buildD365foProject.d.ts +9 -0
  73. package/dist/server/toolSchemas/buildD365foProject.js +13 -4
  74. package/dist/server/toolSchemas/d365foFile.js +5 -5
  75. package/dist/server/toolSchemas/getObjectInfo.d.ts +1 -1
  76. package/dist/server/toolSchemas/getObjectInfo.js +1 -1
  77. package/dist/server/toolSchemas/index.d.ts +13 -2
  78. package/dist/server/toolSchemas/labels.js +1 -1
  79. package/dist/server/toolSchemas/objectPatterns.js +1 -1
  80. package/dist/server/toolSchemas/runSystestClass.js +1 -1
  81. package/dist/server/toolSchemas/search.js +1 -1
  82. package/dist/server/toolSchemas/updateSymbolIndex.d.ts +4 -0
  83. package/dist/server/toolSchemas/updateSymbolIndex.js +7 -4
  84. package/dist/server/toolSchemas/validateObjectNaming.d.ts +4 -1
  85. package/dist/server/toolSchemas/validateObjectNaming.js +7 -4
  86. package/dist/tools/analysis/analyzeCompleteness.js +11 -2
  87. package/dist/tools/analysis/exactLabelLookup.d.ts +35 -0
  88. package/dist/tools/analysis/exactLabelLookup.js +187 -0
  89. package/dist/tools/analysis/extensionSearch.d.ts +1 -1
  90. package/dist/tools/analysis/extensionSearch.js +5 -5
  91. package/dist/tools/analysis/findReferences.d.ts +24 -1
  92. package/dist/tools/analysis/findReferences.js +175 -30
  93. package/dist/tools/analysis/search.js +40 -19
  94. package/dist/tools/analysis/validateFormPattern.d.ts +1 -1
  95. package/dist/tools/analysis/validateFormPattern.js +1 -1
  96. package/dist/tools/analysis/validateObjectNaming.js +16 -6
  97. package/dist/tools/analysis/validateXpp.js +56 -6
  98. package/dist/tools/d365foFile.js +54 -12
  99. package/dist/tools/generateObject.d.ts +1 -4
  100. package/dist/tools/generateObject.js +22 -1
  101. package/dist/tools/knowledge/analyzeExtensionPoints.js +9 -7
  102. package/dist/tools/knowledge/apiUsagePatterns.js +2 -1
  103. package/dist/tools/knowledge/findCocExtensions.js +22 -15
  104. package/dist/tools/knowledge/findEventHandlers.js +5 -3
  105. package/dist/tools/knowledge/formPattern.d.ts +1 -1
  106. package/dist/tools/knowledge/formPattern.js +1 -1
  107. package/dist/tools/knowledge/methodSignature.js +7 -1
  108. package/dist/tools/knowledge/xppKnowledge.js +123 -24
  109. package/dist/tools/labels.js +10 -0
  110. package/dist/tools/prepare/prepareChange.js +8 -3
  111. package/dist/tools/prepare/prepareCreate.js +6 -1
  112. package/dist/tools/readers/classInfo.js +10 -3
  113. package/dist/tools/readers/formInfo.js +3 -1
  114. package/dist/tools/readers/getLabelInfo.js +44 -3
  115. package/dist/tools/readers/getObjectInfo.js +2 -2
  116. package/dist/tools/readers/getWorkspaceInfo.js +46 -7
  117. package/dist/tools/readers/mapInfo.js +35 -29
  118. package/dist/tools/readers/menuInfo.d.ts +42 -0
  119. package/dist/tools/readers/menuInfo.js +270 -0
  120. package/dist/tools/readers/objectInfoRegistry.d.ts +1 -1
  121. package/dist/tools/readers/objectInfoRegistry.js +6 -2
  122. package/dist/tools/readers/objectXml.js +23 -15
  123. package/dist/tools/readers/queryInfo.js +13 -4
  124. package/dist/tools/readers/reportInfo.js +5 -4
  125. package/dist/tools/readers/viewInfo.d.ts +5 -3
  126. package/dist/tools/readers/viewInfo.js +81 -30
  127. package/dist/tools/sdlc/bpPipelineParity.d.ts +147 -0
  128. package/dist/tools/sdlc/bpPipelineParity.js +477 -0
  129. package/dist/tools/sdlc/buildProject.d.ts +13 -2
  130. package/dist/tools/sdlc/buildProject.js +557 -88
  131. package/dist/tools/sdlc/dbSync.d.ts +1 -0
  132. package/dist/tools/sdlc/dbSync.js +3 -0
  133. package/dist/tools/sdlc/formPatternGuard.d.ts +33 -0
  134. package/dist/tools/sdlc/formPatternGuard.js +73 -0
  135. package/dist/tools/sdlc/modelReindex.d.ts +34 -0
  136. package/dist/tools/sdlc/modelReindex.js +194 -0
  137. package/dist/tools/sdlc/odataActionGuard.d.ts +2 -0
  138. package/dist/tools/sdlc/odataActionGuard.js +1 -1
  139. package/dist/tools/sdlc/runBpCheck.js +23 -2
  140. package/dist/tools/sdlc/schemaChangeGuard.d.ts +26 -0
  141. package/dist/tools/sdlc/schemaChangeGuard.js +170 -0
  142. package/dist/tools/sdlc/sysTestRunner.d.ts +6 -7
  143. package/dist/tools/sdlc/sysTestRunner.js +189 -10
  144. package/dist/tools/sdlc/udeDeploy.d.ts +99 -0
  145. package/dist/tools/sdlc/udeDeploy.js +477 -0
  146. package/dist/tools/sdlc/udeDeployPowerShell.d.ts +38 -0
  147. package/dist/tools/sdlc/udeDeployPowerShell.js +238 -0
  148. package/dist/tools/sdlc/udeSysTest.d.ts +71 -0
  149. package/dist/tools/sdlc/udeSysTest.js +359 -0
  150. package/dist/tools/sdlc/undoLastModification.js +11 -5
  151. package/dist/tools/sdlc/updateSymbolIndex.d.ts +11 -0
  152. package/dist/tools/sdlc/updateSymbolIndex.js +49 -9
  153. package/dist/tools/smart/codeGen.js +66 -26
  154. package/dist/tools/smart/generateSmartReport.js +27 -0
  155. package/dist/tools/smart/generateSmartTable.js +38 -24
  156. package/dist/tools/specs/d365foFileOpSpecs.js +191 -26
  157. package/dist/tools/specs/generateObjectOpSpecs.js +9 -1
  158. package/dist/tools/specs/labelsOpSpecs.js +35 -2
  159. package/dist/tools/specs/opSpecs.js +2 -2
  160. package/dist/tools/write/createD365File.d.ts +2 -0
  161. package/dist/tools/write/createD365File.js +177 -171
  162. package/dist/tools/write/createLabel.d.ts +12 -1
  163. package/dist/tools/write/createLabel.js +206 -42
  164. package/dist/tools/write/createObjectName.d.ts +52 -0
  165. package/dist/tools/write/createObjectName.js +110 -0
  166. package/dist/tools/write/dataEntityOps.d.ts +2 -1
  167. package/dist/tools/write/dataEntityOps.js +64 -2
  168. package/dist/tools/write/deleteD365File.js +2 -1
  169. package/dist/tools/write/directXmlWriters.d.ts +177 -3
  170. package/dist/tools/write/directXmlWriters.js +667 -48
  171. package/dist/tools/write/extensionTargets.d.ts +108 -0
  172. package/dist/tools/write/extensionTargets.js +430 -0
  173. package/dist/tools/write/fieldTypeProvisioning.d.ts +78 -0
  174. package/dist/tools/write/fieldTypeProvisioning.js +304 -0
  175. package/dist/tools/write/formStructureOps.d.ts +28 -0
  176. package/dist/tools/write/formStructureOps.js +53 -0
  177. package/dist/tools/write/inlineIndexUpsert.js +4 -1
  178. package/dist/tools/write/inlineWriteVerification.d.ts +119 -2
  179. package/dist/tools/write/inlineWriteVerification.js +363 -8
  180. package/dist/tools/write/intrinsicMembers.d.ts +35 -0
  181. package/dist/tools/write/intrinsicMembers.js +162 -0
  182. package/dist/tools/write/methodXmlFallback.js +9 -1
  183. package/dist/tools/write/modelDependencyResolver.d.ts +16 -0
  184. package/dist/tools/write/modelDependencyResolver.js +34 -0
  185. package/dist/tools/write/modifyD365File.d.ts +24 -0
  186. package/dist/tools/write/modifyD365File.js +123 -39
  187. package/dist/tools/write/preserveMetadataElements.js +39 -3
  188. package/dist/tools/write/referenceGroupControl.d.ts +40 -0
  189. package/dist/tools/write/referenceGroupControl.js +163 -0
  190. package/dist/tools/write/resolveReferences.d.ts +25 -1
  191. package/dist/tools/write/resolveReferences.js +68 -20
  192. package/dist/tools/write/resolveWriteTarget.d.ts +69 -0
  193. package/dist/tools/write/resolveWriteTarget.js +192 -0
  194. package/dist/tools/write/securityReferences.d.ts +29 -0
  195. package/dist/tools/write/securityReferences.js +123 -0
  196. package/dist/tools/write/stagingTableProvisioning.d.ts +83 -0
  197. package/dist/tools/write/stagingTableProvisioning.js +312 -0
  198. package/dist/tools/write/writeAnchorGuard.d.ts +3 -0
  199. package/dist/tools/write/writeAnchorGuard.js +4 -0
  200. package/dist/tools/xml/bpAccessPropertyModify.d.ts +41 -0
  201. package/dist/tools/xml/bpAccessPropertyModify.js +136 -0
  202. package/dist/tools/xml/createTablePropertyHonesty.d.ts +4 -1
  203. package/dist/tools/xml/createTablePropertyHonesty.js +61 -13
  204. package/dist/tools/xml/dataEntityStagingTableXml.d.ts +86 -0
  205. package/dist/tools/xml/dataEntityStagingTableXml.js +191 -0
  206. package/dist/tools/xml/dataEntityXml.d.ts +4 -2
  207. package/dist/tools/xml/dataEntityXml.js +7 -4
  208. package/dist/tools/xml/edtRelationResolver.d.ts +29 -0
  209. package/dist/tools/xml/edtRelationResolver.js +73 -0
  210. package/dist/tools/xml/edtTableReferenceEdit.d.ts +59 -0
  211. package/dist/tools/xml/edtTableReferenceEdit.js +176 -0
  212. package/dist/tools/xml/entityComputedField.d.ts +54 -0
  213. package/dist/tools/xml/entityComputedField.js +153 -0
  214. package/dist/tools/xml/formDataSourceDomain.d.ts +27 -0
  215. package/dist/tools/xml/formDataSourceDomain.js +71 -0
  216. package/dist/tools/xml/formRestructure.d.ts +56 -0
  217. package/dist/tools/xml/formRestructure.js +385 -0
  218. package/dist/tools/xml/generateD365Xml.d.ts +5 -1
  219. package/dist/tools/xml/generateD365Xml.js +51 -12
  220. package/dist/tools/xml/menuExtensionXml.d.ts +146 -0
  221. package/dist/tools/xml/menuExtensionXml.js +312 -0
  222. package/dist/tools/xml/menuItemBpDefaults.d.ts +53 -0
  223. package/dist/tools/xml/menuItemBpDefaults.js +180 -0
  224. package/dist/tools/xml/menuPropertyUpsert.d.ts +52 -0
  225. package/dist/tools/xml/menuPropertyUpsert.js +205 -0
  226. package/dist/tools/xml/menuXml.d.ts +27 -0
  227. package/dist/tools/xml/menuXml.js +84 -0
  228. package/dist/tools/xml/securityDutyRoleXml.d.ts +91 -0
  229. package/dist/tools/xml/securityDutyRoleXml.js +168 -3
  230. package/dist/tools/xml/surrogateForeignKey.d.ts +35 -0
  231. package/dist/tools/xml/surrogateForeignKey.js +88 -0
  232. package/dist/tools/xml/tableBpDefaults.d.ts +109 -0
  233. package/dist/tools/xml/tableBpDefaults.js +470 -0
  234. package/dist/tools/xml/tableFieldPropertyEdit.js +3 -1
  235. package/dist/tools/xml/tableFieldRemoval.d.ts +41 -0
  236. package/dist/tools/xml/tableFieldRemoval.js +203 -0
  237. package/dist/tools/xml/tableXml.js +12 -4
  238. package/dist/tools/xml/xmlTemplateGenerator.js +11 -1
  239. package/dist/types/context.d.ts +7 -0
  240. package/dist/utils/axFormDesignProperties.d.ts +8 -4
  241. package/dist/utils/axFormDesignProperties.js +17 -5
  242. package/dist/utils/axTablePropertyOrder.js +4 -0
  243. package/dist/utils/baseObjectXml.js +35 -3
  244. package/dist/utils/bpCreateDefaults.d.ts +79 -0
  245. package/dist/utils/bpCreateDefaults.js +140 -0
  246. package/dist/utils/configManager.d.ts +2 -1
  247. package/dist/utils/configManager.js +25 -17
  248. package/dist/utils/crossModelWriteGuard.d.ts +9 -0
  249. package/dist/utils/crossModelWriteGuard.js +39 -8
  250. package/dist/utils/dataverseAuth.d.ts +34 -0
  251. package/dist/utils/dataverseAuth.js +172 -0
  252. package/dist/utils/extensionNameFormat.d.ts +108 -0
  253. package/dist/utils/extensionNameFormat.js +243 -0
  254. package/dist/utils/formControlExpander.d.ts +29 -26
  255. package/dist/utils/formControlExpander.js +359 -83
  256. package/dist/utils/formControlMethodXml.d.ts +73 -0
  257. package/dist/utils/formControlMethodXml.js +190 -0
  258. package/dist/utils/formDataSourcePropertyXml.d.ts +71 -0
  259. package/dist/utils/formDataSourcePropertyXml.js +218 -0
  260. package/dist/utils/formExtensionControlXml.js +12 -1
  261. package/dist/utils/formPatternTemplates.d.ts +2 -0
  262. package/dist/utils/formPatternTemplates.js +55 -14
  263. package/dist/utils/indexStaleness.js +5 -2
  264. package/dist/utils/indexedXmlLookup.d.ts +36 -12
  265. package/dist/utils/indexedXmlLookup.js +43 -15
  266. package/dist/utils/labelText.d.ts +18 -0
  267. package/dist/utils/labelText.js +20 -0
  268. package/dist/utils/loadEnv.d.ts +15 -0
  269. package/dist/utils/loadEnv.js +71 -0
  270. package/dist/utils/menuFiles.d.ts +20 -0
  271. package/dist/utils/menuFiles.js +65 -0
  272. package/dist/utils/modelClassifier.d.ts +8 -2
  273. package/dist/utils/modelClassifier.js +27 -2
  274. package/dist/utils/modelPrefixInference.js +5 -1
  275. package/dist/utils/objectFileLookup.d.ts +18 -0
  276. package/dist/utils/objectFileLookup.js +80 -0
  277. package/dist/utils/objectNaming.d.ts +54 -0
  278. package/dist/utils/objectNaming.js +103 -0
  279. package/dist/utils/objectNamingRules.d.ts +7 -0
  280. package/dist/utils/objectNamingRules.js +120 -2
  281. package/dist/utils/operationLocks.d.ts +11 -0
  282. package/dist/utils/operationLocks.js +93 -2
  283. package/dist/utils/packageResolver.d.ts +42 -8
  284. package/dist/utils/packageResolver.js +136 -26
  285. package/dist/utils/pathContainment.d.ts +23 -0
  286. package/dist/utils/pathContainment.js +24 -0
  287. package/dist/utils/progressReporter.d.ts +10 -0
  288. package/dist/utils/progressReporter.js +16 -0
  289. package/dist/utils/smartXmlBuilder.js +24 -21
  290. package/dist/utils/subscriberAccessLevel.d.ts +4 -3
  291. package/dist/utils/subscriberAccessLevel.js +19 -5
  292. package/dist/utils/symbolLookup.d.ts +26 -0
  293. package/dist/utils/symbolLookup.js +31 -0
  294. package/dist/utils/toolProgressMessage.js +3 -2
  295. package/dist/utils/xmlEscape.d.ts +20 -6
  296. package/dist/utils/xmlEscape.js +42 -7
  297. package/dist/utils/xppConfigProvider.d.ts +2 -0
  298. package/dist/utils/xppConfigProvider.js +1 -0
  299. package/dist/validation/formPatternValidator.d.ts +25 -13
  300. package/dist/validation/formPatternValidator.js +119 -298
  301. package/dist/validation/platformPatternMatcher.d.ts +49 -0
  302. package/dist/validation/platformPatternMatcher.js +375 -0
  303. package/dist/workspace/createdArtifactLedger.d.ts +11 -2
  304. package/dist/workspace/createdArtifactLedger.js +4 -2
  305. package/dist/workspace/projectFile.d.ts +8 -3
  306. package/dist/workspace/projectFile.js +70 -3
  307. package/dist/workspace/workspaceScanner.js +55 -13
  308. package/dist/xref/sqliteXrefProvider.d.ts +188 -0
  309. package/dist/xref/sqliteXrefProvider.js +737 -0
  310. package/dist/xref/xrefPaths.d.ts +99 -0
  311. package/dist/xref/xrefPaths.js +392 -0
  312. package/dist/xref/xrefSource.d.ts +66 -0
  313. package/dist/xref/xrefSource.js +98 -0
  314. package/package.json +9 -1
  315. package/dist/knowledge/formPatterns/catalog/subPatterns/panels.d.ts +0 -9
  316. package/dist/knowledge/formPatterns/catalog/subPatterns/panels.js +0 -47
@@ -42,6 +42,7 @@ PowerShell / any terminal command **WILL HANG** in VS 2022 / VS 2026 MCP integra
42
42
  | Validate form XML against its pattern | `object_patterns(domain="form", action="validate", xml \| formName \| filePath)` — structural errors block form writes (FORM_PATTERN_ENFORCE) |
43
43
  | Resolve label / EDT / class refs | `validate_code(mode="references", code)` |
44
44
  | Build / BP / Sync | `build_d365fo_project(bpCheck: true, dbSync: true)` — ONE call compiles, runs the best-practice check and syncs AxDB |
45
+ | Deploy to a UDE environment (before running changed tests there) | `build_d365fo_project(deploy: true)` — compiles and deploys the model's package to the cloud runtime `run_systest_class` uses; add `dbSync: true` only after a table/view/data-entity/enum/EDT change (~20 min instead of ~3) |
45
46
  | Error diagnosis | `get_knowledge(kind="error", errorText)` |
46
47
  | Parameters for a `d365fo_file` operation / `generate_object` mode | `get_knowledge(kind="op-spec", topic="add-index" \| "table" \| "scaffold:form")` — those two tools keep their parameters OUT of the tool schema; look the contract up once for the operation you picked, then nest the values in `params` (`properties` for `action="create"`) |
47
48
 
@@ -58,7 +59,7 @@ PowerShell / any terminal command **WILL HANG** in VS 2022 / VS 2026 MCP integra
58
59
 
59
60
  ### Build automation
60
61
 
61
- 4. Never run `build_d365fo_project()` automatically — only on explicit user request ("build", "compile", "check errors").
62
+ 4. Never run `build_d365fo_project()` automatically — only on explicit user request ("build", "compile", "check errors"). On UDE, a request to run a test whose code changed since the last deployment counts: tests run against deployed code, so build with `deploy: true` first. Say so before a full sync (`dbSync: true`).
62
63
 
63
64
  ### X++ correctness (BP-clean code)
64
65
 
package/README.md CHANGED
@@ -65,7 +65,7 @@ Forms are the hardest artifact to generate correctly — each pattern dictates r
65
65
  flowchart LR
66
66
  A["object_patterns<br/>(domain=form, action=analyze)"] --> B["object_patterns<br/>(domain=form, action=spec)"]
67
67
  B --> C["generate_object<br/>objectType=form, cloneFrom"]
68
- C --> D["object_patterns<br/>(domain=form, action=validate) FP001–FP010"]
68
+ C --> D["object_patterns<br/>(domain=form, action=validate) FP001–FP011"]
69
69
  D -->|clean| E["d365fo_file<br/>(action=create) write + project"]
70
70
  D -->|errors| C
71
71
  ```
@@ -23,6 +23,7 @@
23
23
  import type { BridgeClient } from './bridgeClient.js';
24
24
  import type { BridgeAttempt } from './bridgeFailure.js';
25
25
  import type { BridgeCompletionResult, BridgeSmartTableResult } from './bridgeTypes.js';
26
+ import { type XrefSource } from '../xref/xrefSource.js';
26
27
  /** Standard MCP tool response shape */
27
28
  export interface ToolResult {
28
29
  content: Array<{
@@ -139,7 +140,7 @@ export type BridgeReferencesOutcome = {
139
140
  } | {
140
141
  status: 'unavailable';
141
142
  };
142
- export declare function tryBridgeReferences(bridge: BridgeClient | undefined, target: string | string[], limit?: number, displayName?: string, formatAs?: 'default' | 'label'): Promise<BridgeReferencesOutcome>;
143
+ export declare function tryBridgeReferences(bridge: XrefSource | undefined, target: string | string[], limit?: number, displayName?: string, formatAs?: 'default' | 'label'): Promise<BridgeReferencesOutcome>;
143
144
  export interface BridgeSearchOptions {
144
145
  /**
145
146
  * Exact-name hits the caller already resolved from the SQLite index with an
@@ -588,9 +589,9 @@ declare function memberLine(m: {
588
589
  signature?: string;
589
590
  }): string;
590
591
  declare function formatCompletion(r: BridgeCompletionResult, prefix?: string): string;
591
- export declare function tryBridgeCocExtensions(bridge: BridgeClient | undefined, baseClassName: string, methodName?: string): Promise<ToolResult | null>;
592
- export declare function tryBridgeEventHandlers(bridge: BridgeClient | undefined, targetName: string, eventName?: string, handlerType?: string): Promise<ToolResult | null>;
593
- export declare function tryBridgeApiUsageCallers(bridge: BridgeClient | undefined, apiName: string, limit?: number): Promise<ToolResult | null>;
592
+ export declare function tryBridgeCocExtensions(bridge: XrefSource | undefined, baseClassName: string, methodName?: string): Promise<ToolResult | null>;
593
+ export declare function tryBridgeEventHandlers(bridge: XrefSource | undefined, targetName: string, eventName?: string, handlerType?: string): Promise<ToolResult | null>;
594
+ export declare function tryBridgeApiUsageCallers(bridge: XrefSource | undefined, apiName: string, limit?: number): Promise<ToolResult | null>;
594
595
  /**
595
596
  * Internals exposed for tests only. `formatCompletion` renders a member list,
596
597
  * and a member list that cannot be trusted to name its members is worse than no
@@ -31,6 +31,8 @@ import { rankCustomFirst, isExactNameMatch } from '../utils/exactMatchRanking.js
31
31
  import { COMPACT_METHODS_HINT, fullBodyHint } from '../utils/methodBodyHint.js';
32
32
  import { subscriberAccessLevelValue } from '../utils/subscriberAccessLevel.js';
33
33
  import { pageFields, fieldsHeading, fieldsFooter, createControlBudget, chargeControl, chargeSkippedSubtree, controlsFooter, } from '../utils/payloadBudget.js';
34
+ import { xrefSourceLabel, isSqliteXref } from '../xref/xrefSource.js';
35
+ import { XREF_SQLITE_COUNT_CAP } from '../xref/sqliteXrefProvider.js';
34
36
  // TABLE
35
37
  const TABLE_METHOD_PAGE_SIZE = 25;
36
38
  /**
@@ -547,6 +549,8 @@ export async function tryBridgeReferences(bridge, target, limit = 50, displayNam
547
549
  let exact = true;
548
550
  let exactTotal = 0;
549
551
  let exactMetadata = 0;
552
+ // The SQLite provider counts up to a cap: its totals are then lower bounds.
553
+ let totalCapped = false;
550
554
  for (const t of targets) {
551
555
  try {
552
556
  const r = await bridge.findReferences(t);
@@ -554,6 +558,8 @@ export async function tryBridgeReferences(bridge, target, limit = 50, displayNam
554
558
  errored = true;
555
559
  if (r?.references?.length)
556
560
  merged.push(...r.references);
561
+ if (r?.totalCapped)
562
+ totalCapped = true;
557
563
  if (typeof r?.total === 'number') {
558
564
  exactTotal += r.total;
559
565
  exactMetadata += r.metadataTotal ?? 0;
@@ -578,7 +584,7 @@ export async function tryBridgeReferences(bridge, target, limit = 50, displayNam
578
584
  // properties rather than X++ code — so they get a dedicated formatter that
579
585
  // groups by source object type and surfaces the referencing property.
580
586
  if (formatAs === 'label') {
581
- return { status: 'ok', result: formatLabelReferences(merged, label, limit) };
587
+ return { status: 'ok', result: formatLabelReferences(merged, label, limit, xrefSourceLabel(bridge)) };
582
588
  }
583
589
  {
584
590
  const refs = { count: merged.length, references: merged };
@@ -586,11 +592,20 @@ export async function tryBridgeReferences(bridge, target, limit = 50, displayNam
586
592
  const total = exact ? exactTotal : refs.count;
587
593
  const metadataTotal = exact ? exactMetadata : returnedMetadata;
588
594
  const sampled = exact && refs.count < exactTotal;
595
+ // Lower-bound marks for the SQLite cap only; a bridge's output stays as it was.
596
+ const plus = totalCapped ? '+' : '';
597
+ const who = isSqliteXref(bridge) ? 'The xref SQLite file' : 'The bridge';
589
598
  let out = `# References to \`${label}\`\n\n`;
590
- out += `**Total:** ${total}${capped ? '+' : ''} reference(s) found${sampled ? ` (showing ${refs.count})` : ''}\n`;
591
- out += `_Source: C# bridge (DYNAMICSXREFDB) — X++ code and declarative metadata references_\n\n`;
592
- if (sampled) {
593
- out += `> ℹ️ The bridge returns up to ${XREF_ROW_CAP} rows per lookup for code and for metadata: the totals are exact, ` +
599
+ out += `**Total:** ${total}${capped || totalCapped ? '+' : ''} reference(s) found${sampled ? ` (showing ${refs.count})` : ''}\n`;
600
+ out += `_Source: ${xrefSourceLabel(bridge)} — X++ code and declarative metadata references_\n\n`;
601
+ if (sampled && totalCapped) {
602
+ out += `> ℹ️ ${who} returns up to ${XREF_ROW_CAP} rows per lookup for code and for metadata and counts up to ` +
603
+ `${isSqliteXref(bridge) ? bridge.countCap : XREF_SQLITE_COUNT_CAP} references each: more exist than counted, ` +
604
+ `and the rows below are a sample. ` +
605
+ `Narrow the target (e.g. \`Owner.member\`) for a complete list.\n\n`;
606
+ }
607
+ else if (sampled) {
608
+ out += `> ℹ️ ${who} returns up to ${XREF_ROW_CAP} rows per lookup for code and for metadata: the totals are exact, ` +
594
609
  `the rows below are a sample. Narrow the target (e.g. \`Owner.member\`) for a complete list.\n\n`;
595
610
  }
596
611
  else if (capped) {
@@ -611,7 +626,7 @@ export async function tryBridgeReferences(bridge, target, limit = 50, displayNam
611
626
  for (const [type, count] of byType) {
612
627
  out += `- **${type}**: ${count} reference(s)\n`;
613
628
  }
614
- out += `- From X++ code: ${total - metadataTotal} · from declarative metadata: ${metadataTotal}\n`;
629
+ out += `- From X++ code: ${total - metadataTotal}${plus} · from declarative metadata: ${metadataTotal}${plus}\n`;
615
630
  out += `\n`;
616
631
  // Top callers
617
632
  const sortedCallers = [...topCallers.entries()].sort((a, b) => b[1] - a[1]).slice(0, 10);
@@ -645,7 +660,7 @@ export async function tryBridgeReferences(bridge, target, limit = 50, displayNam
645
660
  for (const [heading, rows, share, groupTotal] of groups) {
646
661
  if (rows.length === 0)
647
662
  continue;
648
- out += `### ${heading} (${share < groupTotal ? `${share} of ${groupTotal}` : share})\n\n`;
663
+ out += `### ${heading} (${share < groupTotal ? `${share} of ${groupTotal}${plus}` : share})\n\n`;
649
664
  for (const r of rows.slice(0, share))
650
665
  out += renderRow(r);
651
666
  out += `\n`;
@@ -763,7 +778,7 @@ function parseLabelSource(sourcePath) {
763
778
  * explicit — a label is typically referenced far more from metadata (form
764
779
  * captions, field/EDT labels, menu-item captions, …) than from X++ code.
765
780
  */
766
- function formatLabelReferences(references, label, limit) {
781
+ function formatLabelReferences(references, label, limit, source) {
767
782
  const parsed = references.map(r => ({
768
783
  ...parseLabelSource(r.sourcePath),
769
784
  module: r.sourceModule,
@@ -771,7 +786,7 @@ function formatLabelReferences(references, label, limit) {
771
786
  }));
772
787
  let out = `# References to label \`${label}\`\n\n`;
773
788
  out += `**Total:** ${references.length} reference(s) found\n`;
774
- out += `_Source: C# bridge (DYNAMICSXREFDB) — includes both X++ code and declarative metadata references_\n\n`;
789
+ out += `_Source: ${source} — includes both X++ code and declarative metadata references_\n\n`;
775
790
  // Summary: count by source object type (most-referenced first). This counts
776
791
  // ALL references, whereas the detail section below is capped at `limit` — so
777
792
  // each truncated group carries a "showing X of Y" marker to keep the two
@@ -1316,6 +1331,8 @@ const BRIDGE_MODIFY_OPS = new Set([
1316
1331
  // schema. Both this set AND XML_ONLY_MODIFY_PAIRS have to name it; either alone
1317
1332
  // still returns false. (eval case L2-object-delete-and-entry-point-cleanup)
1318
1333
  'remove-control', 'add-entry-point', 'remove-entry-point',
1334
+ // The duty and privilege lists of a role or duty: XML-only for the same reason.
1335
+ 'add-duty', 'remove-duty', 'add-privilege', 'remove-privilege',
1319
1336
  // AxIgnoreDiagnosticList is not an AOT object at all — MetadataWriteService has
1320
1337
  // no concept of it — so this is XML-only for the same structural reason as the
1321
1338
  // two above.
@@ -1325,6 +1342,12 @@ const BRIDGE_MODIFY_OPS = new Set([
1325
1342
  'add-module-reference', 'remove-module-reference',
1326
1343
  'add-display-method', 'add-table-method',
1327
1344
  'add-field-modification', 'add-menu-item-to-menu',
1345
+ // No C# op adds a submenu: served by a direct-XML writer on a menu (already in
1346
+ // BRIDGE_MODIFY_TYPES) and, through XML_ONLY_MODIFY_PAIRS, on a menu extension.
1347
+ 'add-submenu',
1348
+ // No C# op changes a control's parent: an AxForm's control tree is restructured by a
1349
+ // direct-XML writer (formRestructure.ts; form is already in BRIDGE_MODIFY_TYPES).
1350
+ 'move-control', 'wrap-controls',
1328
1351
  // No C# op exists for query ranges on entities — served entirely by a
1329
1352
  // direct-XML writer (data-entity is already in BRIDGE_MODIFY_TYPES).
1330
1353
  'add-query-range', 'remove-query-range',
@@ -1363,6 +1386,10 @@ const BRIDGE_MODIFY_TYPES = new Set([
1363
1386
  const XML_ONLY_MODIFY_PAIRS = {
1364
1387
  'add-entry-point': new Set(['security-privilege']),
1365
1388
  'remove-entry-point': new Set(['security-privilege']),
1389
+ 'add-duty': new Set(['security-role', 'security-role-extension']),
1390
+ 'remove-duty': new Set(['security-role', 'security-role-extension']),
1391
+ 'add-privilege': new Set(['security-role', 'security-role-extension', 'security-duty', 'security-duty-extension']),
1392
+ 'remove-privilege': new Set(['security-role', 'security-role-extension', 'security-duty', 'security-duty-extension']),
1366
1393
  'remove-diagnostic-suppression': new Set(['ignore-diagnostic-list']),
1367
1394
  'add-diagnostic-suppression': new Set(['ignore-diagnostic-list']),
1368
1395
  'add-module-reference': new Set(['model-descriptor']),
@@ -1373,6 +1400,12 @@ const XML_ONLY_MODIFY_PAIRS = {
1373
1400
  // this pair the caller would get "the bridge could not resolve the object" instead
1374
1401
  // of the operation actually running.
1375
1402
  'report-design': new Set(['report']),
1403
+ // The C# AddMenuItemToMenu reads an AxMenu and cannot resolve "BaseMenu.Suffix",
1404
+ // and `menu-extension` cannot join BRIDGE_MODIFY_TYPES without claiming every other
1405
+ // op on it too. Without this pair the extension the cross-model guard sends an
1406
+ // agent to create could not be filled at all.
1407
+ 'add-menu-item-to-menu': new Set(['menu-extension']),
1408
+ 'add-submenu': new Set(['menu-extension']),
1376
1409
  };
1377
1410
  /**
1378
1411
  * Names the properties the bridge could not write, for appending to a success message.
@@ -2671,38 +2704,68 @@ export async function tryBridgeCocExtensions(bridge, baseClassName, methodName)
2671
2704
  const result = await bridge.findExtensionClasses(baseClassName);
2672
2705
  if (!result)
2673
2706
  return null;
2674
- return { content: [{ type: 'text', text: formatCocExtensions(result, methodName) }] };
2707
+ return { content: [{ type: 'text', text: formatCocExtensions(result, methodName, xrefSourceLabel(bridge)) }] };
2675
2708
  }
2676
2709
  catch (e) {
2677
2710
  recordBridgeFailure(`findExtensionClasses(${baseClassName})`, e);
2678
2711
  return null;
2679
2712
  }
2680
2713
  }
2681
- function formatCocExtensions(r, methodNameFilter) {
2714
+ function formatCocExtensions(r, methodNameFilter, source) {
2682
2715
  let out = `CoC Extensions of: ${r.baseClassName}\n`;
2683
- out += `_Source: C# bridge (DYNAMICSXREFDB)_\n\n`;
2716
+ out += `_Source: ${source}_\n\n`;
2684
2717
  if (r.count === 0) {
2685
2718
  out += `No class extensions found via cross-reference database.\n`;
2686
2719
  return out;
2687
2720
  }
2688
- // Apply method filter if specified
2689
- let filtered = r.extensions;
2690
- if (methodNameFilter) {
2691
- filtered = r.extensions.filter(ext => ext.wrappedMethods?.some(m => m.toLowerCase() === methodNameFilter.toLowerCase())
2692
- || !ext.wrappedMethods || ext.wrappedMethods.length === 0);
2693
- }
2694
2721
  // Dedupe by class name ONCE, before anything is counted. A class carries a single
2695
2722
  // [ExtensionOf] and the bridge keys its results by class name, so a duplicate cannot
2696
2723
  // reach here today — but the count and the list it introduces have to agree whatever
2697
2724
  // arrives, and skipping an entry inside the render loop after the heading above it had
2698
2725
  // already counted that entry is exactly how the two come apart.
2699
2726
  const byClassName = new Map();
2700
- for (const ext of filtered) {
2727
+ for (const ext of r.extensions) {
2701
2728
  if (!byClassName.has(ext.className))
2702
2729
  byClassName.set(ext.className, ext);
2703
2730
  }
2704
2731
  const unique = [...byClassName.values()];
2705
- out += `Found ${unique.length} extension class(es)${methodNameFilter ? ` wrapping "${methodNameFilter}"` : ''}:\n\n`;
2732
+ if (!methodNameFilter) {
2733
+ out += `Found ${unique.length} extension class(es):\n\n`;
2734
+ return out + formatCocGroups(unique);
2735
+ }
2736
+ // With a method filter, "Found N … wrapping m" counts only the classes whose wrap list names
2737
+ // m. It used to count every class with an EMPTY list as well — a leftover from when the list
2738
+ // held every base method the class called — so "Found 12 extension class(es) wrapping
2739
+ // validateWrite" listed ten classes that wrap something else. The bridge sends a list for
2740
+ // every class (WrappedMethods = new List<string>()), so empty means "wraps nothing". Those
2741
+ // classes are still worth seeing, under their own heading and count; a class with no list at
2742
+ // all (an older bridge, another source) is unknown, and is never counted as a wrapper either.
2743
+ const wanted = methodNameFilter.toLowerCase();
2744
+ const wrappers = [];
2745
+ const others = [];
2746
+ const unknown = [];
2747
+ for (const ext of unique) {
2748
+ if (!ext.wrappedMethods)
2749
+ unknown.push(ext);
2750
+ else if (ext.wrappedMethods.some(m => m.toLowerCase() === wanted))
2751
+ wrappers.push(ext);
2752
+ else
2753
+ others.push(ext);
2754
+ }
2755
+ out += `Found ${wrappers.length} extension class(es) wrapping "${methodNameFilter}":\n\n`;
2756
+ out += formatCocGroups(wrappers);
2757
+ if (others.length > 0) {
2758
+ out += `Other extension classes of ${r.baseClassName} (no wrap of "${methodNameFilter}" recorded): ${others.length}\n\n`;
2759
+ out += formatCocGroups(others);
2760
+ }
2761
+ if (unknown.length > 0) {
2762
+ out += `Extension classes of ${r.baseClassName}, wraps unknown (the source sent no wrap list): ${unknown.length}\n\n`;
2763
+ out += formatCocGroups(unknown);
2764
+ }
2765
+ return out;
2766
+ }
2767
+ function formatCocGroups(extensions) {
2768
+ let out = '';
2706
2769
  // Grouped by the element each class actually extends, never pooled into one list. A name can
2707
2770
  // denote several objects at once — "SalesTable" is a table (14 extensions) AND a form (17),
2708
2771
  // and the form's data sources, controls and data fields are each extended separately again
@@ -2710,7 +2773,7 @@ function formatCocExtensions(r, methodNameFilter) {
2710
2773
  // to write a table CoC that 34 form extensions were its concern, and hid which of the form's
2711
2774
  // NINE data sources with an `active` method was already wrapped.
2712
2775
  const groups = new Map();
2713
- for (const ext of unique) {
2776
+ for (const ext of extensions) {
2714
2777
  const key = ext.extendedElement ?? '';
2715
2778
  const bucket = groups.get(key) ?? [];
2716
2779
  bucket.push(ext);
@@ -2775,19 +2838,22 @@ export async function tryBridgeEventHandlers(bridge, targetName, eventName, hand
2775
2838
  const result = await bridge.findEventSubscribers(targetName, eventName, handlerType);
2776
2839
  if (!result)
2777
2840
  return null;
2778
- return { content: [{ type: 'text', text: formatEventHandlers(result) }] };
2841
+ return { content: [{ type: 'text', text: formatEventHandlers(result, xrefSourceLabel(bridge)) }] };
2779
2842
  }
2780
2843
  catch (e) {
2781
2844
  recordBridgeFailure(`findEventSubscribers(${targetName})`, e);
2782
2845
  return null;
2783
2846
  }
2784
2847
  }
2785
- function formatEventHandlers(r) {
2848
+ function formatEventHandlers(r, source) {
2786
2849
  let out = `Event Handlers for: ${r.targetName}\n`;
2787
- out += `_Source: C# bridge (DYNAMICSXREFDB)_\n\n`;
2850
+ out += `_Source: ${source}_\n\n`;
2851
+ const scanNote = r.scanCapped
2852
+ ? `> ⚠️ Only the first ${r.scanned ?? '?'} references to ${r.targetName} were examined: more handlers may exist.\n`
2853
+ : '';
2788
2854
  if (r.count === 0) {
2789
2855
  out += `No event handlers found via cross-reference database.\n`;
2790
- return out;
2856
+ return out + scanNote;
2791
2857
  }
2792
2858
  out += `Found ${r.count} handler(s):\n\n`;
2793
2859
  // Group by handler type
@@ -2812,7 +2878,7 @@ function formatEventHandlers(r) {
2812
2878
  }
2813
2879
  out += `\n`;
2814
2880
  }
2815
- return out;
2881
+ return out + scanNote;
2816
2882
  }
2817
2883
  // API USAGE CALLERS via XREF (P5)
2818
2884
  export async function tryBridgeApiUsageCallers(bridge, apiName, limit = 200) {
@@ -2822,17 +2888,18 @@ export async function tryBridgeApiUsageCallers(bridge, apiName, limit = 200) {
2822
2888
  const result = await bridge.findApiUsageCallers(apiName, limit);
2823
2889
  if (!result || result.totalCallers === 0)
2824
2890
  return null;
2825
- return { content: [{ type: 'text', text: formatApiUsageCallers(result) }] };
2891
+ return { content: [{ type: 'text', text: formatApiUsageCallers(result, xrefSourceLabel(bridge)) }] };
2826
2892
  }
2827
2893
  catch (e) {
2828
2894
  recordBridgeFailure(`findApiUsageCallers(${apiName})`, e);
2829
2895
  return null;
2830
2896
  }
2831
2897
  }
2832
- function formatApiUsageCallers(r) {
2898
+ function formatApiUsageCallers(r, source) {
2833
2899
  let out = `# API Usage: ${r.apiName}\n\n`;
2834
- out += `**Total references:** ${r.totalCallers} from ${r.uniqueClasses} unique class(es)\n`;
2835
- out += `_Source: C# bridge (DYNAMICSXREFDB)_\n\n`;
2900
+ out += `**Total references:** ${r.totalCallers}${r.more ? '+' : ''} from ${r.uniqueClasses} unique class(es)` +
2901
+ `${r.more ? ` (more available: the first ${r.totalCallers} found are shown)` : ''}\n`;
2902
+ out += `_Source: ${source}_\n\n`;
2836
2903
  out += `## Top Callers by Class\n\n`;
2837
2904
  for (const cls of r.callersByClass.slice(0, 30)) {
2838
2905
  out += `- **${cls.callerClass}** (${cls.callCount} call(s))`;
@@ -80,7 +80,7 @@ export interface BridgeClientOptions {
80
80
  }
81
81
  export declare class BridgeClient extends EventEmitter {
82
82
  private process;
83
- private buffer;
83
+ private lineReader;
84
84
  private requestId;
85
85
  private pending;
86
86
  private readyPayload;
@@ -18,6 +18,7 @@ import * as path from 'path';
18
18
  import * as fs from 'fs';
19
19
  import { fileURLToPath } from 'url';
20
20
  import { packagesRoots } from '../utils/packagesRoot.js';
21
+ import { BridgeLineReader } from './lineReader.js';
21
22
  export * from './bridgeTypes.js';
22
23
  const BRIDGE_EXE_NAME = 'D365MetadataBridge.exe';
23
24
  /** Where a built bridge is looked for inside this installation, in order. */
@@ -129,7 +130,7 @@ async function settledWithin(promise, ms) {
129
130
  }
130
131
  export class BridgeClient extends EventEmitter {
131
132
  process = null;
132
- buffer = '';
133
+ lineReader = new BridgeLineReader();
133
134
  requestId = 0;
134
135
  pending = new Map();
135
136
  readyPayload = null;
@@ -234,11 +235,14 @@ export class BridgeClient extends EventEmitter {
234
235
  child.stdout.on('data', (chunk) => {
235
236
  if (this.process !== child)
236
237
  return;
237
- this.buffer += chunk.toString('utf8');
238
- let newlineIdx;
239
- while ((newlineIdx = this.buffer.indexOf('\n')) !== -1) {
240
- const line = this.buffer.substring(0, newlineIdx).trim();
241
- this.buffer = this.buffer.substring(newlineIdx + 1);
238
+ // The reader searches only the new chunk for the newline and decodes
239
+ // across chunk boundaries (see lineReader.ts). Lines it has not handed
240
+ // out yet stay in it, as they stayed in the old string buffer, so the
241
+ // early return on "ready" below still leaves the rest for the next chunk.
242
+ this.lineReader.push(chunk);
243
+ let rawLine;
244
+ while ((rawLine = this.lineReader.next()) !== undefined) {
245
+ const line = rawLine.trim();
242
246
  if (!line)
243
247
  continue;
244
248
  try {
@@ -452,7 +456,7 @@ export class BridgeClient extends EventEmitter {
452
456
  await this.killChild();
453
457
  this._isReady = false;
454
458
  this.readyPayload = null;
455
- this.buffer = '';
459
+ this.lineReader.reset();
456
460
  await this.spawnAndWaitReady();
457
461
  console.error('[BridgeClient] Bridge child restarted successfully');
458
462
  })();
@@ -283,6 +283,11 @@ export interface BridgeReferenceResult {
283
283
  /** Every matching reference, and how many of them are declarative metadata. Absent from older bridges. */
284
284
  total?: number;
285
285
  metadataTotal?: number;
286
+ /**
287
+ * Set by the xref SQLite provider when a count stopped at its cap: total and
288
+ * metadataTotal are then lower bounds. The bridge counts without a cap.
289
+ */
290
+ totalCapped?: boolean;
286
291
  references: BridgeReferenceInfo[];
287
292
  /** Set by the C# bridge when the xref query failed in-band (e.g. SQL error) — count is 0 but this is NOT an authoritative "no references". */
288
293
  error?: string;
@@ -602,6 +607,12 @@ export interface BridgeEventSubscriberResult {
602
607
  count: number;
603
608
  handlers: BridgeEventSubscriberEntry[];
604
609
  _source: string;
610
+ /**
611
+ * Set by the xref SQLite provider when it examined only the first `scanned`
612
+ * references to the target (its scan cap): more handlers may exist.
613
+ */
614
+ scanCapped?: boolean;
615
+ scanned?: number;
605
616
  }
606
617
  export interface BridgeApiUsageCallerEntry {
607
618
  callerClass: string;
@@ -623,5 +634,7 @@ export interface BridgeApiUsageCallersResult {
623
634
  callersByClass: BridgeApiUsageCallersByClass[];
624
635
  callers: BridgeApiUsageCallerEntry[];
625
636
  _source: string;
637
+ /** Set by the xref SQLite provider when more callers exist than were returned. */
638
+ more?: boolean;
626
639
  }
627
640
  //# sourceMappingURL=bridgeTypes.d.ts.map
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Splits the bridge child's stdout into lines.
3
+ *
4
+ * The protocol is newline-delimited JSON, and one reply can be many megabytes on
5
+ * a single line that arrives in thousands of chunks. Two things follow from that:
6
+ *
7
+ * - Only the newly arrived text is searched for the newline, and the parts of
8
+ * an unfinished line are kept in an array and joined once when the line
9
+ * completes. Appending every chunk to one string and searching it from the
10
+ * start is quadratic in the size of the line (measured: 2.7 s for a 20 MB
11
+ * reply against about 120 ms this way).
12
+ * - Bytes are decoded with a StringDecoder, which holds back the first bytes
13
+ * of a multi-byte character until the rest arrives. Decoding each chunk on
14
+ * its own turns a character that straddles two chunks into U+FFFD.
15
+ *
16
+ * Lines are returned as they were sent, without the terminating "\n" and with
17
+ * nothing trimmed (a "\r" before the newline stays). An empty line is returned
18
+ * as "". Text after the last newline stays pending until its newline arrives.
19
+ */
20
+ export declare class BridgeLineReader {
21
+ private decoder;
22
+ /** Text of the line still being received, in arrival order. Never holds a newline. */
23
+ private parts;
24
+ /** Complete lines not yet handed out by next(). */
25
+ private lines;
26
+ private head;
27
+ /** Add a chunk of stdout. Complete lines become available through next(). */
28
+ push(chunk: Buffer): void;
29
+ /** The next complete line, or undefined when none is waiting. */
30
+ next(): string | undefined;
31
+ /** Forget everything received so far, including a half-received character. */
32
+ reset(): void;
33
+ /** How many parts the unfinished line is held in (one per chunk that added to it). */
34
+ get pendingParts(): number;
35
+ }
36
+ //# sourceMappingURL=lineReader.d.ts.map
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Splits the bridge child's stdout into lines.
3
+ *
4
+ * The protocol is newline-delimited JSON, and one reply can be many megabytes on
5
+ * a single line that arrives in thousands of chunks. Two things follow from that:
6
+ *
7
+ * - Only the newly arrived text is searched for the newline, and the parts of
8
+ * an unfinished line are kept in an array and joined once when the line
9
+ * completes. Appending every chunk to one string and searching it from the
10
+ * start is quadratic in the size of the line (measured: 2.7 s for a 20 MB
11
+ * reply against about 120 ms this way).
12
+ * - Bytes are decoded with a StringDecoder, which holds back the first bytes
13
+ * of a multi-byte character until the rest arrives. Decoding each chunk on
14
+ * its own turns a character that straddles two chunks into U+FFFD.
15
+ *
16
+ * Lines are returned as they were sent, without the terminating "\n" and with
17
+ * nothing trimmed (a "\r" before the newline stays). An empty line is returned
18
+ * as "". Text after the last newline stays pending until its newline arrives.
19
+ */
20
+ import { StringDecoder } from 'node:string_decoder';
21
+ export class BridgeLineReader {
22
+ decoder = new StringDecoder('utf8');
23
+ /** Text of the line still being received, in arrival order. Never holds a newline. */
24
+ parts = [];
25
+ /** Complete lines not yet handed out by next(). */
26
+ lines = [];
27
+ head = 0;
28
+ /** Add a chunk of stdout. Complete lines become available through next(). */
29
+ push(chunk) {
30
+ const text = this.decoder.write(chunk);
31
+ if (!text)
32
+ return;
33
+ let start = 0;
34
+ let newlineIdx;
35
+ while ((newlineIdx = text.indexOf('\n', start)) !== -1) {
36
+ const segment = text.substring(start, newlineIdx);
37
+ if (this.parts.length > 0) {
38
+ this.parts.push(segment);
39
+ this.lines.push(this.parts.join(''));
40
+ this.parts = [];
41
+ }
42
+ else {
43
+ this.lines.push(segment);
44
+ }
45
+ start = newlineIdx + 1;
46
+ }
47
+ if (start < text.length) {
48
+ this.parts.push(start === 0 ? text : text.substring(start));
49
+ }
50
+ }
51
+ /** The next complete line, or undefined when none is waiting. */
52
+ next() {
53
+ if (this.head >= this.lines.length) {
54
+ if (this.head > 0) {
55
+ this.lines = [];
56
+ this.head = 0;
57
+ }
58
+ return undefined;
59
+ }
60
+ const line = this.lines[this.head];
61
+ // Release the reference: a multi-megabyte line must not stay reachable from
62
+ // the queue after it has been handed out.
63
+ this.lines[this.head++] = '';
64
+ return line;
65
+ }
66
+ /** Forget everything received so far, including a half-received character. */
67
+ reset() {
68
+ this.decoder = new StringDecoder('utf8');
69
+ this.parts = [];
70
+ this.lines = [];
71
+ this.head = 0;
72
+ }
73
+ /** How many parts the unfinished line is held in (one per chunk that added to it). */
74
+ get pendingParts() {
75
+ return this.parts.length;
76
+ }
77
+ }
78
+ //# sourceMappingURL=lineReader.js.map
@@ -80,6 +80,11 @@ export declare function checkPrefixResolution(configuredPrefix: string, modelNam
80
80
  * `"false"` is off here exactly as it is at runtime.
81
81
  */
82
82
  export declare function checkSqlSwitch(store: SettingsStore, label: string, env?: NodeJS.ProcessEnv): CheckResult | null;
83
+ /**
84
+ * On UDE, `build_d365fo_project(deploy)` deploys through Power Platform Tools for Visual
85
+ * Studio's library. It is a UDE prerequisite, so its absence only costs the deploy option.
86
+ */
87
+ export declare function checkPowerPlatformTools(dirs: readonly string[]): CheckResult;
83
88
  /**
84
89
  * Tracing switched on: where captures will go and whether that drive can take one.
85
90
  *
@@ -94,6 +99,11 @@ export declare function checkTrace(store: SettingsStore, label: string, free?: (
94
99
  * (relations, form data sources, fields using an EDT). Null when configured.
95
100
  */
96
101
  export declare function checkXrefConfigured(store: SettingsStore): CheckResult | null;
102
+ /**
103
+ * The xref SQLite file (D365FO_XREF_SQLITE_PATH), opened the way the server opens
104
+ * it: read-only, validated, then closed. Null when none is configured.
105
+ */
106
+ export declare function checkXrefSqlite(store: SettingsStore): CheckResult | null;
97
107
  /**
98
108
  * A built bridge, judged against the sources it was compiled from (#1115). An
99
109
  * update can leave an old binary in place while it moves the bridge sources,