@codeyam/codeyam-cli 0.1.0-staging.596f0eb → 0.1.0-staging.76566f9

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 (354) hide show
  1. package/analyzer-template/.build-info.json +7 -7
  2. package/analyzer-template/log.txt +3 -3
  3. package/analyzer-template/package.json +2 -1
  4. package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +2 -0
  5. package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +22 -0
  6. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +23 -1
  7. package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +401 -106
  8. package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +60 -0
  9. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +734 -45
  10. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +2 -1
  11. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +715 -0
  12. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +233 -75
  13. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +19 -1
  14. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +34 -1
  15. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +23 -0
  16. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
  17. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +34 -1
  18. package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +236 -24
  19. package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +18 -1
  20. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +41 -0
  21. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +37 -4
  22. package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +5 -0
  23. package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +213 -12
  24. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +36 -25
  25. package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +114 -11
  26. package/analyzer-template/packages/ai/src/lib/getConditionalUsagesFromCode.ts +143 -31
  27. package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +8 -2
  28. package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +7 -0
  29. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +42 -2
  30. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +38 -2
  31. package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +28 -2
  32. package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +5 -0
  33. package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +8 -1
  34. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +127 -43
  35. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +158 -0
  36. package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +405 -45
  37. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
  38. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +260 -133
  39. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +10 -5
  40. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +77 -83
  41. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +2 -5
  42. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +196 -86
  43. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts +15 -0
  44. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts.map +1 -0
  45. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js +31 -0
  46. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js.map +1 -0
  47. package/analyzer-template/packages/aws/package.json +1 -1
  48. package/analyzer-template/packages/aws/s3/index.ts +1 -0
  49. package/analyzer-template/packages/aws/src/lib/s3/checkS3ObjectExists.ts +47 -0
  50. package/analyzer-template/packages/database/src/lib/kysely/db.ts +4 -4
  51. package/analyzer-template/packages/database/src/lib/kysely/tableRelations.ts +2 -2
  52. package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +20 -9
  53. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +9 -4
  54. package/analyzer-template/packages/generate/src/lib/deepMerge.ts +26 -1
  55. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -2
  56. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +2 -2
  57. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tableRelations.d.ts +2 -2
  58. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +8 -1
  59. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
  60. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +14 -7
  61. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
  62. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
  63. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  64. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +1 -1
  65. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
  66. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
  67. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
  68. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  69. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.d.ts.map +1 -1
  70. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js +27 -1
  71. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js.map +1 -1
  72. package/analyzer-template/packages/github/dist/types/index.d.ts +4 -3
  73. package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
  74. package/analyzer-template/packages/github/dist/types/index.js +1 -0
  75. package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
  76. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +31 -1
  77. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
  78. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +51 -1
  79. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
  80. package/analyzer-template/packages/github/dist/types/src/types/Scenario.js +21 -1
  81. package/analyzer-template/packages/github/dist/types/src/types/Scenario.js.map +1 -1
  82. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +48 -0
  83. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  84. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
  85. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
  86. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  87. package/analyzer-template/packages/types/index.ts +8 -0
  88. package/analyzer-template/packages/types/src/types/Analysis.ts +32 -1
  89. package/analyzer-template/packages/types/src/types/Scenario.ts +75 -6
  90. package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +49 -0
  91. package/analyzer-template/packages/ui-components/src/components/ScenarioDetailInteractiveView.tsx +23 -7
  92. package/analyzer-template/packages/utils/dist/types/index.d.ts +4 -3
  93. package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
  94. package/analyzer-template/packages/utils/dist/types/index.js +1 -0
  95. package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
  96. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +31 -1
  97. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
  98. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +51 -1
  99. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
  100. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.js +21 -1
  101. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.js.map +1 -1
  102. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +48 -0
  103. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  104. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
  105. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
  106. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  107. package/analyzer-template/packages/utils/src/lib/lightweightEntityExtractor.ts +27 -0
  108. package/analyzer-template/playwright/takeElementScreenshot.ts +26 -11
  109. package/analyzer-template/playwright/takeScreenshot.ts +9 -7
  110. package/analyzer-template/project/constructMockCode.ts +286 -84
  111. package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +77 -37
  112. package/analyzer-template/project/reconcileMockDataKeys.ts +5 -2
  113. package/analyzer-template/project/runMultiScenarioServer.ts +11 -10
  114. package/analyzer-template/project/serverOnlyModules.ts +71 -23
  115. package/analyzer-template/project/start.ts +10 -0
  116. package/analyzer-template/project/startScenarioCapture.ts +73 -41
  117. package/analyzer-template/project/writeMockDataTsx.ts +115 -54
  118. package/analyzer-template/project/writeScenarioComponents.ts +571 -162
  119. package/analyzer-template/project/writeSimpleRoot.ts +11 -13
  120. package/background/src/lib/virtualized/project/constructMockCode.js +265 -75
  121. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  122. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +67 -32
  123. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
  124. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +5 -2
  125. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
  126. package/background/src/lib/virtualized/project/runMultiScenarioServer.js +11 -9
  127. package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
  128. package/background/src/lib/virtualized/project/serverOnlyModules.js +62 -25
  129. package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
  130. package/background/src/lib/virtualized/project/start.js +6 -0
  131. package/background/src/lib/virtualized/project/start.js.map +1 -1
  132. package/background/src/lib/virtualized/project/startScenarioCapture.js +54 -31
  133. package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
  134. package/background/src/lib/virtualized/project/writeMockDataTsx.js +106 -46
  135. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  136. package/background/src/lib/virtualized/project/writeScenarioComponents.js +399 -106
  137. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  138. package/background/src/lib/virtualized/project/writeSimpleRoot.js +11 -11
  139. package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
  140. package/codeyam-cli/src/cli.js +2 -0
  141. package/codeyam-cli/src/cli.js.map +1 -1
  142. package/codeyam-cli/src/commands/debug.js +14 -2
  143. package/codeyam-cli/src/commands/debug.js.map +1 -1
  144. package/codeyam-cli/src/commands/recapture.js +215 -0
  145. package/codeyam-cli/src/commands/recapture.js.map +1 -0
  146. package/codeyam-cli/src/commands/report.js +26 -23
  147. package/codeyam-cli/src/commands/report.js.map +1 -1
  148. package/codeyam-cli/src/utils/backgroundServer.js +2 -2
  149. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  150. package/codeyam-cli/src/utils/generateReport.js +252 -106
  151. package/codeyam-cli/src/utils/generateReport.js.map +1 -1
  152. package/codeyam-cli/src/utils/install-skills.js +2 -2
  153. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  154. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +38 -0
  155. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
  156. package/codeyam-cli/src/utils/queue/job.js +140 -16
  157. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  158. package/codeyam-cli/src/utils/queue/manager.js +19 -7
  159. package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
  160. package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
  161. package/codeyam-cli/src/webserver/app/lib/database.js +47 -0
  162. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  163. package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
  164. package/codeyam-cli/src/webserver/backgroundServer.js +5 -10
  165. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  166. package/codeyam-cli/src/webserver/bootstrap.js +9 -0
  167. package/codeyam-cli/src/webserver/bootstrap.js.map +1 -0
  168. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-wXL1Z2Aq.js +1 -0
  169. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-efWKDYMr.js → EntityTypeBadge-CzGX-miz.js} +1 -1
  170. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-CXFKsCOD.js +41 -0
  171. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-D-9pXIaY.js +25 -0
  172. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-CBQPrpT0.js +3 -0
  173. package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-D1CdlbrV.js +6 -0
  174. package/codeyam-cli/src/webserver/build/client/assets/LogViewer-wDPcZNKx.js +3 -0
  175. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-4lcOlid-.js +11 -0
  176. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BfmDgXxG.js +1 -0
  177. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CUxUNEEC.js +15 -0
  178. package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-COPstp9J.js → TruncatedFilePath-6J7zDUD5.js} +1 -1
  179. package/codeyam-cli/src/webserver/build/client/assets/_index-DHImXdXq.js +11 -0
  180. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-CVP_WGQ3.js +32 -0
  181. package/codeyam-cli/src/webserver/build/client/assets/api.link-scenario-value-l0sNRNKZ.js +1 -0
  182. package/codeyam-cli/src/webserver/build/client/assets/api.update-key-attributes-l0sNRNKZ.js +1 -0
  183. package/codeyam-cli/src/webserver/build/client/assets/api.update-valid-values-l0sNRNKZ.js +1 -0
  184. package/codeyam-cli/src/webserver/build/client/assets/chevron-down-BYimnrHg.js +6 -0
  185. package/codeyam-cli/src/webserver/build/client/assets/chunk-JMJ3UQ3L-BambyYE_.js +51 -0
  186. package/codeyam-cli/src/webserver/build/client/assets/circle-check-CaVsIRxt.js +6 -0
  187. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-CgUsG7ib.js +21 -0
  188. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-CKnwPCDr.js +1 -0
  189. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-DW_hdGUc.js +1 -0
  190. package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-Dt-SjPsw.js +23 -0
  191. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DyB90fWk.js +1 -0
  192. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-D_3ero5o.js +1 -0
  193. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-CfLCUi9S.js +5 -0
  194. package/codeyam-cli/src/webserver/build/client/assets/entry.client-DKJyZfAY.js +29 -0
  195. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-DAtOlaWE.js +1 -0
  196. package/codeyam-cli/src/webserver/build/client/assets/files-ClR0d32A.js +1 -0
  197. package/codeyam-cli/src/webserver/build/client/assets/git-D62Lxxmv.js +15 -0
  198. package/codeyam-cli/src/webserver/build/client/assets/globals-C9s7Lhdl.css +1 -0
  199. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-fmIEn3Bc.js +9 -0
  200. package/codeyam-cli/src/webserver/build/client/assets/index-BosqDOlH.js +3 -0
  201. package/codeyam-cli/src/webserver/build/client/assets/index-CzNNiTkw.js +9 -0
  202. package/codeyam-cli/src/webserver/build/client/assets/keyAttributeCoverage-CTlFMihX.js +1 -0
  203. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-CNp9QFCX.js +6 -0
  204. package/codeyam-cli/src/webserver/build/client/assets/manifest-0d27da29.js +1 -0
  205. package/codeyam-cli/src/webserver/build/client/assets/preload-helper-ckwbz45p.js +1 -0
  206. package/codeyam-cli/src/webserver/build/client/assets/root-B_wIKCIf.js +56 -0
  207. package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
  208. package/codeyam-cli/src/webserver/build/client/assets/search-DDGjYAMJ.js +6 -0
  209. package/codeyam-cli/src/webserver/build/client/assets/settings-DgTyB-Wg.js +1 -0
  210. package/codeyam-cli/src/webserver/build/client/assets/simulations-CoNWGt0K.js +1 -0
  211. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-CBc5dE1s.js +6 -0
  212. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BMIGFP-m.js +1 -0
  213. package/codeyam-cli/src/webserver/build/client/assets/useInteractiveMode-Dk_FQqWJ.js +1 -0
  214. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-3pmpUQB-.js → useLastLogLine-BqPPNjAl.js} +1 -1
  215. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DsJbgMY9.js +1 -0
  216. package/codeyam-cli/src/webserver/build/client/assets/{useToast-DEyawJ8r.js → useToast-DWHcCcl1.js} +1 -1
  217. package/codeyam-cli/src/webserver/build/server/assets/index-CU58-Ttc.js +1 -0
  218. package/codeyam-cli/src/webserver/build/server/assets/server-build-D35o2uae.js +175 -0
  219. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  220. package/codeyam-cli/src/webserver/build-info.json +5 -5
  221. package/codeyam-cli/src/webserver/devServer.js +1 -3
  222. package/codeyam-cli/src/webserver/devServer.js.map +1 -1
  223. package/codeyam-cli/templates/codeyam-setup-skill.md +138 -3
  224. package/codeyam-cli/templates/debug-codeyam.md +625 -0
  225. package/package.json +14 -14
  226. package/packages/ai/src/lib/analyzeScope.js +2 -0
  227. package/packages/ai/src/lib/analyzeScope.js.map +1 -1
  228. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +16 -0
  229. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
  230. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +16 -0
  231. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
  232. package/packages/ai/src/lib/astScopes/processExpression.js +305 -88
  233. package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
  234. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +582 -41
  235. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  236. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +2 -1
  237. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
  238. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +454 -0
  239. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -0
  240. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +173 -55
  241. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
  242. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +16 -1
  243. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
  244. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +30 -1
  245. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
  246. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +20 -0
  247. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
  248. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js +86 -0
  249. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js.map +1 -0
  250. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +28 -2
  251. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
  252. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +179 -17
  253. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +1 -1
  254. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +6 -0
  255. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +1 -1
  256. package/packages/ai/src/lib/generateChangesEntityScenarioData.js +41 -0
  257. package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
  258. package/packages/ai/src/lib/generateChangesEntityScenarios.js +37 -4
  259. package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
  260. package/packages/ai/src/lib/generateEntityDataStructure.js +4 -0
  261. package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
  262. package/packages/ai/src/lib/generateEntityKeyAttributes.js +176 -9
  263. package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +1 -1
  264. package/packages/ai/src/lib/generateEntityScenarioData.js +29 -25
  265. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  266. package/packages/ai/src/lib/generateEntityScenarios.js +105 -9
  267. package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
  268. package/packages/ai/src/lib/getConditionalUsagesFromCode.js +84 -14
  269. package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
  270. package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -1
  271. package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
  272. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +6 -0
  273. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
  274. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +38 -2
  275. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
  276. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +38 -2
  277. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
  278. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +16 -3
  279. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
  280. package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
  281. package/packages/ai/src/lib/worker/analyzeScopeWorker.js +4 -0
  282. package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
  283. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +100 -23
  284. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  285. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +125 -0
  286. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -0
  287. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +298 -45
  288. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
  289. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
  290. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
  291. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +201 -80
  292. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  293. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +10 -5
  294. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +1 -1
  295. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +55 -69
  296. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
  297. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +2 -5
  298. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
  299. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +171 -81
  300. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  301. package/packages/database/src/lib/kysely/db.js +2 -2
  302. package/packages/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
  303. package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  304. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
  305. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  306. package/packages/generate/src/lib/deepMerge.js +27 -1
  307. package/packages/generate/src/lib/deepMerge.js.map +1 -1
  308. package/packages/types/index.js +1 -0
  309. package/packages/types/index.js.map +1 -1
  310. package/packages/types/src/types/Scenario.js +21 -1
  311. package/packages/types/src/types/Scenario.js.map +1 -1
  312. package/packages/utils/src/lib/lightweightEntityExtractor.js +25 -0
  313. package/packages/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  314. package/scripts/finalize-analyzer.cjs +3 -1
  315. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
  316. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
  317. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-CVbSvOjo.js +0 -1
  318. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-DcwcHyl5.js +0 -1
  319. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-WgwC1GfJ.js +0 -26
  320. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-IEKom9O2.js +0 -3
  321. package/codeyam-cli/src/webserver/build/client/assets/LogViewer-BYnfxbUG.js +0 -3
  322. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-_lBPJCzG.js +0 -1
  323. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-lHVhvsu_.js +0 -1
  324. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-d_TBk4GQ.js +0 -5
  325. package/codeyam-cli/src/webserver/build/client/assets/_index-kGT7VUqj.js +0 -1
  326. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-DDGmhu7P.js +0 -7
  327. package/codeyam-cli/src/webserver/build/client/assets/chevron-down-n_HPRfM_.js +0 -1
  328. package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-CbVoyx1U.js +0 -26
  329. package/codeyam-cli/src/webserver/build/client/assets/circle-check-D1VOYveA.js +0 -1
  330. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-YR8jjAlu.js +0 -1
  331. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-B8vP3V_s.js +0 -1
  332. package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-CN6aLCT1.js +0 -16
  333. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DA5Jeu2P.js +0 -1
  334. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-BTeitalf.js +0 -5
  335. package/codeyam-cli/src/webserver/build/client/assets/entry.client-du6UEYD-.js +0 -13
  336. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-BpjkhMoi.js +0 -1
  337. package/codeyam-cli/src/webserver/build/client/assets/files-BQGvk4lJ.js +0 -1
  338. package/codeyam-cli/src/webserver/build/client/assets/git-DVdYRT-I.js +0 -12
  339. package/codeyam-cli/src/webserver/build/client/assets/globals-CO-U8Bpo.css +0 -1
  340. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +0 -5
  341. package/codeyam-cli/src/webserver/build/client/assets/index-DCG-vks0.js +0 -1
  342. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-GazdNeLl.js +0 -1
  343. package/codeyam-cli/src/webserver/build/client/assets/manifest-0b694d28.js +0 -1
  344. package/codeyam-cli/src/webserver/build/client/assets/root-D3tQP7hx.js +0 -16
  345. package/codeyam-cli/src/webserver/build/client/assets/search-CIY6XmtE.js +0 -1
  346. package/codeyam-cli/src/webserver/build/client/assets/server-build-CMKNK2uU.css +0 -1
  347. package/codeyam-cli/src/webserver/build/client/assets/settings-CoMDgElu.js +0 -1
  348. package/codeyam-cli/src/webserver/build/client/assets/simulations-agkniXp2.js +0 -1
  349. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-B2VUcygF.js +0 -1
  350. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-EvdK-zXP.js +0 -1
  351. package/codeyam-cli/src/webserver/build/server/assets/index-DGVHQEXD.js +0 -1
  352. package/codeyam-cli/src/webserver/build/server/assets/server-build-CghkTkIL.js +0 -166
  353. package/codeyam-cli/templates/debug-command.md +0 -303
  354. /package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-CMKNK2uU.css → styles-CMKNK2uU.css} +0 -0
@@ -17,6 +17,12 @@ interface UseStateInfo {
17
17
  export class ReactFrameworkManager implements EquivalencyManager {
18
18
  private useStateInfos: UseStateInfo[] = [];
19
19
  private useCallbackEquivalents: Record<string, string> = {};
20
+ // Track variables used as ref props - they should be typed as 'null'
21
+ // Format: { scopeNodeName -> Set of variable paths }
22
+ private refVariables: Map<string, Set<string>> = new Map();
23
+ // Track ref variable source paths for updating external function call schemas in finalize
24
+ // Format: { functionCallName -> Set of source paths (e.g., 'useAutoAnimate().functionCallReturnValue[]') }
25
+ private refVariableSources: Map<string, Set<string>> = new Map();
20
26
 
21
27
  postProcess(scopeNode: ScopeNode, scopeDataStructure: ScopeDataStructure) {
22
28
  this.handleUseState(scopeNode, scopeDataStructure);
@@ -139,7 +145,27 @@ export class ReactFrameworkManager implements EquivalencyManager {
139
145
  'main',
140
146
  ]);
141
147
 
142
- finalize(_scopeNode: ScopeNode, _scopeDataStructure: ScopeDataStructure) {}
148
+ finalize(scopeNode: ScopeNode, scopeDataStructure: ScopeDataStructure) {
149
+ // Set all tracked ref variables to 'null' type
150
+ // This ensures mock data generation uses null instead of placeholder strings
151
+ const refVarsForScope = this.refVariables.get(scopeNode.name);
152
+ if (refVarsForScope) {
153
+ for (const refVar of refVarsForScope) {
154
+ scopeNode.schema[refVar] = 'null';
155
+ }
156
+ }
157
+
158
+ // Update external function call schemas with ref source paths
159
+ // This runs AFTER schema building is complete, so the null values won't be overwritten
160
+ for (const efc of scopeDataStructure.externalFunctionCalls) {
161
+ const refSourcePaths = this.refVariableSources.get(efc.name);
162
+ if (refSourcePaths) {
163
+ for (const sourcePath of refSourcePaths) {
164
+ efc.schema[sourcePath] = 'null';
165
+ }
166
+ }
167
+ }
168
+ }
143
169
 
144
170
  private findUseStateInfo(useStateCall: string) {
145
171
  return this.useStateInfos.find(
@@ -382,90 +408,126 @@ export class ReactFrameworkManager implements EquivalencyManager {
382
408
  let propagated = false;
383
409
  const functionCallSignature = getFunctionCallSignature(subPathParts);
384
410
 
385
- const relevantUseStateInfo = this.findUseStateInfo(functionCallSignature);
411
+ let relevantUseStateInfo = this.findUseStateInfo(functionCallSignature);
412
+
413
+ // If we didn't find a useState call directly, check if the function being called
414
+ // is a setter variable (e.g., setWorkouts from useState)
415
+ if (!relevantUseStateInfo && functionCallSignature) {
416
+ // Extract the function name from the call (e.g., "setWorkouts" from "setWorkouts(data || [])")
417
+ const fnName = functionCallSignature.split('(')[0];
418
+ relevantUseStateInfo = this.useStateInfos.find(
419
+ (info) => info.setter === fnName,
420
+ );
421
+ }
386
422
 
387
423
  if (relevantUseStateInfo) {
388
424
  const pathParts = scopeDataStructure.splitPath(path);
389
- if (pathParts.length < 3) return false;
390
425
 
391
- const basePath = scopeDataStructure.joinPathParts([
392
- ...pathParts.slice(0, 2),
393
- pathParts[2],
394
- ]);
426
+ // Check if this is a direct setter variable call (e.g., setWorkouts(data).signature[0])
427
+ // rather than a useState path (e.g., useState<X>().functionCallReturnValue[1].signature[0])
428
+ const fnName = functionCallSignature?.split('(')[0];
429
+ const isDirectSetterCall = fnName === relevantUseStateInfo.setter;
430
+
431
+ if (isDirectSetterCall && pathParts.length === 2) {
432
+ // Handle direct setter calls like setWorkouts(data || []).signature[0] = data
433
+ const lastPart = pathParts[1];
434
+ if (lastPart === 'signature[0]') {
435
+ // Get the value being passed to the setter from the equivalency
436
+ const originScopeInfoName =
437
+ equivalencyValueChain[0]?.currentPath?.scopeNodeName;
438
+ if (!originScopeInfoName) return propagated;
439
+
440
+ const originScope =
441
+ scopeDataStructure.getScopeOrFunctionCallInfo(originScopeInfoName);
442
+ const setterCallEquiv = originScope?.equivalencies?.[path];
443
+ if (!setterCallEquiv || setterCallEquiv.length === 0)
444
+ return propagated;
445
+
446
+ const argumentPath = setterCallEquiv[0].schemaPath;
447
+ const argumentScopeName = setterCallEquiv[0].scopeNodeName;
448
+
449
+ // Create equivalency: useState<X>().functionCallReturnValue[0] = argumentPath
450
+ propagated = true;
451
+ const valuePath = `${relevantUseStateInfo.useStateCall}.functionCallReturnValue[0]`;
452
+ const useStateScopeInfo =
453
+ scopeDataStructure.getScopeOrFunctionCallInfo(
454
+ relevantUseStateInfo.scopeNodeName,
455
+ ) as ScopeNode;
395
456
 
396
- const expectedSetterBasePath = scopeDataStructure.joinPathParts([
397
- functionCallSignature,
398
- 'functionCallReturnValue[1]',
399
- ]);
457
+ scopeDataStructure.addEquivalency(
458
+ valuePath,
459
+ argumentPath,
460
+ argumentScopeName,
461
+ useStateScopeInfo,
462
+ 'useState setter call equivalency (direct)',
463
+ equivalencyValueChain,
464
+ traceId,
465
+ );
466
+ }
467
+ } else if (pathParts.length >= 3) {
468
+ // Original logic for useState path patterns
469
+ const basePath = scopeDataStructure.joinPathParts([
470
+ ...pathParts.slice(0, 2),
471
+ pathParts[2],
472
+ ]);
400
473
 
401
- // if (traceId) {
402
- // console.info(
403
- // 'Debug Propagation: useState base path',
404
- // JSON.stringify(
405
- // {
406
- // traceId,
407
- // basePath,
408
- // expectedValueBasePath,
409
- // expectedSetterBasePath,
410
- // },
411
- // null,
412
- // 2,
413
- // ),
414
- // );
415
- // }
416
-
417
- if (basePath === expectedSetterBasePath) {
418
- const originScopeInfoName =
419
- equivalencyValueChain[0].currentPath?.scopeNodeName;
420
- const setterScope =
421
- scopeDataStructure.getScopeOrFunctionCallInfo(originScopeInfoName);
422
- const setterEquivalencyPath = Object.keys(
423
- setterScope.equivalencies,
424
- ).find((p) => {
425
- if (!p.startsWith(relevantUseStateInfo.setter)) return false;
426
- const pParts = scopeDataStructure.splitPath(p);
427
-
428
- const valid = pathParts
429
- .slice(3)
430
- .reverse()
431
- .every((part, index) => [...pParts].reverse()[index] === part);
432
-
433
- // if (p.includes('.title') && valid)
434
- // console.info({ p, pParts, pathParts: pathParts.slice(3) });
435
-
436
- return valid;
437
- });
438
-
439
- if (!setterEquivalencyPath) return;
440
-
441
- const setterEquivalencyPathParts = scopeDataStructure.splitPath(
442
- setterEquivalencyPath,
443
- );
444
- const setterEquivalentVariable =
445
- setterScope.equivalencies[setterEquivalencyPath][0].schemaPath;
474
+ const expectedSetterBasePath = scopeDataStructure.joinPathParts([
475
+ functionCallSignature,
476
+ 'functionCallReturnValue[1]',
477
+ ]);
446
478
 
447
- if (setterEquivalentVariable === expectedSetterBasePath) return;
479
+ if (basePath === expectedSetterBasePath) {
480
+ const originScopeInfoName =
481
+ equivalencyValueChain[0].currentPath?.scopeNodeName;
482
+ const setterScope =
483
+ scopeDataStructure.getScopeOrFunctionCallInfo(originScopeInfoName);
484
+ const setterEquivalencyPath = Object.keys(
485
+ setterScope.equivalencies,
486
+ ).find((p) => {
487
+ if (!p.startsWith(relevantUseStateInfo.setter)) return false;
488
+ const pParts = scopeDataStructure.splitPath(p);
489
+
490
+ const valid = pathParts
491
+ .slice(3)
492
+ .reverse()
493
+ .every((part, index) => [...pParts].reverse()[index] === part);
494
+
495
+ return valid;
496
+ });
497
+
498
+ if (!setterEquivalencyPath) return propagated;
499
+
500
+ const setterEquivalencyPathParts = scopeDataStructure.splitPath(
501
+ setterEquivalencyPath,
502
+ );
503
+ const setterEquivalentVariable =
504
+ setterScope.equivalencies[setterEquivalencyPath][0].schemaPath;
448
505
 
449
- propagated = true;
450
- const valuePath = `${functionCallSignature}.functionCallReturnValue[0]`;
451
- const useStateScopeInfo = scopeDataStructure.getScopeOrFunctionCallInfo(
452
- relevantUseStateInfo.scopeNodeName,
453
- ) as ScopeNode;
506
+ if (setterEquivalentVariable === expectedSetterBasePath)
507
+ return propagated;
454
508
 
455
- const fullValuePath = scopeDataStructure.joinPathParts([
456
- valuePath,
457
- ...setterEquivalencyPathParts.slice(2),
458
- ]);
509
+ propagated = true;
510
+ const valuePath = `${functionCallSignature}.functionCallReturnValue[0]`;
511
+ const useStateScopeInfo =
512
+ scopeDataStructure.getScopeOrFunctionCallInfo(
513
+ relevantUseStateInfo.scopeNodeName,
514
+ ) as ScopeNode;
515
+
516
+ const fullValuePath = scopeDataStructure.joinPathParts([
517
+ valuePath,
518
+ ...setterEquivalencyPathParts.slice(2),
519
+ ]);
459
520
 
460
- scopeDataStructure.addEquivalency(
461
- fullValuePath,
462
- setterEquivalentVariable,
463
- originScopeInfoName,
464
- useStateScopeInfo,
465
- 'useState setter call equivalency',
466
- equivalencyValueChain,
467
- traceId,
468
- );
521
+ scopeDataStructure.addEquivalency(
522
+ fullValuePath,
523
+ setterEquivalentVariable,
524
+ originScopeInfoName,
525
+ useStateScopeInfo,
526
+ 'useState setter call equivalency',
527
+ equivalencyValueChain,
528
+ traceId,
529
+ );
530
+ }
469
531
  }
470
532
  }
471
533
 
@@ -564,6 +626,102 @@ export class ReactFrameworkManager implements EquivalencyManager {
564
626
  for (const [equivalentPath, equivalentValues] of Object.entries(
565
627
  scopeNode.equivalencies,
566
628
  )) {
629
+ // Check if the equivalency KEY (e.g., "div().signature[0].ref") ends with .ref
630
+ // If so, the VALUE (e.g., "parent") should be marked as null
631
+ const equivalentPathParts = scopeDataStructure.splitPath(equivalentPath);
632
+ const pathLength = equivalentPathParts.length;
633
+
634
+ if (pathLength >= 2) {
635
+ const secondToLast = equivalentPathParts[pathLength - 2];
636
+ const last = equivalentPathParts[pathLength - 1];
637
+
638
+ if (secondToLast === 'signature[0]' && last === 'ref') {
639
+ // This is a ref prop usage like div().signature[0].ref -> parent
640
+ for (const equivalentValue of equivalentValues) {
641
+ propagated = true;
642
+
643
+ // Track this variable as a ref - we'll set its type to 'null' in finalize()
644
+ // after the schema is built (setting directly here would be overwritten)
645
+ // IMPORTANT: The ref variable might be defined in a parent scope, not the
646
+ // current scope. We need to find where the variable is actually defined by
647
+ // walking up the scope tree.
648
+ const varName = equivalentValue.schemaPath;
649
+ let targetScope: ScopeNode | null = scopeNode;
650
+
651
+ // Walk up the scope tree to find where this variable is defined
652
+ while (targetScope) {
653
+ // Check if this scope has the variable in its schema or equivalencies
654
+ const hasVariable =
655
+ varName in (targetScope.schema || {}) ||
656
+ varName in (targetScope.equivalencies || {});
657
+
658
+ if (hasVariable) {
659
+ if (!this.refVariables.has(targetScope.name)) {
660
+ this.refVariables.set(targetScope.name, new Set());
661
+ }
662
+ this.refVariables.get(targetScope.name)!.add(varName);
663
+
664
+ // IMPORTANT: Also update the source of the ref variable in the external
665
+ // function call's schema. This ensures dataForMocks produces [null]
666
+ // instead of ["string"] for hooks like useAutoAnimate.
667
+ const varEquivalencies = targetScope.equivalencies?.[varName];
668
+ if (varEquivalencies) {
669
+ for (const varEquivalency of varEquivalencies) {
670
+ const sourcePath = varEquivalency.schemaPath;
671
+ // Check if this comes from an external function call
672
+ // (contains functionCallReturnValue which indicates it's a hook/function return)
673
+ if (sourcePath.includes('functionCallReturnValue')) {
674
+ // Store the source path for later - we'll update the external function
675
+ // call's schema in finalize() which runs AFTER schema building is complete.
676
+ // Setting it here would be overwritten by later schema building.
677
+ for (const efc of scopeDataStructure.externalFunctionCalls) {
678
+ if (sourcePath.startsWith(efc.name)) {
679
+ if (!this.refVariableSources.has(efc.name)) {
680
+ this.refVariableSources.set(efc.name, new Set());
681
+ }
682
+ // Store both the specific indexed path and the generic [] path
683
+ this.refVariableSources
684
+ .get(efc.name)!
685
+ .add(sourcePath);
686
+ const genericPath = sourcePath.replace(
687
+ /\[\d+\]/g,
688
+ '[]',
689
+ );
690
+ if (genericPath !== sourcePath) {
691
+ this.refVariableSources
692
+ .get(efc.name)!
693
+ .add(genericPath);
694
+ }
695
+ }
696
+ }
697
+ }
698
+ }
699
+ }
700
+ }
701
+
702
+ // Move up to parent scope
703
+ if (targetScope.tree && targetScope.tree.length > 0) {
704
+ const parentScopeName =
705
+ targetScope.tree[targetScope.tree.length - 1];
706
+ targetScope = scopeDataStructure.getScopeOrFunctionCallInfo(
707
+ parentScopeName,
708
+ ) as ScopeNode | null;
709
+ } else {
710
+ targetScope = null;
711
+ }
712
+ }
713
+
714
+ scopeDataStructure.removeEquivalency(
715
+ equivalentPath,
716
+ equivalentValue,
717
+ scopeNode,
718
+ );
719
+ }
720
+ continue;
721
+ }
722
+ }
723
+
724
+ // Original logic for checking the value side
567
725
  for (const equivalentValue of equivalentValues) {
568
726
  const equivalentValueParts = scopeDataStructure.splitPath(
569
727
  equivalentValue.schemaPath,
@@ -64,6 +64,14 @@ const protoMethodSets: Record<PrimitiveKind, Set<string>> = {
64
64
  ),
65
65
  };
66
66
 
67
+ /** Built-in properties (not methods) that should be removed from primitives.
68
+ * These are properties that exist on the prototype and shouldn't appear
69
+ * as schema entries (they cause malformed mock data structures). */
70
+ const protoPropertySets: Partial<Record<PrimitiveKind, Set<string>>> = {
71
+ array: new Set(['length']),
72
+ string: new Set(['length']),
73
+ };
74
+
67
75
  /**
68
76
  * Extract primitive kind from a type string, handling union types.
69
77
  * E.g., "number | undefined" -> "number", "string | null" -> "string"
@@ -118,11 +126,21 @@ function scrub(
118
126
  const rootKind = rootTable.get(prefix);
119
127
  if (!rootKind) continue;
120
128
 
121
- const rawMethod = keyParts[cut].split('(')[0];
129
+ const rawToken = keyParts[cut];
130
+ const rawMethod = rawToken.split('(')[0];
131
+
132
+ // Check if it's a prototype method (e.g., map, filter, toString)
122
133
  if (protoMethodSets[rootKind].has(rawMethod)) {
123
134
  onRemove(keyPath);
124
135
  break;
125
136
  }
137
+
138
+ // Check if it's a built-in property (e.g., length on arrays/strings)
139
+ const propertySet = protoPropertySets[rootKind];
140
+ if (propertySet && propertySet.has(rawToken)) {
141
+ onRemove(keyPath);
142
+ break;
143
+ }
126
144
  }
127
145
  }
128
146
  }
@@ -41,6 +41,19 @@ const isolatingArrayMethodsSet = new Set([
41
41
  // Methods that are ambiguous - used on both arrays and non-arrays (e.g., router.push, history.pop)
42
42
  // Don't infer array type from these alone without additional evidence
43
43
  const ambiguousArrayMethodsSet = new Set(['push', 'pop']);
44
+
45
+ // Methods that return primitives (boolean, number) - their return values are not mockable
46
+ // These should have their .functionCallReturnValue paths removed from the schema
47
+ const primitiveReturningMethodsSet = new Set([
48
+ 'some', // Returns boolean
49
+ 'every', // Returns boolean
50
+ 'includes', // Returns boolean
51
+ 'indexOf', // Returns number (index)
52
+ 'lastIndexOf', // Returns number (index from end)
53
+ 'findIndex', // Returns number (index)
54
+ 'findLastIndex', // Returns number (index from end)
55
+ ]);
56
+
44
57
  export const transformingArrayMethodsSet = new Set([
45
58
  'map',
46
59
  'reduce',
@@ -970,6 +983,17 @@ function clearAttributes(
970
983
  for (const key in mapping) {
971
984
  const value = mapping[key];
972
985
  if (knownTypes.has(value)) {
986
+ // Don't add string-typed array element paths (ending with []) to knownBasePaths.
987
+ // When an array element is typed as 'string' but has child paths (like data[].id),
988
+ // it's actually an object - the 'string' type is incorrect. The child paths
989
+ // describe the array element structure and should not be deleted.
990
+ //
991
+ // However, array-typed [] paths (like matrix[] where matrix is array of arrays)
992
+ // should still be in knownBasePaths so their method calls (filter, map, etc.)
993
+ // get cleaned up properly.
994
+ if (key.endsWith('[]') && value === 'string') {
995
+ continue;
996
+ }
973
997
  knownBasePaths.add(key);
974
998
  }
975
999
  }
@@ -984,11 +1008,20 @@ function clearAttributes(
984
1008
  basePath
985
1009
  )
986
1010
  continue;
1011
+ // Preserve functionCallReturnValue for non-string types, UNLESS
1012
+ // the method is a primitive-returning method (like some, every, includes, indexOf)
1013
+ // whose return values are not mockable
1014
+ const methodPart = keyParts[basePathParts.length];
1015
+ const methodName = methodPart?.split('(')[0];
1016
+ const isPrimitiveReturning = primitiveReturningMethodsSet.has(
1017
+ methodName ?? '',
1018
+ );
987
1019
  if (
988
1020
  mapping[basePath] !== 'string' &&
989
1021
  keyParts[basePathParts.length + 1]?.startsWith(
990
1022
  'functionCallReturnValue',
991
- )
1023
+ ) &&
1024
+ !isPrimitiveReturning
992
1025
  )
993
1026
  continue;
994
1027
 
@@ -6,6 +6,14 @@ const STANDALONE_INDEX_RE = /^\[(\d+)\]$/;
6
6
  const isExplicitIndex = (s?: string) => !!s && INDEXED_RE.test(s);
7
7
  const isStandaloneIndex = (s?: string) => !!s && STANDALONE_INDEX_RE.test(s);
8
8
 
9
+ // Detect .length properties that come from dynamic iteration patterns
10
+ // These aren't useful for mock data - arrays work without explicit length,
11
+ // and objects shouldn't have length. We filter .length that appears:
12
+ // 1. After array notation: metadata[].length, items[][].length
13
+ // 2. On object paths that likely come from iteration: metadata.length (when metadata has other props)
14
+ // The regex matches any path ending with .length that has [] somewhere before it
15
+ const DYNAMIC_LENGTH_RE = /\[\].*\.length$/;
16
+
9
17
  // Treat these as structural placeholders (don't commit them as concrete leaves)
10
18
  function isSkippableLeafType(t: string) {
11
19
  // 'unknown' by itself is a placeholder (but 'boolean | unknown' is not)
@@ -23,6 +31,10 @@ export default function convertDotNotation(
23
31
  const result: JsonTypeDefinition = {};
24
32
 
25
33
  for (const [rawPath, typ] of Object.entries(schema)) {
34
+ // Skip paths with .length after array notation from dynamic iteration
35
+ // e.g., metadata[].length, metadata[][].length
36
+ if (DYNAMIC_LENGTH_RE.test(rawPath)) continue;
37
+
26
38
  const parts = splitOutsideParenthesesAndArrays(rawPath);
27
39
  if (!parts || parts.length === 0) continue;
28
40
 
@@ -187,6 +199,17 @@ export default function convertDotNotation(
187
199
  i++; // consume '[]'
188
200
  } else {
189
201
  // Pattern like: "items", "[]", "id" -> items: [ { id: ... } ]
202
+ // But if cursor[key] is already a non-array object (from paths like "metadata: object"),
203
+ // don't overwrite it with an array - the object type should take precedence.
204
+ // This handles spurious "metadata[]" paths from dynamic iteration (Object.keys, for...in).
205
+ if (
206
+ cursor[key] !== undefined &&
207
+ typeof cursor[key] === 'object' &&
208
+ !Array.isArray(cursor[key])
209
+ ) {
210
+ // Skip this path - it's trying to treat an object as an array
211
+ break;
212
+ }
190
213
  if (!Array.isArray(cursor[key])) cursor[key] = [];
191
214
 
192
215
  // Look ahead to see what comes after '[]'
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Converts null values to undefined (removes them) based on schema type constraints.
3
+ *
4
+ * When the LLM generates mock data, it uses `null` to represent "no value" because
5
+ * JSON doesn't support `undefined`. However, TypeScript types like `string | undefined`
6
+ * don't accept `null`.
7
+ *
8
+ * This function traverses data and schema together:
9
+ * - If schema type is "T | undefined" (but NOT "T | null"), convert null → undefined (delete key)
10
+ * - If schema type includes "null" (e.g., "T | null" or "T | null | undefined"), preserve null
11
+ * - If field not in schema, preserve as-is
12
+ *
13
+ * @param data The data object with potential null values
14
+ * @param schema The schema describing expected types
15
+ * @returns The data with null→undefined conversions applied (mutates original)
16
+ */
17
+ export default function convertNullToUndefinedBySchema<T>(
18
+ data: T,
19
+ schema: unknown,
20
+ ): T {
21
+ // Handle null/undefined data
22
+ if (data === null || data === undefined) {
23
+ return data;
24
+ }
25
+
26
+ // Only process objects
27
+ if (typeof data !== 'object') {
28
+ return data;
29
+ }
30
+
31
+ // Handle arrays
32
+ if (Array.isArray(data)) {
33
+ // For arrays, the schema should be an array with one element describing the item type
34
+ const itemSchema = Array.isArray(schema) ? schema[0] : undefined;
35
+ for (let i = 0; i < data.length; i++) {
36
+ data[i] = convertNullToUndefinedBySchema(data[i], itemSchema);
37
+ }
38
+ return data;
39
+ }
40
+
41
+ // Handle objects
42
+ const dataObj = data as Record<string, unknown>;
43
+ const schemaObj = schema as Record<string, unknown> | undefined;
44
+
45
+ for (const key of Object.keys(dataObj)) {
46
+ const value = dataObj[key];
47
+ const fieldSchema = schemaObj?.[key];
48
+
49
+ if (value === null) {
50
+ // Check if schema allows null
51
+ if (shouldConvertNullToUndefined(fieldSchema)) {
52
+ // Delete the key (converts null to undefined)
53
+ delete dataObj[key];
54
+ }
55
+ // If schema allows null, preserve it
56
+ } else if (typeof value === 'object' && value !== null) {
57
+ // Recursively process nested objects/arrays
58
+ convertNullToUndefinedBySchema(value, fieldSchema);
59
+ }
60
+ }
61
+
62
+ return data;
63
+ }
64
+
65
+ /**
66
+ * Determines if a null value should be converted to undefined based on schema type.
67
+ *
68
+ * @param fieldSchema The schema type string or object for the field
69
+ * @returns true if null should be converted to undefined, false if null should be preserved
70
+ */
71
+ function shouldConvertNullToUndefined(fieldSchema: unknown): boolean {
72
+ // If no schema for this field, preserve null (be conservative)
73
+ if (fieldSchema === undefined || fieldSchema === null) {
74
+ return false;
75
+ }
76
+
77
+ // If schema is a string type definition, check if it allows null
78
+ if (typeof fieldSchema === 'string') {
79
+ // Schema types that include "null" should preserve null values
80
+ // e.g., "string | null", "number | null | undefined", "null"
81
+ const allowsNull = fieldSchema.includes('null');
82
+ const allowsUndefined = fieldSchema.includes('undefined');
83
+
84
+ // If type allows undefined but NOT null, convert null to undefined
85
+ // e.g., "string | undefined" → convert null to undefined
86
+ // e.g., "string | null" → preserve null
87
+ // e.g., "string | null | undefined" → preserve null
88
+ if (allowsUndefined && !allowsNull) {
89
+ return true;
90
+ }
91
+
92
+ return false;
93
+ }
94
+
95
+ // If schema is an object or array, it's a nested structure
96
+ // Don't convert the container itself, just recurse into it
97
+ return false;
98
+ }
@@ -208,10 +208,12 @@ export default function fillInSchemaGapsAndUnknowns(
208
208
  export function fillInDirectSchemaGapsAndUnknowns({
209
209
  scopeName,
210
210
  schema,
211
+ mergedSchema,
211
212
  attempts = 0,
212
213
  }: {
213
214
  scopeName?: string;
214
215
  schema: Record<string, string>;
216
+ mergedSchema?: Record<string, string>;
215
217
  attempts?: number;
216
218
  }) {
217
219
  try {
@@ -245,7 +247,9 @@ export function fillInDirectSchemaGapsAndUnknowns({
245
247
  const guessTypeForPath = (path: string, defaultType = 'string') => {
246
248
  let knownType = checkIfKnownType(path, functionKeysMapping);
247
249
  if (!knownType) {
248
- knownType = checkIfObjectOrFunction(path, schema);
250
+ // Use mergedSchema for type inference if available (has more complete nested paths)
251
+ // Fall back to schema if mergedSchema is not provided
252
+ knownType = checkIfObjectOrFunction(path, mergedSchema ?? schema);
249
253
  }
250
254
 
251
255
  if (knownType && schema[path] !== knownType) {
@@ -373,10 +377,39 @@ export function fillInDirectSchemaGapsAndUnknowns({
373
377
  fillInDirectSchemaGapsAndUnknowns({
374
378
  scopeName,
375
379
  schema,
380
+ mergedSchema,
376
381
  attempts: ++attempts,
377
382
  });
378
383
  }
379
384
 
385
+ // Remove .length paths when the parent is typed as 'array' or 'string' (or nullable variants).
386
+ // These are built-in properties that were used for type inference but shouldn't appear
387
+ // in the final schema (they create { length: N } objects instead of proper arrays).
388
+ // However, if the parent could be an 'object' or other type, keep .length as it may be
389
+ // a custom property.
390
+ for (const key of Object.keys(schema)) {
391
+ const parts = splitOutsideParenthesesAndArrays(key);
392
+ if (parts[parts.length - 1] === 'length') {
393
+ const parentPath = joinParenthesesAndArrays(parts.slice(0, -1));
394
+ const parentType = schema[parentPath];
395
+ if (parentType) {
396
+ // Split union types and filter out nullable parts
397
+ const typeParts = parentType.split(' | ').map((t) => t.trim());
398
+ const nonNullableTypes = typeParts.filter(
399
+ (t) => t !== 'undefined' && t !== 'null',
400
+ );
401
+ // Only remove if ALL non-nullable types are array or string
402
+ // This ensures we don't remove .length from potential custom objects
403
+ if (
404
+ nonNullableTypes.length > 0 &&
405
+ nonNullableTypes.every((t) => t === 'array' || t === 'string')
406
+ ) {
407
+ delete schema[key];
408
+ }
409
+ }
410
+ }
411
+ }
412
+
380
413
  return schema;
381
414
  } catch (error) {
382
415
  console.info(