@codeyam/codeyam-cli 0.1.0-staging.15d0f46 → 0.1.0-staging.1669d45

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 (625) hide show
  1. package/analyzer-template/.build-info.json +7 -7
  2. package/analyzer-template/common/execAsync.ts +1 -1
  3. package/analyzer-template/log.txt +3 -3
  4. package/analyzer-template/package.json +9 -5
  5. package/analyzer-template/packages/ai/index.ts +5 -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 +152 -6
  9. package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +107 -1
  10. package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
  11. package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +42 -0
  12. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
  13. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +38 -1
  14. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +301 -1
  15. package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +972 -106
  16. package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +232 -0
  17. package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
  18. package/analyzer-template/packages/ai/src/lib/completionCall.ts +18 -2
  19. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +1409 -138
  20. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +2 -1
  21. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +771 -0
  22. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +233 -75
  23. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +19 -1
  24. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +39 -4
  25. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +23 -0
  26. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
  27. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +42 -2
  28. package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
  29. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +74 -7
  30. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +89 -112
  31. package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +6 -0
  32. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +486 -86
  33. package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +182 -104
  34. package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +201 -0
  35. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
  36. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +1019 -0
  37. package/analyzer-template/packages/ai/src/lib/getConditionalUsagesFromCode.ts +143 -31
  38. package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +8 -2
  39. package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +276 -3
  40. package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +33 -3
  41. package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +7 -0
  42. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
  43. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -102
  44. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +71 -4
  45. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -53
  46. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
  47. package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +28 -2
  48. package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +690 -0
  49. package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
  50. package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
  51. package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +102 -0
  52. package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +8 -1
  53. package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +14 -0
  54. package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +1 -0
  55. package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
  56. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +458 -267
  57. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +18 -0
  58. package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -0
  59. package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +31 -15
  60. package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
  61. package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
  62. package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
  63. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +196 -0
  64. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
  65. package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +588 -52
  66. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
  67. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
  68. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +299 -133
  69. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +156 -0
  70. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +78 -83
  71. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +4 -8
  72. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +384 -94
  73. package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
  74. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
  75. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
  76. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
  77. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
  78. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
  79. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
  80. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
  81. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
  82. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
  83. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
  84. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
  85. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
  86. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts +15 -0
  87. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts.map +1 -0
  88. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js +31 -0
  89. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js.map +1 -0
  90. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
  91. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
  92. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
  93. package/analyzer-template/packages/aws/package.json +2 -2
  94. package/analyzer-template/packages/aws/s3/index.ts +1 -0
  95. package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
  96. package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
  97. package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
  98. package/analyzer-template/packages/aws/src/lib/s3/checkS3ObjectExists.ts +47 -0
  99. package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
  100. package/analyzer-template/packages/database/src/lib/kysely/db.ts +4 -4
  101. package/analyzer-template/packages/database/src/lib/kysely/tableRelations.ts +2 -2
  102. package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +36 -9
  103. package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +7 -3
  104. package/analyzer-template/packages/generate/index.ts +3 -0
  105. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +17 -1
  106. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +193 -0
  107. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
  108. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +9 -4
  109. package/analyzer-template/packages/generate/src/lib/deepMerge.ts +26 -1
  110. package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
  111. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -2
  112. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +2 -2
  113. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tableRelations.d.ts +2 -2
  114. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +1 -11
  115. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
  116. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +30 -7
  117. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
  118. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
  119. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  120. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
  121. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
  122. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +2 -6
  123. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
  124. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
  125. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
  126. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  127. package/analyzer-template/packages/github/dist/generate/index.d.ts +3 -0
  128. package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
  129. package/analyzer-template/packages/github/dist/generate/index.js +3 -0
  130. package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
  131. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
  132. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
  133. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  134. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
  135. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
  136. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
  137. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
  138. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
  139. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
  140. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
  141. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
  142. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
  143. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
  144. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  145. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.d.ts.map +1 -1
  146. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js +27 -1
  147. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js.map +1 -1
  148. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
  149. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
  150. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
  151. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
  152. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
  153. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
  154. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
  155. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
  156. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
  157. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
  158. package/analyzer-template/packages/github/dist/types/index.d.ts +2 -2
  159. package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
  160. package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
  161. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +63 -13
  162. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
  163. package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
  164. package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
  165. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +11 -6
  166. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
  167. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +146 -0
  168. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  169. package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts +2 -0
  170. package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts.map +1 -1
  171. package/analyzer-template/packages/github/src/lib/loadOrCreateCommit.ts +14 -0
  172. package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
  173. package/analyzer-template/packages/process/index.ts +2 -0
  174. package/analyzer-template/packages/process/package.json +12 -0
  175. package/analyzer-template/packages/process/tsconfig.json +8 -0
  176. package/analyzer-template/packages/types/index.ts +4 -0
  177. package/analyzer-template/packages/types/src/types/Analysis.ts +79 -13
  178. package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
  179. package/analyzer-template/packages/types/src/types/Scenario.ts +11 -10
  180. package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +161 -0
  181. package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
  182. package/analyzer-template/packages/utils/dist/types/index.d.ts +2 -2
  183. package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
  184. package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
  185. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +63 -13
  186. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
  187. package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
  188. package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
  189. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +11 -6
  190. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
  191. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +146 -0
  192. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  193. package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
  194. package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts.map +1 -1
  195. package/analyzer-template/playwright/capture.ts +37 -18
  196. package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
  197. package/analyzer-template/playwright/takeElementScreenshot.ts +26 -11
  198. package/analyzer-template/playwright/waitForServer.ts +21 -6
  199. package/analyzer-template/project/analyzeBaselineCommit.ts +4 -0
  200. package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
  201. package/analyzer-template/project/analyzeFileEntities.ts +4 -0
  202. package/analyzer-template/project/analyzeRegularCommit.ts +4 -0
  203. package/analyzer-template/project/constructMockCode.ts +868 -132
  204. package/analyzer-template/project/controller/startController.ts +16 -1
  205. package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
  206. package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
  207. package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +3 -6
  208. package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +49 -33
  209. package/analyzer-template/project/orchestrateCapture.ts +10 -3
  210. package/analyzer-template/project/reconcileMockDataKeys.ts +102 -2
  211. package/analyzer-template/project/runAnalysis.ts +7 -0
  212. package/analyzer-template/project/serverOnlyModules.ts +127 -2
  213. package/analyzer-template/project/start.ts +26 -4
  214. package/analyzer-template/project/startScenarioCapture.ts +72 -40
  215. package/analyzer-template/project/writeMockDataTsx.ts +118 -55
  216. package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
  217. package/analyzer-template/project/writeScenarioComponents.ts +263 -92
  218. package/analyzer-template/project/writeScenarioFiles.ts +26 -0
  219. package/analyzer-template/project/writeSimpleRoot.ts +13 -15
  220. package/analyzer-template/scripts/comboWorkerLoop.cjs +1 -0
  221. package/analyzer-template/scripts/defaultCmd.sh +9 -0
  222. package/analyzer-template/tsconfig.json +2 -1
  223. package/background/src/lib/local/createLocalAnalyzer.js +1 -29
  224. package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
  225. package/background/src/lib/local/execAsync.js +1 -1
  226. package/background/src/lib/local/execAsync.js.map +1 -1
  227. package/background/src/lib/virtualized/common/execAsync.js +1 -1
  228. package/background/src/lib/virtualized/common/execAsync.js.map +1 -1
  229. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +2 -1
  230. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
  231. package/background/src/lib/virtualized/project/analyzeBranchCommit.js +2 -1
  232. package/background/src/lib/virtualized/project/analyzeBranchCommit.js.map +1 -1
  233. package/background/src/lib/virtualized/project/analyzeFileEntities.js +2 -1
  234. package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
  235. package/background/src/lib/virtualized/project/analyzeRegularCommit.js +2 -1
  236. package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
  237. package/background/src/lib/virtualized/project/constructMockCode.js +799 -121
  238. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  239. package/background/src/lib/virtualized/project/controller/startController.js +11 -1
  240. package/background/src/lib/virtualized/project/controller/startController.js.map +1 -1
  241. package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js +6 -3
  242. package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js.map +1 -1
  243. package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js +7 -7
  244. package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js.map +1 -1
  245. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +3 -2
  246. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
  247. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +42 -28
  248. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
  249. package/background/src/lib/virtualized/project/orchestrateCapture.js +7 -4
  250. package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
  251. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +87 -2
  252. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
  253. package/background/src/lib/virtualized/project/runAnalysis.js +6 -0
  254. package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
  255. package/background/src/lib/virtualized/project/serverOnlyModules.js +106 -3
  256. package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
  257. package/background/src/lib/virtualized/project/start.js +21 -4
  258. package/background/src/lib/virtualized/project/start.js.map +1 -1
  259. package/background/src/lib/virtualized/project/startScenarioCapture.js +56 -30
  260. package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
  261. package/background/src/lib/virtualized/project/writeMockDataTsx.js +110 -48
  262. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  263. package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js +15 -0
  264. package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js.map +1 -0
  265. package/background/src/lib/virtualized/project/writeScenarioComponents.js +211 -75
  266. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  267. package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
  268. package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
  269. package/background/src/lib/virtualized/project/writeSimpleRoot.js +13 -13
  270. package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
  271. package/codeyam-cli/src/cli.js +5 -1
  272. package/codeyam-cli/src/cli.js.map +1 -1
  273. package/codeyam-cli/src/commands/analyze.js +1 -1
  274. package/codeyam-cli/src/commands/analyze.js.map +1 -1
  275. package/codeyam-cli/src/commands/baseline.js +174 -0
  276. package/codeyam-cli/src/commands/baseline.js.map +1 -0
  277. package/codeyam-cli/src/commands/debug.js +28 -18
  278. package/codeyam-cli/src/commands/debug.js.map +1 -1
  279. package/codeyam-cli/src/commands/default.js +0 -15
  280. package/codeyam-cli/src/commands/default.js.map +1 -1
  281. package/codeyam-cli/src/commands/recapture.js +44 -23
  282. package/codeyam-cli/src/commands/recapture.js.map +1 -1
  283. package/codeyam-cli/src/commands/report.js +72 -24
  284. package/codeyam-cli/src/commands/report.js.map +1 -1
  285. package/codeyam-cli/src/commands/start.js +8 -12
  286. package/codeyam-cli/src/commands/start.js.map +1 -1
  287. package/codeyam-cli/src/commands/status.js +23 -1
  288. package/codeyam-cli/src/commands/status.js.map +1 -1
  289. package/codeyam-cli/src/commands/test-startup.js +1 -1
  290. package/codeyam-cli/src/commands/test-startup.js.map +1 -1
  291. package/codeyam-cli/src/commands/wipe.js +108 -0
  292. package/codeyam-cli/src/commands/wipe.js.map +1 -0
  293. package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js +81 -0
  294. package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js.map +1 -0
  295. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +27 -27
  296. package/codeyam-cli/src/utils/analysisRunner.js +8 -13
  297. package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
  298. package/codeyam-cli/src/utils/backgroundServer.js +12 -2
  299. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  300. package/codeyam-cli/src/utils/database.js +91 -5
  301. package/codeyam-cli/src/utils/database.js.map +1 -1
  302. package/codeyam-cli/src/utils/generateReport.js +253 -106
  303. package/codeyam-cli/src/utils/generateReport.js.map +1 -1
  304. package/codeyam-cli/src/utils/git.js +79 -0
  305. package/codeyam-cli/src/utils/git.js.map +1 -0
  306. package/codeyam-cli/src/utils/install-skills.js +11 -11
  307. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  308. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +38 -0
  309. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
  310. package/codeyam-cli/src/utils/queue/job.js +239 -16
  311. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  312. package/codeyam-cli/src/utils/queue/manager.js +19 -7
  313. package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
  314. package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
  315. package/codeyam-cli/src/utils/serverState.js.map +1 -1
  316. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +5 -5
  317. package/codeyam-cli/src/utils/versionInfo.js +25 -19
  318. package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
  319. package/codeyam-cli/src/utils/wipe.js +128 -0
  320. package/codeyam-cli/src/utils/wipe.js.map +1 -0
  321. package/codeyam-cli/src/webserver/app/lib/database.js +96 -0
  322. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  323. package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
  324. package/codeyam-cli/src/webserver/backgroundServer.js +2 -5
  325. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  326. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-vauWK972.js +1 -0
  327. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-DKdsUF7Y.js → EntityTypeBadge-COi5OvsN.js} +1 -1
  328. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-BwdQv49w.js +41 -0
  329. package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-CEleMv_j.js +34 -0
  330. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-D68KarMg.js +25 -0
  331. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-L75Wvqgw.js +3 -0
  332. package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-C53WM8qn.js +6 -0
  333. package/codeyam-cli/src/webserver/build/client/assets/LogViewer-CrNkmy4i.js +3 -0
  334. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-DzJRkCkr.js +11 -0
  335. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-CQifa1n-.js +1 -0
  336. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CyaBFX7l.js +20 -0
  337. package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-CWjSsLqY.js → TruncatedFilePath-D36O1rzU.js} +1 -1
  338. package/codeyam-cli/src/webserver/build/client/assets/_index-Be83mo_j.js +11 -0
  339. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BN6wu6Y-.js +37 -0
  340. package/codeyam-cli/src/webserver/build/client/assets/chevron-down-DgTPh8H-.js +6 -0
  341. package/codeyam-cli/src/webserver/build/client/assets/chunk-EPOLDU6W-DdQKK6on.js +51 -0
  342. package/codeyam-cli/src/webserver/build/client/assets/circle-check-Dmr2bb1R.js +6 -0
  343. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-Do4ZLUYa.js +21 -0
  344. package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
  345. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
  346. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-Bn6aCAy_.js +1 -0
  347. package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-CbdFyxZh.js +23 -0
  348. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-B4iCfs5M.js +6 -0
  349. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-wDWZZO1W.js +6 -0
  350. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-BMbl7MeQ.js +5 -0
  351. package/codeyam-cli/src/webserver/build/client/assets/entry.client-5wRKRIH9.js +29 -0
  352. package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
  353. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-DD3SDH7t.js +1 -0
  354. package/codeyam-cli/src/webserver/build/client/assets/files-DKyMFI90.js +1 -0
  355. package/codeyam-cli/src/webserver/build/client/assets/git-zXjT7J0G.js +15 -0
  356. package/codeyam-cli/src/webserver/build/client/assets/globals-DTTQ3gY7.css +1 -0
  357. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-fmIEn3Bc.js +9 -0
  358. package/codeyam-cli/src/webserver/build/client/assets/index-DLbXwndH.js +9 -0
  359. package/codeyam-cli/src/webserver/build/client/assets/index-gPZ-lad1.js +3 -0
  360. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-BsPXJ81F.js +6 -0
  361. package/codeyam-cli/src/webserver/build/client/assets/manifest-22590fcf.js +1 -0
  362. package/codeyam-cli/src/webserver/build/client/assets/preload-helper-ckwbz45p.js +1 -0
  363. package/codeyam-cli/src/webserver/build/client/assets/root-BsAarjAM.js +57 -0
  364. package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
  365. package/codeyam-cli/src/webserver/build/client/assets/search-P2FKIUql.js +6 -0
  366. package/codeyam-cli/src/webserver/build/client/assets/settings-B2eDuBj8.js +1 -0
  367. package/codeyam-cli/src/webserver/build/client/assets/simulations-L18M6-kN.js +1 -0
  368. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-BDz7kbVA.js +6 -0
  369. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-29dDmbH8.js +1 -0
  370. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-CmrTPlIB.js → useLastLogLine-BUm0UVJm.js} +1 -1
  371. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-CkIOKTrZ.js +1 -0
  372. package/codeyam-cli/src/webserver/build/client/assets/{useToast-C1ig_BmP.js → useToast-KKw5kTn-.js} +1 -1
  373. package/codeyam-cli/src/webserver/build/server/assets/index-BND5I5fv.js +1 -0
  374. package/codeyam-cli/src/webserver/build/server/assets/server-build-CFXnd7MG.js +228 -0
  375. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  376. package/codeyam-cli/src/webserver/build-info.json +5 -5
  377. package/codeyam-cli/src/webserver/devServer.js +1 -3
  378. package/codeyam-cli/src/webserver/devServer.js.map +1 -1
  379. package/codeyam-cli/src/webserver/server.js +35 -25
  380. package/codeyam-cli/src/webserver/server.js.map +1 -1
  381. package/codeyam-cli/templates/{codeyam-debug-skill.md → codeyam:debug.md} +1 -1
  382. package/codeyam-cli/templates/codeyam:diagnose.md +625 -0
  383. package/codeyam-cli/templates/{codeyam-setup-skill.md → codeyam:setup.md} +139 -4
  384. package/codeyam-cli/templates/{codeyam-sim-skill.md → codeyam:sim.md} +1 -1
  385. package/codeyam-cli/templates/{codeyam-test-skill.md → codeyam:test.md} +1 -1
  386. package/codeyam-cli/templates/{codeyam-verify-skill.md → codeyam:verify.md} +1 -1
  387. package/package.json +8 -8
  388. package/packages/ai/index.js +2 -4
  389. package/packages/ai/index.js.map +1 -1
  390. package/packages/ai/src/lib/analyzeScope.js +107 -0
  391. package/packages/ai/src/lib/analyzeScope.js.map +1 -1
  392. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +76 -1
  393. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
  394. package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
  395. package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
  396. package/packages/ai/src/lib/astScopes/methodSemantics.js +29 -0
  397. package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
  398. package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js +8 -0
  399. package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
  400. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +23 -0
  401. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
  402. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +239 -1
  403. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
  404. package/packages/ai/src/lib/astScopes/processExpression.js +728 -87
  405. package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
  406. package/packages/ai/src/lib/checkAllAttributes.js +24 -9
  407. package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
  408. package/packages/ai/src/lib/completionCall.js +17 -1
  409. package/packages/ai/src/lib/completionCall.js.map +1 -1
  410. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1126 -82
  411. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  412. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +2 -1
  413. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
  414. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +482 -0
  415. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -0
  416. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +173 -55
  417. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
  418. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +16 -1
  419. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
  420. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +35 -2
  421. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
  422. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +20 -0
  423. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
  424. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js +86 -0
  425. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js.map +1 -0
  426. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +34 -3
  427. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
  428. package/packages/ai/src/lib/deepEqual.js +32 -0
  429. package/packages/ai/src/lib/deepEqual.js.map +1 -0
  430. package/packages/ai/src/lib/generateChangesEntityScenarioData.js +62 -5
  431. package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
  432. package/packages/ai/src/lib/generateChangesEntityScenarios.js +81 -90
  433. package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
  434. package/packages/ai/src/lib/generateEntityDataStructure.js +5 -0
  435. package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
  436. package/packages/ai/src/lib/generateEntityScenarioData.js +398 -81
  437. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  438. package/packages/ai/src/lib/generateEntityScenarios.js +168 -82
  439. package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
  440. package/packages/ai/src/lib/generateExecutionFlows.js +123 -0
  441. package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -0
  442. package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js +380 -0
  443. package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js.map +1 -0
  444. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +742 -0
  445. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -0
  446. package/packages/ai/src/lib/getConditionalUsagesFromCode.js +84 -14
  447. package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
  448. package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -1
  449. package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
  450. package/packages/ai/src/lib/isolateScopes.js +231 -4
  451. package/packages/ai/src/lib/isolateScopes.js.map +1 -1
  452. package/packages/ai/src/lib/mergeStatements.js +26 -3
  453. package/packages/ai/src/lib/mergeStatements.js.map +1 -1
  454. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +6 -0
  455. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
  456. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +1 -1
  457. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
  458. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -64
  459. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
  460. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +58 -4
  461. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
  462. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -34
  463. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
  464. package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
  465. package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
  466. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +16 -3
  467. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
  468. package/packages/ai/src/lib/resolvePathToControllable.js +563 -0
  469. package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
  470. package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
  471. package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
  472. package/packages/ai/src/lib/worker/SerializableDataStructure.js +22 -0
  473. package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
  474. package/packages/ai/src/lib/worker/analyzeScopeWorker.js +4 -0
  475. package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
  476. package/packages/analyze/src/lib/FileAnalyzer.js +15 -0
  477. package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
  478. package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
  479. package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
  480. package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
  481. package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
  482. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +214 -50
  483. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  484. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +10 -0
  485. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  486. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +2 -0
  487. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
  488. package/packages/analyze/src/lib/files/analyzeChange.js +21 -11
  489. package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
  490. package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
  491. package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
  492. package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
  493. package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
  494. package/packages/analyze/src/lib/files/enums/steps.js +1 -1
  495. package/packages/analyze/src/lib/files/enums/steps.js.map +1 -1
  496. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +159 -0
  497. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -0
  498. package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
  499. package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
  500. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +458 -48
  501. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
  502. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
  503. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
  504. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
  505. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
  506. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +235 -81
  507. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  508. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +96 -0
  509. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
  510. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +56 -69
  511. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
  512. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +4 -8
  513. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
  514. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +307 -89
  515. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  516. package/packages/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
  517. package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
  518. package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
  519. package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
  520. package/packages/database/src/lib/kysely/db.js +2 -2
  521. package/packages/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
  522. package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  523. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
  524. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  525. package/packages/generate/index.js +3 -0
  526. package/packages/generate/index.js.map +1 -1
  527. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
  528. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  529. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
  530. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
  531. package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
  532. package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
  533. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
  534. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  535. package/packages/generate/src/lib/deepMerge.js +27 -1
  536. package/packages/generate/src/lib/deepMerge.js.map +1 -1
  537. package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
  538. package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
  539. package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
  540. package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
  541. package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
  542. package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
  543. package/packages/process/index.js +3 -0
  544. package/packages/process/index.js.map +1 -0
  545. package/packages/process/src/GlobalProcessManager.js.map +1 -0
  546. package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
  547. package/packages/process/src/ProcessManager.js.map +1 -0
  548. package/packages/process/src/index.js.map +1 -0
  549. package/packages/process/src/managedExecAsync.js.map +1 -0
  550. package/packages/types/index.js.map +1 -1
  551. package/scripts/finalize-analyzer.cjs +3 -1
  552. package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
  553. package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -197
  554. package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -271
  555. package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -294
  556. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
  557. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -115
  558. package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
  559. package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
  560. package/analyzer-template/process/README.md +0 -507
  561. package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
  562. package/background/src/lib/process/ProcessManager.js.map +0 -1
  563. package/background/src/lib/process/index.js.map +0 -1
  564. package/background/src/lib/process/managedExecAsync.js.map +0 -1
  565. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
  566. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
  567. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-D0VW1-W7.js +0 -1
  568. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-BAk4S4pI.js +0 -1
  569. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-Y756iZxZ.js +0 -25
  570. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-zzrrjW1p.js +0 -3
  571. package/codeyam-cli/src/webserver/build/client/assets/LogViewer-QMn7bJg6.js +0 -3
  572. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-DmP5mRxX.js +0 -1
  573. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BXwvsbLw.js +0 -1
  574. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-DAmUX_1y.js +0 -5
  575. package/codeyam-cli/src/webserver/build/client/assets/_index-Df-nk4J5.js +0 -1
  576. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-_ZUyFdie.js +0 -7
  577. package/codeyam-cli/src/webserver/build/client/assets/chevron-down-Eoh0PhcW.js +0 -1
  578. package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-CZgPLy5i.js +0 -26
  579. package/codeyam-cli/src/webserver/build/client/assets/circle-check-DI-p9ZLZ.js +0 -1
  580. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-DvyV2x6y.js +0 -1
  581. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-DURu2qlF.js +0 -1
  582. package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-DDobn9Xh.js +0 -16
  583. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-CGdWnLD_.js +0 -1
  584. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-DgMmzrKs.js +0 -5
  585. package/codeyam-cli/src/webserver/build/client/assets/entry.client-DEVXuhkn.js +0 -13
  586. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-WPRQyc68.js +0 -1
  587. package/codeyam-cli/src/webserver/build/client/assets/files-B9u3lJer.js +0 -1
  588. package/codeyam-cli/src/webserver/build/client/assets/git-YGnKIuHU.js +0 -11
  589. package/codeyam-cli/src/webserver/build/client/assets/globals-28lrWTTo.css +0 -1
  590. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +0 -5
  591. package/codeyam-cli/src/webserver/build/client/assets/index-CJ0uPJjV.js +0 -1
  592. package/codeyam-cli/src/webserver/build/client/assets/index-CfqeA2XG.js +0 -3
  593. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-DIjSvh6B.js +0 -1
  594. package/codeyam-cli/src/webserver/build/client/assets/manifest-8125c15c.js +0 -1
  595. package/codeyam-cli/src/webserver/build/client/assets/preload-helper-BXl3LOEh.js +0 -1
  596. package/codeyam-cli/src/webserver/build/client/assets/root-C-g286WP.js +0 -16
  597. package/codeyam-cli/src/webserver/build/client/assets/search-xBKWfOxd.js +0 -1
  598. package/codeyam-cli/src/webserver/build/client/assets/settings-DVY_wGOx.js +0 -1
  599. package/codeyam-cli/src/webserver/build/client/assets/simulations-Be1pJo5A.js +0 -1
  600. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-CR-FkSvx.js +0 -1
  601. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DABetnSj.js +0 -1
  602. package/codeyam-cli/src/webserver/build/server/assets/index-DcR7DH9q.js +0 -1
  603. package/codeyam-cli/src/webserver/build/server/assets/server-build-BDBrfp7e.js +0 -175
  604. package/codeyam-cli/templates/debug-codeyam.md +0 -527
  605. package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
  606. package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
  607. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -136
  608. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
  609. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -220
  610. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
  611. package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -241
  612. package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
  613. package/packages/ai/src/lib/isFrontend.js +0 -5
  614. package/packages/ai/src/lib/isFrontend.js.map +0 -1
  615. package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
  616. package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
  617. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -72
  618. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
  619. /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
  620. /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
  621. /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
  622. /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
  623. /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
  624. /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
  625. /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
@@ -0,0 +1,1019 @@
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
+
15
+ import type { ExecutionFlow } from '~codeyam/types';
16
+ import type { ConditionalUsage, CompoundConditional } from './astScopes/types';
17
+ import type { EnrichedConditionalUsage } from './worker/SerializableDataStructure';
18
+ import resolvePathToControllable from './resolvePathToControllable';
19
+
20
+ /** Extended conditional usage type that may include sourceDataPath from enrichment */
21
+ type ExtendedConditionalUsage = ConditionalUsage &
22
+ Partial<EnrichedConditionalUsage>;
23
+
24
+ /** Child component conditional data for merging child flows into parent */
25
+ export interface ChildComponentConditionalData {
26
+ /** Child's conditional usages keyed by variable name (may include sourceDataPath from enrichment) */
27
+ conditionalUsages: Record<string, ExtendedConditionalUsage[]>;
28
+ /** Child's equivalent signature variables (maps internal paths to prop paths) */
29
+ equivalentSignatureVariables: Record<string, string>;
30
+ /** Child's compound conditionals */
31
+ compoundConditionals: CompoundConditional[];
32
+ /**
33
+ * Gating conditions - the parent's conditions required to render this child component.
34
+ * For example, if the parent has `{hasAnalysis && <ChildComponent />}`,
35
+ * then `hasAnalysis` is a gating condition for all of ChildComponent's flows.
36
+ */
37
+ gatingConditions?: ConditionalUsage[];
38
+ }
39
+
40
+ export interface GenerateFlowsFromConditionalsArgs {
41
+ /** Record of attribute paths to their conditional usages (may include sourceDataPath) */
42
+ conditionalUsages: Record<string, ExtendedConditionalUsage[]>;
43
+ /** Compound conditionals (&&-chained conditions) */
44
+ compoundConditionals: CompoundConditional[];
45
+ /** Map of controllable paths to their types */
46
+ attributesMap: Record<string, string>;
47
+ /** Map from local variable names to data sources */
48
+ equivalentSignatureVariables: Record<string, string>;
49
+ /** Map from full paths to short paths */
50
+ fullToShortPathMap: Record<string, string>;
51
+ /**
52
+ * Optional child component conditional data.
53
+ * Maps child component name to its conditional data.
54
+ * Used to merge child execution flows into parent.
55
+ */
56
+ childComponentData?: Record<string, ChildComponentConditionalData>;
57
+ }
58
+
59
+ /**
60
+ * Clean up sourceDataPath by removing redundant scope prefixes.
61
+ *
62
+ * This function ONLY handles the specific pattern where a scope name is
63
+ * duplicated before the hook call:
64
+ *
65
+ * Example:
66
+ * "useLoaderData<LoaderData>.useLoaderData<LoaderData>().functionCallReturnValue.entity.sha"
67
+ * → "useLoaderData<LoaderData>().functionCallReturnValue.entity.sha"
68
+ *
69
+ * For paths with multiple function calls (like fetch().json()), or paths
70
+ * that don't match the expected pattern, returns null to indicate the
71
+ * fallback resolution should be used.
72
+ */
73
+ function cleanSourceDataPath(sourceDataPath: string): string | null {
74
+ // Count function call patterns - both empty () and with content (...)
75
+ // We detect multiple function calls by counting:
76
+ // 1. Empty () patterns
77
+ // 2. Patterns like functionName(...) - closing paren followed by dot or end
78
+ const emptyFnCalls = (sourceDataPath.match(/\(\)/g) || []).length;
79
+ const fnCallReturnValues = (
80
+ sourceDataPath.match(/\.functionCallReturnValue/g) || []
81
+ ).length;
82
+
83
+ // If there are multiple functionCallReturnValue occurrences, this is a chained call
84
+ // (e.g., fetch(...).functionCallReturnValue.json().functionCallReturnValue.data)
85
+ if (fnCallReturnValues > 1 || emptyFnCalls !== 1) {
86
+ // Multiple function calls - return null to use fallback resolution
87
+ return null;
88
+ }
89
+
90
+ // Find the "()" which marks the function call
91
+ const fnCallIndex = sourceDataPath.indexOf('()');
92
+
93
+ // Find where the function name starts (go back to find the start of this segment)
94
+ const beforeFnCall = sourceDataPath.slice(0, fnCallIndex);
95
+ const lastDotBeforeFn = beforeFnCall.lastIndexOf('.');
96
+
97
+ if (lastDotBeforeFn === -1) {
98
+ return sourceDataPath;
99
+ }
100
+
101
+ // Extract the scope prefix and the actual path
102
+ const scopePrefix = sourceDataPath.slice(0, lastDotBeforeFn);
103
+ const actualPath = sourceDataPath.slice(lastDotBeforeFn + 1);
104
+
105
+ // Verify this is actually a redundant scope prefix pattern
106
+ // The actualPath should start with something that matches the scopePrefix
107
+ // e.g., scopePrefix="useLoaderData<LoaderData>" and actualPath starts with "useLoaderData<LoaderData>()..."
108
+ if (!actualPath.startsWith(scopePrefix.split('.').pop() || '')) {
109
+ // Not a redundant prefix pattern - return the original path
110
+ return sourceDataPath;
111
+ }
112
+
113
+ return actualPath;
114
+ }
115
+
116
+ /**
117
+ * Find a path in attributesMap, using fullToShortPathMap to verify the path is controllable.
118
+ *
119
+ * IMPORTANT: Returns the FULL path (preserving data source context) when possible.
120
+ * This ensures execution flows can be traced back to specific data sources,
121
+ * which is critical when multiple data sources have the same property names
122
+ * (e.g., multiple useFetcher hooks all having 'state' and 'data').
123
+ *
124
+ * The attributesMap contains short relative paths (e.g., "entity.sha")
125
+ * The sourceDataPath contains full paths (e.g., "useLoaderData<LoaderData>().functionCallReturnValue.entity.sha")
126
+ * The fullToShortPathMap maps full paths to short paths
127
+ */
128
+ function findInAttributesMapForPath(
129
+ path: string,
130
+ attributesMap: Record<string, string>,
131
+ fullToShortPathMap: Record<string, string>,
132
+ ): string | null {
133
+ // Direct match in attributesMap (already a short path)
134
+ if (path in attributesMap) {
135
+ return path;
136
+ }
137
+
138
+ // Try looking up the path in fullToShortPathMap to verify it's controllable
139
+ // IMPORTANT: Return the FULL path, not the short path, to preserve data source context
140
+ if (path in fullToShortPathMap) {
141
+ const shortPath = fullToShortPathMap[path];
142
+ if (shortPath in attributesMap) {
143
+ return path; // Return FULL path to preserve data source context
144
+ }
145
+ }
146
+
147
+ // Normalized match (array indices [N] → [])
148
+ const normalizedPath = path.replace(/\[\d+\]/g, '[]');
149
+ if (normalizedPath !== path) {
150
+ if (normalizedPath in attributesMap) {
151
+ return normalizedPath;
152
+ }
153
+ if (normalizedPath in fullToShortPathMap) {
154
+ const shortPath = fullToShortPathMap[normalizedPath];
155
+ if (shortPath in attributesMap) {
156
+ return normalizedPath; // Return normalized FULL path
157
+ }
158
+ }
159
+ }
160
+
161
+ // Try prefix matching for child paths
162
+ // e.g., path is "entity.sha.something" and attributesMap has "entity.sha"
163
+ // OR path is a full path like "useLoaderData<...>().functionCallReturnValue.entity.sha"
164
+ // and we need to find matching short path prefix
165
+ for (const attrPath of Object.keys(attributesMap)) {
166
+ if (path.startsWith(attrPath + '.') || path.startsWith(attrPath + '[')) {
167
+ // The path is a child of a known attribute path
168
+ return path;
169
+ }
170
+ }
171
+
172
+ // Try suffix matching: if the path ends with ".X.Y.Z" and attributesMap has "X.Y.Z"
173
+ // Return the FULL input path to preserve data source context
174
+ for (const attrPath of Object.keys(attributesMap)) {
175
+ if (
176
+ path.endsWith('.' + attrPath) ||
177
+ path.endsWith('.' + attrPath.replace(/\[\d+\]/g, '[]'))
178
+ ) {
179
+ return path; // Return FULL path, not short attrPath
180
+ }
181
+ }
182
+
183
+ return null;
184
+ }
185
+
186
+ /**
187
+ * Generate a human-readable name from a path.
188
+ * Extracts the last meaningful part of the path.
189
+ *
190
+ * Examples:
191
+ * - "useFetcher<...>().functionCallReturnValue.state" → "state"
192
+ * - "useLoaderData<...>().functionCallReturnValue.user.isActive" → "isActive"
193
+ */
194
+ function generateNameFromPath(path: string): string {
195
+ // Remove function call markers and get the last meaningful segment
196
+ const cleanPath = path
197
+ .replace(/\(\)/g, '')
198
+ .replace(/\.functionCallReturnValue/g, '');
199
+ const parts = cleanPath.split('.');
200
+ const lastPart = parts[parts.length - 1];
201
+
202
+ // Convert camelCase to Title Case with spaces
203
+ return lastPart
204
+ .replace(/([A-Z])/g, ' $1')
205
+ .replace(/^./, (str) => str.toUpperCase())
206
+ .trim();
207
+ }
208
+
209
+ /**
210
+ * Generate a flow ID from path and value.
211
+ * Creates a unique, URL-safe identifier.
212
+ */
213
+ function generateFlowId(path: string, value: string): string {
214
+ // Clean the path for use in ID
215
+ const cleanPath = path
216
+ .replace(/\(\)/g, '')
217
+ .replace(/\.functionCallReturnValue/g, '')
218
+ .replace(/[<>]/g, '')
219
+ .replace(/\./g, '-');
220
+
221
+ // Clean the value
222
+ const cleanValue = value
223
+ .toString()
224
+ .toLowerCase()
225
+ .replace(/[^a-z0-9]/g, '-')
226
+ .replace(/-+/g, '-')
227
+ .replace(/^-|-$/g, '');
228
+
229
+ return `${cleanPath}-${cleanValue}`.toLowerCase();
230
+ }
231
+
232
+ /**
233
+ * Infer value type from a string value.
234
+ */
235
+ function inferValueType(
236
+ value: string,
237
+ ): 'string' | 'number' | 'boolean' | 'null' {
238
+ if (value === 'true' || value === 'false') return 'boolean';
239
+ if (value === 'null' || value === 'undefined') return 'null';
240
+ if (!isNaN(Number(value)) && value !== '') return 'number';
241
+ return 'string';
242
+ }
243
+
244
+ /**
245
+ * Generate flows from a single conditional usage.
246
+ * Sets impact to 'high' if the conditional controls JSX rendering.
247
+ */
248
+ function generateFlowsFromUsage(
249
+ usage: ConditionalUsage,
250
+ resolvedPath: string,
251
+ ): ExecutionFlow[] {
252
+ const flows: ExecutionFlow[] = [];
253
+ const baseName = generateNameFromPath(resolvedPath);
254
+
255
+ // Determine impact based on whether this conditional controls JSX rendering
256
+ // Conditionals that control visual output are high-impact
257
+ const impact: ExecutionFlow['impact'] = usage.controlsJsxRendering
258
+ ? 'high'
259
+ : 'medium';
260
+
261
+ if (usage.conditionType === 'truthiness') {
262
+ // Generate both truthy and falsy flows
263
+ const isNegated = usage.isNegated ?? false;
264
+
265
+ // Truthy flow (or falsy if negated)
266
+ flows.push({
267
+ id: generateFlowId(resolvedPath, isNegated ? 'falsy' : 'truthy'),
268
+ name: `${baseName} ${isNegated ? 'False' : 'True'}`,
269
+ description: `When ${baseName.toLowerCase()} is ${isNegated ? 'falsy' : 'truthy'}`,
270
+ requiredValues: [
271
+ {
272
+ attributePath: resolvedPath,
273
+ value: isNegated ? 'falsy' : 'truthy',
274
+ comparison: isNegated ? 'falsy' : 'truthy',
275
+ valueType: 'boolean',
276
+ },
277
+ ],
278
+ impact,
279
+ sourceLocation: usage.sourceLocation
280
+ ? {
281
+ lineNumber: usage.sourceLocation.lineNumber,
282
+ column: usage.sourceLocation.column,
283
+ }
284
+ : undefined,
285
+ codeSnippet: usage.sourceLocation?.codeSnippet,
286
+ });
287
+
288
+ // Falsy flow (or truthy if negated)
289
+ flows.push({
290
+ id: generateFlowId(resolvedPath, isNegated ? 'truthy' : 'falsy'),
291
+ name: `${baseName} ${isNegated ? 'True' : 'False'}`,
292
+ description: `When ${baseName.toLowerCase()} is ${isNegated ? 'truthy' : 'falsy'}`,
293
+ requiredValues: [
294
+ {
295
+ attributePath: resolvedPath,
296
+ value: isNegated ? 'truthy' : 'falsy',
297
+ comparison: isNegated ? 'truthy' : 'falsy',
298
+ valueType: 'boolean',
299
+ },
300
+ ],
301
+ impact,
302
+ sourceLocation: usage.sourceLocation
303
+ ? {
304
+ lineNumber: usage.sourceLocation.lineNumber,
305
+ column: usage.sourceLocation.column,
306
+ }
307
+ : undefined,
308
+ codeSnippet: usage.sourceLocation?.codeSnippet,
309
+ });
310
+ } else if (
311
+ usage.conditionType === 'comparison' ||
312
+ usage.conditionType === 'switch'
313
+ ) {
314
+ // Generate one flow per compared value
315
+ const values = usage.comparedValues ?? [];
316
+
317
+ for (const value of values) {
318
+ flows.push({
319
+ id: generateFlowId(resolvedPath, value),
320
+ name: `${baseName}: ${value}`,
321
+ description: `When ${baseName.toLowerCase()} equals "${value}"`,
322
+ requiredValues: [
323
+ {
324
+ attributePath: resolvedPath,
325
+ value: value,
326
+ comparison: 'equals',
327
+ valueType: inferValueType(value),
328
+ },
329
+ ],
330
+ impact,
331
+ sourceLocation: usage.sourceLocation
332
+ ? {
333
+ lineNumber: usage.sourceLocation.lineNumber,
334
+ column: usage.sourceLocation.column,
335
+ }
336
+ : undefined,
337
+ codeSnippet: usage.sourceLocation?.codeSnippet,
338
+ });
339
+ }
340
+ }
341
+
342
+ return flows;
343
+ }
344
+
345
+ /**
346
+ * Generate a flow from a compound conditional (all conditions must be satisfied).
347
+ * Sets impact to 'high' if the compound conditional controls JSX rendering.
348
+ */
349
+ function generateFlowFromCompound(
350
+ compound: CompoundConditional,
351
+ resolvedPaths: Map<string, string>,
352
+ ): ExecutionFlow | null {
353
+ // Determine impact based on whether this compound conditional controls JSX rendering
354
+ const impact: ExecutionFlow['impact'] = compound.controlsJsxRendering
355
+ ? 'high'
356
+ : 'medium';
357
+ const requiredValues: ExecutionFlow['requiredValues'] = [];
358
+
359
+ for (const condition of compound.conditions) {
360
+ const resolvedPath = resolvedPaths.get(condition.path);
361
+ if (!resolvedPath) {
362
+ // This shouldn't happen if we pre-filtered, but safety check
363
+ return null;
364
+ }
365
+
366
+ // Determine the required value based on condition type
367
+ let value: string;
368
+ let comparison: ExecutionFlow['requiredValues'][0]['comparison'];
369
+
370
+ if (condition.conditionType === 'truthiness') {
371
+ // If negated (!foo), we need falsy; otherwise truthy
372
+ value = condition.isNegated ? 'falsy' : 'truthy';
373
+ comparison = condition.isNegated ? 'falsy' : 'truthy';
374
+ } else {
375
+ // For comparison/switch, use the first compared value or required value
376
+ value =
377
+ condition.requiredValue?.toString() ??
378
+ condition.comparedValues?.[0] ??
379
+ 'truthy';
380
+ comparison = 'equals';
381
+ }
382
+
383
+ requiredValues.push({
384
+ attributePath: resolvedPath,
385
+ value,
386
+ comparison,
387
+ valueType: inferValueType(value),
388
+ });
389
+ }
390
+
391
+ // Generate a combined ID from all paths
392
+ const pathParts = requiredValues
393
+ .map((rv) => {
394
+ const name = generateNameFromPath(rv.attributePath);
395
+ return name.toLowerCase().replace(/\s+/g, '-');
396
+ })
397
+ .join('-and-');
398
+
399
+ return {
400
+ id: `compound-${pathParts}`,
401
+ name: requiredValues
402
+ .map((rv) => generateNameFromPath(rv.attributePath))
403
+ .join(' + '),
404
+ description: `When ${requiredValues.map((rv) => `${generateNameFromPath(rv.attributePath).toLowerCase()} is ${rv.value}`).join(' and ')}`,
405
+ requiredValues,
406
+ impact,
407
+ sourceLocation: {
408
+ lineNumber: compound.sourceLocation.lineNumber,
409
+ column: compound.sourceLocation.column,
410
+ },
411
+ codeSnippet: compound.sourceLocation.codeSnippet,
412
+ };
413
+ }
414
+
415
+ /**
416
+ * Generate execution flows from conditional usages using pure static analysis.
417
+ *
418
+ * Only generates flows where all paths resolve to controllable data sources.
419
+ * This ensures we never produce flows with invalid paths like useState variables.
420
+ */
421
+ /**
422
+ * Normalize a resolved path to a canonical form for deduplication.
423
+ * Uses fullToShortPathMap to convert full paths to short paths.
424
+ * This ensures that both "hasNewerVersion" and
425
+ * "useLoaderData<LoaderData>().functionCallReturnValue.hasNewerVersion"
426
+ * normalize to the same canonical path.
427
+ */
428
+ function normalizePathForDeduplication(
429
+ resolvedPath: string,
430
+ fullToShortPathMap: Record<string, string>,
431
+ ): string {
432
+ // If the path is in fullToShortPathMap, use the short path as canonical
433
+ if (resolvedPath in fullToShortPathMap) {
434
+ return fullToShortPathMap[resolvedPath];
435
+ }
436
+ // Otherwise, the path itself is canonical
437
+ return resolvedPath;
438
+ }
439
+
440
+ /**
441
+ * Translate a child component path to a parent path using prop mappings.
442
+ *
443
+ * Given:
444
+ * - childPath: "selectedScenario.metadata.screenshotPaths[0]" (path in child's context)
445
+ * - childEquiv: { selectedScenario: "signature[0].selectedScenario" } (child's internal-to-prop mapping)
446
+ * - parentEquiv: { "ChildName().signature[0].selectedScenario": "selectedScenario" } (parent's prop assignments)
447
+ * - childName: "ChildName"
448
+ *
449
+ * Returns: "selectedScenario.metadata.screenshotPaths[0]" (path in parent's context)
450
+ *
451
+ * The translation works by:
452
+ * 1. Finding the root variable in the child path (e.g., "selectedScenario")
453
+ * 2. Looking up the child's equivalence to find the prop path (e.g., "signature[0].selectedScenario")
454
+ * 3. Building the full child prop path (e.g., "ChildName().signature[0].selectedScenario")
455
+ * 4. Looking up the parent's equivalence to find the parent path (e.g., "selectedScenario")
456
+ * 5. Replacing the root with the parent path and preserving the suffix
457
+ */
458
+ function translateChildPathToParent(
459
+ childPath: string,
460
+ childEquivalentSignatureVariables: Record<string, string>,
461
+ parentEquivalentSignatureVariables: Record<string, string>,
462
+ childName: string,
463
+ ): string | null {
464
+ // Extract the root variable from the child path
465
+ // e.g., "selectedScenario.metadata.screenshotPaths[0]" → "selectedScenario"
466
+ const dotIndex = childPath.indexOf('.');
467
+ const bracketIndex = childPath.indexOf('[');
468
+ let rootVar: string;
469
+ let suffix: string;
470
+
471
+ if (dotIndex === -1 && bracketIndex === -1) {
472
+ rootVar = childPath;
473
+ suffix = '';
474
+ } else if (dotIndex === -1) {
475
+ rootVar = childPath.slice(0, bracketIndex);
476
+ suffix = childPath.slice(bracketIndex);
477
+ } else if (bracketIndex === -1) {
478
+ rootVar = childPath.slice(0, dotIndex);
479
+ suffix = childPath.slice(dotIndex);
480
+ } else {
481
+ const firstIndex = Math.min(dotIndex, bracketIndex);
482
+ rootVar = childPath.slice(0, firstIndex);
483
+ suffix = childPath.slice(firstIndex);
484
+ }
485
+
486
+ // Look up the child's equivalence for this root variable
487
+ // e.g., childEquiv[selectedScenario] = "signature[0].selectedScenario"
488
+ const childPropPath = childEquivalentSignatureVariables[rootVar];
489
+
490
+ if (!childPropPath) {
491
+ // No mapping found - this might be internal state, not a prop
492
+ return null;
493
+ }
494
+
495
+ // Build the full child prop path as seen from parent
496
+ // e.g., "ChildName().signature[0].selectedScenario"
497
+ const fullChildPropPath = `${childName}().${childPropPath}`;
498
+
499
+ // Look up parent's equivalence to find what value was passed to this prop
500
+ // e.g., parentEquiv["ChildName().signature[0].selectedScenario"] = "selectedScenario"
501
+ const parentValue = parentEquivalentSignatureVariables[fullChildPropPath];
502
+
503
+ if (!parentValue) {
504
+ // No parent mapping found - log ALL parent keys that contain the childName
505
+ const relevantParentKeys = Object.keys(
506
+ parentEquivalentSignatureVariables,
507
+ ).filter((k) => k.includes(childName));
508
+ return null;
509
+ }
510
+
511
+ // Build the translated path: parentValue + suffix
512
+ // e.g., "selectedScenario" + ".metadata.screenshotPaths[0]"
513
+ const result = parentValue + suffix;
514
+ return result;
515
+ }
516
+
517
+ export default function generateExecutionFlowsFromConditionals(
518
+ args: GenerateFlowsFromConditionalsArgs,
519
+ ): ExecutionFlow[] {
520
+ const {
521
+ conditionalUsages,
522
+ compoundConditionals,
523
+ attributesMap,
524
+ equivalentSignatureVariables,
525
+ fullToShortPathMap,
526
+ childComponentData,
527
+ } = args;
528
+
529
+ const flows: ExecutionFlow[] = [];
530
+ const seenFlowIds = new Set<string>();
531
+
532
+ // Track normalized resolved paths to prevent duplicate flows
533
+ // This handles the case where we have usages for both:
534
+ // - "hasNewerVersion" (short path from destructured variable)
535
+ // - "useLoaderData<LoaderData>().functionCallReturnValue.hasNewerVersion" (full path)
536
+ // Both resolve to the same logical data source, so we only want ONE set of flows.
537
+ const seenNormalizedPaths = new Set<string>();
538
+
539
+ // Track which usages are part of compound conditionals (to avoid duplicates)
540
+ const compoundChainIds = new Set(
541
+ compoundConditionals.map((c) => c.chainId).filter(Boolean),
542
+ );
543
+
544
+ // Process individual conditional usages
545
+ for (const [_path, usages] of Object.entries(conditionalUsages)) {
546
+ for (const usage of usages) {
547
+ // Skip usages that are part of compound conditionals (handled separately)
548
+ if (usage.chainId && compoundChainIds.has(usage.chainId)) {
549
+ continue;
550
+ }
551
+
552
+ // First, try to use pre-computed sourceDataPath if available
553
+ let resolvedPath: string | null = null;
554
+
555
+ if (usage.sourceDataPath) {
556
+ // Clean up the sourceDataPath - it may have redundant scope prefixes
557
+ // e.g., "useLoaderData<LoaderData>.useLoaderData<LoaderData>().functionCallReturnValue.entity.sha"
558
+ // should become "useLoaderData<LoaderData>().functionCallReturnValue.entity.sha"
559
+ // Returns null for malformed paths (e.g., chained function calls like fetch().json())
560
+ const cleanedPath = cleanSourceDataPath(usage.sourceDataPath);
561
+
562
+ if (cleanedPath) {
563
+ // Verify the cleaned path exists in attributesMap
564
+ const pathMatch = findInAttributesMapForPath(
565
+ cleanedPath,
566
+ attributesMap,
567
+ fullToShortPathMap,
568
+ );
569
+ if (pathMatch) {
570
+ resolvedPath = pathMatch;
571
+ }
572
+ }
573
+ // If cleanedPath is null, fall through to use fallback resolution
574
+ }
575
+
576
+ // Fall back to resolution via equivalentSignatureVariables
577
+ if (!resolvedPath) {
578
+ const resolution = resolvePathToControllable(
579
+ usage.path,
580
+ attributesMap,
581
+ equivalentSignatureVariables,
582
+ fullToShortPathMap,
583
+ );
584
+
585
+ if (resolution.isControllable && resolution.resolvedPath) {
586
+ resolvedPath = resolution.resolvedPath;
587
+ }
588
+ }
589
+
590
+ // If still not resolved, try using derivedFrom info to find the source path
591
+ // This handles cases like: const hasAnalysis = analysis !== null
592
+ // where hasAnalysis is not in attributesMap but analysis is
593
+ if (!resolvedPath && usage.derivedFrom) {
594
+ const { sourcePath, sourcePaths } = usage.derivedFrom;
595
+
596
+ // For single-source derivations (notNull, equals, etc.)
597
+ if (sourcePath) {
598
+ const resolution = resolvePathToControllable(
599
+ sourcePath,
600
+ attributesMap,
601
+ equivalentSignatureVariables,
602
+ fullToShortPathMap,
603
+ );
604
+
605
+ if (resolution.isControllable && resolution.resolvedPath) {
606
+ resolvedPath = resolution.resolvedPath;
607
+ }
608
+ }
609
+
610
+ // For multi-source derivations (or, and), try the first resolvable path
611
+ // This is a simplification - ideally we'd generate flows for each source
612
+ if (!resolvedPath && sourcePaths && sourcePaths.length > 0) {
613
+ for (const sp of sourcePaths) {
614
+ const resolution = resolvePathToControllable(
615
+ sp,
616
+ attributesMap,
617
+ equivalentSignatureVariables,
618
+ fullToShortPathMap,
619
+ );
620
+
621
+ if (resolution.isControllable && resolution.resolvedPath) {
622
+ resolvedPath = resolution.resolvedPath;
623
+ break;
624
+ }
625
+ }
626
+ }
627
+ }
628
+
629
+ if (!resolvedPath) {
630
+ // Path is not controllable - skip (no invalid flows possible)
631
+ continue;
632
+ }
633
+
634
+ // Normalize the resolved path to detect duplicates
635
+ // E.g., both "hasNewerVersion" and "useLoaderData<...>().hasNewerVersion"
636
+ // should normalize to the same canonical path
637
+ const normalizedPath = normalizePathForDeduplication(
638
+ resolvedPath,
639
+ fullToShortPathMap,
640
+ );
641
+
642
+ // Skip if we've already generated flows for this normalized path
643
+ // This prevents duplicate flows when we have usages for both short and full paths
644
+ if (seenNormalizedPaths.has(normalizedPath)) {
645
+ continue;
646
+ }
647
+ seenNormalizedPaths.add(normalizedPath);
648
+
649
+ // Generate flows for this controllable usage
650
+ const usageFlows = generateFlowsFromUsage(usage, resolvedPath);
651
+
652
+ for (const flow of usageFlows) {
653
+ // Deduplicate by flow ID
654
+ if (!seenFlowIds.has(flow.id)) {
655
+ seenFlowIds.add(flow.id);
656
+ flows.push(flow);
657
+ }
658
+ }
659
+ }
660
+ }
661
+
662
+ // Process compound conditionals
663
+ for (const compound of compoundConditionals) {
664
+ // First, check if ALL paths in this compound are controllable
665
+ const resolvedPaths = new Map<string, string>();
666
+ let allControllable = true;
667
+
668
+ for (const condition of compound.conditions) {
669
+ const resolution = resolvePathToControllable(
670
+ condition.path,
671
+ attributesMap,
672
+ equivalentSignatureVariables,
673
+ fullToShortPathMap,
674
+ );
675
+
676
+ if (!resolution.isControllable || !resolution.resolvedPath) {
677
+ allControllable = false;
678
+ break;
679
+ }
680
+
681
+ resolvedPaths.set(condition.path, resolution.resolvedPath);
682
+ }
683
+
684
+ // Only create a flow if ALL paths are controllable
685
+ if (allControllable && resolvedPaths.size > 0) {
686
+ const compoundFlow = generateFlowFromCompound(compound, resolvedPaths);
687
+ if (compoundFlow && !seenFlowIds.has(compoundFlow.id)) {
688
+ seenFlowIds.add(compoundFlow.id);
689
+ flows.push(compoundFlow);
690
+ }
691
+ }
692
+ }
693
+
694
+ // Process child component conditional usages
695
+ // Translate child paths to parent paths and merge flows
696
+ if (childComponentData) {
697
+ for (const [childName, childData] of Object.entries(childComponentData)) {
698
+ // First, resolve gating conditions to get required values that must be added to all child flows
699
+ const gatingRequiredValues: Array<{
700
+ attributePath: string;
701
+ value: string;
702
+ comparison:
703
+ | 'truthy'
704
+ | 'falsy'
705
+ | 'equals'
706
+ | 'length>'
707
+ | 'length<'
708
+ | 'exists'
709
+ | 'not-exists';
710
+ }> = [];
711
+
712
+ if (childData.gatingConditions) {
713
+ for (const gatingCondition of childData.gatingConditions) {
714
+ // Try to resolve via derivedFrom first
715
+ let gatingPath = gatingCondition.path;
716
+ if (gatingCondition.derivedFrom?.sourcePath) {
717
+ gatingPath = gatingCondition.derivedFrom.sourcePath;
718
+ }
719
+
720
+ // Fix 32: Handle comparison expressions like "activeTab === 'scenarios'"
721
+ // Extract the variable name and the compared value
722
+ const comparisonMatch = gatingPath.match(
723
+ /^([a-zA-Z_][a-zA-Z0-9_]*)\s*(===?|!==?)\s*['"]?([^'"]+)['"]?$/,
724
+ );
725
+ if (comparisonMatch) {
726
+ const [, varName, operator, comparedValue] = comparisonMatch;
727
+
728
+ // Try to resolve the variable name
729
+ const varResolution = resolvePathToControllable(
730
+ varName,
731
+ attributesMap,
732
+ equivalentSignatureVariables,
733
+ fullToShortPathMap,
734
+ );
735
+
736
+ if (varResolution.isControllable && varResolution.resolvedPath) {
737
+ const isNegated = (gatingCondition as any).isNegated === true;
738
+ const isNotEquals = operator === '!=' || operator === '!==';
739
+ // Determine the effective value for this gating condition
740
+ // If condition is "activeTab === 'scenarios'" and NOT negated, flow needs activeTab = 'scenarios'
741
+ // If condition is "activeTab === 'scenarios'" and IS negated, flow needs activeTab != 'scenarios' (falsy/other value)
742
+ // If condition is "activeTab !== 'scenarios'" and NOT negated, flow needs activeTab != 'scenarios'
743
+ // XOR logic: isNegated XOR isNotEquals
744
+ const needsExactValue = isNegated !== isNotEquals;
745
+
746
+ gatingRequiredValues.push({
747
+ attributePath: varResolution.resolvedPath,
748
+ value: needsExactValue ? 'falsy' : comparedValue,
749
+ comparison: needsExactValue ? 'falsy' : 'equals',
750
+ });
751
+ continue; // Skip to next gating condition
752
+ }
753
+ }
754
+
755
+ // Fix 31: Handle compound gating conditions (containing && or ||)
756
+ // e.g., "isEditMode && selectedScenario" should be parsed into individual paths
757
+ const isAndExpression = gatingPath.includes(' && ');
758
+ const isOrExpression = gatingPath.includes(' || ');
759
+ const isCompoundExpression = isAndExpression || isOrExpression;
760
+
761
+ if (isCompoundExpression) {
762
+ // Parse the compound expression into individual variable names
763
+ // Split on && and || (with optional spaces)
764
+ const parts = gatingPath.split(/\s*(?:&&|\|\|)\s*/);
765
+ const isNegated = (gatingCondition as any).isNegated === true;
766
+
767
+ // Fix 37: Apply DeMorgan's law correctly for compound conditions
768
+ // - !(A && B) = !A || !B: EITHER A is false OR B is false (can't know which)
769
+ // - !(A || B) = !A && !B: BOTH must be false
770
+ // - (A && B): BOTH must be true
771
+ // - (A || B): EITHER is true (can't know which)
772
+ //
773
+ // We should only add gating requirements when we can definitively say
774
+ // all parts must have the same value. This is true for:
775
+ // - Non-negated &&: all parts must be truthy
776
+ // - Negated ||: all parts must be falsy (DeMorgan: !(A || B) = !A && !B)
777
+ //
778
+ // We should NOT add gating requirements when either part could be true/false:
779
+ // - Negated && (DeMorgan: !(A && B) = !A || !B): can't constrain both to falsy
780
+ // - Non-negated ||: can't constrain both to truthy
781
+ const shouldSkipGating =
782
+ (isAndExpression && isNegated) || // !(A && B) - either could be falsy
783
+ (isOrExpression && !isNegated); // (A || B) - either could be truthy
784
+
785
+ if (shouldSkipGating) {
786
+ // Don't add gating requirements for this compound condition
787
+ // The child flow's own requirements will determine what values are needed
788
+ } else {
789
+ for (const part of parts) {
790
+ // Clean up the part (remove parentheses, negation, etc.)
791
+ const cleanPart = part
792
+ .replace(/^\(+|\)+$/g, '') // Remove leading/trailing parens
793
+ .replace(/^!+/, '') // Remove leading negation
794
+ .trim();
795
+
796
+ if (!cleanPart) continue;
797
+
798
+ // Try to resolve this individual path
799
+ const partResolution = resolvePathToControllable(
800
+ cleanPart,
801
+ attributesMap,
802
+ equivalentSignatureVariables,
803
+ fullToShortPathMap,
804
+ );
805
+
806
+ if (
807
+ partResolution.isControllable &&
808
+ partResolution.resolvedPath
809
+ ) {
810
+ // For non-negated &&: all parts must be truthy
811
+ // For negated ||: all parts must be falsy (DeMorgan: !(A || B) = !A && !B)
812
+ gatingRequiredValues.push({
813
+ attributePath: partResolution.resolvedPath,
814
+ value: isNegated ? 'falsy' : 'truthy',
815
+ comparison: isNegated ? 'falsy' : 'truthy',
816
+ });
817
+ }
818
+ }
819
+ }
820
+ } else {
821
+ // Simple gating condition (single path)
822
+ // Resolve the gating path in parent context
823
+ const gatingResolution = resolvePathToControllable(
824
+ gatingPath,
825
+ attributesMap,
826
+ equivalentSignatureVariables,
827
+ fullToShortPathMap,
828
+ );
829
+
830
+ if (
831
+ gatingResolution.isControllable &&
832
+ gatingResolution.resolvedPath
833
+ ) {
834
+ // For truthiness conditions on gating, check if the condition is negated
835
+ // e.g., ternary else branch: isError ? <ErrorView /> : <SuccessView />
836
+ // SuccessView has isNegated: true, meaning it renders when isError is falsy
837
+ const isNegated = (gatingCondition as any).isNegated === true;
838
+ gatingRequiredValues.push({
839
+ attributePath: gatingResolution.resolvedPath,
840
+ value: isNegated ? 'falsy' : 'truthy',
841
+ comparison: isNegated ? 'falsy' : 'truthy',
842
+ });
843
+ }
844
+ }
845
+ }
846
+ }
847
+
848
+ // Track which child usages are part of compound conditionals (to avoid duplicates)
849
+ // Fix 33: Only skip usages that are part of compound conditionals, not all usages with chainIds
850
+ const childCompoundChainIds = new Set(
851
+ childData.compoundConditionals.map((c) => c.chainId).filter(Boolean),
852
+ );
853
+
854
+ for (const [_path, usages] of Object.entries(
855
+ childData.conditionalUsages,
856
+ )) {
857
+ for (const usage of usages) {
858
+ // Skip usages that are part of compound conditionals (handled separately)
859
+ // Fix 33: Only skip if the chainId is in the child's compound conditionals
860
+ if (usage.chainId && childCompoundChainIds.has(usage.chainId)) {
861
+ continue;
862
+ }
863
+
864
+ // Determine the child path to translate
865
+ let childPath = usage.path;
866
+
867
+ // If the usage has derivedFrom, use the source path instead
868
+ if (usage.derivedFrom?.sourcePath) {
869
+ childPath = usage.derivedFrom.sourcePath;
870
+ }
871
+
872
+ // Translate the child path to a parent path
873
+ let translatedPath = translateChildPathToParent(
874
+ childPath,
875
+ childData.equivalentSignatureVariables,
876
+ equivalentSignatureVariables,
877
+ childName,
878
+ );
879
+
880
+ // If translation failed but we have sourceDataPath, try to extract the prop path from it
881
+ // sourceDataPath format: "ChildName.signature[n].propPath.rest" → extract "propPath.rest"
882
+ if (!translatedPath && usage.sourceDataPath) {
883
+ const signatureMatch = usage.sourceDataPath.match(
884
+ /\.signature\[\d+\]\.(.+)$/,
885
+ );
886
+ if (signatureMatch) {
887
+ translatedPath = signatureMatch[1];
888
+ }
889
+ }
890
+
891
+ if (!translatedPath) {
892
+ // Could not translate - skip this usage
893
+ continue;
894
+ }
895
+
896
+ // Now resolve the translated path in the parent context
897
+ const resolution = resolvePathToControllable(
898
+ translatedPath,
899
+ attributesMap,
900
+ equivalentSignatureVariables,
901
+ fullToShortPathMap,
902
+ );
903
+
904
+ if (!resolution.isControllable || !resolution.resolvedPath) {
905
+ // Path is not controllable in parent context
906
+ continue;
907
+ }
908
+
909
+ const resolvedPath = resolution.resolvedPath;
910
+
911
+ // Check for duplicates
912
+ const normalizedPath = normalizePathForDeduplication(
913
+ resolvedPath,
914
+ fullToShortPathMap,
915
+ );
916
+
917
+ if (seenNormalizedPaths.has(normalizedPath)) {
918
+ continue;
919
+ }
920
+ seenNormalizedPaths.add(normalizedPath);
921
+
922
+ // Generate flows for this translated usage
923
+ // Create a modified usage with the translated path for flow generation
924
+ const translatedUsage: ConditionalUsage = {
925
+ ...usage,
926
+ path: resolvedPath,
927
+ };
928
+
929
+ const usageFlows = generateFlowsFromUsage(
930
+ translatedUsage,
931
+ resolvedPath,
932
+ );
933
+
934
+ // Add gating conditions to each flow
935
+ for (const flow of usageFlows) {
936
+ // Add gating required values to the flow
937
+ if (gatingRequiredValues.length > 0) {
938
+ // Filter out any gating values that are already in the flow
939
+ const existingPaths = new Set(
940
+ flow.requiredValues.map((rv) => rv.attributePath),
941
+ );
942
+ const newGatingValues = gatingRequiredValues.filter(
943
+ (gv) => !existingPaths.has(gv.attributePath),
944
+ );
945
+ flow.requiredValues = [
946
+ ...flow.requiredValues,
947
+ ...newGatingValues,
948
+ ];
949
+
950
+ // Update the flow ID to include gating conditions
951
+ if (newGatingValues.length > 0) {
952
+ const gatingIdPart = newGatingValues
953
+ .map((gv) => `${gv.attributePath}-${gv.value}`)
954
+ .join('-');
955
+ flow.id = `${flow.id}-gated-${gatingIdPart}`;
956
+ }
957
+ }
958
+
959
+ if (!seenFlowIds.has(flow.id)) {
960
+ seenFlowIds.add(flow.id);
961
+ flows.push(flow);
962
+ }
963
+ }
964
+ }
965
+ }
966
+
967
+ // Process child's compound conditionals
968
+ for (const compound of childData.compoundConditionals) {
969
+ const resolvedPaths = new Map<string, string>();
970
+ let allControllable = true;
971
+
972
+ for (const condition of compound.conditions) {
973
+ // Determine the child path to translate
974
+ const childPath = condition.path;
975
+
976
+ // Translate the child path to a parent path
977
+ const translatedPath = translateChildPathToParent(
978
+ childPath,
979
+ childData.equivalentSignatureVariables,
980
+ equivalentSignatureVariables,
981
+ childName,
982
+ );
983
+
984
+ if (!translatedPath) {
985
+ allControllable = false;
986
+ break;
987
+ }
988
+
989
+ const resolution = resolvePathToControllable(
990
+ translatedPath,
991
+ attributesMap,
992
+ equivalentSignatureVariables,
993
+ fullToShortPathMap,
994
+ );
995
+
996
+ if (!resolution.isControllable || !resolution.resolvedPath) {
997
+ allControllable = false;
998
+ break;
999
+ }
1000
+
1001
+ resolvedPaths.set(condition.path, resolution.resolvedPath);
1002
+ }
1003
+
1004
+ if (allControllable && resolvedPaths.size > 0) {
1005
+ const compoundFlow = generateFlowFromCompound(
1006
+ compound,
1007
+ resolvedPaths,
1008
+ );
1009
+ if (compoundFlow && !seenFlowIds.has(compoundFlow.id)) {
1010
+ seenFlowIds.add(compoundFlow.id);
1011
+ flows.push(compoundFlow);
1012
+ }
1013
+ }
1014
+ }
1015
+ }
1016
+ }
1017
+
1018
+ return flows;
1019
+ }