@codeyam/codeyam-cli 0.1.0-staging.8aea589 → 0.1.0-staging.bbe4da9

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 (485) 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 +6 -2
  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 +145 -4
  12. package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +1 -3
  13. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +1877 -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/cleanNonObjectFunctions.ts +64 -1
  23. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +14 -6
  24. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/selectBestValue.ts +70 -0
  25. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/uniqueIdUtils.ts +113 -0
  26. package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +36 -0
  27. package/analyzer-template/packages/ai/src/lib/generateChangesEntityDocumentation.ts +20 -2
  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 +32 -8
  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 +41 -0
  47. package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +47 -8
  48. package/analyzer-template/packages/analyze/src/lib/asts/nodes/getNodeType.ts +1 -1
  49. package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +2 -1
  50. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExportedNodes.ts +4 -2
  51. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +5 -3
  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/analyzeRemixRoute.ts +21 -33
  60. package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +75 -10
  61. package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +26 -0
  62. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +7 -1
  63. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +9 -1
  64. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +6 -1
  65. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +9 -1
  66. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +15 -7
  67. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +12 -2
  68. package/analyzer-template/packages/aws/dist/src/lib/s3/getPresignedUrl.d.ts +23 -0
  69. package/analyzer-template/packages/aws/dist/src/lib/s3/getPresignedUrl.d.ts.map +1 -0
  70. package/analyzer-template/packages/aws/dist/src/lib/s3/getPresignedUrl.js +30 -0
  71. package/analyzer-template/packages/aws/dist/src/lib/s3/getPresignedUrl.js.map +1 -0
  72. package/analyzer-template/packages/aws/package.json +5 -4
  73. package/analyzer-template/packages/aws/s3/index.ts +4 -0
  74. package/analyzer-template/packages/aws/src/lib/s3/getPresignedUrl.ts +62 -0
  75. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +28 -21
  76. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageRemix.ts +18 -11
  77. package/analyzer-template/packages/generate/src/lib/scenarioComponent.ts +6 -3
  78. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
  79. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +28 -21
  80. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  81. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageRemix.d.ts.map +1 -1
  82. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageRemix.js +18 -11
  83. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageRemix.js.map +1 -1
  84. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponent.d.ts.map +1 -1
  85. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponent.js +5 -3
  86. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponent.js.map +1 -1
  87. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/db.d.ts +2 -0
  88. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/db.d.ts.map +1 -1
  89. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/db.js +3 -0
  90. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/db.js.map +1 -1
  91. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/tableRelations.d.ts +2 -0
  92. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/tableRelations.d.ts.map +1 -1
  93. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/tables/debugReportsTable.d.ts +37 -0
  94. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -0
  95. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/tables/debugReportsTable.js +27 -0
  96. package/analyzer-template/packages/github/dist/supabase/src/lib/kysely/tables/debugReportsTable.js.map +1 -0
  97. package/analyzer-template/packages/github/dist/supabase/src/lib/scenarioToDb.d.ts.map +1 -1
  98. package/analyzer-template/packages/github/dist/supabase/src/lib/scenarioToDb.js +1 -1
  99. package/analyzer-template/packages/github/dist/supabase/src/lib/scenarioToDb.js.map +1 -1
  100. package/analyzer-template/packages/github/dist/utils/index.d.ts +2 -0
  101. package/analyzer-template/packages/github/dist/utils/index.d.ts.map +1 -1
  102. package/analyzer-template/packages/github/dist/utils/index.js +2 -0
  103. package/analyzer-template/packages/github/dist/utils/index.js.map +1 -1
  104. package/analyzer-template/packages/github/dist/utils/src/lib/Semaphore.d.ts +25 -0
  105. package/analyzer-template/packages/github/dist/utils/src/lib/Semaphore.d.ts.map +1 -0
  106. package/analyzer-template/packages/github/dist/utils/src/lib/Semaphore.js +40 -0
  107. package/analyzer-template/packages/github/dist/utils/src/lib/Semaphore.js.map +1 -0
  108. package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.d.ts.map +1 -1
  109. package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.js +39 -5
  110. package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.js.map +1 -1
  111. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/getNextRoutePath.d.ts.map +1 -1
  112. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/getNextRoutePath.js +2 -1
  113. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/getNextRoutePath.js.map +1 -1
  114. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/getRemixRoutePath.d.ts.map +1 -1
  115. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/getRemixRoutePath.js +2 -1
  116. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/getRemixRoutePath.js.map +1 -1
  117. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/nextRouteFileNameToRoute.d.ts.map +1 -1
  118. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/nextRouteFileNameToRoute.js +2 -1
  119. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/nextRouteFileNameToRoute.js.map +1 -1
  120. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/remixRouteFileNameToRoute.d.ts.map +1 -1
  121. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/remixRouteFileNameToRoute.js +1 -0
  122. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/remixRouteFileNameToRoute.js.map +1 -1
  123. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/sanitizeNextRouteSegments.d.ts +12 -0
  124. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/sanitizeNextRouteSegments.d.ts.map +1 -0
  125. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/sanitizeNextRouteSegments.js +32 -0
  126. package/analyzer-template/packages/github/dist/utils/src/lib/frameworks/sanitizeNextRouteSegments.js.map +1 -0
  127. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
  128. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js +17 -0
  129. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  130. package/analyzer-template/packages/supabase/src/lib/kysely/db.ts +6 -0
  131. package/analyzer-template/packages/supabase/src/lib/kysely/tableRelations.ts +3 -0
  132. package/analyzer-template/packages/supabase/src/lib/kysely/tables/debugReportsTable.ts +61 -0
  133. package/analyzer-template/packages/supabase/src/lib/scenarioToDb.ts +1 -0
  134. package/analyzer-template/packages/ui-components/src/scenario-editor/components/DataItemEditor.tsx +1 -1
  135. package/analyzer-template/packages/utils/dist/utils/index.d.ts +2 -0
  136. package/analyzer-template/packages/utils/dist/utils/index.d.ts.map +1 -1
  137. package/analyzer-template/packages/utils/dist/utils/index.js +2 -0
  138. package/analyzer-template/packages/utils/dist/utils/index.js.map +1 -1
  139. package/analyzer-template/packages/utils/dist/utils/src/lib/Semaphore.d.ts +25 -0
  140. package/analyzer-template/packages/utils/dist/utils/src/lib/Semaphore.d.ts.map +1 -0
  141. package/analyzer-template/packages/utils/dist/utils/src/lib/Semaphore.js +40 -0
  142. package/analyzer-template/packages/utils/dist/utils/src/lib/Semaphore.js.map +1 -0
  143. package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.d.ts.map +1 -1
  144. package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.js +39 -5
  145. package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.js.map +1 -1
  146. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/getNextRoutePath.d.ts.map +1 -1
  147. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/getNextRoutePath.js +2 -1
  148. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/getNextRoutePath.js.map +1 -1
  149. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/getRemixRoutePath.d.ts.map +1 -1
  150. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/getRemixRoutePath.js +2 -1
  151. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/getRemixRoutePath.js.map +1 -1
  152. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/nextRouteFileNameToRoute.d.ts.map +1 -1
  153. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/nextRouteFileNameToRoute.js +2 -1
  154. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/nextRouteFileNameToRoute.js.map +1 -1
  155. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/remixRouteFileNameToRoute.d.ts.map +1 -1
  156. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/remixRouteFileNameToRoute.js +1 -0
  157. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/remixRouteFileNameToRoute.js.map +1 -1
  158. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/sanitizeNextRouteSegments.d.ts +12 -0
  159. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/sanitizeNextRouteSegments.d.ts.map +1 -0
  160. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/sanitizeNextRouteSegments.js +32 -0
  161. package/analyzer-template/packages/utils/dist/utils/src/lib/frameworks/sanitizeNextRouteSegments.js.map +1 -0
  162. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
  163. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js +17 -0
  164. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  165. package/analyzer-template/packages/utils/index.ts +2 -0
  166. package/analyzer-template/packages/utils/src/lib/Semaphore.ts +42 -0
  167. package/analyzer-template/packages/utils/src/lib/applyUniversalMocks.ts +46 -7
  168. package/analyzer-template/packages/utils/src/lib/frameworks/getNextRoutePath.ts +2 -1
  169. package/analyzer-template/packages/utils/src/lib/frameworks/getRemixRoutePath.ts +2 -1
  170. package/analyzer-template/packages/utils/src/lib/frameworks/nextRouteFileNameToRoute.ts +2 -1
  171. package/analyzer-template/packages/utils/src/lib/frameworks/remixRouteFileNameToRoute.ts +1 -0
  172. package/analyzer-template/packages/utils/src/lib/frameworks/sanitizeNextRouteSegments.ts +33 -0
  173. package/analyzer-template/packages/utils/src/lib/lightweightEntityExtractor.ts +16 -0
  174. package/analyzer-template/project/constructMockCode.ts +199 -9
  175. package/analyzer-template/project/reconcileMockDataKeys.ts +13 -0
  176. package/analyzer-template/project/runMultiScenarioServer.ts +0 -4
  177. package/analyzer-template/project/runScenarioServer.ts +0 -4
  178. package/analyzer-template/project/start.ts +1 -11
  179. package/analyzer-template/project/startScenarioCapture.ts +24 -0
  180. package/analyzer-template/project/startServer.ts +50 -70
  181. package/analyzer-template/project/trackGeneratedFiles.ts +41 -0
  182. package/analyzer-template/project/writeMockDataTsx.ts +191 -7
  183. package/analyzer-template/project/writeScenarioComponents.ts +643 -63
  184. package/analyzer-template/project/writeUniversalMocks.ts +66 -8
  185. package/analyzer-template/scripts/postbuild.cjs +12 -1
  186. package/background/src/lib/virtualized/project/constructMockCode.js +183 -11
  187. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  188. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +12 -0
  189. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
  190. package/background/src/lib/virtualized/project/runMultiScenarioServer.js +0 -3
  191. package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
  192. package/background/src/lib/virtualized/project/start.js +1 -8
  193. package/background/src/lib/virtualized/project/start.js.map +1 -1
  194. package/background/src/lib/virtualized/project/startScenarioCapture.js +18 -0
  195. package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
  196. package/background/src/lib/virtualized/project/startServer.js +40 -68
  197. package/background/src/lib/virtualized/project/startServer.js.map +1 -1
  198. package/background/src/lib/virtualized/project/trackGeneratedFiles.js +30 -0
  199. package/background/src/lib/virtualized/project/trackGeneratedFiles.js.map +1 -0
  200. package/background/src/lib/virtualized/project/writeMockDataTsx.js +156 -6
  201. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  202. package/background/src/lib/virtualized/project/writeScenarioComponents.js +433 -41
  203. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  204. package/background/src/lib/virtualized/project/writeUniversalMocks.js +56 -7
  205. package/background/src/lib/virtualized/project/writeUniversalMocks.js.map +1 -1
  206. package/codeyam-cli/src/cli.js +6 -0
  207. package/codeyam-cli/src/cli.js.map +1 -1
  208. package/codeyam-cli/src/codeyam-cli.js +0 -0
  209. package/codeyam-cli/src/commands/debug.js +222 -0
  210. package/codeyam-cli/src/commands/debug.js.map +1 -0
  211. package/codeyam-cli/src/commands/init.js +4 -23
  212. package/codeyam-cli/src/commands/init.js.map +1 -1
  213. package/codeyam-cli/src/commands/report.js +102 -0
  214. package/codeyam-cli/src/commands/report.js.map +1 -0
  215. package/codeyam-cli/src/commands/setup-sandbox.js +165 -0
  216. package/codeyam-cli/src/commands/setup-sandbox.js.map +1 -0
  217. package/codeyam-cli/src/commands/test-startup.js +14 -5
  218. package/codeyam-cli/src/commands/test-startup.js.map +1 -1
  219. package/codeyam-cli/src/utils/__tests__/cleanupAnalysisFiles.test.js +6 -6
  220. package/codeyam-cli/src/utils/__tests__/cleanupAnalysisFiles.test.js.map +1 -1
  221. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +8 -0
  222. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
  223. package/codeyam-cli/src/utils/analysisRunner.js +2 -1
  224. package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
  225. package/codeyam-cli/src/utils/analyzer.js +24 -2
  226. package/codeyam-cli/src/utils/analyzer.js.map +1 -1
  227. package/codeyam-cli/src/utils/cleanupAnalysisFiles.js +2 -2
  228. package/codeyam-cli/src/utils/cleanupAnalysisFiles.js.map +1 -1
  229. package/codeyam-cli/src/utils/generateReport.js +219 -0
  230. package/codeyam-cli/src/utils/generateReport.js.map +1 -0
  231. package/codeyam-cli/src/utils/install-skills.js +7 -0
  232. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  233. package/codeyam-cli/src/utils/queue/__tests__/job.pidTracking.test.js +1 -0
  234. package/codeyam-cli/src/utils/queue/__tests__/job.pidTracking.test.js.map +1 -1
  235. package/codeyam-cli/src/utils/queue/job.js +10 -5
  236. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  237. package/codeyam-cli/src/utils/sandbox.js +190 -0
  238. package/codeyam-cli/src/utils/sandbox.js.map +1 -0
  239. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +4 -0
  240. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
  241. package/codeyam-cli/src/utils/webappDetection.js +2 -1
  242. package/codeyam-cli/src/utils/webappDetection.js.map +1 -1
  243. package/codeyam-cli/src/webserver/app/lib/database.js +50 -2
  244. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  245. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-Dp_FTAs1.js +1 -0
  246. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-TlHocYno.js +26 -0
  247. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-CVMmGuIc.js +3 -0
  248. package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-BKKG1s2B.js → LogViewer-JkfQ-VaI.js} +1 -1
  249. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-Cqce0_KG.js +1 -0
  250. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BrMAP1nP.js +1 -0
  251. package/codeyam-cli/src/webserver/build/client/assets/ScenarioPreview-Bi-__7HT.js +6 -0
  252. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-XmIpHcLJ.js +5 -0
  253. package/codeyam-cli/src/webserver/build/client/assets/_index-BmfhU6CA.js +1 -0
  254. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-Dm8lM73z.js +10 -0
  255. package/codeyam-cli/src/webserver/build/client/assets/api.generate-report-l0sNRNKZ.js +1 -0
  256. package/codeyam-cli/src/webserver/build/client/assets/chart-column-kA4jn9if.js +1 -0
  257. package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-CgXbbZRx.js +26 -0
  258. package/codeyam-cli/src/webserver/build/client/assets/circle-check-B2oHQ-zo.js +1 -0
  259. package/codeyam-cli/src/webserver/build/client/assets/clock-BAfbP_iK.js +1 -0
  260. package/codeyam-cli/src/webserver/build/client/assets/codeyam-name-logo-CvKwUgHo.svg +9 -0
  261. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-BBYuR56H.js +1 -0
  262. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-BgPXZbm0.js +1 -0
  263. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-BHiWkb_W.js → entity._sha._-BkoAXaOa.js} +10 -10
  264. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-Bj5GHkhb.js +1 -0
  265. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-eW5z9AyZ.js +5 -0
  266. package/codeyam-cli/src/webserver/build/client/assets/entityStatus-C5Okl18j.js +1 -0
  267. package/codeyam-cli/src/webserver/build/client/assets/{entityVersioning-Bk_YB1jM.js → entityVersioning-CU_Lchhc.js} +1 -1
  268. package/codeyam-cli/src/webserver/build/client/assets/entry.client-B9tSboXM.js +5 -0
  269. package/codeyam-cli/src/webserver/build/client/assets/file-text-18aYHZGd.js +1 -0
  270. package/codeyam-cli/src/webserver/build/client/assets/files-Df79EyEb.js +1 -0
  271. package/codeyam-cli/src/webserver/build/client/assets/git-CDEwTVH_.js +12 -0
  272. package/codeyam-cli/src/webserver/build/client/assets/globals-DXRB6jBc.css +1 -0
  273. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +5 -0
  274. package/codeyam-cli/src/webserver/build/client/assets/index-_LjBsTxX.js +8 -0
  275. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-D_EGChhq.js +1 -0
  276. package/codeyam-cli/src/webserver/build/client/assets/manifest-3e0ffbcc.js +1 -0
  277. package/codeyam-cli/src/webserver/build/client/assets/root-CGyT4J4b.js +16 -0
  278. package/codeyam-cli/src/webserver/build/client/assets/settings-CEPbAsom.js +1 -0
  279. package/codeyam-cli/src/webserver/build/client/assets/settings-R8QF_mHX.js +1 -0
  280. package/codeyam-cli/src/webserver/build/client/assets/simulations-B_PXvFom.js +1 -0
  281. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-BthANBVv.js +1 -0
  282. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-Lumm1t01.js → useLastLogLine-Blr5oZDE.js} +1 -1
  283. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-CANr3QJ5.js +1 -0
  284. package/codeyam-cli/src/webserver/build/client/assets/useToast-Bbf4Hokd.js +1 -0
  285. package/codeyam-cli/src/webserver/build/server/assets/index-vf1FETCO.js +1 -0
  286. package/codeyam-cli/src/webserver/build/server/assets/server-build-B5s58TvB.js +169 -0
  287. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  288. package/codeyam-cli/src/webserver/build-info.json +5 -5
  289. package/codeyam-cli/src/webserver/server.js +1 -1
  290. package/codeyam-cli/src/webserver/server.js.map +1 -1
  291. package/codeyam-cli/templates/codeyam-setup-skill.md +70 -85
  292. package/codeyam-cli/templates/debug-command.md +125 -0
  293. package/package.json +9 -11
  294. package/packages/ai/index.js +2 -3
  295. package/packages/ai/index.js.map +1 -1
  296. package/packages/ai/src/lib/analyzeScope.js +13 -0
  297. package/packages/ai/src/lib/analyzeScope.js.map +1 -1
  298. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +6 -15
  299. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
  300. package/packages/ai/src/lib/astScopes/methodSemantics.js +134 -0
  301. package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
  302. package/packages/ai/src/lib/astScopes/paths.js +28 -3
  303. package/packages/ai/src/lib/astScopes/paths.js.map +1 -1
  304. package/packages/ai/src/lib/astScopes/processExpression.js +123 -3
  305. package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
  306. package/packages/ai/src/lib/checkAllAttributes.js +1 -3
  307. package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
  308. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1358 -396
  309. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  310. package/packages/ai/src/lib/dataStructure/equivalencyManagers/FunctionCallManager.js +137 -1
  311. package/packages/ai/src/lib/dataStructure/equivalencyManagers/FunctionCallManager.js.map +1 -1
  312. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +1 -1
  313. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
  314. package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +112 -0
  315. package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -0
  316. package/packages/ai/src/lib/dataStructure/helpers/DebugTracer.js +176 -0
  317. package/packages/ai/src/lib/dataStructure/helpers/DebugTracer.js.map +1 -0
  318. package/packages/ai/src/lib/dataStructure/helpers/PathManager.js +178 -0
  319. package/packages/ai/src/lib/dataStructure/helpers/PathManager.js.map +1 -0
  320. package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +138 -0
  321. package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -0
  322. package/packages/ai/src/lib/dataStructure/helpers/VisitedTracker.js +199 -0
  323. package/packages/ai/src/lib/dataStructure/helpers/VisitedTracker.js.map +1 -0
  324. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +55 -1
  325. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
  326. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +14 -6
  327. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
  328. package/packages/ai/src/lib/dataStructure/helpers/selectBestValue.js +62 -0
  329. package/packages/ai/src/lib/dataStructure/helpers/selectBestValue.js.map +1 -0
  330. package/packages/ai/src/lib/dataStructure/helpers/uniqueIdUtils.js +90 -0
  331. package/packages/ai/src/lib/dataStructure/helpers/uniqueIdUtils.js.map +1 -0
  332. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +22 -0
  333. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +1 -1
  334. package/packages/ai/src/lib/generateChangesEntityDocumentation.js +19 -1
  335. package/packages/ai/src/lib/generateChangesEntityDocumentation.js.map +1 -1
  336. package/packages/ai/src/lib/generateChangesEntityScenarioData.js +55 -156
  337. package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
  338. package/packages/ai/src/lib/generateChangesEntityScenarios.js +79 -262
  339. package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
  340. package/packages/ai/src/lib/generateEntityDocumentation.js +15 -1
  341. package/packages/ai/src/lib/generateEntityDocumentation.js.map +1 -1
  342. package/packages/ai/src/lib/generateEntityKeyAttributes.js +32 -8
  343. package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +1 -1
  344. package/packages/ai/src/lib/generateEntityScenarioData.js +52 -152
  345. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  346. package/packages/ai/src/lib/generateEntityScenarios.js +88 -258
  347. package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
  348. package/packages/ai/src/lib/generateStatementAnalysis.js +46 -71
  349. package/packages/ai/src/lib/generateStatementAnalysis.js.map +1 -1
  350. package/packages/ai/src/lib/getConditionalUsagesFromCode.js +13 -8
  351. package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
  352. package/packages/ai/src/lib/getLLMCallStats.js +0 -14
  353. package/packages/ai/src/lib/getLLMCallStats.js.map +1 -1
  354. package/packages/ai/src/lib/modelInfo.js +15 -0
  355. package/packages/ai/src/lib/modelInfo.js.map +1 -1
  356. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +36 -3
  357. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
  358. package/packages/ai/src/lib/promptGenerators/generateChangesEntityDocumentationGenerator.js +8 -33
  359. package/packages/ai/src/lib/promptGenerators/generateChangesEntityDocumentationGenerator.js.map +1 -1
  360. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +35 -41
  361. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
  362. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +59 -72
  363. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
  364. package/packages/ai/src/lib/promptGenerators/generateEntityDocumentationGenerator.js +8 -27
  365. package/packages/ai/src/lib/promptGenerators/generateEntityDocumentationGenerator.js.map +1 -1
  366. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +24 -27
  367. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
  368. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +21 -22
  369. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
  370. package/packages/ai/src/lib/types/index.js +2 -0
  371. package/packages/ai/src/lib/types/index.js.map +1 -1
  372. package/packages/ai/src/lib/worker/SerializableDataStructure.js +7 -0
  373. package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
  374. package/packages/analyze/src/lib/FileAnalyzer.js +39 -7
  375. package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
  376. package/packages/analyze/src/lib/asts/nodes/getNodeType.js +1 -1
  377. package/packages/analyze/src/lib/asts/nodes/getNodeType.js.map +1 -1
  378. package/packages/analyze/src/lib/asts/nodes/index.js +2 -1
  379. package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
  380. package/packages/analyze/src/lib/asts/sourceFiles/getAllExportedNodes.js +3 -2
  381. package/packages/analyze/src/lib/asts/sourceFiles/getAllExportedNodes.js.map +1 -1
  382. package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +4 -3
  383. package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
  384. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +6 -8
  385. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  386. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +5 -1
  387. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  388. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +8 -2
  389. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
  390. package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js +5 -8
  391. package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js.map +1 -1
  392. package/packages/analyze/src/lib/files/analyzeChange.js +21 -9
  393. package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
  394. package/packages/analyze/src/lib/files/analyzeEntity.js +10 -4
  395. package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
  396. package/packages/analyze/src/lib/files/analyzeInitial.js +21 -9
  397. package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
  398. package/packages/analyze/src/lib/files/analyzeRemixRoute.js +18 -23
  399. package/packages/analyze/src/lib/files/analyzeRemixRoute.js.map +1 -1
  400. package/packages/analyze/src/lib/files/getImportedExports.js +56 -4
  401. package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
  402. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +24 -0
  403. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
  404. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +6 -1
  405. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  406. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +9 -1
  407. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +1 -1
  408. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +5 -1
  409. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
  410. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +9 -1
  411. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
  412. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +16 -7
  413. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  414. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +8 -2
  415. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
  416. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +28 -21
  417. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  418. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageRemix.js +18 -11
  419. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageRemix.js.map +1 -1
  420. package/packages/generate/src/lib/scenarioComponent.js +5 -3
  421. package/packages/generate/src/lib/scenarioComponent.js.map +1 -1
  422. package/packages/supabase/src/lib/kysely/db.js +3 -0
  423. package/packages/supabase/src/lib/kysely/db.js.map +1 -1
  424. package/packages/supabase/src/lib/kysely/tables/debugReportsTable.js +27 -0
  425. package/packages/supabase/src/lib/kysely/tables/debugReportsTable.js.map +1 -0
  426. package/packages/supabase/src/lib/scenarioToDb.js +1 -1
  427. package/packages/supabase/src/lib/scenarioToDb.js.map +1 -1
  428. package/packages/utils/index.js +2 -0
  429. package/packages/utils/index.js.map +1 -1
  430. package/packages/utils/src/lib/Semaphore.js +40 -0
  431. package/packages/utils/src/lib/Semaphore.js.map +1 -0
  432. package/packages/utils/src/lib/applyUniversalMocks.js +39 -5
  433. package/packages/utils/src/lib/applyUniversalMocks.js.map +1 -1
  434. package/packages/utils/src/lib/frameworks/getNextRoutePath.js +2 -1
  435. package/packages/utils/src/lib/frameworks/getNextRoutePath.js.map +1 -1
  436. package/packages/utils/src/lib/frameworks/getRemixRoutePath.js +2 -1
  437. package/packages/utils/src/lib/frameworks/getRemixRoutePath.js.map +1 -1
  438. package/packages/utils/src/lib/frameworks/nextRouteFileNameToRoute.js +2 -1
  439. package/packages/utils/src/lib/frameworks/nextRouteFileNameToRoute.js.map +1 -1
  440. package/packages/utils/src/lib/frameworks/remixRouteFileNameToRoute.js +1 -0
  441. package/packages/utils/src/lib/frameworks/remixRouteFileNameToRoute.js.map +1 -1
  442. package/packages/utils/src/lib/frameworks/sanitizeNextRouteSegments.js +32 -0
  443. package/packages/utils/src/lib/frameworks/sanitizeNextRouteSegments.js.map +1 -0
  444. package/packages/utils/src/lib/lightweightEntityExtractor.js +17 -0
  445. package/packages/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  446. package/analyzer-template/packages/ai/src/lib/generateEntityDataMap.ts +0 -375
  447. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-rqv54FUY.js +0 -1
  448. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-B0oiPem-.js +0 -26
  449. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-DqXXjAJ7.js +0 -3
  450. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-DU_jxCPD.js +0 -1
  451. package/codeyam-cli/src/webserver/build/client/assets/ScenarioPreview-5DY-YIxu.js +0 -6
  452. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-DmjXUj6m.js +0 -5
  453. package/codeyam-cli/src/webserver/build/client/assets/_index-DvSrcxsk.js +0 -1
  454. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-CsaMd9mb.js +0 -10
  455. package/codeyam-cli/src/webserver/build/client/assets/chart-column-VXBS6qOn.js +0 -1
  456. package/codeyam-cli/src/webserver/build/client/assets/circle-alert-n5GUC2AS.js +0 -1
  457. package/codeyam-cli/src/webserver/build/client/assets/clock-DKqtX8js.js +0 -1
  458. package/codeyam-cli/src/webserver/build/client/assets/components-Dj-Ggnl2.js +0 -40
  459. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-BbR3FwNc.js +0 -1
  460. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-L7M9Vr5z.js +0 -1
  461. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-C9w-q7P3.js +0 -5
  462. package/codeyam-cli/src/webserver/build/client/assets/entry.client-CdGoUs8A.js +0 -1
  463. package/codeyam-cli/src/webserver/build/client/assets/file-text-B6Er7j5k.js +0 -1
  464. package/codeyam-cli/src/webserver/build/client/assets/files-KcDVw1FY.js +0 -1
  465. package/codeyam-cli/src/webserver/build/client/assets/git-B9uZ8eSJ.js +0 -12
  466. package/codeyam-cli/src/webserver/build/client/assets/globals-B0f88RTV.css +0 -1
  467. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-v3c6DFp4.js +0 -1
  468. package/codeyam-cli/src/webserver/build/client/assets/manifest-fca08d7e.js +0 -1
  469. package/codeyam-cli/src/webserver/build/client/assets/root-Cf8VBqIb.js +0 -16
  470. package/codeyam-cli/src/webserver/build/client/assets/search-DA14wXpu.js +0 -1
  471. package/codeyam-cli/src/webserver/build/client/assets/settings-COJUrwGu.js +0 -1
  472. package/codeyam-cli/src/webserver/build/client/assets/settings-NU_ZquhK.js +0 -1
  473. package/codeyam-cli/src/webserver/build/client/assets/simulations-CNaMJ-nR.js +0 -1
  474. package/codeyam-cli/src/webserver/build/client/assets/useToast-BRShB17p.js +0 -1
  475. package/codeyam-cli/src/webserver/build/client/assets/zap-BvukH0eN.js +0 -1
  476. package/codeyam-cli/src/webserver/build/client/cy-logo-cli.svg +0 -13
  477. package/codeyam-cli/src/webserver/build/client/favicon.svg +0 -13
  478. package/codeyam-cli/src/webserver/build/server/assets/index-DHr4rT4u.js +0 -1
  479. package/codeyam-cli/src/webserver/build/server/assets/server-build-Bi1mj14J.js +0 -166
  480. package/codeyam-cli/src/webserver/public/cy-logo-cli.svg +0 -13
  481. package/codeyam-cli/src/webserver/public/favicon.svg +0 -13
  482. package/packages/ai/src/lib/generateEntityDataMap.js +0 -335
  483. package/packages/ai/src/lib/generateEntityDataMap.js.map +0 -1
  484. package/packages/ai/src/lib/promptGenerators/generateEntityDataMapGenerator.js +0 -17
  485. package/packages/ai/src/lib/promptGenerators/generateEntityDataMapGenerator.js.map +0 -1
@@ -1,3 +1,4 @@
1
+ import { ProjectFramework, } from "../../../../../packages/types/index.js";
1
2
  import writeFile from "../common/writeFile.js";
2
3
  import { isFrameworkRoute, getFrameworkRoutePath, safeFileName, PROJECT_RELATIVE_PATH, } from "../../../../../packages/utils/index.js";
3
4
  import { getRelativePath, safeFolder } from "../../../../../packages/generate/index.js";
@@ -6,11 +7,18 @@ import { splitOutsideParenthesesAndArrays } from "../../../../../packages/ai/ind
6
7
  import { loadEntities } from "../../../../../packages/supabase/index.js";
7
8
  import * as fs from 'fs';
8
9
  import * as path from 'path';
10
+ /**
11
+ * Escape special regex characters in a string so it can be used as a literal pattern.
12
+ * This prevents characters like . * + ? ^ $ { } ( ) | [ ] \ from being interpreted as regex metacharacters.
13
+ */
14
+ function escapeRegExp(str) {
15
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
16
+ }
9
17
  function hasMockStructure(importedExport, fileAnalyses) {
10
18
  if (!fileAnalyses?.some((a) => a.entity.metadata?.isolatedDataStructure?.dependencySchemas)) {
11
19
  return false;
12
20
  }
13
- return !!constructMockCode(importedExport.name, fileAnalyses.find((a) => !!a.metadata?.mergedDataStructure?.dependencySchemas?.[importedExport.filePath]?.[importedExport.name])?.metadata?.mergedDataStructure?.dependencySchemas);
21
+ return !!constructMockCode(importedExport.name, fileAnalyses.find((a) => !!a.metadata?.mergedDataStructure?.dependencySchemas?.[importedExport.filePath]?.[importedExport.name])?.metadata?.mergedDataStructure?.dependencySchemas, importedExport.entityType);
14
22
  }
15
23
  function isIndexPath(filePath) {
16
24
  if (!filePath)
@@ -19,27 +27,81 @@ function isIndexPath(filePath) {
19
27
  return fileName.startsWith('index.');
20
28
  }
21
29
  /**
22
- * Rewrite asset imports (CSS, images, fonts, etc.) to correct relative paths.
23
- * These imports aren't tracked as importedExports, so we need to handle them separately.
30
+ * Convert .d.ts type declaration content to stub implementations.
31
+ * .d.ts files only have type declarations which don't provide runtime exports.
32
+ * This function converts them to actual stub implementations.
24
33
  *
25
- * Handles patterns like:
34
+ * @param content - The .d.ts file content
35
+ * @param entityName - The name of the entity we're generating for (used to ensure it's exported)
36
+ * @returns The converted content with stub implementations
37
+ */
38
+ function convertDtsToStubs(content, entityName) {
39
+ let result = content;
40
+ // Handle object types FIRST (before simple types) since they span multiple lines
41
+ // and contain semicolons that would incorrectly terminate the simple type regex
42
+ // Convert "export declare const NAME: { ... };" (object type) to "export const NAME = {} as any;"
43
+ result = result.replace(/export\s+declare\s+const\s+(\w+)\s*:\s*\{[^}]*\}\s*;/gs, 'export const $1 = {} as any;');
44
+ // Convert "export declare let NAME: { ... };" (object type) to "export let NAME = {} as any;"
45
+ result = result.replace(/export\s+declare\s+let\s+(\w+)\s*:\s*\{[^}]*\}\s*;/gs, 'export let $1 = {} as any;');
46
+ // Convert "export declare var NAME: { ... };" (object type) to "export var NAME = {} as any;"
47
+ result = result.replace(/export\s+declare\s+var\s+(\w+)\s*:\s*\{[^}]*\}\s*;/gs, 'export var $1 = {} as any;');
48
+ // Now handle simple types (non-object types)
49
+ // Convert "export declare const NAME: TYPE;" to "export const NAME = {} as any;"
50
+ result = result.replace(/export\s+declare\s+const\s+(\w+)\s*:\s*[^;]+;/g, 'export const $1 = {} as any;');
51
+ // Convert "export declare let NAME: TYPE;" to "export let NAME = {} as any;"
52
+ result = result.replace(/export\s+declare\s+let\s+(\w+)\s*:\s*[^;]+;/g, 'export let $1 = {} as any;');
53
+ // Convert "export declare var NAME: TYPE;" to "export var NAME = {} as any;"
54
+ result = result.replace(/export\s+declare\s+var\s+(\w+)\s*:\s*[^;]+;/g, 'export var $1 = {} as any;');
55
+ // Convert "export declare function NAME(...): TYPE;" to "export function NAME() { return {} as any; }"
56
+ result = result.replace(/export\s+declare\s+function\s+(\w+)\s*\([^)]*\)\s*:\s*[^;]+;/g, 'export function $1(...args: any[]) { return {} as any; }');
57
+ // Convert "export declare class NAME { ... }" to "export class NAME {}"
58
+ // This is tricky because class bodies can span multiple lines
59
+ result = result.replace(/export\s+declare\s+class\s+(\w+)\s*(?:extends\s+[^{]+)?\{[^}]*\}/gs, 'export class $1 {}');
60
+ // Convert "declare const NAME: { ... }" (object type, non-exported) to "const NAME = {} as any;"
61
+ // Object types can span multiple lines and contain semicolons, so we handle them separately
62
+ // The 's' flag makes . match newlines, so this matches the entire object type block
63
+ result = result.replace(/^declare\s+const\s+(\w+)\s*:\s*\{[^}]*\}\s*;/gms, 'const $1 = {} as any;');
64
+ // Convert "declare const NAME: TYPE;" (simple type, non-exported) to "const NAME = {} as any;"
65
+ // These are often used with "export { NAME }" at the end
66
+ // This must come AFTER the object type handler above
67
+ result = result.replace(/^declare\s+const\s+(\w+)\s*:\s*[^;]+;/gm, 'const $1 = {} as any;');
68
+ // Convert "declare function NAME" (non-exported) to "function NAME() { return {} as any; }"
69
+ result = result.replace(/^declare\s+function\s+(\w+)\s*\([^)]*\)\s*:\s*[^;]+;/gm, 'function $1(...args: any[]) { return {} as any; }');
70
+ // Convert "declare class NAME" (non-exported) to "class NAME {}"
71
+ result = result.replace(/^declare\s+class\s+(\w+)\s*(?:extends\s+[^{]+)?\{[^}]*\}/gm, 'class $1 {}');
72
+ // Remove "export { }" at the end (empty export statement that marks module as having no exports)
73
+ result = result.replace(/export\s*\{\s*\}\s*;?\s*$/g, '');
74
+ // Keep export type and export interface statements as-is (they're valid in .ts)
75
+ // No transformation needed for these
76
+ console.log(`CodeYam: Converted .d.ts content for entity "${entityName}". Result length: ${result.length}`);
77
+ return result;
78
+ }
79
+ /**
80
+ * Rewrite relative asset paths to correct locations when a file is moved.
81
+ *
82
+ * This function generically handles ANY string literal containing a relative path
83
+ * to an asset file, not just import statements. This catches patterns like:
26
84
  * - import "./globals.css"
27
85
  * - import styles from "./file.module.css.js"
28
- * - import logo from "./logo.png.js"
86
+ * - localFont({ src: "../fonts/font.woff2" })
87
+ * - Image src="../images/logo.png"
88
+ * - Any other string literal with a relative asset path
29
89
  */
30
90
  function rewriteAssetImports(fileContent, originalFilePath, newFilePath) {
31
- // Match imports with non-JS/TS extensions
91
+ // Asset file extensions that should have their paths rewritten
32
92
  const assetExtensions = 'css|scss|sass|less|styl|png|jpg|jpeg|gif|svg|webp|ico|woff|woff2|ttf|eot|otf|mp4|webm|json';
33
- const assetImportRegex = new RegExp(`import\\s+(?:[\\w$]+\\s+from\\s+)?(['"])(\\.{1,2}/[^'"]+\\.(?:${assetExtensions}))\\1`, 'g');
93
+ // Match ANY string literal containing a relative path to an asset file
94
+ // This captures both single and double quoted strings that start with ./ or ../
95
+ const relativeAssetPathRegex = new RegExp(`(['"])(\\.{1,2}/[^'"]*\\.(?:${assetExtensions}))\\1`, 'g');
34
96
  // Get the directory part of the original file path (relative to project root)
35
97
  const originalDirParts = originalFilePath.split('/').slice(0, -1);
36
- return fileContent.replace(assetImportRegex, (match, quote, importPath) => {
98
+ return fileContent.replace(relativeAssetPathRegex, (match, quote, assetPath) => {
37
99
  // Resolve the asset path relative to the original file's directory
38
100
  // We need to manually resolve the relative path without using path.resolve
39
101
  // which would resolve against the actual filesystem
40
- const importParts = importPath.split('/');
102
+ const pathParts = assetPath.split('/');
41
103
  const resolvedParts = [...originalDirParts];
42
- for (const part of importParts) {
104
+ for (const part of pathParts) {
43
105
  if (part === '..') {
44
106
  resolvedParts.pop();
45
107
  }
@@ -51,10 +113,141 @@ function rewriteAssetImports(fileContent, originalFilePath, newFilePath) {
51
113
  const absoluteAssetPath = resolvedParts.join('/');
52
114
  // Calculate the new relative path from new file location
53
115
  const newRelativePath = getRelativePath(newFilePath, absoluteAssetPath);
54
- // Reconstruct the import statement
55
- return match.replace(importPath, newRelativePath);
116
+ // Replace the path in the original match, preserving the quote style
117
+ return `${quote}${newRelativePath}${quote}`;
118
+ });
119
+ }
120
+ /**
121
+ * Rewrite relative TypeScript/JavaScript module imports when a file is moved.
122
+ *
123
+ * When a file is moved from one location to another (e.g., from [environmentId]/
124
+ * to _environmentId_/), relative imports like "./lib/organization" need to be
125
+ * rewritten to point to the correct location from the new path.
126
+ *
127
+ * This is similar to rewriteAssetImports but handles TypeScript/JavaScript modules
128
+ * instead of asset files (CSS, images, etc.).
129
+ */
130
+ function rewriteRelativeModuleImports(fileContent, originalFilePath, newFilePath) {
131
+ // Module file extensions that should have their relative paths rewritten
132
+ const moduleExtensions = 'ts|tsx|js|jsx|mjs|cjs';
133
+ // Match import statements with relative paths (starting with ./ or ../)
134
+ // This matches:
135
+ // - import { foo } from "./path.js"
136
+ // - import foo from "../path.js"
137
+ // - import * as foo from "./path/index.js"
138
+ // - import "./path" (side-effect imports)
139
+ // The path may or may not have a file extension
140
+ const relativeImportRegex = new RegExp(`(from\\s+)(['"])(\\.\\.?\\/[^'"]+?)(?:\\.(?:${moduleExtensions}))?\\2`, 'g');
141
+ // Get the directory part of the original file path (relative to project root)
142
+ const originalDirParts = originalFilePath.split('/').slice(0, -1);
143
+ return fileContent.replace(relativeImportRegex, (match, fromKeyword, quote, importPath) => {
144
+ // Skip imports that already point to generated CodeYam files:
145
+ // 1. Scenario component files with SHA hashes (64 hex chars) and scenario name suffixes
146
+ // e.g., "abc123def_EnvironmentLayout_Empty_Survey_No_Responses"
147
+ // 2. Mock data files in __codeyamMocks__ directory
148
+ // e.g., "../__codeyamMocks__/MockData_Empty_Survey_No_Responses"
149
+ const scenarioFilePattern = /[a-f0-9]{64}_\w+_[A-Z][a-zA-Z_]+$/;
150
+ const mockDataPattern = /__codeyamMocks__\//;
151
+ if (scenarioFilePattern.test(importPath) ||
152
+ mockDataPattern.test(importPath)) {
153
+ // This import already points to a generated file, don't rewrite it
154
+ return match;
155
+ }
156
+ // Resolve the import path relative to the original file's directory
157
+ const pathParts = importPath.split('/');
158
+ const resolvedParts = [...originalDirParts];
159
+ for (const part of pathParts) {
160
+ if (part === '..') {
161
+ resolvedParts.pop();
162
+ }
163
+ else if (part !== '.') {
164
+ resolvedParts.push(part);
165
+ }
166
+ }
167
+ // Build the project-relative path to the module
168
+ const absoluteModulePath = resolvedParts.join('/');
169
+ // Calculate the new relative path from new file location
170
+ const newRelativePath = getRelativePath(newFilePath, absoluteModulePath);
171
+ // Replace the path in the original match, preserving the quote style
172
+ return `${fromKeyword}${quote}${newRelativePath}${quote}`;
56
173
  });
57
174
  }
175
+ /**
176
+ * Strip <html> and <body> tags from root layout files for Next.js App Router.
177
+ *
178
+ * When a root layout (app/layout.tsx) is generated as a scenario component and placed
179
+ * under the /static/ route, it becomes nested under the real app root layout. Having
180
+ * two layouts with <html> and <body> tags causes hydration errors:
181
+ *
182
+ * "In HTML, <html> cannot be a child of <body>"
183
+ * "You are mounting a new html component when a previous one has not first unmounted"
184
+ *
185
+ * This function removes the <html> and <body> wrapper tags while preserving the inner
186
+ * content, allowing the scenario layout to work correctly when nested.
187
+ *
188
+ * Before: <html lang="en"><body className={...}><main>{children}</main></body></html>
189
+ * After: <div className={...}><main>{children}</main></div>
190
+ */
191
+ function stripHtmlBodyTags(fileContent, filePath, framework) {
192
+ // Only apply to Next.js App Router root layouts
193
+ if (framework !== ProjectFramework.Next) {
194
+ return fileContent;
195
+ }
196
+ // Check if this is a root layout file (typically app/layout.tsx or apps/*/app/layout.tsx)
197
+ // Root layouts are at the app directory level, not in subdirectories like (app)/ or routes/
198
+ const pathParts = filePath.split('/');
199
+ const fileName = pathParts[pathParts.length - 1];
200
+ // Must be a layout file
201
+ if (!fileName?.startsWith('layout.')) {
202
+ return fileContent;
203
+ }
204
+ // Check if it's at the app root level (parent directory is 'app')
205
+ const parentDir = pathParts[pathParts.length - 2];
206
+ if (parentDir !== 'app') {
207
+ return fileContent;
208
+ }
209
+ // Check if this file actually contains <html> and <body> tags
210
+ if (!/<html[^>]*>/.test(fileContent) || !/<body[^>]*>/.test(fileContent)) {
211
+ return fileContent;
212
+ }
213
+ console.log(`CodeYam: Stripping <html> and <body> tags from root layout: ${filePath}`);
214
+ // Extract the body className/attributes if any, to preserve styling
215
+ const bodyMatch = fileContent.match(/<body([^>]*)>/);
216
+ const bodyAttributes = bodyMatch?.[1]?.trim() || '';
217
+ // Replace the JSX structure:
218
+ // <html ...><body ...>CONTENT</body></html>
219
+ // With: <div ...>CONTENT</div>
220
+ //
221
+ // This regex handles:
222
+ // 1. Opening <html> tag with any attributes
223
+ // 2. Opening <body> tag with any attributes (captured for the wrapper div)
224
+ // 3. Content between body tags (captured)
225
+ // 4. Closing </body> and </html> tags
226
+ const htmlBodyRegex = /(<html[^>]*>\s*<body)([^>]*)(>)([\s\S]*?)(<\/body>\s*<\/html>)/g;
227
+ let result = fileContent.replace(htmlBodyRegex, (match, _htmlBody, bodyAttrs, closeBracket, content, _closing) => {
228
+ // Create a wrapper div with the body's attributes
229
+ const attrs = bodyAttrs?.trim() || '';
230
+ if (attrs) {
231
+ return `(<div${bodyAttrs}${closeBracket}${content}</div>)`;
232
+ }
233
+ else {
234
+ return `(<>${content}</>)`;
235
+ }
236
+ });
237
+ // If the regex didn't match (perhaps due to different formatting),
238
+ // try a more lenient approach - just remove the tags
239
+ if (result === fileContent) {
240
+ // Remove <html ...> opening tag
241
+ result = result.replace(/<html[^>]*>\s*/g, '');
242
+ // Remove </html> closing tag
243
+ result = result.replace(/\s*<\/html>/g, '');
244
+ // Replace <body ...> with <div ...> to preserve attributes
245
+ result = result.replace(/<body([^>]*)>/g, '<div$1>');
246
+ // Replace </body> with </div>
247
+ result = result.replace(/<\/body>/g, '</div>');
248
+ }
249
+ return result;
250
+ }
58
251
  function addMockToContent(fileContent, importedExport, fileAnalyses, rootAnalysis, relativeMocksDir, scenarioName, importPath) {
59
252
  // First try to find dependency schemas in fileAnalyses (for same-file dependencies)
60
253
  let dependencySchemas = fileAnalyses.find((a) => !!a.metadata?.mergedDataStructure?.dependencySchemas?.[importedExport.filePath]?.[importedExport.name])?.metadata?.mergedDataStructure?.dependencySchemas;
@@ -64,7 +257,7 @@ function addMockToContent(fileContent, importedExport, fileAnalyses, rootAnalysi
64
257
  dependencySchemas =
65
258
  rootAnalysis.metadata?.mergedDataStructure?.dependencySchemas;
66
259
  }
67
- const mockCode = constructMockCode(importedExport.name, dependencySchemas);
260
+ const mockCode = constructMockCode(importedExport.name, dependencySchemas, importedExport.entityType);
68
261
  if (!mockCode) {
69
262
  console.log('CodeYam Error: Mock code not found', JSON.stringify({
70
263
  importedExportFilePath: importedExport.filePath,
@@ -89,7 +282,9 @@ function addMockToContent(fileContent, importedExport, fileAnalyses, rootAnalysi
89
282
  fileContent = fileContent.replace(entireImportRegExp, '');
90
283
  }
91
284
  else {
92
- const importRegExp = new RegExp(`(import(?:(?!${firstPart}|from|import)[\\s\\S])*?)${firstPart}(?:,\\s*)?((?:(?!import)[\\s\\S])*?from\\s+['"]${importPath}['"])`, 'm');
285
+ // Escape regex special characters in importPath (e.g., brackets in [environmentId])
286
+ const escapedImportPath = importPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
287
+ const importRegExp = new RegExp(`(import(?:(?!${firstPart}|from|import)[\\s\\S])*?)${firstPart}(?:,\\s*)?((?:(?!import)[\\s\\S])*?from\\s+['"]${escapedImportPath}['"])`, 'm');
93
288
  if (importedExportNameParts.length > 1) {
94
289
  fileContent = fileContent.replace(importRegExp, `$1${firstPart}__cyOriginal$2`);
95
290
  }
@@ -101,6 +296,26 @@ function addMockToContent(fileContent, importedExport, fileAnalyses, rootAnalysi
101
296
  fileContent = fileContent.replace(/import\s*\{\s*\}\s*from\s+['"][^'"]*['"];?\s*\n?/g, '');
102
297
  }
103
298
  }
299
+ else {
300
+ // Fallback: When importPath is undefined (e.g., path alias not in mapping),
301
+ // we still need to remove the import to avoid "name defined multiple times" errors.
302
+ // Search for the entity name in any import statement and remove it.
303
+ const importedExportNameParts = splitOutsideParenthesesAndArrays(importedExport.name);
304
+ const firstPart = importedExportNameParts[0];
305
+ // Match the entity name in any named import and remove just that name
306
+ // This handles imports like: import { useEnvironment, otherThing } from "any/path"
307
+ // Removes useEnvironment but keeps otherThing
308
+ const namedImportRegExp = new RegExp(`(import\\s*\\{[^}]*?)\\b${escapeRegExp(firstPart)}\\b(?:,\\s*|\\s*,)?((?:[^}]*\\}\\s*from\\s*['"][^'"]*['"];?))`, 'm');
309
+ if (importedExportNameParts.length > 1) {
310
+ // Rename the import instead of removing (for destructured access patterns)
311
+ fileContent = fileContent.replace(namedImportRegExp, `$1${firstPart}__cyOriginal$2`);
312
+ }
313
+ else {
314
+ fileContent = fileContent.replace(namedImportRegExp, '$1$2');
315
+ }
316
+ // Clean up empty imports that might result from removing the only import
317
+ fileContent = fileContent.replace(/import\s*\{\s*\}\s*from\s+['"][^'"]*['"];?\s*\n?/g, '');
318
+ }
104
319
  if (fileContent.indexOf('import { scenarios } from') === -1) {
105
320
  // Use scenario-specific MockData file to allow multiple scenarios to coexist
106
321
  const mockDataPath = `${relativeMocksDir}/MockData_${safeFileName(scenarioName)}`;
@@ -250,7 +465,7 @@ function captureArgumentsForTesting(args) {
250
465
  console.error('CodeYam Debug: Failed to capture arguments:', error);
251
466
  }
252
467
  }
253
- export default async function writeScenarioComponents({ project, file, entity, rootAnalysis, scenario, context, projectAnalyzer, framework, mocksDir, rootFile, namespaceMocks, writtenScenarioComponents = {}, fileStore, }) {
468
+ export default async function writeScenarioComponents({ project, file, entity, rootAnalysis, scenario, context, projectAnalyzer, framework, mocksDir, rootFile, namespaceMocks, writtenScenarioComponents = {}, fileStore, exportAsNamed, }) {
254
469
  var _a;
255
470
  // Capture arguments for testing if debug mode is enabled
256
471
  captureArgumentsForTesting({
@@ -320,6 +535,22 @@ export default async function writeScenarioComponents({ project, file, entity, r
320
535
  const nodeModuleImports = allImportedExports.filter((nodeModuleImport, index, self) => nodeModuleImport.isNodeModule &&
321
536
  index === self.findIndex((nmi) => nmi.name === nodeModuleImport.name));
322
537
  let fileContent = file.content;
538
+ // Handle .d.ts files: convert type declarations to stub implementations
539
+ // .d.ts files only have type declarations (e.g., "export declare const logger")
540
+ // which don't provide runtime exports. We need to generate actual stub implementations.
541
+ if (file.path.endsWith('.d.ts')) {
542
+ console.log(`CodeYam: Converting .d.ts file to stub implementations: ${file.path}`);
543
+ fileContent = convertDtsToStubs(fileContent, entity.name);
544
+ }
545
+ // Extract "use client" or "use server" directive FIRST, before any modifications
546
+ // This ensures the directive isn't buried by prepended imports
547
+ const directiveMatch = fileContent.match(/^(\s*["']use (client|server)["'];?\s*\n?)/);
548
+ let extractedDirective = null;
549
+ if (directiveMatch) {
550
+ extractedDirective = directiveMatch[1].trim();
551
+ // Remove the directive from fileContent - we'll add it back at the very end
552
+ fileContent = fileContent.slice(directiveMatch[0].length);
553
+ }
323
554
  const fileAnalyzer = projectAnalyzer.getFileAnalyzer(file);
324
555
  const importMapping = fileAnalyzer.getRelativeImportMappings();
325
556
  let filePath = file.path;
@@ -392,9 +623,11 @@ export default async function writeScenarioComponents({ project, file, entity, r
392
623
  }
393
624
  importedExportEntity.localFilePath = importedExport.filePath;
394
625
  if (!importedExport.isMocked) {
395
- const importedExportFilePath = importedExportEntity.localFilePath === file.path
396
- ? (importedExport.resolvedFilePath ?? importedExport.filePath)
397
- : importedExport.filePath;
626
+ // Use resolvedFilePath (actual entity location) for scenario component writing.
627
+ // This is critical for re-exports: when importing from index.tsx which re-exports
628
+ // from a nested file, we need to write scenario components for the actual file
629
+ // where the entity code lives, not the re-export file.
630
+ const importedExportFilePath = importedExport.resolvedFilePath ?? importedExport.filePath;
398
631
  if (importedExportFilePath !== file.path) {
399
632
  if (!writtenScenarioComponents[importedExportFilePath]?.includes(importedExport.name)) {
400
633
  // Skip recursion for type/data entities - they don't need scenario components
@@ -407,12 +640,32 @@ export default async function writeScenarioComponents({ project, file, entity, r
407
640
  let fileNotMocked = fileStore
408
641
  ? fileStore.getByPath(importedExportFilePath)
409
642
  : project.files.find((f) => f.path === importedExportFilePath);
643
+ // Fallback: if file at resolvedFilePath doesn't exist, try filePath
644
+ // This handles cases where the actual entity file isn't in project.files
645
+ // (e.g., type re-exports where only the index file is tracked)
646
+ if (!fileNotMocked &&
647
+ importedExport.resolvedFilePath &&
648
+ importedExport.filePath !== importedExport.resolvedFilePath) {
649
+ const fallbackPath = importedExport.filePath;
650
+ fileNotMocked = fileStore
651
+ ? fileStore.getByPath(fallbackPath)
652
+ : project.files.find((f) => f.path === fallbackPath);
653
+ }
654
+ // Skip if file still not found - can't write scenario component without the file
655
+ if (!fileNotMocked) {
656
+ continue;
657
+ }
410
658
  // Ensure content is loaded for the file
411
659
  if (fileNotMocked &&
412
660
  fileStore &&
413
- !fileStore.isContentLoaded(importedExportFilePath)) {
414
- fileNotMocked = await fileStore.ensureContent(importedExportFilePath);
661
+ !fileStore.isContentLoaded(fileNotMocked.path)) {
662
+ fileNotMocked = await fileStore.ensureContent(fileNotMocked.path);
415
663
  }
664
+ // When a default export is imported as named (via index re-export), we need
665
+ // to add a named re-export to the scenario component so the import works.
666
+ // e.g., if file has `export default X` but parent does `import { X } from '...'`
667
+ const needsNamedReExport = importedExport.resolvedIsDefault === true &&
668
+ importedExport.isDefault === false;
416
669
  const { scenarioComponentPaths: newScenarioComponentPaths, writtenScenarioComponents: updatedWrittenScenarioComponents, } = await writeScenarioComponents({
417
670
  project,
418
671
  file: fileNotMocked,
@@ -427,6 +680,8 @@ export default async function writeScenarioComponents({ project, file, entity, r
427
680
  namespaceMocks,
428
681
  writtenScenarioComponents,
429
682
  fileStore,
683
+ // Pass the import name so we can add `export { default as Name };`
684
+ exportAsNamed: needsNamedReExport ? importedExport.name : undefined,
430
685
  });
431
686
  writtenScenarioComponents = updatedWrittenScenarioComponents;
432
687
  scenarioComponentPaths.push(...newScenarioComponentPaths);
@@ -436,29 +691,76 @@ export default async function writeScenarioComponents({ project, file, entity, r
436
691
  else if (importedExport.filePath === file.path &&
437
692
  importedExport.name !== entity.name) {
438
693
  // For same-file dependencies:
439
- // - Strip if isMocked is true (e.g., Remix/Next loaders, server-side code)
440
- // - Strip if we have a mock structure we can generate
441
- // - Only add mock code if we have a mock structure
442
- const shouldStrip = importedExport.isMocked ||
443
- hasMockStructure(importedExport, fileAnalyses);
444
- if (shouldStrip) {
694
+ // - Strip and replace if we have a mock structure we can generate
695
+ // - Strip and stub if isMocked is true AND it's a callable entity (visual, library, functionCall)
696
+ // - Preserve as-is for data entities (like Zod schemas) that need their methods
697
+ const hasMock = hasMockStructure(importedExport, fileAnalyses);
698
+ const entityType = importedExport.entityType;
699
+ // Data and type entities should be preserved - they're not callable and may have methods
700
+ // that stubbing would break (e.g., Zod schemas with .superRefine())
701
+ const isDataEntity = entityType === 'data' || entityType === 'type';
702
+ // Heuristic: Zod schemas are often misclassified as 'library' but should be preserved
703
+ // Detect by: name starts with Z + uppercase letter, AND has Zod method calls
704
+ const looksLikeZodSchema = entityType === 'library' &&
705
+ /^Z[A-Z]/.test(importedExport.name) &&
706
+ importedExport.calls?.some((call) => /\.(superRefine|refine|transform|default|optional|nullable|array|object|string|number|boolean|parse|safeParse)\s*\(/.test(call));
707
+ if (looksLikeZodSchema) {
708
+ console.log(`CodeYam: Detected Zod schema "${importedExport.name}" (misclassified as library) - will preserve`);
709
+ }
710
+ // Callable entities can be safely stubbed (but not Zod schemas)
711
+ const isCallable = !isDataEntity && !looksLikeZodSchema && entityType !== undefined;
712
+ // Determine what action to take
713
+ const shouldStripAndReplace = hasMock;
714
+ const shouldStripAndStub = !hasMock && importedExport.isMocked && isCallable;
715
+ const shouldPreserve = !hasMock && importedExport.isMocked && !isCallable;
716
+ // Log warning if entityType is undefined for a mocked same-file dependency
717
+ // This could indicate an analysis issue where entityType wasn't properly set
718
+ if (importedExport.isMocked && entityType === undefined) {
719
+ console.warn(`CodeYam: WARNING - Same-file dependency "${importedExport.name}" is isMocked but has no entityType. ` +
720
+ `Treating as non-callable (will preserve). File: ${file.path}`);
721
+ }
722
+ if (shouldPreserve) {
723
+ // For data entities (like Zod schemas), don't strip or stub - preserve the original
724
+ // This ensures schema methods like .superRefine() continue to work
725
+ console.log(`CodeYam: Preserving ${importedExport.name} (entityType: ${entityType}) - not stripping data entities`);
726
+ // Don't modify fileContent - keep the original code
727
+ }
728
+ else if (shouldStripAndReplace || shouldStripAndStub) {
729
+ // Strip the original code
445
730
  const entityCode = fileAnalyzer.getEntityCode(importedExport.name);
446
731
  if (entityCode) {
447
732
  fileContent = fileContent.replace(entityCode, '');
448
733
  }
449
- // Only add mock if we have a mock structure to generate
450
- if (hasMockStructure(importedExport, fileAnalyses)) {
734
+ if (shouldStripAndReplace) {
735
+ // Add mock from mock structure
451
736
  fileContent = addMockToContent(fileContent, importedExport, fileAnalyses, rootAnalysis, relativeMocksDir, scenario.name);
452
737
  }
738
+ else if (shouldStripAndStub) {
739
+ // Generate a simple stub mock that returns scenario data.
740
+ // This prevents ReferenceError at runtime when the stripped
741
+ // function is called (e.g., local helper functions like getInitialProps).
742
+ const functionName = importedExport.name;
743
+ console.log(`CodeYam: Generating stub mock for ${functionName} (entityType: ${entityType}) in ${file.path}`);
744
+ // Add scenarios import if not present
745
+ if (fileContent.indexOf('import { scenarios } from') === -1) {
746
+ const mockDataPath = `${relativeMocksDir}/MockData_${safeFileName(scenario.name)}`;
747
+ const importStatement = `import { scenarios } from "${mockDataPath}";`;
748
+ fileContent = `${fileContent}\n\n\n${importStatement}`;
749
+ }
750
+ // Generate a simple stub that returns the scenario data for this function
751
+ const stubMock = `\n\n// Stub mock for local function without mock structure\nfunction ${functionName}(...args) {\n return scenarios().data()?.["${functionName}()"];\n}`;
752
+ fileContent += stubMock;
753
+ }
453
754
  }
454
755
  }
455
756
  // Try to find the import mapping using different key formats
456
757
  // The import mapping may use either absolute or relative paths as keys
457
- // IMPORTANT: Use filePath (where it's imported FROM), not resolvedFilePath (where entity lives)
458
- // For re-exports like ~codeyam/types, filePath="packages/types/index.ts",
459
- // resolvedFilePath="packages/types/src/types/Commit.ts"
460
- // We need to generate files at the import location (index.ts), not the entity location
758
+ // Use filePath (import source) for looking up the import mapping
759
+ // because that's how imports are written in source code
461
760
  const mockFilePathRelative = importedExport.filePath;
761
+ // For scenario component paths, prefer resolvedFilePath (where entity actually lives)
762
+ // because that's where scenario component files are written
763
+ const scenarioFilePathRelative = importedExport.resolvedFilePath ?? importedExport.filePath;
462
764
  // Try looking up with different key formats (absolute, relative, resolved absolute)
463
765
  // Filter out undefined keys to avoid misleading undefined lookups
464
766
  const lookupKeys = [
@@ -501,10 +803,22 @@ export default async function writeScenarioComponents({ project, file, entity, r
501
803
  else {
502
804
  // For non-mocked imports, rewrite the import path to point to the generated scenario file
503
805
  // Use fileStore for O(1) lookup when available
504
- const fileNotMocked = fileStore
505
- ? fileStore.getByPath(mockFilePathRelative)
506
- : project.files.find((f) => f.path === mockFilePathRelative);
507
- const fileName = mockFilePathRelative.split('/').pop();
806
+ // First try resolvedFilePath (where entity lives), fallback to filePath (import source)
807
+ let fileNotMocked = fileStore
808
+ ? fileStore.getByPath(scenarioFilePathRelative)
809
+ : project.files.find((f) => f.path === scenarioFilePathRelative);
810
+ // Track which path we're actually using for the scenario component
811
+ let actualScenarioFilePathRelative = scenarioFilePathRelative;
812
+ if (!fileNotMocked &&
813
+ importedExport.resolvedFilePath &&
814
+ importedExport.filePath !== importedExport.resolvedFilePath) {
815
+ // Fallback to filePath if file at resolvedFilePath doesn't exist
816
+ actualScenarioFilePathRelative = importedExport.filePath;
817
+ fileNotMocked = fileStore
818
+ ? fileStore.getByPath(actualScenarioFilePathRelative)
819
+ : project.files.find((f) => f.path === actualScenarioFilePathRelative);
820
+ }
821
+ const fileName = actualScenarioFilePathRelative.split('/').pop();
508
822
  const fileNotMockedIsIndex = isIndexPath(fileNotMocked?.path);
509
823
  const mockFilePath = isFrameworkRoute(fileNotMocked, importedExportEntity, framework, fileNotMocked === rootFile)
510
824
  ? getFrameworkRoutePath({
@@ -512,7 +826,7 @@ export default async function writeScenarioComponents({ project, file, entity, r
512
826
  rootFile,
513
827
  entity: importedExportEntity,
514
828
  rootAnalysis,
515
- scenarioComponentPath: mockFilePathRelative,
829
+ scenarioComponentPath: actualScenarioFilePathRelative,
516
830
  project,
517
831
  framework,
518
832
  scenario,
@@ -520,13 +834,46 @@ export default async function writeScenarioComponents({ project, file, entity, r
520
834
  .split('.')
521
835
  .slice(0, -1)
522
836
  .join('.')
523
- : mockFilePathRelative.replace(`${fileName}`, `${importedExportEntity.sha}_${fileNotMockedIsIndex ? 'index_' : ''}${safeFileName(importedExportEntity.name)}_${safeFileName(scenario.name)}`);
837
+ : actualScenarioFilePathRelative.replace(`${fileName}`, `${importedExportEntity.sha}_${fileNotMockedIsIndex ? 'index_' : ''}${safeFileName(importedExportEntity.name)}_${safeFileName(scenario.name)}`);
524
838
  const path = safeFolder(getRelativePath(filePath, mockFilePath));
525
839
  // If we have an import mapping, use it to find the import string to replace
526
840
  // Otherwise, skip rewriting (we can't find the import statement without knowing what to search for)
527
841
  if (mockImportMapping) {
528
- const importRegExp = new RegExp(`${mockImportMapping.replace(/([$()])/g, '\\$1')}(['"])`, 'g');
529
- fileContent = fileContent.replace(importRegExp, `${path}$1`);
842
+ const importRegExp = new RegExp(`${escapeRegExp(mockImportMapping)}(['"])`, 'g');
843
+ // Check if the original import path still exists in the file
844
+ // If it was already rewritten by another entity from the same module,
845
+ // we need to add a separate import statement for this entity
846
+ if (fileContent.match(importRegExp)) {
847
+ fileContent = fileContent.replace(importRegExp, `${path}$1`);
848
+ }
849
+ else {
850
+ // The import path was already rewritten - add a new import for this entity
851
+ // This handles cases where multiple entities are imported from the same index file
852
+ // (e.g., import { A, B, C } from '@pkg') and each has its own scenario file
853
+ const entityImportName = importedExport.name;
854
+ const newImport = `import { ${entityImportName} } from '${path}';`;
855
+ // First, try to remove this entity from the already-rewritten grouped import
856
+ // This prevents duplicate/conflicting imports
857
+ // Match patterns like "EntityName," or ", EntityName" or "EntityName" (if only one)
858
+ // Note: entityImportName needs escaping since JS identifiers can contain $ (a regex metacharacter)
859
+ const escapedEntityName = escapeRegExp(entityImportName);
860
+ const removeFromGroupedImportPatterns = [
861
+ new RegExp(`\\b${escapedEntityName}\\s*,\\s*`, 'g'), // "EntityName, "
862
+ new RegExp(`\\s*,\\s*${escapedEntityName}\\b`, 'g'), // ", EntityName"
863
+ ];
864
+ for (const pattern of removeFromGroupedImportPatterns) {
865
+ fileContent = fileContent.replace(pattern, '');
866
+ }
867
+ // Add the new import at the beginning of fileContent
868
+ // Note: The header comment (// Scenario:) doesn't exist yet - it's prepended at writeFile time
869
+ // So prepending here puts the import right after the header in the final output
870
+ //
871
+ // IMPORTANT: We cannot use indexOf('// Scenario:') + '\n\n' here because:
872
+ // 1. The header doesn't exist during processing
873
+ // 2. indexOf would return -1, and indexOf('\n\n', -1) starts from 0
874
+ // 3. This could find a \n\n inside a function body, inserting the import there!
875
+ fileContent = newImport + '\n' + fileContent;
876
+ }
530
877
  }
531
878
  }
532
879
  }
@@ -535,6 +882,24 @@ export default async function writeScenarioComponents({ project, file, entity, r
535
882
  continue;
536
883
  fileContent = addMockToContent(fileContent, nodeModuleImport, fileAnalyses, rootAnalysis, relativeMocksDir, scenario.name, importMapping[nodeModuleImport.filePath] ?? nodeModuleImport.filePath);
537
884
  }
885
+ // Rewrite node_module imports that have universal mocks
886
+ // Universal mocks create mock files at __codeyamMocks__/{safeFileName}.tsx
887
+ // We need to rewrite imports like `import { logger } from "@formbricks/logger"`
888
+ // to `import { logger } from "../__codeyamMocks__/_formbricks_logger.js"`
889
+ const universalMocks = project.metadata?.universalMocks ?? [];
890
+ const nodeModuleUniversalMocks = universalMocks.filter((mock) => mock.nodeModule && mock.content);
891
+ for (const universalMock of nodeModuleUniversalMocks) {
892
+ const originalPath = universalMock.filePath;
893
+ // Create the mock file name using the same safeFileName function as writeUniversalMocks
894
+ const safeMockFileName = safeFileName(originalPath);
895
+ const mockFileRelativePath = `${relativeMocksDir}/${safeMockFileName}`;
896
+ // Match both single and double quotes, and handle both named and default imports
897
+ // Pattern 1: import { x, y } from "module"
898
+ // Pattern 2: import x from "module"
899
+ // Pattern 3: import * as x from "module"
900
+ const importRegex = new RegExp(`(import\\s+(?:\\{[^}]*\\}|\\*\\s+as\\s+\\w+|\\w+)\\s+from\\s+)['"]${originalPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}['"]`, 'g');
901
+ fileContent = fileContent.replace(importRegex, `$1'${mockFileRelativePath}'`);
902
+ }
538
903
  if (rootAnalysis.entitySha === entity.sha &&
539
904
  entity.metadata?.notExported &&
540
905
  entity.name !== 'default') {
@@ -544,6 +909,16 @@ export default async function writeScenarioComponents({ project, file, entity, r
544
909
  fileContent = `${fileContent}\n\n${exportStatement}`;
545
910
  }
546
911
  }
912
+ // When a default export is imported as named via re-export (e.g., index.tsx re-exports
913
+ // a default export as named), we need to add a named export so the parent's
914
+ // import statement works: `import { Name } from "./path.js"`
915
+ // The local variable name is the same as exportAsNamed (e.g., ScenarioEditor)
916
+ if (exportAsNamed) {
917
+ const namedExport = `export { ${exportAsNamed} };`;
918
+ if (!fileContent.includes(namedExport)) {
919
+ fileContent = `${fileContent}\n\n${namedExport}`;
920
+ }
921
+ }
547
922
  const basePath = safeFolder(file.path.split('/').slice(0, -1).join('/'));
548
923
  const extension = file.name.split('.').pop();
549
924
  // Include scenario name in path to allow multiple scenarios to coexist
@@ -560,9 +935,16 @@ export default async function writeScenarioComponents({ project, file, entity, r
560
935
  scenario,
561
936
  });
562
937
  }
938
+ // Strip <html> and <body> tags from root layout files for Next.js
939
+ // These tags cause hydration errors when the scenario layout is nested under the real root
940
+ fileContent = stripHtmlBodyTags(fileContent, file.path, framework);
563
941
  // Rewrite asset imports (CSS, images, fonts, etc.) to correct relative paths
564
942
  // The original file path is relative to PROJECT_RELATIVE_PATH, the new path is scenarioComponentPath
565
943
  fileContent = rewriteAssetImports(fileContent, `${PROJECT_RELATIVE_PATH}/${file.path}`, scenarioComponentPath);
944
+ // Rewrite relative TypeScript/JavaScript module imports to correct relative paths
945
+ // This handles cases where the file is moved (e.g., from [environmentId]/ to _environmentId_/)
946
+ // and relative imports like "./lib/organization" need to be rewritten
947
+ fileContent = rewriteRelativeModuleImports(fileContent, `${PROJECT_RELATIVE_PATH}/${file.path}`, scenarioComponentPath);
566
948
  console.log('Writing scenario component', file.path, entity.name, scenarioComponentPath, fileContent.length);
567
949
  const scenarioComponentComment = `// This file is auto-generated by CodeYam. Do not edit this file manually.
568
950
  // This file contains content for a scenario component:
@@ -574,7 +956,17 @@ export default async function writeScenarioComponents({ project, file, entity, r
574
956
  // Entity: ${rootAnalysis.entitySha} ${rootAnalysis.entityName}
575
957
  // Scenario: ${scenario.id} - ${scenario.name}
576
958
  `;
577
- await writeFile(scenarioComponentPath, `${scenarioComponentComment}\n\n${fileContent}`);
959
+ // Use the directive that was extracted at the beginning of processing
960
+ // This ensures it stays at the very top even after imports are prepended
961
+ let finalContent;
962
+ if (extractedDirective) {
963
+ finalContent = `${extractedDirective}\n\n${scenarioComponentComment}\n\n${fileContent}`;
964
+ console.log(`CodeYam: Placed "${extractedDirective}" directive at top of file: ${scenarioComponentPath}`);
965
+ }
966
+ else {
967
+ finalContent = `${scenarioComponentComment}\n\n${fileContent}`;
968
+ }
969
+ await writeFile(scenarioComponentPath, finalContent);
578
970
  scenarioComponentPaths.push(scenarioComponentPath);
579
971
  console.log('CodeYam [writeScenarioComponents]: Generated scenario files', {
580
972
  entityName: entity.name,