@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,5 +1,10 @@
1
1
  import ts from 'typescript';
2
- import { AnalysisContext, ConditionalUsage } from './types';
2
+ import * as crypto from 'crypto';
3
+ import {
4
+ AnalysisContext,
5
+ CompoundConditional,
6
+ ConditionalUsage,
7
+ } from './types';
3
8
  import { StructuredPath } from './paths';
4
9
  import { nodeToSource } from './nodeToSource';
5
10
  import { methodRegistry, ArrayPushSemantics } from './methodSemantics';
@@ -14,6 +19,341 @@ import {
14
19
  unwrapExpression,
15
20
  } from './sharedPatterns';
16
21
  import { processBindingPattern } from './processBindings';
22
+ import {
23
+ extractConditionalEffectsFromTernary,
24
+ findUseStateSetters,
25
+ } from './conditionalEffectsExtractor';
26
+ import { detectArrayDerivedPattern } from './arrayDerivationDetector';
27
+
28
+ /**
29
+ * Checks if a JSX element has props that reference variables from the parent scope.
30
+ * This is used to detect unconditionally-rendered children that should have their
31
+ * execution flows merged into the parent.
32
+ *
33
+ * We want to track children where the parent controls data that affects the child's
34
+ * conditional rendering. Static props (like title="Dashboard") don't need tracking
35
+ * because they don't create variable execution flows.
36
+ *
37
+ * Examples:
38
+ * - <WorkoutsView workouts={workouts} /> → true (workouts is a variable)
39
+ * - <ItemList items={items} count={count} /> → true (items, count are variables)
40
+ * - <Header title="Dashboard" /> → false (static string)
41
+ * - <Footer /> → false (no props)
42
+ * - <Button onClick={handleClick} /> → false (only callback, no data props)
43
+ *
44
+ * @returns true if the component has at least one prop that references a variable
45
+ * (excluding callbacks which typically start with 'on' or 'handle')
46
+ */
47
+ function hasDataPropsFromParent(
48
+ node: ts.JsxElement | ts.JsxSelfClosingElement,
49
+ componentName: string,
50
+ ): { hasDataProps: boolean; dataProps: string[] } {
51
+ const attributes = ts.isJsxElement(node)
52
+ ? node.openingElement.attributes.properties
53
+ : node.attributes.properties;
54
+
55
+ const dataProps: string[] = [];
56
+
57
+ for (const attr of attributes) {
58
+ // Spread attributes always reference parent data: {...props}
59
+ if (ts.isJsxSpreadAttribute(attr)) {
60
+ const spreadText = attr.expression?.getText() || '...spread';
61
+ dataProps.push(`{...${spreadText}}`);
62
+ console.log(
63
+ `[UnconditionalChild] ${componentName}: Found spread attribute {${spreadText}}`,
64
+ );
65
+ continue;
66
+ }
67
+
68
+ if (ts.isJsxAttribute(attr)) {
69
+ const propName = attr.name.getText();
70
+
71
+ // Skip callback props - they don't create data-driven execution flows
72
+ // Callbacks typically start with 'on' (onClick, onChange) or 'handle' (handleSubmit)
73
+ if (
74
+ propName.startsWith('on') ||
75
+ propName.startsWith('handle') ||
76
+ propName === 'ref'
77
+ ) {
78
+ console.log(
79
+ `[UnconditionalChild] ${componentName}: Skipping callback prop '${propName}'`,
80
+ );
81
+ continue;
82
+ }
83
+
84
+ // Check if the prop value is a JSX expression (references a variable)
85
+ // vs a string literal which is static
86
+ if (attr.initializer) {
87
+ if (ts.isJsxExpression(attr.initializer)) {
88
+ // JSX expression like prop={value} - this references a variable
89
+ // Could be a simple identifier, property access, or more complex expression
90
+ const expression = attr.initializer.expression;
91
+ if (expression) {
92
+ // Skip if it's just a function/arrow function (callback)
93
+ if (
94
+ ts.isArrowFunction(expression) ||
95
+ ts.isFunctionExpression(expression)
96
+ ) {
97
+ console.log(
98
+ `[UnconditionalChild] ${componentName}: Skipping inline callback prop '${propName}'`,
99
+ );
100
+ continue;
101
+ }
102
+ // This is a data prop that references parent state/props
103
+ const exprText = expression.getText();
104
+ dataProps.push(`${propName}={${exprText}}`);
105
+ console.log(
106
+ `[UnconditionalChild] ${componentName}: Found data prop '${propName}' = {${exprText}}`,
107
+ );
108
+ }
109
+ } else {
110
+ // String literals like prop="value" are static
111
+ console.log(
112
+ `[UnconditionalChild] ${componentName}: Skipping static prop '${propName}'`,
113
+ );
114
+ }
115
+ }
116
+ }
117
+ }
118
+
119
+ const hasDataProps = dataProps.length > 0;
120
+ if (hasDataProps) {
121
+ console.log(
122
+ `[UnconditionalChild] ${componentName}: Has ${dataProps.length} data props: [${dataProps.join(', ')}]`,
123
+ );
124
+ } else {
125
+ console.log(
126
+ `[UnconditionalChild] ${componentName}: No data props found, will NOT track`,
127
+ );
128
+ }
129
+
130
+ return { hasDataProps, dataProps };
131
+ }
132
+
133
+ /**
134
+ * Extracts the component name from a JSX element.
135
+ * Returns null for intrinsic elements (div, span, etc.) since we only care about
136
+ * custom components for gating condition tracking.
137
+ *
138
+ * Examples:
139
+ * - <ChildViewer /> → "ChildViewer"
140
+ * - <ScenarioViewer scenario={...} /> → "ScenarioViewer"
141
+ * - <div> → null (intrinsic element)
142
+ */
143
+ function getComponentNameFromJsx(
144
+ node: ts.JsxElement | ts.JsxSelfClosingElement,
145
+ ): string | null {
146
+ let tagName: ts.JsxTagNameExpression;
147
+
148
+ if (ts.isJsxElement(node)) {
149
+ tagName = node.openingElement.tagName;
150
+ } else {
151
+ tagName = node.tagName;
152
+ }
153
+
154
+ // Get the text of the tag name
155
+ const name = tagName.getText();
156
+
157
+ // Check if it's a custom component (starts with uppercase) vs intrinsic element
158
+ // Custom components start with uppercase: <MyComponent />
159
+ // Intrinsic elements start with lowercase: <div />
160
+ if (
161
+ name &&
162
+ name[0] === name[0].toUpperCase() &&
163
+ name[0] !== name[0].toLowerCase()
164
+ ) {
165
+ return name;
166
+ }
167
+
168
+ return null;
169
+ }
170
+
171
+ /**
172
+ * Extracts condition paths from a logical AND chain expression.
173
+ * Used for creating gating conditions for child components.
174
+ *
175
+ * Example: `hasData && isReady && <Component />` returns ['hasData', 'isReady']
176
+ */
177
+ function extractConditionPathsFromAndChain(
178
+ expr: ts.Expression,
179
+ sourceFile: ts.SourceFile,
180
+ ): string[] {
181
+ const paths: string[] = [];
182
+ const unwrapped = unwrapExpression(expr);
183
+
184
+ if (
185
+ ts.isBinaryExpression(unwrapped) &&
186
+ unwrapped.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken
187
+ ) {
188
+ // Recursively get conditions from left side
189
+ paths.push(
190
+ ...extractConditionPathsFromAndChain(unwrapped.left, sourceFile),
191
+ );
192
+
193
+ // Process right side if it's not JSX (JSX is the consequence, not a condition)
194
+ const rightUnwrapped = unwrapExpression(unwrapped.right);
195
+ if (
196
+ !ts.isJsxElement(rightUnwrapped) &&
197
+ !ts.isJsxSelfClosingElement(rightUnwrapped) &&
198
+ !ts.isJsxFragment(rightUnwrapped)
199
+ ) {
200
+ paths.push(
201
+ ...extractConditionPathsFromAndChain(unwrapped.right, sourceFile),
202
+ );
203
+ }
204
+ } else {
205
+ // Base case: extract path from this expression
206
+ const path = StructuredPath.fromNode(unwrapped, sourceFile);
207
+ if (path) {
208
+ paths.push(path.toString());
209
+ }
210
+ }
211
+
212
+ return paths;
213
+ }
214
+
215
+ /**
216
+ * Finds the rightmost JSX element in an && chain.
217
+ * Example: `a && b && <Component />` returns <Component />
218
+ */
219
+ function findJsxInAndChain(
220
+ expr: ts.Expression,
221
+ ): ts.JsxElement | ts.JsxSelfClosingElement | null {
222
+ const unwrapped = unwrapExpression(expr);
223
+
224
+ if (ts.isJsxElement(unwrapped) || ts.isJsxSelfClosingElement(unwrapped)) {
225
+ return unwrapped;
226
+ }
227
+
228
+ if (
229
+ ts.isBinaryExpression(unwrapped) &&
230
+ unwrapped.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken
231
+ ) {
232
+ // Check right side first (most common case: condition && <Jsx />)
233
+ const rightResult = findJsxInAndChain(unwrapped.right);
234
+ if (rightResult) return rightResult;
235
+
236
+ // Also check left side for rare cases
237
+ return findJsxInAndChain(unwrapped.left);
238
+ }
239
+
240
+ return null;
241
+ }
242
+
243
+ /**
244
+ * Fix 32: Finds a JSX fragment in an && chain.
245
+ * Example: `activeTab && <><ChildA /><ChildB /></>` returns the fragment
246
+ * This is needed to propagate parent conditions through fragments.
247
+ */
248
+ function findJsxFragmentInAndChain(expr: ts.Expression): ts.JsxFragment | null {
249
+ const unwrapped = unwrapExpression(expr);
250
+
251
+ if (ts.isJsxFragment(unwrapped)) {
252
+ return unwrapped;
253
+ }
254
+
255
+ if (
256
+ ts.isBinaryExpression(unwrapped) &&
257
+ unwrapped.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken
258
+ ) {
259
+ // Check right side first (most common case: condition && <></>)
260
+ const rightResult = findJsxFragmentInAndChain(unwrapped.right);
261
+ if (rightResult) return rightResult;
262
+
263
+ // Also check left side for rare cases
264
+ return findJsxFragmentInAndChain(unwrapped.left);
265
+ }
266
+
267
+ return null;
268
+ }
269
+
270
+ /**
271
+ * Detects if a property access looks like an environment variable store access.
272
+ * Matches patterns like `env.DATABASE_URL`, `env.IS_FORMBRICKS_CLOUD`, etc.
273
+ * where the object is named "env" and the property looks like an env var name.
274
+ */
275
+ function isEnvStoreAccess(fullText: string): boolean {
276
+ // Match: env.SOME_VAR or env.someVar (but object must be exactly "env")
277
+ // This catches patterns from @t3-oss/env-nextjs and similar packages
278
+ const envStorePattern = /^env\.[A-Z_][A-Z0-9_]*$/;
279
+ return envStorePattern.test(fullText);
280
+ }
281
+
282
+ /**
283
+ * Converts a call expression argument to a StructuredPath.
284
+ *
285
+ * IMPORTANT: We always use the original source text for callbacks, never cyScope names.
286
+ * cyScope names are internal identifiers for child scopes and should NEVER appear
287
+ * in schema paths or call signatures. Using cyScope names causes data merge conflicts
288
+ * because the same callback gets different identifiers in different contexts.
289
+ */
290
+ function getArgPathForCallSignature(
291
+ arg: ts.Expression,
292
+ context: AnalysisContext,
293
+ ): StructuredPath {
294
+ // Always use the standard path conversion - never replace with cyScope names
295
+ return (
296
+ StructuredPath.fromNode(arg, context.sourceFile) ||
297
+ nodeToSource(arg, context.sourceFile)
298
+ );
299
+ }
300
+
301
+ /**
302
+ * Builds a StructuredPath for a call expression using the original source text.
303
+ *
304
+ * IMPORTANT: This function ensures consistent call signatures by always using
305
+ * the original callback text, never cyScope names. This prevents schema path
306
+ * conflicts where the same call would have different paths.
307
+ */
308
+ function buildCallPathFromSource(
309
+ node: ts.CallExpression,
310
+ context: AnalysisContext,
311
+ ): StructuredPath | null {
312
+ const expression = node.expression;
313
+
314
+ // Convert arguments using original source text
315
+ const argPaths = node.arguments.map((arg) =>
316
+ getArgPathForCallSignature(arg, context),
317
+ );
318
+
319
+ // Handle type arguments if present
320
+ let typeArgs: string[] | undefined = undefined;
321
+ if (node.typeArguments && node.typeArguments.length > 0) {
322
+ typeArgs = node.typeArguments.map((typeArg) =>
323
+ typeArg.getText(context.sourceFile),
324
+ );
325
+ }
326
+
327
+ if (ts.isIdentifier(expression)) {
328
+ // Simple function call: func(arg1, arg2)
329
+ return StructuredPath.fromFunction(expression.text, argPaths, typeArgs);
330
+ } else if (ts.isPropertyAccessExpression(expression)) {
331
+ // Method call: obj.method(arg1, arg2)
332
+ const objPath = StructuredPath.fromNode(
333
+ expression.expression,
334
+ context.sourceFile,
335
+ );
336
+ if (!objPath) return null;
337
+ return objPath
338
+ .withProperty(expression.name.text)
339
+ .withFunctionCall(argPaths, typeArgs);
340
+ } else if (ts.isCallExpression(expression)) {
341
+ // Chained call: func(arg1)(arg2)
342
+ const funcPath = buildCallPathFromSource(expression, context);
343
+ if (!funcPath) return null;
344
+ return funcPath.withFunctionCall(argPaths, typeArgs);
345
+ } else if (ts.isElementAccessExpression(expression)) {
346
+ // Element access call: obj[key](args)
347
+ const basePath = StructuredPath.fromNode(expression, context.sourceFile);
348
+ if (!basePath) return null;
349
+ return basePath.withFunctionCall(argPaths, typeArgs);
350
+ } else {
351
+ // Complex call expression
352
+ const basePath = StructuredPath.fromNode(expression, context.sourceFile);
353
+ if (!basePath) return null;
354
+ return basePath.withFunctionCall(argPaths, typeArgs);
355
+ }
356
+ }
17
357
 
18
358
  /**
19
359
  * Checks if an expression is likely an array type.
@@ -114,131 +454,1008 @@ export function markConditionVariablesAsNullable(
114
454
  }
115
455
 
116
456
  /**
117
- * Extracts conditional usages from a condition expression for key attribute detection.
118
- * This function identifies which attributes are used in conditionals and how they're used.
457
+ * Helper to extract source location from an AST node
458
+ */
459
+ function getSourceLocation(
460
+ node: ts.Node,
461
+ sourceFile: ts.SourceFile,
462
+ ): ConditionalUsage['sourceLocation'] {
463
+ const start = node.getStart(sourceFile);
464
+ const { line, character } = sourceFile.getLineAndCharacterOfPosition(start);
465
+ const codeSnippet = node.getText(sourceFile);
466
+
467
+ return {
468
+ lineNumber: line + 1, // Convert to 1-based
469
+ column: character,
470
+ codeSnippet:
471
+ codeSnippet.length > 100
472
+ ? codeSnippet.slice(0, 100) + '...'
473
+ : codeSnippet,
474
+ };
475
+ }
476
+
477
+ /**
478
+ * Extracts the root array path from an expression that ends with .map().
479
+ * Handles chained methods like .filter().map(), .slice().map(), etc.
119
480
  *
120
- * @param condition The condition expression to analyze
481
+ * Examples:
482
+ * - items.map(...) → "items"
483
+ * - data.users.map(...) → "data.users"
484
+ * - items.filter(...).map(...) → "items"
485
+ * - items.slice(0, 5).map(...) → "items"
486
+ */
487
+ function extractArrayPathFromMapCall(
488
+ expr: ts.CallExpression,
489
+ sourceFile: ts.SourceFile,
490
+ ): string | null {
491
+ // Walk up the chain to find the root array
492
+ let current: ts.Expression = expr.expression;
493
+
494
+ while (ts.isPropertyAccessExpression(current)) {
495
+ const methodName = current.name.getText(sourceFile);
496
+
497
+ // Common array methods that return arrays (so we keep going up)
498
+ const arrayReturningMethods = [
499
+ 'map',
500
+ 'filter',
501
+ 'slice',
502
+ 'concat',
503
+ 'flat',
504
+ 'flatMap',
505
+ 'reverse',
506
+ 'sort',
507
+ 'toReversed',
508
+ 'toSorted',
509
+ 'toSpliced',
510
+ ];
511
+
512
+ if (arrayReturningMethods.includes(methodName)) {
513
+ const objectExpr = current.expression;
514
+
515
+ // If the object is a call expression (chained method), keep going
516
+ if (ts.isCallExpression(objectExpr)) {
517
+ current = objectExpr.expression;
518
+ } else {
519
+ // Found the root - it's an identifier or property access
520
+ const path = StructuredPath.fromNode(objectExpr, sourceFile);
521
+ return path ? path.toString() : null;
522
+ }
523
+ } else {
524
+ // Not an array method we recognize
525
+ break;
526
+ }
527
+ }
528
+
529
+ return null;
530
+ }
531
+
532
+ /**
533
+ * Extracts JSX rendering usages from a JSX expression.
534
+ * Detects:
535
+ * - array.map() calls → 'array-map' type
536
+ * - string interpolations (identifiers/property access) → 'text-interpolation' type
537
+ *
538
+ * Recursively searches inside && chains and ternary expressions.
539
+ *
540
+ * @param expr The expression inside {expr}
121
541
  * @param context The analysis context
122
- * @param location Where this condition appears (if, ternary, logical-and, switch)
123
542
  */
124
- export function extractConditionalUsage(
125
- condition: ts.Expression,
543
+ function extractJsxRenderingUsage(
544
+ expr: ts.Expression,
126
545
  context: AnalysisContext,
127
- location: ConditionalUsage['location'],
128
546
  ): void {
129
- const unwrapped = unwrapExpression(condition);
547
+ const unwrapped = unwrapExpression(expr);
548
+ const sourceLocation = getSourceLocation(expr, context.sourceFile);
130
549
 
131
- // Handle binary expressions with && (logical AND chains)
132
- // Example: `a && b && <Component />` - both a and b are conditional checks
133
- if (
550
+ // Detect array.map() calls
551
+ if (ts.isCallExpression(unwrapped)) {
552
+ const calleeExpr = unwrapped.expression;
553
+
554
+ if (ts.isPropertyAccessExpression(calleeExpr)) {
555
+ const methodName = calleeExpr.name.getText(context.sourceFile);
556
+
557
+ if (methodName === 'map') {
558
+ const arrayPath = extractArrayPathFromMapCall(
559
+ unwrapped,
560
+ context.sourceFile,
561
+ );
562
+
563
+ if (arrayPath) {
564
+ context.addJsxRenderingUsage({
565
+ path: arrayPath,
566
+ renderingType: 'array-map',
567
+ valueType: 'array',
568
+ sourceLocation,
569
+ });
570
+ }
571
+ }
572
+ }
573
+ }
574
+ // Detect simple string interpolations: {title} or {user.name}
575
+ else if (
576
+ ts.isIdentifier(unwrapped) ||
577
+ ts.isPropertyAccessExpression(unwrapped)
578
+ ) {
579
+ const path = StructuredPath.fromNode(unwrapped, context.sourceFile);
580
+
581
+ if (path) {
582
+ const pathStr = path.toString();
583
+ const typeInfo = context.getTypeInfo(path);
584
+
585
+ // Only track as text interpolation if it's a string type
586
+ // Check for 'string' type, or types that contain 'string' (but not 'string[]')
587
+ if (
588
+ typeInfo === 'string' ||
589
+ (typeInfo &&
590
+ typeInfo.includes('string') &&
591
+ !typeInfo.includes('string[]'))
592
+ ) {
593
+ context.addJsxRenderingUsage({
594
+ path: pathStr,
595
+ renderingType: 'text-interpolation',
596
+ valueType: 'string',
597
+ sourceLocation,
598
+ });
599
+ }
600
+ }
601
+ }
602
+ // Recursively search inside && chains: {showList && items.map(...)}
603
+ else if (
134
604
  ts.isBinaryExpression(unwrapped) &&
135
605
  unwrapped.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken
136
606
  ) {
137
- // Recursively process left side
138
- extractConditionalUsage(unwrapped.left, context, location);
607
+ // Check the right side of the && chain (where .map() typically appears)
608
+ const rightSide = unwrapExpression(unwrapped.right);
609
+ extractJsxRenderingUsage(rightSide, context);
610
+ // Also check nested && chains on the left
611
+ extractJsxRenderingUsage(unwrapped.left, context);
612
+ }
613
+ // Recursively search inside ternaries: {isEmpty ? null : items.map(...)}
614
+ else if (ts.isConditionalExpression(unwrapped)) {
615
+ extractJsxRenderingUsage(unwrapped.whenTrue, context);
616
+ extractJsxRenderingUsage(unwrapped.whenFalse, context);
617
+ }
618
+ }
619
+
620
+ /**
621
+ * Counts the number of conditions in an && chain (excluding JSX consequence)
622
+ */
623
+ function countConditionsInAndChain(expr: ts.Expression): number {
624
+ const unwrapped = unwrapExpression(expr);
139
625
 
140
- // Process right side if it's not JSX (JSX is the consequence, not the condition)
626
+ if (
627
+ ts.isBinaryExpression(unwrapped) &&
628
+ unwrapped.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken
629
+ ) {
630
+ const leftCount = countConditionsInAndChain(unwrapped.left);
141
631
  const rightUnwrapped = unwrapExpression(unwrapped.right);
142
632
  const isJsxConsequence =
143
633
  ts.isJsxElement(rightUnwrapped) ||
144
634
  ts.isJsxSelfClosingElement(rightUnwrapped) ||
145
635
  ts.isJsxFragment(rightUnwrapped);
146
636
 
147
- if (!isJsxConsequence) {
148
- extractConditionalUsage(unwrapped.right, context, location);
637
+ if (isJsxConsequence) {
638
+ return leftCount;
149
639
  }
150
- return;
640
+ return leftCount + countConditionsInAndChain(unwrapped.right);
151
641
  }
152
642
 
153
- // Handle binary expressions with || (logical OR)
154
- if (
155
- ts.isBinaryExpression(unwrapped) &&
156
- unwrapped.operatorToken.kind === ts.SyntaxKind.BarBarToken
157
- ) {
158
- // Both sides of || are conditional checks
159
- extractConditionalUsage(unwrapped.left, context, location);
160
- extractConditionalUsage(unwrapped.right, context, location);
643
+ // Single condition (not an && chain)
644
+ return 1;
645
+ }
646
+
647
+ /**
648
+ * Chain tracking info for compound conditionals
649
+ */
650
+ interface ChainInfo {
651
+ chainId: string;
652
+ chainLength: number;
653
+ chainExpression: string;
654
+ currentPosition: number;
655
+ compound: CompoundConditional;
656
+ /**
657
+ * When processing OR expressions within an && chain, this tracks the
658
+ * current OR group ID. Conditions added while this is set will be marked
659
+ * as OR alternatives (only one needs to be true).
660
+ */
661
+ currentOrGroupId?: string;
662
+ }
663
+
664
+ /**
665
+ * Parent gating condition accumulated during JSX traversal.
666
+ * Used to track conditions from parent && chains that gate child components.
667
+ */
668
+ interface ParentGatingCondition {
669
+ path: string;
670
+ sourceLocation: { lineNumber: number; column: number; codeSnippet: string };
671
+ isNegated?: boolean;
672
+ }
673
+
674
+ /**
675
+ * Extracts conditionals from JSX elements by recursively traversing children.
676
+ *
677
+ * This is CRITICAL for extracting compound conditionals from JSX expressions
678
+ * like `{hasNewerVersion && !isActive && <Banner />}`.
679
+ *
680
+ * This function is called BEFORE the child boundary check in processExpression
681
+ * because JSX elements are NOT scopes - their expressions use variables from
682
+ * the parent scope and should have their conditionals extracted regardless of
683
+ * whether the JSX is within a child boundary.
684
+ *
685
+ * Fix 32: Added parentConditions parameter to track gating conditions from
686
+ * parent && chains. When we find a component nested inside multiple conditionals
687
+ * like `{activeTab && <>{ternary ? ... : <Component />}</>}`, ALL parent
688
+ * conditions should be added as gating conditions for the component.
689
+ *
690
+ * @param node The JSX element, self-closing element, or fragment to traverse
691
+ * @param context The analysis context
692
+ * @param parentConditions Accumulated gating conditions from parent && chains
693
+ */
694
+ function extractConditionalsFromJsx(
695
+ node: ts.JsxElement | ts.JsxSelfClosingElement | ts.JsxFragment,
696
+ context: AnalysisContext,
697
+ parentConditions: ParentGatingCondition[] = [],
698
+ ): void {
699
+ // Get children to process
700
+ let children: ts.NodeArray<ts.JsxChild> | undefined;
701
+
702
+ if (ts.isJsxElement(node)) {
703
+ children = node.children;
704
+ } else if (ts.isJsxFragment(node)) {
705
+ children = node.children;
706
+ }
707
+ // JsxSelfClosingElement has no children
708
+
709
+ if (!children) {
161
710
  return;
162
711
  }
163
712
 
164
- // Handle comparison operators (===, !==, <, >, <=, >=)
165
- // Example: `if (status === 'active')` - status is compared against 'active'
166
- if (
167
- ts.isBinaryExpression(unwrapped) &&
168
- isComparisonOperator(unwrapped.operatorToken.kind)
169
- ) {
170
- // Try to extract the variable and the compared value
171
- const leftPath = StructuredPath.fromNode(
172
- unwrapped.left,
173
- context.sourceFile,
174
- );
175
- const rightPath = StructuredPath.fromNode(
176
- unwrapped.right,
177
- context.sourceFile,
178
- );
713
+ for (const child of children) {
714
+ // Process JSX expressions: {expr}
715
+ if (ts.isJsxExpression(child) && child.expression) {
716
+ const expr = unwrapExpression(child.expression);
179
717
 
180
- // Check if left is a variable and right is a literal
181
- if (leftPath && isLiteralExpression(unwrapped.right)) {
182
- const literalValue = getLiteralValue(unwrapped.right, context);
183
- context.addConditionalUsage({
184
- path: leftPath.toLeftHandSideString(),
185
- conditionType: 'comparison',
186
- comparedValues: literalValue !== undefined ? [literalValue] : undefined,
187
- location,
188
- });
718
+ // Extract JSX rendering usages (array.map, text interpolation)
719
+ // This handles direct usages like {items.map(...)} or {user.name}
720
+ extractJsxRenderingUsage(expr, context);
721
+
722
+ // If the expression is an && chain, extract its conditional usages
723
+ if (
724
+ ts.isBinaryExpression(expr) &&
725
+ expr.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken
726
+ ) {
727
+ // Mark nullable variables
728
+ markConditionVariablesAsNullable(expr, context);
729
+ // Extract conditional usage (this handles compound conditionals)
730
+ // Pass controlsJsxRendering: true since this conditional controls JSX rendering
731
+ extractConditionalUsage(expr, context, 'logical-and', {
732
+ controlsJsxRendering: true,
733
+ });
734
+
735
+ // Extract all condition paths from the && chain for gating tracking
736
+ const conditionPaths = extractConditionPathsFromAndChain(
737
+ expr,
738
+ context.sourceFile,
739
+ );
740
+ const sourceLocation = getSourceLocation(expr, context.sourceFile);
741
+
742
+ // Fix 32: Build accumulated conditions including parent conditions
743
+ const accumulatedConditions: ParentGatingCondition[] = [
744
+ ...parentConditions,
745
+ ...conditionPaths.map((path) => ({
746
+ path,
747
+ sourceLocation,
748
+ isNegated: false,
749
+ })),
750
+ ];
751
+
752
+ // Track gating conditions for child components
753
+ // Example: {hasAnalysis && <ScenarioViewer />}
754
+ const jsxElement = findJsxInAndChain(expr);
755
+ if (jsxElement) {
756
+ const componentName = getComponentNameFromJsx(jsxElement);
757
+ if (componentName) {
758
+ // Fix 32: Add ALL accumulated conditions (parent + current) as gating conditions
759
+ for (const condition of accumulatedConditions) {
760
+ context.addChildBoundaryGatingCondition(componentName, {
761
+ path: condition.path,
762
+ conditionType: 'truthiness',
763
+ location: 'logical-and',
764
+ sourceLocation: condition.sourceLocation,
765
+ controlsJsxRendering: true,
766
+ isNegated: condition.isNegated,
767
+ });
768
+ }
769
+ }
770
+
771
+ // Fix 32: Recursively process nested JSX with accumulated conditions
772
+ if (
773
+ ts.isJsxElement(jsxElement) ||
774
+ ts.isJsxSelfClosingElement(jsxElement)
775
+ ) {
776
+ extractConditionalsFromJsx(
777
+ jsxElement,
778
+ context,
779
+ accumulatedConditions,
780
+ );
781
+ }
782
+ }
783
+
784
+ // Fix 32: Also check for nested JSX fragments
785
+ const jsxFragment = findJsxFragmentInAndChain(expr);
786
+ if (jsxFragment) {
787
+ extractConditionalsFromJsx(
788
+ jsxFragment,
789
+ context,
790
+ accumulatedConditions,
791
+ );
792
+ }
793
+ }
794
+ // If the expression is a ternary, extract its conditional
795
+ else if (ts.isConditionalExpression(expr)) {
796
+ // Pass controlsJsxRendering: true since this conditional controls JSX rendering
797
+ extractConditionalUsage(expr.condition, context, 'ternary', {
798
+ controlsJsxRendering: true,
799
+ });
800
+
801
+ // Track gating conditions for components in both branches of the ternary
802
+ // Example: {isError ? <ErrorView /> : <SuccessView />}
803
+ const conditionPath = StructuredPath.fromNode(
804
+ unwrapExpression(expr.condition),
805
+ context.sourceFile,
806
+ );
807
+ const sourceLocation = getSourceLocation(expr, context.sourceFile);
808
+
809
+ // Recursively process the whenTrue and whenFalse branches for JSX
810
+ const whenTrue = unwrapExpression(expr.whenTrue);
811
+ const whenFalse = unwrapExpression(expr.whenFalse);
812
+
813
+ // Fix 32: Build conditions for whenTrue branch (parent conditions + ternary condition truthy)
814
+ const whenTrueConditions: ParentGatingCondition[] = [
815
+ ...parentConditions,
816
+ ...(conditionPath
817
+ ? [
818
+ {
819
+ path: conditionPath.toString(),
820
+ sourceLocation,
821
+ isNegated: false,
822
+ },
823
+ ]
824
+ : []),
825
+ ];
826
+
827
+ // Fix 32: Build conditions for whenFalse branch (parent conditions + ternary condition falsy)
828
+ const whenFalseConditions: ParentGatingCondition[] = [
829
+ ...parentConditions,
830
+ ...(conditionPath
831
+ ? [
832
+ {
833
+ path: conditionPath.toString(),
834
+ sourceLocation,
835
+ isNegated: true,
836
+ },
837
+ ]
838
+ : []),
839
+ ];
840
+
841
+ // Handle whenTrue branch (condition is truthy)
842
+ if (ts.isJsxElement(whenTrue) || ts.isJsxSelfClosingElement(whenTrue)) {
843
+ const componentName = getComponentNameFromJsx(whenTrue);
844
+ if (componentName) {
845
+ // Fix 32: Add ALL conditions (parent + ternary) as gating conditions
846
+ for (const condition of whenTrueConditions) {
847
+ context.addChildBoundaryGatingCondition(componentName, {
848
+ path: condition.path,
849
+ conditionType: 'truthiness',
850
+ location: 'ternary',
851
+ sourceLocation: condition.sourceLocation,
852
+ controlsJsxRendering: true,
853
+ isNegated: condition.isNegated,
854
+ });
855
+ }
856
+ }
857
+ }
858
+ if (
859
+ ts.isJsxElement(whenTrue) ||
860
+ ts.isJsxSelfClosingElement(whenTrue) ||
861
+ ts.isJsxFragment(whenTrue)
862
+ ) {
863
+ extractConditionalsFromJsx(whenTrue, context, whenTrueConditions);
864
+ }
865
+
866
+ // Handle whenFalse branch (condition is falsy/negated)
867
+ if (
868
+ ts.isJsxElement(whenFalse) ||
869
+ ts.isJsxSelfClosingElement(whenFalse)
870
+ ) {
871
+ const componentName = getComponentNameFromJsx(whenFalse);
872
+ if (componentName) {
873
+ // Fix 32: Add ALL conditions (parent + ternary) as gating conditions
874
+ for (const condition of whenFalseConditions) {
875
+ context.addChildBoundaryGatingCondition(componentName, {
876
+ path: condition.path,
877
+ conditionType: 'truthiness',
878
+ location: 'ternary',
879
+ sourceLocation: condition.sourceLocation,
880
+ controlsJsxRendering: true,
881
+ isNegated: condition.isNegated,
882
+ });
883
+ }
884
+ }
885
+ }
886
+ if (
887
+ ts.isJsxElement(whenFalse) ||
888
+ ts.isJsxSelfClosingElement(whenFalse) ||
889
+ ts.isJsxFragment(whenFalse)
890
+ ) {
891
+ extractConditionalsFromJsx(whenFalse, context, whenFalseConditions);
892
+ }
893
+ // Handle chained ternaries: a ? <A/> : b ? <B/> : <C/>
894
+ // When whenFalse is another ConditionalExpression, recursively process it
895
+ else if (ts.isConditionalExpression(whenFalse)) {
896
+ // Extract conditional usage for the nested ternary's condition
897
+ extractConditionalUsage(whenFalse.condition, context, 'ternary', {
898
+ controlsJsxRendering: true,
899
+ });
900
+
901
+ // Get the nested condition path
902
+ const nestedConditionPath = StructuredPath.fromNode(
903
+ unwrapExpression(whenFalse.condition),
904
+ context.sourceFile,
905
+ );
906
+ const nestedSourceLocation = getSourceLocation(
907
+ whenFalse,
908
+ context.sourceFile,
909
+ );
910
+
911
+ const nestedWhenTrue = unwrapExpression(whenFalse.whenTrue);
912
+ const nestedWhenFalse = unwrapExpression(whenFalse.whenFalse);
913
+
914
+ // Fix 32: Build conditions for nested whenTrue (parent falsy + nested truthy)
915
+ const nestedWhenTrueConditions: ParentGatingCondition[] = [
916
+ ...whenFalseConditions, // Parent ternary was falsy to get here
917
+ ...(nestedConditionPath
918
+ ? [
919
+ {
920
+ path: nestedConditionPath.toString(),
921
+ sourceLocation: nestedSourceLocation,
922
+ isNegated: false,
923
+ },
924
+ ]
925
+ : []),
926
+ ];
927
+
928
+ // Fix 32: Build conditions for nested whenFalse (parent falsy + nested falsy)
929
+ const nestedWhenFalseConditions: ParentGatingCondition[] = [
930
+ ...whenFalseConditions, // Parent ternary was falsy to get here
931
+ ...(nestedConditionPath
932
+ ? [
933
+ {
934
+ path: nestedConditionPath.toString(),
935
+ sourceLocation: nestedSourceLocation,
936
+ isNegated: true,
937
+ },
938
+ ]
939
+ : []),
940
+ ];
941
+
942
+ // Handle nested whenTrue branch
943
+ if (
944
+ ts.isJsxElement(nestedWhenTrue) ||
945
+ ts.isJsxSelfClosingElement(nestedWhenTrue)
946
+ ) {
947
+ const componentName = getComponentNameFromJsx(nestedWhenTrue);
948
+ if (componentName) {
949
+ // Fix 32: Add ALL accumulated conditions
950
+ for (const condition of nestedWhenTrueConditions) {
951
+ context.addChildBoundaryGatingCondition(componentName, {
952
+ path: condition.path,
953
+ conditionType: 'truthiness',
954
+ location: 'ternary',
955
+ sourceLocation: condition.sourceLocation,
956
+ controlsJsxRendering: true,
957
+ isNegated: condition.isNegated,
958
+ });
959
+ }
960
+ }
961
+ }
962
+ if (
963
+ ts.isJsxElement(nestedWhenTrue) ||
964
+ ts.isJsxSelfClosingElement(nestedWhenTrue) ||
965
+ ts.isJsxFragment(nestedWhenTrue)
966
+ ) {
967
+ extractConditionalsFromJsx(
968
+ nestedWhenTrue,
969
+ context,
970
+ nestedWhenTrueConditions,
971
+ );
972
+ }
973
+
974
+ // Handle nested whenFalse branch (this could be another chained ternary or JSX)
975
+ if (
976
+ ts.isJsxElement(nestedWhenFalse) ||
977
+ ts.isJsxSelfClosingElement(nestedWhenFalse)
978
+ ) {
979
+ const componentName = getComponentNameFromJsx(nestedWhenFalse);
980
+ if (componentName) {
981
+ // Fix 32: Add ALL accumulated conditions
982
+ for (const condition of nestedWhenFalseConditions) {
983
+ context.addChildBoundaryGatingCondition(componentName, {
984
+ path: condition.path,
985
+ conditionType: 'truthiness',
986
+ location: 'ternary',
987
+ sourceLocation: condition.sourceLocation,
988
+ controlsJsxRendering: true,
989
+ isNegated: condition.isNegated,
990
+ });
991
+ }
992
+ }
993
+ }
994
+ if (
995
+ ts.isJsxElement(nestedWhenFalse) ||
996
+ ts.isJsxSelfClosingElement(nestedWhenFalse) ||
997
+ ts.isJsxFragment(nestedWhenFalse)
998
+ ) {
999
+ extractConditionalsFromJsx(
1000
+ nestedWhenFalse,
1001
+ context,
1002
+ nestedWhenFalseConditions,
1003
+ );
1004
+ }
1005
+ // If nestedWhenFalse is yet another ConditionalExpression, the recursion
1006
+ // will handle it on the next iteration when this function processes it
1007
+ else if (ts.isConditionalExpression(nestedWhenFalse)) {
1008
+ // Recursively handle deeper nesting by wrapping in a synthetic process
1009
+ // We create a fake JsxExpression context to reuse the same logic
1010
+ const syntheticChild = {
1011
+ kind: ts.SyntaxKind.JsxExpression,
1012
+ expression: nestedWhenFalse,
1013
+ } as unknown as ts.JsxExpression;
1014
+ // Process via the main JSX expression handler by recursing
1015
+ // For now, just extract conditionals directly
1016
+ extractConditionalUsage(
1017
+ nestedWhenFalse.condition,
1018
+ context,
1019
+ 'ternary',
1020
+ { controlsJsxRendering: true },
1021
+ );
1022
+ }
1023
+ }
1024
+ }
1025
+ }
1026
+ // Recursively process nested JSX elements - Fix 32: pass parent conditions
1027
+ else if (ts.isJsxElement(child)) {
1028
+ // Check if this is a user-defined component (vs intrinsic element like div)
1029
+ const componentName = getComponentNameFromJsx(child);
1030
+ if (componentName) {
1031
+ if (parentConditions.length > 0) {
1032
+ // If there are parent conditions, record them as gating conditions
1033
+ console.log(
1034
+ `[ChildBoundary] ${componentName}: Conditionally rendered with ${parentConditions.length} gating conditions`,
1035
+ );
1036
+ for (const condition of parentConditions) {
1037
+ console.log(
1038
+ `[ChildBoundary] ${componentName}: Adding gating condition path='${condition.path}' isNegated=${condition.isNegated}`,
1039
+ );
1040
+ context.addChildBoundaryGatingCondition(componentName, {
1041
+ path: condition.path,
1042
+ conditionType: 'truthiness',
1043
+ location: 'ternary',
1044
+ sourceLocation: condition.sourceLocation,
1045
+ controlsJsxRendering: true,
1046
+ isNegated: condition.isNegated,
1047
+ });
1048
+ }
1049
+ } else {
1050
+ // No parent conditions - check if it has data props for unconditional tracking
1051
+ console.log(
1052
+ `[ChildBoundary] ${componentName}: Checking for unconditional rendering with data props...`,
1053
+ );
1054
+ const { hasDataProps, dataProps } = hasDataPropsFromParent(
1055
+ child,
1056
+ componentName,
1057
+ );
1058
+ if (hasDataProps) {
1059
+ // Fix: Track unconditionally-rendered children that receive data props
1060
+ // These need to be tracked for flow merging even without gating conditions
1061
+ // Example: <WorkoutsView workouts={workouts} /> - parent controls workouts data
1062
+ console.log(
1063
+ `[ChildBoundary] ${componentName}: TRACKING as unconditionally-rendered with data props: [${dataProps.join(', ')}]`,
1064
+ );
1065
+ context.addChildBoundaryGatingCondition(componentName, {
1066
+ path: '__unconditional__',
1067
+ conditionType: 'truthiness',
1068
+ location: 'unconditional',
1069
+ controlsJsxRendering: true,
1070
+ isNegated: false,
1071
+ });
1072
+ }
1073
+ }
1074
+ }
1075
+ extractConditionalsFromJsx(child, context, parentConditions);
1076
+ }
1077
+ // Handle self-closing JSX elements (e.g., <ScenarioViewer />)
1078
+ else if (ts.isJsxSelfClosingElement(child)) {
1079
+ // Check if this is a user-defined component (vs intrinsic element like div)
1080
+ const componentName = getComponentNameFromJsx(child);
1081
+ if (componentName) {
1082
+ if (parentConditions.length > 0) {
1083
+ // If there are parent conditions, record them as gating conditions
1084
+ console.log(
1085
+ `[ChildBoundary] ${componentName}: Conditionally rendered (self-closing) with ${parentConditions.length} gating conditions`,
1086
+ );
1087
+ for (const condition of parentConditions) {
1088
+ console.log(
1089
+ `[ChildBoundary] ${componentName}: Adding gating condition path='${condition.path}' isNegated=${condition.isNegated}`,
1090
+ );
1091
+ context.addChildBoundaryGatingCondition(componentName, {
1092
+ path: condition.path,
1093
+ conditionType: 'truthiness',
1094
+ location: 'ternary',
1095
+ sourceLocation: condition.sourceLocation,
1096
+ controlsJsxRendering: true,
1097
+ isNegated: condition.isNegated,
1098
+ });
1099
+ }
1100
+ } else {
1101
+ // No parent conditions - check if it has data props for unconditional tracking
1102
+ console.log(
1103
+ `[ChildBoundary] ${componentName}: Checking for unconditional rendering (self-closing) with data props...`,
1104
+ );
1105
+ const { hasDataProps, dataProps } = hasDataPropsFromParent(
1106
+ child,
1107
+ componentName,
1108
+ );
1109
+ if (hasDataProps) {
1110
+ // Fix: Track unconditionally-rendered children that receive data props
1111
+ console.log(
1112
+ `[ChildBoundary] ${componentName}: TRACKING as unconditionally-rendered (self-closing) with data props: [${dataProps.join(', ')}]`,
1113
+ );
1114
+ context.addChildBoundaryGatingCondition(componentName, {
1115
+ path: '__unconditional__',
1116
+ conditionType: 'truthiness',
1117
+ location: 'unconditional',
1118
+ controlsJsxRendering: true,
1119
+ isNegated: false,
1120
+ });
1121
+ }
1122
+ }
1123
+ }
1124
+ // Self-closing elements have no children, so no recursion needed
1125
+ }
1126
+ // Recursively process nested JSX fragments - Fix 32: pass parent conditions
1127
+ else if (ts.isJsxFragment(child)) {
1128
+ extractConditionalsFromJsx(child, context, parentConditions);
1129
+ }
1130
+ }
1131
+ }
1132
+
1133
+ /**
1134
+ * Options for extractConditionalUsage
1135
+ */
1136
+ interface ExtractConditionalOptions {
1137
+ /**
1138
+ * Whether this conditional controls JSX rendering.
1139
+ * Set to true when the conditional appears in a JSX expression like {cond && <Component />}
1140
+ */
1141
+ controlsJsxRendering?: boolean;
1142
+ }
1143
+
1144
+ /**
1145
+ * Extracts conditional usages from a condition expression for key attribute detection.
1146
+ * This function identifies which attributes are used in conditionals and how they're used.
1147
+ * It also tracks compound conditionals (&&-chains) where all conditions must be true together.
1148
+ *
1149
+ * @param condition The condition expression to analyze
1150
+ * @param context The analysis context
1151
+ * @param location Where this condition appears (if, ternary, logical-and, switch)
1152
+ * @param options Additional options including controlsJsxRendering flag
1153
+ */
1154
+ export function extractConditionalUsage(
1155
+ condition: ts.Expression,
1156
+ context: AnalysisContext,
1157
+ location: ConditionalUsage['location'],
1158
+ options: ExtractConditionalOptions = {},
1159
+ ): void {
1160
+ const { controlsJsxRendering } = options;
1161
+ // Internal recursive function with chain tracking
1162
+ function extractWithChainTracking(
1163
+ expr: ts.Expression,
1164
+ chainInfo: ChainInfo | null,
1165
+ isNegated: boolean,
1166
+ ): void {
1167
+ const unwrapped = unwrapExpression(expr);
1168
+
1169
+ // Handle binary expressions with && (logical AND chains)
1170
+ // Example: `a && b && <Component />` - both a and b are conditional checks
1171
+ if (
1172
+ ts.isBinaryExpression(unwrapped) &&
1173
+ unwrapped.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken
1174
+ ) {
1175
+ // Track if we're creating the chain at this level (root of the chain)
1176
+ const isChainRoot = !chainInfo;
1177
+
1178
+ // If no chainInfo, this is the root of a new chain
1179
+ if (isChainRoot) {
1180
+ const chainLength = countConditionsInAndChain(unwrapped);
1181
+ // Only create chain tracking for chains with 2+ conditions
1182
+ if (chainLength >= 2) {
1183
+ const chainId = `chain_${crypto.randomUUID().slice(0, 8)}`;
1184
+ const chainExpression = unwrapped.getText(context.sourceFile);
1185
+ const compound: CompoundConditional = {
1186
+ chainId,
1187
+ expression:
1188
+ chainExpression.length > 200
1189
+ ? chainExpression.slice(0, 200) + '...'
1190
+ : chainExpression,
1191
+ conditions: [],
1192
+ location,
1193
+ sourceLocation: getSourceLocation(unwrapped, context.sourceFile),
1194
+ controlsJsxRendering,
1195
+ };
1196
+ chainInfo = {
1197
+ chainId,
1198
+ chainLength,
1199
+ chainExpression: compound.expression,
1200
+ currentPosition: 0,
1201
+ compound,
1202
+ };
1203
+ }
1204
+ }
1205
+
1206
+ // Recursively process left side
1207
+ extractWithChainTracking(unwrapped.left, chainInfo, false);
1208
+
1209
+ // Process right side if it's not JSX (JSX is the consequence, not the condition)
1210
+ const rightUnwrapped = unwrapExpression(unwrapped.right);
1211
+ const isJsxConsequence =
1212
+ ts.isJsxElement(rightUnwrapped) ||
1213
+ ts.isJsxSelfClosingElement(rightUnwrapped) ||
1214
+ ts.isJsxFragment(rightUnwrapped);
1215
+
1216
+ if (!isJsxConsequence) {
1217
+ extractWithChainTracking(unwrapped.right, chainInfo, false);
1218
+ }
1219
+
1220
+ // If this is the root of the chain, register the compound conditional
1221
+ if (isChainRoot && chainInfo) {
1222
+ context.addCompoundConditional(chainInfo.compound);
1223
+ }
189
1224
  return;
190
1225
  }
191
1226
 
192
- // Check if right is a variable and left is a literal
193
- if (rightPath && isLiteralExpression(unwrapped.left)) {
194
- const literalValue = getLiteralValue(unwrapped.left, context);
195
- context.addConditionalUsage({
196
- path: rightPath.toLeftHandSideString(),
197
- conditionType: 'comparison',
198
- comparedValues: literalValue !== undefined ? [literalValue] : undefined,
199
- location,
200
- });
1227
+ // Handle binary expressions with || (logical OR)
1228
+ // When OR is inside an && chain, we need to continue chain tracking
1229
+ // and mark conditions as OR alternatives
1230
+ if (
1231
+ ts.isBinaryExpression(unwrapped) &&
1232
+ unwrapped.operatorToken.kind === ts.SyntaxKind.BarBarToken
1233
+ ) {
1234
+ if (chainInfo) {
1235
+ // We're inside an && chain - continue tracking but mark as OR alternatives
1236
+ // Generate an orGroupId so conditions from both sides can be grouped
1237
+ const orGroupId =
1238
+ chainInfo.currentOrGroupId ?? `or_${crypto.randomUUID().slice(0, 8)}`;
1239
+
1240
+ // Process left side with OR group tracking
1241
+ const leftChainInfo = {
1242
+ ...chainInfo,
1243
+ currentOrGroupId: orGroupId,
1244
+ };
1245
+ extractWithChainTracking(unwrapped.left, leftChainInfo, false);
1246
+
1247
+ // Process right side with same OR group
1248
+ // Note: we use leftChainInfo's currentPosition which may have been updated
1249
+ const rightChainInfo = {
1250
+ ...leftChainInfo,
1251
+ currentPosition: chainInfo.currentPosition,
1252
+ };
1253
+ extractWithChainTracking(unwrapped.right, rightChainInfo, false);
1254
+ } else {
1255
+ // Not inside a chain - OR breaks into independent conditional checks
1256
+ extractWithChainTracking(unwrapped.left, null, false);
1257
+ extractWithChainTracking(unwrapped.right, null, false);
1258
+ }
201
1259
  return;
202
1260
  }
203
1261
 
204
- // Both sides are variables - record both as comparisons without specific values
205
- if (leftPath) {
206
- context.addConditionalUsage({
207
- path: leftPath.toLeftHandSideString(),
208
- conditionType: 'comparison',
209
- location,
210
- });
1262
+ // Handle comparison operators (===, !==, <, >, <=, >=)
1263
+ // Example: `if (status === 'active')` - status is compared against 'active'
1264
+ if (
1265
+ ts.isBinaryExpression(unwrapped) &&
1266
+ isComparisonOperator(unwrapped.operatorToken.kind)
1267
+ ) {
1268
+ // Try to extract the variable and the compared value
1269
+ const leftPath = StructuredPath.fromNode(
1270
+ unwrapped.left,
1271
+ context.sourceFile,
1272
+ );
1273
+ const rightPath = StructuredPath.fromNode(
1274
+ unwrapped.right,
1275
+ context.sourceFile,
1276
+ );
1277
+
1278
+ // Determine the compared value for computing requiredValue
1279
+ const getRequiredValue = (
1280
+ literalValue: string | undefined,
1281
+ isNegatedComparison: boolean,
1282
+ ): string | boolean | undefined => {
1283
+ if (literalValue === undefined) return undefined;
1284
+ // For !== comparisons, the condition is true when NOT equal to the value
1285
+ // For === comparisons, the condition is true when equal to the value
1286
+ const isNotEqual =
1287
+ unwrapped.operatorToken.kind ===
1288
+ ts.SyntaxKind.ExclamationEqualsEqualsToken ||
1289
+ unwrapped.operatorToken.kind === ts.SyntaxKind.ExclamationEqualsToken;
1290
+ if (isNotEqual) {
1291
+ // !== 'value' means requiredValue is NOT 'value', but we express this as "not 'value'"
1292
+ return `not ${literalValue}`;
1293
+ }
1294
+ return literalValue;
1295
+ };
1296
+
1297
+ // Helper to add a condition
1298
+ const addCondition = (
1299
+ path: string,
1300
+ conditionType: 'comparison' | 'truthiness',
1301
+ comparedValues?: string[],
1302
+ requiredValue?: string | boolean,
1303
+ sourceExpr?: ts.Expression,
1304
+ ) => {
1305
+ const usage: ConditionalUsage = {
1306
+ path,
1307
+ conditionType,
1308
+ comparedValues,
1309
+ location,
1310
+ sourceLocation: getSourceLocation(unwrapped, context.sourceFile),
1311
+ isNegated,
1312
+ controlsJsxRendering,
1313
+ };
1314
+
1315
+ // Check for inline array-derived patterns (.length) on the source expression
1316
+ if (sourceExpr) {
1317
+ const arrayDerived = detectArrayDerivedPattern(sourceExpr);
1318
+ if (arrayDerived) {
1319
+ usage.derivedFrom = {
1320
+ operation: arrayDerived.operation,
1321
+ sourcePath: arrayDerived.sourcePath,
1322
+ };
1323
+ }
1324
+ }
1325
+
1326
+ // Add chain info if part of a compound conditional
1327
+ if (chainInfo) {
1328
+ usage.chainId = chainInfo.chainId;
1329
+ usage.chainPosition = chainInfo.currentPosition;
1330
+ usage.chainLength = chainInfo.chainLength;
1331
+ usage.chainExpression = chainInfo.chainExpression;
1332
+ chainInfo.currentPosition++;
1333
+
1334
+ // Add to compound conditional conditions
1335
+ chainInfo.compound.conditions.push({
1336
+ path,
1337
+ conditionType,
1338
+ comparedValues,
1339
+ isNegated,
1340
+ requiredValue,
1341
+ ...(chainInfo.currentOrGroupId && {
1342
+ orGroupId: chainInfo.currentOrGroupId,
1343
+ }),
1344
+ });
1345
+ }
1346
+
1347
+ context.addConditionalUsage(usage);
1348
+ };
1349
+
1350
+ // Check if left is a variable and right is a literal
1351
+ if (leftPath && isLiteralExpression(unwrapped.right)) {
1352
+ const literalValue = getLiteralValue(unwrapped.right, context);
1353
+ addCondition(
1354
+ leftPath.toLeftHandSideString(),
1355
+ 'comparison',
1356
+ literalValue !== undefined ? [literalValue] : undefined,
1357
+ getRequiredValue(literalValue, isNegated),
1358
+ unwrapped.left, // Pass source expression for array derivation detection
1359
+ );
1360
+ return;
1361
+ }
1362
+
1363
+ // Check if right is a variable and left is a literal
1364
+ if (rightPath && isLiteralExpression(unwrapped.left)) {
1365
+ const literalValue = getLiteralValue(unwrapped.left, context);
1366
+ addCondition(
1367
+ rightPath.toLeftHandSideString(),
1368
+ 'comparison',
1369
+ literalValue !== undefined ? [literalValue] : undefined,
1370
+ getRequiredValue(literalValue, isNegated),
1371
+ unwrapped.right, // Pass source expression for array derivation detection
1372
+ );
1373
+ return;
1374
+ }
1375
+
1376
+ // Both sides are variables - record both as comparisons without specific values
1377
+ if (leftPath) {
1378
+ addCondition(
1379
+ leftPath.toLeftHandSideString(),
1380
+ 'comparison',
1381
+ undefined,
1382
+ undefined,
1383
+ unwrapped.left,
1384
+ );
1385
+ }
1386
+ if (rightPath) {
1387
+ addCondition(
1388
+ rightPath.toLeftHandSideString(),
1389
+ 'comparison',
1390
+ undefined,
1391
+ undefined,
1392
+ unwrapped.right,
1393
+ );
1394
+ }
1395
+ return;
211
1396
  }
212
- if (rightPath) {
213
- context.addConditionalUsage({
214
- path: rightPath.toLeftHandSideString(),
215
- conditionType: 'comparison',
216
- location,
217
- });
1397
+
1398
+ // Handle prefix unary NOT expression: !variable
1399
+ // Example: `if (!isVisible)` - isVisible is a truthiness check (negated)
1400
+ if (
1401
+ ts.isPrefixUnaryExpression(unwrapped) &&
1402
+ unwrapped.operator === ts.SyntaxKind.ExclamationToken
1403
+ ) {
1404
+ extractWithChainTracking(unwrapped.operand, chainInfo, !isNegated);
1405
+ return;
218
1406
  }
219
- return;
220
- }
221
1407
 
222
- // Handle prefix unary NOT expression: !variable
223
- // Example: `if (!isVisible)` - isVisible is a truthiness check
224
- if (
225
- ts.isPrefixUnaryExpression(unwrapped) &&
226
- unwrapped.operator === ts.SyntaxKind.ExclamationToken
227
- ) {
228
- extractConditionalUsage(unwrapped.operand, context, location);
229
- return;
230
- }
1408
+ // Handle simple identifiers or property accesses (truthiness checks)
1409
+ // Example: `if (x)` or `x && <JSX />` - x is checked for truthiness
1410
+ const path = StructuredPath.fromNode(unwrapped, context.sourceFile);
1411
+ if (path && !path.isLiteral()) {
1412
+ const pathStr = path.toLeftHandSideString();
1413
+ const usage: ConditionalUsage = {
1414
+ path: pathStr,
1415
+ conditionType: 'truthiness',
1416
+ location,
1417
+ sourceLocation: getSourceLocation(unwrapped, context.sourceFile),
1418
+ isNegated,
1419
+ controlsJsxRendering,
1420
+ };
1421
+
1422
+ // Check for inline array-derived patterns (.some(), .every(), .includes(), .length)
1423
+ // This populates derivedFrom so downstream code can resolve to the base array path
1424
+ const arrayDerived = detectArrayDerivedPattern(unwrapped);
1425
+ if (arrayDerived) {
1426
+ usage.derivedFrom = {
1427
+ operation: arrayDerived.operation,
1428
+ sourcePath: arrayDerived.sourcePath,
1429
+ };
1430
+ }
231
1431
 
232
- // Handle simple identifiers or property accesses (truthiness checks)
233
- // Example: `if (x)` or `x && <JSX />` - x is checked for truthiness
234
- const path = StructuredPath.fromNode(unwrapped, context.sourceFile);
235
- if (path && !path.isLiteral()) {
236
- context.addConditionalUsage({
237
- path: path.toLeftHandSideString(),
238
- conditionType: 'truthiness',
239
- location,
240
- });
1432
+ // Add chain info if part of a compound conditional
1433
+ if (chainInfo) {
1434
+ usage.chainId = chainInfo.chainId;
1435
+ usage.chainPosition = chainInfo.currentPosition;
1436
+ usage.chainLength = chainInfo.chainLength;
1437
+ usage.chainExpression = chainInfo.chainExpression;
1438
+ chainInfo.currentPosition++;
1439
+
1440
+ // Add to compound conditional conditions
1441
+ // For truthiness, requiredValue is true if not negated, false if negated
1442
+ chainInfo.compound.conditions.push({
1443
+ path: pathStr,
1444
+ conditionType: 'truthiness',
1445
+ isNegated,
1446
+ requiredValue: !isNegated,
1447
+ ...(chainInfo.currentOrGroupId && {
1448
+ orGroupId: chainInfo.currentOrGroupId,
1449
+ }),
1450
+ });
1451
+ }
1452
+
1453
+ context.addConditionalUsage(usage);
1454
+ }
241
1455
  }
1456
+
1457
+ // Start extraction with no chain info
1458
+ extractWithChainTracking(condition, null, false);
242
1459
  }
243
1460
 
244
1461
  /**
@@ -341,7 +1558,28 @@ export function processExpression({
341
1558
  ) {
342
1559
  markConditionVariablesAsNullable(unwrappedNode, context);
343
1560
  // Extract conditional usages for key attribute detection
344
- extractConditionalUsage(unwrappedNode, context, 'logical-and');
1561
+ // Only call from the OUTERMOST && expression to avoid duplicates
1562
+ // Check if parent is also a && (meaning we're nested)
1563
+ const parent = unwrappedNode.parent;
1564
+ const parentIsAndChain =
1565
+ parent &&
1566
+ ts.isBinaryExpression(parent) &&
1567
+ parent.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken;
1568
+ if (!parentIsAndChain) {
1569
+ extractConditionalUsage(unwrappedNode, context, 'logical-and');
1570
+ }
1571
+ }
1572
+
1573
+ // CRITICAL: Extract conditionals from JSX BEFORE checking child boundaries
1574
+ // JSX elements are NOT scopes - their expressions use variables from the parent scope.
1575
+ // Even if the JSX element is within a child boundary (e.g., because it contains callbacks),
1576
+ // we must still extract conditionals from JSX expression children like {x && <div>...</div>}
1577
+ if (
1578
+ ts.isJsxElement(unwrappedNode) ||
1579
+ ts.isJsxSelfClosingElement(unwrappedNode) ||
1580
+ ts.isJsxFragment(unwrappedNode)
1581
+ ) {
1582
+ extractConditionalsFromJsx(unwrappedNode, context);
345
1583
  }
346
1584
 
347
1585
  // If the node falls within an excluded child scope, stop processing it.
@@ -378,7 +1616,7 @@ export function processExpression({
378
1616
  const structure = context.getStructure();
379
1617
 
380
1618
  // Propagate existing equivalencies for sub-properties
381
- for (const [key, value] of Object.entries(equivalentVariables)) {
1619
+ for (const [key, rawValue] of Object.entries(equivalentVariables)) {
382
1620
  // Check if this equivalency is for a sub-property of the identifier
383
1621
  // e.g., completeDataStructure['Function Arguments'] or completeDataStructure.foo
384
1622
  if (
@@ -389,8 +1627,14 @@ export function processExpression({
389
1627
  const newTargetPath = StructuredPath.fromBase(
390
1628
  targetPath.toString() + subPath,
391
1629
  );
392
- const valuePath = StructuredPath.fromBase(value);
393
- context.addEquivalence(newTargetPath, valuePath);
1630
+ // Handle both string and string[] values
1631
+ const values = Array.isArray(rawValue) ? rawValue : [rawValue];
1632
+ for (const value of values) {
1633
+ if (typeof value === 'string') {
1634
+ const valuePath = StructuredPath.fromBase(value);
1635
+ context.addEquivalence(newTargetPath, valuePath);
1636
+ }
1637
+ }
394
1638
  }
395
1639
  }
396
1640
 
@@ -535,7 +1779,8 @@ export function processExpression({
535
1779
  // Check if this is an environment variable access
536
1780
  const fullText = unwrappedNode.getText(context.sourceFile);
537
1781
  if (
538
- fullText.includes('.env.') // simple heuristic for env var access but not great
1782
+ fullText.includes('.env.') || // process.env.X, window.env.X
1783
+ isEnvStoreAccess(fullText) // env.X where env is likely an env config object
539
1784
  ) {
540
1785
  context.addEnvironmentVariable(fullText);
541
1786
  }
@@ -842,6 +2087,14 @@ export function processExpression({
842
2087
  // e.g., `const tab = segments[0] || 'default'` should trace tab back to segments[0]
843
2088
  if (operatorKind === ts.SyntaxKind.QuestionQuestionToken) {
844
2089
  // specifically for ?? we create an equivalence to the left side
2090
+ // IMPORTANT: Also process the left side recursively to apply method semantics
2091
+ // (e.g., for `const segments = splat?.split('/') ?? []`, we need split semantics)
2092
+ processExpression({
2093
+ node: unwrappedNode.left,
2094
+ context,
2095
+ // Don't pass targetPath here - we'll establish equivalence separately below
2096
+ });
2097
+
845
2098
  if (targetPath) {
846
2099
  resultPath = StructuredPath.fromNode(
847
2100
  unwrappedNode.left,
@@ -859,15 +2112,55 @@ export function processExpression({
859
2112
  );
860
2113
  }
861
2114
  } else if (operatorKind === ts.SyntaxKind.BarBarToken) {
862
- // For ||, also create an equivalence to the left side
2115
+ // For ||, create equivalences to BOTH sides
863
2116
  // This enables data flow tracing through fallback expressions
2117
+ // e.g., `const item = items.find(...) || null` should trace to both:
2118
+ // - items[] (from the find result)
2119
+ // - null (from the fallback)
864
2120
  if (targetPath) {
865
- resultPath = StructuredPath.fromNode(
2121
+ // Get paths for both sides
2122
+ const leftPath = StructuredPath.fromNode(
866
2123
  unwrappedNode.left,
867
2124
  context.sourceFile,
868
2125
  );
2126
+ const rightPath = StructuredPath.fromNode(
2127
+ unwrappedNode.right,
2128
+ context.sourceFile,
2129
+ );
2130
+
2131
+ // Collect all valid paths
2132
+ const allPaths: StructuredPath[] = [];
2133
+ if (leftPath) allPaths.push(leftPath);
2134
+ if (rightPath) allPaths.push(rightPath);
2135
+
2136
+ // Add multiple equivalencies to track both sources
2137
+ if (allPaths.length > 0) {
2138
+ context.addMultipleEquivalencies(targetPath, allPaths);
2139
+ }
2140
+
2141
+ // Process both sides to capture their internal structures
2142
+ processExpression({
2143
+ node: unwrappedNode.left,
2144
+ context,
2145
+ });
2146
+ processExpression({
2147
+ node: unwrappedNode.right,
2148
+ context,
2149
+ });
2150
+
2151
+ // Register the type for the target path
2152
+ const leftType = context.inferTypeFromNode(unwrappedNode.left);
2153
+ const rightType = context.inferTypeFromNode(unwrappedNode.right);
2154
+ const orResultType = isDefinedType(leftType)
2155
+ ? leftType
2156
+ : rightType || 'unknown';
2157
+ context.addType(targetPath, orResultType);
2158
+
2159
+ // Return early - we've already handled equivalencies with addMultipleEquivalencies
2160
+ // Don't fall through to the generic addEquivalence call below
2161
+ return true;
869
2162
  }
870
- // Note: Unlike ??, we don't set targetPath when there's no target
2163
+ // Note: When there's no targetPath, we don't recursively process
871
2164
  // because || is often used in boolean contexts where the full expression matters
872
2165
  }
873
2166
  } else if (operatorKind === ts.SyntaxKind.InstanceOfKeyword) {
@@ -930,9 +2223,10 @@ export function processExpression({
930
2223
  return false;
931
2224
  }
932
2225
 
933
- // Construct empty arguments list just to get the call path
934
- // We'll process each argument with its parameter path as targetPath
935
- const callPath = StructuredPath.fromNode(unwrappedNode, context.sourceFile);
2226
+ // Build call path using original source text for consistent schema paths.
2227
+ // IMPORTANT: Never use cyScope names in call paths - they are internal identifiers
2228
+ // that should not appear in schema paths or call signatures.
2229
+ const callPath = buildCallPathFromSource(unwrappedNode, context);
936
2230
 
937
2231
  // 2. Process all arguments recursively WITH targetPath for proper equivalence
938
2232
  for (let i = 0; i < unwrappedNode.arguments.length; i++) {
@@ -974,24 +2268,56 @@ export function processExpression({
974
2268
 
975
2269
  // Get the source expression path (e.g., the object for obj.method())
976
2270
  const sourceExpr = unwrappedNode.expression.expression;
977
- const sourcePath = StructuredPath.fromNode(
978
- sourceExpr,
979
- context.sourceFile,
980
- );
981
-
982
- if (sourcePath) {
983
- // For array-specific semantics (like push), verify the source is actually an array
984
- // This prevents router.push() from being mistakenly treated as Array.push()
985
- const isArraySemantics = semantics instanceof ArrayPushSemantics;
986
- const shouldApply =
987
- !isArraySemantics ||
988
- isLikelyArrayType(sourceExpr, context.typeChecker);
2271
+ const unwrappedSourceExpr = unwrapExpression(sourceExpr);
2272
+
2273
+ // When the source is a ternary expression like (cond ? arr : arr.slice()),
2274
+ // apply method semantics to BOTH branches directly. The ternary itself isn't
2275
+ // a variable - it's just a choice between two paths that both flow to the result.
2276
+ if (ts.isConditionalExpression(unwrappedSourceExpr)) {
2277
+ const branches = [
2278
+ unwrappedSourceExpr.whenTrue,
2279
+ unwrappedSourceExpr.whenFalse,
2280
+ ];
2281
+
2282
+ for (const branch of branches) {
2283
+ const branchPath = StructuredPath.fromNode(
2284
+ branch,
2285
+ context.sourceFile,
2286
+ );
2287
+ if (branchPath) {
2288
+ const isArraySemantics = semantics instanceof ArrayPushSemantics;
2289
+ const shouldApply =
2290
+ !isArraySemantics ||
2291
+ isLikelyArrayType(branch, context.typeChecker);
2292
+
2293
+ if (shouldApply) {
2294
+ semantics.addEquivalences(callPath, branchPath, context);
2295
+ returnType = semantics.getReturnType();
2296
+ handledBySemantics = true;
2297
+ }
2298
+ }
2299
+ }
2300
+ } else {
2301
+ // Regular (non-ternary) source expression
2302
+ const sourcePath = StructuredPath.fromNode(
2303
+ sourceExpr,
2304
+ context.sourceFile,
2305
+ );
989
2306
 
990
- if (shouldApply) {
991
- // Apply method semantics
992
- semantics.addEquivalences(callPath, sourcePath, context);
993
- returnType = semantics.getReturnType();
994
- handledBySemantics = true;
2307
+ if (sourcePath) {
2308
+ // For array-specific semantics (like push), verify the source is actually an array
2309
+ // This prevents router.push() from being mistakenly treated as Array.push()
2310
+ const isArraySemantics = semantics instanceof ArrayPushSemantics;
2311
+ const shouldApply =
2312
+ !isArraySemantics ||
2313
+ isLikelyArrayType(sourceExpr, context.typeChecker);
2314
+
2315
+ if (shouldApply) {
2316
+ // Apply method semantics
2317
+ semantics.addEquivalences(callPath, sourcePath, context);
2318
+ returnType = semantics.getReturnType();
2319
+ handledBySemantics = true;
2320
+ }
995
2321
  }
996
2322
  }
997
2323
  }
@@ -1099,6 +2425,13 @@ export function processExpression({
1099
2425
  // Create a path for this property within the base
1100
2426
  const propPath = targetPath.withProperty(propName);
1101
2427
 
2428
+ // Handle child boundaries (callback functions) in object properties
2429
+ // This establishes equivalency between the property path and the child scope
2430
+ // e.g., columns[0].renderCell → cyScope1()
2431
+ if (context.isChildBoundary(property.initializer)) {
2432
+ context.addChildBoundaryEquivalence(propPath, property.initializer);
2433
+ }
2434
+
1102
2435
  // Process the property value with propPath as targetPath
1103
2436
  // This allows nested object literals to work correctly
1104
2437
  processExpression({
@@ -1398,14 +2731,30 @@ export function processExpression({
1398
2731
  // Extract conditional usages for key attribute detection
1399
2732
  extractConditionalUsage(unwrappedNode.condition, context, 'ternary');
1400
2733
 
2734
+ // Extract conditional effects (setter calls in ternary branches)
2735
+ const knownSetters = findUseStateSetters(context.sourceFile);
2736
+ const effects = extractConditionalEffectsFromTernary(
2737
+ unwrappedNode,
2738
+ context,
2739
+ knownSetters,
2740
+ );
2741
+ for (const effect of effects) {
2742
+ context.addConditionalEffect(effect);
2743
+ }
2744
+
1401
2745
  // Process all parts recursively
1402
2746
  processExpression({
1403
2747
  node: unwrappedNode.condition,
1404
2748
  context,
1405
2749
  typeHint: 'boolean | unknown',
1406
2750
  }); //TODO: could we capture that this is evidence of a boolean type?
1407
- processExpression({ node: unwrappedNode.whenTrue, context });
1408
- processExpression({ node: unwrappedNode.whenFalse, context });
2751
+
2752
+ // Process both branches WITH targetPath to establish equivalencies
2753
+ // This is critical for tracing nested properties through ternary assignments
2754
+ // e.g., const items = condition ? arr1 : arr2; items.map(i => i.prop)
2755
+ // We need items to be equivalent to both arr1 AND arr2 for proper tracing
2756
+ processExpression({ node: unwrappedNode.whenTrue, context, targetPath });
2757
+ processExpression({ node: unwrappedNode.whenFalse, context, targetPath });
1409
2758
 
1410
2759
  // Create a path for the whole expression
1411
2760
  const expressionSourcePath = nodeToSource(
@@ -1428,10 +2777,22 @@ export function processExpression({
1428
2777
  // Register type for the expression
1429
2778
  context.addType(expressionSourcePath, resultType);
1430
2779
 
1431
- // If targetPath is provided, establish equivalence and register type
2780
+ // If targetPath is provided, only register type (don't overwrite branch equivalencies)
2781
+ // The equivalencies to individual branches (set above) are more useful for tracing
2782
+ // than an equivalency to the entire ternary expression text
1432
2783
  if (targetPath) {
1433
- context.addEquivalence(targetPath, expressionSourcePath);
1434
- context.addType(targetPath, resultType);
2784
+ // NOTE: We intentionally do NOT add equivalence here.
2785
+ // The branch processing above already added equivalencies:
2786
+ // targetPath -> whenTrue branch
2787
+ // targetPath -> whenFalse branch
2788
+ // Adding an equivalence to expressionSourcePath would overwrite those
2789
+ // with a useless equivalence to the ternary text itself.
2790
+ //
2791
+ // Use updateSchemaType instead of addType because:
2792
+ // 1. Branch processing may have already set a type on targetPath
2793
+ // 2. addType has a guard that prevents overwriting specific types with 'unknown'
2794
+ // 3. updateSchemaType bypasses this guard, ensuring the ternary's computed type is used
2795
+ context.updateSchemaType(targetPath, resultType);
1435
2796
  }
1436
2797
 
1437
2798
  return true;
@@ -1514,6 +2875,35 @@ export function processExpression({
1514
2875
 
1515
2876
  // Handle Arrow Functions: (p) => p.prop, (a, b) => { ... }
1516
2877
  if (ts.isArrowFunction(unwrappedNode)) {
2878
+ // If this arrow function is a child boundary (e.g., a .map() callback),
2879
+ // don't process its parameters here - they will be processed when the
2880
+ // child scope is analyzed separately. This prevents parameter variables
2881
+ // from leaking into the parent scope's equivalencies.
2882
+ // Check if this arrow function is a child boundary (i.e., should be processed
2883
+ // as a separate child scope, not here in the parent scope).
2884
+ //
2885
+ // We use two checks because childBoundary positions can be unreliable:
2886
+ // 1. Position-based check (standard isChildBoundary)
2887
+ // 2. Text-based check: if the arrow function text doesn't appear in the
2888
+ // statement text, it was replaced with a cyScope placeholder
2889
+ const isChildBoundary = context.isChildBoundary(unwrappedNode);
2890
+
2891
+ // Text-based child scope detection for when positions are unreliable
2892
+ const arrowFnText = unwrappedNode.getText(context.sourceFile);
2893
+ const firstLine = arrowFnText.split('\n')[0].trim();
2894
+ const searchText = firstLine.substring(0, Math.min(20, firstLine.length));
2895
+ const isInStatementText = context.statementInfo.text.includes(searchText);
2896
+ const isChildScope = !isInStatementText && arrowFnText.length > 10;
2897
+
2898
+ if (isChildBoundary || isChildScope) {
2899
+ // The method semantics (e.g., ArrayMapSemantics) have already established
2900
+ // the necessary equivalences between the child scope placeholder and array elements
2901
+ if (targetPath) {
2902
+ context.addType(targetPath, 'function');
2903
+ }
2904
+ return true;
2905
+ }
2906
+
1517
2907
  // Create a path for the function
1518
2908
  const functionPath = StructuredPath.empty();
1519
2909
 
@@ -2232,6 +3622,9 @@ function processJsxAttribute(
2232
3622
  if (ts.isJsxExpression(attr.initializer) && attr.initializer.expression) {
2233
3623
  const expression = attr.initializer.expression;
2234
3624
  if (context.isChildBoundary(expression)) {
3625
+ // Create equivalency between attribute path and child scope
3626
+ // e.g., Grid().signature[0].renderRow → cyScope1()
3627
+ context.addChildBoundaryEquivalence(attributePath, expression);
2235
3628
  return true;
2236
3629
  }
2237
3630