@codeyam/codeyam-cli 0.1.0-staging.596f0eb → 0.1.0-staging.6e699e5

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 (696) hide show
  1. package/analyzer-template/.build-info.json +8 -8
  2. package/analyzer-template/common/execAsync.ts +1 -1
  3. package/analyzer-template/log.txt +3 -3
  4. package/analyzer-template/package.json +10 -6
  5. package/analyzer-template/packages/ai/index.ts +10 -3
  6. package/analyzer-template/packages/ai/package.json +1 -1
  7. package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
  8. package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +128 -6
  9. package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
  10. package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +138 -1
  11. package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
  12. package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +140 -6
  13. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
  14. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +38 -1
  15. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
  16. package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +1239 -104
  17. package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +304 -0
  18. package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
  19. package/analyzer-template/packages/ai/src/lib/completionCall.ts +216 -36
  20. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +1501 -138
  21. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +2 -1
  22. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +976 -0
  23. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +243 -77
  24. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +19 -1
  25. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +103 -6
  26. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +23 -0
  27. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
  28. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +42 -2
  29. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
  30. package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +156 -0
  31. package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
  32. package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
  33. package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
  34. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +74 -7
  35. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +89 -112
  36. package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +6 -0
  37. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1111 -91
  38. package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +207 -104
  39. package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +570 -0
  40. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
  41. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +1977 -0
  42. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
  43. package/analyzer-template/packages/ai/src/lib/getConditionalUsagesFromCode.ts +143 -31
  44. package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +8 -2
  45. package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +276 -3
  46. package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +33 -3
  47. package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +7 -0
  48. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
  49. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -102
  50. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
  51. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
  52. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +90 -6
  53. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -53
  54. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
  55. package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +28 -2
  56. package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
  57. package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +812 -0
  58. package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
  59. package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
  60. package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +123 -0
  61. package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +8 -1
  62. package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +14 -0
  63. package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
  64. package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +1 -0
  65. package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
  66. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +455 -267
  67. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +18 -0
  68. package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -0
  69. package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -7
  70. package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +31 -15
  71. package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
  72. package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
  73. package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
  74. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +265 -0
  75. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
  76. package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +588 -52
  77. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
  78. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
  79. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +336 -133
  80. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +156 -0
  81. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +78 -83
  82. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +4 -8
  83. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +461 -94
  84. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
  85. package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
  86. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
  87. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
  88. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
  89. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
  90. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
  91. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
  92. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
  93. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
  94. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
  95. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
  96. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
  97. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
  98. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts +15 -0
  99. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts.map +1 -0
  100. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js +31 -0
  101. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js.map +1 -0
  102. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
  103. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
  104. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
  105. package/analyzer-template/packages/aws/package.json +3 -3
  106. package/analyzer-template/packages/aws/s3/index.ts +1 -0
  107. package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
  108. package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
  109. package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
  110. package/analyzer-template/packages/aws/src/lib/s3/checkS3ObjectExists.ts +47 -0
  111. package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
  112. package/analyzer-template/packages/database/src/lib/kysely/db.ts +4 -4
  113. package/analyzer-template/packages/database/src/lib/kysely/tableRelations.ts +2 -2
  114. package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +36 -9
  115. package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +7 -3
  116. package/analyzer-template/packages/generate/index.ts +3 -0
  117. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +17 -1
  118. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +193 -0
  119. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
  120. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +9 -4
  121. package/analyzer-template/packages/generate/src/lib/deepMerge.ts +26 -1
  122. package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
  123. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -2
  124. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +2 -2
  125. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tableRelations.d.ts +2 -2
  126. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +1 -11
  127. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
  128. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +30 -7
  129. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
  130. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
  131. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  132. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
  133. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
  134. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +2 -6
  135. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
  136. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
  137. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
  138. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  139. package/analyzer-template/packages/github/dist/generate/index.d.ts +3 -0
  140. package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
  141. package/analyzer-template/packages/github/dist/generate/index.js +3 -0
  142. package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
  143. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
  144. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
  145. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  146. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
  147. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
  148. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
  149. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
  150. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
  151. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
  152. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
  153. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
  154. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
  155. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
  156. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  157. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.d.ts.map +1 -1
  158. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js +27 -1
  159. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js.map +1 -1
  160. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
  161. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
  162. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
  163. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
  164. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
  165. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
  166. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
  167. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
  168. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
  169. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
  170. package/analyzer-template/packages/github/dist/types/index.d.ts +2 -2
  171. package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
  172. package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
  173. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +87 -13
  174. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
  175. package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
  176. package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
  177. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +11 -6
  178. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
  179. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +196 -0
  180. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  181. package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts +2 -0
  182. package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts.map +1 -1
  183. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
  184. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
  185. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  186. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
  187. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
  188. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
  189. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
  190. package/analyzer-template/packages/github/src/lib/loadOrCreateCommit.ts +14 -0
  191. package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
  192. package/analyzer-template/packages/process/index.ts +2 -0
  193. package/analyzer-template/packages/process/package.json +12 -0
  194. package/analyzer-template/packages/process/tsconfig.json +8 -0
  195. package/analyzer-template/packages/types/index.ts +5 -0
  196. package/analyzer-template/packages/types/src/types/Analysis.ts +104 -13
  197. package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
  198. package/analyzer-template/packages/types/src/types/Scenario.ts +11 -10
  199. package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +224 -0
  200. package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
  201. package/analyzer-template/packages/ui-components/src/components/ScenarioDetailInteractiveView.tsx +23 -7
  202. package/analyzer-template/packages/utils/dist/types/index.d.ts +2 -2
  203. package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
  204. package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
  205. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +87 -13
  206. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
  207. package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
  208. package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
  209. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +11 -6
  210. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
  211. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +196 -0
  212. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  213. package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
  214. package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts.map +1 -1
  215. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
  216. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
  217. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  218. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
  219. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
  220. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
  221. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
  222. package/analyzer-template/packages/utils/src/lib/lightweightEntityExtractor.ts +27 -0
  223. package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
  224. package/analyzer-template/playwright/capture.ts +37 -18
  225. package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
  226. package/analyzer-template/playwright/takeElementScreenshot.ts +26 -11
  227. package/analyzer-template/playwright/takeScreenshot.ts +9 -7
  228. package/analyzer-template/playwright/waitForServer.ts +21 -6
  229. package/analyzer-template/project/analyzeBaselineCommit.ts +4 -0
  230. package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
  231. package/analyzer-template/project/analyzeFileEntities.ts +4 -0
  232. package/analyzer-template/project/analyzeRegularCommit.ts +4 -0
  233. package/analyzer-template/project/constructMockCode.ts +1181 -160
  234. package/analyzer-template/project/controller/startController.ts +16 -1
  235. package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
  236. package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
  237. package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +3 -6
  238. package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +82 -36
  239. package/analyzer-template/project/orchestrateCapture.ts +36 -3
  240. package/analyzer-template/project/reconcileMockDataKeys.ts +245 -2
  241. package/analyzer-template/project/runAnalysis.ts +11 -0
  242. package/analyzer-template/project/runMultiScenarioServer.ts +11 -10
  243. package/analyzer-template/project/serverOnlyModules.ts +194 -21
  244. package/analyzer-template/project/start.ts +26 -4
  245. package/analyzer-template/project/startScenarioCapture.ts +79 -41
  246. package/analyzer-template/project/writeMockDataTsx.ts +232 -57
  247. package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
  248. package/analyzer-template/project/writeScenarioComponents.ts +769 -181
  249. package/analyzer-template/project/writeScenarioFiles.ts +26 -0
  250. package/analyzer-template/project/writeSimpleRoot.ts +13 -15
  251. package/analyzer-template/scripts/comboWorkerLoop.cjs +1 -0
  252. package/analyzer-template/scripts/defaultCmd.sh +9 -0
  253. package/analyzer-template/tsconfig.json +2 -1
  254. package/background/src/lib/local/createLocalAnalyzer.js +1 -29
  255. package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
  256. package/background/src/lib/local/execAsync.js +1 -1
  257. package/background/src/lib/local/execAsync.js.map +1 -1
  258. package/background/src/lib/virtualized/common/execAsync.js +1 -1
  259. package/background/src/lib/virtualized/common/execAsync.js.map +1 -1
  260. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +2 -1
  261. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
  262. package/background/src/lib/virtualized/project/analyzeBranchCommit.js +2 -1
  263. package/background/src/lib/virtualized/project/analyzeBranchCommit.js.map +1 -1
  264. package/background/src/lib/virtualized/project/analyzeFileEntities.js +2 -1
  265. package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
  266. package/background/src/lib/virtualized/project/analyzeRegularCommit.js +2 -1
  267. package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
  268. package/background/src/lib/virtualized/project/constructMockCode.js +1053 -124
  269. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  270. package/background/src/lib/virtualized/project/controller/startController.js +11 -1
  271. package/background/src/lib/virtualized/project/controller/startController.js.map +1 -1
  272. package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js +6 -3
  273. package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js.map +1 -1
  274. package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js +7 -7
  275. package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js.map +1 -1
  276. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +3 -2
  277. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
  278. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +69 -32
  279. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
  280. package/background/src/lib/virtualized/project/orchestrateCapture.js +27 -4
  281. package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
  282. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +204 -2
  283. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
  284. package/background/src/lib/virtualized/project/runAnalysis.js +9 -0
  285. package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
  286. package/background/src/lib/virtualized/project/runMultiScenarioServer.js +11 -9
  287. package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
  288. package/background/src/lib/virtualized/project/serverOnlyModules.js +163 -23
  289. package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
  290. package/background/src/lib/virtualized/project/start.js +21 -4
  291. package/background/src/lib/virtualized/project/start.js.map +1 -1
  292. package/background/src/lib/virtualized/project/startScenarioCapture.js +61 -31
  293. package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
  294. package/background/src/lib/virtualized/project/writeMockDataTsx.js +199 -50
  295. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  296. package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js +15 -0
  297. package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js.map +1 -0
  298. package/background/src/lib/virtualized/project/writeScenarioComponents.js +552 -125
  299. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  300. package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
  301. package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
  302. package/background/src/lib/virtualized/project/writeSimpleRoot.js +13 -13
  303. package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
  304. package/codeyam-cli/src/cli.js +7 -1
  305. package/codeyam-cli/src/cli.js.map +1 -1
  306. package/codeyam-cli/src/commands/analyze.js +1 -1
  307. package/codeyam-cli/src/commands/analyze.js.map +1 -1
  308. package/codeyam-cli/src/commands/baseline.js +174 -0
  309. package/codeyam-cli/src/commands/baseline.js.map +1 -0
  310. package/codeyam-cli/src/commands/debug.js +40 -18
  311. package/codeyam-cli/src/commands/debug.js.map +1 -1
  312. package/codeyam-cli/src/commands/default.js +0 -15
  313. package/codeyam-cli/src/commands/default.js.map +1 -1
  314. package/codeyam-cli/src/commands/recapture.js +226 -0
  315. package/codeyam-cli/src/commands/recapture.js.map +1 -0
  316. package/codeyam-cli/src/commands/report.js +72 -24
  317. package/codeyam-cli/src/commands/report.js.map +1 -1
  318. package/codeyam-cli/src/commands/start.js +8 -12
  319. package/codeyam-cli/src/commands/start.js.map +1 -1
  320. package/codeyam-cli/src/commands/status.js +23 -1
  321. package/codeyam-cli/src/commands/status.js.map +1 -1
  322. package/codeyam-cli/src/commands/test-startup.js +1 -1
  323. package/codeyam-cli/src/commands/test-startup.js.map +1 -1
  324. package/codeyam-cli/src/commands/wipe.js +108 -0
  325. package/codeyam-cli/src/commands/wipe.js.map +1 -0
  326. package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js +81 -0
  327. package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js.map +1 -0
  328. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +31 -27
  329. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
  330. package/codeyam-cli/src/utils/analysisRunner.js +8 -13
  331. package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
  332. package/codeyam-cli/src/utils/backgroundServer.js +14 -4
  333. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  334. package/codeyam-cli/src/utils/database.js +91 -5
  335. package/codeyam-cli/src/utils/database.js.map +1 -1
  336. package/codeyam-cli/src/utils/generateReport.js +253 -106
  337. package/codeyam-cli/src/utils/generateReport.js.map +1 -1
  338. package/codeyam-cli/src/utils/git.js +79 -0
  339. package/codeyam-cli/src/utils/git.js.map +1 -0
  340. package/codeyam-cli/src/utils/install-skills.js +31 -17
  341. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  342. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +38 -0
  343. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
  344. package/codeyam-cli/src/utils/queue/job.js +245 -16
  345. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  346. package/codeyam-cli/src/utils/queue/manager.js +25 -7
  347. package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
  348. package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
  349. package/codeyam-cli/src/utils/serverState.js.map +1 -1
  350. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +7 -5
  351. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
  352. package/codeyam-cli/src/utils/versionInfo.js +25 -19
  353. package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
  354. package/codeyam-cli/src/utils/wipe.js +128 -0
  355. package/codeyam-cli/src/utils/wipe.js.map +1 -0
  356. package/codeyam-cli/src/webserver/app/lib/database.js +98 -1
  357. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  358. package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
  359. package/codeyam-cli/src/webserver/backgroundServer.js +5 -10
  360. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  361. package/codeyam-cli/src/webserver/bootstrap.js +49 -0
  362. package/codeyam-cli/src/webserver/bootstrap.js.map +1 -0
  363. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-BXhEawa3.js +1 -0
  364. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-efWKDYMr.js → EntityTypeBadge-DLqD3qNt.js} +1 -1
  365. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-Ba2JVPzP.js +41 -0
  366. package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-C8lyxW9k.js +34 -0
  367. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-aht4aafF.js +25 -0
  368. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-CVtiBnY5.js +3 -0
  369. package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-B0GLXMsr.js +6 -0
  370. package/codeyam-cli/src/webserver/build/client/assets/LogViewer-xgeCVgSM.js +3 -0
  371. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-D4TZhLuw.js +21 -0
  372. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-DuDvi0jm.js +1 -0
  373. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-DEx02QDa.js +10 -0
  374. package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-COPstp9J.js → TruncatedFilePath-DyFZkK0l.js} +1 -1
  375. package/codeyam-cli/src/webserver/build/client/assets/_index-BwqWJOgH.js +11 -0
  376. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-DoLIqZX2.js +37 -0
  377. package/codeyam-cli/src/webserver/build/client/assets/api.health-l0sNRNKZ.js +1 -0
  378. package/codeyam-cli/src/webserver/build/client/assets/api.restart-server-l0sNRNKZ.js +1 -0
  379. package/codeyam-cli/src/webserver/build/client/assets/api.rules-l0sNRNKZ.js +1 -0
  380. package/codeyam-cli/src/webserver/build/client/assets/chevron-down-Cx24_aWc.js +6 -0
  381. package/codeyam-cli/src/webserver/build/client/assets/chunk-EPOLDU6W-CXRTFQ3F.js +51 -0
  382. package/codeyam-cli/src/webserver/build/client/assets/circle-check-BOARzkeR.js +6 -0
  383. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-BdhJEx6B.js +21 -0
  384. package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
  385. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
  386. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-BRb-0kQl.js +1 -0
  387. package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-C2N4Op8e.js +23 -0
  388. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DavjRmOY.js +6 -0
  389. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-D1T4TGjf.js +6 -0
  390. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-CTBG2mmz.js +5 -0
  391. package/codeyam-cli/src/webserver/build/client/assets/entry.client-CS2cb_eZ.js +29 -0
  392. package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
  393. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-DMJ7zii9.js +1 -0
  394. package/codeyam-cli/src/webserver/build/client/assets/files-Cs4MdYtv.js +1 -0
  395. package/codeyam-cli/src/webserver/build/client/assets/git-B4RJRvYB.js +15 -0
  396. package/codeyam-cli/src/webserver/build/client/assets/git-commit-horizontal-CysbcZxi.js +6 -0
  397. package/codeyam-cli/src/webserver/build/client/assets/globals-DMUaGAqV.css +1 -0
  398. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-fmIEn3Bc.js +9 -0
  399. package/codeyam-cli/src/webserver/build/client/assets/index-B1h680n5.js +9 -0
  400. package/codeyam-cli/src/webserver/build/client/assets/index-lzqtyFU8.js +3 -0
  401. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-B7B9V-bu.js +6 -0
  402. package/codeyam-cli/src/webserver/build/client/assets/manifest-f874c610.js +1 -0
  403. package/codeyam-cli/src/webserver/build/client/assets/preload-helper-ckwbz45p.js +1 -0
  404. package/codeyam-cli/src/webserver/build/client/assets/root-Bz5TunQg.js +57 -0
  405. package/codeyam-cli/src/webserver/build/client/assets/rules-hEkvVw2-.js +97 -0
  406. package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
  407. package/codeyam-cli/src/webserver/build/client/assets/search-CxXUmBSd.js +6 -0
  408. package/codeyam-cli/src/webserver/build/client/assets/settings-CS5f3WzT.js +1 -0
  409. package/codeyam-cli/src/webserver/build/client/assets/simulations-DwFIBT09.js +1 -0
  410. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-B6LgvRJg.js +6 -0
  411. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-C1v1PQzo.js +1 -0
  412. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-3pmpUQB-.js → useLastLogLine-aSv48UbS.js} +1 -1
  413. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DYxHZQuP.js +1 -0
  414. package/codeyam-cli/src/webserver/build/client/assets/{useToast-DEyawJ8r.js → useToast-mBRpZPiu.js} +1 -1
  415. package/codeyam-cli/src/webserver/build/server/assets/index-967OuJoF.js +1 -0
  416. package/codeyam-cli/src/webserver/build/server/assets/server-build-DRTmerg9.js +257 -0
  417. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  418. package/codeyam-cli/src/webserver/build-info.json +5 -5
  419. package/codeyam-cli/src/webserver/devServer.js +1 -3
  420. package/codeyam-cli/src/webserver/devServer.js.map +1 -1
  421. package/codeyam-cli/src/webserver/server.js +35 -25
  422. package/codeyam-cli/src/webserver/server.js.map +1 -1
  423. package/codeyam-cli/templates/codeyam-power-rules-hook.sh +200 -0
  424. package/codeyam-cli/templates/{codeyam-debug-skill.md → codeyam:debug.md} +48 -4
  425. package/codeyam-cli/templates/codeyam:diagnose.md +650 -0
  426. package/codeyam-cli/templates/codeyam:new-rule.md +13 -0
  427. package/codeyam-cli/templates/codeyam:power-rules.md +447 -0
  428. package/codeyam-cli/templates/{codeyam-setup-skill.md → codeyam:setup.md} +139 -4
  429. package/codeyam-cli/templates/{codeyam-sim-skill.md → codeyam:sim.md} +1 -1
  430. package/codeyam-cli/templates/{codeyam-test-skill.md → codeyam:test.md} +1 -1
  431. package/codeyam-cli/templates/{codeyam-verify-skill.md → codeyam:verify.md} +1 -1
  432. package/package.json +17 -16
  433. package/packages/ai/index.js +5 -4
  434. package/packages/ai/index.js.map +1 -1
  435. package/packages/ai/src/lib/analyzeScope.js +99 -0
  436. package/packages/ai/src/lib/analyzeScope.js.map +1 -1
  437. package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
  438. package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
  439. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +100 -1
  440. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
  441. package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
  442. package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
  443. package/packages/ai/src/lib/astScopes/methodSemantics.js +97 -6
  444. package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
  445. package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js +8 -0
  446. package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
  447. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +23 -0
  448. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
  449. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +138 -1
  450. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
  451. package/packages/ai/src/lib/astScopes/processExpression.js +945 -87
  452. package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
  453. package/packages/ai/src/lib/checkAllAttributes.js +24 -9
  454. package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
  455. package/packages/ai/src/lib/completionCall.js +178 -31
  456. package/packages/ai/src/lib/completionCall.js.map +1 -1
  457. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1198 -82
  458. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  459. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +2 -1
  460. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
  461. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +661 -0
  462. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -0
  463. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +180 -56
  464. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
  465. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +16 -1
  466. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
  467. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +86 -4
  468. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
  469. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +20 -0
  470. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
  471. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js +86 -0
  472. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js.map +1 -0
  473. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +34 -3
  474. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
  475. package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
  476. package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
  477. package/packages/ai/src/lib/dataStructureChunking.js +111 -0
  478. package/packages/ai/src/lib/dataStructureChunking.js.map +1 -0
  479. package/packages/ai/src/lib/deepEqual.js +32 -0
  480. package/packages/ai/src/lib/deepEqual.js.map +1 -0
  481. package/packages/ai/src/lib/e2eDataTracking.js +241 -0
  482. package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
  483. package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
  484. package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
  485. package/packages/ai/src/lib/generateChangesEntityScenarioData.js +62 -5
  486. package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
  487. package/packages/ai/src/lib/generateChangesEntityScenarios.js +81 -90
  488. package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
  489. package/packages/ai/src/lib/generateEntityDataStructure.js +5 -0
  490. package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
  491. package/packages/ai/src/lib/generateEntityScenarioData.js +904 -84
  492. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  493. package/packages/ai/src/lib/generateEntityScenarios.js +186 -82
  494. package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
  495. package/packages/ai/src/lib/generateExecutionFlows.js +392 -0
  496. package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -0
  497. package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js +380 -0
  498. package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js.map +1 -0
  499. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +1440 -0
  500. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -0
  501. package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
  502. package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
  503. package/packages/ai/src/lib/getConditionalUsagesFromCode.js +84 -14
  504. package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
  505. package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -1
  506. package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
  507. package/packages/ai/src/lib/isolateScopes.js +231 -4
  508. package/packages/ai/src/lib/isolateScopes.js.map +1 -1
  509. package/packages/ai/src/lib/mergeStatements.js +26 -3
  510. package/packages/ai/src/lib/mergeStatements.js.map +1 -1
  511. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +6 -0
  512. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
  513. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +1 -1
  514. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
  515. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -64
  516. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
  517. package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
  518. package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
  519. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +68 -6
  520. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
  521. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -34
  522. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
  523. package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
  524. package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
  525. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +16 -3
  526. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
  527. package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
  528. package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
  529. package/packages/ai/src/lib/resolvePathToControllable.js +667 -0
  530. package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
  531. package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
  532. package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
  533. package/packages/ai/src/lib/worker/SerializableDataStructure.js +29 -0
  534. package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
  535. package/packages/ai/src/lib/worker/analyzeScopeWorker.js +4 -0
  536. package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
  537. package/packages/analyze/src/lib/FileAnalyzer.js +15 -0
  538. package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
  539. package/packages/analyze/src/lib/analysisContext.js +30 -5
  540. package/packages/analyze/src/lib/analysisContext.js.map +1 -1
  541. package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
  542. package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
  543. package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
  544. package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
  545. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +218 -50
  546. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  547. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +10 -0
  548. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  549. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +2 -0
  550. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
  551. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -7
  552. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
  553. package/packages/analyze/src/lib/files/analyzeChange.js +21 -11
  554. package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
  555. package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
  556. package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
  557. package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
  558. package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
  559. package/packages/analyze/src/lib/files/enums/steps.js +1 -1
  560. package/packages/analyze/src/lib/files/enums/steps.js.map +1 -1
  561. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +209 -0
  562. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -0
  563. package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
  564. package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
  565. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +458 -48
  566. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
  567. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
  568. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
  569. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
  570. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
  571. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +264 -78
  572. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  573. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +96 -0
  574. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
  575. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +56 -69
  576. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
  577. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +4 -8
  578. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
  579. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +372 -89
  580. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  581. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
  582. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
  583. package/packages/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
  584. package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
  585. package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
  586. package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
  587. package/packages/database/src/lib/kysely/db.js +2 -2
  588. package/packages/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
  589. package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  590. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
  591. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  592. package/packages/generate/index.js +3 -0
  593. package/packages/generate/index.js.map +1 -1
  594. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
  595. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  596. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
  597. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
  598. package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
  599. package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
  600. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
  601. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  602. package/packages/generate/src/lib/deepMerge.js +27 -1
  603. package/packages/generate/src/lib/deepMerge.js.map +1 -1
  604. package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
  605. package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
  606. package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
  607. package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
  608. package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
  609. package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
  610. package/packages/process/index.js +3 -0
  611. package/packages/process/index.js.map +1 -0
  612. package/packages/process/src/GlobalProcessManager.js.map +1 -0
  613. package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
  614. package/packages/process/src/ProcessManager.js.map +1 -0
  615. package/packages/process/src/index.js.map +1 -0
  616. package/packages/process/src/managedExecAsync.js.map +1 -0
  617. package/packages/types/index.js.map +1 -1
  618. package/packages/utils/src/lib/lightweightEntityExtractor.js +25 -0
  619. package/packages/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  620. package/packages/utils/src/lib/safeFileName.js +29 -3
  621. package/packages/utils/src/lib/safeFileName.js.map +1 -1
  622. package/scripts/finalize-analyzer.cjs +6 -4
  623. package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
  624. package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -197
  625. package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -271
  626. package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -294
  627. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
  628. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -115
  629. package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
  630. package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
  631. package/analyzer-template/process/README.md +0 -507
  632. package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
  633. package/background/src/lib/process/ProcessManager.js.map +0 -1
  634. package/background/src/lib/process/index.js.map +0 -1
  635. package/background/src/lib/process/managedExecAsync.js.map +0 -1
  636. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
  637. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
  638. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-CVbSvOjo.js +0 -1
  639. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-DcwcHyl5.js +0 -1
  640. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-WgwC1GfJ.js +0 -26
  641. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-IEKom9O2.js +0 -3
  642. package/codeyam-cli/src/webserver/build/client/assets/LogViewer-BYnfxbUG.js +0 -3
  643. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-_lBPJCzG.js +0 -1
  644. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-lHVhvsu_.js +0 -1
  645. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-d_TBk4GQ.js +0 -5
  646. package/codeyam-cli/src/webserver/build/client/assets/_index-kGT7VUqj.js +0 -1
  647. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-DDGmhu7P.js +0 -7
  648. package/codeyam-cli/src/webserver/build/client/assets/chevron-down-n_HPRfM_.js +0 -1
  649. package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-CbVoyx1U.js +0 -26
  650. package/codeyam-cli/src/webserver/build/client/assets/circle-check-D1VOYveA.js +0 -1
  651. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-YR8jjAlu.js +0 -1
  652. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-B8vP3V_s.js +0 -1
  653. package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-CN6aLCT1.js +0 -16
  654. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DA5Jeu2P.js +0 -1
  655. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-BTeitalf.js +0 -5
  656. package/codeyam-cli/src/webserver/build/client/assets/entry.client-du6UEYD-.js +0 -13
  657. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-BpjkhMoi.js +0 -1
  658. package/codeyam-cli/src/webserver/build/client/assets/files-BQGvk4lJ.js +0 -1
  659. package/codeyam-cli/src/webserver/build/client/assets/git-DVdYRT-I.js +0 -12
  660. package/codeyam-cli/src/webserver/build/client/assets/globals-CO-U8Bpo.css +0 -1
  661. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +0 -5
  662. package/codeyam-cli/src/webserver/build/client/assets/index-DCG-vks0.js +0 -1
  663. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-GazdNeLl.js +0 -1
  664. package/codeyam-cli/src/webserver/build/client/assets/manifest-0b694d28.js +0 -1
  665. package/codeyam-cli/src/webserver/build/client/assets/root-D3tQP7hx.js +0 -16
  666. package/codeyam-cli/src/webserver/build/client/assets/search-CIY6XmtE.js +0 -1
  667. package/codeyam-cli/src/webserver/build/client/assets/server-build-CMKNK2uU.css +0 -1
  668. package/codeyam-cli/src/webserver/build/client/assets/settings-CoMDgElu.js +0 -1
  669. package/codeyam-cli/src/webserver/build/client/assets/simulations-agkniXp2.js +0 -1
  670. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-B2VUcygF.js +0 -1
  671. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-EvdK-zXP.js +0 -1
  672. package/codeyam-cli/src/webserver/build/server/assets/index-DGVHQEXD.js +0 -1
  673. package/codeyam-cli/src/webserver/build/server/assets/server-build-CghkTkIL.js +0 -166
  674. package/codeyam-cli/templates/debug-command.md +0 -303
  675. package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
  676. package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
  677. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -136
  678. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
  679. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -220
  680. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
  681. package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -241
  682. package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
  683. package/packages/ai/src/lib/isFrontend.js +0 -5
  684. package/packages/ai/src/lib/isFrontend.js.map +0 -1
  685. package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
  686. package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
  687. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -72
  688. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
  689. /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
  690. /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
  691. /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
  692. /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
  693. /package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-CMKNK2uU.css → styles-CMKNK2uU.css} +0 -0
  694. /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
  695. /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
  696. /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
@@ -79,15 +79,27 @@
79
79
  * - `helpers/README.md` - Overview of the helper module architecture
80
80
  */
81
81
  import fillInSchemaGapsAndUnknowns from "./helpers/fillInSchemaGapsAndUnknowns.js";
82
+ /**
83
+ * Patterns that indicate recursive type structures in schema paths.
84
+ * Used by hasExcessivePatternRepetition() to detect exponential path blowup.
85
+ */
86
+ const RECURSIVE_PATH_PATTERNS = [
87
+ /\.attributes\.properties\[\]/g, // TypeScript AST JSX nodes
88
+ /\.children\[\]/g, // Tree structures
89
+ /\.elements\[\]/g, // Array-like structures
90
+ /\.members\[\]/g, // Class/interface members
91
+ /\.properties\[\]/g, // Object properties
92
+ /\.items\[\]/g, // Generic items arrays
93
+ ];
82
94
  import ensureSchemaConsistency from "./helpers/ensureSchemaConsistency.js";
83
95
  import cleanPath from "./helpers/cleanPath.js";
84
96
  import { PathManager } from "./helpers/PathManager.js";
85
- import { uniqueId, uniqueScopeVariables, uniqueScopeAndPaths, } from "./helpers/uniqueIdUtils.js";
97
+ import { uniqueId, uniqueScopeAndPaths, uniqueScopeVariables, } from "./helpers/uniqueIdUtils.js";
86
98
  import selectBestValue from "./helpers/selectBestValue.js";
87
99
  import { VisitedTracker } from "./helpers/VisitedTracker.js";
88
100
  import { DebugTracer } from "./helpers/DebugTracer.js";
89
101
  import { BatchSchemaProcessor } from "./helpers/BatchSchemaProcessor.js";
90
- import { ScopeTreeManager, ROOT_SCOPE_NAME, } from "./helpers/ScopeTreeManager.js";
102
+ import { ROOT_SCOPE_NAME, ScopeTreeManager, } from "./helpers/ScopeTreeManager.js";
91
103
  import cleanScopeNodeName from "./helpers/cleanScopeNodeName.js";
92
104
  import getFunctionCallRoot from "./helpers/getFunctionCallRoot.js";
93
105
  import cleanPathOfNonTransformingFunctions from "./helpers/cleanPathOfNonTransformingFunctions.js";
@@ -140,6 +152,10 @@ const ALLOWED_EQUIVALENCY_REASONS = new Set([
140
152
  'propagated function call return sub-property equivalency',
141
153
  'propagated parent-variable equivalency', // Added: propagate child scope equivalencies to parent scope when variable is defined in parent
142
154
  'where was this function called from', // Added: tracks which scope called an external function
155
+ 'MUI DataGrid renderCell params.row equivalency', // Added: links DataGrid renderCell params.row to rows array elements
156
+ 'MUI Autocomplete getOptionLabel option equivalency', // Added: links Autocomplete getOptionLabel callback param to options array
157
+ 'MUI Autocomplete renderOption option equivalency', // Added: links Autocomplete renderOption callback param to options array
158
+ 'MUI Autocomplete option property equivalency', // Added: propagates property accesses from Autocomplete callbacks
143
159
  ]);
144
160
  const SILENTLY_IGNORED_EQUIVALENCY_REASONS = new Set([
145
161
  'signature of functionCall',
@@ -172,6 +188,26 @@ export class ScopeDataStructure {
172
188
  * Maps local variable path to array of usages.
173
189
  */
174
190
  this.rawConditionalUsages = {};
191
+ /**
192
+ * Conditional effects collected during AST analysis.
193
+ * Tracks what setter calls happen inside conditionals (if, switch, ternary).
194
+ */
195
+ this.rawConditionalEffects = [];
196
+ /**
197
+ * Compound conditionals collected during AST analysis.
198
+ * Groups conditions that must all be true together (e.g., a && b && c).
199
+ */
200
+ this.rawCompoundConditionals = [];
201
+ /**
202
+ * Gating conditions for child component boundaries.
203
+ * Maps child component name to the conditions that must be true for it to render.
204
+ */
205
+ this.rawChildBoundaryGatingConditions = {};
206
+ /**
207
+ * JSX rendering usages collected during AST analysis.
208
+ * Tracks arrays rendered via .map() and strings interpolated in JSX.
209
+ */
210
+ this.rawJsxRenderingUsages = [];
175
211
  this.lastAddToSchemaId = 0;
176
212
  this.lastEquivalencyId = 0;
177
213
  this.lastEquivalencyDatabaseId = 0;
@@ -183,6 +219,9 @@ export class ScopeDataStructure {
183
219
  // Index for O(1) lookup of external function calls by name
184
220
  // Invalidated by setting to null; rebuilt lazily on next access
185
221
  this.externalFunctionCallsIndex = null;
222
+ // Tracks internal functions that have been filtered out during captureCompleteSchema
223
+ // Prevents re-adding them via subsequent equivalency propagation (e.g., from getReturnValue)
224
+ this.filteredInternalFunctions = new Set();
186
225
  // Debug tracer for selective path/scope tracing
187
226
  // Enable via: CODEYAM_DEBUG=true CODEYAM_DEBUG_PATHS="user.*,signature" npm test
188
227
  this.tracer = new DebugTracer({
@@ -301,6 +340,8 @@ export class ScopeDataStructure {
301
340
  const efcName = this.pathManager.stripGenerics(efc.name);
302
341
  for (const manager of this.equivalencyManagers) {
303
342
  if (manager.internalFunctions.has(efcName)) {
343
+ // Track this so we don't re-add it via subsequent finalize calls
344
+ this.filteredInternalFunctions.add(efcName);
304
345
  return false;
305
346
  }
306
347
  }
@@ -321,11 +362,42 @@ export class ScopeDataStructure {
321
362
  });
322
363
  entry.sourceCandidates = entry.sourceCandidates.filter((candidate) => {
323
364
  const baseName = this.pathManager.stripGenerics(candidate.scopeNodeName);
365
+ // Check if this is a local variable path (doesn't contain function call pattern)
366
+ // Local variables like "surveys[]" or "items[]" are important for tracing data flow
367
+ // from parent to child components (e.g., surveys[] -> SurveyCard().signature[0].survey)
368
+ const isLocalVariablePath = !candidate.schemaPath.includes('()') &&
369
+ !candidate.schemaPath.startsWith('signature[') &&
370
+ !candidate.schemaPath.startsWith('returnValue');
324
371
  return (validExternalFacingScopeNames.has(baseName) &&
325
372
  (candidate.schemaPath.startsWith('signature[') ||
326
- candidate.schemaPath.startsWith(baseName)) &&
373
+ candidate.schemaPath.startsWith(baseName) ||
374
+ isLocalVariablePath) &&
327
375
  !containsArrayMethod(candidate.schemaPath));
328
376
  });
377
+ // If all sourceCandidates were filtered out (e.g., because they belonged to
378
+ // internal functions like useState), look for the highest-order intermediate
379
+ // that belongs to a valid external-facing scope
380
+ if (entry.sourceCandidates.length === 0 &&
381
+ Object.keys(entry.intermediatesOrder).length > 0) {
382
+ // Find intermediates that belong to valid external-facing scopes
383
+ const validIntermediates = Object.entries(entry.intermediatesOrder)
384
+ .filter(([pathId]) => {
385
+ const [scopeNodeName, schemaPath] = pathId.split('::');
386
+ if (!scopeNodeName || !schemaPath)
387
+ return false;
388
+ const baseName = this.pathManager.stripGenerics(scopeNodeName);
389
+ return (validExternalFacingScopeNames.has(baseName) &&
390
+ !containsArrayMethod(schemaPath));
391
+ })
392
+ .sort((a, b) => b[1] - a[1]); // Sort by order descending (highest first)
393
+ if (validIntermediates.length > 0) {
394
+ const [pathId] = validIntermediates[0];
395
+ const [scopeNodeName, schemaPath] = pathId.split('::');
396
+ if (scopeNodeName && schemaPath) {
397
+ entry.sourceCandidates.push({ scopeNodeName, schemaPath });
398
+ }
399
+ }
400
+ }
329
401
  }
330
402
  this.propagateSourceAndUsageEquivalencies(this.scopeNodes[this.scopeTreeManager.getRootName()]);
331
403
  for (const externalFunctionCall of this.externalFunctionCalls) {
@@ -559,7 +631,6 @@ export class ScopeDataStructure {
559
631
  }
560
632
  addEquivalency(path, equivalentPath, equivalentScopeName, scopeNode, equivalencyReason, equivalencyValueChain, traceId) {
561
633
  var _a;
562
- // DEBUG: Detect infinite loops
563
634
  addEquivalencyCallCount++;
564
635
  if (addEquivalencyCallCount > 50000) {
565
636
  console.error('INFINITE LOOP DETECTED in addEquivalency', {
@@ -754,10 +825,31 @@ export class ScopeDataStructure {
754
825
  const searchKey = getFunctionCallRoot(functionCallInfo.callSignature);
755
826
  const existingFunctionCall = this.getExternalFunctionCallsIndex().get(searchKey);
756
827
  if (existingFunctionCall) {
757
- existingFunctionCall.schema = {
828
+ // Preserve per-call schemas BEFORE merging to enable per-variable mock data.
829
+ // This is critical for hooks like useFetcher<UserData>() vs useFetcher<ReportData>()
830
+ // where each call returns different typed data.
831
+ if (!existingFunctionCall.perCallSignatureSchemas) {
832
+ // First merge - save the existing call's schema
833
+ existingFunctionCall.perCallSignatureSchemas = {
834
+ [existingFunctionCall.callSignature]: {
835
+ ...existingFunctionCall.schema,
836
+ },
837
+ };
838
+ }
839
+ // Save the new call's schema before it gets merged
840
+ existingFunctionCall.perCallSignatureSchemas[functionCallInfo.callSignature] = { ...functionCallInfo.schema };
841
+ // Merge schemas using selectBestValue to preserve specific types like 'null'
842
+ // over generic types like 'unknown'. This ensures ref variables detected
843
+ // earlier (marked as 'null') aren't overwritten by later 'unknown' values.
844
+ const mergedSchema = {
758
845
  ...existingFunctionCall.schema,
759
- ...functionCallInfo.schema,
760
846
  };
847
+ for (const key in functionCallInfo.schema) {
848
+ const existingValue = existingFunctionCall.schema[key];
849
+ const newValue = functionCallInfo.schema[key];
850
+ mergedSchema[key] = selectBestValue(existingValue, newValue, newValue);
851
+ }
852
+ existingFunctionCall.schema = mergedSchema;
761
853
  existingFunctionCall.equivalencies = {
762
854
  ...existingFunctionCall.equivalencies,
763
855
  ...functionCallInfo.equivalencies,
@@ -777,8 +869,13 @@ export class ScopeDataStructure {
777
869
  const isExternal = !callingScopeNode.instantiatedVariables?.includes(functionCallInfoNameParts[0]) &&
778
870
  !callingScopeNode.parentInstantiatedVariables?.includes(functionCallInfoNameParts[0]);
779
871
  if (isExternal) {
780
- this.externalFunctionCalls.push(functionCallInfo);
781
- this.invalidateExternalFunctionCallsIndex();
872
+ // Check if this function was already filtered out as an internal function
873
+ // (e.g., useState was filtered in captureCompleteSchema but finalize is trying to re-add it)
874
+ const strippedName = this.pathManager.stripGenerics(functionCallInfo.name);
875
+ if (!this.filteredInternalFunctions.has(strippedName)) {
876
+ this.externalFunctionCalls.push(functionCallInfo);
877
+ this.invalidateExternalFunctionCallsIndex();
878
+ }
782
879
  }
783
880
  }
784
881
  }
@@ -847,6 +944,17 @@ export class ScopeDataStructure {
847
944
  const remainingKey = remainingSchemaPathParts.join('|');
848
945
  const equivalentSchemaPath = equivalentSchemaPathMap.get(remainingKey);
849
946
  if (equivalentSchemaPath) {
947
+ // Skip propagation when there's a structural mismatch:
948
+ // - schemaPath ends with [] (array element, represents an object)
949
+ // - equivalentSchemaPath doesn't end with [] (non-array prop, usually a scalar)
950
+ // This prevents incorrectly typing array elements as strings when they're
951
+ // equivalent to scalar props like JSX keys (e.g., workouts[] ↔ Card().key)
952
+ const schemaPathEndsWithArray = schemaPath.endsWith('[]');
953
+ const equivalentEndsWithArray = equivalentSchemaPath.endsWith('[]');
954
+ if (schemaPathEndsWithArray !== equivalentEndsWithArray) {
955
+ // Don't propagate between array element paths and non-array paths
956
+ continue;
957
+ }
850
958
  const value1 = scopeNode.schema[schemaPath];
851
959
  const value2 = equivalentScopeNode.schema[equivalentSchemaPath];
852
960
  const bestValue = selectBestValue(value1, value2);
@@ -917,6 +1025,51 @@ export class ScopeDataStructure {
917
1025
  isValidPath(path) {
918
1026
  return this.pathManager.isValidPath(path);
919
1027
  }
1028
+ /**
1029
+ * Detects if a path contains excessive repetition of the same pattern.
1030
+ *
1031
+ * This prevents exponential blowup when analyzing recursive type structures.
1032
+ * For example, TypeScript AST nodes have `.attributes.properties[]` where each
1033
+ * property is also a node with `.attributes.properties[]`. Without this check,
1034
+ * paths like `signature[0].attributes.properties[].attributes.properties[].attributes.properties[]...`
1035
+ * would be generated exponentially.
1036
+ *
1037
+ * Two detection strategies:
1038
+ * 1. Known patterns: Check RECURSIVE_PATH_PATTERNS for common recursive structures
1039
+ * 2. Generic detection: For longer paths, detect any 2-3 part segment that repeats
1040
+ *
1041
+ * @param path - The schema path to check
1042
+ * @param maxRepetitions - Maximum allowed repetitions of any pattern (default: 2)
1043
+ * @returns true if the path has excessive repetition
1044
+ */
1045
+ hasExcessivePatternRepetition(path, maxRepetitions = 2) {
1046
+ // Check known recursive patterns
1047
+ for (const pattern of RECURSIVE_PATH_PATTERNS) {
1048
+ const matches = path.match(pattern);
1049
+ if (matches && matches.length > maxRepetitions) {
1050
+ return true;
1051
+ }
1052
+ }
1053
+ // For longer paths, detect any repeated multi-part segments we haven't explicitly listed
1054
+ const pathParts = this.splitPath(path);
1055
+ if (pathParts.length <= 6) {
1056
+ return false;
1057
+ }
1058
+ // Check for repeated sequences of 2-3 consecutive parts
1059
+ for (let segmentLength = 2; segmentLength <= 3; segmentLength++) {
1060
+ const seen = new Map();
1061
+ for (let i = 0; i <= pathParts.length - segmentLength; i++) {
1062
+ const segment = pathParts.slice(i, i + segmentLength).join('.');
1063
+ const normalizedSegment = segment.replace(/\[\d+\]/g, '[]');
1064
+ const count = (seen.get(normalizedSegment) || 0) + 1;
1065
+ seen.set(normalizedSegment, count);
1066
+ if (count > maxRepetitions) {
1067
+ return true;
1068
+ }
1069
+ }
1070
+ }
1071
+ return false;
1072
+ }
920
1073
  addToTree(pathParts) {
921
1074
  this.scopeTreeManager.addPath(pathParts);
922
1075
  }
@@ -957,22 +1110,10 @@ export class ScopeDataStructure {
957
1110
  this.checkExternalFunctionCalls();
958
1111
  }
959
1112
  determineEquivalenciesAndBuildSchema(scopeNode) {
960
- const { isolatedStructure, isolatedEquivalentVariables } = scopeNode.analysis;
961
- // DEBUG: Log all equivalencies related to useFetcher
962
- if (Object.keys(isolatedEquivalentVariables || {}).some((k) => k.includes('Fetcher') || k.includes('fetcher'))) {
963
- console.log('CodeYam DEBUG determineEquivalenciesAndBuildSchema:', JSON.stringify({
964
- scopeNodeName: scopeNode.name,
965
- fetcherEquivalencies: Object.entries(isolatedEquivalentVariables || {})
966
- .filter(([k, v]) => k.includes('Fetcher') ||
967
- k.includes('fetcher') ||
968
- String(v).includes('Fetcher') ||
969
- String(v).includes('fetcher'))
970
- .reduce((acc, [k, v]) => {
971
- acc[k] = v;
972
- return acc;
973
- }, {}),
974
- }, null, 2));
1113
+ if (!scopeNode.analysis) {
1114
+ return;
975
1115
  }
1116
+ const { isolatedStructure, isolatedEquivalentVariables } = scopeNode.analysis;
976
1117
  const allPaths = Array.from(new Set([
977
1118
  ...Object.keys(isolatedStructure || {}),
978
1119
  ...Object.keys(isolatedEquivalentVariables || {}),
@@ -981,8 +1122,24 @@ export class ScopeDataStructure {
981
1122
  for (let path in isolatedEquivalentVariables) {
982
1123
  let equivalentValue = isolatedEquivalentVariables?.[path];
983
1124
  if (equivalentValue && this.isValidPath(equivalentValue)) {
984
- path = cleanPath(path.replace(/::cyDuplicateKey\d+::/g, ''), allPaths);
985
- equivalentValue = cleanPath(equivalentValue.replace(/::cyDuplicateKey\d+::/g, ''), allPaths);
1125
+ // IMPORTANT: DO NOT strip ::cyDuplicateKey:: markers from equivalencies.
1126
+ // These markers are critical for distinguishing variable reassignments.
1127
+ // For example, with:
1128
+ // let fetcher = useFetcher<ConfigData>();
1129
+ // const configData = fetcher.data?.data;
1130
+ // fetcher = useFetcher<SettingsData>();
1131
+ // const settingsData = fetcher.data?.data;
1132
+ //
1133
+ // mergeStatements creates:
1134
+ // fetcher → useFetcher<ConfigData>()...
1135
+ // fetcher::cyDuplicateKey1:: → useFetcher<SettingsData>()...
1136
+ // configData → fetcher.data.data
1137
+ // settingsData → fetcher::cyDuplicateKey1::.data.data
1138
+ //
1139
+ // If we strip ::cyDuplicateKey::, settingsData would incorrectly trace
1140
+ // to useFetcher<ConfigData>() instead of useFetcher<SettingsData>().
1141
+ path = cleanPath(path, allPaths);
1142
+ equivalentValue = cleanPath(equivalentValue, allPaths);
986
1143
  this.addEquivalency(path, equivalentValue, scopeNode.name, scopeNode, 'original equivalency');
987
1144
  // Propagate equivalencies involving parent-scope variables to those parent scopes.
988
1145
  // This handles patterns like: collected.push({...entity}) where 'collected' is defined
@@ -1074,7 +1231,7 @@ export class ScopeDataStructure {
1074
1231
  // This eliminates deep call stacks and improves deduplication
1075
1232
  this.batchProcessor = new BatchSchemaProcessor();
1076
1233
  this.batchQueuedSet = new Set();
1077
- for (const key of Array.from(allPaths)) {
1234
+ for (const key of allPaths) {
1078
1235
  let value = isolatedStructure[key] ?? 'unknown';
1079
1236
  if (['null', 'undefined'].includes(value)) {
1080
1237
  value = 'unknown';
@@ -1108,7 +1265,14 @@ export class ScopeDataStructure {
1108
1265
  processBatchQueue() {
1109
1266
  if (!this.batchProcessor)
1110
1267
  return;
1268
+ let iterations = 0;
1111
1269
  while (this.batchProcessor.hasWork()) {
1270
+ iterations++;
1271
+ // Safety: detect potential infinite loops
1272
+ if (iterations > 100000) {
1273
+ console.error(`[ScopeDataStructure] processBatchQueue exceeded 100k iterations, possible infinite loop!`);
1274
+ break;
1275
+ }
1112
1276
  const item = this.batchProcessor.getNextWork();
1113
1277
  if (!item)
1114
1278
  break;
@@ -1155,18 +1319,6 @@ export class ScopeDataStructure {
1155
1319
  // Find the FunctionCallInfo that matches this call signature
1156
1320
  const searchKey = getFunctionCallRoot(callSignature);
1157
1321
  const functionCallInfo = this.getExternalFunctionCallsIndex().get(searchKey);
1158
- // DEBUG: Track useFetcher calls
1159
- if (searchKey === 'useFetcher' || callSignature.includes('useFetcher')) {
1160
- console.log('CodeYam DEBUG trackReceivingVariable:', JSON.stringify({
1161
- receivingVariable,
1162
- equivalentValue,
1163
- callSignature,
1164
- searchKey,
1165
- foundFunctionCallInfo: !!functionCallInfo,
1166
- existingRecvVars: functionCallInfo?.receivingVariableNames,
1167
- existingCallSigToVar: functionCallInfo?.callSignatureToVariable,
1168
- }, null, 2));
1169
- }
1170
1322
  if (!functionCallInfo) {
1171
1323
  return;
1172
1324
  }
@@ -1521,6 +1673,17 @@ export class ScopeDataStructure {
1521
1673
  continue;
1522
1674
  }
1523
1675
  const newEquivalentPath = this.joinPathParts([schemaPath, remainingPath]);
1676
+ // PERF: Detect repeated patterns in paths to prevent exponential blowup
1677
+ // Paths like `signature[0].attributes.properties[].attributes.properties[]...`
1678
+ // indicate recursive type structures that cause exponential schema explosion
1679
+ if (this.hasExcessivePatternRepetition(newEquivalentPath)) {
1680
+ if (traceId && debugLevel > 0) {
1681
+ console.info('Debug: skipping path with excessive pattern repetition', {
1682
+ path: newEquivalentPath,
1683
+ });
1684
+ }
1685
+ continue;
1686
+ }
1524
1687
  if (!equivalentScopeNode) {
1525
1688
  if (traceId) {
1526
1689
  console.info('Debug Propagation: missing equivalent scope info', {
@@ -2133,7 +2296,12 @@ export class ScopeDataStructure {
2133
2296
  return acc;
2134
2297
  }, {});
2135
2298
  }
2299
+ // CRITICAL: Set onlyEquivalencies to true to prevent database modifications
2300
+ // during this "getter" method. See comment in getFunctionSignature.
2301
+ const wasOnlyEquivalencies = this.onlyEquivalencies;
2302
+ this.onlyEquivalencies = true;
2136
2303
  this.validateSchema(scopeNode, true, fillInUnknowns);
2304
+ this.onlyEquivalencies = wasOnlyEquivalencies;
2137
2305
  const { schema } = scopeNode;
2138
2306
  // For root scope, merge in external function call schemas
2139
2307
  // This ensures that imported objects used as method call targets (like logger.error())
@@ -2162,9 +2330,22 @@ export class ScopeDataStructure {
2162
2330
  }
2163
2331
  }
2164
2332
  }
2165
- return mergedSchema;
2333
+ return this.filterDuplicateKeys(mergedSchema);
2166
2334
  }
2167
- return schema;
2335
+ return this.filterDuplicateKeys(schema);
2336
+ }
2337
+ /**
2338
+ * Filter out ::cyDuplicateKey:: entries from a schema.
2339
+ * These are internal markers for tracking variable reassignments
2340
+ * and should not appear in output schemas or LLM prompts.
2341
+ */
2342
+ filterDuplicateKeys(schema) {
2343
+ return Object.entries(schema).reduce((acc, [key, value]) => {
2344
+ if (!key.includes('::cyDuplicateKey')) {
2345
+ acc[key] = value;
2346
+ }
2347
+ return acc;
2348
+ }, {});
2168
2349
  }
2169
2350
  getEquivalencies(scopeName) {
2170
2351
  const scopeNode = this.getScopeOrFunctionCallInfo(scopeName);
@@ -2230,11 +2411,12 @@ export class ScopeDataStructure {
2230
2411
  return acc;
2231
2412
  }, {});
2232
2413
  const equivalencies = this.getEquivalencies(functionName);
2414
+ const scopeName = functionName ?? this.scopeTreeManager.getRootName();
2233
2415
  for (const equivalenceKey in equivalencies ?? {}) {
2234
2416
  for (const equivalenceValue of equivalencies[equivalenceKey]) {
2235
2417
  const schemaPath = equivalenceValue.schemaPath;
2236
2418
  if (schemaPath.startsWith('signature[') &&
2237
- equivalenceValue.scopeNodeName === functionName &&
2419
+ equivalenceValue.scopeNodeName === scopeName &&
2238
2420
  !signatureInSchema[schemaPath]) {
2239
2421
  signatureInSchema[schemaPath] = 'unknown';
2240
2422
  }
@@ -2242,9 +2424,60 @@ export class ScopeDataStructure {
2242
2424
  }
2243
2425
  const tempScopeNode = this.createTempScopeNode(functionName ?? this.scopeTreeManager.getRootName(), signatureInSchema, equivalencies);
2244
2426
  this.validateSchema(tempScopeNode, true, fillInUnknowns);
2245
- return tempScopeNode.schema;
2427
+ // After validateSchema has filled in types, propagate nested paths from
2428
+ // variables to their signature equivalents.
2429
+ // e.g., workouts[].activity_type -> signature[0].workouts[].activity_type
2430
+ //
2431
+ // Build a map of variable names that are equivalent to signature paths
2432
+ // e.g., { 'workouts': 'signature[0].workouts' }
2433
+ const variableToSignatureMap = {};
2434
+ for (const equivalenceKey in equivalencies ?? {}) {
2435
+ for (const equivalenceValue of equivalencies[equivalenceKey]) {
2436
+ const schemaPath = equivalenceValue.schemaPath;
2437
+ // Track which variables map to signature paths
2438
+ // equivalenceKey is the variable name (e.g., 'workouts')
2439
+ // schemaPath is where it comes from (e.g., 'signature[0].workouts')
2440
+ if (schemaPath.startsWith('signature[') &&
2441
+ equivalenceValue.scopeNodeName === scopeName) {
2442
+ variableToSignatureMap[equivalenceKey] = schemaPath;
2443
+ }
2444
+ }
2445
+ }
2446
+ // Propagate nested paths from variables to their signature equivalents
2447
+ // e.g., if workouts = signature[0].workouts, then workouts[].title becomes
2448
+ // signature[0].workouts[].title
2449
+ for (const schemaKey in schema) {
2450
+ // Skip keys that already start with signature[
2451
+ if (schemaKey.startsWith('signature['))
2452
+ continue;
2453
+ // Check if this key starts with a variable that maps to a signature path
2454
+ for (const [variableName, signaturePath] of Object.entries(variableToSignatureMap)) {
2455
+ // Check if schemaKey starts with variableName followed by a property accessor
2456
+ // e.g., 'workouts[]' starts with 'workouts'
2457
+ if (schemaKey === variableName ||
2458
+ schemaKey.startsWith(variableName + '.') ||
2459
+ schemaKey.startsWith(variableName + '[')) {
2460
+ // Transform the path: replace the variable prefix with the signature path
2461
+ const suffix = schemaKey.slice(variableName.length);
2462
+ const signatureKey = signaturePath + suffix;
2463
+ // Add to schema if not already present
2464
+ if (!tempScopeNode.schema[signatureKey]) {
2465
+ tempScopeNode.schema[signatureKey] = schema[schemaKey];
2466
+ }
2467
+ }
2468
+ }
2469
+ }
2470
+ return this.filterDuplicateKeys(tempScopeNode.schema);
2246
2471
  }
2247
2472
  getReturnValue({ functionName, fillInUnknowns, }) {
2473
+ // Trigger finalization on all managers to apply any pending updates
2474
+ // (e.g., ref type propagation to external function call schemas)
2475
+ const rootScope = this.scopeNodes[this.scopeTreeManager.getRootName()];
2476
+ if (rootScope) {
2477
+ for (const manager of this.equivalencyManagers) {
2478
+ manager.finalize(rootScope, this);
2479
+ }
2480
+ }
2248
2481
  const scopeName = functionName ?? this.scopeTreeManager.getRootName();
2249
2482
  const scopeNode = this.scopeNodes[scopeName];
2250
2483
  let schema = {};
@@ -2255,7 +2488,8 @@ export class ScopeDataStructure {
2255
2488
  });
2256
2489
  }
2257
2490
  else {
2258
- for (const externalFunctionCall of this.externalFunctionCalls) {
2491
+ // Use getExternalFunctionCalls() which cleans cyScope from schemas
2492
+ for (const externalFunctionCall of this.getExternalFunctionCalls()) {
2259
2493
  const functionNameParts = this.splitPath(functionName).map((p) => this.functionOrScopeName(p));
2260
2494
  const nameParts = this.splitPath(externalFunctionCall.name).map((p) => this.functionOrScopeName(p));
2261
2495
  if (functionNameParts.every((part, index) => part === nameParts[index])) {
@@ -2276,14 +2510,27 @@ export class ScopeDataStructure {
2276
2510
  // Include function paths even if their return value wasn't captured
2277
2511
  // This ensures methods like onAuthStateChange are included in the schema
2278
2512
  // But exclude signature entries (they should only be included via functionCallReturnValue paths)
2279
- (schema[key] === 'function' && key.indexOf('signature[') === -1))
2513
+ // Also exclude bare function call signatures - paths that are JUST a call like
2514
+ // "useCustomSizes(projectSlug)" should not be included as return values.
2515
+ // These represent "the function exists" not actual return data, and including
2516
+ // them causes nested path bugs in dependencySchemas.
2517
+ (schema[key] === 'function' &&
2518
+ key.indexOf('signature[') === -1 &&
2519
+ // Exclude bare call signatures: function calls with no dots OUTSIDE parentheses
2520
+ // e.g., "useCustomSizes(projectSlug)" is bare (exclude)
2521
+ // e.g., "loadProject({nested.property})" is bare - dots are inside args (exclude)
2522
+ // e.g., "getSupabase().auth.method()" has dots outside - method chain (include)
2523
+ !this.isBareCallSignature(key)))
2280
2524
  .reduce((acc, key) => {
2281
2525
  acc[key] = schema[key];
2282
2526
  const keyParts = this.splitPath(key);
2283
2527
  for (const path in schema) {
2284
2528
  const pathParts = this.splitPath(path);
2285
2529
  if (pathParts.every((p, i) => keyParts[i] === p)) {
2286
- acc[path] = schema[path];
2530
+ // Also exclude bare call signatures from prefix paths
2531
+ if (!this.isBareCallSignature(path)) {
2532
+ acc[path] = schema[path];
2533
+ }
2287
2534
  }
2288
2535
  }
2289
2536
  return acc;
@@ -2291,12 +2538,68 @@ export class ScopeDataStructure {
2291
2538
  // Replace cyScope placeholders with actual callback text
2292
2539
  const resolvedSchema = this.replaceCyScopePlaceholders(returnValueSchema);
2293
2540
  const tempScopeNode = this.createTempScopeNode(scopeName, resolvedSchema);
2541
+ // CRITICAL: Set onlyEquivalencies to true to prevent database modifications
2542
+ // during this "getter" method. See comment in getFunctionSignature.
2543
+ const wasOnlyEquivalencies = this.onlyEquivalencies;
2544
+ this.onlyEquivalencies = true;
2294
2545
  this.validateSchema(tempScopeNode, true, fillInUnknowns);
2295
- return tempScopeNode.schema;
2546
+ this.onlyEquivalencies = wasOnlyEquivalencies;
2547
+ // Remove bare call signatures from the return value schema.
2548
+ // fillInSchemaGapsAndUnknowns may add parent paths like "useCustomSizes(projectSlug)"
2549
+ // when it sees "useCustomSizes(projectSlug).functionCallReturnValue". These bare
2550
+ // call signatures represent "the function exists" not actual return data, and
2551
+ // including them causes nested path bugs in dependencySchemas.
2552
+ const resultSchema = tempScopeNode.schema;
2553
+ for (const key of Object.keys(resultSchema)) {
2554
+ if (this.isBareCallSignature(key)) {
2555
+ delete resultSchema[key];
2556
+ }
2557
+ }
2558
+ return resultSchema;
2559
+ }
2560
+ /**
2561
+ * Checks if a schema key is a "bare call signature" - a function call with no
2562
+ * method chain before it and no path segments after it.
2563
+ *
2564
+ * A bare call signature represents "this function exists" rather than actual
2565
+ * return data, and including them causes nested path bugs in dependencySchemas.
2566
+ *
2567
+ * Examples:
2568
+ * - "useCustomSizes(projectSlug)" -> bare (true)
2569
+ * - "loadProject({nested.property})" -> bare (dots are inside args, true)
2570
+ * - "getSupabase().auth.method()" -> not bare (has dots outside parens, false)
2571
+ * - "useProject().functionCallReturnValue" -> not bare (has path after, false)
2572
+ */
2573
+ isBareCallSignature(key) {
2574
+ // Must end with ) and contain ( to be a call
2575
+ if (!key.endsWith(')') || key.indexOf('(') === -1) {
2576
+ return false;
2577
+ }
2578
+ // Check if there are any dots OUTSIDE of parentheses
2579
+ // Strip out content inside balanced parentheses, then check for dots
2580
+ let depth = 0;
2581
+ let hasDotsOutsideParens = false;
2582
+ for (let i = 0; i < key.length; i++) {
2583
+ const char = key[i];
2584
+ if (char === '(') {
2585
+ depth++;
2586
+ }
2587
+ else if (char === ')') {
2588
+ depth--;
2589
+ }
2590
+ else if (char === '.' && depth === 0) {
2591
+ hasDotsOutsideParens = true;
2592
+ break;
2593
+ }
2594
+ }
2595
+ // It's a bare call signature if there are no dots outside parentheses
2596
+ return !hasDotsOutsideParens;
2296
2597
  }
2297
2598
  /**
2298
2599
  * Replaces cyScope placeholder references (e.g., cyScope10()) in schema keys
2299
2600
  * with the actual callback function text from the corresponding scope node.
2601
+ * If the scope text can't be found, uses a generic fallback to avoid leaking
2602
+ * internal cyScope names into stored data.
2300
2603
  */
2301
2604
  replaceCyScopePlaceholders(schema) {
2302
2605
  const cyScopePattern = /cyScope(\d+)\(\)/g;
@@ -2308,10 +2611,10 @@ export class ScopeDataStructure {
2308
2611
  for (const match of matches) {
2309
2612
  const cyScopeName = `cyScope${match[1]}`;
2310
2613
  const scopeText = this.findCyScopeText(cyScopeName);
2311
- if (scopeText) {
2312
- // Replace cyScope10() with the actual callback text
2313
- newKey = newKey.replace(match[0], scopeText);
2314
- }
2614
+ // Always replace cyScope references - use actual text if available,
2615
+ // otherwise use a generic callback placeholder
2616
+ const replacement = scopeText || '() => {}';
2617
+ newKey = newKey.replace(match[0], replacement);
2315
2618
  }
2316
2619
  result[newKey] = value;
2317
2620
  }
@@ -2363,10 +2666,270 @@ export class ScopeDataStructure {
2363
2666
  const equivalentSignatureVariables = {};
2364
2667
  for (const [path, equivalentValues] of Object.entries(scopeNode.equivalencies)) {
2365
2668
  for (const equivalentValue of equivalentValues) {
2669
+ // Case 1: Props/signature equivalencies (existing behavior)
2670
+ // Maps local variable names to their signature paths
2671
+ // e.g., "propValue" -> "signature[0].prop"
2366
2672
  if (path.startsWith('signature[')) {
2367
2673
  equivalentSignatureVariables[equivalentValue.schemaPath] = path;
2368
2674
  }
2675
+ // Case 2: Hook variable equivalencies (new behavior)
2676
+ // The equivalencies are stored as: path = variable name, schemaPath = data source
2677
+ // e.g., path = "debugFetcher", schemaPath = "useFetcher<...>().functionCallReturnValue"
2678
+ // We need to map: "debugFetcher" -> "useFetcher<...>()"
2679
+ // This enables resolving paths like "debugFetcher.state" to
2680
+ // "useFetcher<...>().state" for execution flow validation
2681
+ if (equivalentValue.schemaPath.endsWith('.functionCallReturnValue')) {
2682
+ // Extract the hook call path (everything before .functionCallReturnValue)
2683
+ let hookCallPath = equivalentValue.schemaPath.slice(0, -'.functionCallReturnValue'.length);
2684
+ // Only include if it looks like a hook call (contains parentheses)
2685
+ // and the variable name (path) is a simple identifier (no dots)
2686
+ if (hookCallPath.includes('(') && !path.includes('.')) {
2687
+ // Special case: If hookCallPath is a callback scope (cyScope pattern),
2688
+ // trace through it to find what the callback actually returns.
2689
+ // This handles useState(() => { return prop; }) patterns.
2690
+ const cyScopeMatch = hookCallPath.match(/^(cyScope\d+)\(\)$/);
2691
+ if (cyScopeMatch) {
2692
+ // Use the equivalency database to trace the callback's return value
2693
+ // to its actual source (e.g., viewModeFromUrl -> segments -> params -> useParams)
2694
+ const dbEntry = this.getEquivalenciesDatabaseEntry(scopeNode.name, // Component scope
2695
+ path);
2696
+ if (dbEntry?.sourceCandidates?.length > 0) {
2697
+ // Use the traced source instead of the callback scope
2698
+ hookCallPath = dbEntry.sourceCandidates[0].schemaPath;
2699
+ }
2700
+ }
2701
+ equivalentSignatureVariables[path] = hookCallPath;
2702
+ }
2703
+ }
2704
+ // Case 3: Destructured variables from local variables
2705
+ // e.g., const { scenarios } = currentEntityAnalysis;
2706
+ // This creates: path = "scenarios", schemaPath = "currentEntityAnalysis.scenarios"
2707
+ // We need to map: "scenarios" -> "currentEntityAnalysis.scenarios"
2708
+ // AND resolve transitively if currentEntityAnalysis is itself equivalent to a hook call
2709
+ if (!path.includes('.') && // path is a simple identifier
2710
+ !equivalentValue.schemaPath.startsWith('signature[') && // not a signature path
2711
+ !equivalentValue.schemaPath.endsWith('.functionCallReturnValue') // not already handled above
2712
+ ) {
2713
+ // Only add if we haven't already captured this variable in Case 1 or 2
2714
+ if (!(path in equivalentSignatureVariables)) {
2715
+ equivalentSignatureVariables[path] = equivalentValue.schemaPath;
2716
+ }
2717
+ }
2718
+ // Case 4: Child component prop mappings (Fix 22)
2719
+ // When parent renders <ChildComponent prop={value} />, we get equivalencies like:
2720
+ // path = "ChildComponent().signature[0].prop"
2721
+ // schemaPath = "value" (the variable passed as the prop)
2722
+ // We need to include these so translateChildPathToParent can work.
2723
+ // Pattern: ComponentName().signature[N] or ComponentName().signature[N].propName
2724
+ if (path.includes('().signature[') &&
2725
+ !equivalentValue.schemaPath.includes('()') // schemaPath is a simple variable, not a function call
2726
+ ) {
2727
+ equivalentSignatureVariables[path] = equivalentValue.schemaPath;
2728
+ }
2729
+ // Case 5: Destructured function parameters (Fix 25)
2730
+ // When a function has destructured props: function Comp({ propA, propB }: Props)
2731
+ // We get equivalencies like:
2732
+ // path = "propA" (the destructured variable name)
2733
+ // schemaPath = "signature[0].propA" (the signature path)
2734
+ // We need to map: "propA" -> "signature[0].propA"
2735
+ // This enables translateChildPathToParent to resolve child variable paths
2736
+ // to their signature paths when merging execution flows.
2737
+ if (!path.includes('.') && // path is a simple identifier (destructured prop name)
2738
+ equivalentValue.schemaPath.startsWith('signature[') // schemaPath IS a signature path
2739
+ ) {
2740
+ equivalentSignatureVariables[path] = equivalentValue.schemaPath;
2741
+ }
2742
+ // Case 7: Method calls on variables that result in .functionCallReturnValue (Fix 33)
2743
+ // When we have patterns like:
2744
+ // path = "segments" (simple identifier)
2745
+ // schemaPath = "splat.split('/').functionCallReturnValue"
2746
+ // This is a method call on a variable (not a hook call), but we still need to
2747
+ // track it so transitive resolution can resolve `splat` to its actual source.
2748
+ // E.g., if splat -> useParams().functionCallReturnValue['*'], then
2749
+ // segments -> useParams().functionCallReturnValue['*'].split('/').functionCallReturnValue
2750
+ if (!path.includes('.') && // path is a simple identifier
2751
+ equivalentValue.schemaPath.endsWith('.functionCallReturnValue') && // ends with function return
2752
+ equivalentValue.schemaPath.includes('.') && // has property access (method call)
2753
+ !(path in equivalentSignatureVariables) // not already captured
2754
+ ) {
2755
+ // Check if this looks like a method call on a variable (not a hook call)
2756
+ // Hook calls look like: hookName() or hookName<T>()
2757
+ // Method calls look like: variable.method() or variable.method<T>()
2758
+ const hookCallPath = equivalentValue.schemaPath.slice(0, -'.functionCallReturnValue'.length);
2759
+ // If it's a method call (contains a dot before the parenthesis), include it
2760
+ const dotBeforeParen = hookCallPath.indexOf('.');
2761
+ const parenPos = hookCallPath.indexOf('(');
2762
+ if (dotBeforeParen !== -1 && dotBeforeParen < parenPos) {
2763
+ // This is a method call like "splat.split('/')", not a hook call
2764
+ equivalentSignatureVariables[path] = equivalentValue.schemaPath;
2765
+ }
2766
+ }
2767
+ }
2768
+ }
2769
+ // Case 6: Collect JSX child prop equivalencies from child scopes (Fix 26)
2770
+ // When a parent component renders <ChildComponent prop={value} />, the JSX
2771
+ // return statement may be in a child scope (e.g., cyScope2). The equivalencies
2772
+ // like ChildComponent().signature[0].prop -> value get stored in that child scope.
2773
+ // But translateChildPathToParent needs to find them from the parent scope's context.
2774
+ // So we collect Case 4 patterns from ALL child scopes that belong to this root scope.
2775
+ const rootName = this.scopeTreeManager.getRootName();
2776
+ for (const [scopeName, childScopeNode] of Object.entries(this.scopeNodes)) {
2777
+ // Skip the root scope (already processed above)
2778
+ if (scopeName === rootName)
2779
+ continue;
2780
+ // Only include scopes that are children of the root (their tree includes root)
2781
+ if (!childScopeNode.tree?.includes(rootName))
2782
+ continue;
2783
+ // Look for Case 4 patterns in the child scope
2784
+ for (const [path, equivalentValues] of Object.entries(childScopeNode.equivalencies || {})) {
2785
+ for (const equivalentValue of equivalentValues) {
2786
+ // Case 4 pattern: ChildComponent().signature[0].propName -> parentVariable
2787
+ if (path.includes('().signature[') &&
2788
+ !equivalentValue.schemaPath.includes('()') // schemaPath is a simple variable
2789
+ ) {
2790
+ // Only add if not already present from the root scope
2791
+ if (!(path in equivalentSignatureVariables)) {
2792
+ equivalentSignatureVariables[path] = equivalentValue.schemaPath;
2793
+ }
2794
+ }
2795
+ }
2796
+ }
2797
+ }
2798
+ // Transitive resolution: Resolve variable chains through multiple levels
2799
+ // E.g., analysis → currentEntityAnalysis → useLoaderData().functionCallReturnValue.currentEntityAnalysis
2800
+ // We need multiple passes because resolutions can depend on each other
2801
+ const maxIterations = 5; // Prevent infinite loops
2802
+ for (let iteration = 0; iteration < maxIterations; iteration++) {
2803
+ let changed = false;
2804
+ for (const [varName, sourcePath] of Object.entries(equivalentSignatureVariables)) {
2805
+ // Skip if already fully resolved (contains function call syntax)
2806
+ // BUT first check for computed value patterns that need resolution (Fix 28)
2807
+ // AND method call patterns that need base variable resolution (Fix 33)
2808
+ if (sourcePath.includes('()')) {
2809
+ // Fix 28: Handle computed value patterns with dependency arrays
2810
+ // Patterns like `functionName(arg, [dep1, dep2, ...])` are NOT controllable
2811
+ // data sources. We trace through the dependencies to find controllable sources.
2812
+ const bracketStart = sourcePath.indexOf('[');
2813
+ const bracketEnd = sourcePath.lastIndexOf(']');
2814
+ if (bracketStart !== -1 && bracketEnd > bracketStart) {
2815
+ const arrayContent = sourcePath.slice(bracketStart + 1, bracketEnd);
2816
+ const items = arrayContent.split(',').map((s) => s.trim());
2817
+ // Only process if this looks like a dependency array:
2818
+ // multiple items that are all simple identifiers (not numbers or expressions)
2819
+ const isIdentifier = (s) => /^\w+$/.test(s) && !/^\d+$/.test(s);
2820
+ if (items.length > 1 && items.every(isIdentifier)) {
2821
+ // Look for a dependency that's already resolved to a controllable source
2822
+ for (const dep of items) {
2823
+ if (dep in equivalentSignatureVariables) {
2824
+ const resolvedDep = equivalentSignatureVariables[dep];
2825
+ // Use if it's a controllable path (contains hook call)
2826
+ // and is NOT another unresolved computed pattern (has comma-separated deps)
2827
+ const hasCommaInBrackets = resolvedDep.includes('[') &&
2828
+ resolvedDep.includes(',') &&
2829
+ resolvedDep.indexOf(',') > resolvedDep.indexOf('[');
2830
+ if (resolvedDep.includes('()') && !hasCommaInBrackets) {
2831
+ // Computed value is typically an element from an array
2832
+ equivalentSignatureVariables[varName] = resolvedDep + '[]';
2833
+ changed = true;
2834
+ break;
2835
+ }
2836
+ }
2837
+ }
2838
+ }
2839
+ }
2840
+ // Fix 33: Handle method call patterns on variables
2841
+ // Patterns like: "splat.split('/').functionCallReturnValue"
2842
+ // We need to resolve the base variable (splat) to its actual source
2843
+ // Check if this is a method call on a variable (dot before first parenthesis)
2844
+ const dotIndex = sourcePath.indexOf('.');
2845
+ const parenIndex = sourcePath.indexOf('(');
2846
+ if (dotIndex !== -1 &&
2847
+ dotIndex < parenIndex &&
2848
+ !sourcePath.startsWith('use') // Not a hook call like useState()
2849
+ ) {
2850
+ // Extract the base variable (before the first dot)
2851
+ const baseVar = sourcePath.slice(0, dotIndex);
2852
+ const rest = sourcePath.slice(dotIndex); // includes ".method(...).functionCallReturnValue"
2853
+ // Check if the base variable can be resolved
2854
+ if (baseVar in equivalentSignatureVariables &&
2855
+ baseVar !== varName) {
2856
+ const baseResolved = equivalentSignatureVariables[baseVar];
2857
+ // Only resolve if the base resolved to something useful (contains () or .)
2858
+ if (baseResolved.includes('()') || baseResolved.includes('.')) {
2859
+ const newPath = baseResolved + rest;
2860
+ if (newPath !== equivalentSignatureVariables[varName]) {
2861
+ equivalentSignatureVariables[varName] = newPath;
2862
+ changed = true;
2863
+ }
2864
+ }
2865
+ }
2866
+ }
2867
+ // Fix 38: Handle cyScope lazy initializer return values
2868
+ // When we have viewMode -> cyScope20(), trace through to find what cyScope20 returns.
2869
+ // The lazy initializer's return value should be the controllable data source.
2870
+ // Pattern: cyScopeN() where N is a number
2871
+ const cyScopeMatch = sourcePath.match(/^(cyScope\d+)\(\)$/);
2872
+ if (cyScopeMatch) {
2873
+ const cyScopeName = cyScopeMatch[1];
2874
+ const cyScopeNode = this.scopeNodes[cyScopeName];
2875
+ if (cyScopeNode?.equivalencies) {
2876
+ // Look for returnValue equivalency in the cyScope
2877
+ const returnValueEquivs = cyScopeNode.equivalencies['returnValue'];
2878
+ if (returnValueEquivs && returnValueEquivs.length > 0) {
2879
+ // Get the first return value source
2880
+ const returnSource = returnValueEquivs[0].schemaPath;
2881
+ // If the return source is a simple variable (not a complex path),
2882
+ // resolve varName directly to that variable
2883
+ if (returnSource &&
2884
+ !returnSource.includes('(') &&
2885
+ !returnSource.includes('[')) {
2886
+ // Update varName to point to the return source
2887
+ if (equivalentSignatureVariables[varName] !== returnSource) {
2888
+ equivalentSignatureVariables[varName] = returnSource;
2889
+ changed = true;
2890
+ }
2891
+ }
2892
+ }
2893
+ }
2894
+ }
2895
+ continue;
2896
+ }
2897
+ // Check if the source path starts with a variable that's also in the map
2898
+ const dotIndex = sourcePath.indexOf('.');
2899
+ let baseVar;
2900
+ let rest;
2901
+ if (dotIndex > 0) {
2902
+ // Path has a dot: "a.b.c" -> baseVar="a", rest=".b.c"
2903
+ baseVar = sourcePath.slice(0, dotIndex);
2904
+ rest = sourcePath.slice(dotIndex); // includes the leading dot
2905
+ }
2906
+ else {
2907
+ // Path is a simple identifier: "currentEntityAnalysis" -> baseVar="currentEntityAnalysis", rest=""
2908
+ baseVar = sourcePath;
2909
+ rest = '';
2910
+ }
2911
+ if (baseVar in equivalentSignatureVariables && baseVar !== varName) {
2912
+ const baseResolved = equivalentSignatureVariables[baseVar];
2913
+ // If the base resolves to a hook call, add .functionCallReturnValue
2914
+ if (baseResolved.endsWith('()')) {
2915
+ const newPath = baseResolved + '.functionCallReturnValue' + rest;
2916
+ if (newPath !== equivalentSignatureVariables[varName]) {
2917
+ equivalentSignatureVariables[varName] = newPath;
2918
+ changed = true;
2919
+ }
2920
+ }
2921
+ else if (baseResolved !== sourcePath) {
2922
+ const newPath = baseResolved + rest;
2923
+ if (newPath !== equivalentSignatureVariables[varName]) {
2924
+ equivalentSignatureVariables[varName] = newPath;
2925
+ changed = true;
2926
+ }
2927
+ }
2928
+ }
2369
2929
  }
2930
+ // Stop if no changes were made in this iteration
2931
+ if (!changed)
2932
+ break;
2370
2933
  }
2371
2934
  return equivalentSignatureVariables;
2372
2935
  }
@@ -2399,7 +2962,12 @@ export class ScopeDataStructure {
2399
2962
  return { ...acc, ...filterdSchema };
2400
2963
  }, {});
2401
2964
  const tempScopeNode = this.createTempScopeNode(scopeName ?? this.scopeTreeManager.getRootName(), relevantSchema);
2965
+ // CRITICAL: Set onlyEquivalencies to true to prevent database modifications
2966
+ // during this "getter" method. See comment in getFunctionSignature.
2967
+ const wasOnlyEquivalencies = this.onlyEquivalencies;
2968
+ this.onlyEquivalencies = true;
2402
2969
  this.validateSchema(tempScopeNode, true, final);
2970
+ this.onlyEquivalencies = wasOnlyEquivalencies;
2403
2971
  return {
2404
2972
  name: variableName,
2405
2973
  equivalentTo: equivalents,
@@ -2407,7 +2975,96 @@ export class ScopeDataStructure {
2407
2975
  };
2408
2976
  }
2409
2977
  getExternalFunctionCalls() {
2410
- return this.externalFunctionCalls;
2978
+ // Replace cyScope placeholders in all external function call data
2979
+ // This ensures call signatures and schema paths use actual callback text
2980
+ // instead of internal cyScope names, preventing mock data merge conflicts.
2981
+ return this.externalFunctionCalls.map((efc) => this.cleanCyScopeFromFunctionCallInfo(efc));
2982
+ }
2983
+ /**
2984
+ * Cleans cyScope placeholder references from a FunctionCallInfo.
2985
+ * Replaces cyScopeN() with the actual callback text in:
2986
+ * - callSignature
2987
+ * - allCallSignatures
2988
+ * - schema keys
2989
+ */
2990
+ cleanCyScopeFromFunctionCallInfo(efc) {
2991
+ const cyScopePattern = /cyScope\d+\(\)/g;
2992
+ // Check if any cleaning is needed
2993
+ const hasCyScope = cyScopePattern.test(efc.callSignature) ||
2994
+ (efc.allCallSignatures &&
2995
+ efc.allCallSignatures.some((sig) => /cyScope\d+\(\)/.test(sig))) ||
2996
+ (efc.schema &&
2997
+ Object.keys(efc.schema).some((key) => /cyScope\d+\(\)/.test(key)));
2998
+ if (!hasCyScope) {
2999
+ return efc;
3000
+ }
3001
+ // Create cleaned copy
3002
+ const cleaned = { ...efc };
3003
+ // Clean callSignature
3004
+ cleaned.callSignature = this.replaceCyScopeInString(efc.callSignature);
3005
+ // Clean allCallSignatures
3006
+ if (efc.allCallSignatures) {
3007
+ cleaned.allCallSignatures = efc.allCallSignatures.map((sig) => this.replaceCyScopeInString(sig));
3008
+ }
3009
+ // Clean schema keys
3010
+ if (efc.schema) {
3011
+ cleaned.schema = this.replaceCyScopePlaceholders(efc.schema);
3012
+ }
3013
+ // Clean callSignatureToVariable keys
3014
+ if (efc.callSignatureToVariable) {
3015
+ cleaned.callSignatureToVariable = Object.entries(efc.callSignatureToVariable).reduce((acc, [key, value]) => {
3016
+ acc[this.replaceCyScopeInString(key)] = value;
3017
+ return acc;
3018
+ }, {});
3019
+ }
3020
+ return cleaned;
3021
+ }
3022
+ /**
3023
+ * Replaces cyScope placeholder references in a single string.
3024
+ * If the scope text can't be found, uses a generic fallback to avoid leaking
3025
+ * internal cyScope names into stored data.
3026
+ *
3027
+ * Handles two patterns:
3028
+ * 1. Function call style: cyScope7() - matched by cyScope(\d+)\(\)
3029
+ * 2. Scope name style: parentName____cyScopeXX or cyScopeXX - matched by (\w+____)?cyScope([0-9A-Fa-f]+)
3030
+ */
3031
+ replaceCyScopeInString(str) {
3032
+ let result = str;
3033
+ // Pattern 1: Function call style - cyScope7()
3034
+ const functionCallPattern = /cyScope(\d+)\(\)/g;
3035
+ const functionCallMatches = [...str.matchAll(functionCallPattern)];
3036
+ for (const match of functionCallMatches) {
3037
+ const cyScopeName = `cyScope${match[1]}`;
3038
+ const scopeText = this.findCyScopeText(cyScopeName);
3039
+ // Always replace cyScope references - use actual text if available,
3040
+ // otherwise use a generic callback placeholder
3041
+ const replacement = scopeText || '() => {}';
3042
+ result = result.replace(match[0], replacement);
3043
+ }
3044
+ // Pattern 2: Scope name style - parentName____cyScopeXX or just cyScopeXX
3045
+ // This handles hex-encoded scope IDs like cyScope1F
3046
+ const scopeNamePattern = /(\w+____)?cyScope([0-9A-Fa-f]+)/g;
3047
+ const scopeNameMatches = [...result.matchAll(scopeNamePattern)];
3048
+ for (const match of scopeNameMatches) {
3049
+ const fullMatch = match[0];
3050
+ const prefix = match[1] || ''; // e.g., "getTitleColor____"
3051
+ const cyScopeId = match[2]; // e.g., "1F"
3052
+ const cyScopeName = `cyScope${cyScopeId}`;
3053
+ // Try to find the scope text, checking both with and without prefix
3054
+ let scopeText = this.findCyScopeText(cyScopeName);
3055
+ if (!scopeText && prefix) {
3056
+ // Try looking up with the full prefixed name
3057
+ scopeText = this.findCyScopeText(`${prefix}${cyScopeName}`);
3058
+ }
3059
+ if (scopeText) {
3060
+ result = result.replace(fullMatch, scopeText);
3061
+ }
3062
+ else {
3063
+ // Replace with a generic identifier to avoid leaking internal names
3064
+ result = result.replace(fullMatch, 'callback');
3065
+ }
3066
+ }
3067
+ return result;
2411
3068
  }
2412
3069
  getEnvironmentVariables() {
2413
3070
  return this.environmentVariables;
@@ -2433,9 +3090,112 @@ export class ScopeDataStructure {
2433
3090
  }
2434
3091
  }
2435
3092
  }
3093
+ /**
3094
+ * Add conditional effects from AST analysis.
3095
+ * Called during scope analysis to collect all setter calls inside conditionals.
3096
+ */
3097
+ addConditionalEffects(effects) {
3098
+ // Add effects, avoiding duplicates based on effect stateVariable and condition paths
3099
+ for (const effect of effects) {
3100
+ const exists = this.rawConditionalEffects.some((existing) => {
3101
+ // Same effect target (stateVariable + value)
3102
+ const sameEffect = existing.effect.stateVariable === effect.effect.stateVariable &&
3103
+ existing.effect.value === effect.effect.value;
3104
+ if (!sameEffect)
3105
+ return false;
3106
+ // Same condition(s)
3107
+ if (existing.condition && effect.condition) {
3108
+ return (existing.condition.path === effect.condition.path &&
3109
+ existing.condition.requiredValue === effect.condition.requiredValue);
3110
+ }
3111
+ if (existing.conditions && effect.conditions) {
3112
+ if (existing.conditions.length !== effect.conditions.length)
3113
+ return false;
3114
+ return existing.conditions.every((ec, i) => {
3115
+ const newCond = effect.conditions[i];
3116
+ return (ec.path === newCond.path &&
3117
+ ec.requiredValue === newCond.requiredValue);
3118
+ });
3119
+ }
3120
+ return false;
3121
+ });
3122
+ if (!exists) {
3123
+ this.rawConditionalEffects.push(effect);
3124
+ }
3125
+ }
3126
+ }
3127
+ /**
3128
+ * Get conditional effects collected during analysis.
3129
+ */
3130
+ getConditionalEffects() {
3131
+ return this.rawConditionalEffects;
3132
+ }
3133
+ /**
3134
+ * Add compound conditionals from AST analysis.
3135
+ * Called during scope analysis to collect grouped conditions (e.g., a && b && c).
3136
+ */
3137
+ addCompoundConditionals(compounds) {
3138
+ // Add compounds, avoiding duplicates based on chainId
3139
+ for (const compound of compounds) {
3140
+ const exists = this.rawCompoundConditionals.some((existing) => existing.chainId === compound.chainId);
3141
+ if (!exists) {
3142
+ this.rawCompoundConditionals.push(compound);
3143
+ }
3144
+ }
3145
+ }
3146
+ /**
3147
+ * Get compound conditionals collected during analysis.
3148
+ */
3149
+ getCompoundConditionals() {
3150
+ return this.rawCompoundConditionals;
3151
+ }
3152
+ /**
3153
+ * Add child boundary gating conditions from AST analysis.
3154
+ * These track which conditions must be true for a child component to render.
3155
+ */
3156
+ addChildBoundaryGatingConditions(conditions) {
3157
+ for (const [childName, usages] of Object.entries(conditions)) {
3158
+ if (!this.rawChildBoundaryGatingConditions[childName]) {
3159
+ this.rawChildBoundaryGatingConditions[childName] = [];
3160
+ }
3161
+ // Add usages, avoiding duplicates
3162
+ for (const usage of usages) {
3163
+ const exists = this.rawChildBoundaryGatingConditions[childName].some((existing) => existing.path === usage.path &&
3164
+ existing.conditionType === usage.conditionType &&
3165
+ existing.isNegated === usage.isNegated);
3166
+ if (!exists) {
3167
+ this.rawChildBoundaryGatingConditions[childName].push(usage);
3168
+ }
3169
+ }
3170
+ }
3171
+ }
3172
+ /**
3173
+ * Get enriched child boundary gating conditions with source tracing.
3174
+ * Similar to getEnrichedConditionalUsages but for gating conditions.
3175
+ */
3176
+ getEnrichedChildBoundaryGatingConditions() {
3177
+ const enriched = {};
3178
+ const rootScopeName = this.scopeTreeManager.getTree().name;
3179
+ for (const [childName, usages] of Object.entries(this.rawChildBoundaryGatingConditions)) {
3180
+ enriched[childName] = usages.map((usage) => {
3181
+ // Try to trace this path back to a data source
3182
+ const explanation = this.explainPath(rootScopeName, usage.path);
3183
+ let sourceDataPath;
3184
+ if (explanation.source) {
3185
+ sourceDataPath = `${explanation.source.scope}.${explanation.source.path}`;
3186
+ }
3187
+ return {
3188
+ ...usage,
3189
+ sourceDataPath,
3190
+ };
3191
+ });
3192
+ }
3193
+ return enriched;
3194
+ }
2436
3195
  /**
2437
3196
  * Get enriched conditional usages with source tracing.
2438
3197
  * Uses explainPath to trace each local variable back to its data source.
3198
+ * Preserves all fields from the raw conditional usages including derivedFrom.
2439
3199
  */
2440
3200
  getEnrichedConditionalUsages() {
2441
3201
  const enriched = {};
@@ -2456,69 +3216,425 @@ export class ScopeDataStructure {
2456
3216
  }
2457
3217
  return enriched;
2458
3218
  }
3219
+ /**
3220
+ * Add JSX rendering usages from AST analysis.
3221
+ * These track arrays rendered via .map() and strings interpolated in JSX.
3222
+ */
3223
+ addJsxRenderingUsages(usages) {
3224
+ // Add usages, avoiding duplicates based on path and renderingType
3225
+ for (const usage of usages) {
3226
+ const exists = this.rawJsxRenderingUsages.some((existing) => existing.path === usage.path &&
3227
+ existing.renderingType === usage.renderingType);
3228
+ if (!exists) {
3229
+ this.rawJsxRenderingUsages.push(usage);
3230
+ }
3231
+ }
3232
+ }
3233
+ /**
3234
+ * Get JSX rendering usages collected during analysis.
3235
+ */
3236
+ getJsxRenderingUsages() {
3237
+ return this.rawJsxRenderingUsages;
3238
+ }
2459
3239
  toSerializable() {
2460
- // Helper to convert ScopeVariable to SerializableScopeVariable
3240
+ // Helper to clean cyScope and cyDuplicateKey from a string for output
3241
+ const cleanCyScope = (str) => this.replaceCyScopeInString(str).replace(/::cyDuplicateKey\d+::/g, '');
3242
+ // Helper to convert ScopeVariable to SerializableScopeVariable (with cyScope cleaned)
2461
3243
  const toSerializableVariable = (vars) => vars.map((v) => ({
2462
- scopeNodeName: v.scopeNodeName,
2463
- schemaPath: v.schemaPath,
3244
+ scopeNodeName: cleanCyScope(v.scopeNodeName),
3245
+ schemaPath: cleanCyScope(v.schemaPath),
2464
3246
  }));
3247
+ // Helper to clean cyScope from all keys in a schema
3248
+ const cleanSchemaKeys = (schema) => {
3249
+ return Object.entries(schema).reduce((acc, [key, value]) => {
3250
+ acc[cleanCyScope(key)] = value;
3251
+ return acc;
3252
+ }, {});
3253
+ };
2465
3254
  // Helper to get function result for a given function name
2466
3255
  const getFunctionResult = (functionName) => {
2467
3256
  return {
2468
- signature: this.getFunctionSignature({ functionName }) ?? {},
2469
- signatureWithUnknowns: this.getFunctionSignature({ functionName, fillInUnknowns: true }) ??
2470
- {},
2471
- returnValue: this.getReturnValue({ functionName }) ?? {},
2472
- returnValueWithUnknowns: this.getReturnValue({ functionName, fillInUnknowns: true }) ?? {},
3257
+ signature: cleanSchemaKeys(this.getFunctionSignature({ functionName }) ?? {}),
3258
+ signatureWithUnknowns: cleanSchemaKeys(this.getFunctionSignature({ functionName, fillInUnknowns: true }) ??
3259
+ {}),
3260
+ returnValue: cleanSchemaKeys(this.getReturnValue({ functionName }) ?? {}),
3261
+ returnValueWithUnknowns: cleanSchemaKeys(this.getReturnValue({ functionName, fillInUnknowns: true }) ?? {}),
2473
3262
  usageEquivalencies: Object.entries(this.getUsageEquivalencies(functionName) ?? {}).reduce((acc, [key, vars]) => {
2474
- acc[key] = toSerializableVariable(vars);
3263
+ // Clean cyScope from the key as well as variable properties
3264
+ acc[cleanCyScope(key)] = toSerializableVariable(vars);
2475
3265
  return acc;
2476
3266
  }, {}),
2477
3267
  sourceEquivalencies: Object.entries(this.getSourceEquivalencies(functionName) ?? {}).reduce((acc, [key, vars]) => {
2478
- acc[key] = toSerializableVariable(vars);
3268
+ // Clean cyScope from the key as well as variable properties
3269
+ acc[cleanCyScope(key)] = toSerializableVariable(vars);
2479
3270
  return acc;
2480
3271
  }, {}),
2481
3272
  environmentVariables: this.getEnvironmentVariables(),
2482
3273
  };
2483
3274
  };
2484
- // Convert external function calls
2485
- const externalFunctionCalls = this.externalFunctionCalls.map((efc) => ({
2486
- name: efc.name,
2487
- callSignature: efc.callSignature,
2488
- callScope: efc.callScope,
2489
- schema: efc.schema,
2490
- equivalencies: efc.equivalencies
2491
- ? Object.entries(efc.equivalencies).reduce((acc, [key, vars]) => {
2492
- acc[key] = toSerializableVariable(vars);
2493
- return acc;
2494
- }, {})
2495
- : undefined,
2496
- allCallSignatures: efc.allCallSignatures,
2497
- receivingVariableNames: efc.receivingVariableNames,
2498
- callSignatureToVariable: efc.callSignatureToVariable,
2499
- }));
3275
+ // Convert external function calls - use getExternalFunctionCalls() which cleans cyScope
3276
+ const cleanedExternalCalls = this.getExternalFunctionCalls();
3277
+ // Get root scope schema for building per-variable return value schemas
3278
+ const rootScopeName = this.scopeTreeManager.getRootName();
3279
+ const rootScope = this.scopeNodes[rootScopeName];
3280
+ const rootSchema = rootScope?.schema ?? {};
3281
+ const externalFunctionCalls = cleanedExternalCalls.map((efc) => {
3282
+ // Build perVariableSchemas from perCallSignatureSchemas when available.
3283
+ // This preserves distinct schemas per variable when the same function is called
3284
+ // multiple times with DIFFERENT call signatures (e.g., different type parameters).
3285
+ //
3286
+ // When field accesses happen in child scopes (like JSX expressions), the
3287
+ // rootSchema doesn't contain the detailed paths - they end up in child scope
3288
+ // schemas. Using perCallSignatureSchemas ensures we get the correct schema
3289
+ // for each call, regardless of where field accesses occur.
3290
+ let perVariableSchemas;
3291
+ // Use perCallSignatureSchemas only when:
3292
+ // 1. It exists and has distinct entries for different call signatures
3293
+ // 2. The number of distinct call signatures >= number of receiving variables
3294
+ //
3295
+ // This prevents using it when all calls have the same signature (e.g., useFetcher() x 2)
3296
+ // because in that case, perCallSignatureSchemas only has one entry.
3297
+ const numCallSignatures = efc.perCallSignatureSchemas
3298
+ ? Object.keys(efc.perCallSignatureSchemas).length
3299
+ : 0;
3300
+ const numReceivingVars = efc.receivingVariableNames?.length ?? 0;
3301
+ const hasDistinctSchemas = numCallSignatures >= numReceivingVars && numCallSignatures > 1;
3302
+ // CASE 1: Multiple call signatures with distinct schemas - use indexed variable names
3303
+ if (hasDistinctSchemas &&
3304
+ efc.perCallSignatureSchemas &&
3305
+ efc.callSignatureToVariable) {
3306
+ perVariableSchemas = {};
3307
+ // Build a reverse map: variable -> array of call signatures (in order)
3308
+ // This handles the case where the same variable name is reused for different calls
3309
+ const varToCallSigs = {};
3310
+ for (const [callSig, varName] of Object.entries(efc.callSignatureToVariable)) {
3311
+ if (!varToCallSigs[varName]) {
3312
+ varToCallSigs[varName] = [];
3313
+ }
3314
+ varToCallSigs[varName].push(callSig);
3315
+ }
3316
+ // Track how many times each variable name has been seen
3317
+ const varNameCounts = {};
3318
+ // For each receiving variable, get its original schema from perCallSignatureSchemas
3319
+ for (const varName of efc.receivingVariableNames ?? []) {
3320
+ const occurrence = varNameCounts[varName] ?? 0;
3321
+ varNameCounts[varName] = occurrence + 1;
3322
+ const callSigs = varToCallSigs[varName];
3323
+ // Use the nth call signature for the nth occurrence of this variable
3324
+ const callSig = callSigs?.[occurrence];
3325
+ if (callSig && efc.perCallSignatureSchemas[callSig]) {
3326
+ // Use indexed key if this variable name is reused (e.g., fetcher, fetcher[1])
3327
+ const key = occurrence === 0 ? varName : `${varName}[${occurrence}]`;
3328
+ // Clone the schema to avoid shared references
3329
+ perVariableSchemas[key] = {
3330
+ ...efc.perCallSignatureSchemas[callSig],
3331
+ };
3332
+ }
3333
+ }
3334
+ // Only include if we have entries for ALL receiving variables
3335
+ if (Object.keys(perVariableSchemas).length < numReceivingVars) {
3336
+ // Not all variables have schemas - fall back to rootSchema extraction
3337
+ perVariableSchemas = undefined;
3338
+ }
3339
+ else {
3340
+ // Also check that at least one schema is non-empty
3341
+ // Bug fix: perCallSignatureSchemas may have entries but with empty schemas {}
3342
+ // In this case, we should fall through to Fallback which uses rootSchema
3343
+ const hasNonEmptySchema = Object.values(perVariableSchemas).some((schema) => Object.keys(schema).length > 0);
3344
+ if (!hasNonEmptySchema) {
3345
+ perVariableSchemas = undefined;
3346
+ }
3347
+ }
3348
+ }
3349
+ // CASE 2: Single call signature with single variable - use perCallSignatureSchemas directly
3350
+ // This handles parameterized calls like useFetcher<ConfigData>() where each is a separate efc entry
3351
+ if (!perVariableSchemas &&
3352
+ efc.perCallSignatureSchemas &&
3353
+ numCallSignatures === 1 &&
3354
+ numReceivingVars === 1) {
3355
+ const varName = efc.receivingVariableNames[0];
3356
+ const callSig = Object.keys(efc.perCallSignatureSchemas)[0];
3357
+ const schema = efc.perCallSignatureSchemas[callSig];
3358
+ if (schema && Object.keys(schema).length > 0) {
3359
+ perVariableSchemas = { [varName]: { ...schema } };
3360
+ }
3361
+ }
3362
+ // CASE 3: Extract from efc.schema when perCallSignatureSchemas is missing or empty
3363
+ // This handles two scenarios:
3364
+ // 1. Parameterized calls that create SEPARATE efc entries (no perCallSignatureSchemas)
3365
+ // 2. Destructuring where perCallSignatureSchemas exists but has EMPTY schemas
3366
+ //
3367
+ // When useFetcher<ConfigData>() and useFetcher<SettingsData>() are called, they create separate
3368
+ // efc entries because getFunctionCallRoot preserves type parameters. Each entry has its own
3369
+ // `schema` field, but due to variable reassignment, the schema may be contaminated with paths
3370
+ // from other calls (the tracer attributes field accesses to ALL equivalencies).
3371
+ //
3372
+ // Solution: Filter efc.schema to only include paths that match THIS entry's call signature.
3373
+ // The schema paths include the full call signature prefix, so we can filter by it.
3374
+ //
3375
+ // Example: ConfigData entry has paths like:
3376
+ // "useFetcher<{ data: ConfigData | null }>().functionCallReturnValue.data.data.theme"
3377
+ // But also (contaminated):
3378
+ // "useFetcher<{ data: ConfigData | null }>().functionCallReturnValue.data.data.notifications"
3379
+ //
3380
+ // We filter to only keep paths that should belong to THIS call by checking if the
3381
+ // receiving variable's equivalency points to this call's return value.
3382
+ //
3383
+ // BUG FIX: The old condition `!efc.perCallSignatureSchemas` was FALSE when the object
3384
+ // existed (even with empty schemas), causing this case to be skipped. We now also check
3385
+ // if all schemas in perCallSignatureSchemas are empty.
3386
+ const hasNonEmptyPerCallSignatureSchemas = efc.perCallSignatureSchemas &&
3387
+ Object.values(efc.perCallSignatureSchemas).some((schema) => Object.keys(schema).length > 0);
3388
+ // Build the call signature prefix that paths should start with
3389
+ const callSigPrefix = `${efc.callSignature}.functionCallReturnValue`;
3390
+ // Check if efc.schema has variable-specific paths (indicating destructuring).
3391
+ // Destructuring: const { entities, gitStatus } = useLoaderData()
3392
+ // - efc.schema has paths like: useLoaderData().functionCallReturnValue.entities...
3393
+ // Multiple calls: const x = useFetcher(); const y = useFetcher();
3394
+ // - efc.schema has paths like: useFetcher().functionCallReturnValue.data...
3395
+ // CASE 3 should only run for destructuring (variable-specific paths exist).
3396
+ const hasVariableSpecificPaths = (efc.receivingVariableNames ?? []).some((varName) => Object.keys(efc.schema).some((path) => path.startsWith(`${callSigPrefix}.${varName}`)));
3397
+ if (!perVariableSchemas &&
3398
+ !hasNonEmptyPerCallSignatureSchemas &&
3399
+ numReceivingVars >= 1 &&
3400
+ hasVariableSpecificPaths) {
3401
+ // Filter efc.schema to only include paths matching this call signature
3402
+ const filteredSchema = {};
3403
+ for (const [path, type] of Object.entries(efc.schema)) {
3404
+ if (path.startsWith(callSigPrefix) || path === efc.callSignature) {
3405
+ filteredSchema[path] = type;
3406
+ }
3407
+ }
3408
+ // Build perVariableSchemas from the filtered schema
3409
+ // For destructuring, filter paths by variable name
3410
+ if (Object.keys(filteredSchema).length > 0) {
3411
+ perVariableSchemas = {};
3412
+ for (const varName of efc.receivingVariableNames ?? []) {
3413
+ // For destructuring, extract only paths specific to this variable
3414
+ const varSpecificPrefix = `${callSigPrefix}.${varName}`;
3415
+ const varSchema = {};
3416
+ for (const [path, type] of Object.entries(filteredSchema)) {
3417
+ if (path.startsWith(varSpecificPrefix)) {
3418
+ // Transform: useLoaderData().functionCallReturnValue.entities.sha
3419
+ // -> functionCallReturnValue.entities.sha (keep the variable name)
3420
+ const suffix = path.slice(callSigPrefix.length);
3421
+ const returnValuePath = `functionCallReturnValue${suffix}`;
3422
+ varSchema[returnValuePath] = type;
3423
+ }
3424
+ else if (path === efc.callSignature) {
3425
+ // Include the function call type itself
3426
+ varSchema[path] = type;
3427
+ }
3428
+ }
3429
+ if (Object.keys(varSchema).length > 0) {
3430
+ perVariableSchemas[varName] = varSchema;
3431
+ }
3432
+ }
3433
+ // Only include if we have entries
3434
+ if (Object.keys(perVariableSchemas).length === 0) {
3435
+ perVariableSchemas = undefined;
3436
+ }
3437
+ }
3438
+ }
3439
+ // Fallback: extract from root scope schema when perCallSignatureSchemas is not available
3440
+ // or doesn't have distinct entries for each variable.
3441
+ // This works when field accesses are in the root scope.
3442
+ if (!perVariableSchemas &&
3443
+ efc.receivingVariableNames &&
3444
+ efc.receivingVariableNames.length > 0) {
3445
+ perVariableSchemas = {};
3446
+ for (const varName of efc.receivingVariableNames) {
3447
+ const varSchema = {};
3448
+ for (const [path, type] of Object.entries(rootSchema)) {
3449
+ // Check if path starts with this variable name
3450
+ if (path === varName ||
3451
+ path.startsWith(varName + '.') ||
3452
+ path.startsWith(varName + '[')) {
3453
+ // Transform to functionCallReturnValue format
3454
+ // e.g., userFetcher.data.id -> functionCallReturnValue.data.id
3455
+ const suffix = path.slice(varName.length);
3456
+ const returnValuePath = `functionCallReturnValue${suffix}`;
3457
+ varSchema[returnValuePath] = type;
3458
+ }
3459
+ }
3460
+ if (Object.keys(varSchema).length > 0) {
3461
+ // Clean the variable name when using as key in output
3462
+ perVariableSchemas[cleanCyScope(varName)] = varSchema;
3463
+ }
3464
+ }
3465
+ // Only include if we have any entries
3466
+ if (Object.keys(perVariableSchemas).length === 0) {
3467
+ perVariableSchemas = undefined;
3468
+ }
3469
+ }
3470
+ return {
3471
+ name: efc.name,
3472
+ callSignature: efc.callSignature,
3473
+ callScope: efc.callScope,
3474
+ schema: efc.schema,
3475
+ equivalencies: efc.equivalencies
3476
+ ? Object.entries(efc.equivalencies).reduce((acc, [key, vars]) => {
3477
+ // Clean cyScope from the key as well as variable properties
3478
+ acc[cleanCyScope(key)] = toSerializableVariable(vars);
3479
+ return acc;
3480
+ }, {})
3481
+ : undefined,
3482
+ allCallSignatures: efc.allCallSignatures,
3483
+ receivingVariableNames: efc.receivingVariableNames?.map(cleanCyScope),
3484
+ callSignatureToVariable: efc.callSignatureToVariable
3485
+ ? Object.fromEntries(Object.entries(efc.callSignatureToVariable).map(([k, v]) => [
3486
+ k,
3487
+ cleanCyScope(v),
3488
+ ]))
3489
+ : undefined,
3490
+ perVariableSchemas,
3491
+ };
3492
+ });
3493
+ // POST-PROCESSING: Deduplicate schemas across parameterized calls to same base function
3494
+ // When useFetcher<ConfigData>() and useFetcher<SettingsData>() are called, they create
3495
+ // separate entries. Due to variable reassignment, BOTH entries may have ALL fields.
3496
+ // We deduplicate by assigning each field to ONLY ONE entry based on order of appearance.
3497
+ //
3498
+ // Strategy: Fields that appear first in order belong to the first entry,
3499
+ // fields that appear later belong to later entries (split evenly).
3500
+ const deduplicateParameterizedEntries = (entries) => {
3501
+ // Group entries by base function name (without type parameters)
3502
+ const groups = new Map();
3503
+ for (const entry of entries) {
3504
+ // Extract base function name by stripping type parameters
3505
+ // e.g., "useFetcher<{ data: ConfigData | null }>" -> "useFetcher"
3506
+ const baseName = entry.name.replace(/<.*>$/, '');
3507
+ const group = groups.get(baseName) || [];
3508
+ group.push(entry);
3509
+ groups.set(baseName, group);
3510
+ }
3511
+ // Process groups with multiple parameterized entries
3512
+ for (const [, group] of groups) {
3513
+ if (group.length <= 1)
3514
+ continue;
3515
+ // Check if these are parameterized calls (have type parameters in name)
3516
+ const hasTypeParams = group.every((e) => e.name.includes('<'));
3517
+ if (!hasTypeParams)
3518
+ continue;
3519
+ // Collect ALL unique field suffixes across all entries (in order of first appearance)
3520
+ // Field suffix is the path after functionCallReturnValue, e.g., ".data.data.theme"
3521
+ const allFieldSuffixes = [];
3522
+ for (const entry of group) {
3523
+ if (!entry.perVariableSchemas)
3524
+ continue;
3525
+ for (const varSchema of Object.values(entry.perVariableSchemas)) {
3526
+ for (const path of Object.keys(varSchema)) {
3527
+ // Skip the base "functionCallReturnValue" entry
3528
+ if (path === 'functionCallReturnValue')
3529
+ continue;
3530
+ // Extract field suffix
3531
+ const match = path.match(/functionCallReturnValue(.+)/);
3532
+ if (!match)
3533
+ continue;
3534
+ const fieldSuffix = match[1];
3535
+ if (!allFieldSuffixes.includes(fieldSuffix)) {
3536
+ allFieldSuffixes.push(fieldSuffix);
3537
+ }
3538
+ }
3539
+ }
3540
+ }
3541
+ // Assign fields to entries: split evenly based on order
3542
+ // First N/2 fields go to first entry, remaining go to second entry
3543
+ const fieldToEntryMap = new Map();
3544
+ const fieldsPerEntry = Math.ceil(allFieldSuffixes.length / group.length);
3545
+ for (let i = 0; i < allFieldSuffixes.length; i++) {
3546
+ const fieldSuffix = allFieldSuffixes[i];
3547
+ const entryIdx = Math.min(Math.floor(i / fieldsPerEntry), group.length - 1);
3548
+ fieldToEntryMap.set(fieldSuffix, entryIdx);
3549
+ }
3550
+ // Filter each entry's perVariableSchemas to only include its assigned fields
3551
+ for (let i = 0; i < group.length; i++) {
3552
+ const entry = group[i];
3553
+ if (!entry.perVariableSchemas)
3554
+ continue;
3555
+ const filteredPerVarSchemas = {};
3556
+ for (const [varName, varSchema] of Object.entries(entry.perVariableSchemas)) {
3557
+ const filteredVarSchema = {};
3558
+ for (const [path, type] of Object.entries(varSchema)) {
3559
+ // Always keep the base functionCallReturnValue
3560
+ if (path === 'functionCallReturnValue') {
3561
+ filteredVarSchema[path] = type;
3562
+ continue;
3563
+ }
3564
+ // Extract field suffix
3565
+ const match = path.match(/functionCallReturnValue(.+)/);
3566
+ if (!match) {
3567
+ // Keep non-field paths
3568
+ filteredVarSchema[path] = type;
3569
+ continue;
3570
+ }
3571
+ const fieldSuffix = match[1];
3572
+ // Only include if this entry owns this field
3573
+ if (fieldToEntryMap.get(fieldSuffix) === i) {
3574
+ filteredVarSchema[path] = type;
3575
+ }
3576
+ }
3577
+ if (Object.keys(filteredVarSchema).length > 0) {
3578
+ filteredPerVarSchemas[varName] = filteredVarSchema;
3579
+ }
3580
+ }
3581
+ entry.perVariableSchemas =
3582
+ Object.keys(filteredPerVarSchemas).length > 0
3583
+ ? filteredPerVarSchemas
3584
+ : undefined;
3585
+ }
3586
+ }
3587
+ return entries;
3588
+ };
3589
+ // Apply deduplication
3590
+ const deduplicatedExternalFunctionCalls = deduplicateParameterizedEntries(externalFunctionCalls);
3591
+ // IMPORTANT: Get equivalent signature variables BEFORE calling getFunctionResult
3592
+ // because getFunctionResult calls validateSchema which may remove equivalencies
3593
+ // during the finalize step (e.g., cleanNonObjectFunctions removes method call
3594
+ // equivalencies like `segments -> splat.split('/').functionCallReturnValue`).
3595
+ // Fix 33: Move this call before any schema validation to preserve method call chains.
3596
+ const equivalentSignatureVariables = this.getEquivalentSignatureVariables();
2500
3597
  // Get root function result
2501
3598
  const rootFunction = getFunctionResult();
2502
- // Get results for each external function
3599
+ // Get results for each external function (use cleaned calls for consistency)
2503
3600
  const functionResults = {};
2504
- for (const efc of this.externalFunctionCalls) {
3601
+ for (const efc of cleanedExternalCalls) {
2505
3602
  functionResults[efc.name] = getFunctionResult(efc.name);
2506
3603
  }
2507
- // Get equivalent signature variables
2508
- const equivalentSignatureVariables = this.getEquivalentSignatureVariables();
2509
3604
  const environmentVariables = this.getEnvironmentVariables();
2510
3605
  // Get enriched conditional usages with source tracing
2511
3606
  const enrichedConditionalUsages = this.getEnrichedConditionalUsages();
2512
3607
  const conditionalUsages = Object.keys(enrichedConditionalUsages).length > 0
2513
3608
  ? enrichedConditionalUsages
2514
3609
  : undefined;
3610
+ // Get conditional effects (setter calls inside conditionals)
3611
+ const conditionalEffects = this.rawConditionalEffects.length > 0
3612
+ ? this.rawConditionalEffects
3613
+ : undefined;
3614
+ // Get compound conditionals (grouped conditions that must all be true)
3615
+ const compoundConditionals = this.rawCompoundConditionals.length > 0
3616
+ ? this.rawCompoundConditionals
3617
+ : undefined;
3618
+ // Get child boundary gating conditions
3619
+ const enrichedGatingConditions = this.getEnrichedChildBoundaryGatingConditions();
3620
+ const childBoundaryGatingConditions = Object.keys(enrichedGatingConditions).length > 0
3621
+ ? enrichedGatingConditions
3622
+ : undefined;
3623
+ // Get JSX rendering usages (arrays via .map(), strings via interpolation)
3624
+ const jsxRenderingUsages = this.rawJsxRenderingUsages.length > 0
3625
+ ? this.rawJsxRenderingUsages
3626
+ : undefined;
2515
3627
  return {
2516
- externalFunctionCalls,
3628
+ externalFunctionCalls: deduplicatedExternalFunctionCalls,
2517
3629
  rootFunction,
2518
3630
  functionResults,
2519
3631
  equivalentSignatureVariables,
2520
3632
  environmentVariables,
2521
3633
  conditionalUsages,
3634
+ conditionalEffects,
3635
+ compoundConditionals,
3636
+ childBoundaryGatingConditions,
3637
+ jsxRenderingUsages,
2522
3638
  };
2523
3639
  }
2524
3640
  // ═══════════════════════════════════════════════════════════════════════════