@codeyam/codeyam-cli 0.1.0-staging.596f0eb → 0.1.0-staging.62d4615

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 (914) hide show
  1. package/analyzer-template/.build-info.json +8 -8
  2. package/analyzer-template/common/execAsync.ts +1 -1
  3. package/analyzer-template/log.txt +3 -3
  4. package/analyzer-template/package.json +16 -12
  5. package/analyzer-template/packages/ai/index.ts +20 -5
  6. package/analyzer-template/packages/ai/package.json +3 -3
  7. package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
  8. package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +214 -24
  9. package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
  10. package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +205 -10
  11. package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
  12. package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +181 -23
  13. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
  14. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
  15. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +38 -1
  16. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
  17. package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +1518 -125
  18. package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +318 -5
  19. package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
  20. package/analyzer-template/packages/ai/src/lib/completionCall.ts +216 -36
  21. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +2301 -348
  22. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +7 -2
  23. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +976 -0
  24. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +243 -77
  25. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.ts +16 -3
  26. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +6 -4
  27. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +71 -2
  28. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +161 -19
  29. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
  30. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +93 -1
  31. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
  32. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +179 -0
  33. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.ts +40 -30
  34. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +422 -86
  35. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
  36. package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +156 -0
  37. package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
  38. package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
  39. package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
  40. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +74 -7
  41. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +89 -112
  42. package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +63 -2
  43. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1394 -92
  44. package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +216 -109
  45. package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +578 -0
  46. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
  47. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +2267 -0
  48. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
  49. package/analyzer-template/packages/ai/src/lib/getConditionalUsagesFromCode.ts +143 -31
  50. package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +8 -2
  51. package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +328 -7
  52. package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +111 -87
  53. package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +17 -7
  54. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
  55. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -102
  56. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
  57. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
  58. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +90 -6
  59. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -53
  60. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
  61. package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +28 -2
  62. package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
  63. package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +824 -0
  64. package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
  65. package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
  66. package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +127 -3
  67. package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +121 -2
  68. package/analyzer-template/packages/analyze/index.ts +2 -0
  69. package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +79 -59
  70. package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +113 -26
  71. package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
  72. package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +1 -0
  73. package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
  74. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.ts +19 -0
  75. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.ts +19 -0
  76. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +11 -0
  77. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.ts +8 -0
  78. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.ts +49 -1
  79. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.ts +2 -1
  80. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +522 -272
  81. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +34 -1
  82. package/analyzer-template/packages/analyze/src/lib/files/analyze/dependencyResolver.ts +6 -0
  83. package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -0
  84. package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
  85. package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -10
  86. package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +31 -15
  87. package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
  88. package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
  89. package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
  90. package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
  91. package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +14 -12
  92. package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1315 -0
  93. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +313 -0
  94. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
  95. package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +625 -52
  96. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
  97. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
  98. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +550 -137
  99. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +264 -0
  100. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +78 -83
  101. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +4 -8
  102. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +917 -130
  103. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
  104. package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
  105. package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
  106. package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
  107. package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
  108. package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
  109. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
  110. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
  111. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
  112. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
  113. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
  114. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
  115. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
  116. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
  117. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
  118. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
  119. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
  120. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
  121. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts +15 -0
  122. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts.map +1 -0
  123. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js +31 -0
  124. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js.map +1 -0
  125. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
  126. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
  127. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
  128. package/analyzer-template/packages/aws/package.json +3 -3
  129. package/analyzer-template/packages/aws/s3/index.ts +1 -0
  130. package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
  131. package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
  132. package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
  133. package/analyzer-template/packages/aws/src/lib/s3/checkS3ObjectExists.ts +47 -0
  134. package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
  135. package/analyzer-template/packages/database/package.json +1 -1
  136. package/analyzer-template/packages/database/src/lib/kysely/db.ts +12 -5
  137. package/analyzer-template/packages/database/src/lib/kysely/tableRelations.ts +2 -2
  138. package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
  139. package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +36 -9
  140. package/analyzer-template/packages/database/src/lib/loadAnalyses.ts +58 -1
  141. package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +13 -0
  142. package/analyzer-template/packages/database/src/lib/loadBranch.ts +16 -1
  143. package/analyzer-template/packages/database/src/lib/loadCommit.ts +11 -0
  144. package/analyzer-template/packages/database/src/lib/loadCommits.ts +28 -0
  145. package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -3
  146. package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
  147. package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +7 -3
  148. package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +7 -14
  149. package/analyzer-template/packages/generate/index.ts +3 -0
  150. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +17 -1
  151. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +193 -0
  152. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
  153. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +9 -4
  154. package/analyzer-template/packages/generate/src/lib/deepMerge.ts +26 -1
  155. package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
  156. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -2
  157. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
  158. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +10 -3
  159. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
  160. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tableRelations.d.ts +2 -2
  161. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +1 -11
  162. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
  163. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts +1 -0
  164. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts.map +1 -1
  165. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js +3 -0
  166. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
  167. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +30 -7
  168. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
  169. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
  170. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  171. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
  172. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
  173. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +2 -6
  174. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
  175. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts +2 -0
  176. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts.map +1 -1
  177. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js +45 -2
  178. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js.map +1 -1
  179. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
  180. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +8 -0
  181. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
  182. package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js +11 -1
  183. package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js.map +1 -1
  184. package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.d.ts.map +1 -1
  185. package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js +7 -0
  186. package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js.map +1 -1
  187. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts +3 -1
  188. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts.map +1 -1
  189. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +22 -1
  190. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js.map +1 -1
  191. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts +3 -1
  192. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
  193. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +23 -4
  194. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
  195. package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.d.ts.map +1 -1
  196. package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js +9 -0
  197. package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js.map +1 -1
  198. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
  199. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
  200. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  201. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts +2 -2
  202. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
  203. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +5 -4
  204. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
  205. package/analyzer-template/packages/github/dist/generate/index.d.ts +3 -0
  206. package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
  207. package/analyzer-template/packages/github/dist/generate/index.js +3 -0
  208. package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
  209. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
  210. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
  211. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  212. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
  213. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
  214. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
  215. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
  216. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
  217. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
  218. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
  219. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
  220. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
  221. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
  222. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  223. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.d.ts.map +1 -1
  224. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js +27 -1
  225. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js.map +1 -1
  226. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
  227. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
  228. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
  229. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
  230. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
  231. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
  232. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
  233. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
  234. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
  235. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
  236. package/analyzer-template/packages/github/dist/types/index.d.ts +2 -2
  237. package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
  238. package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
  239. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +87 -13
  240. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
  241. package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts +2 -0
  242. package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts.map +1 -1
  243. package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
  244. package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
  245. package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +3 -0
  246. package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
  247. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +11 -6
  248. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
  249. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +199 -3
  250. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  251. package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
  252. package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
  253. package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts +2 -0
  254. package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts.map +1 -1
  255. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
  256. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
  257. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  258. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
  259. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
  260. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
  261. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
  262. package/analyzer-template/packages/github/package.json +1 -1
  263. package/analyzer-template/packages/github/src/lib/loadOrCreateCommit.ts +14 -0
  264. package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
  265. package/analyzer-template/packages/process/index.ts +2 -0
  266. package/analyzer-template/packages/process/package.json +12 -0
  267. package/analyzer-template/packages/process/tsconfig.json +8 -0
  268. package/analyzer-template/packages/types/index.ts +5 -0
  269. package/analyzer-template/packages/types/src/types/Analysis.ts +104 -13
  270. package/analyzer-template/packages/types/src/types/Commit.ts +2 -0
  271. package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
  272. package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +1 -0
  273. package/analyzer-template/packages/types/src/types/Scenario.ts +11 -10
  274. package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +228 -3
  275. package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
  276. package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
  277. package/analyzer-template/packages/ui-components/src/components/ScenarioDetailInteractiveView.tsx +23 -7
  278. package/analyzer-template/packages/utils/dist/types/index.d.ts +2 -2
  279. package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
  280. package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
  281. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +87 -13
  282. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
  283. package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts +2 -0
  284. package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts.map +1 -1
  285. package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
  286. package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
  287. package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +3 -0
  288. package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
  289. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +11 -6
  290. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
  291. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +199 -3
  292. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  293. package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
  294. package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
  295. package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
  296. package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts.map +1 -1
  297. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
  298. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
  299. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  300. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
  301. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
  302. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
  303. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
  304. package/analyzer-template/packages/utils/src/lib/lightweightEntityExtractor.ts +27 -0
  305. package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
  306. package/analyzer-template/playwright/capture.ts +57 -26
  307. package/analyzer-template/playwright/captureStatic.ts +1 -1
  308. package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
  309. package/analyzer-template/playwright/takeElementScreenshot.ts +26 -11
  310. package/analyzer-template/playwright/takeScreenshot.ts +9 -7
  311. package/analyzer-template/playwright/waitForServer.ts +21 -6
  312. package/analyzer-template/project/analyzeBaselineCommit.ts +9 -0
  313. package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
  314. package/analyzer-template/project/analyzeFileEntities.ts +4 -0
  315. package/analyzer-template/project/analyzeRegularCommit.ts +9 -0
  316. package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
  317. package/analyzer-template/project/constructMockCode.ts +1268 -167
  318. package/analyzer-template/project/controller/startController.ts +16 -1
  319. package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
  320. package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
  321. package/analyzer-template/project/loadReadyToBeCaptured.ts +65 -41
  322. package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
  323. package/analyzer-template/project/orchestrateCapture/AwsCaptureTaskRunner.ts +12 -4
  324. package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +3 -6
  325. package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +93 -42
  326. package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
  327. package/analyzer-template/project/orchestrateCapture.ts +81 -9
  328. package/analyzer-template/project/reconcileMockDataKeys.ts +245 -2
  329. package/analyzer-template/project/runAnalysis.ts +11 -0
  330. package/analyzer-template/project/runMultiScenarioServer.ts +11 -10
  331. package/analyzer-template/project/serverOnlyModules.ts +194 -21
  332. package/analyzer-template/project/start.ts +61 -15
  333. package/analyzer-template/project/startScenarioCapture.ts +79 -41
  334. package/analyzer-template/project/writeMockDataTsx.ts +405 -65
  335. package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
  336. package/analyzer-template/project/writeScenarioComponents.ts +862 -183
  337. package/analyzer-template/project/writeScenarioFiles.ts +26 -0
  338. package/analyzer-template/project/writeSimpleRoot.ts +31 -23
  339. package/analyzer-template/scripts/comboWorkerLoop.cjs +99 -50
  340. package/analyzer-template/scripts/defaultCmd.sh +9 -0
  341. package/analyzer-template/tsconfig.json +2 -1
  342. package/background/src/lib/local/createLocalAnalyzer.js +1 -29
  343. package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
  344. package/background/src/lib/local/execAsync.js +1 -1
  345. package/background/src/lib/local/execAsync.js.map +1 -1
  346. package/background/src/lib/virtualized/common/execAsync.js +1 -1
  347. package/background/src/lib/virtualized/common/execAsync.js.map +1 -1
  348. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +7 -1
  349. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
  350. package/background/src/lib/virtualized/project/analyzeBranchCommit.js +2 -1
  351. package/background/src/lib/virtualized/project/analyzeBranchCommit.js.map +1 -1
  352. package/background/src/lib/virtualized/project/analyzeFileEntities.js +2 -1
  353. package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
  354. package/background/src/lib/virtualized/project/analyzeRegularCommit.js +7 -1
  355. package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
  356. package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js +3 -3
  357. package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js.map +1 -1
  358. package/background/src/lib/virtualized/project/constructMockCode.js +1126 -126
  359. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  360. package/background/src/lib/virtualized/project/controller/startController.js +11 -1
  361. package/background/src/lib/virtualized/project/controller/startController.js.map +1 -1
  362. package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js +73 -1
  363. package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js.map +1 -1
  364. package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js +6 -3
  365. package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js.map +1 -1
  366. package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js +19 -8
  367. package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js.map +1 -1
  368. package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js +7 -7
  369. package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js.map +1 -1
  370. package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js +2 -2
  371. package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js.map +1 -1
  372. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +3 -2
  373. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
  374. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +73 -36
  375. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
  376. package/background/src/lib/virtualized/project/orchestrateCapture.js +65 -10
  377. package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
  378. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +204 -2
  379. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
  380. package/background/src/lib/virtualized/project/runAnalysis.js +9 -0
  381. package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
  382. package/background/src/lib/virtualized/project/runMultiScenarioServer.js +11 -9
  383. package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
  384. package/background/src/lib/virtualized/project/serverOnlyModules.js +163 -23
  385. package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
  386. package/background/src/lib/virtualized/project/start.js +53 -15
  387. package/background/src/lib/virtualized/project/start.js.map +1 -1
  388. package/background/src/lib/virtualized/project/startScenarioCapture.js +61 -31
  389. package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
  390. package/background/src/lib/virtualized/project/writeMockDataTsx.js +354 -54
  391. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  392. package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js +15 -0
  393. package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js.map +1 -0
  394. package/background/src/lib/virtualized/project/writeScenarioComponents.js +624 -127
  395. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  396. package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
  397. package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
  398. package/background/src/lib/virtualized/project/writeSimpleRoot.js +31 -21
  399. package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
  400. package/codeyam-cli/scripts/apply-setup.js +180 -0
  401. package/codeyam-cli/scripts/apply-setup.js.map +1 -1
  402. package/codeyam-cli/src/cli.js +9 -1
  403. package/codeyam-cli/src/cli.js.map +1 -1
  404. package/codeyam-cli/src/commands/analyze.js +1 -1
  405. package/codeyam-cli/src/commands/analyze.js.map +1 -1
  406. package/codeyam-cli/src/commands/baseline.js +174 -0
  407. package/codeyam-cli/src/commands/baseline.js.map +1 -0
  408. package/codeyam-cli/src/commands/debug.js +42 -18
  409. package/codeyam-cli/src/commands/debug.js.map +1 -1
  410. package/codeyam-cli/src/commands/default.js +0 -15
  411. package/codeyam-cli/src/commands/default.js.map +1 -1
  412. package/codeyam-cli/src/commands/memory.js +264 -0
  413. package/codeyam-cli/src/commands/memory.js.map +1 -0
  414. package/codeyam-cli/src/commands/recapture.js +226 -0
  415. package/codeyam-cli/src/commands/recapture.js.map +1 -0
  416. package/codeyam-cli/src/commands/report.js +72 -24
  417. package/codeyam-cli/src/commands/report.js.map +1 -1
  418. package/codeyam-cli/src/commands/start.js +8 -12
  419. package/codeyam-cli/src/commands/start.js.map +1 -1
  420. package/codeyam-cli/src/commands/status.js +23 -1
  421. package/codeyam-cli/src/commands/status.js.map +1 -1
  422. package/codeyam-cli/src/commands/test-startup.js +1 -1
  423. package/codeyam-cli/src/commands/test-startup.js.map +1 -1
  424. package/codeyam-cli/src/commands/wipe.js +108 -0
  425. package/codeyam-cli/src/commands/wipe.js.map +1 -0
  426. package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js +81 -0
  427. package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js.map +1 -0
  428. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +31 -27
  429. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
  430. package/codeyam-cli/src/utils/analysisRunner.js +29 -15
  431. package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
  432. package/codeyam-cli/src/utils/backgroundServer.js +18 -4
  433. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  434. package/codeyam-cli/src/utils/database.js +91 -5
  435. package/codeyam-cli/src/utils/database.js.map +1 -1
  436. package/codeyam-cli/src/utils/generateReport.js +253 -106
  437. package/codeyam-cli/src/utils/generateReport.js.map +1 -1
  438. package/codeyam-cli/src/utils/git.js +79 -0
  439. package/codeyam-cli/src/utils/git.js.map +1 -0
  440. package/codeyam-cli/src/utils/install-skills.js +76 -17
  441. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  442. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +38 -0
  443. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
  444. package/codeyam-cli/src/utils/queue/job.js +249 -16
  445. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  446. package/codeyam-cli/src/utils/queue/manager.js +25 -7
  447. package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
  448. package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
  449. package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js +82 -0
  450. package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
  451. package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +128 -0
  452. package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
  453. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
  454. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
  455. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
  456. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
  457. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
  458. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
  459. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
  460. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
  461. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +75 -0
  462. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
  463. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +285 -0
  464. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
  465. package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +83 -0
  466. package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -0
  467. package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js +127 -0
  468. package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js.map +1 -0
  469. package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js +50 -0
  470. package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js.map +1 -0
  471. package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +96 -0
  472. package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -0
  473. package/codeyam-cli/src/utils/ruleReflection/index.js +5 -0
  474. package/codeyam-cli/src/utils/ruleReflection/index.js.map +1 -0
  475. package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js +33 -0
  476. package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js.map +1 -0
  477. package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js +85 -0
  478. package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js.map +1 -0
  479. package/codeyam-cli/src/utils/ruleReflection/types.js +5 -0
  480. package/codeyam-cli/src/utils/ruleReflection/types.js.map +1 -0
  481. package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +293 -0
  482. package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
  483. package/codeyam-cli/src/utils/rules/index.js +6 -0
  484. package/codeyam-cli/src/utils/rules/index.js.map +1 -0
  485. package/codeyam-cli/src/utils/rules/parser.js +78 -0
  486. package/codeyam-cli/src/utils/rules/parser.js.map +1 -0
  487. package/codeyam-cli/src/utils/rules/pathMatcher.js +18 -0
  488. package/codeyam-cli/src/utils/rules/pathMatcher.js.map +1 -0
  489. package/codeyam-cli/src/utils/rules/ruleState.js +150 -0
  490. package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
  491. package/codeyam-cli/src/utils/rules/staleness.js +137 -0
  492. package/codeyam-cli/src/utils/rules/staleness.js.map +1 -0
  493. package/codeyam-cli/src/utils/serverState.js.map +1 -1
  494. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +7 -5
  495. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
  496. package/codeyam-cli/src/utils/versionInfo.js +25 -19
  497. package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
  498. package/codeyam-cli/src/utils/wipe.js +128 -0
  499. package/codeyam-cli/src/utils/wipe.js.map +1 -0
  500. package/codeyam-cli/src/webserver/app/lib/database.js +104 -3
  501. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  502. package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
  503. package/codeyam-cli/src/webserver/backgroundServer.js +5 -10
  504. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  505. package/codeyam-cli/src/webserver/bootstrap.js +49 -0
  506. package/codeyam-cli/src/webserver/bootstrap.js.map +1 -0
  507. package/codeyam-cli/src/webserver/build/client/assets/CopyButton-CA3JxPb7.js +1 -0
  508. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-B86KKU7e.js +11 -0
  509. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-efWKDYMr.js → EntityTypeBadge-B5ctlSYt.js} +1 -1
  510. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-BqY8gDAW.js +41 -0
  511. package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-ClaLpuOo.js +34 -0
  512. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-BDhPilK7.js +25 -0
  513. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-VeqEBv9v.js +3 -0
  514. package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-Bs7Nn1Jr.js +6 -0
  515. package/codeyam-cli/src/webserver/build/client/assets/LogViewer-Bm3PmcCz.js +3 -0
  516. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-C6PKeMYR.js +11 -0
  517. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-Gq3Ocjo6.js +1 -0
  518. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-BNLaXBHR.js +10 -0
  519. package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-COPstp9J.js → TruncatedFilePath-CiwXDxLh.js} +1 -1
  520. package/codeyam-cli/src/webserver/build/client/assets/_index-B3TDXxnk.js +11 -0
  521. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-DD1r_QU0.js +27 -0
  522. package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-DfKzxuoe.js +11 -0
  523. package/codeyam-cli/src/webserver/build/client/assets/api.agent-transcripts-l0sNRNKZ.js +1 -0
  524. package/codeyam-cli/src/webserver/build/client/assets/api.health-l0sNRNKZ.js +1 -0
  525. package/codeyam-cli/src/webserver/build/client/assets/api.memory-profile-l0sNRNKZ.js +1 -0
  526. package/codeyam-cli/src/webserver/build/client/assets/api.restart-server-l0sNRNKZ.js +1 -0
  527. package/codeyam-cli/src/webserver/build/client/assets/api.save-fixture-l0sNRNKZ.js +1 -0
  528. package/codeyam-cli/src/webserver/build/client/assets/book-open-PttOB2SF.js +6 -0
  529. package/codeyam-cli/src/webserver/build/client/assets/chevron-down-TJp6ofnp.js +6 -0
  530. package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-JE9ZIoBl.js +51 -0
  531. package/codeyam-cli/src/webserver/build/client/assets/circle-check-CXhHQYrI.js +6 -0
  532. package/codeyam-cli/src/webserver/build/client/assets/copy-6y9ALfGT.js +11 -0
  533. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-Ca9fAY46.js +21 -0
  534. package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
  535. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
  536. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-C5lqplTC.js +1 -0
  537. package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-n38keI1k.js +23 -0
  538. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-CBoafmVs.js +6 -0
  539. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DGgZjdFg.js +6 -0
  540. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-38yPijoD.js +5 -0
  541. package/codeyam-cli/src/webserver/build/client/assets/entry.client-BSHEfydn.js +29 -0
  542. package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
  543. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-DCPhhSMo.js +1 -0
  544. package/codeyam-cli/src/webserver/build/client/assets/files-Dk8wkAS7.js +1 -0
  545. package/codeyam-cli/src/webserver/build/client/assets/git-DXnyr8uP.js +15 -0
  546. package/codeyam-cli/src/webserver/build/client/assets/globals-Bh6jH0cL.css +1 -0
  547. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-fmIEn3Bc.js +9 -0
  548. package/codeyam-cli/src/webserver/build/client/assets/index-CcsFv748.js +3 -0
  549. package/codeyam-cli/src/webserver/build/client/assets/index-ChN9-fAY.js +9 -0
  550. package/codeyam-cli/src/webserver/build/client/assets/labs-BUvfJMNR.js +1 -0
  551. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-CTqLEAGU.js +6 -0
  552. package/codeyam-cli/src/webserver/build/client/assets/manifest-d4e77269.js +1 -0
  553. package/codeyam-cli/src/webserver/build/client/assets/memory-DCHBwHou.js +76 -0
  554. package/codeyam-cli/src/webserver/build/client/assets/pause-D6vreykR.js +11 -0
  555. package/codeyam-cli/src/webserver/build/client/assets/preload-helper-ckwbz45p.js +1 -0
  556. package/codeyam-cli/src/webserver/build/client/assets/root-D6oziHts.js +62 -0
  557. package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
  558. package/codeyam-cli/src/webserver/build/client/assets/search-B8VUL8nl.js +6 -0
  559. package/codeyam-cli/src/webserver/build/client/assets/settings-B2X7lJgQ.js +1 -0
  560. package/codeyam-cli/src/webserver/build/client/assets/simulations-CPoAg7Zo.js +1 -0
  561. package/codeyam-cli/src/webserver/build/client/assets/terminal-BrCP7uQo.js +11 -0
  562. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-BZz2NjYa.js +6 -0
  563. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-DNwUduNu.js +1 -0
  564. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-3pmpUQB-.js → useLastLogLine-COky1GVF.js} +1 -1
  565. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-CpZgwliL.js +1 -0
  566. package/codeyam-cli/src/webserver/build/client/assets/{useToast-DEyawJ8r.js → useToast-Bv9JFvUO.js} +1 -1
  567. package/codeyam-cli/src/webserver/build/server/assets/index-C0KrUQp-.js +1 -0
  568. package/codeyam-cli/src/webserver/build/server/assets/server-build-C2h1v1XD.js +260 -0
  569. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  570. package/codeyam-cli/src/webserver/build-info.json +5 -5
  571. package/codeyam-cli/src/webserver/devServer.js +1 -3
  572. package/codeyam-cli/src/webserver/devServer.js.map +1 -1
  573. package/codeyam-cli/src/webserver/server.js +35 -25
  574. package/codeyam-cli/src/webserver/server.js.map +1 -1
  575. package/codeyam-cli/templates/codeyam-memory-hook.sh +199 -0
  576. package/codeyam-cli/templates/{codeyam-debug-skill.md → codeyam:debug.md} +48 -4
  577. package/codeyam-cli/templates/codeyam:diagnose.md +803 -0
  578. package/codeyam-cli/templates/codeyam:memory.md +404 -0
  579. package/codeyam-cli/templates/codeyam:new-rule.md +13 -0
  580. package/codeyam-cli/templates/{codeyam-setup-skill.md → codeyam:setup.md} +139 -4
  581. package/codeyam-cli/templates/{codeyam-sim-skill.md → codeyam:sim.md} +1 -1
  582. package/codeyam-cli/templates/{codeyam-test-skill.md → codeyam:test.md} +1 -1
  583. package/codeyam-cli/templates/{codeyam-verify-skill.md → codeyam:verify.md} +1 -1
  584. package/codeyam-cli/templates/rule-notification-hook.py +54 -0
  585. package/codeyam-cli/templates/rule-reflection-hook.py +428 -0
  586. package/codeyam-cli/templates/rules-instructions.md +123 -0
  587. package/package.json +22 -19
  588. package/packages/ai/index.js +8 -6
  589. package/packages/ai/index.js.map +1 -1
  590. package/packages/ai/src/lib/analyzeScope.js +167 -13
  591. package/packages/ai/src/lib/analyzeScope.js.map +1 -1
  592. package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
  593. package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
  594. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +154 -9
  595. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
  596. package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
  597. package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
  598. package/packages/ai/src/lib/astScopes/methodSemantics.js +138 -23
  599. package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
  600. package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js +10 -14
  601. package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js.map +1 -1
  602. package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js +8 -0
  603. package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
  604. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +23 -0
  605. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
  606. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +138 -1
  607. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
  608. package/packages/ai/src/lib/astScopes/processExpression.js +1157 -103
  609. package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
  610. package/packages/ai/src/lib/checkAllAttributes.js +24 -9
  611. package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
  612. package/packages/ai/src/lib/completionCall.js +178 -31
  613. package/packages/ai/src/lib/completionCall.js.map +1 -1
  614. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1816 -216
  615. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  616. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +7 -2
  617. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
  618. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +661 -0
  619. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -0
  620. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +180 -56
  621. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
  622. package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +13 -3
  623. package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -1
  624. package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +6 -4
  625. package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -1
  626. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +66 -2
  627. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
  628. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +139 -13
  629. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
  630. package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
  631. package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
  632. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +83 -1
  633. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
  634. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js +86 -0
  635. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js.map +1 -0
  636. package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +173 -0
  637. package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -0
  638. package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js +37 -20
  639. package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js.map +1 -1
  640. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +355 -77
  641. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
  642. package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
  643. package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
  644. package/packages/ai/src/lib/dataStructureChunking.js +111 -0
  645. package/packages/ai/src/lib/dataStructureChunking.js.map +1 -0
  646. package/packages/ai/src/lib/deepEqual.js +32 -0
  647. package/packages/ai/src/lib/deepEqual.js.map +1 -0
  648. package/packages/ai/src/lib/e2eDataTracking.js +241 -0
  649. package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
  650. package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
  651. package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
  652. package/packages/ai/src/lib/generateChangesEntityScenarioData.js +62 -5
  653. package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
  654. package/packages/ai/src/lib/generateChangesEntityScenarios.js +81 -90
  655. package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
  656. package/packages/ai/src/lib/generateEntityDataStructure.js +50 -1
  657. package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
  658. package/packages/ai/src/lib/generateEntityScenarioData.js +1109 -85
  659. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  660. package/packages/ai/src/lib/generateEntityScenarios.js +193 -83
  661. package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
  662. package/packages/ai/src/lib/generateExecutionFlows.js +400 -0
  663. package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -0
  664. package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js +380 -0
  665. package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js.map +1 -0
  666. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +1646 -0
  667. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -0
  668. package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
  669. package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
  670. package/packages/ai/src/lib/getConditionalUsagesFromCode.js +84 -14
  671. package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
  672. package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -1
  673. package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
  674. package/packages/ai/src/lib/isolateScopes.js +270 -7
  675. package/packages/ai/src/lib/isolateScopes.js.map +1 -1
  676. package/packages/ai/src/lib/mergeStatements.js +88 -46
  677. package/packages/ai/src/lib/mergeStatements.js.map +1 -1
  678. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +16 -4
  679. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
  680. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +1 -1
  681. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
  682. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -64
  683. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
  684. package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
  685. package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
  686. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +68 -6
  687. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
  688. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -34
  689. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
  690. package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
  691. package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
  692. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +16 -3
  693. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
  694. package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
  695. package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
  696. package/packages/ai/src/lib/resolvePathToControllable.js +677 -0
  697. package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
  698. package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
  699. package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
  700. package/packages/ai/src/lib/worker/SerializableDataStructure.js +29 -0
  701. package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
  702. package/packages/ai/src/lib/worker/analyzeScopeWorker.js +98 -1
  703. package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
  704. package/packages/analyze/index.js +1 -0
  705. package/packages/analyze/index.js.map +1 -1
  706. package/packages/analyze/src/lib/FileAnalyzer.js +75 -36
  707. package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
  708. package/packages/analyze/src/lib/ProjectAnalyzer.js +96 -26
  709. package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
  710. package/packages/analyze/src/lib/analysisContext.js +30 -5
  711. package/packages/analyze/src/lib/analysisContext.js.map +1 -1
  712. package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
  713. package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
  714. package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
  715. package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
  716. package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js +14 -0
  717. package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -1
  718. package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js +14 -0
  719. package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js.map +1 -1
  720. package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +6 -0
  721. package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
  722. package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js +6 -0
  723. package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js.map +1 -1
  724. package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js +39 -1
  725. package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js.map +1 -1
  726. package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js +2 -1
  727. package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js.map +1 -1
  728. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +268 -52
  729. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  730. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +24 -1
  731. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  732. package/packages/analyze/src/lib/files/analyze/dependencyResolver.js +5 -0
  733. package/packages/analyze/src/lib/files/analyze/dependencyResolver.js.map +1 -1
  734. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +2 -0
  735. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
  736. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +2 -1
  737. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
  738. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -10
  739. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
  740. package/packages/analyze/src/lib/files/analyzeChange.js +21 -11
  741. package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
  742. package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
  743. package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
  744. package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
  745. package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
  746. package/packages/analyze/src/lib/files/analyzeRemixRoute.js +3 -2
  747. package/packages/analyze/src/lib/files/analyzeRemixRoute.js.map +1 -1
  748. package/packages/analyze/src/lib/files/enums/steps.js +1 -1
  749. package/packages/analyze/src/lib/files/enums/steps.js.map +1 -1
  750. package/packages/analyze/src/lib/files/getImportedExports.js +11 -7
  751. package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
  752. package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +880 -0
  753. package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
  754. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +255 -0
  755. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -0
  756. package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
  757. package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
  758. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +483 -48
  759. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
  760. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
  761. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
  762. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
  763. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
  764. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +404 -85
  765. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  766. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +144 -0
  767. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
  768. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +56 -69
  769. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
  770. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +4 -8
  771. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
  772. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +768 -117
  773. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  774. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
  775. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
  776. package/packages/analyze/src/lib/files/setImportedExports.js +2 -1
  777. package/packages/analyze/src/lib/files/setImportedExports.js.map +1 -1
  778. package/packages/analyze/src/lib/index.js +1 -0
  779. package/packages/analyze/src/lib/index.js.map +1 -1
  780. package/packages/analyze/src/lib/utils/getFileByPath.js +12 -0
  781. package/packages/analyze/src/lib/utils/getFileByPath.js.map +1 -0
  782. package/packages/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
  783. package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
  784. package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
  785. package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
  786. package/packages/database/src/lib/kysely/db.js +10 -3
  787. package/packages/database/src/lib/kysely/db.js.map +1 -1
  788. package/packages/database/src/lib/kysely/tables/commitsTable.js +3 -0
  789. package/packages/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
  790. package/packages/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
  791. package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  792. package/packages/database/src/lib/loadAnalyses.js +45 -2
  793. package/packages/database/src/lib/loadAnalyses.js.map +1 -1
  794. package/packages/database/src/lib/loadAnalysis.js +8 -0
  795. package/packages/database/src/lib/loadAnalysis.js.map +1 -1
  796. package/packages/database/src/lib/loadBranch.js +11 -1
  797. package/packages/database/src/lib/loadBranch.js.map +1 -1
  798. package/packages/database/src/lib/loadCommit.js +7 -0
  799. package/packages/database/src/lib/loadCommit.js.map +1 -1
  800. package/packages/database/src/lib/loadCommits.js +22 -1
  801. package/packages/database/src/lib/loadCommits.js.map +1 -1
  802. package/packages/database/src/lib/loadEntities.js +23 -4
  803. package/packages/database/src/lib/loadEntities.js.map +1 -1
  804. package/packages/database/src/lib/loadEntityBranches.js +9 -0
  805. package/packages/database/src/lib/loadEntityBranches.js.map +1 -1
  806. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
  807. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  808. package/packages/database/src/lib/updateCommitMetadata.js +5 -4
  809. package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
  810. package/packages/generate/index.js +3 -0
  811. package/packages/generate/index.js.map +1 -1
  812. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
  813. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  814. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
  815. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
  816. package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
  817. package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
  818. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
  819. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  820. package/packages/generate/src/lib/deepMerge.js +27 -1
  821. package/packages/generate/src/lib/deepMerge.js.map +1 -1
  822. package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
  823. package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
  824. package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
  825. package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
  826. package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
  827. package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
  828. package/packages/process/index.js +3 -0
  829. package/packages/process/index.js.map +1 -0
  830. package/packages/process/src/GlobalProcessManager.js.map +1 -0
  831. package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
  832. package/packages/process/src/ProcessManager.js.map +1 -0
  833. package/packages/process/src/index.js.map +1 -0
  834. package/packages/process/src/managedExecAsync.js.map +1 -0
  835. package/packages/types/index.js.map +1 -1
  836. package/packages/utils/src/lib/lightweightEntityExtractor.js +25 -0
  837. package/packages/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  838. package/packages/utils/src/lib/safeFileName.js +29 -3
  839. package/packages/utils/src/lib/safeFileName.js.map +1 -1
  840. package/scripts/finalize-analyzer.cjs +6 -4
  841. package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
  842. package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -197
  843. package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -271
  844. package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -294
  845. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
  846. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -115
  847. package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
  848. package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
  849. package/analyzer-template/process/README.md +0 -507
  850. package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
  851. package/background/src/lib/process/ProcessManager.js.map +0 -1
  852. package/background/src/lib/process/index.js.map +0 -1
  853. package/background/src/lib/process/managedExecAsync.js.map +0 -1
  854. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
  855. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
  856. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-CVbSvOjo.js +0 -1
  857. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-DcwcHyl5.js +0 -1
  858. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-WgwC1GfJ.js +0 -26
  859. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-IEKom9O2.js +0 -3
  860. package/codeyam-cli/src/webserver/build/client/assets/LogViewer-BYnfxbUG.js +0 -3
  861. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-_lBPJCzG.js +0 -1
  862. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-lHVhvsu_.js +0 -1
  863. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-d_TBk4GQ.js +0 -5
  864. package/codeyam-cli/src/webserver/build/client/assets/_index-kGT7VUqj.js +0 -1
  865. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-DDGmhu7P.js +0 -7
  866. package/codeyam-cli/src/webserver/build/client/assets/chevron-down-n_HPRfM_.js +0 -1
  867. package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-CbVoyx1U.js +0 -26
  868. package/codeyam-cli/src/webserver/build/client/assets/circle-check-D1VOYveA.js +0 -1
  869. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-YR8jjAlu.js +0 -1
  870. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-B8vP3V_s.js +0 -1
  871. package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-CN6aLCT1.js +0 -16
  872. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DA5Jeu2P.js +0 -1
  873. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-BTeitalf.js +0 -5
  874. package/codeyam-cli/src/webserver/build/client/assets/entry.client-du6UEYD-.js +0 -13
  875. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-BpjkhMoi.js +0 -1
  876. package/codeyam-cli/src/webserver/build/client/assets/files-BQGvk4lJ.js +0 -1
  877. package/codeyam-cli/src/webserver/build/client/assets/git-DVdYRT-I.js +0 -12
  878. package/codeyam-cli/src/webserver/build/client/assets/globals-CO-U8Bpo.css +0 -1
  879. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +0 -5
  880. package/codeyam-cli/src/webserver/build/client/assets/index-DCG-vks0.js +0 -1
  881. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-GazdNeLl.js +0 -1
  882. package/codeyam-cli/src/webserver/build/client/assets/manifest-0b694d28.js +0 -1
  883. package/codeyam-cli/src/webserver/build/client/assets/root-D3tQP7hx.js +0 -16
  884. package/codeyam-cli/src/webserver/build/client/assets/search-CIY6XmtE.js +0 -1
  885. package/codeyam-cli/src/webserver/build/client/assets/server-build-CMKNK2uU.css +0 -1
  886. package/codeyam-cli/src/webserver/build/client/assets/settings-CoMDgElu.js +0 -1
  887. package/codeyam-cli/src/webserver/build/client/assets/simulations-agkniXp2.js +0 -1
  888. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-B2VUcygF.js +0 -1
  889. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-EvdK-zXP.js +0 -1
  890. package/codeyam-cli/src/webserver/build/server/assets/index-DGVHQEXD.js +0 -1
  891. package/codeyam-cli/src/webserver/build/server/assets/server-build-CghkTkIL.js +0 -166
  892. package/codeyam-cli/templates/debug-command.md +0 -303
  893. package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
  894. package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
  895. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -136
  896. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
  897. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -220
  898. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
  899. package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -241
  900. package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
  901. package/packages/ai/src/lib/isFrontend.js +0 -5
  902. package/packages/ai/src/lib/isFrontend.js.map +0 -1
  903. package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
  904. package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
  905. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -72
  906. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
  907. /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
  908. /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
  909. /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
  910. /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
  911. /package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-CMKNK2uU.css → styles-CMKNK2uU.css} +0 -0
  912. /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
  913. /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
  914. /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
@@ -1,9 +1,266 @@
1
1
  import ts from 'typescript';
2
+ import * as crypto from 'crypto';
2
3
  import { StructuredPath } from "./paths.js";
3
4
  import { nodeToSource } from "./nodeToSource.js";
4
5
  import { methodRegistry, ArrayPushSemantics } from "./methodSemantics.js";
5
6
  import { isArithmeticOperator, isAssignmentOperator, isBitwiseCompoundOperator, isComparisonOperator, isDefinedType, isNumericCompoundOperator, leftOrRightType, unwrapExpression, } from "./sharedPatterns.js";
6
7
  import { processBindingPattern } from "./processBindings.js";
8
+ import { extractConditionalEffectsFromTernary, findUseStateSetters, } from "./conditionalEffectsExtractor.js";
9
+ import { detectArrayDerivedPattern } from "./arrayDerivationDetector.js";
10
+ /**
11
+ * Checks if a JSX element has props that reference variables from the parent scope.
12
+ * This is used to detect unconditionally-rendered children that should have their
13
+ * execution flows merged into the parent.
14
+ *
15
+ * We want to track children where the parent controls data that affects the child's
16
+ * conditional rendering. Static props (like title="Dashboard") don't need tracking
17
+ * because they don't create variable execution flows.
18
+ *
19
+ * Examples:
20
+ * - <WorkoutsView workouts={workouts} /> → true (workouts is a variable)
21
+ * - <ItemList items={items} count={count} /> → true (items, count are variables)
22
+ * - <Header title="Dashboard" /> → false (static string)
23
+ * - <Footer /> → false (no props)
24
+ * - <Button onClick={handleClick} /> → false (only callback, no data props)
25
+ *
26
+ * @returns true if the component has at least one prop that references a variable
27
+ * (excluding callbacks which typically start with 'on' or 'handle')
28
+ */
29
+ function hasDataPropsFromParent(node, componentName) {
30
+ const attributes = ts.isJsxElement(node)
31
+ ? node.openingElement.attributes.properties
32
+ : node.attributes.properties;
33
+ const dataProps = [];
34
+ for (const attr of attributes) {
35
+ // Spread attributes always reference parent data: {...props}
36
+ if (ts.isJsxSpreadAttribute(attr)) {
37
+ const spreadText = attr.expression?.getText() || '...spread';
38
+ dataProps.push(`{...${spreadText}}`);
39
+ console.log(`[UnconditionalChild] ${componentName}: Found spread attribute {${spreadText}}`);
40
+ continue;
41
+ }
42
+ if (ts.isJsxAttribute(attr)) {
43
+ const propName = attr.name.getText();
44
+ // Skip callback props - they don't create data-driven execution flows
45
+ // Callbacks typically start with 'on' (onClick, onChange) or 'handle' (handleSubmit)
46
+ if (propName.startsWith('on') ||
47
+ propName.startsWith('handle') ||
48
+ propName === 'ref') {
49
+ console.log(`[UnconditionalChild] ${componentName}: Skipping callback prop '${propName}'`);
50
+ continue;
51
+ }
52
+ // Check if the prop value is a JSX expression (references a variable)
53
+ // vs a string literal which is static
54
+ if (attr.initializer) {
55
+ if (ts.isJsxExpression(attr.initializer)) {
56
+ // JSX expression like prop={value} - this references a variable
57
+ // Could be a simple identifier, property access, or more complex expression
58
+ const expression = attr.initializer.expression;
59
+ if (expression) {
60
+ // Skip if it's just a function/arrow function (callback)
61
+ if (ts.isArrowFunction(expression) ||
62
+ ts.isFunctionExpression(expression)) {
63
+ console.log(`[UnconditionalChild] ${componentName}: Skipping inline callback prop '${propName}'`);
64
+ continue;
65
+ }
66
+ // This is a data prop that references parent state/props
67
+ const exprText = expression.getText();
68
+ dataProps.push(`${propName}={${exprText}}`);
69
+ console.log(`[UnconditionalChild] ${componentName}: Found data prop '${propName}' = {${exprText}}`);
70
+ }
71
+ }
72
+ else {
73
+ // String literals like prop="value" are static
74
+ console.log(`[UnconditionalChild] ${componentName}: Skipping static prop '${propName}'`);
75
+ }
76
+ }
77
+ }
78
+ }
79
+ const hasDataProps = dataProps.length > 0;
80
+ if (hasDataProps) {
81
+ console.log(`[UnconditionalChild] ${componentName}: Has ${dataProps.length} data props: [${dataProps.join(', ')}]`);
82
+ }
83
+ else {
84
+ console.log(`[UnconditionalChild] ${componentName}: No data props found, will NOT track`);
85
+ }
86
+ return { hasDataProps, dataProps };
87
+ }
88
+ /**
89
+ * Extracts the component name from a JSX element.
90
+ * Returns null for intrinsic elements (div, span, etc.) since we only care about
91
+ * custom components for gating condition tracking.
92
+ *
93
+ * Examples:
94
+ * - <ChildViewer /> → "ChildViewer"
95
+ * - <ScenarioViewer scenario={...} /> → "ScenarioViewer"
96
+ * - <div> → null (intrinsic element)
97
+ */
98
+ function getComponentNameFromJsx(node) {
99
+ let tagName;
100
+ if (ts.isJsxElement(node)) {
101
+ tagName = node.openingElement.tagName;
102
+ }
103
+ else {
104
+ tagName = node.tagName;
105
+ }
106
+ // Get the text of the tag name
107
+ const name = tagName.getText();
108
+ // Check if it's a custom component (starts with uppercase) vs intrinsic element
109
+ // Custom components start with uppercase: <MyComponent />
110
+ // Intrinsic elements start with lowercase: <div />
111
+ if (name &&
112
+ name[0] === name[0].toUpperCase() &&
113
+ name[0] !== name[0].toLowerCase()) {
114
+ return name;
115
+ }
116
+ return null;
117
+ }
118
+ /**
119
+ * Extracts condition paths from a logical AND chain expression.
120
+ * Used for creating gating conditions for child components.
121
+ *
122
+ * Example: `hasData && isReady && <Component />` returns ['hasData', 'isReady']
123
+ */
124
+ function extractConditionPathsFromAndChain(expr, sourceFile) {
125
+ const paths = [];
126
+ const unwrapped = unwrapExpression(expr);
127
+ if (ts.isBinaryExpression(unwrapped) &&
128
+ unwrapped.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {
129
+ // Recursively get conditions from left side
130
+ paths.push(...extractConditionPathsFromAndChain(unwrapped.left, sourceFile));
131
+ // Process right side if it's not JSX (JSX is the consequence, not a condition)
132
+ const rightUnwrapped = unwrapExpression(unwrapped.right);
133
+ if (!ts.isJsxElement(rightUnwrapped) &&
134
+ !ts.isJsxSelfClosingElement(rightUnwrapped) &&
135
+ !ts.isJsxFragment(rightUnwrapped)) {
136
+ paths.push(...extractConditionPathsFromAndChain(unwrapped.right, sourceFile));
137
+ }
138
+ }
139
+ else {
140
+ // Base case: extract path from this expression
141
+ const path = StructuredPath.fromNode(unwrapped, sourceFile);
142
+ if (path) {
143
+ paths.push(path.toString());
144
+ }
145
+ }
146
+ return paths;
147
+ }
148
+ /**
149
+ * Finds the rightmost JSX element in an && chain.
150
+ * Example: `a && b && <Component />` returns <Component />
151
+ */
152
+ function findJsxInAndChain(expr) {
153
+ const unwrapped = unwrapExpression(expr);
154
+ if (ts.isJsxElement(unwrapped) || ts.isJsxSelfClosingElement(unwrapped)) {
155
+ return unwrapped;
156
+ }
157
+ if (ts.isBinaryExpression(unwrapped) &&
158
+ unwrapped.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {
159
+ // Check right side first (most common case: condition && <Jsx />)
160
+ const rightResult = findJsxInAndChain(unwrapped.right);
161
+ if (rightResult)
162
+ return rightResult;
163
+ // Also check left side for rare cases
164
+ return findJsxInAndChain(unwrapped.left);
165
+ }
166
+ return null;
167
+ }
168
+ /**
169
+ * Fix 32: Finds a JSX fragment in an && chain.
170
+ * Example: `activeTab && <><ChildA /><ChildB /></>` returns the fragment
171
+ * This is needed to propagate parent conditions through fragments.
172
+ */
173
+ function findJsxFragmentInAndChain(expr) {
174
+ const unwrapped = unwrapExpression(expr);
175
+ if (ts.isJsxFragment(unwrapped)) {
176
+ return unwrapped;
177
+ }
178
+ if (ts.isBinaryExpression(unwrapped) &&
179
+ unwrapped.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {
180
+ // Check right side first (most common case: condition && <></>)
181
+ const rightResult = findJsxFragmentInAndChain(unwrapped.right);
182
+ if (rightResult)
183
+ return rightResult;
184
+ // Also check left side for rare cases
185
+ return findJsxFragmentInAndChain(unwrapped.left);
186
+ }
187
+ return null;
188
+ }
189
+ /**
190
+ * Detects if a property access looks like an environment variable store access.
191
+ * Matches patterns like `env.DATABASE_URL`, `env.IS_FORMBRICKS_CLOUD`, etc.
192
+ * where the object is named "env" and the property looks like an env var name.
193
+ */
194
+ function isEnvStoreAccess(fullText) {
195
+ // Match: env.SOME_VAR or env.someVar (but object must be exactly "env")
196
+ // This catches patterns from @t3-oss/env-nextjs and similar packages
197
+ const envStorePattern = /^env\.[A-Z_][A-Z0-9_]*$/;
198
+ return envStorePattern.test(fullText);
199
+ }
200
+ /**
201
+ * Converts a call expression argument to a StructuredPath.
202
+ *
203
+ * IMPORTANT: We always use the original source text for callbacks, never cyScope names.
204
+ * cyScope names are internal identifiers for child scopes and should NEVER appear
205
+ * in schema paths or call signatures. Using cyScope names causes data merge conflicts
206
+ * because the same callback gets different identifiers in different contexts.
207
+ */
208
+ function getArgPathForCallSignature(arg, context) {
209
+ // Always use the standard path conversion - never replace with cyScope names
210
+ return (StructuredPath.fromNode(arg, context.sourceFile) ||
211
+ nodeToSource(arg, context.sourceFile));
212
+ }
213
+ /**
214
+ * Builds a StructuredPath for a call expression using the original source text.
215
+ *
216
+ * IMPORTANT: This function ensures consistent call signatures by always using
217
+ * the original callback text, never cyScope names. This prevents schema path
218
+ * conflicts where the same call would have different paths.
219
+ */
220
+ function buildCallPathFromSource(node, context) {
221
+ const expression = node.expression;
222
+ // Convert arguments using original source text
223
+ const argPaths = node.arguments.map((arg) => getArgPathForCallSignature(arg, context));
224
+ // Handle type arguments if present
225
+ let typeArgs = undefined;
226
+ if (node.typeArguments && node.typeArguments.length > 0) {
227
+ typeArgs = node.typeArguments.map((typeArg) => typeArg.getText(context.sourceFile));
228
+ }
229
+ if (ts.isIdentifier(expression)) {
230
+ // Simple function call: func(arg1, arg2)
231
+ return StructuredPath.fromFunction(expression.text, argPaths, typeArgs);
232
+ }
233
+ else if (ts.isPropertyAccessExpression(expression)) {
234
+ // Method call: obj.method(arg1, arg2)
235
+ const objPath = StructuredPath.fromNode(expression.expression, context.sourceFile);
236
+ if (!objPath)
237
+ return null;
238
+ return objPath
239
+ .withProperty(expression.name.text)
240
+ .withFunctionCall(argPaths, typeArgs);
241
+ }
242
+ else if (ts.isCallExpression(expression)) {
243
+ // Chained call: func(arg1)(arg2)
244
+ const funcPath = buildCallPathFromSource(expression, context);
245
+ if (!funcPath)
246
+ return null;
247
+ return funcPath.withFunctionCall(argPaths, typeArgs);
248
+ }
249
+ else if (ts.isElementAccessExpression(expression)) {
250
+ // Element access call: obj[key](args)
251
+ const basePath = StructuredPath.fromNode(expression, context.sourceFile);
252
+ if (!basePath)
253
+ return null;
254
+ return basePath.withFunctionCall(argPaths, typeArgs);
255
+ }
256
+ else {
257
+ // Complex call expression
258
+ const basePath = StructuredPath.fromNode(expression, context.sourceFile);
259
+ if (!basePath)
260
+ return null;
261
+ return basePath.withFunctionCall(argPaths, typeArgs);
262
+ }
263
+ }
7
264
  /**
8
265
  * Checks if an expression is likely an array type.
9
266
  * Uses TypeScript's type checker when available, falls back to heuristics.
@@ -81,102 +338,750 @@ export function markConditionVariablesAsNullable(condition, context) {
81
338
  }
82
339
  }
83
340
  /**
84
- * Extracts conditional usages from a condition expression for key attribute detection.
85
- * This function identifies which attributes are used in conditionals and how they're used.
341
+ * Helper to extract source location from an AST node
342
+ */
343
+ function getSourceLocation(node, sourceFile) {
344
+ const start = node.getStart(sourceFile);
345
+ const { line, character } = sourceFile.getLineAndCharacterOfPosition(start);
346
+ const codeSnippet = node.getText(sourceFile);
347
+ return {
348
+ lineNumber: line + 1, // Convert to 1-based
349
+ column: character,
350
+ codeSnippet: codeSnippet.length > 100
351
+ ? codeSnippet.slice(0, 100) + '...'
352
+ : codeSnippet,
353
+ };
354
+ }
355
+ /**
356
+ * Extracts the root array path from an expression that ends with .map().
357
+ * Handles chained methods like .filter().map(), .slice().map(), etc.
86
358
  *
87
- * @param condition The condition expression to analyze
359
+ * Examples:
360
+ * - items.map(...) → "items"
361
+ * - data.users.map(...) → "data.users"
362
+ * - items.filter(...).map(...) → "items"
363
+ * - items.slice(0, 5).map(...) → "items"
364
+ */
365
+ function extractArrayPathFromMapCall(expr, sourceFile) {
366
+ // Walk up the chain to find the root array
367
+ let current = expr.expression;
368
+ while (ts.isPropertyAccessExpression(current)) {
369
+ const methodName = current.name.getText(sourceFile);
370
+ // Common array methods that return arrays (so we keep going up)
371
+ const arrayReturningMethods = [
372
+ 'map',
373
+ 'filter',
374
+ 'slice',
375
+ 'concat',
376
+ 'flat',
377
+ 'flatMap',
378
+ 'reverse',
379
+ 'sort',
380
+ 'toReversed',
381
+ 'toSorted',
382
+ 'toSpliced',
383
+ ];
384
+ if (arrayReturningMethods.includes(methodName)) {
385
+ const objectExpr = current.expression;
386
+ // If the object is a call expression (chained method), keep going
387
+ if (ts.isCallExpression(objectExpr)) {
388
+ current = objectExpr.expression;
389
+ }
390
+ else {
391
+ // Found the root - it's an identifier or property access
392
+ const path = StructuredPath.fromNode(objectExpr, sourceFile);
393
+ return path ? path.toString() : null;
394
+ }
395
+ }
396
+ else {
397
+ // Not an array method we recognize
398
+ break;
399
+ }
400
+ }
401
+ return null;
402
+ }
403
+ /**
404
+ * Extracts JSX rendering usages from a JSX expression.
405
+ * Detects:
406
+ * - array.map() calls → 'array-map' type
407
+ * - string interpolations (identifiers/property access) → 'text-interpolation' type
408
+ *
409
+ * Recursively searches inside && chains and ternary expressions.
410
+ *
411
+ * @param expr The expression inside {expr}
88
412
  * @param context The analysis context
89
- * @param location Where this condition appears (if, ternary, logical-and, switch)
90
413
  */
91
- export function extractConditionalUsage(condition, context, location) {
92
- const unwrapped = unwrapExpression(condition);
93
- // Handle binary expressions with && (logical AND chains)
94
- // Example: `a && b && <Component />` - both a and b are conditional checks
414
+ function extractJsxRenderingUsage(expr, context) {
415
+ const unwrapped = unwrapExpression(expr);
416
+ const sourceLocation = getSourceLocation(expr, context.sourceFile);
417
+ // Detect array.map() calls
418
+ if (ts.isCallExpression(unwrapped)) {
419
+ const calleeExpr = unwrapped.expression;
420
+ if (ts.isPropertyAccessExpression(calleeExpr)) {
421
+ const methodName = calleeExpr.name.getText(context.sourceFile);
422
+ if (methodName === 'map') {
423
+ const arrayPath = extractArrayPathFromMapCall(unwrapped, context.sourceFile);
424
+ if (arrayPath) {
425
+ context.addJsxRenderingUsage({
426
+ path: arrayPath,
427
+ renderingType: 'array-map',
428
+ valueType: 'array',
429
+ sourceLocation,
430
+ });
431
+ }
432
+ }
433
+ }
434
+ }
435
+ // Detect simple string interpolations: {title} or {user.name}
436
+ else if (ts.isIdentifier(unwrapped) ||
437
+ ts.isPropertyAccessExpression(unwrapped)) {
438
+ const path = StructuredPath.fromNode(unwrapped, context.sourceFile);
439
+ if (path) {
440
+ const pathStr = path.toString();
441
+ const typeInfo = context.getTypeInfo(path);
442
+ // Only track as text interpolation if it's a string type
443
+ // Check for 'string' type, or types that contain 'string' (but not 'string[]')
444
+ if (typeInfo === 'string' ||
445
+ (typeInfo &&
446
+ typeInfo.includes('string') &&
447
+ !typeInfo.includes('string[]'))) {
448
+ context.addJsxRenderingUsage({
449
+ path: pathStr,
450
+ renderingType: 'text-interpolation',
451
+ valueType: 'string',
452
+ sourceLocation,
453
+ });
454
+ }
455
+ }
456
+ }
457
+ // Recursively search inside && chains: {showList && items.map(...)}
458
+ else if (ts.isBinaryExpression(unwrapped) &&
459
+ unwrapped.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {
460
+ // Check the right side of the && chain (where .map() typically appears)
461
+ const rightSide = unwrapExpression(unwrapped.right);
462
+ extractJsxRenderingUsage(rightSide, context);
463
+ // Also check nested && chains on the left
464
+ extractJsxRenderingUsage(unwrapped.left, context);
465
+ }
466
+ // Recursively search inside ternaries: {isEmpty ? null : items.map(...)}
467
+ else if (ts.isConditionalExpression(unwrapped)) {
468
+ extractJsxRenderingUsage(unwrapped.whenTrue, context);
469
+ extractJsxRenderingUsage(unwrapped.whenFalse, context);
470
+ }
471
+ }
472
+ /**
473
+ * Counts the number of conditions in an && chain (excluding JSX consequence)
474
+ */
475
+ function countConditionsInAndChain(expr) {
476
+ const unwrapped = unwrapExpression(expr);
95
477
  if (ts.isBinaryExpression(unwrapped) &&
96
478
  unwrapped.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {
97
- // Recursively process left side
98
- extractConditionalUsage(unwrapped.left, context, location);
99
- // Process right side if it's not JSX (JSX is the consequence, not the condition)
479
+ const leftCount = countConditionsInAndChain(unwrapped.left);
100
480
  const rightUnwrapped = unwrapExpression(unwrapped.right);
101
481
  const isJsxConsequence = ts.isJsxElement(rightUnwrapped) ||
102
482
  ts.isJsxSelfClosingElement(rightUnwrapped) ||
103
483
  ts.isJsxFragment(rightUnwrapped);
104
- if (!isJsxConsequence) {
105
- extractConditionalUsage(unwrapped.right, context, location);
484
+ if (isJsxConsequence) {
485
+ return leftCount;
106
486
  }
107
- return;
487
+ return leftCount + countConditionsInAndChain(unwrapped.right);
108
488
  }
109
- // Handle binary expressions with || (logical OR)
110
- if (ts.isBinaryExpression(unwrapped) &&
111
- unwrapped.operatorToken.kind === ts.SyntaxKind.BarBarToken) {
112
- // Both sides of || are conditional checks
113
- extractConditionalUsage(unwrapped.left, context, location);
114
- extractConditionalUsage(unwrapped.right, context, location);
489
+ // Single condition (not an && chain)
490
+ return 1;
491
+ }
492
+ /**
493
+ * Extracts conditionals from JSX elements by recursively traversing children.
494
+ *
495
+ * This is CRITICAL for extracting compound conditionals from JSX expressions
496
+ * like `{hasNewerVersion && !isActive && <Banner />}`.
497
+ *
498
+ * This function is called BEFORE the child boundary check in processExpression
499
+ * because JSX elements are NOT scopes - their expressions use variables from
500
+ * the parent scope and should have their conditionals extracted regardless of
501
+ * whether the JSX is within a child boundary.
502
+ *
503
+ * Fix 32: Added parentConditions parameter to track gating conditions from
504
+ * parent && chains. When we find a component nested inside multiple conditionals
505
+ * like `{activeTab && <>{ternary ? ... : <Component />}</>}`, ALL parent
506
+ * conditions should be added as gating conditions for the component.
507
+ *
508
+ * @param node The JSX element, self-closing element, or fragment to traverse
509
+ * @param context The analysis context
510
+ * @param parentConditions Accumulated gating conditions from parent && chains
511
+ */
512
+ function extractConditionalsFromJsx(node, context, parentConditions = []) {
513
+ // Get children to process
514
+ let children;
515
+ if (ts.isJsxElement(node)) {
516
+ children = node.children;
517
+ }
518
+ else if (ts.isJsxFragment(node)) {
519
+ children = node.children;
520
+ }
521
+ // JsxSelfClosingElement has no children
522
+ if (!children) {
115
523
  return;
116
524
  }
117
- // Handle comparison operators (===, !==, <, >, <=, >=)
118
- // Example: `if (status === 'active')` - status is compared against 'active'
119
- if (ts.isBinaryExpression(unwrapped) &&
120
- isComparisonOperator(unwrapped.operatorToken.kind)) {
121
- // Try to extract the variable and the compared value
122
- const leftPath = StructuredPath.fromNode(unwrapped.left, context.sourceFile);
123
- const rightPath = StructuredPath.fromNode(unwrapped.right, context.sourceFile);
124
- // Check if left is a variable and right is a literal
125
- if (leftPath && isLiteralExpression(unwrapped.right)) {
126
- const literalValue = getLiteralValue(unwrapped.right, context);
127
- context.addConditionalUsage({
128
- path: leftPath.toLeftHandSideString(),
129
- conditionType: 'comparison',
130
- comparedValues: literalValue !== undefined ? [literalValue] : undefined,
131
- location,
132
- });
525
+ for (const child of children) {
526
+ // Process JSX expressions: {expr}
527
+ if (ts.isJsxExpression(child) && child.expression) {
528
+ const expr = unwrapExpression(child.expression);
529
+ // Extract JSX rendering usages (array.map, text interpolation)
530
+ // This handles direct usages like {items.map(...)} or {user.name}
531
+ extractJsxRenderingUsage(expr, context);
532
+ // If the expression is an && chain, extract its conditional usages
533
+ if (ts.isBinaryExpression(expr) &&
534
+ expr.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {
535
+ // Mark nullable variables
536
+ markConditionVariablesAsNullable(expr, context);
537
+ // Extract conditional usage (this handles compound conditionals)
538
+ // Pass controlsJsxRendering: true since this conditional controls JSX rendering
539
+ extractConditionalUsage(expr, context, 'logical-and', {
540
+ controlsJsxRendering: true,
541
+ });
542
+ // Extract all condition paths from the && chain for gating tracking
543
+ const conditionPaths = extractConditionPathsFromAndChain(expr, context.sourceFile);
544
+ const sourceLocation = getSourceLocation(expr, context.sourceFile);
545
+ // Fix 32: Build accumulated conditions including parent conditions
546
+ const accumulatedConditions = [
547
+ ...parentConditions,
548
+ ...conditionPaths.map((path) => ({
549
+ path,
550
+ sourceLocation,
551
+ isNegated: false,
552
+ })),
553
+ ];
554
+ // Track gating conditions for child components
555
+ // Example: {hasAnalysis && <ScenarioViewer />}
556
+ const jsxElement = findJsxInAndChain(expr);
557
+ if (jsxElement) {
558
+ const componentName = getComponentNameFromJsx(jsxElement);
559
+ if (componentName) {
560
+ // Fix 32: Add ALL accumulated conditions (parent + current) as gating conditions
561
+ for (const condition of accumulatedConditions) {
562
+ context.addChildBoundaryGatingCondition(componentName, {
563
+ path: condition.path,
564
+ conditionType: 'truthiness',
565
+ location: 'logical-and',
566
+ sourceLocation: condition.sourceLocation,
567
+ controlsJsxRendering: true,
568
+ isNegated: condition.isNegated,
569
+ });
570
+ }
571
+ }
572
+ // Fix 32: Recursively process nested JSX with accumulated conditions
573
+ if (ts.isJsxElement(jsxElement) ||
574
+ ts.isJsxSelfClosingElement(jsxElement)) {
575
+ extractConditionalsFromJsx(jsxElement, context, accumulatedConditions);
576
+ }
577
+ }
578
+ // Fix 32: Also check for nested JSX fragments
579
+ const jsxFragment = findJsxFragmentInAndChain(expr);
580
+ if (jsxFragment) {
581
+ extractConditionalsFromJsx(jsxFragment, context, accumulatedConditions);
582
+ }
583
+ }
584
+ // If the expression is a ternary, extract its conditional
585
+ else if (ts.isConditionalExpression(expr)) {
586
+ // Pass controlsJsxRendering: true since this conditional controls JSX rendering
587
+ extractConditionalUsage(expr.condition, context, 'ternary', {
588
+ controlsJsxRendering: true,
589
+ });
590
+ // Track gating conditions for components in both branches of the ternary
591
+ // Example: {isError ? <ErrorView /> : <SuccessView />}
592
+ const conditionPath = StructuredPath.fromNode(unwrapExpression(expr.condition), context.sourceFile);
593
+ const sourceLocation = getSourceLocation(expr, context.sourceFile);
594
+ // Recursively process the whenTrue and whenFalse branches for JSX
595
+ const whenTrue = unwrapExpression(expr.whenTrue);
596
+ const whenFalse = unwrapExpression(expr.whenFalse);
597
+ // Fix 32: Build conditions for whenTrue branch (parent conditions + ternary condition truthy)
598
+ const whenTrueConditions = [
599
+ ...parentConditions,
600
+ ...(conditionPath
601
+ ? [
602
+ {
603
+ path: conditionPath.toString(),
604
+ sourceLocation,
605
+ isNegated: false,
606
+ },
607
+ ]
608
+ : []),
609
+ ];
610
+ // Fix 32: Build conditions for whenFalse branch (parent conditions + ternary condition falsy)
611
+ const whenFalseConditions = [
612
+ ...parentConditions,
613
+ ...(conditionPath
614
+ ? [
615
+ {
616
+ path: conditionPath.toString(),
617
+ sourceLocation,
618
+ isNegated: true,
619
+ },
620
+ ]
621
+ : []),
622
+ ];
623
+ // Handle whenTrue branch (condition is truthy)
624
+ if (ts.isJsxElement(whenTrue) || ts.isJsxSelfClosingElement(whenTrue)) {
625
+ const componentName = getComponentNameFromJsx(whenTrue);
626
+ if (componentName) {
627
+ // Fix 32: Add ALL conditions (parent + ternary) as gating conditions
628
+ for (const condition of whenTrueConditions) {
629
+ context.addChildBoundaryGatingCondition(componentName, {
630
+ path: condition.path,
631
+ conditionType: 'truthiness',
632
+ location: 'ternary',
633
+ sourceLocation: condition.sourceLocation,
634
+ controlsJsxRendering: true,
635
+ isNegated: condition.isNegated,
636
+ });
637
+ }
638
+ }
639
+ }
640
+ if (ts.isJsxElement(whenTrue) ||
641
+ ts.isJsxSelfClosingElement(whenTrue) ||
642
+ ts.isJsxFragment(whenTrue)) {
643
+ extractConditionalsFromJsx(whenTrue, context, whenTrueConditions);
644
+ }
645
+ // Handle whenFalse branch (condition is falsy/negated)
646
+ if (ts.isJsxElement(whenFalse) ||
647
+ ts.isJsxSelfClosingElement(whenFalse)) {
648
+ const componentName = getComponentNameFromJsx(whenFalse);
649
+ if (componentName) {
650
+ // Fix 32: Add ALL conditions (parent + ternary) as gating conditions
651
+ for (const condition of whenFalseConditions) {
652
+ context.addChildBoundaryGatingCondition(componentName, {
653
+ path: condition.path,
654
+ conditionType: 'truthiness',
655
+ location: 'ternary',
656
+ sourceLocation: condition.sourceLocation,
657
+ controlsJsxRendering: true,
658
+ isNegated: condition.isNegated,
659
+ });
660
+ }
661
+ }
662
+ }
663
+ if (ts.isJsxElement(whenFalse) ||
664
+ ts.isJsxSelfClosingElement(whenFalse) ||
665
+ ts.isJsxFragment(whenFalse)) {
666
+ extractConditionalsFromJsx(whenFalse, context, whenFalseConditions);
667
+ }
668
+ // Handle chained ternaries: a ? <A/> : b ? <B/> : <C/>
669
+ // When whenFalse is another ConditionalExpression, recursively process it
670
+ else if (ts.isConditionalExpression(whenFalse)) {
671
+ // Extract conditional usage for the nested ternary's condition
672
+ extractConditionalUsage(whenFalse.condition, context, 'ternary', {
673
+ controlsJsxRendering: true,
674
+ });
675
+ // Get the nested condition path
676
+ const nestedConditionPath = StructuredPath.fromNode(unwrapExpression(whenFalse.condition), context.sourceFile);
677
+ const nestedSourceLocation = getSourceLocation(whenFalse, context.sourceFile);
678
+ const nestedWhenTrue = unwrapExpression(whenFalse.whenTrue);
679
+ const nestedWhenFalse = unwrapExpression(whenFalse.whenFalse);
680
+ // Fix 32: Build conditions for nested whenTrue (parent falsy + nested truthy)
681
+ const nestedWhenTrueConditions = [
682
+ ...whenFalseConditions, // Parent ternary was falsy to get here
683
+ ...(nestedConditionPath
684
+ ? [
685
+ {
686
+ path: nestedConditionPath.toString(),
687
+ sourceLocation: nestedSourceLocation,
688
+ isNegated: false,
689
+ },
690
+ ]
691
+ : []),
692
+ ];
693
+ // Fix 32: Build conditions for nested whenFalse (parent falsy + nested falsy)
694
+ const nestedWhenFalseConditions = [
695
+ ...whenFalseConditions, // Parent ternary was falsy to get here
696
+ ...(nestedConditionPath
697
+ ? [
698
+ {
699
+ path: nestedConditionPath.toString(),
700
+ sourceLocation: nestedSourceLocation,
701
+ isNegated: true,
702
+ },
703
+ ]
704
+ : []),
705
+ ];
706
+ // Handle nested whenTrue branch
707
+ if (ts.isJsxElement(nestedWhenTrue) ||
708
+ ts.isJsxSelfClosingElement(nestedWhenTrue)) {
709
+ const componentName = getComponentNameFromJsx(nestedWhenTrue);
710
+ if (componentName) {
711
+ // Fix 32: Add ALL accumulated conditions
712
+ for (const condition of nestedWhenTrueConditions) {
713
+ context.addChildBoundaryGatingCondition(componentName, {
714
+ path: condition.path,
715
+ conditionType: 'truthiness',
716
+ location: 'ternary',
717
+ sourceLocation: condition.sourceLocation,
718
+ controlsJsxRendering: true,
719
+ isNegated: condition.isNegated,
720
+ });
721
+ }
722
+ }
723
+ }
724
+ if (ts.isJsxElement(nestedWhenTrue) ||
725
+ ts.isJsxSelfClosingElement(nestedWhenTrue) ||
726
+ ts.isJsxFragment(nestedWhenTrue)) {
727
+ extractConditionalsFromJsx(nestedWhenTrue, context, nestedWhenTrueConditions);
728
+ }
729
+ // Handle nested whenFalse branch (this could be another chained ternary or JSX)
730
+ if (ts.isJsxElement(nestedWhenFalse) ||
731
+ ts.isJsxSelfClosingElement(nestedWhenFalse)) {
732
+ const componentName = getComponentNameFromJsx(nestedWhenFalse);
733
+ if (componentName) {
734
+ // Fix 32: Add ALL accumulated conditions
735
+ for (const condition of nestedWhenFalseConditions) {
736
+ context.addChildBoundaryGatingCondition(componentName, {
737
+ path: condition.path,
738
+ conditionType: 'truthiness',
739
+ location: 'ternary',
740
+ sourceLocation: condition.sourceLocation,
741
+ controlsJsxRendering: true,
742
+ isNegated: condition.isNegated,
743
+ });
744
+ }
745
+ }
746
+ }
747
+ if (ts.isJsxElement(nestedWhenFalse) ||
748
+ ts.isJsxSelfClosingElement(nestedWhenFalse) ||
749
+ ts.isJsxFragment(nestedWhenFalse)) {
750
+ extractConditionalsFromJsx(nestedWhenFalse, context, nestedWhenFalseConditions);
751
+ }
752
+ // If nestedWhenFalse is yet another ConditionalExpression, the recursion
753
+ // will handle it on the next iteration when this function processes it
754
+ else if (ts.isConditionalExpression(nestedWhenFalse)) {
755
+ // Recursively handle deeper nesting by wrapping in a synthetic process
756
+ // We create a fake JsxExpression context to reuse the same logic
757
+ const syntheticChild = {
758
+ kind: ts.SyntaxKind.JsxExpression,
759
+ expression: nestedWhenFalse,
760
+ };
761
+ // Process via the main JSX expression handler by recursing
762
+ // For now, just extract conditionals directly
763
+ extractConditionalUsage(nestedWhenFalse.condition, context, 'ternary', { controlsJsxRendering: true });
764
+ }
765
+ }
766
+ }
767
+ }
768
+ // Recursively process nested JSX elements - Fix 32: pass parent conditions
769
+ else if (ts.isJsxElement(child)) {
770
+ // Check if this is a user-defined component (vs intrinsic element like div)
771
+ const componentName = getComponentNameFromJsx(child);
772
+ if (componentName) {
773
+ if (parentConditions.length > 0) {
774
+ // If there are parent conditions, record them as gating conditions
775
+ console.log(`[ChildBoundary] ${componentName}: Conditionally rendered with ${parentConditions.length} gating conditions`);
776
+ for (const condition of parentConditions) {
777
+ console.log(`[ChildBoundary] ${componentName}: Adding gating condition path='${condition.path}' isNegated=${condition.isNegated}`);
778
+ context.addChildBoundaryGatingCondition(componentName, {
779
+ path: condition.path,
780
+ conditionType: 'truthiness',
781
+ location: 'ternary',
782
+ sourceLocation: condition.sourceLocation,
783
+ controlsJsxRendering: true,
784
+ isNegated: condition.isNegated,
785
+ });
786
+ }
787
+ }
788
+ else {
789
+ // No parent conditions - check if it has data props for unconditional tracking
790
+ console.log(`[ChildBoundary] ${componentName}: Checking for unconditional rendering with data props...`);
791
+ const { hasDataProps, dataProps } = hasDataPropsFromParent(child, componentName);
792
+ if (hasDataProps) {
793
+ // Fix: Track unconditionally-rendered children that receive data props
794
+ // These need to be tracked for flow merging even without gating conditions
795
+ // Example: <WorkoutsView workouts={workouts} /> - parent controls workouts data
796
+ console.log(`[ChildBoundary] ${componentName}: TRACKING as unconditionally-rendered with data props: [${dataProps.join(', ')}]`);
797
+ context.addChildBoundaryGatingCondition(componentName, {
798
+ path: '__unconditional__',
799
+ conditionType: 'truthiness',
800
+ location: 'unconditional',
801
+ controlsJsxRendering: true,
802
+ isNegated: false,
803
+ });
804
+ }
805
+ }
806
+ }
807
+ extractConditionalsFromJsx(child, context, parentConditions);
808
+ }
809
+ // Handle self-closing JSX elements (e.g., <ScenarioViewer />)
810
+ else if (ts.isJsxSelfClosingElement(child)) {
811
+ // Check if this is a user-defined component (vs intrinsic element like div)
812
+ const componentName = getComponentNameFromJsx(child);
813
+ if (componentName) {
814
+ if (parentConditions.length > 0) {
815
+ // If there are parent conditions, record them as gating conditions
816
+ console.log(`[ChildBoundary] ${componentName}: Conditionally rendered (self-closing) with ${parentConditions.length} gating conditions`);
817
+ for (const condition of parentConditions) {
818
+ console.log(`[ChildBoundary] ${componentName}: Adding gating condition path='${condition.path}' isNegated=${condition.isNegated}`);
819
+ context.addChildBoundaryGatingCondition(componentName, {
820
+ path: condition.path,
821
+ conditionType: 'truthiness',
822
+ location: 'ternary',
823
+ sourceLocation: condition.sourceLocation,
824
+ controlsJsxRendering: true,
825
+ isNegated: condition.isNegated,
826
+ });
827
+ }
828
+ }
829
+ else {
830
+ // No parent conditions - check if it has data props for unconditional tracking
831
+ console.log(`[ChildBoundary] ${componentName}: Checking for unconditional rendering (self-closing) with data props...`);
832
+ const { hasDataProps, dataProps } = hasDataPropsFromParent(child, componentName);
833
+ if (hasDataProps) {
834
+ // Fix: Track unconditionally-rendered children that receive data props
835
+ console.log(`[ChildBoundary] ${componentName}: TRACKING as unconditionally-rendered (self-closing) with data props: [${dataProps.join(', ')}]`);
836
+ context.addChildBoundaryGatingCondition(componentName, {
837
+ path: '__unconditional__',
838
+ conditionType: 'truthiness',
839
+ location: 'unconditional',
840
+ controlsJsxRendering: true,
841
+ isNegated: false,
842
+ });
843
+ }
844
+ }
845
+ }
846
+ // Self-closing elements have no children, so no recursion needed
847
+ }
848
+ // Recursively process nested JSX fragments - Fix 32: pass parent conditions
849
+ else if (ts.isJsxFragment(child)) {
850
+ extractConditionalsFromJsx(child, context, parentConditions);
851
+ }
852
+ }
853
+ }
854
+ /**
855
+ * Extracts conditional usages from a condition expression for key attribute detection.
856
+ * This function identifies which attributes are used in conditionals and how they're used.
857
+ * It also tracks compound conditionals (&&-chains) where all conditions must be true together.
858
+ *
859
+ * @param condition The condition expression to analyze
860
+ * @param context The analysis context
861
+ * @param location Where this condition appears (if, ternary, logical-and, switch)
862
+ * @param options Additional options including controlsJsxRendering flag
863
+ */
864
+ export function extractConditionalUsage(condition, context, location, options = {}) {
865
+ const { controlsJsxRendering } = options;
866
+ // Internal recursive function with chain tracking
867
+ function extractWithChainTracking(expr, chainInfo, isNegated) {
868
+ const unwrapped = unwrapExpression(expr);
869
+ // Handle binary expressions with && (logical AND chains)
870
+ // Example: `a && b && <Component />` - both a and b are conditional checks
871
+ if (ts.isBinaryExpression(unwrapped) &&
872
+ unwrapped.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {
873
+ // Track if we're creating the chain at this level (root of the chain)
874
+ const isChainRoot = !chainInfo;
875
+ // If no chainInfo, this is the root of a new chain
876
+ if (isChainRoot) {
877
+ const chainLength = countConditionsInAndChain(unwrapped);
878
+ // Only create chain tracking for chains with 2+ conditions
879
+ if (chainLength >= 2) {
880
+ const chainId = `chain_${crypto.randomUUID().slice(0, 8)}`;
881
+ const chainExpression = unwrapped.getText(context.sourceFile);
882
+ const compound = {
883
+ chainId,
884
+ expression: chainExpression.length > 200
885
+ ? chainExpression.slice(0, 200) + '...'
886
+ : chainExpression,
887
+ conditions: [],
888
+ location,
889
+ sourceLocation: getSourceLocation(unwrapped, context.sourceFile),
890
+ controlsJsxRendering,
891
+ };
892
+ chainInfo = {
893
+ chainId,
894
+ chainLength,
895
+ chainExpression: compound.expression,
896
+ currentPosition: 0,
897
+ compound,
898
+ };
899
+ }
900
+ }
901
+ // Recursively process left side
902
+ extractWithChainTracking(unwrapped.left, chainInfo, false);
903
+ // Process right side if it's not JSX (JSX is the consequence, not the condition)
904
+ const rightUnwrapped = unwrapExpression(unwrapped.right);
905
+ const isJsxConsequence = ts.isJsxElement(rightUnwrapped) ||
906
+ ts.isJsxSelfClosingElement(rightUnwrapped) ||
907
+ ts.isJsxFragment(rightUnwrapped);
908
+ if (!isJsxConsequence) {
909
+ extractWithChainTracking(unwrapped.right, chainInfo, false);
910
+ }
911
+ // If this is the root of the chain, register the compound conditional
912
+ if (isChainRoot && chainInfo) {
913
+ context.addCompoundConditional(chainInfo.compound);
914
+ }
133
915
  return;
134
916
  }
135
- // Check if right is a variable and left is a literal
136
- if (rightPath && isLiteralExpression(unwrapped.left)) {
137
- const literalValue = getLiteralValue(unwrapped.left, context);
138
- context.addConditionalUsage({
139
- path: rightPath.toLeftHandSideString(),
140
- conditionType: 'comparison',
141
- comparedValues: literalValue !== undefined ? [literalValue] : undefined,
142
- location,
143
- });
917
+ // Handle binary expressions with || (logical OR)
918
+ // When OR is inside an && chain, we need to continue chain tracking
919
+ // and mark conditions as OR alternatives
920
+ if (ts.isBinaryExpression(unwrapped) &&
921
+ unwrapped.operatorToken.kind === ts.SyntaxKind.BarBarToken) {
922
+ if (chainInfo) {
923
+ // We're inside an && chain - continue tracking but mark as OR alternatives
924
+ // Generate an orGroupId so conditions from both sides can be grouped
925
+ const orGroupId = chainInfo.currentOrGroupId ?? `or_${crypto.randomUUID().slice(0, 8)}`;
926
+ // Process left side with OR group tracking
927
+ const leftChainInfo = {
928
+ ...chainInfo,
929
+ currentOrGroupId: orGroupId,
930
+ };
931
+ extractWithChainTracking(unwrapped.left, leftChainInfo, false);
932
+ // Process right side with same OR group
933
+ // Note: we use leftChainInfo's currentPosition which may have been updated
934
+ const rightChainInfo = {
935
+ ...leftChainInfo,
936
+ currentPosition: chainInfo.currentPosition,
937
+ };
938
+ extractWithChainTracking(unwrapped.right, rightChainInfo, false);
939
+ }
940
+ else {
941
+ // Not inside a chain - OR breaks into independent conditional checks
942
+ extractWithChainTracking(unwrapped.left, null, false);
943
+ extractWithChainTracking(unwrapped.right, null, false);
944
+ }
144
945
  return;
145
946
  }
146
- // Both sides are variables - record both as comparisons without specific values
147
- if (leftPath) {
148
- context.addConditionalUsage({
149
- path: leftPath.toLeftHandSideString(),
150
- conditionType: 'comparison',
151
- location,
152
- });
947
+ // Handle comparison operators (===, !==, <, >, <=, >=)
948
+ // Example: `if (status === 'active')` - status is compared against 'active'
949
+ if (ts.isBinaryExpression(unwrapped) &&
950
+ isComparisonOperator(unwrapped.operatorToken.kind)) {
951
+ // Try to extract the variable and the compared value
952
+ const leftPath = StructuredPath.fromNode(unwrapped.left, context.sourceFile);
953
+ const rightPath = StructuredPath.fromNode(unwrapped.right, context.sourceFile);
954
+ // Determine the compared value for computing requiredValue
955
+ const getRequiredValue = (literalValue, isNegatedComparison) => {
956
+ if (literalValue === undefined)
957
+ return undefined;
958
+ // For !== comparisons, the condition is true when NOT equal to the value
959
+ // For === comparisons, the condition is true when equal to the value
960
+ const isNotEqual = unwrapped.operatorToken.kind ===
961
+ ts.SyntaxKind.ExclamationEqualsEqualsToken ||
962
+ unwrapped.operatorToken.kind === ts.SyntaxKind.ExclamationEqualsToken;
963
+ if (isNotEqual) {
964
+ // !== 'value' means requiredValue is NOT 'value', but we express this as "not 'value'"
965
+ return `not ${literalValue}`;
966
+ }
967
+ return literalValue;
968
+ };
969
+ // Helper to add a condition
970
+ const addCondition = (path, conditionType, comparedValues, requiredValue, sourceExpr) => {
971
+ const usage = {
972
+ path,
973
+ conditionType,
974
+ comparedValues,
975
+ location,
976
+ sourceLocation: getSourceLocation(unwrapped, context.sourceFile),
977
+ isNegated,
978
+ controlsJsxRendering,
979
+ };
980
+ // Check for inline array-derived patterns (.length) on the source expression
981
+ if (sourceExpr) {
982
+ const arrayDerived = detectArrayDerivedPattern(sourceExpr);
983
+ if (arrayDerived) {
984
+ usage.derivedFrom = {
985
+ operation: arrayDerived.operation,
986
+ sourcePath: arrayDerived.sourcePath,
987
+ };
988
+ }
989
+ }
990
+ // Add chain info if part of a compound conditional
991
+ if (chainInfo) {
992
+ usage.chainId = chainInfo.chainId;
993
+ usage.chainPosition = chainInfo.currentPosition;
994
+ usage.chainLength = chainInfo.chainLength;
995
+ usage.chainExpression = chainInfo.chainExpression;
996
+ chainInfo.currentPosition++;
997
+ // Add to compound conditional conditions
998
+ chainInfo.compound.conditions.push({
999
+ path,
1000
+ conditionType,
1001
+ comparedValues,
1002
+ isNegated,
1003
+ requiredValue,
1004
+ ...(chainInfo.currentOrGroupId && {
1005
+ orGroupId: chainInfo.currentOrGroupId,
1006
+ }),
1007
+ });
1008
+ }
1009
+ context.addConditionalUsage(usage);
1010
+ };
1011
+ // Check if left is a variable and right is a literal
1012
+ if (leftPath && isLiteralExpression(unwrapped.right)) {
1013
+ const literalValue = getLiteralValue(unwrapped.right, context);
1014
+ addCondition(leftPath.toLeftHandSideString(), 'comparison', literalValue !== undefined ? [literalValue] : undefined, getRequiredValue(literalValue, isNegated), unwrapped.left);
1015
+ return;
1016
+ }
1017
+ // Check if right is a variable and left is a literal
1018
+ if (rightPath && isLiteralExpression(unwrapped.left)) {
1019
+ const literalValue = getLiteralValue(unwrapped.left, context);
1020
+ addCondition(rightPath.toLeftHandSideString(), 'comparison', literalValue !== undefined ? [literalValue] : undefined, getRequiredValue(literalValue, isNegated), unwrapped.right);
1021
+ return;
1022
+ }
1023
+ // Both sides are variables - record both as comparisons without specific values
1024
+ if (leftPath) {
1025
+ addCondition(leftPath.toLeftHandSideString(), 'comparison', undefined, undefined, unwrapped.left);
1026
+ }
1027
+ if (rightPath) {
1028
+ addCondition(rightPath.toLeftHandSideString(), 'comparison', undefined, undefined, unwrapped.right);
1029
+ }
1030
+ return;
1031
+ }
1032
+ // Handle prefix unary NOT expression: !variable
1033
+ // Example: `if (!isVisible)` - isVisible is a truthiness check (negated)
1034
+ if (ts.isPrefixUnaryExpression(unwrapped) &&
1035
+ unwrapped.operator === ts.SyntaxKind.ExclamationToken) {
1036
+ extractWithChainTracking(unwrapped.operand, chainInfo, !isNegated);
1037
+ return;
153
1038
  }
154
- if (rightPath) {
155
- context.addConditionalUsage({
156
- path: rightPath.toLeftHandSideString(),
157
- conditionType: 'comparison',
1039
+ // Handle simple identifiers or property accesses (truthiness checks)
1040
+ // Example: `if (x)` or `x && <JSX />` - x is checked for truthiness
1041
+ const path = StructuredPath.fromNode(unwrapped, context.sourceFile);
1042
+ if (path && !path.isLiteral()) {
1043
+ const pathStr = path.toLeftHandSideString();
1044
+ const usage = {
1045
+ path: pathStr,
1046
+ conditionType: 'truthiness',
158
1047
  location,
159
- });
1048
+ sourceLocation: getSourceLocation(unwrapped, context.sourceFile),
1049
+ isNegated,
1050
+ controlsJsxRendering,
1051
+ };
1052
+ // Check for inline array-derived patterns (.some(), .every(), .includes(), .length)
1053
+ // This populates derivedFrom so downstream code can resolve to the base array path
1054
+ const arrayDerived = detectArrayDerivedPattern(unwrapped);
1055
+ if (arrayDerived) {
1056
+ usage.derivedFrom = {
1057
+ operation: arrayDerived.operation,
1058
+ sourcePath: arrayDerived.sourcePath,
1059
+ };
1060
+ }
1061
+ // Add chain info if part of a compound conditional
1062
+ if (chainInfo) {
1063
+ usage.chainId = chainInfo.chainId;
1064
+ usage.chainPosition = chainInfo.currentPosition;
1065
+ usage.chainLength = chainInfo.chainLength;
1066
+ usage.chainExpression = chainInfo.chainExpression;
1067
+ chainInfo.currentPosition++;
1068
+ // Add to compound conditional conditions
1069
+ // For truthiness, requiredValue is true if not negated, false if negated
1070
+ chainInfo.compound.conditions.push({
1071
+ path: pathStr,
1072
+ conditionType: 'truthiness',
1073
+ isNegated,
1074
+ requiredValue: !isNegated,
1075
+ ...(chainInfo.currentOrGroupId && {
1076
+ orGroupId: chainInfo.currentOrGroupId,
1077
+ }),
1078
+ });
1079
+ }
1080
+ context.addConditionalUsage(usage);
160
1081
  }
161
- return;
162
- }
163
- // Handle prefix unary NOT expression: !variable
164
- // Example: `if (!isVisible)` - isVisible is a truthiness check
165
- if (ts.isPrefixUnaryExpression(unwrapped) &&
166
- unwrapped.operator === ts.SyntaxKind.ExclamationToken) {
167
- extractConditionalUsage(unwrapped.operand, context, location);
168
- return;
169
- }
170
- // Handle simple identifiers or property accesses (truthiness checks)
171
- // Example: `if (x)` or `x && <JSX />` - x is checked for truthiness
172
- const path = StructuredPath.fromNode(unwrapped, context.sourceFile);
173
- if (path && !path.isLiteral()) {
174
- context.addConditionalUsage({
175
- path: path.toLeftHandSideString(),
176
- conditionType: 'truthiness',
177
- location,
178
- });
179
1082
  }
1083
+ // Start extraction with no chain info
1084
+ extractWithChainTracking(condition, null, false);
180
1085
  }
181
1086
  /**
182
1087
  * Helper to check if an expression is a literal value
@@ -254,7 +1159,24 @@ export function processExpression({ node, context, targetPath, typeHint, }) {
254
1159
  unwrappedNode.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {
255
1160
  markConditionVariablesAsNullable(unwrappedNode, context);
256
1161
  // Extract conditional usages for key attribute detection
257
- extractConditionalUsage(unwrappedNode, context, 'logical-and');
1162
+ // Only call from the OUTERMOST && expression to avoid duplicates
1163
+ // Check if parent is also a && (meaning we're nested)
1164
+ const parent = unwrappedNode.parent;
1165
+ const parentIsAndChain = parent &&
1166
+ ts.isBinaryExpression(parent) &&
1167
+ parent.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken;
1168
+ if (!parentIsAndChain) {
1169
+ extractConditionalUsage(unwrappedNode, context, 'logical-and');
1170
+ }
1171
+ }
1172
+ // CRITICAL: Extract conditionals from JSX BEFORE checking child boundaries
1173
+ // JSX elements are NOT scopes - their expressions use variables from the parent scope.
1174
+ // Even if the JSX element is within a child boundary (e.g., because it contains callbacks),
1175
+ // we must still extract conditionals from JSX expression children like {x && <div>...</div>}
1176
+ if (ts.isJsxElement(unwrappedNode) ||
1177
+ ts.isJsxSelfClosingElement(unwrappedNode) ||
1178
+ ts.isJsxFragment(unwrappedNode)) {
1179
+ extractConditionalsFromJsx(unwrappedNode, context);
258
1180
  }
259
1181
  // If the node falls within an excluded child scope, stop processing it.
260
1182
  if (context.isChildBoundary(node)) {
@@ -284,15 +1206,21 @@ export function processExpression({ node, context, targetPath, typeHint, }) {
284
1206
  const equivalentVariables = context.getEquivalentVariables();
285
1207
  const structure = context.getStructure();
286
1208
  // Propagate existing equivalencies for sub-properties
287
- for (const [key, value] of Object.entries(equivalentVariables)) {
1209
+ for (const [key, rawValue] of Object.entries(equivalentVariables)) {
288
1210
  // Check if this equivalency is for a sub-property of the identifier
289
1211
  // e.g., completeDataStructure['Function Arguments'] or completeDataStructure.foo
290
1212
  if (key.startsWith(nodePathStr + '.') ||
291
1213
  key.startsWith(nodePathStr + '[')) {
292
1214
  const subPath = key.substring(nodePathStr.length);
293
1215
  const newTargetPath = StructuredPath.fromBase(targetPath.toString() + subPath);
294
- const valuePath = StructuredPath.fromBase(value);
295
- context.addEquivalence(newTargetPath, valuePath);
1216
+ // Handle both string and string[] values
1217
+ const values = Array.isArray(rawValue) ? rawValue : [rawValue];
1218
+ for (const value of values) {
1219
+ if (typeof value === 'string') {
1220
+ const valuePath = StructuredPath.fromBase(value);
1221
+ context.addEquivalence(newTargetPath, valuePath);
1222
+ }
1223
+ }
296
1224
  }
297
1225
  }
298
1226
  // Propagate existing structure entries for sub-properties
@@ -386,7 +1314,8 @@ export function processExpression({ node, context, targetPath, typeHint, }) {
386
1314
  const propertyPath = objectPath.withProperty(unwrappedNode.name.text);
387
1315
  // Check if this is an environment variable access
388
1316
  const fullText = unwrappedNode.getText(context.sourceFile);
389
- if (fullText.includes('.env.') // simple heuristic for env var access but not great
1317
+ if (fullText.includes('.env.') || // process.env.X, window.env.X
1318
+ isEnvStoreAccess(fullText) // env.X where env is likely an env config object
390
1319
  ) {
391
1320
  context.addEnvironmentVariable(fullText);
392
1321
  }
@@ -610,6 +1539,13 @@ export function processExpression({ node, context, targetPath, typeHint, }) {
610
1539
  // e.g., `const tab = segments[0] || 'default'` should trace tab back to segments[0]
611
1540
  if (operatorKind === ts.SyntaxKind.QuestionQuestionToken) {
612
1541
  // specifically for ?? we create an equivalence to the left side
1542
+ // IMPORTANT: Also process the left side recursively to apply method semantics
1543
+ // (e.g., for `const segments = splat?.split('/') ?? []`, we need split semantics)
1544
+ processExpression({
1545
+ node: unwrappedNode.left,
1546
+ context,
1547
+ // Don't pass targetPath here - we'll establish equivalence separately below
1548
+ });
613
1549
  if (targetPath) {
614
1550
  resultPath = StructuredPath.fromNode(unwrappedNode.left, context.sourceFile);
615
1551
  }
@@ -620,12 +1556,46 @@ export function processExpression({ node, context, targetPath, typeHint, }) {
620
1556
  }
621
1557
  }
622
1558
  else if (operatorKind === ts.SyntaxKind.BarBarToken) {
623
- // For ||, also create an equivalence to the left side
1559
+ // For ||, create equivalences to BOTH sides
624
1560
  // This enables data flow tracing through fallback expressions
1561
+ // e.g., `const item = items.find(...) || null` should trace to both:
1562
+ // - items[] (from the find result)
1563
+ // - null (from the fallback)
625
1564
  if (targetPath) {
626
- resultPath = StructuredPath.fromNode(unwrappedNode.left, context.sourceFile);
1565
+ // Get paths for both sides
1566
+ const leftPath = StructuredPath.fromNode(unwrappedNode.left, context.sourceFile);
1567
+ const rightPath = StructuredPath.fromNode(unwrappedNode.right, context.sourceFile);
1568
+ // Collect all valid paths
1569
+ const allPaths = [];
1570
+ if (leftPath)
1571
+ allPaths.push(leftPath);
1572
+ if (rightPath)
1573
+ allPaths.push(rightPath);
1574
+ // Add multiple equivalencies to track both sources
1575
+ if (allPaths.length > 0) {
1576
+ context.addMultipleEquivalencies(targetPath, allPaths);
1577
+ }
1578
+ // Process both sides to capture their internal structures
1579
+ processExpression({
1580
+ node: unwrappedNode.left,
1581
+ context,
1582
+ });
1583
+ processExpression({
1584
+ node: unwrappedNode.right,
1585
+ context,
1586
+ });
1587
+ // Register the type for the target path
1588
+ const leftType = context.inferTypeFromNode(unwrappedNode.left);
1589
+ const rightType = context.inferTypeFromNode(unwrappedNode.right);
1590
+ const orResultType = isDefinedType(leftType)
1591
+ ? leftType
1592
+ : rightType || 'unknown';
1593
+ context.addType(targetPath, orResultType);
1594
+ // Return early - we've already handled equivalencies with addMultipleEquivalencies
1595
+ // Don't fall through to the generic addEquivalence call below
1596
+ return true;
627
1597
  }
628
- // Note: Unlike ??, we don't set targetPath when there's no target
1598
+ // Note: When there's no targetPath, we don't recursively process
629
1599
  // because || is often used in boolean contexts where the full expression matters
630
1600
  }
631
1601
  }
@@ -666,9 +1636,10 @@ export function processExpression({ node, context, targetPath, typeHint, }) {
666
1636
  context.markUnsupported(unwrappedNode.expression, `processExpression: Couldn't get path for called expression: ${ts.SyntaxKind[unwrappedNode.expression.kind]}`, false);
667
1637
  return false;
668
1638
  }
669
- // Construct empty arguments list just to get the call path
670
- // We'll process each argument with its parameter path as targetPath
671
- const callPath = StructuredPath.fromNode(unwrappedNode, context.sourceFile);
1639
+ // Build call path using original source text for consistent schema paths.
1640
+ // IMPORTANT: Never use cyScope names in call paths - they are internal identifiers
1641
+ // that should not appear in schema paths or call signatures.
1642
+ const callPath = buildCallPathFromSource(unwrappedNode, context);
672
1643
  // 2. Process all arguments recursively WITH targetPath for proper equivalence
673
1644
  for (let i = 0; i < unwrappedNode.arguments.length; i++) {
674
1645
  const arg = unwrappedNode.arguments[i];
@@ -702,18 +1673,44 @@ export function processExpression({ node, context, targetPath, typeHint, }) {
702
1673
  const semantics = semanticsList[0];
703
1674
  // Get the source expression path (e.g., the object for obj.method())
704
1675
  const sourceExpr = unwrappedNode.expression.expression;
705
- const sourcePath = StructuredPath.fromNode(sourceExpr, context.sourceFile);
706
- if (sourcePath) {
707
- // For array-specific semantics (like push), verify the source is actually an array
708
- // This prevents router.push() from being mistakenly treated as Array.push()
709
- const isArraySemantics = semantics instanceof ArrayPushSemantics;
710
- const shouldApply = !isArraySemantics ||
711
- isLikelyArrayType(sourceExpr, context.typeChecker);
712
- if (shouldApply) {
713
- // Apply method semantics
714
- semantics.addEquivalences(callPath, sourcePath, context);
715
- returnType = semantics.getReturnType();
716
- handledBySemantics = true;
1676
+ const unwrappedSourceExpr = unwrapExpression(sourceExpr);
1677
+ // When the source is a ternary expression like (cond ? arr : arr.slice()),
1678
+ // apply method semantics to BOTH branches directly. The ternary itself isn't
1679
+ // a variable - it's just a choice between two paths that both flow to the result.
1680
+ if (ts.isConditionalExpression(unwrappedSourceExpr)) {
1681
+ const branches = [
1682
+ unwrappedSourceExpr.whenTrue,
1683
+ unwrappedSourceExpr.whenFalse,
1684
+ ];
1685
+ for (const branch of branches) {
1686
+ const branchPath = StructuredPath.fromNode(branch, context.sourceFile);
1687
+ if (branchPath) {
1688
+ const isArraySemantics = semantics instanceof ArrayPushSemantics;
1689
+ const shouldApply = !isArraySemantics ||
1690
+ isLikelyArrayType(branch, context.typeChecker);
1691
+ if (shouldApply) {
1692
+ semantics.addEquivalences(callPath, branchPath, context);
1693
+ returnType = semantics.getReturnType();
1694
+ handledBySemantics = true;
1695
+ }
1696
+ }
1697
+ }
1698
+ }
1699
+ else {
1700
+ // Regular (non-ternary) source expression
1701
+ const sourcePath = StructuredPath.fromNode(sourceExpr, context.sourceFile);
1702
+ if (sourcePath) {
1703
+ // For array-specific semantics (like push), verify the source is actually an array
1704
+ // This prevents router.push() from being mistakenly treated as Array.push()
1705
+ const isArraySemantics = semantics instanceof ArrayPushSemantics;
1706
+ const shouldApply = !isArraySemantics ||
1707
+ isLikelyArrayType(sourceExpr, context.typeChecker);
1708
+ if (shouldApply) {
1709
+ // Apply method semantics
1710
+ semantics.addEquivalences(callPath, sourcePath, context);
1711
+ returnType = semantics.getReturnType();
1712
+ handledBySemantics = true;
1713
+ }
717
1714
  }
718
1715
  }
719
1716
  }
@@ -798,6 +1795,12 @@ export function processExpression({ node, context, targetPath, typeHint, }) {
798
1795
  }
799
1796
  // Create a path for this property within the base
800
1797
  const propPath = targetPath.withProperty(propName);
1798
+ // Handle child boundaries (callback functions) in object properties
1799
+ // This establishes equivalency between the property path and the child scope
1800
+ // e.g., columns[0].renderCell → cyScope1()
1801
+ if (context.isChildBoundary(property.initializer)) {
1802
+ context.addChildBoundaryEquivalence(propPath, property.initializer);
1803
+ }
801
1804
  // Process the property value with propPath as targetPath
802
1805
  // This allows nested object literals to work correctly
803
1806
  processExpression({
@@ -1032,14 +2035,24 @@ export function processExpression({ node, context, targetPath, typeHint, }) {
1032
2035
  markConditionVariablesAsNullable(unwrappedNode.condition, context);
1033
2036
  // Extract conditional usages for key attribute detection
1034
2037
  extractConditionalUsage(unwrappedNode.condition, context, 'ternary');
2038
+ // Extract conditional effects (setter calls in ternary branches)
2039
+ const knownSetters = findUseStateSetters(context.sourceFile);
2040
+ const effects = extractConditionalEffectsFromTernary(unwrappedNode, context, knownSetters);
2041
+ for (const effect of effects) {
2042
+ context.addConditionalEffect(effect);
2043
+ }
1035
2044
  // Process all parts recursively
1036
2045
  processExpression({
1037
2046
  node: unwrappedNode.condition,
1038
2047
  context,
1039
2048
  typeHint: 'boolean | unknown',
1040
2049
  }); //TODO: could we capture that this is evidence of a boolean type?
1041
- processExpression({ node: unwrappedNode.whenTrue, context });
1042
- processExpression({ node: unwrappedNode.whenFalse, context });
2050
+ // Process both branches WITH targetPath to establish equivalencies
2051
+ // This is critical for tracing nested properties through ternary assignments
2052
+ // e.g., const items = condition ? arr1 : arr2; items.map(i => i.prop)
2053
+ // We need items to be equivalent to both arr1 AND arr2 for proper tracing
2054
+ processExpression({ node: unwrappedNode.whenTrue, context, targetPath });
2055
+ processExpression({ node: unwrappedNode.whenFalse, context, targetPath });
1043
2056
  // Create a path for the whole expression
1044
2057
  const expressionSourcePath = nodeToSource(unwrappedNode, context.sourceFile);
1045
2058
  // Infer type based on branches
@@ -1054,10 +2067,22 @@ export function processExpression({ node, context, targetPath, typeHint, }) {
1054
2067
  }
1055
2068
  // Register type for the expression
1056
2069
  context.addType(expressionSourcePath, resultType);
1057
- // If targetPath is provided, establish equivalence and register type
2070
+ // If targetPath is provided, only register type (don't overwrite branch equivalencies)
2071
+ // The equivalencies to individual branches (set above) are more useful for tracing
2072
+ // than an equivalency to the entire ternary expression text
1058
2073
  if (targetPath) {
1059
- context.addEquivalence(targetPath, expressionSourcePath);
1060
- context.addType(targetPath, resultType);
2074
+ // NOTE: We intentionally do NOT add equivalence here.
2075
+ // The branch processing above already added equivalencies:
2076
+ // targetPath -> whenTrue branch
2077
+ // targetPath -> whenFalse branch
2078
+ // Adding an equivalence to expressionSourcePath would overwrite those
2079
+ // with a useless equivalence to the ternary text itself.
2080
+ //
2081
+ // Use updateSchemaType instead of addType because:
2082
+ // 1. Branch processing may have already set a type on targetPath
2083
+ // 2. addType has a guard that prevents overwriting specific types with 'unknown'
2084
+ // 3. updateSchemaType bypasses this guard, ensuring the ternary's computed type is used
2085
+ context.updateSchemaType(targetPath, resultType);
1061
2086
  }
1062
2087
  return true;
1063
2088
  }
@@ -1114,6 +2139,32 @@ export function processExpression({ node, context, targetPath, typeHint, }) {
1114
2139
  }
1115
2140
  // Handle Arrow Functions: (p) => p.prop, (a, b) => { ... }
1116
2141
  if (ts.isArrowFunction(unwrappedNode)) {
2142
+ // If this arrow function is a child boundary (e.g., a .map() callback),
2143
+ // don't process its parameters here - they will be processed when the
2144
+ // child scope is analyzed separately. This prevents parameter variables
2145
+ // from leaking into the parent scope's equivalencies.
2146
+ // Check if this arrow function is a child boundary (i.e., should be processed
2147
+ // as a separate child scope, not here in the parent scope).
2148
+ //
2149
+ // We use two checks because childBoundary positions can be unreliable:
2150
+ // 1. Position-based check (standard isChildBoundary)
2151
+ // 2. Text-based check: if the arrow function text doesn't appear in the
2152
+ // statement text, it was replaced with a cyScope placeholder
2153
+ const isChildBoundary = context.isChildBoundary(unwrappedNode);
2154
+ // Text-based child scope detection for when positions are unreliable
2155
+ const arrowFnText = unwrappedNode.getText(context.sourceFile);
2156
+ const firstLine = arrowFnText.split('\n')[0].trim();
2157
+ const searchText = firstLine.substring(0, Math.min(20, firstLine.length));
2158
+ const isInStatementText = context.statementInfo.text.includes(searchText);
2159
+ const isChildScope = !isInStatementText && arrowFnText.length > 10;
2160
+ if (isChildBoundary || isChildScope) {
2161
+ // The method semantics (e.g., ArrayMapSemantics) have already established
2162
+ // the necessary equivalences between the child scope placeholder and array elements
2163
+ if (targetPath) {
2164
+ context.addType(targetPath, 'function');
2165
+ }
2166
+ return true;
2167
+ }
1117
2168
  // Create a path for the function
1118
2169
  const functionPath = StructuredPath.empty();
1119
2170
  // Process parameters
@@ -1618,6 +2669,9 @@ function processJsxAttribute(attr, context, componentPath, targetPath) {
1618
2669
  if (ts.isJsxExpression(attr.initializer) && attr.initializer.expression) {
1619
2670
  const expression = attr.initializer.expression;
1620
2671
  if (context.isChildBoundary(expression)) {
2672
+ // Create equivalency between attribute path and child scope
2673
+ // e.g., Grid().signature[0].renderRow → cyScope1()
2674
+ context.addChildBoundaryEquivalence(attributePath, expression);
1621
2675
  return true;
1622
2676
  }
1623
2677
  // Process the expression with attributePath as targetPath