@codeyam/codeyam-cli 0.1.0-staging.1 → 0.1.0-staging.28f73cf

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 (440) 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 +8 -7
  4. package/analyzer-template/packages/ai/index.ts +2 -1
  5. package/analyzer-template/packages/ai/package.json +2 -2
  6. package/analyzer-template/packages/ai/scripts/ai-test-matrix.mjs +424 -0
  7. package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +24 -0
  8. package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +6 -16
  9. package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +197 -0
  10. package/analyzer-template/packages/ai/src/lib/astScopes/paths.ts +28 -2
  11. package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +127 -4
  12. package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +1 -3
  13. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +1821 -542
  14. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/FunctionCallManager.ts +138 -0
  15. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +1 -1
  16. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.ts +139 -0
  17. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/DebugTracer.ts +224 -0
  18. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/PathManager.ts +203 -0
  19. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/README.md +294 -0
  20. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +161 -0
  21. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/VisitedTracker.ts +235 -0
  22. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +14 -6
  23. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/selectBestValue.ts +70 -0
  24. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/uniqueIdUtils.ts +113 -0
  25. package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +36 -0
  26. package/analyzer-template/packages/ai/src/lib/generateChangesEntityDocumentation.ts +20 -2
  27. package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +51 -107
  28. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +56 -160
  29. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +79 -265
  30. package/analyzer-template/packages/ai/src/lib/generateEntityDocumentation.ts +16 -2
  31. package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +53 -176
  32. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +53 -154
  33. package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +84 -254
  34. package/analyzer-template/packages/ai/src/lib/generateStatementAnalysis.ts +48 -71
  35. package/analyzer-template/packages/ai/src/lib/getConditionalUsagesFromCode.ts +27 -6
  36. package/analyzer-template/packages/ai/src/lib/getLLMCallStats.ts +0 -14
  37. package/analyzer-template/packages/ai/src/lib/modelInfo.ts +15 -0
  38. package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +42 -4
  39. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityDocumentationGenerator.ts +8 -33
  40. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +54 -62
  41. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +93 -109
  42. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityDocumentationGenerator.ts +8 -27
  43. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +33 -38
  44. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +30 -30
  45. package/analyzer-template/packages/ai/src/lib/types/index.ts +2 -0
  46. package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +39 -0
  47. package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +52 -6
  48. package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +2 -1
  49. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.ts +238 -0
  50. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getDeclaredEntityNode.ts +25 -0
  51. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/index.ts +2 -0
  52. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +8 -10
  53. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +6 -1
  54. package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +8 -6
  55. package/analyzer-template/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.ts +5 -13
  56. package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +34 -15
  57. package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +17 -3
  58. package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +35 -16
  59. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +7 -1
  60. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +9 -1
  61. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +6 -1
  62. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +9 -1
  63. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +15 -7
  64. package/analyzer-template/packages/aws/dist/src/lib/s3/getPresignedUrl.d.ts +23 -0
  65. package/analyzer-template/packages/aws/dist/src/lib/s3/getPresignedUrl.d.ts.map +1 -0
  66. package/analyzer-template/packages/aws/dist/src/lib/s3/getPresignedUrl.js +30 -0
  67. package/analyzer-template/packages/aws/dist/src/lib/s3/getPresignedUrl.js.map +1 -0
  68. package/analyzer-template/packages/aws/package.json +5 -4
  69. package/analyzer-template/packages/aws/s3/index.ts +4 -0
  70. package/analyzer-template/packages/aws/src/lib/s3/getPresignedUrl.ts +62 -0
  71. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +28 -21
  72. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageRemix.ts +18 -11
  73. package/analyzer-template/packages/generate/src/lib/scenarioComponent.ts +6 -3
  74. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
  75. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +28 -21
  76. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  77. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageRemix.d.ts.map +1 -1
  78. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageRemix.js +18 -11
  79. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageRemix.js.map +1 -1
  80. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponent.d.ts.map +1 -1
  81. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponent.js +5 -3
  82. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponent.js.map +1 -1
  83. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/db.d.ts +2 -0
  84. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/db.d.ts.map +1 -1
  85. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/db.js +3 -0
  86. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/db.js.map +1 -1
  87. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/tableRelations.d.ts +2 -0
  88. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/tableRelations.d.ts.map +1 -1
  89. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/tables/debugReportsTable.d.ts +37 -0
  90. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -0
  91. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/tables/debugReportsTable.js +27 -0
  92. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/tables/debugReportsTable.js.map +1 -0
  93. package/analyzer-template/packages/github/dist/utils/index.d.ts +2 -0
  94. package/analyzer-template/packages/github/dist/utils/index.d.ts.map +1 -1
  95. package/analyzer-template/packages/github/dist/utils/index.js +2 -0
  96. package/analyzer-template/packages/github/dist/utils/index.js.map +1 -1
  97. package/analyzer-template/packages/github/dist/utils/src/lib/Semaphore.d.ts +25 -0
  98. package/analyzer-template/packages/github/dist/utils/src/lib/Semaphore.d.ts.map +1 -0
  99. package/analyzer-template/packages/github/dist/utils/src/lib/Semaphore.js +40 -0
  100. package/analyzer-template/packages/github/dist/utils/src/lib/Semaphore.js.map +1 -0
  101. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/getNextRoutePath.d.ts.map +1 -1
  102. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/getNextRoutePath.js +5 -3
  103. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/getNextRoutePath.js.map +1 -1
  104. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/getRemixRoutePath.d.ts.map +1 -1
  105. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/getRemixRoutePath.js +2 -1
  106. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/getRemixRoutePath.js.map +1 -1
  107. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/nextRouteFileNameToRoute.d.ts.map +1 -1
  108. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/nextRouteFileNameToRoute.js +2 -1
  109. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/nextRouteFileNameToRoute.js.map +1 -1
  110. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/remixRouteFileNameToRoute.d.ts.map +1 -1
  111. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/remixRouteFileNameToRoute.js +1 -0
  112. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/remixRouteFileNameToRoute.js.map +1 -1
  113. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/sanitizeNextRouteSegments.d.ts +12 -0
  114. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/sanitizeNextRouteSegments.d.ts.map +1 -0
  115. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/sanitizeNextRouteSegments.js +32 -0
  116. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/sanitizeNextRouteSegments.js.map +1 -0
  117. package/analyzer-template/packages/supabase/src/lib/kysely/db.ts +6 -0
  118. package/analyzer-template/packages/supabase/src/lib/kysely/tableRelations.ts +3 -0
  119. package/analyzer-template/packages/supabase/src/lib/kysely/tables/debugReportsTable.ts +61 -0
  120. package/analyzer-template/packages/ui-components/src/scenario-editor/components/DataItemEditor.tsx +1 -1
  121. package/analyzer-template/packages/utils/dist/utils/index.d.ts +2 -0
  122. package/analyzer-template/packages/utils/dist/utils/index.d.ts.map +1 -1
  123. package/analyzer-template/packages/utils/dist/utils/index.js +2 -0
  124. package/analyzer-template/packages/utils/dist/utils/index.js.map +1 -1
  125. package/analyzer-template/packages/utils/dist/utils/src/lib/Semaphore.d.ts +25 -0
  126. package/analyzer-template/packages/utils/dist/utils/src/lib/Semaphore.d.ts.map +1 -0
  127. package/analyzer-template/packages/utils/dist/utils/src/lib/Semaphore.js +40 -0
  128. package/analyzer-template/packages/utils/dist/utils/src/lib/Semaphore.js.map +1 -0
  129. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/getNextRoutePath.d.ts.map +1 -1
  130. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/getNextRoutePath.js +5 -3
  131. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/getNextRoutePath.js.map +1 -1
  132. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/getRemixRoutePath.d.ts.map +1 -1
  133. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/getRemixRoutePath.js +2 -1
  134. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/getRemixRoutePath.js.map +1 -1
  135. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/nextRouteFileNameToRoute.d.ts.map +1 -1
  136. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/nextRouteFileNameToRoute.js +2 -1
  137. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/nextRouteFileNameToRoute.js.map +1 -1
  138. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/remixRouteFileNameToRoute.d.ts.map +1 -1
  139. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/remixRouteFileNameToRoute.js +1 -0
  140. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/remixRouteFileNameToRoute.js.map +1 -1
  141. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/sanitizeNextRouteSegments.d.ts +12 -0
  142. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/sanitizeNextRouteSegments.d.ts.map +1 -0
  143. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/sanitizeNextRouteSegments.js +32 -0
  144. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/sanitizeNextRouteSegments.js.map +1 -0
  145. package/analyzer-template/packages/utils/index.ts +2 -0
  146. package/analyzer-template/packages/utils/src/lib/Semaphore.ts +42 -0
  147. package/analyzer-template/packages/utils/src/lib/frameworks/getNextRoutePath.ts +8 -3
  148. package/analyzer-template/packages/utils/src/lib/frameworks/getRemixRoutePath.ts +2 -1
  149. package/analyzer-template/packages/utils/src/lib/frameworks/nextRouteFileNameToRoute.ts +2 -1
  150. package/analyzer-template/packages/utils/src/lib/frameworks/remixRouteFileNameToRoute.ts +1 -0
  151. package/analyzer-template/packages/utils/src/lib/frameworks/sanitizeNextRouteSegments.ts +33 -0
  152. package/analyzer-template/project/constructMockCode.ts +170 -6
  153. package/analyzer-template/project/reconcileMockDataKeys.ts +13 -0
  154. package/analyzer-template/project/start.ts +1 -11
  155. package/analyzer-template/project/startScenarioCapture.ts +24 -0
  156. package/analyzer-template/project/trackGeneratedFiles.ts +41 -0
  157. package/analyzer-template/project/writeMockDataTsx.ts +125 -4
  158. package/analyzer-template/project/writeScenarioComponents.ts +199 -45
  159. package/analyzer-template/project/writeUniversalMocks.ts +72 -10
  160. package/background/src/lib/virtualized/project/constructMockCode.js +158 -7
  161. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  162. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +12 -0
  163. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
  164. package/background/src/lib/virtualized/project/start.js +1 -8
  165. package/background/src/lib/virtualized/project/start.js.map +1 -1
  166. package/background/src/lib/virtualized/project/startScenarioCapture.js +18 -0
  167. package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
  168. package/background/src/lib/virtualized/project/trackGeneratedFiles.js +30 -0
  169. package/background/src/lib/virtualized/project/trackGeneratedFiles.js.map +1 -0
  170. package/background/src/lib/virtualized/project/writeMockDataTsx.js +95 -3
  171. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  172. package/background/src/lib/virtualized/project/writeScenarioComponents.js +144 -28
  173. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  174. package/background/src/lib/virtualized/project/writeUniversalMocks.js +59 -9
  175. package/background/src/lib/virtualized/project/writeUniversalMocks.js.map +1 -1
  176. package/codeyam-cli/scripts/apply-setup.js +288 -0
  177. package/codeyam-cli/scripts/apply-setup.js.map +1 -0
  178. package/codeyam-cli/scripts/extract-setup.js +130 -0
  179. package/codeyam-cli/scripts/extract-setup.js.map +1 -0
  180. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +238 -0
  181. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +1 -0
  182. package/codeyam-cli/src/cli.js +6 -0
  183. package/codeyam-cli/src/cli.js.map +1 -1
  184. package/codeyam-cli/src/codeyam-cli.js +0 -0
  185. package/codeyam-cli/src/commands/debug.js +221 -0
  186. package/codeyam-cli/src/commands/debug.js.map +1 -0
  187. package/codeyam-cli/src/commands/init.js +4 -23
  188. package/codeyam-cli/src/commands/init.js.map +1 -1
  189. package/codeyam-cli/src/commands/report.js +102 -0
  190. package/codeyam-cli/src/commands/report.js.map +1 -0
  191. package/codeyam-cli/src/commands/setup-sandbox.js +164 -0
  192. package/codeyam-cli/src/commands/setup-sandbox.js.map +1 -0
  193. package/codeyam-cli/src/utils/__tests__/cleanupAnalysisFiles.test.js +6 -6
  194. package/codeyam-cli/src/utils/__tests__/cleanupAnalysisFiles.test.js.map +1 -1
  195. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +8 -0
  196. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
  197. package/codeyam-cli/src/utils/analysisRunner.js +4 -3
  198. package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
  199. package/codeyam-cli/src/utils/analyzer.js +30 -0
  200. package/codeyam-cli/src/utils/analyzer.js.map +1 -1
  201. package/codeyam-cli/src/utils/backgroundServer.js +25 -5
  202. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  203. package/codeyam-cli/src/utils/cleanupAnalysisFiles.js +2 -2
  204. package/codeyam-cli/src/utils/cleanupAnalysisFiles.js.map +1 -1
  205. package/codeyam-cli/src/utils/fileWatcher.js +75 -5
  206. package/codeyam-cli/src/utils/fileWatcher.js.map +1 -1
  207. package/codeyam-cli/src/utils/generateReport.js +219 -0
  208. package/codeyam-cli/src/utils/generateReport.js.map +1 -0
  209. package/codeyam-cli/src/utils/install-skills.js +7 -0
  210. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  211. package/codeyam-cli/src/utils/queue/__tests__/job.pidTracking.test.js +1 -0
  212. package/codeyam-cli/src/utils/queue/__tests__/job.pidTracking.test.js.map +1 -1
  213. package/codeyam-cli/src/utils/queue/job.js +8 -3
  214. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  215. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +4 -0
  216. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
  217. package/codeyam-cli/src/utils/webappDetection.js +2 -1
  218. package/codeyam-cli/src/utils/webappDetection.js.map +1 -1
  219. package/codeyam-cli/src/webserver/app/lib/database.js +63 -2
  220. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  221. package/codeyam-cli/src/webserver/backgroundServer.js +15 -35
  222. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  223. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-D5ZHFomX.js +1 -0
  224. package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-Dh-FldQK.js → InteractivePreview-XDSzQLOY.js} +3 -3
  225. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-BYVx9KFp.js +3 -0
  226. package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-Dp6DC845.js → LogViewer-CRcT5fOZ.js} +1 -1
  227. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-BORLgi0X.js +1 -0
  228. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-Bual6h18.js +1 -0
  229. package/codeyam-cli/src/webserver/build/client/assets/ScenarioPreview-Bi-YUMa-.js +6 -0
  230. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-4D2vLLJz.js +5 -0
  231. package/codeyam-cli/src/webserver/build/client/assets/_index-BC200mfN.js +1 -0
  232. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-CxvZPkCv.js +10 -0
  233. package/codeyam-cli/src/webserver/build/client/assets/api.generate-report-l0sNRNKZ.js +1 -0
  234. package/codeyam-cli/src/webserver/build/client/assets/{chart-column-B2I7jQx2.js → chart-column-B8fb6wnw.js} +1 -1
  235. package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-De6i8FUT.js +26 -0
  236. package/codeyam-cli/src/webserver/build/client/assets/{circle-alert-GwwOAbhw.js → circle-alert-IdsgAK39.js} +1 -1
  237. package/codeyam-cli/src/webserver/build/client/assets/circle-check-BACUUf75.js +1 -0
  238. package/codeyam-cli/src/webserver/build/client/assets/clock-vWeoCemX.js +1 -0
  239. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-CS7XDrKv.js +1 -0
  240. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-DIOEw_3i.js +1 -0
  241. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-1Z6D0fLM.js → entity._sha._-8Els_3Wb.js} +10 -10
  242. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-C3FZJx1w.js +1 -0
  243. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-YJz_igar.js +5 -0
  244. package/codeyam-cli/src/webserver/build/client/assets/entityStatus-BEqj2qBy.js +1 -0
  245. package/codeyam-cli/src/webserver/build/client/assets/{entityVersioning-DO2gCvXv.js → entityVersioning-Bk_YB1jM.js} +1 -1
  246. package/codeyam-cli/src/webserver/build/client/assets/entry.client-DiP0q291.js +5 -0
  247. package/codeyam-cli/src/webserver/build/client/assets/file-text-LM0mgxXE.js +1 -0
  248. package/codeyam-cli/src/webserver/build/client/assets/files-Dxh9CcaV.js +1 -0
  249. package/codeyam-cli/src/webserver/build/client/assets/git-BXmqrWCH.js +12 -0
  250. package/codeyam-cli/src/webserver/build/client/assets/globals-BGS74ED-.css +1 -0
  251. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +5 -0
  252. package/codeyam-cli/src/webserver/build/client/assets/index-D-zYbzFZ.js +8 -0
  253. package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-DN7Vr40D.js → loader-circle-BXPKbHEb.js} +1 -1
  254. package/codeyam-cli/src/webserver/build/client/assets/manifest-1af162d4.js +1 -0
  255. package/codeyam-cli/src/webserver/build/client/assets/root-DB7VgjCY.js +16 -0
  256. package/codeyam-cli/src/webserver/build/client/assets/{settings-MZc4XdmE.js → settings-5zF_GOcS.js} +1 -1
  257. package/codeyam-cli/src/webserver/build/client/assets/settings-Dc4MlMpK.js +1 -0
  258. package/codeyam-cli/src/webserver/build/client/assets/simulations-BQ-02-jB.js +1 -0
  259. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-D7k-ArFa.js +1 -0
  260. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-BBlyqxij.js → useLastLogLine-AlhS7g5F.js} +1 -1
  261. package/codeyam-cli/src/webserver/build/client/assets/useToast-Ddo4UQv7.js +1 -0
  262. package/codeyam-cli/src/webserver/build/client/assets/{zap-B4gsLUZQ.js → zap-_jw-9DCp.js} +1 -1
  263. package/codeyam-cli/src/webserver/build/server/assets/index-D4JpXSIO.js +1 -0
  264. package/codeyam-cli/src/webserver/build/server/assets/server-build-vwbN7n65.js +169 -0
  265. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  266. package/codeyam-cli/src/webserver/build-info.json +5 -5
  267. package/codeyam-cli/src/webserver/server.js +1 -1
  268. package/codeyam-cli/src/webserver/server.js.map +1 -1
  269. package/codeyam-cli/templates/codeyam-setup-skill.md +85 -94
  270. package/codeyam-cli/templates/debug-command.md +125 -0
  271. package/package.json +9 -11
  272. package/packages/ai/index.js +1 -2
  273. package/packages/ai/index.js.map +1 -1
  274. package/packages/ai/src/lib/analyzeScope.js +13 -0
  275. package/packages/ai/src/lib/analyzeScope.js.map +1 -1
  276. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +6 -15
  277. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
  278. package/packages/ai/src/lib/astScopes/methodSemantics.js +134 -0
  279. package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
  280. package/packages/ai/src/lib/astScopes/paths.js +28 -3
  281. package/packages/ai/src/lib/astScopes/paths.js.map +1 -1
  282. package/packages/ai/src/lib/astScopes/processExpression.js +111 -3
  283. package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
  284. package/packages/ai/src/lib/checkAllAttributes.js +1 -3
  285. package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
  286. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1320 -396
  287. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  288. package/packages/ai/src/lib/dataStructure/equivalencyManagers/FunctionCallManager.js +137 -1
  289. package/packages/ai/src/lib/dataStructure/equivalencyManagers/FunctionCallManager.js.map +1 -1
  290. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +1 -1
  291. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
  292. package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +112 -0
  293. package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -0
  294. package/packages/ai/src/lib/dataStructure/helpers/DebugTracer.js +176 -0
  295. package/packages/ai/src/lib/dataStructure/helpers/DebugTracer.js.map +1 -0
  296. package/packages/ai/src/lib/dataStructure/helpers/PathManager.js +178 -0
  297. package/packages/ai/src/lib/dataStructure/helpers/PathManager.js.map +1 -0
  298. package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +138 -0
  299. package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -0
  300. package/packages/ai/src/lib/dataStructure/helpers/VisitedTracker.js +199 -0
  301. package/packages/ai/src/lib/dataStructure/helpers/VisitedTracker.js.map +1 -0
  302. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +14 -6
  303. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
  304. package/packages/ai/src/lib/dataStructure/helpers/selectBestValue.js +62 -0
  305. package/packages/ai/src/lib/dataStructure/helpers/selectBestValue.js.map +1 -0
  306. package/packages/ai/src/lib/dataStructure/helpers/uniqueIdUtils.js +90 -0
  307. package/packages/ai/src/lib/dataStructure/helpers/uniqueIdUtils.js.map +1 -0
  308. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +22 -0
  309. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +1 -1
  310. package/packages/ai/src/lib/generateChangesEntityDocumentation.js +19 -1
  311. package/packages/ai/src/lib/generateChangesEntityDocumentation.js.map +1 -1
  312. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +51 -107
  313. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +1 -1
  314. package/packages/ai/src/lib/generateChangesEntityScenarioData.js +55 -156
  315. package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
  316. package/packages/ai/src/lib/generateChangesEntityScenarios.js +79 -262
  317. package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
  318. package/packages/ai/src/lib/generateEntityDocumentation.js +15 -1
  319. package/packages/ai/src/lib/generateEntityDocumentation.js.map +1 -1
  320. package/packages/ai/src/lib/generateEntityKeyAttributes.js +53 -176
  321. package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +1 -1
  322. package/packages/ai/src/lib/generateEntityScenarioData.js +52 -152
  323. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  324. package/packages/ai/src/lib/generateEntityScenarios.js +88 -258
  325. package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
  326. package/packages/ai/src/lib/generateStatementAnalysis.js +46 -71
  327. package/packages/ai/src/lib/generateStatementAnalysis.js.map +1 -1
  328. package/packages/ai/src/lib/getConditionalUsagesFromCode.js +13 -8
  329. package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
  330. package/packages/ai/src/lib/getLLMCallStats.js +0 -14
  331. package/packages/ai/src/lib/getLLMCallStats.js.map +1 -1
  332. package/packages/ai/src/lib/modelInfo.js +15 -0
  333. package/packages/ai/src/lib/modelInfo.js.map +1 -1
  334. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +36 -3
  335. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
  336. package/packages/ai/src/lib/promptGenerators/generateChangesEntityDocumentationGenerator.js +8 -33
  337. package/packages/ai/src/lib/promptGenerators/generateChangesEntityDocumentationGenerator.js.map +1 -1
  338. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +35 -41
  339. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
  340. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +59 -72
  341. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
  342. package/packages/ai/src/lib/promptGenerators/generateEntityDocumentationGenerator.js +8 -27
  343. package/packages/ai/src/lib/promptGenerators/generateEntityDocumentationGenerator.js.map +1 -1
  344. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +24 -27
  345. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
  346. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +21 -22
  347. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
  348. package/packages/ai/src/lib/types/index.js +2 -0
  349. package/packages/ai/src/lib/types/index.js.map +1 -1
  350. package/packages/ai/src/lib/worker/SerializableDataStructure.js +7 -0
  351. package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
  352. package/packages/analyze/src/lib/FileAnalyzer.js +45 -5
  353. package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
  354. package/packages/analyze/src/lib/asts/nodes/index.js +2 -1
  355. package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
  356. package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js +191 -0
  357. package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -0
  358. package/packages/analyze/src/lib/asts/sourceFiles/getDeclaredEntityNode.js +16 -0
  359. package/packages/analyze/src/lib/asts/sourceFiles/getDeclaredEntityNode.js.map +1 -0
  360. package/packages/analyze/src/lib/asts/sourceFiles/index.js +2 -0
  361. package/packages/analyze/src/lib/asts/sourceFiles/index.js.map +1 -1
  362. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +6 -8
  363. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  364. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +5 -1
  365. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  366. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +8 -2
  367. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
  368. package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js +5 -8
  369. package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js.map +1 -1
  370. package/packages/analyze/src/lib/files/analyzeChange.js +21 -9
  371. package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
  372. package/packages/analyze/src/lib/files/analyzeEntity.js +10 -4
  373. package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
  374. package/packages/analyze/src/lib/files/analyzeInitial.js +21 -9
  375. package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
  376. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +6 -1
  377. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  378. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +9 -1
  379. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +1 -1
  380. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +5 -1
  381. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
  382. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +9 -1
  383. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
  384. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +16 -7
  385. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  386. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +28 -21
  387. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  388. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageRemix.js +18 -11
  389. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageRemix.js.map +1 -1
  390. package/packages/generate/src/lib/scenarioComponent.js +5 -3
  391. package/packages/generate/src/lib/scenarioComponent.js.map +1 -1
  392. package/packages/supabase/src/lib/kysely/db.js +3 -0
  393. package/packages/supabase/src/lib/kysely/db.js.map +1 -1
  394. package/packages/supabase/src/lib/kysely/tables/debugReportsTable.js +27 -0
  395. package/packages/supabase/src/lib/kysely/tables/debugReportsTable.js.map +1 -0
  396. package/packages/utils/index.js +2 -0
  397. package/packages/utils/index.js.map +1 -1
  398. package/packages/utils/src/lib/Semaphore.js +40 -0
  399. package/packages/utils/src/lib/Semaphore.js.map +1 -0
  400. package/packages/utils/src/lib/frameworks/getNextRoutePath.js +5 -3
  401. package/packages/utils/src/lib/frameworks/getNextRoutePath.js.map +1 -1
  402. package/packages/utils/src/lib/frameworks/getRemixRoutePath.js +2 -1
  403. package/packages/utils/src/lib/frameworks/getRemixRoutePath.js.map +1 -1
  404. package/packages/utils/src/lib/frameworks/nextRouteFileNameToRoute.js +2 -1
  405. package/packages/utils/src/lib/frameworks/nextRouteFileNameToRoute.js.map +1 -1
  406. package/packages/utils/src/lib/frameworks/remixRouteFileNameToRoute.js +1 -0
  407. package/packages/utils/src/lib/frameworks/remixRouteFileNameToRoute.js.map +1 -1
  408. package/packages/utils/src/lib/frameworks/sanitizeNextRouteSegments.js +32 -0
  409. package/packages/utils/src/lib/frameworks/sanitizeNextRouteSegments.js.map +1 -0
  410. package/analyzer-template/packages/ai/src/lib/generateEntityDataMap.ts +0 -375
  411. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-GqWwt5wG.js +0 -1
  412. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-p0fuyqGQ.js +0 -3
  413. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-xwuhwsZH.js +0 -1
  414. package/codeyam-cli/src/webserver/build/client/assets/ScenarioPreview-Bl2IRh55.js +0 -1
  415. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-M2QuSHKC.js +0 -5
  416. package/codeyam-cli/src/webserver/build/client/assets/_index-CAVtep9Q.js +0 -1
  417. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-CLmzsLsT.js +0 -10
  418. package/codeyam-cli/src/webserver/build/client/assets/components-CAx5ONX_.js +0 -40
  419. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-CgyOwWip.js +0 -1
  420. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-DGy3zrli.js +0 -1
  421. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-ChAdTrrU.js +0 -1
  422. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-D9L7267w.js +0 -5
  423. package/codeyam-cli/src/webserver/build/client/assets/entry.client-C6FRgjPr.js +0 -1
  424. package/codeyam-cli/src/webserver/build/client/assets/files-C3-cQjgv.js +0 -1
  425. package/codeyam-cli/src/webserver/build/client/assets/git-Dp4EB9nv.js +0 -12
  426. package/codeyam-cli/src/webserver/build/client/assets/globals-Da3jt49-.css +0 -1
  427. package/codeyam-cli/src/webserver/build/client/assets/manifest-172a4629.js +0 -1
  428. package/codeyam-cli/src/webserver/build/client/assets/root-COyVTsPq.js +0 -16
  429. package/codeyam-cli/src/webserver/build/client/assets/search-CvyP_1Lo.js +0 -1
  430. package/codeyam-cli/src/webserver/build/client/assets/settings-Hbf8b7J_.js +0 -1
  431. package/codeyam-cli/src/webserver/build/client/assets/simulations-BMBi0VzO.js +0 -1
  432. package/codeyam-cli/src/webserver/build/client/assets/useToast-C_VxoXTh.js +0 -1
  433. package/codeyam-cli/src/webserver/build/client/cy-logo-cli.svg +0 -13
  434. package/codeyam-cli/src/webserver/build/server/assets/index-eAULANMV.js +0 -1
  435. package/codeyam-cli/src/webserver/build/server/assets/server-build-lutv16q5.js +0 -161
  436. package/codeyam-cli/src/webserver/public/cy-logo-cli.svg +0 -13
  437. package/packages/ai/src/lib/generateEntityDataMap.js +0 -335
  438. package/packages/ai/src/lib/generateEntityDataMap.js.map +0 -1
  439. package/packages/ai/src/lib/promptGenerators/generateEntityDataMapGenerator.js +0 -17
  440. package/packages/ai/src/lib/promptGenerators/generateEntityDataMapGenerator.js.map +0 -1
@@ -244,6 +244,9 @@ const jsonToCode = (
244
244
  } else {
245
245
  const keyStrings: string[] = [];
246
246
  const jsonObj = json as Record<string, unknown>;
247
+ // Track normalized function names to avoid duplicate keys in output
248
+ // e.g., submit({ a }) and submit({ b }) should both become "submit" once
249
+ const seenNormalizedFuncNames = new Set<string>();
247
250
 
248
251
  for (const key of Object.keys(jsonObj)) {
249
252
  if (jsonObj[key] === undefined || jsonObj[key] === null) continue;
@@ -252,6 +255,42 @@ const jsonToCode = (
252
255
  if (key === '~~codeyam-jsx~~') {
253
256
  return `<>${(jsonObj[key] as string[]).join('')}</>`;
254
257
  }
258
+
259
+ // Check if this is a nested function signature with array value
260
+ // e.g., "postMessage(message, '*')": ["mockMessageString", "*"]
261
+ // These need to be transformed into callable arrow functions
262
+ // Only apply at deeper nesting levels (level > 2) - top-level mock data keys
263
+ // (level 2) are return values that should preserve their data
264
+ // Skip when array contains objects (likely return data like getAll() returning [{name, value}])
265
+ const argsArray = jsonObj[key] as unknown[];
266
+ const isReturnData = argsArray.some(
267
+ (item) => item && typeof item === 'object' && !Array.isArray(item),
268
+ );
269
+ if (
270
+ key.includes('(') &&
271
+ key.endsWith(')') &&
272
+ level > 2 &&
273
+ !isReturnData
274
+ ) {
275
+ const funcName = key.split('(')[0];
276
+ // Skip if we've already added this normalized function name
277
+ if (seenNormalizedFuncNames.has(funcName)) {
278
+ continue;
279
+ }
280
+ seenNormalizedFuncNames.add(funcName);
281
+ const argsArray = jsonObj[key] as unknown[];
282
+ const argsString = argsArray
283
+ .map((_, i) => `arg${i + 1}`)
284
+ .join(', ');
285
+ console.log(
286
+ `CodeYam: Nested func transform (array): "${key}" -> "${funcName}"`,
287
+ );
288
+ keyStrings.push(
289
+ `${levelSpacing}"${safeString(funcName, level)}": (${argsString}) => {}`,
290
+ );
291
+ continue;
292
+ }
293
+
255
294
  const arrayString = jsonToCode(
256
295
  jsonObj[key],
257
296
  level + 1,
@@ -269,9 +308,38 @@ const jsonToCode = (
269
308
  );
270
309
  }
271
310
  } else if (typeof jsonObj[key] === 'object') {
272
- // Check if this object has a "functionCallReturnValue" key - if so, unwrap it
273
311
  const objKeys = Object.keys(jsonObj[key] as object);
312
+
313
+ // Check if this is a nested function signature (e.g., "postMessage(message, targetOrigin)": { signature: [...] })
314
+ // These need to be transformed into callable arrow functions
315
+ // Only apply at deeper nesting levels (level > 2) - top-level mock data keys
316
+ // (level 2) are return values that should preserve their data
274
317
  if (
318
+ key.includes('(') &&
319
+ key.endsWith(')') &&
320
+ level > 2 &&
321
+ objKeys.includes('signature') &&
322
+ Array.isArray((jsonObj[key] as Record<string, unknown>).signature)
323
+ ) {
324
+ const funcName = key.split('(')[0];
325
+ // Skip if we've already added this normalized function name
326
+ if (seenNormalizedFuncNames.has(funcName)) {
327
+ continue;
328
+ }
329
+ seenNormalizedFuncNames.add(funcName);
330
+ const signature = (jsonObj[key] as Record<string, unknown>)
331
+ .signature as string[];
332
+ const argsString = signature
333
+ .map((_, i) => `arg${i + 1}`)
334
+ .join(', ');
335
+ console.log(
336
+ `CodeYam: Nested func transform (signature): "${key}" -> "${funcName}"`,
337
+ );
338
+ keyStrings.push(
339
+ `${levelSpacing}"${safeString(funcName, level)}": (${argsString}) => {}`,
340
+ );
341
+ } else if (
342
+ // Check if this object has a "functionCallReturnValue" key - if so, unwrap it
275
343
  objKeys.length === 1 &&
276
344
  objKeys[0] === 'functionCallReturnValue'
277
345
  ) {
@@ -341,9 +409,60 @@ const jsonToCode = (
341
409
  }
342
410
  return keyValue;
343
411
  } else if (typeof jsonObj[key] === 'string') {
344
- keyStrings.push(
345
- `${levelSpacing}"${safeString(key, level)}": "${safeString(jsonObj[key] as string, level)}"`,
346
- );
412
+ const stringValue = jsonObj[key] as string;
413
+
414
+ // Check if this is a nested function signature with string value
415
+ // e.g., "postMessage(message, '*')": "() => { console.log('postMessage called'); }"
416
+ // These need to have the key normalized to just the function name
417
+ // Only apply at deeper nesting levels (level > 2)
418
+ if (key.includes('(') && key.endsWith(')') && level > 2) {
419
+ const funcName = key.split('(')[0];
420
+
421
+ // Skip if we've already added this normalized function name
422
+ if (seenNormalizedFuncNames.has(funcName)) {
423
+ continue;
424
+ }
425
+ seenNormalizedFuncNames.add(funcName);
426
+
427
+ // Check if the string value looks like a function expression
428
+ const looksLikeFunction =
429
+ stringValue.includes('=>') ||
430
+ stringValue.startsWith('function') ||
431
+ stringValue.startsWith('async');
432
+
433
+ // Handle special type indicators that need transformation
434
+ let outputValue: string;
435
+ if (stringValue === 'promise') {
436
+ outputValue = 'Promise.resolve()';
437
+ console.log(
438
+ `CodeYam: Nested func transform (string->Promise): "${key}" -> "${funcName}": Promise.resolve()`,
439
+ );
440
+ } else if (stringValue === 'function') {
441
+ outputValue = '() => {}';
442
+ console.log(
443
+ `CodeYam: Nested func transform (string->function): "${key}" -> "${funcName}": () => {}`,
444
+ );
445
+ } else if (looksLikeFunction) {
446
+ outputValue = stringValue;
447
+ console.log(
448
+ `CodeYam: Nested func transform (string): "${key}" -> "${funcName}": ${stringValue.substring(0, 30)}...`,
449
+ );
450
+ } else {
451
+ // Plain string value - must be quoted
452
+ outputValue = `"${safeString(stringValue, level)}"`;
453
+ console.log(
454
+ `CodeYam: Nested func transform (string->quoted): "${key}" -> "${funcName}": "${stringValue}"`,
455
+ );
456
+ }
457
+
458
+ keyStrings.push(
459
+ `${levelSpacing}"${safeString(funcName, level)}": ${outputValue}`,
460
+ );
461
+ } else {
462
+ keyStrings.push(
463
+ `${levelSpacing}"${safeString(key, level)}": "${safeString(stringValue, level)}"`,
464
+ );
465
+ }
347
466
  } else {
348
467
  keyStrings.push(
349
468
  `${levelSpacing}"${safeString(key, level)}": ${safeString(String(jsonObj[key]), level)}`,
@@ -437,6 +556,7 @@ import React from 'react';
437
556
  const rawScenarioMockData = {
438
557
  ...(mockScenario.metadata.data?.mockData ?? {}),
439
558
  };
559
+
440
560
  // Reconcile scenario-specific mock data keys as well
441
561
  const scenarioMockData = reconcileMockDataKeys(
442
562
  rawScenarioMockData,
@@ -448,6 +568,7 @@ import React from 'react';
448
568
  });
449
569
 
450
570
  const mergedMockData = deepMerge(defaultMockData, scenarioMockData);
571
+
451
572
  // Normalize mock data to merge entries with same normalized function name
452
573
  const normalizedMockData = normalizeMockData(
453
574
  mergedMockData as Record<string, unknown>,
@@ -43,6 +43,12 @@ interface WriteScenarioComponentsArgs {
43
43
  })[];
44
44
  writtenScenarioComponents?: { [key: string]: string[] };
45
45
  fileStore?: LazyFileStore;
46
+ /**
47
+ * When a default export needs to be accessible as a named export (e.g., when
48
+ * the parent imports it as `{ Name }` via an index re-export), pass the name here.
49
+ * A re-export statement `export { default as Name };` will be added to the output.
50
+ */
51
+ exportAsNamed?: string;
46
52
  }
47
53
 
48
54
  type EnhancedImportedExport = Omit<
@@ -83,54 +89,62 @@ function isIndexPath(filePath: string) {
83
89
  }
84
90
 
85
91
  /**
86
- * Rewrite asset imports (CSS, images, fonts, etc.) to correct relative paths.
87
- * These imports aren't tracked as importedExports, so we need to handle them separately.
92
+ * Rewrite relative asset paths to correct locations when a file is moved.
88
93
  *
89
- * Handles patterns like:
94
+ * This function generically handles ANY string literal containing a relative path
95
+ * to an asset file, not just import statements. This catches patterns like:
90
96
  * - import "./globals.css"
91
97
  * - import styles from "./file.module.css"
92
- * - import logo from "./logo.png"
98
+ * - localFont({ src: "../fonts/font.woff2" })
99
+ * - Image src="../images/logo.png"
100
+ * - Any other string literal with a relative asset path
93
101
  */
94
102
  function rewriteAssetImports(
95
103
  fileContent: string,
96
104
  originalFilePath: string,
97
105
  newFilePath: string,
98
106
  ): string {
99
- // Match imports with non-JS/TS extensions
107
+ // Asset file extensions that should have their paths rewritten
100
108
  const assetExtensions =
101
109
  'css|scss|sass|less|styl|png|jpg|jpeg|gif|svg|webp|ico|woff|woff2|ttf|eot|otf|mp4|webm|json';
102
- const assetImportRegex = new RegExp(
103
- `import\\s+(?:[\\w$]+\\s+from\\s+)?(['"])(\\.{1,2}/[^'"]+\\.(?:${assetExtensions}))\\1`,
110
+
111
+ // Match ANY string literal containing a relative path to an asset file
112
+ // This captures both single and double quoted strings that start with ./ or ../
113
+ const relativeAssetPathRegex = new RegExp(
114
+ `(['"])(\\.{1,2}/[^'"]*\\.(?:${assetExtensions}))\\1`,
104
115
  'g',
105
116
  );
106
117
 
107
118
  // Get the directory part of the original file path (relative to project root)
108
119
  const originalDirParts = originalFilePath.split('/').slice(0, -1);
109
120
 
110
- return fileContent.replace(assetImportRegex, (match, quote, importPath) => {
111
- // Resolve the asset path relative to the original file's directory
112
- // We need to manually resolve the relative path without using path.resolve
113
- // which would resolve against the actual filesystem
114
- const importParts = importPath.split('/');
115
- const resolvedParts = [...originalDirParts];
116
-
117
- for (const part of importParts) {
118
- if (part === '..') {
119
- resolvedParts.pop();
120
- } else if (part !== '.') {
121
- resolvedParts.push(part);
121
+ return fileContent.replace(
122
+ relativeAssetPathRegex,
123
+ (match, quote, assetPath) => {
124
+ // Resolve the asset path relative to the original file's directory
125
+ // We need to manually resolve the relative path without using path.resolve
126
+ // which would resolve against the actual filesystem
127
+ const pathParts = assetPath.split('/');
128
+ const resolvedParts = [...originalDirParts];
129
+
130
+ for (const part of pathParts) {
131
+ if (part === '..') {
132
+ resolvedParts.pop();
133
+ } else if (part !== '.') {
134
+ resolvedParts.push(part);
135
+ }
122
136
  }
123
- }
124
137
 
125
- // Build the project-relative path to the asset
126
- const absoluteAssetPath = resolvedParts.join('/');
138
+ // Build the project-relative path to the asset
139
+ const absoluteAssetPath = resolvedParts.join('/');
127
140
 
128
- // Calculate the new relative path from new file location
129
- const newRelativePath = getRelativePath(newFilePath, absoluteAssetPath);
141
+ // Calculate the new relative path from new file location
142
+ const newRelativePath = getRelativePath(newFilePath, absoluteAssetPath);
130
143
 
131
- // Reconstruct the import statement
132
- return match.replace(importPath, newRelativePath);
133
- });
144
+ // Replace the path in the original match, preserving the quote style
145
+ return `${quote}${newRelativePath}${quote}`;
146
+ },
147
+ );
134
148
  }
135
149
 
136
150
  function addMockToContent(
@@ -409,6 +423,7 @@ export default async function writeScenarioComponents({
409
423
  namespaceMocks,
410
424
  writtenScenarioComponents = {},
411
425
  fileStore,
426
+ exportAsNamed,
412
427
  }: WriteScenarioComponentsArgs): Promise<{
413
428
  scenarioComponentPaths: string[];
414
429
  writtenScenarioComponents: { [key: string]: string[] };
@@ -643,10 +658,12 @@ export default async function writeScenarioComponents({
643
658
  (importedExportEntity as Entity).localFilePath = importedExport.filePath;
644
659
 
645
660
  if (!importedExport.isMocked) {
661
+ // Use resolvedFilePath (actual entity location) for scenario component writing.
662
+ // This is critical for re-exports: when importing from index.tsx which re-exports
663
+ // from a nested file, we need to write scenario components for the actual file
664
+ // where the entity code lives, not the re-export file.
646
665
  const importedExportFilePath =
647
- importedExportEntity.localFilePath === file.path
648
- ? (importedExport.resolvedFilePath ?? importedExport.filePath)
649
- : importedExport.filePath;
666
+ importedExport.resolvedFilePath ?? importedExport.filePath;
650
667
 
651
668
  if (importedExportFilePath !== file.path) {
652
669
  if (
@@ -668,17 +685,41 @@ export default async function writeScenarioComponents({
668
685
  ? fileStore.getByPath(importedExportFilePath)
669
686
  : project.files.find((f) => f.path === importedExportFilePath);
670
687
 
688
+ // Fallback: if file at resolvedFilePath doesn't exist, try filePath
689
+ // This handles cases where the actual entity file isn't in project.files
690
+ // (e.g., type re-exports where only the index file is tracked)
691
+ if (
692
+ !fileNotMocked &&
693
+ importedExport.resolvedFilePath &&
694
+ importedExport.filePath !== importedExport.resolvedFilePath
695
+ ) {
696
+ const fallbackPath = importedExport.filePath;
697
+ fileNotMocked = fileStore
698
+ ? fileStore.getByPath(fallbackPath)
699
+ : project.files.find((f) => f.path === fallbackPath);
700
+ }
701
+
702
+ // Skip if file still not found - can't write scenario component without the file
703
+ if (!fileNotMocked) {
704
+ continue;
705
+ }
706
+
671
707
  // Ensure content is loaded for the file
672
708
  if (
673
709
  fileNotMocked &&
674
710
  fileStore &&
675
- !fileStore.isContentLoaded(importedExportFilePath)
711
+ !fileStore.isContentLoaded(fileNotMocked.path)
676
712
  ) {
677
- fileNotMocked = await fileStore.ensureContent(
678
- importedExportFilePath,
679
- );
713
+ fileNotMocked = await fileStore.ensureContent(fileNotMocked.path);
680
714
  }
681
715
 
716
+ // When a default export is imported as named (via index re-export), we need
717
+ // to add a named re-export to the scenario component so the import works.
718
+ // e.g., if file has `export default X` but parent does `import { X } from '...'`
719
+ const needsNamedReExport =
720
+ importedExport.resolvedIsDefault === true &&
721
+ importedExport.isDefault === false;
722
+
682
723
  const {
683
724
  scenarioComponentPaths: newScenarioComponentPaths,
684
725
  writtenScenarioComponents: updatedWrittenScenarioComponents,
@@ -696,6 +737,8 @@ export default async function writeScenarioComponents({
696
737
  namespaceMocks,
697
738
  writtenScenarioComponents,
698
739
  fileStore,
740
+ // Pass the import name so we can add `export { default as Name };`
741
+ exportAsNamed: needsNamedReExport ? importedExport.name : undefined,
699
742
  });
700
743
  writtenScenarioComponents = updatedWrittenScenarioComponents;
701
744
  scenarioComponentPaths.push(...newScenarioComponentPaths);
@@ -729,18 +772,38 @@ export default async function writeScenarioComponents({
729
772
  relativeMocksDir,
730
773
  scenario.name,
731
774
  );
775
+ } else if (importedExport.isMocked) {
776
+ // No mock structure available, but isMocked is true.
777
+ // Generate a simple stub mock that returns scenario data.
778
+ // This prevents ReferenceError at runtime when the stripped
779
+ // function is called (e.g., local helper functions like getInitialProps).
780
+ const functionName = importedExport.name;
781
+
782
+ // Add scenarios import if not present
783
+ if (fileContent.indexOf('import { scenarios } from') === -1) {
784
+ const mockDataPath = `${relativeMocksDir}/MockData_${safeFileName(scenario.name)}`;
785
+ const importStatement = `import { scenarios } from "${mockDataPath}";`;
786
+ fileContent = `${fileContent}\n\n\n${importStatement}`;
787
+ }
788
+
789
+ // Generate a simple stub that returns the scenario data for this function
790
+ const stubMock = `\n\n// Stub mock for local function without mock structure\nfunction ${functionName}(...args) {\n return scenarios().data()?.["${functionName}()"];\n}`;
791
+ fileContent += stubMock;
732
792
  }
733
793
  }
734
794
  }
735
795
 
736
796
  // Try to find the import mapping using different key formats
737
797
  // The import mapping may use either absolute or relative paths as keys
738
- // IMPORTANT: Use filePath (where it's imported FROM), not resolvedFilePath (where entity lives)
739
- // For re-exports like ~codeyam/types, filePath="packages/types/index.ts",
740
- // resolvedFilePath="packages/types/src/types/Commit.ts"
741
- // We need to generate files at the import location (index.ts), not the entity location
798
+ // Use filePath (import source) for looking up the import mapping
799
+ // because that's how imports are written in source code
742
800
  const mockFilePathRelative = importedExport.filePath;
743
801
 
802
+ // For scenario component paths, prefer resolvedFilePath (where entity actually lives)
803
+ // because that's where scenario component files are written
804
+ const scenarioFilePathRelative =
805
+ importedExport.resolvedFilePath ?? importedExport.filePath;
806
+
744
807
  // Try looking up with different key formats (absolute, relative, resolved absolute)
745
808
  // Filter out undefined keys to avoid misleading undefined lookups
746
809
  const lookupKeys = [
@@ -794,10 +857,28 @@ export default async function writeScenarioComponents({
794
857
  } else {
795
858
  // For non-mocked imports, rewrite the import path to point to the generated scenario file
796
859
  // Use fileStore for O(1) lookup when available
797
- const fileNotMocked = fileStore
798
- ? fileStore.getByPath(mockFilePathRelative)
799
- : project.files.find((f) => f.path === mockFilePathRelative);
800
- const fileName = mockFilePathRelative.split('/').pop();
860
+ // First try resolvedFilePath (where entity lives), fallback to filePath (import source)
861
+ let fileNotMocked = fileStore
862
+ ? fileStore.getByPath(scenarioFilePathRelative)
863
+ : project.files.find((f) => f.path === scenarioFilePathRelative);
864
+
865
+ // Track which path we're actually using for the scenario component
866
+ let actualScenarioFilePathRelative = scenarioFilePathRelative;
867
+ if (
868
+ !fileNotMocked &&
869
+ importedExport.resolvedFilePath &&
870
+ importedExport.filePath !== importedExport.resolvedFilePath
871
+ ) {
872
+ // Fallback to filePath if file at resolvedFilePath doesn't exist
873
+ actualScenarioFilePathRelative = importedExport.filePath;
874
+ fileNotMocked = fileStore
875
+ ? fileStore.getByPath(actualScenarioFilePathRelative)
876
+ : project.files.find(
877
+ (f) => f.path === actualScenarioFilePathRelative,
878
+ );
879
+ }
880
+
881
+ const fileName = actualScenarioFilePathRelative.split('/').pop();
801
882
  const fileNotMockedIsIndex = isIndexPath(fileNotMocked?.path);
802
883
  const mockFilePath = isFrameworkRoute(
803
884
  fileNotMocked,
@@ -810,7 +891,7 @@ export default async function writeScenarioComponents({
810
891
  rootFile,
811
892
  entity: importedExportEntity,
812
893
  rootAnalysis,
813
- scenarioComponentPath: mockFilePathRelative,
894
+ scenarioComponentPath: actualScenarioFilePathRelative,
814
895
  project,
815
896
  framework,
816
897
  scenario,
@@ -818,7 +899,7 @@ export default async function writeScenarioComponents({
818
899
  .split('.')
819
900
  .slice(0, -1)
820
901
  .join('.')
821
- : mockFilePathRelative.replace(
902
+ : actualScenarioFilePathRelative.replace(
822
903
  `${fileName}`,
823
904
  `${importedExportEntity.sha}_${fileNotMockedIsIndex ? 'index_' : ''}${safeFileName(importedExportEntity.name)}_${safeFileName(scenario.name)}`,
824
905
  );
@@ -833,7 +914,39 @@ export default async function writeScenarioComponents({
833
914
  'g',
834
915
  );
835
916
 
836
- fileContent = fileContent.replace(importRegExp, `${path}$1`);
917
+ // Check if the original import path still exists in the file
918
+ // If it was already rewritten by another entity from the same module,
919
+ // we need to add a separate import statement for this entity
920
+ if (fileContent.match(importRegExp)) {
921
+ fileContent = fileContent.replace(importRegExp, `${path}$1`);
922
+ } else {
923
+ // The import path was already rewritten - add a new import for this entity
924
+ // This handles cases where multiple entities are imported from the same index file
925
+ // (e.g., import { A, B, C } from '@pkg') and each has its own scenario file
926
+ const entityImportName = importedExport.name;
927
+ const newImport = `import { ${entityImportName} } from '${path}';`;
928
+
929
+ // First, try to remove this entity from the already-rewritten grouped import
930
+ // This prevents duplicate/conflicting imports
931
+ // Match patterns like "EntityName," or ", EntityName" or "EntityName" (if only one)
932
+ const removeFromGroupedImportPatterns = [
933
+ new RegExp(`\\b${entityImportName}\\s*,\\s*`, 'g'), // "EntityName, "
934
+ new RegExp(`\\s*,\\s*${entityImportName}\\b`, 'g'), // ", EntityName"
935
+ ];
936
+ for (const pattern of removeFromGroupedImportPatterns) {
937
+ fileContent = fileContent.replace(pattern, '');
938
+ }
939
+
940
+ // Add the new import at the beginning of fileContent
941
+ // Note: The header comment (// Scenario:) doesn't exist yet - it's prepended at writeFile time
942
+ // So prepending here puts the import right after the header in the final output
943
+ //
944
+ // IMPORTANT: We cannot use indexOf('// Scenario:') + '\n\n' here because:
945
+ // 1. The header doesn't exist during processing
946
+ // 2. indexOf would return -1, and indexOf('\n\n', -1) starts from 0
947
+ // 3. This could find a \n\n inside a function body, inserting the import there!
948
+ fileContent = newImport + '\n' + fileContent;
949
+ }
837
950
  }
838
951
  }
839
952
  }
@@ -852,6 +965,36 @@ export default async function writeScenarioComponents({
852
965
  );
853
966
  }
854
967
 
968
+ // Rewrite node_module imports that have universal mocks
969
+ // Universal mocks create mock files at __codeyamMocks__/{safeFileName}.tsx
970
+ // We need to rewrite imports like `import { logger } from "@formbricks/logger"`
971
+ // to `import { logger } from "../__codeyamMocks__/_formbricks_logger"`
972
+ const universalMocks = project.metadata?.universalMocks ?? [];
973
+ const nodeModuleUniversalMocks = universalMocks.filter(
974
+ (mock) => mock.nodeModule && mock.content,
975
+ );
976
+
977
+ for (const universalMock of nodeModuleUniversalMocks) {
978
+ const originalPath = universalMock.filePath;
979
+ // Create the mock file name using the same pattern as applyUniversalMocks
980
+ const safeFileName = originalPath.replace(/[^a-zA-Z0-9_\-./]/g, '_');
981
+ const mockFileRelativePath = `${relativeMocksDir}/${safeFileName}`;
982
+
983
+ // Match both single and double quotes, and handle both named and default imports
984
+ // Pattern 1: import { x, y } from "module"
985
+ // Pattern 2: import x from "module"
986
+ // Pattern 3: import * as x from "module"
987
+ const importRegex = new RegExp(
988
+ `(import\\s+(?:\\{[^}]*\\}|\\*\\s+as\\s+\\w+|\\w+)\\s+from\\s+)['"]${originalPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}['"]`,
989
+ 'g',
990
+ );
991
+
992
+ fileContent = fileContent.replace(
993
+ importRegex,
994
+ `$1'${mockFileRelativePath}'`,
995
+ );
996
+ }
997
+
855
998
  if (
856
999
  rootAnalysis.entitySha === entity.sha &&
857
1000
  entity.metadata?.notExported &&
@@ -864,6 +1007,17 @@ export default async function writeScenarioComponents({
864
1007
  }
865
1008
  }
866
1009
 
1010
+ // When a default export is imported as named via re-export (e.g., index.tsx re-exports
1011
+ // a default export as named), we need to add a named export so the parent's
1012
+ // import statement works: `import { Name } from './path'`
1013
+ // The local variable name is the same as exportAsNamed (e.g., ScenarioEditor)
1014
+ if (exportAsNamed) {
1015
+ const namedExport = `export { ${exportAsNamed} };`;
1016
+ if (!fileContent.includes(namedExport)) {
1017
+ fileContent = `${fileContent}\n\n${namedExport}`;
1018
+ }
1019
+ }
1020
+
867
1021
  const basePath = safeFolder(file.path.split('/').slice(0, -1).join('/'));
868
1022
  const extension = file.name.split('.').pop();
869
1023
  // Include scenario name in path to allow multiple scenarios to coexist
@@ -28,7 +28,26 @@ export default async function writeUniversalMocks({
28
28
  }: WriteUniversalMocksArgs) {
29
29
  const { project } = projectAnalyzer;
30
30
 
31
- for (const universalMock of project.metadata?.universalMocks ?? []) {
31
+ // Group node_module mocks by filePath to merge multiple exports into one file
32
+ // This prevents later mocks from overwriting earlier ones for the same package
33
+ const nodeModuleMocksByPath = new Map<
34
+ string,
35
+ Array<(typeof universalMocks)[number]>
36
+ >();
37
+ const universalMocks = project.metadata?.universalMocks ?? [];
38
+
39
+ for (const mock of universalMocks) {
40
+ if (mock.nodeModule) {
41
+ const existing = nodeModuleMocksByPath.get(mock.filePath) ?? [];
42
+ existing.push(mock);
43
+ nodeModuleMocksByPath.set(mock.filePath, existing);
44
+ }
45
+ }
46
+
47
+ // Track which filePaths we've already processed (for node_modules)
48
+ const processedNodeModulePaths = new Set<string>();
49
+
50
+ for (const universalMock of universalMocks) {
32
51
  console.log(
33
52
  'CodeYam: Initializing universal mock',
34
53
  universalMock.filePath,
@@ -60,13 +79,27 @@ export default async function writeUniversalMocks({
60
79
  universalMock.filePath,
61
80
  );
62
81
  const fileAnalyzer = projectAnalyzer.getFileAnalyzer(file);
63
- if (fileAnalyzer.getAllEntityNodes()[universalMock.entityName]) {
64
- const entityCode = fileAnalyzer.getEntityCode(
82
+
83
+ // Use getAllDeclaredEntityNodes to avoid incorrectly matching identifier references
84
+ if (
85
+ fileAnalyzer.getAllDeclaredEntityNodes()[universalMock.entityName]
86
+ ) {
87
+ const entityCode = fileAnalyzer.getDeclaredEntityCode(
65
88
  universalMock.entityName,
66
89
  );
67
90
  mockContent = file.content.replace(entityCode, universalMock.content);
68
91
  }
69
92
  } else {
93
+ // For node_modules, check if we've already processed this path
94
+ // (multiple mocks for the same package should be merged)
95
+ if (universalMock.nodeModule) {
96
+ if (processedNodeModulePaths.has(universalMock.filePath)) {
97
+ // Already processed as part of a merged mock, skip
98
+ continue;
99
+ }
100
+ processedNodeModulePaths.add(universalMock.filePath);
101
+ }
102
+
70
103
  const appPath = getAppPath(
71
104
  project,
72
105
  framework,
@@ -83,14 +116,37 @@ export default async function writeUniversalMocks({
83
116
  CODEYAM_MOCKS_DIRNAME,
84
117
  safeFileName(filePathForMockFile) + '.tsx',
85
118
  );
86
- const exportName =
87
- universalMock.entityName === 'default'
88
- ? 'default'
89
- : `{ ${universalMock.entityName} }`;
90
- if (exportName === 'default') {
91
- mockContent = `export default ${universalMock.content}`;
119
+
120
+ // For node_modules, merge all mocks for this filePath
121
+ const mocksToProcess = universalMock.nodeModule
122
+ ? (nodeModuleMocksByPath.get(universalMock.filePath) ?? [
123
+ universalMock,
124
+ ])
125
+ : [universalMock];
126
+
127
+ const contentParts: string[] = [];
128
+ const namedExports: string[] = [];
129
+ let hasDefaultExport = false;
130
+
131
+ for (const mock of mocksToProcess) {
132
+ if (mock.entityName === 'default') {
133
+ hasDefaultExport = true;
134
+ contentParts.push(`export default ${mock.content}`);
135
+ } else {
136
+ contentParts.push(mock.content);
137
+ namedExports.push(mock.entityName);
138
+ }
139
+ }
140
+
141
+ // Build the final mock content
142
+ if (namedExports.length > 0) {
143
+ mockContent = contentParts.join('\n\n');
144
+ // Only add export statement for non-default exports if not already in content
145
+ if (!hasDefaultExport || namedExports.length > 0) {
146
+ mockContent += `\n\nexport { ${namedExports.join(', ')} };`;
147
+ }
92
148
  } else {
93
- mockContent = `${universalMock.content}\n\nexport { ${universalMock.entityName} };`;
149
+ mockContent = contentParts.join('\n\n');
94
150
  }
95
151
  }
96
152
 
@@ -132,6 +188,12 @@ export default async function writeUniversalMocks({
132
188
  );
133
189
  const allSourceFiles = projectAnalyzer.getAllSourceFiles();
134
190
  for (const sourceFile of allSourceFiles) {
191
+ // Skip JSON files - they should not have imports rewritten
192
+ // This can happen when resolveJsonModule is enabled in tsconfig
193
+ // and package.json is included in the TypeScript program
194
+ if (sourceFile.path.endsWith('.json')) {
195
+ continue;
196
+ }
135
197
  if (importRegEx.test(sourceFile.content)) {
136
198
  const relativeMockPath = getRelativePath(sourceFile.path, mockPath);
137
199
  const newContent = sourceFile.content.replace(