@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
@@ -0,0 +1,1440 @@
1
+ /**
2
+ * Generates execution flows from conditional usages using pure static analysis.
3
+ *
4
+ * This replaces LLM-driven flow generation with deterministic flow generation
5
+ * based on conditionalUsages extracted from the AST. Only paths that resolve
6
+ * to controllable data sources (exist in attributesMap) produce flows.
7
+ *
8
+ * Flow generation rules:
9
+ * - truthiness conditions → truthy flow + falsy flow
10
+ * - comparison conditions → one flow per compared value
11
+ * - switch conditions → one flow per case value
12
+ * - compound conditionals → one flow with all conditions (only if ALL paths controllable)
13
+ */
14
+ import resolvePathToControllable from "./resolvePathToControllable.js";
15
+ import cleanPathOfNonTransformingFunctions from "./dataStructure/helpers/cleanPathOfNonTransformingFunctions.js";
16
+ /**
17
+ * Recursively expands a derived variable to its leaf data sources.
18
+ *
19
+ * For OR expressions like `isAnalyzing = a || b || c`:
20
+ * - Returns all source paths [a, b, c] so they can all be set appropriately
21
+ *
22
+ * For nested derivations like `isAnalyzing = isInCurrentRun || isInQueue`:
23
+ * - Where `isInCurrentRun` is derived from `currentRun.entityShas.includes(x)`
24
+ * - Returns the final data sources: [currentRun.entityShas, queueState.jobs]
25
+ *
26
+ * @param path The variable path to expand
27
+ * @param conditionalUsages All conditional usages (to look up derivedFrom info)
28
+ * @param attributesMap Map of controllable paths
29
+ * @param equivalentSignatureVariables Variable-to-path mappings
30
+ * @param fullToShortPathMap Full-to-short path mappings
31
+ * @param visited Set of already-visited paths (prevents infinite recursion)
32
+ * @param derivedVariables Optional map of all derived variables (for intermediate tracing)
33
+ * @returns Array of resolved source paths that are controllable
34
+ */
35
+ function expandDerivedVariableToSources(path, conditionalUsages, attributesMap, equivalentSignatureVariables, fullToShortPathMap, visited = new Set(), derivedVariables) {
36
+ // Prevent infinite recursion
37
+ if (visited.has(path)) {
38
+ return [];
39
+ }
40
+ visited.add(path);
41
+ // First, check if this path is directly controllable
42
+ const directResolution = resolvePathToControllable(path, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
43
+ if (directResolution.isControllable && directResolution.resolvedPath) {
44
+ return [{ path: directResolution.resolvedPath }];
45
+ }
46
+ // Look up derivedFrom info for this path
47
+ // First check conditionalUsages, then fall back to derivedVariables
48
+ const usage = conditionalUsages[path]?.[0];
49
+ let derivedFrom = usage?.derivedFrom;
50
+ // CRITICAL: If not found in conditionalUsages, check derivedVariables
51
+ // This handles intermediate derived variables like `isInCurrentRun` that aren't
52
+ // directly used in conditionals but ARE derived from data sources
53
+ if (!derivedFrom && derivedVariables?.[path]) {
54
+ derivedFrom = derivedVariables[path];
55
+ }
56
+ if (!derivedFrom) {
57
+ return [];
58
+ }
59
+ const { operation, sourcePath, sourcePaths } = derivedFrom;
60
+ // For OR/AND operations, recursively expand all source paths
61
+ if ((operation === 'or' || operation === 'and') && sourcePaths) {
62
+ const allSources = [];
63
+ for (const sp of sourcePaths) {
64
+ const expanded = expandDerivedVariableToSources(sp, conditionalUsages, attributesMap, equivalentSignatureVariables, fullToShortPathMap, visited, derivedVariables);
65
+ // Add all expanded sources
66
+ for (const source of expanded) {
67
+ // Avoid duplicates
68
+ if (!allSources.some((s) => s.path === source.path)) {
69
+ allSources.push(source);
70
+ }
71
+ }
72
+ }
73
+ return allSources;
74
+ }
75
+ // For single-source operations (arrayIncludes, arraySome, notNull, etc.)
76
+ if (sourcePath) {
77
+ // Try to resolve the source path directly
78
+ const sourceResolution = resolvePathToControllable(sourcePath, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
79
+ if (sourceResolution.isControllable && sourceResolution.resolvedPath) {
80
+ return [{ path: sourceResolution.resolvedPath, operation }];
81
+ }
82
+ // If not directly resolvable, recursively expand
83
+ return expandDerivedVariableToSources(sourcePath, conditionalUsages, attributesMap, equivalentSignatureVariables, fullToShortPathMap, visited, derivedVariables);
84
+ }
85
+ return [];
86
+ }
87
+ /**
88
+ * Clean up sourceDataPath by removing redundant scope prefixes.
89
+ *
90
+ * This function ONLY handles the specific pattern where a scope name is
91
+ * duplicated before the hook call:
92
+ *
93
+ * Example:
94
+ * "useLoaderData<LoaderData>.useLoaderData<LoaderData>().functionCallReturnValue.entity.sha"
95
+ * → "useLoaderData<LoaderData>().functionCallReturnValue.entity.sha"
96
+ *
97
+ * For paths with multiple function calls (like fetch().json()), or paths
98
+ * that don't match the expected pattern, returns null to indicate the
99
+ * fallback resolution should be used.
100
+ */
101
+ function cleanSourceDataPath(sourceDataPath) {
102
+ // Count function call patterns - both empty () and with content (...)
103
+ // We detect multiple function calls by counting:
104
+ // 1. Empty () patterns
105
+ // 2. Patterns like functionName(...) - closing paren followed by dot or end
106
+ const emptyFnCalls = (sourceDataPath.match(/\(\)/g) || []).length;
107
+ const fnCallReturnValues = (sourceDataPath.match(/\.functionCallReturnValue/g) || []).length;
108
+ // If there are multiple functionCallReturnValue occurrences, this is a chained call
109
+ // (e.g., fetch(...).functionCallReturnValue.json().functionCallReturnValue.data)
110
+ if (fnCallReturnValues > 1 || emptyFnCalls !== 1) {
111
+ // Multiple function calls - return null to use fallback resolution
112
+ return null;
113
+ }
114
+ // Find the "()" which marks the function call
115
+ const fnCallIndex = sourceDataPath.indexOf('()');
116
+ // Find where the function name starts (go back to find the start of this segment)
117
+ const beforeFnCall = sourceDataPath.slice(0, fnCallIndex);
118
+ const lastDotBeforeFn = beforeFnCall.lastIndexOf('.');
119
+ if (lastDotBeforeFn === -1) {
120
+ return sourceDataPath;
121
+ }
122
+ // Extract the scope prefix and the actual path
123
+ const scopePrefix = sourceDataPath.slice(0, lastDotBeforeFn);
124
+ const actualPath = sourceDataPath.slice(lastDotBeforeFn + 1);
125
+ // Verify this is actually a redundant scope prefix pattern
126
+ // The actualPath should start with something that matches the scopePrefix
127
+ // e.g., scopePrefix="useLoaderData<LoaderData>" and actualPath starts with "useLoaderData<LoaderData>()..."
128
+ if (!actualPath.startsWith(scopePrefix.split('.').pop() || '')) {
129
+ // Not a redundant prefix pattern - return the original path
130
+ return sourceDataPath;
131
+ }
132
+ return actualPath;
133
+ }
134
+ /**
135
+ * Strip .length suffix from a path if present.
136
+ *
137
+ * When we have a path like "items.length", the controllable attribute is "items"
138
+ * (the array), not "items.length". The length is derived from the array contents.
139
+ *
140
+ * This ensures that execution flows reference the actual controllable attribute
141
+ * rather than the derived .length property.
142
+ */
143
+ function stripLengthSuffix(path) {
144
+ if (path.endsWith('.length')) {
145
+ return path.slice(0, -7); // Remove ".length" (7 characters)
146
+ }
147
+ return path;
148
+ }
149
+ /**
150
+ * Extract the controllable base path from a path that may contain method calls.
151
+ *
152
+ * This handles complex expressions like:
153
+ * - `scenarios.filter((s) => s.active).length` → `scenarios`
154
+ * - `users.some((u) => u.role === 'admin')` → `users`
155
+ * - `items.map(x => x.name).join(', ')` → `items`
156
+ *
157
+ * The controllable base is the path that can be mocked - we can control
158
+ * what `scenarios` contains, but we can't control what `.filter()` returns.
159
+ *
160
+ * @param path - The path that may contain method calls
161
+ * @returns The controllable base path with method calls stripped
162
+ */
163
+ function extractControllableBase(path) {
164
+ // First strip .length suffix if present
165
+ const pathWithoutLength = stripLengthSuffix(path);
166
+ // Use cleanPathOfNonTransformingFunctions to strip method calls like .filter(), .some()
167
+ const cleanedPath = cleanPathOfNonTransformingFunctions(pathWithoutLength);
168
+ // If the cleaned path is different, return it
169
+ if (cleanedPath !== pathWithoutLength) {
170
+ return cleanedPath;
171
+ }
172
+ // Otherwise, return the path with just .length stripped
173
+ return pathWithoutLength;
174
+ }
175
+ /**
176
+ * Find a path in attributesMap, using fullToShortPathMap to verify the path is controllable.
177
+ *
178
+ * IMPORTANT: Returns the FULL path (preserving data source context) when possible.
179
+ * This ensures execution flows can be traced back to specific data sources,
180
+ * which is critical when multiple data sources have the same property names
181
+ * (e.g., multiple useFetcher hooks all having 'state' and 'data').
182
+ *
183
+ * The attributesMap contains short relative paths (e.g., "entity.sha")
184
+ * The sourceDataPath contains full paths (e.g., "useLoaderData<LoaderData>().functionCallReturnValue.entity.sha")
185
+ * The fullToShortPathMap maps full paths to short paths
186
+ */
187
+ function findInAttributesMapForPath(path, attributesMap, fullToShortPathMap) {
188
+ // Direct match in attributesMap (already a short path)
189
+ if (path in attributesMap) {
190
+ return path;
191
+ }
192
+ // Try looking up the path in fullToShortPathMap to verify it's controllable
193
+ // IMPORTANT: Return the FULL path, not the short path, to preserve data source context
194
+ if (path in fullToShortPathMap) {
195
+ const shortPath = fullToShortPathMap[path];
196
+ if (shortPath in attributesMap) {
197
+ return path; // Return FULL path to preserve data source context
198
+ }
199
+ }
200
+ // Normalized match (array indices [N] → [])
201
+ const normalizedPath = path.replace(/\[\d+\]/g, '[]');
202
+ if (normalizedPath !== path) {
203
+ if (normalizedPath in attributesMap) {
204
+ return normalizedPath;
205
+ }
206
+ if (normalizedPath in fullToShortPathMap) {
207
+ const shortPath = fullToShortPathMap[normalizedPath];
208
+ if (shortPath in attributesMap) {
209
+ return normalizedPath; // Return normalized FULL path
210
+ }
211
+ }
212
+ }
213
+ // Try prefix matching for child paths
214
+ // e.g., path is "entity.sha.something" and attributesMap has "entity.sha"
215
+ // OR path is a full path like "useLoaderData<...>().functionCallReturnValue.entity.sha"
216
+ // and we need to find matching short path prefix
217
+ for (const attrPath of Object.keys(attributesMap)) {
218
+ if (path.startsWith(attrPath + '.') || path.startsWith(attrPath + '[')) {
219
+ // The path is a child of a known attribute path
220
+ return path;
221
+ }
222
+ }
223
+ // Try suffix matching: if the path ends with ".X.Y.Z" and attributesMap has "X.Y.Z"
224
+ // Return the FULL input path to preserve data source context
225
+ for (const attrPath of Object.keys(attributesMap)) {
226
+ if (path.endsWith('.' + attrPath) ||
227
+ path.endsWith('.' + attrPath.replace(/\[\d+\]/g, '[]'))) {
228
+ return path; // Return FULL path, not short attrPath
229
+ }
230
+ }
231
+ return null;
232
+ }
233
+ /**
234
+ * Generate a human-readable name from a path.
235
+ * Extracts the last meaningful part of the path.
236
+ *
237
+ * Examples:
238
+ * - "useFetcher<...>().functionCallReturnValue.state" → "state"
239
+ * - "useLoaderData<...>().functionCallReturnValue.user.isActive" → "isActive"
240
+ */
241
+ function generateNameFromPath(path) {
242
+ // Remove function call markers and get the last meaningful segment
243
+ const cleanPath = path
244
+ .replace(/\(\)/g, '')
245
+ .replace(/\.functionCallReturnValue/g, '');
246
+ const parts = cleanPath.split('.');
247
+ const lastPart = parts[parts.length - 1];
248
+ // Convert camelCase to Title Case with spaces
249
+ return lastPart
250
+ .replace(/([A-Z])/g, ' $1')
251
+ .replace(/^./, (str) => str.toUpperCase())
252
+ .trim();
253
+ }
254
+ /**
255
+ * Generate a flow ID from path and value.
256
+ * Creates a unique, URL-safe identifier.
257
+ */
258
+ function generateFlowId(path, value) {
259
+ // Clean the path for use in ID
260
+ const cleanPath = path
261
+ .replace(/\(\)/g, '')
262
+ .replace(/\.functionCallReturnValue/g, '')
263
+ .replace(/[<>]/g, '')
264
+ .replace(/\./g, '-');
265
+ // Clean the value
266
+ const cleanValue = value
267
+ .toString()
268
+ .toLowerCase()
269
+ .replace(/[^a-z0-9]/g, '-')
270
+ .replace(/-+/g, '-')
271
+ .replace(/^-|-$/g, '');
272
+ return `${cleanPath}-${cleanValue}`.toLowerCase();
273
+ }
274
+ /**
275
+ * Infer value type from a string value.
276
+ */
277
+ function inferValueType(value) {
278
+ if (value === 'true' || value === 'false')
279
+ return 'boolean';
280
+ if (value === 'null' || value === 'undefined')
281
+ return 'null';
282
+ if (!isNaN(Number(value)) && value !== '')
283
+ return 'number';
284
+ return 'string';
285
+ }
286
+ /**
287
+ * Generate flows from a single conditional usage.
288
+ * Sets impact to 'high' if the conditional controls JSX rendering.
289
+ *
290
+ * When the usage has a `constraintExpression`, it represents a complex expression
291
+ * that can't be simply resolved (e.g., `scenarios.filter(x => x.active).length > 1`).
292
+ * In this case:
293
+ * - `attributePath` is set to the controllable base (e.g., `scenarios`)
294
+ * - `constraint` is set to the full expression for LLM reasoning
295
+ */
296
+ function generateFlowsFromUsage(usage, resolvedPath) {
297
+ const flows = [];
298
+ const baseName = generateNameFromPath(resolvedPath);
299
+ // Determine impact based on whether this conditional controls JSX rendering
300
+ // Conditionals that control visual output are high-impact
301
+ const impact = usage.controlsJsxRendering
302
+ ? 'high'
303
+ : 'medium';
304
+ // When there's a constraintExpression, use the controllable base for attributePath
305
+ // and pass through the constraint for LLM reasoning
306
+ const hasConstraint = !!usage.constraintExpression;
307
+ const attributePath = hasConstraint
308
+ ? extractControllableBase(resolvedPath)
309
+ : stripLengthSuffix(resolvedPath);
310
+ const constraint = usage.constraintExpression;
311
+ if (usage.conditionType === 'truthiness') {
312
+ // Generate both truthy and falsy flows
313
+ const isNegated = usage.isNegated ?? false;
314
+ // Truthy flow (or falsy if negated)
315
+ flows.push({
316
+ id: generateFlowId(resolvedPath, isNegated ? 'falsy' : 'truthy'),
317
+ name: `${baseName} ${isNegated ? 'False' : 'True'}`,
318
+ description: `When ${baseName.toLowerCase()} is ${isNegated ? 'falsy' : 'truthy'}`,
319
+ requiredValues: [
320
+ {
321
+ attributePath,
322
+ value: isNegated ? 'falsy' : 'truthy',
323
+ comparison: isNegated ? 'falsy' : 'truthy',
324
+ valueType: 'boolean',
325
+ constraint,
326
+ },
327
+ ],
328
+ impact,
329
+ sourceLocation: usage.sourceLocation
330
+ ? {
331
+ lineNumber: usage.sourceLocation.lineNumber,
332
+ column: usage.sourceLocation.column,
333
+ }
334
+ : undefined,
335
+ codeSnippet: usage.sourceLocation?.codeSnippet,
336
+ });
337
+ // Falsy flow (or truthy if negated)
338
+ flows.push({
339
+ id: generateFlowId(resolvedPath, isNegated ? 'truthy' : 'falsy'),
340
+ name: `${baseName} ${isNegated ? 'True' : 'False'}`,
341
+ description: `When ${baseName.toLowerCase()} is ${isNegated ? 'truthy' : 'falsy'}`,
342
+ requiredValues: [
343
+ {
344
+ attributePath,
345
+ value: isNegated ? 'truthy' : 'falsy',
346
+ comparison: isNegated ? 'truthy' : 'falsy',
347
+ valueType: 'boolean',
348
+ constraint,
349
+ },
350
+ ],
351
+ impact,
352
+ sourceLocation: usage.sourceLocation
353
+ ? {
354
+ lineNumber: usage.sourceLocation.lineNumber,
355
+ column: usage.sourceLocation.column,
356
+ }
357
+ : undefined,
358
+ codeSnippet: usage.sourceLocation?.codeSnippet,
359
+ });
360
+ }
361
+ else if (usage.conditionType === 'comparison' ||
362
+ usage.conditionType === 'switch') {
363
+ // Generate one flow per compared value
364
+ const values = usage.comparedValues ?? [];
365
+ for (const value of values) {
366
+ flows.push({
367
+ id: generateFlowId(resolvedPath, value),
368
+ name: `${baseName}: ${value}`,
369
+ description: `When ${baseName.toLowerCase()} equals "${value}"`,
370
+ requiredValues: [
371
+ {
372
+ attributePath,
373
+ value: value,
374
+ comparison: 'equals',
375
+ valueType: inferValueType(value),
376
+ constraint,
377
+ },
378
+ ],
379
+ impact,
380
+ sourceLocation: usage.sourceLocation
381
+ ? {
382
+ lineNumber: usage.sourceLocation.lineNumber,
383
+ column: usage.sourceLocation.column,
384
+ }
385
+ : undefined,
386
+ codeSnippet: usage.sourceLocation?.codeSnippet,
387
+ });
388
+ }
389
+ }
390
+ return flows;
391
+ }
392
+ /**
393
+ * Generate a flow from a compound conditional (all conditions must be satisfied).
394
+ * Sets impact to 'high' if the compound conditional controls JSX rendering.
395
+ */
396
+ function generateFlowFromCompound(compound, resolvedPaths) {
397
+ // Determine impact based on whether this compound conditional controls JSX rendering
398
+ const impact = compound.controlsJsxRendering
399
+ ? 'high'
400
+ : 'medium';
401
+ const requiredValues = [];
402
+ for (const condition of compound.conditions) {
403
+ const resolvedPath = resolvedPaths.get(condition.path);
404
+ if (!resolvedPath) {
405
+ // This shouldn't happen if we pre-filtered, but safety check
406
+ return null;
407
+ }
408
+ // Determine the required value based on condition type
409
+ let value;
410
+ let comparison;
411
+ if (condition.conditionType === 'truthiness') {
412
+ // If negated (!foo), we need falsy; otherwise truthy
413
+ value = condition.isNegated ? 'falsy' : 'truthy';
414
+ comparison = condition.isNegated ? 'falsy' : 'truthy';
415
+ }
416
+ else {
417
+ // For comparison/switch, use the first compared value or required value
418
+ value =
419
+ condition.requiredValue?.toString() ??
420
+ condition.comparedValues?.[0] ??
421
+ 'truthy';
422
+ comparison = 'equals';
423
+ }
424
+ requiredValues.push({
425
+ attributePath: stripLengthSuffix(resolvedPath),
426
+ value,
427
+ comparison,
428
+ valueType: inferValueType(value),
429
+ });
430
+ }
431
+ // Generate a combined ID from all paths
432
+ const pathParts = requiredValues
433
+ .map((rv) => {
434
+ const name = generateNameFromPath(rv.attributePath);
435
+ return name.toLowerCase().replace(/\s+/g, '-');
436
+ })
437
+ .join('-and-');
438
+ return {
439
+ id: `compound-${pathParts}`,
440
+ name: requiredValues
441
+ .map((rv) => generateNameFromPath(rv.attributePath))
442
+ .join(' + '),
443
+ description: `When ${requiredValues.map((rv) => `${generateNameFromPath(rv.attributePath).toLowerCase()} is ${rv.value}`).join(' and ')}`,
444
+ requiredValues,
445
+ impact,
446
+ sourceLocation: {
447
+ lineNumber: compound.sourceLocation.lineNumber,
448
+ column: compound.sourceLocation.column,
449
+ },
450
+ codeSnippet: compound.sourceLocation.codeSnippet,
451
+ };
452
+ }
453
+ /**
454
+ * Expand a compound conditional with OR groups into multiple condition sets.
455
+ *
456
+ * For a compound like `A && (B || C)`:
457
+ * - Conditions: [{ path: 'A' }, { path: 'B', orGroupId: 'or_xxx' }, { path: 'C', orGroupId: 'or_xxx' }]
458
+ * - Returns: [[A, B], [A, C]] - two sets of conditions
459
+ *
460
+ * For multiple OR groups like `A && (B || C) && (D || E)`:
461
+ * - Returns: [[A, B, D], [A, B, E], [A, C, D], [A, C, E]]
462
+ */
463
+ function expandOrGroups(conditions) {
464
+ // Separate conditions into mandatory (no orGroupId) and OR groups
465
+ const mandatory = conditions.filter((c) => !c.orGroupId);
466
+ const orGroups = new Map();
467
+ for (const condition of conditions) {
468
+ if (condition.orGroupId) {
469
+ const group = orGroups.get(condition.orGroupId) ?? [];
470
+ group.push(condition);
471
+ orGroups.set(condition.orGroupId, group);
472
+ }
473
+ }
474
+ // If no OR groups, return the original conditions
475
+ if (orGroups.size === 0) {
476
+ return [conditions];
477
+ }
478
+ // Generate all combinations by picking one condition from each OR group
479
+ const groupArrays = Array.from(orGroups.values());
480
+ const combinations = [];
481
+ function generateCombinations(index, current) {
482
+ if (index === groupArrays.length) {
483
+ // We've picked one from each OR group - combine with mandatory conditions
484
+ combinations.push([...mandatory, ...current]);
485
+ return;
486
+ }
487
+ // Pick each option from the current OR group
488
+ for (const option of groupArrays[index]) {
489
+ generateCombinations(index + 1, [...current, option]);
490
+ }
491
+ }
492
+ generateCombinations(0, []);
493
+ return combinations;
494
+ }
495
+ /**
496
+ * Generate execution flows from conditional usages using pure static analysis.
497
+ *
498
+ * Only generates flows where all paths resolve to controllable data sources.
499
+ * This ensures we never produce flows with invalid paths like useState variables.
500
+ */
501
+ /**
502
+ * Normalize a resolved path to a canonical form for deduplication.
503
+ * Uses fullToShortPathMap to convert full paths to short paths.
504
+ * This ensures that both "hasNewerVersion" and
505
+ * "useLoaderData<LoaderData>().functionCallReturnValue.hasNewerVersion"
506
+ * normalize to the same canonical path.
507
+ */
508
+ function normalizePathForDeduplication(resolvedPath, fullToShortPathMap) {
509
+ // If the path is in fullToShortPathMap, use the short path as canonical
510
+ if (resolvedPath in fullToShortPathMap) {
511
+ return fullToShortPathMap[resolvedPath];
512
+ }
513
+ // Otherwise, the path itself is canonical
514
+ return resolvedPath;
515
+ }
516
+ /**
517
+ * Translate a child component path to a parent path using prop mappings.
518
+ *
519
+ * Given:
520
+ * - childPath: "selectedScenario.metadata.screenshotPaths[0]" (path in child's context)
521
+ * - childEquiv: { selectedScenario: "signature[0].selectedScenario" } (child's internal-to-prop mapping)
522
+ * - parentEquiv: { "ChildName().signature[0].selectedScenario": "selectedScenario" } (parent's prop assignments)
523
+ * - childName: "ChildName"
524
+ *
525
+ * Returns: "selectedScenario.metadata.screenshotPaths[0]" (path in parent's context)
526
+ *
527
+ * The translation works by:
528
+ * 1. Finding the root variable in the child path (e.g., "selectedScenario")
529
+ * 2. Looking up the child's equivalence to find the prop path (e.g., "signature[0].selectedScenario")
530
+ * 3. Building the full child prop path (e.g., "ChildName().signature[0].selectedScenario")
531
+ * 4. Looking up the parent's equivalence to find the parent path (e.g., "selectedScenario")
532
+ * 5. Replacing the root with the parent path and preserving the suffix
533
+ */
534
+ function translateChildPathToParent(childPath, childEquivalentSignatureVariables, parentEquivalentSignatureVariables, childName) {
535
+ // Extract the root variable from the child path
536
+ // e.g., "selectedScenario.metadata.screenshotPaths[0]" → "selectedScenario"
537
+ const dotIndex = childPath.indexOf('.');
538
+ const bracketIndex = childPath.indexOf('[');
539
+ let rootVar;
540
+ let suffix;
541
+ if (dotIndex === -1 && bracketIndex === -1) {
542
+ rootVar = childPath;
543
+ suffix = '';
544
+ }
545
+ else if (dotIndex === -1) {
546
+ rootVar = childPath.slice(0, bracketIndex);
547
+ suffix = childPath.slice(bracketIndex);
548
+ }
549
+ else if (bracketIndex === -1) {
550
+ rootVar = childPath.slice(0, dotIndex);
551
+ suffix = childPath.slice(dotIndex);
552
+ }
553
+ else {
554
+ const firstIndex = Math.min(dotIndex, bracketIndex);
555
+ rootVar = childPath.slice(0, firstIndex);
556
+ suffix = childPath.slice(firstIndex);
557
+ }
558
+ // Look up the child's equivalence for this root variable
559
+ // e.g., childEquiv[selectedScenario] = "signature[0].selectedScenario"
560
+ const childPropPath = childEquivalentSignatureVariables[rootVar];
561
+ if (!childPropPath) {
562
+ // No mapping found - this might be internal state, not a prop
563
+ return null;
564
+ }
565
+ // Build the full child prop path as seen from parent
566
+ // e.g., "ChildName().signature[0].selectedScenario"
567
+ const fullChildPropPath = `${childName}().${childPropPath}`;
568
+ // Look up parent's equivalence to find what value was passed to this prop
569
+ // e.g., parentEquiv["ChildName().signature[0].selectedScenario"] = "selectedScenario"
570
+ const parentValue = parentEquivalentSignatureVariables[fullChildPropPath];
571
+ if (!parentValue) {
572
+ // No parent mapping found - log ALL parent keys that contain the childName
573
+ const relevantParentKeys = Object.keys(parentEquivalentSignatureVariables).filter((k) => k.includes(childName));
574
+ return null;
575
+ }
576
+ // Build the translated path: parentValue + suffix
577
+ // e.g., "selectedScenario" + ".metadata.screenshotPaths[0]"
578
+ const result = parentValue + suffix;
579
+ return result;
580
+ }
581
+ export default function generateExecutionFlowsFromConditionals(args) {
582
+ const { conditionalUsages, compoundConditionals, attributesMap, equivalentSignatureVariables, fullToShortPathMap, childComponentData, derivedVariables, } = args;
583
+ const flows = [];
584
+ const seenFlowIds = new Set();
585
+ // Track normalized resolved paths to prevent duplicate flows
586
+ // This handles the case where we have usages for both:
587
+ // - "hasNewerVersion" (short path from destructured variable)
588
+ // - "useLoaderData<LoaderData>().functionCallReturnValue.hasNewerVersion" (full path)
589
+ // Both resolve to the same logical data source, so we only want ONE set of flows.
590
+ const seenNormalizedPaths = new Set();
591
+ // Track which usages are part of compound conditionals (to avoid duplicates)
592
+ const compoundChainIds = new Set(compoundConditionals.map((c) => c.chainId).filter(Boolean));
593
+ // Process individual conditional usages
594
+ for (const [_path, usages] of Object.entries(conditionalUsages)) {
595
+ for (const usage of usages) {
596
+ // Skip usages that are part of compound conditionals (handled separately)
597
+ if (usage.chainId && compoundChainIds.has(usage.chainId)) {
598
+ continue;
599
+ }
600
+ // First, try to use pre-computed sourceDataPath if available
601
+ let resolvedPath = null;
602
+ if (usage.sourceDataPath) {
603
+ // Clean up the sourceDataPath - it may have redundant scope prefixes
604
+ // e.g., "useLoaderData<LoaderData>.useLoaderData<LoaderData>().functionCallReturnValue.entity.sha"
605
+ // should become "useLoaderData<LoaderData>().functionCallReturnValue.entity.sha"
606
+ // Returns null for malformed paths (e.g., chained function calls like fetch().json())
607
+ const cleanedPath = cleanSourceDataPath(usage.sourceDataPath);
608
+ if (cleanedPath) {
609
+ // Verify the cleaned path exists in attributesMap
610
+ const pathMatch = findInAttributesMapForPath(cleanedPath, attributesMap, fullToShortPathMap);
611
+ if (pathMatch) {
612
+ resolvedPath = pathMatch;
613
+ }
614
+ }
615
+ // If cleanedPath is null, fall through to use fallback resolution
616
+ }
617
+ // Fall back to resolution via equivalentSignatureVariables
618
+ if (!resolvedPath) {
619
+ const resolution = resolvePathToControllable(usage.path, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
620
+ if (resolution.isControllable && resolution.resolvedPath) {
621
+ resolvedPath = resolution.resolvedPath;
622
+ }
623
+ }
624
+ // If still not resolved, try using derivedFrom info to find the source path
625
+ // This handles cases like: const hasAnalysis = analysis !== null
626
+ // where hasAnalysis is not in attributesMap but analysis is
627
+ if (!resolvedPath && usage.derivedFrom) {
628
+ const { operation, sourcePath, sourcePaths, comparedValue } = usage.derivedFrom;
629
+ // For single-source derivations (notNull, equals, etc.)
630
+ if (sourcePath) {
631
+ const resolution = resolvePathToControllable(sourcePath, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
632
+ if (resolution.isControllable && resolution.resolvedPath) {
633
+ resolvedPath = resolution.resolvedPath;
634
+ }
635
+ }
636
+ // For equals/notEquals derivations with comparedValue, generate comparison flows
637
+ // e.g., canEdit derived from user.role === 'admin'
638
+ // When canEdit is used in truthiness check, we need:
639
+ // - Truthy flow: user.role = 'admin' (comparison: 'equals')
640
+ // - Falsy flow: user.role != 'admin' (comparison: 'notEquals')
641
+ if ((operation === 'equals' || operation === 'notEquals') &&
642
+ comparedValue !== undefined &&
643
+ resolvedPath &&
644
+ usage.conditionType === 'truthiness') {
645
+ const baseName = generateNameFromPath(usage.path);
646
+ const impact = usage.controlsJsxRendering
647
+ ? 'high'
648
+ : 'medium';
649
+ const isNegated = usage.isNegated ?? false;
650
+ // For equals derivation:
651
+ // - Truthy check (!negated): needs value = comparedValue (equals)
652
+ // - Falsy check (negated): needs value != comparedValue (notEquals)
653
+ // For notEquals derivation: inverse of above
654
+ const isEqualsDerivation = operation === 'equals';
655
+ const truthyNeedsEquals = isEqualsDerivation !== isNegated;
656
+ // Generate truthy flow
657
+ const truthyFlow = {
658
+ id: generateFlowId(usage.path, 'truthy'),
659
+ name: `${baseName} True`,
660
+ description: `When ${baseName.toLowerCase()} is truthy (${resolvedPath} ${truthyNeedsEquals ? '=' : '!='} ${comparedValue})`,
661
+ requiredValues: [
662
+ {
663
+ attributePath: stripLengthSuffix(resolvedPath),
664
+ value: comparedValue,
665
+ comparison: truthyNeedsEquals ? 'equals' : 'notEquals',
666
+ valueType: inferValueType(comparedValue),
667
+ },
668
+ ],
669
+ impact,
670
+ sourceLocation: usage.sourceLocation
671
+ ? {
672
+ lineNumber: usage.sourceLocation.lineNumber,
673
+ column: usage.sourceLocation.column,
674
+ }
675
+ : undefined,
676
+ codeSnippet: usage.sourceLocation?.codeSnippet,
677
+ };
678
+ // Generate falsy flow
679
+ const falsyFlow = {
680
+ id: generateFlowId(usage.path, 'falsy'),
681
+ name: `${baseName} False`,
682
+ description: `When ${baseName.toLowerCase()} is falsy (${resolvedPath} ${truthyNeedsEquals ? '!=' : '='} ${comparedValue})`,
683
+ requiredValues: [
684
+ {
685
+ attributePath: stripLengthSuffix(resolvedPath),
686
+ value: comparedValue,
687
+ comparison: truthyNeedsEquals ? 'notEquals' : 'equals',
688
+ valueType: inferValueType(comparedValue),
689
+ },
690
+ ],
691
+ impact,
692
+ sourceLocation: usage.sourceLocation
693
+ ? {
694
+ lineNumber: usage.sourceLocation.lineNumber,
695
+ column: usage.sourceLocation.column,
696
+ }
697
+ : undefined,
698
+ codeSnippet: usage.sourceLocation?.codeSnippet,
699
+ };
700
+ // Add flows and skip normal flow generation
701
+ if (!seenFlowIds.has(truthyFlow.id)) {
702
+ seenFlowIds.add(truthyFlow.id);
703
+ flows.push(truthyFlow);
704
+ }
705
+ if (!seenFlowIds.has(falsyFlow.id)) {
706
+ seenFlowIds.add(falsyFlow.id);
707
+ flows.push(falsyFlow);
708
+ }
709
+ continue;
710
+ }
711
+ // For OR derivations with negation, we need ALL sources to be falsy
712
+ // e.g., !isBusy where isBusy = isRunning || isQueued || isPending
713
+ // For the falsy flow, ALL sources must be falsy
714
+ if (operation === 'or' &&
715
+ usage.conditionType === 'truthiness' &&
716
+ usage.isNegated === true &&
717
+ sourcePaths &&
718
+ sourcePaths.length > 0) {
719
+ // Use expandDerivedVariableToSources to recursively resolve all sources
720
+ const allSources = expandDerivedVariableToSources(usage.path, conditionalUsages, attributesMap, equivalentSignatureVariables, fullToShortPathMap, new Set(), derivedVariables);
721
+ if (allSources.length > 0) {
722
+ // Generate a compound-style flow with all sources set to falsy
723
+ const baseName = generateNameFromPath(usage.path);
724
+ const impact = usage.controlsJsxRendering
725
+ ? 'high'
726
+ : 'medium';
727
+ const requiredValues = allSources.map((source) => ({
728
+ attributePath: source.path,
729
+ value: 'falsy',
730
+ comparison: 'falsy',
731
+ valueType: 'boolean',
732
+ }));
733
+ // Create a single falsy flow with all sources
734
+ const falsyFlow = {
735
+ id: generateFlowId(usage.path, 'falsy'),
736
+ name: `${baseName} False`,
737
+ description: `When ${baseName.toLowerCase()} is falsy (all sources are falsy)`,
738
+ requiredValues,
739
+ impact,
740
+ sourceLocation: usage.sourceLocation
741
+ ? {
742
+ lineNumber: usage.sourceLocation.lineNumber,
743
+ column: usage.sourceLocation.column,
744
+ }
745
+ : undefined,
746
+ codeSnippet: usage.sourceLocation?.codeSnippet,
747
+ };
748
+ // Create a truthy flow - for OR, ANY source being truthy is sufficient
749
+ // We use the first resolvable source for the truthy flow
750
+ const firstSource = allSources[0];
751
+ const truthyFlow = {
752
+ id: generateFlowId(usage.path, 'truthy'),
753
+ name: `${baseName} True`,
754
+ description: `When ${baseName.toLowerCase()} is truthy`,
755
+ requiredValues: [
756
+ {
757
+ attributePath: firstSource.path,
758
+ value: 'truthy',
759
+ comparison: 'truthy',
760
+ valueType: 'boolean',
761
+ },
762
+ ],
763
+ impact,
764
+ sourceLocation: usage.sourceLocation
765
+ ? {
766
+ lineNumber: usage.sourceLocation.lineNumber,
767
+ column: usage.sourceLocation.column,
768
+ }
769
+ : undefined,
770
+ codeSnippet: usage.sourceLocation?.codeSnippet,
771
+ };
772
+ // Add both flows (falsy needs all sources, truthy needs one)
773
+ if (!seenFlowIds.has(falsyFlow.id)) {
774
+ seenFlowIds.add(falsyFlow.id);
775
+ flows.push(falsyFlow);
776
+ }
777
+ if (!seenFlowIds.has(truthyFlow.id)) {
778
+ seenFlowIds.add(truthyFlow.id);
779
+ flows.push(truthyFlow);
780
+ }
781
+ // Skip the normal flow generation for this usage
782
+ continue;
783
+ }
784
+ }
785
+ // For AND derivations without negation, we need ALL sources to be truthy
786
+ // e.g., isReady where isReady = hasData && isLoaded && isValid
787
+ // For the truthy flow, ALL sources must be truthy
788
+ // For negated AND (!isReady), ANY source being falsy is sufficient (fallback behavior)
789
+ if (operation === 'and' &&
790
+ usage.conditionType === 'truthiness' &&
791
+ usage.isNegated !== true &&
792
+ sourcePaths &&
793
+ sourcePaths.length > 0) {
794
+ // Use expandDerivedVariableToSources to recursively resolve all sources
795
+ const allSources = expandDerivedVariableToSources(usage.path, conditionalUsages, attributesMap, equivalentSignatureVariables, fullToShortPathMap, new Set(), derivedVariables);
796
+ if (allSources.length > 0) {
797
+ // Generate a compound-style flow with all sources set to truthy
798
+ const baseName = generateNameFromPath(usage.path);
799
+ const impact = usage.controlsJsxRendering
800
+ ? 'high'
801
+ : 'medium';
802
+ const requiredValues = allSources.map((source) => ({
803
+ attributePath: source.path,
804
+ value: 'truthy',
805
+ comparison: 'truthy',
806
+ valueType: 'boolean',
807
+ }));
808
+ // Create a truthy flow with all sources
809
+ const truthyFlow = {
810
+ id: generateFlowId(usage.path, 'truthy'),
811
+ name: `${baseName} True`,
812
+ description: `When ${baseName.toLowerCase()} is truthy (all sources are truthy)`,
813
+ requiredValues,
814
+ impact,
815
+ sourceLocation: usage.sourceLocation
816
+ ? {
817
+ lineNumber: usage.sourceLocation.lineNumber,
818
+ column: usage.sourceLocation.column,
819
+ }
820
+ : undefined,
821
+ codeSnippet: usage.sourceLocation?.codeSnippet,
822
+ };
823
+ // Create a falsy flow - for AND, ANY source being falsy is sufficient
824
+ // We use the first resolvable source for the falsy flow
825
+ const firstSource = allSources[0];
826
+ const falsyFlow = {
827
+ id: generateFlowId(usage.path, 'falsy'),
828
+ name: `${baseName} False`,
829
+ description: `When ${baseName.toLowerCase()} is falsy`,
830
+ requiredValues: [
831
+ {
832
+ attributePath: firstSource.path,
833
+ value: 'falsy',
834
+ comparison: 'falsy',
835
+ valueType: 'boolean',
836
+ },
837
+ ],
838
+ impact,
839
+ sourceLocation: usage.sourceLocation
840
+ ? {
841
+ lineNumber: usage.sourceLocation.lineNumber,
842
+ column: usage.sourceLocation.column,
843
+ }
844
+ : undefined,
845
+ codeSnippet: usage.sourceLocation?.codeSnippet,
846
+ };
847
+ // Add both flows (truthy needs all sources, falsy needs one)
848
+ if (!seenFlowIds.has(truthyFlow.id)) {
849
+ seenFlowIds.add(truthyFlow.id);
850
+ flows.push(truthyFlow);
851
+ }
852
+ if (!seenFlowIds.has(falsyFlow.id)) {
853
+ seenFlowIds.add(falsyFlow.id);
854
+ flows.push(falsyFlow);
855
+ }
856
+ // Skip the normal flow generation for this usage
857
+ continue;
858
+ }
859
+ }
860
+ // For multi-source derivations (or, and) without special handling,
861
+ // try the first resolvable path as a fallback
862
+ if (!resolvedPath && sourcePaths && sourcePaths.length > 0) {
863
+ for (const sp of sourcePaths) {
864
+ const resolution = resolvePathToControllable(sp, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
865
+ if (resolution.isControllable && resolution.resolvedPath) {
866
+ resolvedPath = resolution.resolvedPath;
867
+ break;
868
+ }
869
+ }
870
+ }
871
+ }
872
+ if (!resolvedPath) {
873
+ // Path is not controllable - skip (no invalid flows possible)
874
+ continue;
875
+ }
876
+ // Normalize the resolved path to detect duplicates
877
+ // E.g., both "hasNewerVersion" and "useLoaderData<...>().hasNewerVersion"
878
+ // should normalize to the same canonical path
879
+ const normalizedPath = normalizePathForDeduplication(resolvedPath, fullToShortPathMap);
880
+ // Skip if we've already generated flows for this normalized path
881
+ // This prevents duplicate flows when we have usages for both short and full paths
882
+ if (seenNormalizedPaths.has(normalizedPath)) {
883
+ continue;
884
+ }
885
+ seenNormalizedPaths.add(normalizedPath);
886
+ // Generate flows for this controllable usage
887
+ const usageFlows = generateFlowsFromUsage(usage, resolvedPath);
888
+ for (const flow of usageFlows) {
889
+ // Deduplicate by flow ID
890
+ if (!seenFlowIds.has(flow.id)) {
891
+ seenFlowIds.add(flow.id);
892
+ flows.push(flow);
893
+ }
894
+ }
895
+ }
896
+ }
897
+ // Process compound conditionals
898
+ for (const compound of compoundConditionals) {
899
+ // Expand OR groups into separate condition sets
900
+ // For example, `A && (B || C)` becomes [[A, B], [A, C]]
901
+ const expandedConditionSets = expandOrGroups(compound.conditions);
902
+ // Process each expanded condition set as a separate potential flow
903
+ for (const conditionSet of expandedConditionSets) {
904
+ // First, check if ALL paths in this condition set are controllable (or can be expanded to controllable sources)
905
+ const resolvedPaths = new Map();
906
+ // Track expanded sources for derived variables (path -> array of expanded sources)
907
+ const expandedSources = new Map();
908
+ let allControllable = true;
909
+ for (const condition of conditionSet) {
910
+ // Check if this condition path has derivation info
911
+ // First check conditionalUsages, then fall back to derivedVariables
912
+ const usagesForPath = conditionalUsages[condition.path];
913
+ let derivedFromInfo = usagesForPath?.find((u) => u.derivedFrom?.operation)?.derivedFrom;
914
+ // CRITICAL: Also check derivedVariables for intermediate derived variables
915
+ if (!derivedFromInfo && derivedVariables?.[condition.path]) {
916
+ derivedFromInfo = derivedVariables[condition.path];
917
+ }
918
+ if (derivedFromInfo) {
919
+ // This is a derived variable - expand to its sources
920
+ const sources = expandDerivedVariableToSources(condition.path, conditionalUsages, attributesMap, equivalentSignatureVariables, fullToShortPathMap, new Set(), derivedVariables);
921
+ if (sources.length > 0) {
922
+ // Store the expanded sources for this condition
923
+ expandedSources.set(condition.path, sources);
924
+ // Use the first source's path for the resolvedPaths map (for ID generation)
925
+ resolvedPaths.set(condition.path, sources[0].path);
926
+ }
927
+ else {
928
+ // Derived variable but no controllable sources found
929
+ allControllable = false;
930
+ break;
931
+ }
932
+ }
933
+ else {
934
+ // Not a derived variable - resolve directly
935
+ const resolution = resolvePathToControllable(condition.path, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
936
+ if (!resolution.isControllable || !resolution.resolvedPath) {
937
+ allControllable = false;
938
+ break;
939
+ }
940
+ resolvedPaths.set(condition.path, resolution.resolvedPath);
941
+ }
942
+ }
943
+ // Only create a flow if ALL paths are controllable
944
+ if (allControllable && resolvedPaths.size > 0) {
945
+ // If any conditions were expanded from derived variables, we need to build a custom flow
946
+ if (expandedSources.size > 0) {
947
+ const requiredValues = [];
948
+ for (const condition of conditionSet) {
949
+ const sources = expandedSources.get(condition.path);
950
+ if (sources) {
951
+ // This condition was expanded - add all its sources
952
+ // Determine the required value based on condition type and derivation operation
953
+ const usagesForPath = conditionalUsages[condition.path];
954
+ let expandedDerivedFrom = usagesForPath?.find((u) => u.derivedFrom?.operation)?.derivedFrom;
955
+ // Also check derivedVariables for intermediate derived variables
956
+ if (!expandedDerivedFrom && derivedVariables?.[condition.path]) {
957
+ expandedDerivedFrom = derivedVariables[condition.path];
958
+ }
959
+ const operation = expandedDerivedFrom?.operation;
960
+ for (const source of sources) {
961
+ // For OR-derived truthy: ANY source truthy
962
+ // For AND-derived truthy: ALL sources truthy
963
+ // For negated: inverse
964
+ let value;
965
+ let comparison;
966
+ if (condition.conditionType === 'truthiness') {
967
+ const isNegated = condition.isNegated === true;
968
+ // For OR: truthy needs ANY source truthy, falsy needs ALL sources falsy
969
+ // For AND: truthy needs ALL sources truthy, falsy needs ANY source falsy
970
+ // In compound conditionals, we generate the truthy path by default
971
+ // (the compound expression must be truthy)
972
+ if (operation === 'or') {
973
+ // For OR-derived, truthy means we need at least one source truthy
974
+ // We'll use the first source as truthy (simplification)
975
+ value = isNegated ? 'falsy' : 'truthy';
976
+ }
977
+ else if (operation === 'and') {
978
+ // For AND-derived, truthy means ALL sources truthy
979
+ value = isNegated ? 'falsy' : 'truthy';
980
+ }
981
+ else {
982
+ value = isNegated ? 'falsy' : 'truthy';
983
+ }
984
+ comparison = isNegated ? 'falsy' : 'truthy';
985
+ }
986
+ else {
987
+ value = 'truthy';
988
+ comparison = 'truthy';
989
+ }
990
+ requiredValues.push({
991
+ attributePath: source.path,
992
+ value,
993
+ comparison,
994
+ valueType: 'boolean',
995
+ });
996
+ }
997
+ }
998
+ else {
999
+ // This condition was resolved directly
1000
+ const resolvedPath = resolvedPaths.get(condition.path);
1001
+ if (resolvedPath) {
1002
+ let value;
1003
+ let comparison;
1004
+ if (condition.conditionType === 'truthiness') {
1005
+ value = condition.isNegated ? 'falsy' : 'truthy';
1006
+ comparison = condition.isNegated ? 'falsy' : 'truthy';
1007
+ }
1008
+ else {
1009
+ value =
1010
+ condition.requiredValue?.toString() ??
1011
+ condition.comparedValues?.[0] ??
1012
+ 'truthy';
1013
+ comparison = 'equals';
1014
+ }
1015
+ requiredValues.push({
1016
+ attributePath: stripLengthSuffix(resolvedPath),
1017
+ value,
1018
+ comparison,
1019
+ valueType: inferValueType(value),
1020
+ });
1021
+ }
1022
+ }
1023
+ }
1024
+ if (requiredValues.length > 0) {
1025
+ const impact = compound.controlsJsxRendering ? 'high' : 'medium';
1026
+ // Generate a combined ID from all paths
1027
+ const pathParts = requiredValues
1028
+ .map((rv) => {
1029
+ const name = generateNameFromPath(rv.attributePath);
1030
+ return name.toLowerCase().replace(/\s+/g, '-');
1031
+ })
1032
+ .join('-and-');
1033
+ const compoundFlow = {
1034
+ id: `${pathParts}-${requiredValues.map((rv) => rv.value).join('-')}`,
1035
+ name: generateNameFromPath(requiredValues[0].attributePath),
1036
+ description: `When ${requiredValues.map((rv) => `${generateNameFromPath(rv.attributePath).toLowerCase()} is ${rv.value}`).join(' and ')}`,
1037
+ impact,
1038
+ requiredValues,
1039
+ sourceLocation: compound.sourceLocation,
1040
+ };
1041
+ if (!seenFlowIds.has(compoundFlow.id)) {
1042
+ seenFlowIds.add(compoundFlow.id);
1043
+ flows.push(compoundFlow);
1044
+ }
1045
+ }
1046
+ }
1047
+ else {
1048
+ // No derived variables - use the original generateFlowFromCompound
1049
+ // Create a modified compound with just this condition set
1050
+ const modifiedCompound = {
1051
+ ...compound,
1052
+ conditions: conditionSet,
1053
+ };
1054
+ const compoundFlow = generateFlowFromCompound(modifiedCompound, resolvedPaths);
1055
+ if (compoundFlow && !seenFlowIds.has(compoundFlow.id)) {
1056
+ seenFlowIds.add(compoundFlow.id);
1057
+ flows.push(compoundFlow);
1058
+ }
1059
+ }
1060
+ }
1061
+ }
1062
+ }
1063
+ // Process child component conditional usages
1064
+ // Translate child paths to parent paths and merge flows
1065
+ if (childComponentData) {
1066
+ for (const [childName, childData] of Object.entries(childComponentData)) {
1067
+ // First, resolve gating conditions to get required values that must be added to all child flows
1068
+ const gatingRequiredValues = [];
1069
+ if (childData.gatingConditions) {
1070
+ for (const gatingCondition of childData.gatingConditions) {
1071
+ // Try to resolve via derivedFrom first
1072
+ let gatingPath = gatingCondition.path;
1073
+ if (gatingCondition.derivedFrom?.sourcePath) {
1074
+ gatingPath = gatingCondition.derivedFrom.sourcePath;
1075
+ }
1076
+ // Fix 32: Handle comparison expressions like "activeTab === 'scenarios'"
1077
+ // Extract the variable name and the compared value
1078
+ const comparisonMatch = gatingPath.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\s*(===?|!==?)\s*['"]?([^'"]+)['"]?$/);
1079
+ if (comparisonMatch) {
1080
+ const [, varName, operator, comparedValue] = comparisonMatch;
1081
+ // Try to resolve the variable name
1082
+ const varResolution = resolvePathToControllable(varName, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
1083
+ // Only use controllable paths for gating conditions (whitelist approach).
1084
+ // Do NOT fall back to equivalentSignatureVariables because those may contain
1085
+ // uncontrollable paths like useState that cannot be mocked.
1086
+ let resolvedVarPath = null;
1087
+ if (varResolution.isControllable && varResolution.resolvedPath) {
1088
+ resolvedVarPath = varResolution.resolvedPath;
1089
+ }
1090
+ // Note: We intentionally do NOT fall back to equivalentSignatureVariables here
1091
+ // because that would allow uncontrollable paths (like useState) to be added
1092
+ // as gating conditions.
1093
+ if (resolvedVarPath) {
1094
+ const isNegated = gatingCondition.isNegated === true;
1095
+ const isNotEquals = operator === '!=' || operator === '!==';
1096
+ // Determine the effective value for this gating condition
1097
+ // If condition is "activeTab === 'scenarios'" and NOT negated, flow needs activeTab = 'scenarios'
1098
+ // If condition is "activeTab === 'scenarios'" and IS negated, flow needs activeTab != 'scenarios' (falsy/other value)
1099
+ // If condition is "activeTab !== 'scenarios'" and NOT negated, flow needs activeTab != 'scenarios'
1100
+ // XOR logic: isNegated XOR isNotEquals
1101
+ const needsExactValue = isNegated !== isNotEquals;
1102
+ gatingRequiredValues.push({
1103
+ attributePath: resolvedVarPath,
1104
+ value: needsExactValue ? 'falsy' : comparedValue,
1105
+ comparison: needsExactValue ? 'falsy' : 'equals',
1106
+ });
1107
+ continue; // Skip to next gating condition
1108
+ }
1109
+ }
1110
+ // Fix 31: Handle compound gating conditions (containing && or ||)
1111
+ // e.g., "isEditMode && selectedScenario" should be parsed into individual paths
1112
+ const isAndExpression = gatingPath.includes(' && ');
1113
+ const isOrExpression = gatingPath.includes(' || ');
1114
+ const isCompoundExpression = isAndExpression || isOrExpression;
1115
+ if (isCompoundExpression) {
1116
+ // Parse the compound expression into individual variable names
1117
+ // Split on && and || (with optional spaces)
1118
+ const parts = gatingPath.split(/\s*(?:&&|\|\|)\s*/);
1119
+ const isNegated = gatingCondition.isNegated === true;
1120
+ // Fix 37: Apply DeMorgan's law correctly for compound conditions
1121
+ // - !(A && B) = !A || !B: EITHER A is false OR B is false (can't know which)
1122
+ // - !(A || B) = !A && !B: BOTH must be false
1123
+ // - (A && B): BOTH must be true
1124
+ // - (A || B): EITHER is true (can't know which)
1125
+ //
1126
+ // We should only add gating requirements when we can definitively say
1127
+ // all parts must have the same value. This is true for:
1128
+ // - Non-negated &&: all parts must be truthy
1129
+ // - Negated ||: all parts must be falsy (DeMorgan: !(A || B) = !A && !B)
1130
+ //
1131
+ // We should NOT add gating requirements when either part could be true/false:
1132
+ // - Negated && (DeMorgan: !(A && B) = !A || !B): can't constrain both to falsy
1133
+ // - Non-negated ||: can't constrain both to truthy
1134
+ const shouldSkipGating = (isAndExpression && isNegated) || // !(A && B) - either could be falsy
1135
+ (isOrExpression && !isNegated); // (A || B) - either could be truthy
1136
+ if (shouldSkipGating) {
1137
+ // Don't add gating requirements for this compound condition
1138
+ // The child flow's own requirements will determine what values are needed
1139
+ }
1140
+ else {
1141
+ for (const part of parts) {
1142
+ // Clean up the part (remove parentheses, negation, etc.)
1143
+ const cleanPart = part
1144
+ .replace(/^\(+|\)+$/g, '') // Remove leading/trailing parens
1145
+ .replace(/^!+/, '') // Remove leading negation
1146
+ .trim();
1147
+ if (!cleanPart)
1148
+ continue;
1149
+ // Try to resolve this individual path
1150
+ const partResolution = resolvePathToControllable(cleanPart, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
1151
+ if (partResolution.isControllable &&
1152
+ partResolution.resolvedPath) {
1153
+ // For non-negated &&: all parts must be truthy
1154
+ // For negated ||: all parts must be falsy (DeMorgan: !(A || B) = !A && !B)
1155
+ gatingRequiredValues.push({
1156
+ attributePath: stripLengthSuffix(partResolution.resolvedPath),
1157
+ value: isNegated ? 'falsy' : 'truthy',
1158
+ comparison: isNegated ? 'falsy' : 'truthy',
1159
+ });
1160
+ }
1161
+ }
1162
+ }
1163
+ }
1164
+ else {
1165
+ // Simple gating condition (single path)
1166
+ // Resolve the gating path in parent context
1167
+ const gatingResolution = resolvePathToControllable(gatingPath, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
1168
+ // Only use controllable paths for gating conditions (whitelist approach).
1169
+ // Do NOT fall back to equivalentSignatureVariables because those may contain
1170
+ // uncontrollable paths like useState that cannot be mocked.
1171
+ let resolvedGatingPath = null;
1172
+ if (gatingResolution.isControllable &&
1173
+ gatingResolution.resolvedPath) {
1174
+ resolvedGatingPath = gatingResolution.resolvedPath;
1175
+ }
1176
+ // Note: We intentionally do NOT fall back to equivalentSignatureVariables here
1177
+ // because that would allow uncontrollable paths (like useState) to be added
1178
+ // as gating conditions.
1179
+ if (resolvedGatingPath) {
1180
+ // For truthiness conditions on gating, check if the condition is negated
1181
+ // e.g., ternary else branch: isError ? <ErrorView /> : <SuccessView />
1182
+ // SuccessView has isNegated: true, meaning it renders when isError is falsy
1183
+ const isNegated = gatingCondition.isNegated === true;
1184
+ gatingRequiredValues.push({
1185
+ attributePath: resolvedGatingPath,
1186
+ value: isNegated ? 'falsy' : 'truthy',
1187
+ comparison: isNegated ? 'falsy' : 'truthy',
1188
+ });
1189
+ }
1190
+ }
1191
+ }
1192
+ }
1193
+ // Track which child usages are part of compound conditionals (to avoid duplicates)
1194
+ // Fix 33: Only skip usages that are part of compound conditionals, not all usages with chainIds
1195
+ const childCompoundChainIds = new Set(childData.compoundConditionals.map((c) => c.chainId).filter(Boolean));
1196
+ for (const [_path, usages] of Object.entries(childData.conditionalUsages)) {
1197
+ for (const usage of usages) {
1198
+ // Debug logging (disabled - set to true for troubleshooting child flow resolution)
1199
+ const shouldDebugChild = false;
1200
+ // Skip usages that are part of compound conditionals (handled separately)
1201
+ // Fix 33: Only skip if the chainId is in the child's compound conditionals
1202
+ if (usage.chainId && childCompoundChainIds.has(usage.chainId)) {
1203
+ continue;
1204
+ }
1205
+ // Determine the child path to translate
1206
+ let childPath = usage.path;
1207
+ // If the usage has derivedFrom, use the source path instead
1208
+ if (usage.derivedFrom?.sourcePath) {
1209
+ childPath = usage.derivedFrom.sourcePath;
1210
+ }
1211
+ if (shouldDebugChild) {
1212
+ console.log(`[DEBUG CHILD ${childName}] Processing usage path: ${usage.path}`);
1213
+ console.log(`[DEBUG CHILD ${childName}] childPath (after derivedFrom): ${childPath}`);
1214
+ console.log(`[DEBUG CHILD ${childName}] sourceDataPath: ${usage.sourceDataPath}`);
1215
+ }
1216
+ // Translate the child path to a parent path
1217
+ let translatedPath = translateChildPathToParent(childPath, childData.equivalentSignatureVariables, equivalentSignatureVariables, childName);
1218
+ if (shouldDebugChild) {
1219
+ console.log(`[DEBUG CHILD ${childName}] translatedPath (from translateChildPathToParent): ${translatedPath}`);
1220
+ }
1221
+ // If translation failed but we have sourceDataPath, try to extract the prop path from it
1222
+ // sourceDataPath format: "ChildName.signature[n].propPath.rest" → extract "propPath.rest"
1223
+ if (!translatedPath && usage.sourceDataPath) {
1224
+ const signatureMatch = usage.sourceDataPath.match(/\.signature\[\d+\]\.(.+)$/);
1225
+ if (signatureMatch) {
1226
+ translatedPath = signatureMatch[1];
1227
+ if (shouldDebugChild) {
1228
+ console.log(`[DEBUG CHILD ${childName}] translatedPath (from sourceDataPath regex): ${translatedPath}`);
1229
+ }
1230
+ }
1231
+ }
1232
+ if (!translatedPath) {
1233
+ // Could not translate - skip this usage
1234
+ if (shouldDebugChild) {
1235
+ console.log(`[DEBUG CHILD ${childName}] SKIPPED - no translation found`);
1236
+ }
1237
+ continue;
1238
+ }
1239
+ // Now resolve the translated path in the parent context
1240
+ // First, try standard resolution
1241
+ const resolution = resolvePathToControllable(translatedPath, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
1242
+ if (shouldDebugChild) {
1243
+ console.log(`[DEBUG CHILD ${childName}] resolvePathToControllable result:`);
1244
+ console.log(`[DEBUG CHILD ${childName}] isControllable: ${resolution.isControllable}`);
1245
+ console.log(`[DEBUG CHILD ${childName}] resolvedPath: ${resolution.resolvedPath}`);
1246
+ console.log(`[DEBUG CHILD ${childName}] chain: ${resolution.resolutionChain.join(' -> ')}`);
1247
+ }
1248
+ // Only create flows for controllable paths (whitelist approach).
1249
+ // If the path doesn't resolve to something in attributesMap, skip it.
1250
+ // This prevents creating flows for useState values which are not
1251
+ // controllable via mock data injection.
1252
+ let resolvedPath = resolution.resolvedPath;
1253
+ if (!resolution.isControllable || !resolvedPath) {
1254
+ // Path is not controllable via standard resolution.
1255
+ // Try fallback: For useState values (cyScope*().functionCallReturnValue),
1256
+ // look for a related URL parameter like "varNameFromUrl" that might
1257
+ // control the initial state.
1258
+ //
1259
+ // Example: viewMode → cyScope20().functionCallReturnValue (useState value)
1260
+ // Fallback: viewModeFromUrl → segments[2] (URL param that initializes the useState)
1261
+ const useStateMatch = translatedPath.match(/^cyScope\d+\(\)\.functionCallReturnValue$/);
1262
+ if (useStateMatch) {
1263
+ // Find what variable this useState value corresponds to by looking
1264
+ // for entries like "varName": "cyScope20()" in equivalentSignatureVariables
1265
+ const useStatePattern = translatedPath.replace(/\.functionCallReturnValue$/, ''); // e.g., "cyScope20()"
1266
+ // Find the variable name that maps to this useState
1267
+ let useStateVarName = null;
1268
+ for (const [varName, varPath] of Object.entries(equivalentSignatureVariables)) {
1269
+ if (varPath === useStatePattern) {
1270
+ useStateVarName = varName;
1271
+ break;
1272
+ }
1273
+ }
1274
+ if (shouldDebugChild) {
1275
+ console.log(`[DEBUG CHILD ${childName}] useState fallback: looking for URL param`);
1276
+ console.log(`[DEBUG CHILD ${childName}] useStatePattern: ${useStatePattern}`);
1277
+ console.log(`[DEBUG CHILD ${childName}] useStateVarName: ${useStateVarName}`);
1278
+ }
1279
+ if (useStateVarName) {
1280
+ // Look for a related URL param like "varNameFromUrl"
1281
+ const urlParamName = `${useStateVarName}FromUrl`;
1282
+ const urlParamPath = equivalentSignatureVariables[urlParamName];
1283
+ if (shouldDebugChild) {
1284
+ console.log(`[DEBUG CHILD ${childName}] urlParamName: ${urlParamName}`);
1285
+ console.log(`[DEBUG CHILD ${childName}] urlParamPath: ${urlParamPath}`);
1286
+ }
1287
+ if (urlParamPath) {
1288
+ // For useState values initialized from URL params, use the
1289
+ // URL param variable name directly (e.g., "viewModeFromUrl")
1290
+ // rather than fully resolving it. This keeps the path meaningful
1291
+ // for scenario generation and avoids overly generic paths like
1292
+ // "useParams().functionCallReturnValue.*".
1293
+ //
1294
+ // The flow will use the URL param name as the attributePath,
1295
+ // which gets properly resolved when generating mock data.
1296
+ resolvedPath = urlParamName;
1297
+ if (shouldDebugChild) {
1298
+ console.log(`[DEBUG CHILD ${childName}] useState fallback SUCCESS: using URL param name ${resolvedPath}`);
1299
+ }
1300
+ }
1301
+ }
1302
+ }
1303
+ // If still not resolved after fallback, skip
1304
+ if (!resolvedPath) {
1305
+ if (shouldDebugChild) {
1306
+ console.log(`[DEBUG CHILD ${childName}] SKIPPED - path not controllable`);
1307
+ }
1308
+ continue;
1309
+ }
1310
+ }
1311
+ // Check for duplicates
1312
+ const normalizedPath = normalizePathForDeduplication(resolvedPath, fullToShortPathMap);
1313
+ if (seenNormalizedPaths.has(normalizedPath)) {
1314
+ if (shouldDebugChild) {
1315
+ console.log(`[DEBUG CHILD ${childName}] SKIPPED - duplicate normalized path: ${normalizedPath}`);
1316
+ }
1317
+ continue;
1318
+ }
1319
+ seenNormalizedPaths.add(normalizedPath);
1320
+ // Generate flows for this translated usage
1321
+ // Create a modified usage with the translated path for flow generation
1322
+ const translatedUsage = {
1323
+ ...usage,
1324
+ path: resolvedPath,
1325
+ };
1326
+ const usageFlows = generateFlowsFromUsage(translatedUsage, resolvedPath);
1327
+ if (shouldDebugChild) {
1328
+ console.log(`[DEBUG CHILD ${childName}] GENERATING ${usageFlows.length} flows with resolvedPath: ${resolvedPath}`);
1329
+ for (const f of usageFlows) {
1330
+ console.log(`[DEBUG CHILD ${childName}] - Flow ID: ${f.id}, path: ${f.requiredValues[0]?.attributePath}`);
1331
+ }
1332
+ }
1333
+ // Add gating conditions to each flow
1334
+ for (const flow of usageFlows) {
1335
+ // Add gating required values to the flow
1336
+ if (gatingRequiredValues.length > 0) {
1337
+ // Filter out any gating values that are already in the flow
1338
+ const existingPaths = new Set(flow.requiredValues.map((rv) => rv.attributePath));
1339
+ const newGatingValues = gatingRequiredValues.filter((gv) => !existingPaths.has(gv.attributePath));
1340
+ flow.requiredValues = [
1341
+ ...flow.requiredValues,
1342
+ ...newGatingValues,
1343
+ ];
1344
+ // Update the flow ID to include gating conditions
1345
+ if (newGatingValues.length > 0) {
1346
+ const gatingIdPart = newGatingValues
1347
+ .map((gv) => `${gv.attributePath}-${gv.value}`)
1348
+ .join('-');
1349
+ flow.id = `${flow.id}-gated-${gatingIdPart}`;
1350
+ }
1351
+ }
1352
+ if (!seenFlowIds.has(flow.id)) {
1353
+ seenFlowIds.add(flow.id);
1354
+ flows.push(flow);
1355
+ }
1356
+ }
1357
+ }
1358
+ }
1359
+ // Process child's compound conditionals
1360
+ for (const compound of childData.compoundConditionals) {
1361
+ const resolvedPaths = new Map();
1362
+ let allResolvable = true;
1363
+ for (const condition of compound.conditions) {
1364
+ // Determine the child path to translate
1365
+ const childPath = condition.path;
1366
+ // Translate the child path to a parent path
1367
+ const translatedPath = translateChildPathToParent(childPath, childData.equivalentSignatureVariables, equivalentSignatureVariables, childName);
1368
+ if (!translatedPath) {
1369
+ allResolvable = false;
1370
+ break;
1371
+ }
1372
+ const resolution = resolvePathToControllable(translatedPath, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
1373
+ // Only create flows for controllable paths (whitelist approach).
1374
+ // If the path doesn't resolve to something in attributesMap, skip it.
1375
+ // This prevents creating flows for useState values which are not
1376
+ // controllable via mock data injection.
1377
+ let resolvedPath = resolution.resolvedPath;
1378
+ if (!resolution.isControllable || !resolvedPath) {
1379
+ // Path is not controllable via standard resolution.
1380
+ // Try fallback: For useState values (cyScope*().functionCallReturnValue),
1381
+ // look for a related URL parameter like "varNameFromUrl" that might
1382
+ // control the initial state.
1383
+ const useStateMatch = translatedPath.match(/^cyScope\d+\(\)\.functionCallReturnValue$/);
1384
+ if (useStateMatch) {
1385
+ const useStatePattern = translatedPath.replace(/\.functionCallReturnValue$/, '');
1386
+ // Find the variable name that maps to this useState
1387
+ let useStateVarName = null;
1388
+ for (const [varName, varPath] of Object.entries(equivalentSignatureVariables)) {
1389
+ if (varPath === useStatePattern) {
1390
+ useStateVarName = varName;
1391
+ break;
1392
+ }
1393
+ }
1394
+ if (useStateVarName) {
1395
+ const urlParamName = `${useStateVarName}FromUrl`;
1396
+ const urlParamPath = equivalentSignatureVariables[urlParamName];
1397
+ if (urlParamPath) {
1398
+ resolvedPath = urlParamName;
1399
+ }
1400
+ }
1401
+ }
1402
+ }
1403
+ if (!resolvedPath) {
1404
+ allResolvable = false;
1405
+ break;
1406
+ }
1407
+ resolvedPaths.set(condition.path, resolvedPath);
1408
+ }
1409
+ if (allResolvable && resolvedPaths.size > 0) {
1410
+ const compoundFlow = generateFlowFromCompound(compound, resolvedPaths);
1411
+ if (compoundFlow) {
1412
+ // Add gating conditions to compound flow (same as regular usage flows)
1413
+ if (gatingRequiredValues.length > 0) {
1414
+ // Filter out any gating values that are already in the flow
1415
+ const existingPaths = new Set(compoundFlow.requiredValues.map((rv) => rv.attributePath));
1416
+ const newGatingValues = gatingRequiredValues.filter((gv) => !existingPaths.has(gv.attributePath));
1417
+ compoundFlow.requiredValues = [
1418
+ ...compoundFlow.requiredValues,
1419
+ ...newGatingValues,
1420
+ ];
1421
+ // Update the flow ID to include gating conditions
1422
+ if (newGatingValues.length > 0) {
1423
+ const gatingIdPart = newGatingValues
1424
+ .map((gv) => `${gv.attributePath}-${gv.value}`)
1425
+ .join('-');
1426
+ compoundFlow.id = `${compoundFlow.id}-gated-${gatingIdPart}`;
1427
+ }
1428
+ }
1429
+ if (!seenFlowIds.has(compoundFlow.id)) {
1430
+ seenFlowIds.add(compoundFlow.id);
1431
+ flows.push(compoundFlow);
1432
+ }
1433
+ }
1434
+ }
1435
+ }
1436
+ }
1437
+ }
1438
+ return flows;
1439
+ }
1440
+ //# sourceMappingURL=generateExecutionFlowsFromConditionals.js.map