@codeyam/codeyam-cli 0.1.0-staging.8e7b1bd → 0.1.0-staging.b8a55ba

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 (385) 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 +7 -6
  4. package/analyzer-template/packages/ai/package.json +1 -1
  5. package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +2 -0
  6. package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +22 -0
  7. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +23 -1
  8. package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +401 -106
  9. package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +60 -0
  10. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +661 -50
  11. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +14 -2
  12. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +715 -0
  13. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +123 -1
  14. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +19 -1
  15. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +23 -1
  16. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +23 -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/generateChangesEntityScenarios.ts +37 -4
  21. package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +5 -0
  22. package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +213 -12
  23. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +11 -15
  24. package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +114 -11
  25. package/analyzer-template/packages/ai/src/lib/getConditionalUsagesFromCode.ts +143 -31
  26. package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +8 -2
  27. package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +7 -0
  28. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +42 -2
  29. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +38 -2
  30. package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +28 -2
  31. package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +5 -0
  32. package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +8 -1
  33. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +339 -145
  34. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +20 -0
  35. package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +8 -1
  36. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +158 -0
  37. package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +107 -18
  38. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
  39. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +223 -103
  40. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +10 -5
  41. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +172 -83
  42. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +2 -5
  43. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +97 -27
  44. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts +15 -0
  45. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts.map +1 -0
  46. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js +31 -0
  47. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js.map +1 -0
  48. package/analyzer-template/packages/aws/package.json +1 -1
  49. package/analyzer-template/packages/aws/s3/index.ts +1 -0
  50. package/analyzer-template/packages/aws/src/lib/s3/checkS3ObjectExists.ts +47 -0
  51. package/analyzer-template/packages/database/src/lib/kysely/db.ts +4 -4
  52. package/analyzer-template/packages/database/src/lib/kysely/tableRelations.ts +2 -2
  53. package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +20 -9
  54. package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +3 -2
  55. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +9 -4
  56. package/analyzer-template/packages/generate/src/lib/deepMerge.ts +26 -1
  57. package/analyzer-template/packages/generate/src/lib/getComponentScenarioPath.ts +8 -3
  58. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -2
  59. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +2 -2
  60. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tableRelations.d.ts +2 -2
  61. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +8 -1
  62. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
  63. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +14 -7
  64. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
  65. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
  66. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  67. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +1 -1
  68. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
  69. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
  70. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +4 -2
  71. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  72. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
  73. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
  74. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  75. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.d.ts.map +1 -1
  76. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js +27 -1
  77. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js.map +1 -1
  78. package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.d.ts.map +1 -1
  79. package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.js +7 -3
  80. package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.js.map +1 -1
  81. package/analyzer-template/packages/github/dist/types/index.d.ts +4 -3
  82. package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
  83. package/analyzer-template/packages/github/dist/types/index.js +1 -0
  84. package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
  85. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +31 -1
  86. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
  87. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +51 -1
  88. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
  89. package/analyzer-template/packages/github/dist/types/src/types/Scenario.js +21 -1
  90. package/analyzer-template/packages/github/dist/types/src/types/Scenario.js.map +1 -1
  91. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +48 -0
  92. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  93. package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.d.ts.map +1 -1
  94. package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.js +26 -2
  95. package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.js.map +1 -1
  96. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
  97. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
  98. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  99. package/analyzer-template/packages/types/index.ts +8 -0
  100. package/analyzer-template/packages/types/src/types/Analysis.ts +32 -1
  101. package/analyzer-template/packages/types/src/types/Scenario.ts +75 -6
  102. package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +49 -0
  103. package/analyzer-template/packages/ui-components/package.json +4 -4
  104. package/analyzer-template/packages/ui-components/src/components/ScenarioDetailInteractiveView.tsx +23 -7
  105. package/analyzer-template/packages/utils/dist/types/index.d.ts +4 -3
  106. package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
  107. package/analyzer-template/packages/utils/dist/types/index.js +1 -0
  108. package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
  109. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +31 -1
  110. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
  111. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +51 -1
  112. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
  113. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.js +21 -1
  114. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.js.map +1 -1
  115. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +48 -0
  116. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  117. package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.d.ts.map +1 -1
  118. package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.js +26 -2
  119. package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.js.map +1 -1
  120. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
  121. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
  122. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  123. package/analyzer-template/packages/utils/src/lib/applyUniversalMocks.ts +28 -2
  124. package/analyzer-template/packages/utils/src/lib/lightweightEntityExtractor.ts +27 -0
  125. package/analyzer-template/playwright/takeElementScreenshot.ts +26 -11
  126. package/analyzer-template/playwright/takeScreenshot.ts +9 -7
  127. package/analyzer-template/project/TESTING.md +83 -0
  128. package/analyzer-template/project/constructMockCode.ts +151 -30
  129. package/analyzer-template/project/loadReadyToBeCaptured.ts +17 -1
  130. package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +16 -9
  131. package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +77 -37
  132. package/analyzer-template/project/reconcileMockDataKeys.ts +104 -3
  133. package/analyzer-template/project/runMultiScenarioServer.ts +11 -10
  134. package/analyzer-template/project/serverOnlyModules.ts +288 -0
  135. package/analyzer-template/project/start.ts +10 -0
  136. package/analyzer-template/project/startScenarioCapture.ts +73 -41
  137. package/analyzer-template/project/writeMockDataTsx.ts +103 -40
  138. package/analyzer-template/project/writeScenarioComponents.ts +1162 -203
  139. package/analyzer-template/project/writeSimpleRoot.ts +26 -4
  140. package/analyzer-template/project/writeUniversalMocks.ts +32 -11
  141. package/background/src/lib/virtualized/project/constructMockCode.js +132 -25
  142. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  143. package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js +15 -1
  144. package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js.map +1 -1
  145. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +11 -6
  146. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
  147. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +67 -32
  148. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
  149. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +65 -4
  150. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
  151. package/background/src/lib/virtualized/project/runMultiScenarioServer.js +11 -9
  152. package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
  153. package/background/src/lib/virtualized/project/serverOnlyModules.js +235 -0
  154. package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -0
  155. package/background/src/lib/virtualized/project/start.js +6 -0
  156. package/background/src/lib/virtualized/project/start.js.map +1 -1
  157. package/background/src/lib/virtualized/project/startScenarioCapture.js +54 -31
  158. package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
  159. package/background/src/lib/virtualized/project/writeMockDataTsx.js +87 -34
  160. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  161. package/background/src/lib/virtualized/project/writeScenarioComponents.js +852 -133
  162. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  163. package/background/src/lib/virtualized/project/writeSimpleRoot.js +25 -2
  164. package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
  165. package/background/src/lib/virtualized/project/writeUniversalMocks.js +27 -12
  166. package/background/src/lib/virtualized/project/writeUniversalMocks.js.map +1 -1
  167. package/codeyam-cli/scripts/fixtures/formbricks/universal-mocks/apps/web/lib/instance/service.js +7 -0
  168. package/codeyam-cli/scripts/fixtures/formbricks/universal-mocks/apps/web/lib/instance/service.js.map +1 -0
  169. package/codeyam-cli/src/cli.js +2 -0
  170. package/codeyam-cli/src/cli.js.map +1 -1
  171. package/codeyam-cli/src/commands/debug.js +14 -2
  172. package/codeyam-cli/src/commands/debug.js.map +1 -1
  173. package/codeyam-cli/src/commands/recapture.js +215 -0
  174. package/codeyam-cli/src/commands/recapture.js.map +1 -0
  175. package/codeyam-cli/src/commands/report.js +26 -23
  176. package/codeyam-cli/src/commands/report.js.map +1 -1
  177. package/codeyam-cli/src/utils/backgroundServer.js +2 -2
  178. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  179. package/codeyam-cli/src/utils/generateReport.js +252 -106
  180. package/codeyam-cli/src/utils/generateReport.js.map +1 -1
  181. package/codeyam-cli/src/utils/install-skills.js +2 -7
  182. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  183. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +38 -0
  184. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
  185. package/codeyam-cli/src/utils/queue/job.js +140 -16
  186. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  187. package/codeyam-cli/src/utils/queue/manager.js +19 -7
  188. package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
  189. package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
  190. package/codeyam-cli/src/webserver/app/lib/database.js +47 -0
  191. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  192. package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
  193. package/codeyam-cli/src/webserver/backgroundServer.js +5 -10
  194. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  195. package/codeyam-cli/src/webserver/bootstrap.js +9 -0
  196. package/codeyam-cli/src/webserver/bootstrap.js.map +1 -0
  197. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-wXL1Z2Aq.js +1 -0
  198. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-DQeyk25_.js → EntityTypeBadge-CzGX-miz.js} +1 -1
  199. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-CXFKsCOD.js +41 -0
  200. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-D-9pXIaY.js +25 -0
  201. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-CBQPrpT0.js +3 -0
  202. package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-D1CdlbrV.js +6 -0
  203. package/codeyam-cli/src/webserver/build/client/assets/LogViewer-wDPcZNKx.js +3 -0
  204. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-4lcOlid-.js +11 -0
  205. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BfmDgXxG.js +1 -0
  206. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CUxUNEEC.js +15 -0
  207. package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-ayCJdUAc.js → TruncatedFilePath-6J7zDUD5.js} +1 -1
  208. package/codeyam-cli/src/webserver/build/client/assets/_index-DHImXdXq.js +11 -0
  209. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-2mG6mjVb.js +32 -0
  210. package/codeyam-cli/src/webserver/build/client/assets/api.link-scenario-value-l0sNRNKZ.js +1 -0
  211. package/codeyam-cli/src/webserver/build/client/assets/api.update-key-attributes-l0sNRNKZ.js +1 -0
  212. package/codeyam-cli/src/webserver/build/client/assets/api.update-valid-values-l0sNRNKZ.js +1 -0
  213. package/codeyam-cli/src/webserver/build/client/assets/chevron-down-BYimnrHg.js +6 -0
  214. package/codeyam-cli/src/webserver/build/client/assets/chunk-JMJ3UQ3L-BambyYE_.js +51 -0
  215. package/codeyam-cli/src/webserver/build/client/assets/circle-check-CaVsIRxt.js +6 -0
  216. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-CgUsG7ib.js +21 -0
  217. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-CKnwPCDr.js +1 -0
  218. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-DW_hdGUc.js +1 -0
  219. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-FHOVOgFN.js → entity._sha._-zUEpfPsu.js} +22 -15
  220. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DyB90fWk.js +1 -0
  221. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-D_3ero5o.js +1 -0
  222. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-CfLCUi9S.js +5 -0
  223. package/codeyam-cli/src/webserver/build/client/assets/entry.client-DKJyZfAY.js +29 -0
  224. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-DAtOlaWE.js +1 -0
  225. package/codeyam-cli/src/webserver/build/client/assets/files-ClR0d32A.js +1 -0
  226. package/codeyam-cli/src/webserver/build/client/assets/git-D62Lxxmv.js +15 -0
  227. package/codeyam-cli/src/webserver/build/client/assets/globals-C6vQASxy.css +1 -0
  228. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-fmIEn3Bc.js +9 -0
  229. package/codeyam-cli/src/webserver/build/client/assets/index-BosqDOlH.js +3 -0
  230. package/codeyam-cli/src/webserver/build/client/assets/index-CzNNiTkw.js +9 -0
  231. package/codeyam-cli/src/webserver/build/client/assets/keyAttributeCoverage-CTlFMihX.js +1 -0
  232. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-CNp9QFCX.js +6 -0
  233. package/codeyam-cli/src/webserver/build/client/assets/manifest-09d684be.js +1 -0
  234. package/codeyam-cli/src/webserver/build/client/assets/preload-helper-ckwbz45p.js +1 -0
  235. package/codeyam-cli/src/webserver/build/client/assets/root-BxJUvKau.js +56 -0
  236. package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
  237. package/codeyam-cli/src/webserver/build/client/assets/search-DDGjYAMJ.js +6 -0
  238. package/codeyam-cli/src/webserver/build/client/assets/settings-DgTyB-Wg.js +1 -0
  239. package/codeyam-cli/src/webserver/build/client/assets/simulations-CoNWGt0K.js +1 -0
  240. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-CBc5dE1s.js +6 -0
  241. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BMIGFP-m.js +1 -0
  242. package/codeyam-cli/src/webserver/build/client/assets/useInteractiveMode-Dk_FQqWJ.js +1 -0
  243. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-DOGXmJcI.js → useLastLogLine-BqPPNjAl.js} +1 -1
  244. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DsJbgMY9.js +1 -0
  245. package/codeyam-cli/src/webserver/build/client/assets/{useToast-C07gRg7Z.js → useToast-DWHcCcl1.js} +1 -1
  246. package/codeyam-cli/src/webserver/build/server/assets/index-CV6i1S1A.js +1 -0
  247. package/codeyam-cli/src/webserver/build/server/assets/server-build-BDlyhfrv.js +175 -0
  248. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  249. package/codeyam-cli/src/webserver/build-info.json +5 -5
  250. package/codeyam-cli/src/webserver/devServer.js +1 -3
  251. package/codeyam-cli/src/webserver/devServer.js.map +1 -1
  252. package/codeyam-cli/templates/debug-codeyam.md +620 -0
  253. package/package.json +14 -14
  254. package/packages/ai/src/lib/analyzeScope.js +2 -0
  255. package/packages/ai/src/lib/analyzeScope.js.map +1 -1
  256. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +16 -0
  257. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
  258. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +16 -0
  259. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
  260. package/packages/ai/src/lib/astScopes/processExpression.js +305 -88
  261. package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
  262. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +523 -42
  263. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  264. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +12 -2
  265. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
  266. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +454 -0
  267. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -0
  268. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +103 -1
  269. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
  270. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +16 -1
  271. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
  272. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +19 -1
  273. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
  274. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +20 -0
  275. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
  276. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +28 -2
  277. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
  278. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +179 -17
  279. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +1 -1
  280. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +6 -0
  281. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +1 -1
  282. package/packages/ai/src/lib/generateChangesEntityScenarios.js +37 -4
  283. package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
  284. package/packages/ai/src/lib/generateEntityDataStructure.js +4 -0
  285. package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
  286. package/packages/ai/src/lib/generateEntityKeyAttributes.js +176 -9
  287. package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +1 -1
  288. package/packages/ai/src/lib/generateEntityScenarioData.js +11 -15
  289. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  290. package/packages/ai/src/lib/generateEntityScenarios.js +105 -9
  291. package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
  292. package/packages/ai/src/lib/getConditionalUsagesFromCode.js +84 -14
  293. package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
  294. package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -1
  295. package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
  296. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +6 -0
  297. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
  298. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +38 -2
  299. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
  300. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +38 -2
  301. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
  302. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +16 -3
  303. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
  304. package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
  305. package/packages/ai/src/lib/worker/analyzeScopeWorker.js +4 -0
  306. package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
  307. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +258 -110
  308. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  309. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +18 -0
  310. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  311. package/packages/analyze/src/lib/files/getImportedExports.js +6 -1
  312. package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
  313. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +125 -0
  314. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -0
  315. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +74 -19
  316. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
  317. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
  318. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
  319. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +175 -58
  320. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  321. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +10 -5
  322. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +1 -1
  323. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +127 -69
  324. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
  325. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +2 -5
  326. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
  327. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +74 -23
  328. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  329. package/packages/database/src/lib/kysely/db.js +2 -2
  330. package/packages/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
  331. package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  332. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +4 -2
  333. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  334. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
  335. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  336. package/packages/generate/src/lib/deepMerge.js +27 -1
  337. package/packages/generate/src/lib/deepMerge.js.map +1 -1
  338. package/packages/generate/src/lib/getComponentScenarioPath.js +7 -3
  339. package/packages/generate/src/lib/getComponentScenarioPath.js.map +1 -1
  340. package/packages/types/index.js +1 -0
  341. package/packages/types/index.js.map +1 -1
  342. package/packages/types/src/types/Scenario.js +21 -1
  343. package/packages/types/src/types/Scenario.js.map +1 -1
  344. package/packages/utils/src/lib/applyUniversalMocks.js +26 -2
  345. package/packages/utils/src/lib/applyUniversalMocks.js.map +1 -1
  346. package/packages/utils/src/lib/lightweightEntityExtractor.js +25 -0
  347. package/packages/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  348. package/scripts/finalize-analyzer.cjs +3 -1
  349. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-CWKV2GEz.js +0 -1
  350. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-D2hFeDeg.js +0 -1
  351. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-C8K-4kKP.js +0 -26
  352. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-DgXLv61M.js +0 -3
  353. package/codeyam-cli/src/webserver/build/client/assets/LogViewer-DFdLQbPS.js +0 -3
  354. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-DlRDjT4h.js +0 -1
  355. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-7UkVL-UI.js +0 -1
  356. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-XjtsGuPo.js +0 -5
  357. package/codeyam-cli/src/webserver/build/client/assets/_index-D2eJjWLf.js +0 -1
  358. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-w6sbwlOd.js +0 -7
  359. package/codeyam-cli/src/webserver/build/client/assets/chevron-down-BBNQ8hup.js +0 -1
  360. package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-Bex4RrGs.js +0 -26
  361. package/codeyam-cli/src/webserver/build/client/assets/circle-check-cdhjVtom.js +0 -1
  362. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-DkgmwwRC.js +0 -1
  363. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-CwLmCS0J.js +0 -1
  364. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-YZ-kM3ZG.js +0 -1
  365. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-BeQlz94_.js +0 -5
  366. package/codeyam-cli/src/webserver/build/client/assets/entry.client-DN2XXM7Z.js +0 -5
  367. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-CUeAIQNI.js +0 -1
  368. package/codeyam-cli/src/webserver/build/client/assets/files-ccMQfhGf.js +0 -1
  369. package/codeyam-cli/src/webserver/build/client/assets/git-JmESAHx5.js +0 -12
  370. package/codeyam-cli/src/webserver/build/client/assets/globals-CO-U8Bpo.css +0 -1
  371. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +0 -5
  372. package/codeyam-cli/src/webserver/build/client/assets/index-DsL9BiOc.js +0 -8
  373. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-COYCR2oZ.js +0 -1
  374. package/codeyam-cli/src/webserver/build/client/assets/manifest-90adba57.js +0 -1
  375. package/codeyam-cli/src/webserver/build/client/assets/root-DfbVEEjF.js +0 -16
  376. package/codeyam-cli/src/webserver/build/client/assets/search-DvK9iMBu.js +0 -1
  377. package/codeyam-cli/src/webserver/build/client/assets/server-build-CMKNK2uU.css +0 -1
  378. package/codeyam-cli/src/webserver/build/client/assets/settings-9LTbit4Z.js +0 -1
  379. package/codeyam-cli/src/webserver/build/client/assets/simulations-BrxN5ZtV.js +0 -1
  380. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-Iv0p8T-1.js +0 -1
  381. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-BWmSRPH6.js +0 -1
  382. package/codeyam-cli/src/webserver/build/server/assets/index-CE_1qXCG.js +0 -1
  383. package/codeyam-cli/src/webserver/build/server/assets/server-build-BY_VDhiD.js +0 -166
  384. package/codeyam-cli/templates/debug-command.md +0 -141
  385. /package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-CMKNK2uU.css → styles-CMKNK2uU.css} +0 -0
@@ -5,28 +5,56 @@
5
5
  * (e.g., "eq('user_id', 'user-12345')") when the mock code expects variable
6
6
  * references (e.g., "eq('user_id', user.id)").
7
7
  *
8
- * This function remaps mismatched keys to their expected equivalents.
8
+ * This function also handles canonical key format (EntityName::hookName::index)
9
+ * and remaps old variable-based keys (variableName <- functionName) to canonical keys.
10
+ *
11
+ * @param mockData The mock data object to reconcile
12
+ * @param expectedKeys The expected keys from the structure
13
+ * @param entityName Optional entity name for canonical key remapping
9
14
  */
10
15
  export function reconcileMockDataKeys(
11
16
  mockData: Record<string, unknown>,
12
17
  expectedKeys: string[],
18
+ entityName?: string,
13
19
  ): Record<string, unknown> {
14
20
  const result: Record<string, unknown> = {};
21
+ // Track which canonical keys have been used for multiple calls to same hook
22
+ const usedCanonicalKeys = new Set<string>();
15
23
 
16
24
  for (const [key, value] of Object.entries(mockData)) {
17
25
  // Recursively reconcile nested objects
18
26
  const reconciledValue =
19
27
  value && typeof value === 'object' && !Array.isArray(value)
20
- ? reconcileMockDataKeys(value as Record<string, unknown>, expectedKeys)
28
+ ? reconcileMockDataKeys(
29
+ value as Record<string, unknown>,
30
+ expectedKeys,
31
+ entityName,
32
+ )
21
33
  : value;
22
34
 
23
35
  // Check if key matches an expected key exactly
24
36
  if (expectedKeys.includes(key)) {
25
37
  result[key] = reconciledValue;
38
+ usedCanonicalKeys.add(key);
26
39
  continue;
27
40
  }
28
41
 
29
- // Try to find closest match
42
+ // Try to remap variable-based key to canonical key
43
+ if (entityName) {
44
+ const canonicalKey = remapToCanonicalKey(
45
+ key,
46
+ expectedKeys,
47
+ entityName,
48
+ usedCanonicalKeys,
49
+ );
50
+ if (canonicalKey) {
51
+ result[canonicalKey] = reconciledValue;
52
+ usedCanonicalKeys.add(canonicalKey);
53
+ continue;
54
+ }
55
+ }
56
+
57
+ // Try to find closest match using existing logic
30
58
  const closestKey = findClosestKey(key, expectedKeys);
31
59
  if (closestKey) {
32
60
  result[closestKey] = reconciledValue;
@@ -39,6 +67,79 @@ export function reconcileMockDataKeys(
39
67
  return result;
40
68
  }
41
69
 
70
+ /**
71
+ * Attempt to remap a variable-based key to a canonical key.
72
+ *
73
+ * Variable-based format: "variableName <- functionName"
74
+ * Canonical format: "EntityName::hookName::index"
75
+ *
76
+ * @example
77
+ * remapToCanonicalKey("currentCommit <- useLoaderData", ["DashboardPage::useLoaderData::0"], "DashboardPage", new Set())
78
+ * // returns "DashboardPage::useLoaderData::0"
79
+ */
80
+ function remapToCanonicalKey(
81
+ key: string,
82
+ expectedCanonicalKeys: string[],
83
+ entityName: string,
84
+ usedKeys: Set<string>,
85
+ ): string | null {
86
+ // Check if key is in variable-based format: "varName <- functionName"
87
+ const arrowMatch = key.match(/<-\s*(\w+)/);
88
+ if (!arrowMatch) {
89
+ // Not a variable-based key, try other patterns
90
+ // Check if it's a simple function call like "useLoaderData()"
91
+ const funcCallMatch = key.match(/^(\w+)\(\)/);
92
+ if (funcCallMatch) {
93
+ const hookName = funcCallMatch[1];
94
+ return findMatchingCanonicalKey(
95
+ hookName,
96
+ entityName,
97
+ expectedCanonicalKeys,
98
+ usedKeys,
99
+ );
100
+ }
101
+ return null;
102
+ }
103
+
104
+ const hookName = arrowMatch[1];
105
+
106
+ return findMatchingCanonicalKey(
107
+ hookName,
108
+ entityName,
109
+ expectedCanonicalKeys,
110
+ usedKeys,
111
+ );
112
+ }
113
+
114
+ /**
115
+ * Find a matching canonical key for a hook name within an entity.
116
+ */
117
+ function findMatchingCanonicalKey(
118
+ hookName: string,
119
+ entityName: string,
120
+ expectedCanonicalKeys: string[],
121
+ usedKeys: Set<string>,
122
+ ): string | null {
123
+ // Find all canonical keys for this entity and hook
124
+ const candidatePrefix = `${entityName}::${hookName}::`;
125
+ const candidates = expectedCanonicalKeys.filter(
126
+ (k) => k.startsWith(candidatePrefix) && !usedKeys.has(k),
127
+ );
128
+
129
+ if (candidates.length === 0) {
130
+ return null;
131
+ }
132
+
133
+ // Sort by index to prefer lower indices
134
+ candidates.sort((a, b) => {
135
+ const aIndex = parseInt(a.split('::')[2], 10);
136
+ const bIndex = parseInt(b.split('::')[2], 10);
137
+ return aIndex - bIndex;
138
+ });
139
+
140
+ return candidates[0];
141
+ }
142
+
42
143
  /**
43
144
  * Find the closest matching key from expectedKeys for a given key.
44
145
  *
@@ -302,14 +302,14 @@ export async function runMultiScenarioServer({
302
302
  message: message.slice(0, 1000),
303
303
  });
304
304
 
305
- // Save error to database
306
- await recordErrorMessageForScenario(analysis, currentScenario, {
307
- message: messageToSave,
308
- } as Error);
309
-
310
- // Only signal scenario failed for RELEVANT crash errors
311
- // Non-crash errors (like SSR warnings) should be recorded but not stop capture
305
+ // Only save error and signal scenario failed for RELEVANT crash errors
306
+ // Non-crash errors (like SSR warnings) should be logged but not stop capture
307
+ // or mark the scenario as finished (which would prevent screenshot capture)
312
308
  if (relevantError) {
309
+ // Save crash error to database (sets finishedAt on scenario)
310
+ await recordErrorMessageForScenario(analysis, currentScenario, {
311
+ message: messageToSave,
312
+ } as Error);
313
313
  awsLog(
314
314
  'CodeYam SERVER DEBUG: Calling handleServerError for crash error',
315
315
  {
@@ -320,8 +320,9 @@ export async function runMultiScenarioServer({
320
320
  );
321
321
  iterator.handleServerError(currentScenario.name);
322
322
  } else {
323
+ // Non-crash errors are logged but don't affect scenario status
323
324
  awsLog(
324
- 'CodeYam SERVER DEBUG: Non-crash error recorded, NOT stopping scenario',
325
+ 'CodeYam SERVER DEBUG: Non-crash error logged, NOT stopping scenario',
325
326
  {
326
327
  analysisId: analysis.id,
327
328
  scenarioName: currentScenario.name,
@@ -501,13 +502,13 @@ export async function runMultiScenarioServer({
501
502
 
502
503
  if (!iterator.hasScenarioFailed(scenario.name)) {
503
504
  completedScenarios.push(scenario.name);
504
- awsLog('CodeYam SERVER DEBUG: Scenario marked as completed', {
505
+ awsLog('CodeYam: Scenario marked as completed', {
505
506
  analysisId: analysis.id,
506
507
  scenarioName: scenario.name,
507
508
  scenarioId: scenario.id,
508
509
  });
509
510
  } else {
510
- awsLog('CodeYam SERVER DEBUG: Scenario marked as FAILED', {
511
+ awsLog('CodeYam: Scenario marked as FAILED', {
511
512
  analysisId: analysis.id,
512
513
  scenarioName: scenario.name,
513
514
  scenarioId: scenario.id,
@@ -0,0 +1,288 @@
1
+ import ts from 'typescript';
2
+
3
+ /**
4
+ * Configuration for modules that require client-side mocking.
5
+ *
6
+ * These are Node.js built-ins, server-only npm packages, or framework-specific
7
+ * server APIs that cannot run in the browser and need mock implementations.
8
+ */
9
+
10
+ export interface ServerOnlyModuleMock {
11
+ /** The module specifier pattern (exact match or regex) */
12
+ module: string | RegExp;
13
+ /** Description of why this module needs mocking */
14
+ reason: string;
15
+ /** Category for grouping */
16
+ category: 'node-builtin' | 'npm-package' | 'framework';
17
+ /**
18
+ * Mock code generator function.
19
+ * @param importNames - The names being imported (for named imports)
20
+ * @param defaultImportName - The name used for default import (if any)
21
+ * @returns The mock code to replace the import with
22
+ */
23
+ getMockCode: (importNames: string[], defaultImportName?: string) => string;
24
+ }
25
+
26
+ /**
27
+ * Known server-only modules that need client-side mocking.
28
+ * This list can be extended by users via project configuration.
29
+ */
30
+ export const SERVER_ONLY_MODULES: ServerOnlyModuleMock[] = [
31
+ // Node.js built-ins
32
+ {
33
+ module: 'node:crypto',
34
+ reason: 'Node.js crypto module is not available in browser',
35
+ category: 'node-builtin',
36
+ getMockCode: (importNames, defaultImportName) => {
37
+ if (defaultImportName) {
38
+ return `// Mock for node:crypto (Node.js built-in, not available in browser)
39
+ const ${defaultImportName} = {
40
+ createHash: (algorithm: string) => ({
41
+ update: (data: string) => ({
42
+ digest: (encoding: string) => 'mock-hash-' + data.substring(0, 8),
43
+ }),
44
+ }),
45
+ randomBytes: (size: number) => new Uint8Array(size),
46
+ randomUUID: () => 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
47
+ const r = Math.random() * 16 | 0;
48
+ return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
49
+ }),
50
+ };
51
+ `;
52
+ }
53
+ // Named imports
54
+ let code =
55
+ '// Mock for node:crypto (Node.js built-in, not available in browser)\n';
56
+ for (const name of importNames) {
57
+ const [originalName, aliasName] = name
58
+ .split(/\s+as\s+/)
59
+ .map((s) => s.trim());
60
+ const finalName = aliasName || originalName;
61
+ if (originalName === 'createHash') {
62
+ code += `const ${finalName} = (algorithm: string) => ({
63
+ update: (data: string) => ({
64
+ digest: (encoding: string) => 'mock-hash-' + data.substring(0, 8),
65
+ }),
66
+ });
67
+ `;
68
+ } else if (originalName === 'randomBytes') {
69
+ code += `const ${finalName} = (size: number) => new Uint8Array(size);
70
+ `;
71
+ } else if (originalName === 'randomUUID') {
72
+ code += `const ${finalName} = () => 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
73
+ const r = Math.random() * 16 | 0;
74
+ return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
75
+ });
76
+ `;
77
+ } else {
78
+ code += `const ${finalName} = () => { throw new Error('${originalName} is not available in browser'); };
79
+ `;
80
+ }
81
+ }
82
+ return code;
83
+ },
84
+ },
85
+
86
+ // npm packages that require Node.js
87
+ {
88
+ module: 'https-proxy-agent',
89
+ reason: 'Requires Node.js net/tls modules',
90
+ category: 'npm-package',
91
+ getMockCode: (importNames) => {
92
+ return `// Mock for https-proxy-agent (requires Node.js net/tls modules)
93
+ class HttpsProxyAgent {
94
+ constructor() {}
95
+ }
96
+ `;
97
+ },
98
+ },
99
+ {
100
+ module: 'node-fetch',
101
+ reason: 'Requires Node.js http/https modules',
102
+ category: 'npm-package',
103
+ getMockCode: (importNames, defaultImportName) => {
104
+ if (defaultImportName) {
105
+ return `// Mock for node-fetch (requires Node.js http/https modules)
106
+ const ${defaultImportName} = async (url: string, options?: any) => ({
107
+ ok: true,
108
+ status: 200,
109
+ json: async () => ({}),
110
+ text: async () => '',
111
+ headers: new Headers(),
112
+ });
113
+ `;
114
+ }
115
+ // Named imports - browser has native Response, Headers, etc.
116
+ return '// node-fetch named imports removed - using browser natives\n';
117
+ },
118
+ },
119
+
120
+ // Framework-specific server APIs
121
+ {
122
+ module: 'next/headers',
123
+ reason: 'Next.js server-only API for reading request headers',
124
+ category: 'framework',
125
+ getMockCode: () => {
126
+ return `// Mock for next/headers (server-only in Next.js)
127
+ const headers = async () => ({
128
+ get: (name: string) => null,
129
+ has: (name: string) => false,
130
+ entries: () => [][Symbol.iterator](),
131
+ keys: () => [][Symbol.iterator](),
132
+ values: () => [][Symbol.iterator](),
133
+ forEach: () => {},
134
+ });
135
+ const cookies = async () => ({
136
+ get: (name: string) => undefined,
137
+ getAll: () => [],
138
+ has: (name: string) => false,
139
+ set: () => {},
140
+ delete: () => {},
141
+ });
142
+ `;
143
+ },
144
+ },
145
+ ];
146
+
147
+ /**
148
+ * Find a server-only module configuration by module specifier.
149
+ */
150
+ export function findServerOnlyModule(
151
+ moduleSpecifier: string,
152
+ ): ServerOnlyModuleMock | undefined {
153
+ return SERVER_ONLY_MODULES.find((config) => {
154
+ if (typeof config.module === 'string') {
155
+ return config.module === moduleSpecifier;
156
+ }
157
+ return config.module.test(moduleSpecifier);
158
+ });
159
+ }
160
+
161
+ /**
162
+ * Check if a module specifier matches any known server-only module.
163
+ */
164
+ export function isServerOnlyModule(moduleSpecifier: string): boolean {
165
+ return findServerOnlyModule(moduleSpecifier) !== undefined;
166
+ }
167
+
168
+ /**
169
+ * Parse an import statement to extract module specifier and import names.
170
+ */
171
+ export function parseImportStatement(importStatement: string): {
172
+ moduleSpecifier: string;
173
+ importNames: string[];
174
+ defaultImportName?: string;
175
+ } | null {
176
+ // Match: import { a, b } from "module"
177
+ const namedMatch = importStatement.match(
178
+ /import\s+\{([^}]+)\}\s+from\s+["']([^"']+)["']/,
179
+ );
180
+ if (namedMatch) {
181
+ const names = namedMatch[1]
182
+ .split(',')
183
+ .map((s) => s.trim())
184
+ .filter(Boolean);
185
+ return {
186
+ moduleSpecifier: namedMatch[2],
187
+ importNames: names,
188
+ };
189
+ }
190
+
191
+ // Match: import foo from "module" or import * as foo from "module"
192
+ const defaultMatch = importStatement.match(
193
+ /import\s+(?:\*\s+as\s+)?(\w+)\s+from\s+["']([^"']+)["']/,
194
+ );
195
+ if (defaultMatch) {
196
+ return {
197
+ moduleSpecifier: defaultMatch[2],
198
+ importNames: [],
199
+ defaultImportName: defaultMatch[1],
200
+ };
201
+ }
202
+
203
+ return null;
204
+ }
205
+
206
+ /**
207
+ * Apply server-only module mocks to file content.
208
+ * Replaces imports from known server-only modules with mock implementations.
209
+ */
210
+ export function applyServerOnlyMocks(fileContent: string): string {
211
+ // Always use AST parsing - regex with nested quantifiers can cause catastrophic
212
+ // backtracking that hangs on a single .exec() call (before iteration limits kick in)
213
+ return applyServerOnlyMocksAst(fileContent);
214
+ }
215
+
216
+ /**
217
+ * AST-based implementation of applyServerOnlyMocks for large files.
218
+ * Uses TypeScript parser instead of regex to avoid catastrophic backtracking.
219
+ */
220
+ function applyServerOnlyMocksAst(fileContent: string): string {
221
+ try {
222
+ const sourceFile = ts.createSourceFile(
223
+ 'temp.ts',
224
+ fileContent,
225
+ ts.ScriptTarget.Latest,
226
+ true,
227
+ );
228
+
229
+ const replacements: { start: number; end: number; replacement: string }[] =
230
+ [];
231
+
232
+ for (const statement of sourceFile.statements) {
233
+ if (!ts.isImportDeclaration(statement)) continue;
234
+
235
+ const moduleSpecifier = statement.moduleSpecifier;
236
+ if (!ts.isStringLiteral(moduleSpecifier)) continue;
237
+
238
+ const modulePath = moduleSpecifier.text;
239
+ const config = findServerOnlyModule(modulePath);
240
+ if (!config) continue;
241
+
242
+ // Extract import names
243
+ const importNames: string[] = [];
244
+ let defaultImportName: string | undefined;
245
+
246
+ if (statement.importClause) {
247
+ // Default import
248
+ if (statement.importClause.name) {
249
+ defaultImportName = statement.importClause.name.text;
250
+ }
251
+
252
+ // Named imports
253
+ if (statement.importClause.namedBindings) {
254
+ if (ts.isNamedImports(statement.importClause.namedBindings)) {
255
+ for (const element of statement.importClause.namedBindings
256
+ .elements) {
257
+ importNames.push(element.name.text);
258
+ }
259
+ } else if (
260
+ ts.isNamespaceImport(statement.importClause.namedBindings)
261
+ ) {
262
+ // Namespace import like: import * as foo from 'module'
263
+ importNames.push(statement.importClause.namedBindings.name.text);
264
+ }
265
+ }
266
+ }
267
+
268
+ const mockCode = config.getMockCode(importNames, defaultImportName);
269
+ replacements.push({
270
+ start: statement.getStart(sourceFile),
271
+ end: statement.getEnd(),
272
+ replacement: mockCode,
273
+ });
274
+ }
275
+
276
+ // Apply replacements in reverse order to preserve positions
277
+ let result = fileContent;
278
+ replacements.sort((a, b) => b.start - a.start);
279
+ for (const { start, end, replacement } of replacements) {
280
+ result = result.slice(0, start) + replacement + result.slice(end);
281
+ }
282
+
283
+ return result;
284
+ } catch (error) {
285
+ console.warn('[applyServerOnlyMocksAst] Failed to parse file:', error);
286
+ return fileContent; // Return original content on error
287
+ }
288
+ }
@@ -440,6 +440,16 @@ async function main({
440
440
  `CodeYam: Exiting start.js process with ${hadError ? 'ERROR' : 'SUCCESS'}`,
441
441
  );
442
442
  process.exit(hadError ? 1 : 0);
443
+ } else if (process.env.CAPTURE_ONLY === 'true') {
444
+ awsLog(
445
+ 'CodeYam: CAPTURE_ONLY mode - keeping files and exiting cleanly',
446
+ `Preserved ${generatedFiles.length} files`,
447
+ );
448
+ // Don't cleanup files in capture-only mode to preserve manual edits
449
+ awsLog(
450
+ `CodeYam: Exiting start.js process with ${hadError ? 'ERROR' : 'SUCCESS'}`,
451
+ );
452
+ process.exit(hadError ? 1 : 0);
443
453
  } else {
444
454
  awsLog(`CodeYam: Removing ${generatedFiles.length} generated files...`);
445
455
  removeScenario(generatedFiles);
@@ -85,8 +85,9 @@ export async function startScenarioCapture({
85
85
  }
86
86
 
87
87
  // Clean up any leftover generated files from previous debug sessions
88
+ // Skip in CAPTURE_ONLY mode - we want to preserve the files that were edited
88
89
  const previouslyTracked = readTrackingFile();
89
- if (previouslyTracked) {
90
+ if (previouslyTracked && process.env.CAPTURE_ONLY !== 'true') {
90
91
  awsLog('CodeYam: Cleaning up files from previous session', {
91
92
  generatedCount: previouslyTracked.generatedFiles.length,
92
93
  backupCount: previouslyTracked.backupFiles.length,
@@ -97,6 +98,13 @@ export async function startScenarioCapture({
97
98
  restoreFromBackup(backupPath);
98
99
  }
99
100
  clearTrackingFile();
101
+ } else if (previouslyTracked && process.env.CAPTURE_ONLY === 'true') {
102
+ awsLog(
103
+ 'CodeYam: CAPTURE_ONLY mode - preserving files from previous session',
104
+ {
105
+ generatedCount: previouslyTracked.generatedFiles.length,
106
+ },
107
+ );
100
108
  }
101
109
 
102
110
  const sortedReadyToBeCaptured = readyToBeCaptured.sort((a, b) => {
@@ -352,7 +360,12 @@ export async function startScenarioCapture({
352
360
  const mocksDir = `${appPath}/${CODEYAM_MOCKS_DIRNAME}/`;
353
361
 
354
362
  for (const scenario of sortedScenarios) {
355
- if (scenarioIds && !scenarioIds.includes(scenario.id)) {
363
+ // Check both id and name since scenarioIds may contain either (recapture uses names)
364
+ if (
365
+ scenarioIds &&
366
+ !scenarioIds.includes(scenario.id) &&
367
+ !scenarioIds.includes(scenario.name)
368
+ ) {
356
369
  awsLog('CodeYam: Skipping scenario', {
357
370
  thisScenarioId: scenario.id,
358
371
  thisScenarioName: scenario.name,
@@ -379,6 +392,7 @@ export async function startScenarioCapture({
379
392
  if (
380
393
  !process.env['CODEYAM_LOCAL_PROJECT_PATH'] &&
381
394
  !scenarioIds?.includes(scenario.id) &&
395
+ !scenarioIds?.includes(scenario.name) &&
382
396
  !analysisIds?.includes(analysis.id) &&
383
397
  (scenarioStatus?.finishedAt ||
384
398
  scenarioStatus?.error ||
@@ -389,40 +403,50 @@ export async function startScenarioCapture({
389
403
 
390
404
  awsLogDebugLevel(1, `Preparing ${analysis.entityName}: ${scenario.name}`);
391
405
 
392
- // Write scenario files upfront
393
- const scenarioGeneratedFiles = await writeScenario({
394
- analysis,
395
- scenario,
396
- context,
397
- projectAnalyzer,
398
- framework,
399
- fileStore,
400
- });
401
-
402
- // For non-routes: write root.tsx now (all scenarios can share it)
403
- // For routes: defer writeSimpleRoot to per-scenario execution (each needs different mocks)
404
- // EXCEPTION: In PREP_ONLY mode (debug), routes also need root.tsx written here since we exit early
405
- if (!isRoute || process.env.PREP_ONLY === 'true') {
406
- const simpleRootResult = await writeSimpleRoot(
407
- project,
408
- framework,
406
+ // In CAPTURE_ONLY mode, skip file generation and use existing files
407
+ // This preserves manual fixes made during debugging
408
+ let scenarioGeneratedFiles: string[] = [];
409
+ if (process.env.CAPTURE_ONLY !== 'true') {
410
+ // Write scenario files upfront
411
+ scenarioGeneratedFiles = await writeScenario({
412
+ analysis,
409
413
  scenario,
410
- analysis.filePath,
411
- {
412
- file: analysis.file,
413
- entity: analysis.entity,
414
- routeAnalysis: analysis,
415
- mocksDir,
416
- scenarioComponentPaths: scenarioGeneratedFiles,
417
- },
418
- );
419
- if (simpleRootResult.filePath) {
420
- if (simpleRootResult.backupPath) {
421
- backupFiles.push(simpleRootResult.backupPath);
422
- } else {
423
- scenarioGeneratedFiles.push(simpleRootResult.filePath);
414
+ context,
415
+ projectAnalyzer,
416
+ framework,
417
+ fileStore,
418
+ });
419
+
420
+ // For non-routes: write root.tsx now (all scenarios can share it)
421
+ // For routes: defer writeSimpleRoot to per-scenario execution (each needs different mocks)
422
+ // EXCEPTION: In PREP_ONLY mode (debug), routes also need root.tsx written here since we exit early
423
+ if (!isRoute || process.env.PREP_ONLY === 'true') {
424
+ const simpleRootResult = await writeSimpleRoot(
425
+ project,
426
+ framework,
427
+ scenario,
428
+ analysis.filePath,
429
+ {
430
+ file: analysis.file,
431
+ entity: analysis.entity,
432
+ routeAnalysis: analysis,
433
+ mocksDir,
434
+ scenarioComponentPaths: scenarioGeneratedFiles,
435
+ },
436
+ );
437
+ if (simpleRootResult.filePath) {
438
+ if (simpleRootResult.backupPath) {
439
+ backupFiles.push(simpleRootResult.backupPath);
440
+ } else {
441
+ scenarioGeneratedFiles.push(simpleRootResult.filePath);
442
+ }
424
443
  }
425
444
  }
445
+ } else {
446
+ awsLogDebugLevel(
447
+ 1,
448
+ `CAPTURE_ONLY mode: skipping file generation for ${scenario.name}`,
449
+ );
426
450
  }
427
451
 
428
452
  // Mark scenario as initializing
@@ -678,14 +702,22 @@ export async function startScenarioCapture({
678
702
  allGeneratedFiles,
679
703
  );
680
704
 
681
- // Clean up all generated files
682
- console.log(
683
- 'CodeYam: Removing all scenario files for analysis',
684
- analysis.id,
685
- analysis.entityName,
686
- );
687
- cleanupFiles(allGeneratedFiles, backupFiles);
688
- backupFiles = [];
705
+ // Clean up all generated files (skip in CAPTURE_ONLY mode to preserve edits)
706
+ if (process.env.CAPTURE_ONLY !== 'true') {
707
+ console.log(
708
+ 'CodeYam: Removing all scenario files for analysis',
709
+ analysis.id,
710
+ analysis.entityName,
711
+ );
712
+ cleanupFiles(allGeneratedFiles, backupFiles);
713
+ backupFiles = [];
714
+ } else {
715
+ console.log(
716
+ 'CodeYam: CAPTURE_ONLY mode - preserving scenario files for analysis',
717
+ analysis.id,
718
+ analysis.entityName,
719
+ );
720
+ }
689
721
 
690
722
  forceStop = result.forceStop;
691
723
  }