@codeyam/codeyam-cli 0.1.0-staging.b8a55ba → 0.1.0-staging.c90f8c9

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 (645) hide show
  1. package/analyzer-template/.build-info.json +8 -8
  2. package/analyzer-template/common/execAsync.ts +1 -1
  3. package/analyzer-template/log.txt +3 -3
  4. package/analyzer-template/package.json +9 -6
  5. package/analyzer-template/packages/ai/index.ts +10 -3
  6. package/analyzer-template/packages/ai/package.json +1 -1
  7. package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
  8. package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +126 -6
  9. package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
  10. package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +116 -1
  11. package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
  12. package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +140 -6
  13. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
  14. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +15 -0
  15. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
  16. package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +849 -9
  17. package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +244 -0
  18. package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
  19. package/analyzer-template/packages/ai/src/lib/completionCall.ts +216 -36
  20. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +892 -117
  21. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +2 -1
  22. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +296 -35
  23. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +120 -76
  24. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +80 -5
  25. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
  26. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +8 -1
  27. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
  28. package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +156 -0
  29. package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
  30. package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
  31. package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
  32. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +74 -7
  33. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +86 -142
  34. package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +1 -0
  35. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1111 -87
  36. package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +191 -191
  37. package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +570 -0
  38. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
  39. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +1977 -0
  40. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
  41. package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +5 -5
  42. package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +276 -3
  43. package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +33 -3
  44. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
  45. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -142
  46. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
  47. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
  48. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +90 -6
  49. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -89
  50. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
  51. package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +11 -11
  52. package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
  53. package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +812 -0
  54. package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
  55. package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
  56. package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +118 -0
  57. package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +14 -0
  58. package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
  59. package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +1 -0
  60. package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
  61. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +381 -265
  62. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +18 -0
  63. package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -0
  64. package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -7
  65. package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +31 -15
  66. package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
  67. package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
  68. package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
  69. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +148 -41
  70. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
  71. package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +506 -59
  72. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
  73. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +157 -74
  74. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +156 -0
  75. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +35 -129
  76. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +2 -3
  77. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +420 -87
  78. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
  79. package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
  80. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
  81. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
  82. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
  83. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
  84. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
  85. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
  86. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
  87. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
  88. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
  89. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
  90. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
  91. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
  92. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
  93. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
  94. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
  95. package/analyzer-template/packages/aws/package.json +3 -3
  96. package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
  97. package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
  98. package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
  99. package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
  100. package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +17 -1
  101. package/analyzer-template/packages/database/src/lib/loadAnalyses.ts +58 -1
  102. package/analyzer-template/packages/database/src/lib/loadCommits.ts +16 -0
  103. package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -3
  104. package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +7 -3
  105. package/analyzer-template/packages/generate/index.ts +3 -0
  106. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +17 -1
  107. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +193 -0
  108. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
  109. package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
  110. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +1 -18
  111. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
  112. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +17 -1
  113. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
  114. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  115. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
  116. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
  117. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +2 -6
  118. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
  119. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts +2 -0
  120. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts.map +1 -1
  121. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js +45 -2
  122. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js.map +1 -1
  123. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts +3 -1
  124. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts.map +1 -1
  125. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +13 -1
  126. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js.map +1 -1
  127. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts +3 -1
  128. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
  129. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +23 -4
  130. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
  131. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
  132. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
  133. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  134. package/analyzer-template/packages/github/dist/generate/index.d.ts +3 -0
  135. package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
  136. package/analyzer-template/packages/github/dist/generate/index.js +3 -0
  137. package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
  138. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
  139. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
  140. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  141. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
  142. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
  143. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
  144. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
  145. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
  146. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
  147. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
  148. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
  149. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
  150. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
  151. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
  152. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
  153. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
  154. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
  155. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
  156. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
  157. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
  158. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
  159. package/analyzer-template/packages/github/dist/types/index.d.ts +3 -4
  160. package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
  161. package/analyzer-template/packages/github/dist/types/index.js +0 -1
  162. package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
  163. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +71 -27
  164. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
  165. package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
  166. package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
  167. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +9 -54
  168. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
  169. package/analyzer-template/packages/github/dist/types/src/types/Scenario.js +1 -21
  170. package/analyzer-template/packages/github/dist/types/src/types/Scenario.js.map +1 -1
  171. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +148 -0
  172. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  173. package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts +2 -0
  174. package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts.map +1 -1
  175. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
  176. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
  177. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
  178. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
  179. package/analyzer-template/packages/github/src/lib/loadOrCreateCommit.ts +14 -0
  180. package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
  181. package/analyzer-template/packages/process/index.ts +2 -0
  182. package/analyzer-template/packages/process/package.json +12 -0
  183. package/analyzer-template/packages/process/tsconfig.json +8 -0
  184. package/analyzer-template/packages/types/index.ts +3 -6
  185. package/analyzer-template/packages/types/src/types/Analysis.ts +87 -27
  186. package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
  187. package/analyzer-template/packages/types/src/types/Scenario.ts +9 -77
  188. package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +175 -0
  189. package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
  190. package/analyzer-template/packages/utils/dist/types/index.d.ts +3 -4
  191. package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
  192. package/analyzer-template/packages/utils/dist/types/index.js +0 -1
  193. package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
  194. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +71 -27
  195. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
  196. package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
  197. package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
  198. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +9 -54
  199. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
  200. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.js +1 -21
  201. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.js.map +1 -1
  202. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +148 -0
  203. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  204. package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
  205. package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts.map +1 -1
  206. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
  207. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
  208. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
  209. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
  210. package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
  211. package/analyzer-template/playwright/capture.ts +37 -18
  212. package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
  213. package/analyzer-template/playwright/waitForServer.ts +21 -6
  214. package/analyzer-template/project/analyzeBaselineCommit.ts +4 -0
  215. package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
  216. package/analyzer-template/project/analyzeFileEntities.ts +4 -0
  217. package/analyzer-template/project/analyzeRegularCommit.ts +4 -0
  218. package/analyzer-template/project/constructMockCode.ts +1112 -169
  219. package/analyzer-template/project/controller/startController.ts +16 -1
  220. package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
  221. package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
  222. package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +3 -6
  223. package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +7 -1
  224. package/analyzer-template/project/orchestrateCapture.ts +36 -3
  225. package/analyzer-template/project/reconcileMockDataKeys.ts +220 -78
  226. package/analyzer-template/project/runAnalysis.ts +11 -0
  227. package/analyzer-template/project/serverOnlyModules.ts +127 -2
  228. package/analyzer-template/project/start.ts +16 -4
  229. package/analyzer-template/project/startScenarioCapture.ts +6 -0
  230. package/analyzer-template/project/writeMockDataTsx.ts +164 -24
  231. package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
  232. package/analyzer-template/project/writeScenarioComponents.ts +304 -112
  233. package/analyzer-template/project/writeScenarioFiles.ts +26 -0
  234. package/analyzer-template/project/writeSimpleRoot.ts +11 -35
  235. package/analyzer-template/scripts/comboWorkerLoop.cjs +1 -0
  236. package/analyzer-template/scripts/defaultCmd.sh +9 -0
  237. package/analyzer-template/tsconfig.json +2 -1
  238. package/background/src/lib/local/createLocalAnalyzer.js +1 -29
  239. package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
  240. package/background/src/lib/local/execAsync.js +1 -1
  241. package/background/src/lib/local/execAsync.js.map +1 -1
  242. package/background/src/lib/virtualized/common/execAsync.js +1 -1
  243. package/background/src/lib/virtualized/common/execAsync.js.map +1 -1
  244. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +2 -1
  245. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
  246. package/background/src/lib/virtualized/project/analyzeBranchCommit.js +2 -1
  247. package/background/src/lib/virtualized/project/analyzeBranchCommit.js.map +1 -1
  248. package/background/src/lib/virtualized/project/analyzeFileEntities.js +2 -1
  249. package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
  250. package/background/src/lib/virtualized/project/analyzeRegularCommit.js +2 -1
  251. package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
  252. package/background/src/lib/virtualized/project/constructMockCode.js +987 -130
  253. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  254. package/background/src/lib/virtualized/project/controller/startController.js +11 -1
  255. package/background/src/lib/virtualized/project/controller/startController.js.map +1 -1
  256. package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js +6 -3
  257. package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js.map +1 -1
  258. package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js +7 -7
  259. package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js.map +1 -1
  260. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +3 -2
  261. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
  262. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +3 -1
  263. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
  264. package/background/src/lib/virtualized/project/orchestrateCapture.js +27 -4
  265. package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
  266. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +188 -47
  267. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
  268. package/background/src/lib/virtualized/project/runAnalysis.js +9 -0
  269. package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
  270. package/background/src/lib/virtualized/project/serverOnlyModules.js +106 -3
  271. package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
  272. package/background/src/lib/virtualized/project/start.js +15 -4
  273. package/background/src/lib/virtualized/project/start.js.map +1 -1
  274. package/background/src/lib/virtualized/project/startScenarioCapture.js +7 -0
  275. package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
  276. package/background/src/lib/virtualized/project/writeMockDataTsx.js +139 -23
  277. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  278. package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js +15 -0
  279. package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js.map +1 -0
  280. package/background/src/lib/virtualized/project/writeScenarioComponents.js +228 -95
  281. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  282. package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
  283. package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
  284. package/background/src/lib/virtualized/project/writeSimpleRoot.js +11 -34
  285. package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
  286. package/codeyam-cli/src/cli.js +5 -1
  287. package/codeyam-cli/src/cli.js.map +1 -1
  288. package/codeyam-cli/src/commands/analyze.js +1 -1
  289. package/codeyam-cli/src/commands/analyze.js.map +1 -1
  290. package/codeyam-cli/src/commands/baseline.js +174 -0
  291. package/codeyam-cli/src/commands/baseline.js.map +1 -0
  292. package/codeyam-cli/src/commands/debug.js +28 -18
  293. package/codeyam-cli/src/commands/debug.js.map +1 -1
  294. package/codeyam-cli/src/commands/default.js +0 -15
  295. package/codeyam-cli/src/commands/default.js.map +1 -1
  296. package/codeyam-cli/src/commands/recapture.js +29 -18
  297. package/codeyam-cli/src/commands/recapture.js.map +1 -1
  298. package/codeyam-cli/src/commands/report.js +46 -1
  299. package/codeyam-cli/src/commands/report.js.map +1 -1
  300. package/codeyam-cli/src/commands/start.js +8 -12
  301. package/codeyam-cli/src/commands/start.js.map +1 -1
  302. package/codeyam-cli/src/commands/status.js +23 -1
  303. package/codeyam-cli/src/commands/status.js.map +1 -1
  304. package/codeyam-cli/src/commands/test-startup.js +1 -1
  305. package/codeyam-cli/src/commands/test-startup.js.map +1 -1
  306. package/codeyam-cli/src/commands/wipe.js +108 -0
  307. package/codeyam-cli/src/commands/wipe.js.map +1 -0
  308. package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js +81 -0
  309. package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js.map +1 -0
  310. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +31 -27
  311. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
  312. package/codeyam-cli/src/utils/analysisRunner.js +28 -14
  313. package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
  314. package/codeyam-cli/src/utils/backgroundServer.js +12 -2
  315. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  316. package/codeyam-cli/src/utils/database.js +91 -5
  317. package/codeyam-cli/src/utils/database.js.map +1 -1
  318. package/codeyam-cli/src/utils/generateReport.js +4 -3
  319. package/codeyam-cli/src/utils/generateReport.js.map +1 -1
  320. package/codeyam-cli/src/utils/git.js +79 -0
  321. package/codeyam-cli/src/utils/git.js.map +1 -0
  322. package/codeyam-cli/src/utils/install-skills.js +31 -17
  323. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  324. package/codeyam-cli/src/utils/queue/job.js +105 -0
  325. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  326. package/codeyam-cli/src/utils/queue/manager.js +6 -0
  327. package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
  328. package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
  329. package/codeyam-cli/src/utils/serverState.js.map +1 -1
  330. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +7 -5
  331. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
  332. package/codeyam-cli/src/utils/versionInfo.js +25 -19
  333. package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
  334. package/codeyam-cli/src/utils/wipe.js +128 -0
  335. package/codeyam-cli/src/utils/wipe.js.map +1 -0
  336. package/codeyam-cli/src/webserver/app/lib/database.js +73 -20
  337. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  338. package/codeyam-cli/src/webserver/bootstrap.js +40 -0
  339. package/codeyam-cli/src/webserver/bootstrap.js.map +1 -1
  340. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-BXhEawa3.js +1 -0
  341. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-CzGX-miz.js → EntityTypeBadge-DLqD3qNt.js} +1 -1
  342. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-Ba2JVPzP.js +41 -0
  343. package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-C8lyxW9k.js +34 -0
  344. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-aht4aafF.js +25 -0
  345. package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-CBQPrpT0.js → LibraryFunctionPreview-CVtiBnY5.js} +1 -1
  346. package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-D1CdlbrV.js → LoadingDots-B0GLXMsr.js} +1 -1
  347. package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-wDPcZNKx.js → LogViewer-xgeCVgSM.js} +1 -1
  348. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-D4TZhLuw.js +21 -0
  349. package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-BfmDgXxG.js → SafeScreenshot-DuDvi0jm.js} +1 -1
  350. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-DEx02QDa.js +10 -0
  351. package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-6J7zDUD5.js → TruncatedFilePath-DyFZkK0l.js} +1 -1
  352. package/codeyam-cli/src/webserver/build/client/assets/_index-BwqWJOgH.js +11 -0
  353. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-DoLIqZX2.js +37 -0
  354. package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-BYimnrHg.js → chevron-down-Cx24_aWc.js} +1 -1
  355. package/codeyam-cli/src/webserver/build/client/assets/chunk-EPOLDU6W-CXRTFQ3F.js +51 -0
  356. package/codeyam-cli/src/webserver/build/client/assets/{circle-check-CaVsIRxt.js → circle-check-BOARzkeR.js} +1 -1
  357. package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-CgUsG7ib.js → createLucideIcon-BdhJEx6B.js} +1 -1
  358. package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
  359. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
  360. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-BRb-0kQl.js +1 -0
  361. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-zUEpfPsu.js → entity._sha._-C2N4Op8e.js} +12 -12
  362. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DavjRmOY.js +6 -0
  363. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-D1T4TGjf.js +6 -0
  364. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-CfLCUi9S.js → entity._sha_.edit._scenarioId-CTBG2mmz.js} +1 -1
  365. package/codeyam-cli/src/webserver/build/client/assets/{entry.client-DKJyZfAY.js → entry.client-CS2cb_eZ.js} +6 -6
  366. package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
  367. package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DAtOlaWE.js → fileTableUtils-DMJ7zii9.js} +1 -1
  368. package/codeyam-cli/src/webserver/build/client/assets/files-Cs4MdYtv.js +1 -0
  369. package/codeyam-cli/src/webserver/build/client/assets/{git-D62Lxxmv.js → git-B4RJRvYB.js} +2 -2
  370. package/codeyam-cli/src/webserver/build/client/assets/git-commit-horizontal-CysbcZxi.js +6 -0
  371. package/codeyam-cli/src/webserver/build/client/assets/globals-DMUaGAqV.css +1 -0
  372. package/codeyam-cli/src/webserver/build/client/assets/{index-CzNNiTkw.js → index-B1h680n5.js} +1 -1
  373. package/codeyam-cli/src/webserver/build/client/assets/{index-BosqDOlH.js → index-lzqtyFU8.js} +1 -1
  374. package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-CNp9QFCX.js → loader-circle-B7B9V-bu.js} +1 -1
  375. package/codeyam-cli/src/webserver/build/client/assets/manifest-f874c610.js +1 -0
  376. package/codeyam-cli/src/webserver/build/client/assets/root-Bz5TunQg.js +57 -0
  377. package/codeyam-cli/src/webserver/build/client/assets/rules-hEkvVw2-.js +97 -0
  378. package/codeyam-cli/src/webserver/build/client/assets/{search-DDGjYAMJ.js → search-CxXUmBSd.js} +1 -1
  379. package/codeyam-cli/src/webserver/build/client/assets/settings-CS5f3WzT.js +1 -0
  380. package/codeyam-cli/src/webserver/build/client/assets/simulations-DwFIBT09.js +1 -0
  381. package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-CBc5dE1s.js → triangle-alert-B6LgvRJg.js} +1 -1
  382. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-C1v1PQzo.js +1 -0
  383. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-BqPPNjAl.js → useLastLogLine-aSv48UbS.js} +1 -1
  384. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DYxHZQuP.js +1 -0
  385. package/codeyam-cli/src/webserver/build/client/assets/{useToast-DWHcCcl1.js → useToast-mBRpZPiu.js} +1 -1
  386. package/codeyam-cli/src/webserver/build/server/assets/index-uNNbimct.js +1 -0
  387. package/codeyam-cli/src/webserver/build/server/assets/server-build-B08qC4Y7.js +257 -0
  388. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  389. package/codeyam-cli/src/webserver/build-info.json +5 -5
  390. package/codeyam-cli/src/webserver/server.js +35 -25
  391. package/codeyam-cli/src/webserver/server.js.map +1 -1
  392. package/codeyam-cli/templates/codeyam-power-rules-hook.sh +200 -0
  393. package/codeyam-cli/templates/{codeyam-debug-skill.md → codeyam:debug.md} +48 -4
  394. package/codeyam-cli/templates/{debug-codeyam.md → codeyam:diagnose.md} +185 -23
  395. package/codeyam-cli/templates/codeyam:new-rule.md +13 -0
  396. package/codeyam-cli/templates/codeyam:power-rules.md +449 -0
  397. package/codeyam-cli/templates/{codeyam-setup-skill.md → codeyam:setup.md} +139 -4
  398. package/codeyam-cli/templates/{codeyam-sim-skill.md → codeyam:sim.md} +1 -1
  399. package/codeyam-cli/templates/{codeyam-test-skill.md → codeyam:test.md} +1 -1
  400. package/codeyam-cli/templates/{codeyam-verify-skill.md → codeyam:verify.md} +1 -1
  401. package/package.json +6 -5
  402. package/packages/ai/index.js +5 -4
  403. package/packages/ai/index.js.map +1 -1
  404. package/packages/ai/src/lib/analyzeScope.js +97 -0
  405. package/packages/ai/src/lib/analyzeScope.js.map +1 -1
  406. package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
  407. package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
  408. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +84 -1
  409. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
  410. package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
  411. package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
  412. package/packages/ai/src/lib/astScopes/methodSemantics.js +97 -6
  413. package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
  414. package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js +8 -0
  415. package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
  416. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +7 -0
  417. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
  418. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +138 -1
  419. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
  420. package/packages/ai/src/lib/astScopes/processExpression.js +654 -13
  421. package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
  422. package/packages/ai/src/lib/checkAllAttributes.js +24 -9
  423. package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
  424. package/packages/ai/src/lib/completionCall.js +178 -31
  425. package/packages/ai/src/lib/completionCall.js.map +1 -1
  426. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +715 -64
  427. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  428. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +2 -1
  429. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
  430. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +230 -23
  431. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -1
  432. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +77 -55
  433. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
  434. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +67 -3
  435. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
  436. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js +86 -0
  437. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js.map +1 -0
  438. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +6 -1
  439. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
  440. package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
  441. package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
  442. package/packages/ai/src/lib/dataStructureChunking.js +111 -0
  443. package/packages/ai/src/lib/dataStructureChunking.js.map +1 -0
  444. package/packages/ai/src/lib/deepEqual.js +32 -0
  445. package/packages/ai/src/lib/deepEqual.js.map +1 -0
  446. package/packages/ai/src/lib/e2eDataTracking.js +241 -0
  447. package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
  448. package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
  449. package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
  450. package/packages/ai/src/lib/generateChangesEntityScenarioData.js +62 -5
  451. package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
  452. package/packages/ai/src/lib/generateChangesEntityScenarios.js +78 -120
  453. package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
  454. package/packages/ai/src/lib/generateEntityDataStructure.js +1 -0
  455. package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
  456. package/packages/ai/src/lib/generateEntityScenarioData.js +906 -82
  457. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  458. package/packages/ai/src/lib/generateEntityScenarios.js +170 -162
  459. package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
  460. package/packages/ai/src/lib/generateExecutionFlows.js +392 -0
  461. package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -0
  462. package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js +380 -0
  463. package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js.map +1 -0
  464. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +1440 -0
  465. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -0
  466. package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
  467. package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
  468. package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -2
  469. package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
  470. package/packages/ai/src/lib/isolateScopes.js +231 -4
  471. package/packages/ai/src/lib/isolateScopes.js.map +1 -1
  472. package/packages/ai/src/lib/mergeStatements.js +26 -3
  473. package/packages/ai/src/lib/mergeStatements.js.map +1 -1
  474. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +1 -1
  475. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
  476. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -100
  477. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
  478. package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
  479. package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
  480. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +68 -6
  481. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
  482. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -70
  483. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
  484. package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
  485. package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
  486. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +9 -9
  487. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
  488. package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
  489. package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
  490. package/packages/ai/src/lib/resolvePathToControllable.js +667 -0
  491. package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
  492. package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
  493. package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
  494. package/packages/ai/src/lib/worker/SerializableDataStructure.js +29 -0
  495. package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
  496. package/packages/analyze/src/lib/FileAnalyzer.js +15 -0
  497. package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
  498. package/packages/analyze/src/lib/analysisContext.js +30 -5
  499. package/packages/analyze/src/lib/analysisContext.js.map +1 -1
  500. package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
  501. package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
  502. package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
  503. package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
  504. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +151 -52
  505. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  506. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +10 -0
  507. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  508. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +2 -0
  509. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
  510. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -7
  511. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
  512. package/packages/analyze/src/lib/files/analyzeChange.js +21 -11
  513. package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
  514. package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
  515. package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
  516. package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
  517. package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
  518. package/packages/analyze/src/lib/files/enums/steps.js +1 -1
  519. package/packages/analyze/src/lib/files/enums/steps.js.map +1 -1
  520. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +121 -37
  521. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
  522. package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
  523. package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
  524. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +410 -55
  525. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
  526. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
  527. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
  528. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +126 -57
  529. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  530. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +96 -0
  531. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
  532. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +27 -98
  533. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
  534. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +2 -3
  535. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
  536. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +342 -83
  537. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  538. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
  539. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
  540. package/packages/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
  541. package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
  542. package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
  543. package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
  544. package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  545. package/packages/database/src/lib/loadAnalyses.js +45 -2
  546. package/packages/database/src/lib/loadAnalyses.js.map +1 -1
  547. package/packages/database/src/lib/loadCommits.js +13 -1
  548. package/packages/database/src/lib/loadCommits.js.map +1 -1
  549. package/packages/database/src/lib/loadEntities.js +23 -4
  550. package/packages/database/src/lib/loadEntities.js.map +1 -1
  551. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
  552. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  553. package/packages/generate/index.js +3 -0
  554. package/packages/generate/index.js.map +1 -1
  555. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
  556. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  557. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
  558. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
  559. package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
  560. package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
  561. package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
  562. package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
  563. package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
  564. package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
  565. package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
  566. package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
  567. package/packages/process/index.js +3 -0
  568. package/packages/process/index.js.map +1 -0
  569. package/packages/process/src/GlobalProcessManager.js.map +1 -0
  570. package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
  571. package/packages/process/src/ProcessManager.js.map +1 -0
  572. package/packages/process/src/index.js.map +1 -0
  573. package/packages/process/src/managedExecAsync.js.map +1 -0
  574. package/packages/types/index.js +0 -1
  575. package/packages/types/index.js.map +1 -1
  576. package/packages/types/src/types/Scenario.js +1 -21
  577. package/packages/types/src/types/Scenario.js.map +1 -1
  578. package/packages/utils/src/lib/safeFileName.js +29 -3
  579. package/packages/utils/src/lib/safeFileName.js.map +1 -1
  580. package/scripts/finalize-analyzer.cjs +3 -3
  581. package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
  582. package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -409
  583. package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -288
  584. package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -495
  585. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
  586. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -120
  587. package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
  588. package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
  589. package/analyzer-template/process/README.md +0 -507
  590. package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
  591. package/background/src/lib/process/ProcessManager.js.map +0 -1
  592. package/background/src/lib/process/index.js.map +0 -1
  593. package/background/src/lib/process/managedExecAsync.js.map +0 -1
  594. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
  595. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
  596. package/codeyam-cli/scripts/fixtures/formbricks/universal-mocks/apps/web/lib/instance/service.js +0 -7
  597. package/codeyam-cli/scripts/fixtures/formbricks/universal-mocks/apps/web/lib/instance/service.js.map +0 -1
  598. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-wXL1Z2Aq.js +0 -1
  599. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-CXFKsCOD.js +0 -41
  600. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-D-9pXIaY.js +0 -25
  601. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-4lcOlid-.js +0 -11
  602. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CUxUNEEC.js +0 -15
  603. package/codeyam-cli/src/webserver/build/client/assets/_index-DHImXdXq.js +0 -11
  604. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-2mG6mjVb.js +0 -32
  605. package/codeyam-cli/src/webserver/build/client/assets/chunk-JMJ3UQ3L-BambyYE_.js +0 -51
  606. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-CKnwPCDr.js +0 -1
  607. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-DW_hdGUc.js +0 -1
  608. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DyB90fWk.js +0 -1
  609. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-D_3ero5o.js +0 -1
  610. package/codeyam-cli/src/webserver/build/client/assets/files-ClR0d32A.js +0 -1
  611. package/codeyam-cli/src/webserver/build/client/assets/globals-C6vQASxy.css +0 -1
  612. package/codeyam-cli/src/webserver/build/client/assets/keyAttributeCoverage-CTlFMihX.js +0 -1
  613. package/codeyam-cli/src/webserver/build/client/assets/manifest-09d684be.js +0 -1
  614. package/codeyam-cli/src/webserver/build/client/assets/root-BxJUvKau.js +0 -56
  615. package/codeyam-cli/src/webserver/build/client/assets/settings-DgTyB-Wg.js +0 -1
  616. package/codeyam-cli/src/webserver/build/client/assets/simulations-CoNWGt0K.js +0 -1
  617. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BMIGFP-m.js +0 -1
  618. package/codeyam-cli/src/webserver/build/client/assets/useInteractiveMode-Dk_FQqWJ.js +0 -1
  619. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DsJbgMY9.js +0 -1
  620. package/codeyam-cli/src/webserver/build/server/assets/index-CV6i1S1A.js +0 -1
  621. package/codeyam-cli/src/webserver/build/server/assets/server-build-BDlyhfrv.js +0 -175
  622. package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
  623. package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
  624. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -298
  625. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
  626. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -226
  627. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
  628. package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -408
  629. package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
  630. package/packages/ai/src/lib/isFrontend.js +0 -5
  631. package/packages/ai/src/lib/isFrontend.js.map +0 -1
  632. package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
  633. package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
  634. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -77
  635. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
  636. /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
  637. /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
  638. /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
  639. /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
  640. /package/codeyam-cli/src/webserver/build/client/assets/{api.link-scenario-value-l0sNRNKZ.js → api.health-l0sNRNKZ.js} +0 -0
  641. /package/codeyam-cli/src/webserver/build/client/assets/{api.update-key-attributes-l0sNRNKZ.js → api.restart-server-l0sNRNKZ.js} +0 -0
  642. /package/codeyam-cli/src/webserver/build/client/assets/{api.update-valid-values-l0sNRNKZ.js → api.rules-l0sNRNKZ.js} +0 -0
  643. /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
  644. /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
  645. /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
@@ -62,7 +62,10 @@ function resetDebugTiming() {
62
62
  */
63
63
  function findEndOfImports(content) {
64
64
  try {
65
- const sourceFile = ts.createSourceFile('temp.ts', content, ts.ScriptTarget.Latest, true);
65
+ // Use temp.tsx to enable JSX parsing - otherwise TypeScript may misparse
66
+ // JSX content containing the word "import" (e.g., "Entities that import this")
67
+ // as an import statement, causing mock code to be inserted in the wrong location.
68
+ const sourceFile = ts.createSourceFile('temp.tsx', content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
66
69
  let lastImportEnd = 0;
67
70
  // Visit all top-level statements to find import/export declarations
68
71
  for (const statement of sourceFile.statements) {
@@ -476,7 +479,8 @@ function extractInternalImportPaths(fileContent) {
476
479
  function extractInternalImportPathsAst(fileContent) {
477
480
  const importPaths = [];
478
481
  try {
479
- const sourceFile = ts.createSourceFile('temp.ts', fileContent, ts.ScriptTarget.Latest, true);
482
+ // Use temp.tsx to enable JSX parsing for consistent handling of JSX files
483
+ const sourceFile = ts.createSourceFile('temp.tsx', fileContent, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
480
484
  for (const statement of sourceFile.statements) {
481
485
  if (ts.isImportDeclaration(statement) && statement.moduleSpecifier) {
482
486
  const moduleSpecifier = statement.moduleSpecifier;
@@ -592,33 +596,59 @@ function addMockToContent(fileContent, importedExport, fileAnalyses, rootAnalysi
592
596
  }
593
597
  // Check if we have multiple calls with different variable names
594
598
  // This requires generating separate mock functions for each call site
595
- const hasMultipleCallsWithVariables = importedExport.calls &&
596
- importedExport.calls.length > 1 &&
599
+ //
600
+ // IMPORTANT: calls array may contain BOTH base hook calls (e.g., "useFetcher<Type>()")
601
+ // AND method chain usages (e.g., "useFetcher().functionCallReturnValue.submit(...)").
602
+ // We only want to count base hook calls for the length comparison with callVariableNames.
603
+ // A "base call" is one that ends with "()" possibly preceded by a type annotation,
604
+ // without any subsequent method chains like ".functionCallReturnValue" or ".submit(...)".
605
+ const baseHookCalls = importedExport.calls?.filter((call) => {
606
+ // Base hook calls match patterns like:
607
+ // - "useFetcher()"
608
+ // - "useFetcher<Type>()"
609
+ // - "useFetcher<{ complex: Type }>()"
610
+ // They end with "()" and don't have method chains after the call.
611
+ // Method chains contain ".functionCallReturnValue" or have property access after "()".
612
+ return (call.endsWith('()') &&
613
+ !call.includes('.functionCallReturnValue') &&
614
+ // Also exclude method chains like "hook().something" or "hook().method()"
615
+ !call.match(/\(\)\.[a-zA-Z]/));
616
+ });
617
+ // Determine if we can generate unique mock functions for multiple variables.
618
+ // We need:
619
+ // 1. Multiple variable names (callVariableNames.length > 1)
620
+ // 2. Base hook calls to match them (baseHookCalls.length > 0)
621
+ // Note: We use min(baseHookCalls.length, callVariableNames.length) for iteration
622
+ // to handle cases where data might be slightly out of sync (stale entries).
623
+ const hasMultipleCallsWithVariables = baseHookCalls &&
624
+ baseHookCalls.length > 1 &&
597
625
  importedExport.callVariableNames &&
598
- importedExport.callVariableNames.length === importedExport.calls.length;
626
+ importedExport.callVariableNames.length > 1 &&
627
+ // Only proceed if we have at least as many base calls as variable names,
628
+ // OR they're close enough (within 1) to handle minor sync issues
629
+ Math.abs(baseHookCalls.length - importedExport.callVariableNames.length) <=
630
+ 1;
599
631
  let mockCode;
600
632
  const variableMockCodes = [];
601
633
  if (hasMultipleCallsWithVariables) {
602
634
  // Generate separate mock functions for each variable-qualified call
603
635
  // Look up canonical keys from dataForMocks and track variable names for function naming
604
- // Get all canonical keys for this hook (sorted by index)
636
+ // Get all call signature keys for this hook from dataForMocks
605
637
  const dataForMocks = rootAnalysis.metadata?.scenariosDataStructure?.dataForMocks;
606
- const canonicalKeysForHook = dataForMocks
607
- ? Object.keys(dataForMocks)
608
- .filter((key) => {
609
- const match = key.match(/^[^:]+::([^:]+)::\d+$/);
610
- return match && match[1] === importedExport.name;
611
- })
612
- .sort((a, b) => {
613
- // Sort by the index part (last ::N)
614
- const indexA = parseInt(a.split('::').pop() || '0');
615
- const indexB = parseInt(b.split('::').pop() || '0');
616
- return indexA - indexB;
638
+ // Match keys that start with the hook name (e.g., "useFetcher" matches "useFetcher<User>()")
639
+ const callSignatureKeysForHook = dataForMocks
640
+ ? Object.keys(dataForMocks).filter((key) => {
641
+ const hookBaseName = importedExport.name.split(/[<(]/)[0];
642
+ const keyBaseName = key.split(/[<(]/)[0];
643
+ return keyBaseName === hookBaseName;
617
644
  })
618
645
  : [];
619
646
  // Track variable name occurrences for unique function naming
620
647
  const variableNameCounts = {};
621
- for (let i = 0; i < importedExport.calls.length; i++) {
648
+ // Use the minimum of both array lengths to handle slight mismatches
649
+ // (e.g., stale data from previous analysis runs)
650
+ const iterationLimit = Math.min(baseHookCalls.length, importedExport.callVariableNames.length);
651
+ for (let i = 0; i < iterationLimit; i++) {
622
652
  const variableName = importedExport.callVariableNames[i];
623
653
  if (!variableName)
624
654
  continue;
@@ -633,22 +663,26 @@ function addMockToContent(fileContent, importedExport, fileAnalyses, rootAnalysi
633
663
  // Compute unique mock function name for call site replacement
634
664
  // e.g., useFetcher_entityDiffFetcher, useFetcher_reportFetcher
635
665
  const mockFunctionName = `${importedExport.name}_${safeFunctionName}`;
636
- // Use the canonical key at index i if available
637
- const canonicalKey = canonicalKeysForHook[i];
638
- // Use variable-qualified format that constructMockCode understands
639
- // e.g., "entityDiffFetcher <- useFetcher" for schema lookup
640
- // This generates unique variable names like useFetcher_entityDiffFetcherReturnValue
641
- const qualifiedMockName = `${indexedVariableName} <- ${importedExport.name}`;
642
- // Generate mock code using the variable-qualified name and canonical key for data lookup
666
+ // Use the call signature from baseHookCalls[i] as the data key
667
+ // This matches what's stored in dataForMocks
668
+ const callSignature = baseHookCalls[i];
669
+ // Generate mock code using the call signature directly
643
670
  // This prevents "symbol already declared" errors when multiple calls exist
644
- const variableMockCode = constructMockCode(qualifiedMockName, // Use variable-qualified format for unique naming
645
- dependencySchemas, importedExport.entityType, canonicalKey);
671
+ // Check if this is a package import that won't have scenario copies
672
+ const isPackageImportForMock = importPath?.startsWith('@');
673
+ const variableMockCode = constructMockCode(callSignature, // Use call signature format for data lookup
674
+ dependencySchemas, importedExport.entityType, undefined, // No need for separate canonical key
675
+ {
676
+ uniqueFunctionSuffix: safeFunctionName, // Use variable name for unique function naming
677
+ // For node_modules or package imports, skip spreading from __cyOriginal
678
+ // since those packages/files don't export *__cyOriginal variants
679
+ skipOriginalSpread: importedExport.isNodeModule || isPackageImportForMock,
680
+ });
646
681
  if (variableMockCode) {
647
682
  variableMockCodes.push(variableMockCode);
648
683
  // Replace the call site with the variable-specific mock function
649
684
  // e.g., useFetcher<BranchEntityDiffResult>() -> useFetcher_entityDiffFetcher()
650
685
  // e.g., useFetcher() -> useFetcher_reportFetcher()
651
- const callSignature = importedExport.calls[i];
652
686
  // Escape special regex characters in the call signature
653
687
  const escapedCallSignature = callSignature.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
654
688
  // Create regex that matches the call (with optional whitespace variations)
@@ -667,87 +701,104 @@ function addMockToContent(fileContent, importedExport, fileAnalyses, rootAnalysi
667
701
  ? importedExport.callVariableNames[0]
668
702
  : undefined;
669
703
  if (singleCallVariableName) {
670
- // For single variable assignments, look up canonical key from dataForMocks
704
+ // For single variable assignments, use the call signature directly from dataForMocks
671
705
  const dataForMocks = rootAnalysis.metadata?.scenariosDataStructure?.dataForMocks;
672
- let canonicalKey = dataForMocks
706
+ // Find matching call signature key in dataForMocks
707
+ const hookBaseName = importedExport.name.split(/[<(]/)[0];
708
+ const callSignatureKey = dataForMocks
673
709
  ? Object.keys(dataForMocks).find((key) => {
674
- // Check canonical key format: EntityName::hookName::index
675
- const canonicalMatch = key.match(/^[^:]+::([^:]+)::\d+$/);
676
- if (canonicalMatch && canonicalMatch[1] === importedExport.name) {
677
- return true;
678
- }
679
- // Fall back to legacy format
680
- const legacyMatch = key.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\s*<-\s*(.+)$/);
681
- return legacyMatch && legacyMatch[2] === importedExport.name;
710
+ // Split on ., <, or ( to get the true base name
711
+ // This handles both "useFlags()" -> "useFlags" and "trpc.useUtils()" -> "trpc"
712
+ const keyBaseName = key.split(/[.<(]/)[0];
713
+ return keyBaseName === hookBaseName;
682
714
  })
683
715
  : undefined;
684
- // If no canonical key found in dataForMocks, use variable-qualified format directly
685
- // This allows constructMockCode to find the schema in dependencySchemas
686
- if (!canonicalKey) {
687
- canonicalKey = `${singleCallVariableName} <- ${importedExport.name}`;
688
- }
716
+ // Use the call signature if found, otherwise construct it
717
+ const dataKey = callSignatureKey ??
718
+ importedExport.calls?.[0] ??
719
+ `${importedExport.name}()`;
720
+ // IMPORTANT: If the dataKey is a method chain (e.g., "trpc.useUtils()"), we should
721
+ // use the base name (e.g., "trpc") when calling constructMockCode. This ensures
722
+ // constructMockCode generates a complete nested mock from the schema without
723
+ // referencing __cyOriginal variables.
724
+ const dataKeyBaseName = dataKey.split(/[.<(]/)[0];
725
+ const isMethodChainDataKey = dataKeyBaseName === importedExport.name &&
726
+ dataKey !== importedExport.name &&
727
+ dataKey.includes('.');
728
+ const mockNameToUse = isMethodChainDataKey
729
+ ? importedExport.name
730
+ : dataKey;
689
731
  // Keep the original function name since there's only one call
690
- mockCode = constructMockCode(importedExport.name, dependencySchemas, importedExport.entityType, canonicalKey, { keepOriginalFunctionName: true });
732
+ // Check if this is a package import that won't have scenario copies
733
+ const isPackageImportForSingleCall = importPath?.startsWith('@');
734
+ mockCode = constructMockCode(mockNameToUse, dependencySchemas, importedExport.entityType, undefined, {
735
+ keepOriginalFunctionName: true,
736
+ // For node_modules or package imports, skip spreading from __cyOriginal
737
+ // since those packages/files don't export *__cyOriginal variants
738
+ skipOriginalSpread: importedExport.isNodeModule || isPackageImportForSingleCall,
739
+ });
691
740
  // If constructMockCode didn't generate code, fall back to simple return
741
+ // IMPORTANT: We inline scenarios().data() inside the function rather than
742
+ // storing in a const - see comment in constructMockCode.ts for why.
692
743
  if (!mockCode) {
693
- mockCode = `const ${importedExport.name}ReturnValue = scenarios().data()?.["${canonicalKey}"];
694
-
695
- function ${importedExport.name}() {
696
- return ${importedExport.name}ReturnValue;
744
+ mockCode = `function ${importedExport.name}(...args) {
745
+ return scenarios().data()?.["${dataKey}"];
697
746
  }`;
698
747
  }
699
748
  }
700
749
  else {
701
- // Look for canonical key (format: EntityName::hookName::index) or legacy variable-qualified key
702
- let canonicalKey;
703
- // Helper to find matching key from dataForMocks
750
+ // Helper to find matching call signature key from dataForMocks
751
+ const hookBaseName = importedExport.name.split(/[<(]/)[0];
704
752
  const findMatchingKey = (dataForMocks) => {
705
753
  if (!dataForMocks)
706
754
  return undefined;
707
755
  return Object.keys(dataForMocks).find((key) => {
708
- // Check canonical key format: EntityName::hookName::index
709
- const canonicalMatch = key.match(/^[^:]+::([^:]+)::\d+$/);
710
- if (canonicalMatch && canonicalMatch[1] === importedExport.name) {
711
- return true;
712
- }
713
- // Fall back to legacy variable-qualified format: variableName <- functionName
714
- const legacyMatch = key.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\s*<-\s*(.+)$/);
715
- return legacyMatch && legacyMatch[2] === importedExport.name;
756
+ // Split on ., <, or ( to get the true base name
757
+ // This handles both "useFlags()" -> "useFlags" and "trpc.useUtils()" -> "trpc"
758
+ const keyBaseName = key.split(/[.<(]/)[0];
759
+ return keyBaseName === hookBaseName;
716
760
  });
717
761
  };
718
- // CRITICAL: Check rootAnalysis FIRST for canonical keys.
719
- // This ensures we use the same keys that will be in the mock DATA.
762
+ // Check rootAnalysis FIRST for matching keys.
720
763
  // The mock DATA is generated from rootAnalysis, so the mock CODE must
721
764
  // also use rootAnalysis keys to ensure the lookup succeeds.
722
- // Bug scenario (if we check fileAnalyses first):
723
- // - Child component's fileAnalysis has: "ChildComponent::hook::0"
724
- // - Root's dataForMocks has: "RootEntity::hook::0"
725
- // - Mock CODE uses child key, but mock DATA has root key → lookup fails
726
- canonicalKey = findMatchingKey(rootAnalysis.metadata?.scenariosDataStructure?.dataForMocks);
765
+ let dataKey = findMatchingKey(rootAnalysis.metadata?.scenariosDataStructure?.dataForMocks);
727
766
  // If not found in rootAnalysis, fall back to fileAnalyses
728
- if (!canonicalKey) {
767
+ if (!dataKey) {
729
768
  for (const analysis of fileAnalyses) {
730
- canonicalKey = findMatchingKey(analysis.metadata?.scenariosDataStructure?.dataForMocks);
731
- if (canonicalKey)
769
+ dataKey = findMatchingKey(analysis.metadata?.scenariosDataStructure?.dataForMocks);
770
+ if (dataKey)
732
771
  break;
733
772
  }
734
773
  }
735
- if (canonicalKey) {
736
- // Use the canonical key for data lookup
737
- // Keep the original function name since there's only one call
738
- mockCode = constructMockCode(importedExport.name, dependencySchemas, importedExport.entityType, canonicalKey, { keepOriginalFunctionName: true });
739
- // If constructMockCode didn't generate code, fall back to simple return
740
- if (!mockCode) {
741
- mockCode = `const ${importedExport.name}ReturnValue = scenarios().data()?.["${canonicalKey}"];
742
-
743
- function ${importedExport.name}() {
744
- return ${importedExport.name}ReturnValue;
774
+ // Use the data key if found, otherwise use call signature or function name.
775
+ // IMPORTANT: If the dataKey is a method chain (e.g., "trpc.useUtils()"), we should
776
+ // use the base name (e.g., "trpc") when calling constructMockCode. This ensures
777
+ // constructMockCode generates a complete nested mock from the schema without
778
+ // referencing __cyOriginal variables. The __cyOriginal pattern is only needed
779
+ // for partial mocking where we preserve some original methods, not for complete
780
+ // method-chain mocks where we provide all implementations.
781
+ const dataKeyBaseName = dataKey?.split(/[.<(]/)[0];
782
+ const isMethodChainDataKey = dataKey &&
783
+ dataKeyBaseName === importedExport.name &&
784
+ dataKey !== importedExport.name &&
785
+ dataKey.includes('.');
786
+ const mockNameToUse = isMethodChainDataKey
787
+ ? importedExport.name
788
+ : (dataKey ?? importedExport.calls?.[0] ?? `${importedExport.name}()`);
789
+ mockCode = constructMockCode(mockNameToUse, dependencySchemas, importedExport.entityType, undefined, {
790
+ keepOriginalFunctionName: true,
791
+ // For node_modules or package imports, skip spreading from __cyOriginal
792
+ // since those packages/files don't export *__cyOriginal variants
793
+ skipOriginalSpread: importedExport.isNodeModule || importPath?.startsWith('@'),
794
+ });
795
+ // If constructMockCode didn't generate code, fall back to simple return
796
+ // IMPORTANT: We inline scenarios().data() inside the function rather than
797
+ // storing in a const - see comment in constructMockCode.ts for why.
798
+ if (!mockCode && dataKey) {
799
+ mockCode = `function ${importedExport.name}(...args) {
800
+ return scenarios().data()?.["${dataKey}"];
745
801
  }`;
746
- }
747
- }
748
- else {
749
- // Original behavior for calls without variable names
750
- mockCode = constructMockCode(importedExport.name, dependencySchemas, importedExport.entityType);
751
802
  }
752
803
  }
753
804
  }
@@ -766,13 +817,44 @@ function ${importedExport.name}() {
766
817
  else {
767
818
  // Escape regex special characters in importPath (e.g., brackets in [environmentId])
768
819
  const escapedImportPath = importPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
769
- const importRegExp = new RegExp(`(import(?:(?!${firstPart}|from|import)[\\s\\S])*?)${firstPart}(?:,\\s*)?((?:(?!import)[\\s\\S])*?from\\s+['"]${escapedImportPath}['"])`, 'm');
770
- if (importedExportNameParts.length > 1) {
820
+ // Use a simpler, more robust regex pattern that matches the fallback path.
821
+ // Key improvements:
822
+ // 1. Uses escapeRegExp(firstPart) to handle special characters in function names
823
+ // 2. Uses word boundaries (\b) to prevent partial matches
824
+ // 3. Handles comma BEFORE or AFTER the name: (?:,\s*|\s*,)?
825
+ // 4. Matches specific import path (escapedImportPath)
826
+ const importRegExp = new RegExp(`(import\\s*\\{[^}]*?)\\b${escapeRegExp(firstPart)}\\b(?:,\\s*|\\s*,)?((?:[^}]*\\}\\s*from\\s*['"]${escapedImportPath}['"];?))`, 'm');
827
+ // Check if any call signature has multiple parts (e.g., "logger.error(error)")
828
+ // If so, the mock code will spread from __cyOriginal, so we need to rename the import
829
+ // EXCEPT:
830
+ // 1. For node_module imports, the __cyOriginal pattern doesn't work because
831
+ // the original package doesn't export *__cyOriginal variants.
832
+ // 2. For package imports (starting with @), the __cyOriginal pattern doesn't work
833
+ // because scenario copies aren't created for package files - they keep the
834
+ // original import path which doesn't export *__cyOriginal.
835
+ const anyCallHasMultipleParts = importedExport.calls?.some((call) => {
836
+ const callParts = splitOutsideParenthesesAndArrays(call);
837
+ return callParts.length > 1;
838
+ });
839
+ // Package imports (starting with @) don't get scenario copies, so __cyOriginal won't exist
840
+ const isPackageImport = importPath.startsWith('@');
841
+ const shouldRenameToOriginal = !importedExport.isNodeModule &&
842
+ !isPackageImport &&
843
+ (importedExportNameParts.length > 1 || anyCallHasMultipleParts);
844
+ if (shouldRenameToOriginal) {
771
845
  fileContent = fileContent.replace(importRegExp, `$1${firstPart}__cyOriginal$2`);
772
846
  }
773
847
  else {
774
848
  fileContent = fileContent.replace(importRegExp, '$1$2');
775
849
  }
850
+ // Also handle namespace imports (import * as foo from '...')
851
+ // These need to be renamed to foo__cyOriginal when the mock code spreads from the original.
852
+ // Note: We match any path (not just escapedImportPath) because the import path may have
853
+ // been rewritten by transitive import handling before this code runs.
854
+ if (shouldRenameToOriginal) {
855
+ const namespaceImportRegExp = new RegExp(`(import\\s+\\*\\s+as\\s+)${escapeRegExp(firstPart)}(\\s+from\\s+['"][^'"]*['"])`, 'm');
856
+ fileContent = fileContent.replace(namespaceImportRegExp, `$1${firstPart}__cyOriginal$2`);
857
+ }
776
858
  // Remove empty imports entirely to avoid partial commenting issues with multiline imports
777
859
  // This handles both single-line and multiline empty imports
778
860
  fileContent = fileContent.replace(/import\s*\{\s*\}\s*from\s+['"][^'"]*['"];?\s*\n?/g, '');
@@ -788,7 +870,17 @@ function ${importedExport.name}() {
788
870
  // This handles imports like: import { useEnvironment, otherThing } from "any/path"
789
871
  // Removes useEnvironment but keeps otherThing
790
872
  const namedImportRegExp = new RegExp(`(import\\s*\\{[^}]*?)\\b${escapeRegExp(firstPart)}\\b(?:,\\s*|\\s*,)?((?:[^}]*\\}\\s*from\\s*['"][^'"]*['"];?))`, 'm');
791
- if (importedExportNameParts.length > 1) {
873
+ // Check if any call signature has multiple parts (e.g., "logger.error(error)")
874
+ // If so, the mock code will spread from __cyOriginal, so we need to rename the import
875
+ // EXCEPT: For node_module imports, the __cyOriginal pattern doesn't work because
876
+ // the original package doesn't export *__cyOriginal variants.
877
+ const anyCallHasMultipleParts = importedExport.calls?.some((call) => {
878
+ const callParts = splitOutsideParenthesesAndArrays(call);
879
+ return callParts.length > 1;
880
+ });
881
+ const shouldRenameToOriginal = !importedExport.isNodeModule &&
882
+ (importedExportNameParts.length > 1 || anyCallHasMultipleParts);
883
+ if (shouldRenameToOriginal) {
792
884
  // Rename the import instead of removing (for destructured access patterns)
793
885
  fileContent = fileContent.replace(namedImportRegExp, `$1${firstPart}__cyOriginal$2`);
794
886
  }
@@ -1121,9 +1213,12 @@ export default async function writeScenarioComponents({ project, file, entity, r
1121
1213
  fileContentLength: fileContent.length,
1122
1214
  });
1123
1215
  let importedExportIndex = 0;
1216
+ const loopStartTime = Date.now();
1217
+ console.log(`[WriteScenario] Starting import loop for ${entity.name}: ${sortedImportedExports.length} imports`);
1124
1218
  for (const importedExport of sortedImportedExports) {
1125
1219
  importedExportIndex++;
1126
1220
  if (importedExportIndex % 5 === 0 || importedExportIndex === 1) {
1221
+ console.log(`[WriteScenario] ${entity.name} import ${importedExportIndex}/${sortedImportedExports.length}: ${importedExport.name} elapsed=${Date.now() - loopStartTime}ms`);
1127
1222
  debugLog(`Processing importedExport ${importedExportIndex}/${sortedImportedExports.length}`, {
1128
1223
  name: importedExport.name,
1129
1224
  filePath: importedExport.filePath,
@@ -1256,6 +1351,8 @@ export default async function writeScenarioComponents({ project, file, entity, r
1256
1351
  // e.g., if file has `export default X` but parent does `import { X } from '...'`
1257
1352
  const needsNamedReExport = importedExport.resolvedIsDefault === true &&
1258
1353
  importedExport.isDefault === false;
1354
+ console.log(`[WriteScenario] RECURSE START: ${entity.name} -> ${importedExportEntity.name}`);
1355
+ const recurseStartTime = Date.now();
1259
1356
  debugLog(`Recursing into writeScenarioComponents for ${importedExportEntity.name}`, {
1260
1357
  entityName: importedExportEntity.name,
1261
1358
  filePath: fileNotMocked.path,
@@ -1278,7 +1375,8 @@ export default async function writeScenarioComponents({ project, file, entity, r
1278
1375
  exportAsNamed: needsNamedReExport
1279
1376
  ? importedExport.name
1280
1377
  : undefined,
1281
- }), 60000);
1378
+ }), 180000);
1379
+ console.log(`[WriteScenario] RECURSE END: ${entity.name} -> ${importedExportEntity.name} took ${Date.now() - recurseStartTime}ms`);
1282
1380
  debugLog(`Completed recursive writeScenarioComponents for ${importedExportEntity.name}`);
1283
1381
  writtenScenarioComponents = updatedWrittenScenarioComponents;
1284
1382
  scenarioComponentPaths.push(...newScenarioComponentPaths);
@@ -1540,6 +1638,9 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1540
1638
  }
1541
1639
  }
1542
1640
  }
1641
+ // Track post-import-loop timing
1642
+ const postLoopStartTime = Date.now();
1643
+ console.log(`[WriteScenario] POST-LOOP START: ${entity.name}`);
1543
1644
  // Collect universal mocks BEFORE processing nodeModuleImports
1544
1645
  // This is needed to check if a node module import is handled by a universal mock
1545
1646
  const universalMocks = project.metadata?.universalMocks ?? [];
@@ -1573,6 +1674,7 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1573
1674
  const importRegex = new RegExp(`(import\\s+(?:\\{[^}]*\\}|\\*\\s+as\\s+\\w+|\\w+)\\s+from\\s+)['"]${originalPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}['"]`, 'g');
1574
1675
  fileContent = fileContent.replace(importRegex, `$1'${mockFileRelativePath}'`);
1575
1676
  }
1677
+ console.log(`[WriteScenario] POST-LOOP ${entity.name}: node+universal mocks took ${Date.now() - postLoopStartTime}ms`);
1576
1678
  if (rootAnalysis.entitySha === entity.sha &&
1577
1679
  entity.metadata?.notExported &&
1578
1680
  entity.name !== 'default') {
@@ -1632,6 +1734,7 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1632
1734
  debugLog('Starting rewriteRelativeModuleImports');
1633
1735
  fileContent = rewriteRelativeModuleImports(fileContent, `${PROJECT_RELATIVE_PATH}/${file.path}`, scenarioComponentPath);
1634
1736
  debugLog('Completed rewriteRelativeModuleImports');
1737
+ console.log(`[WriteScenario] POST-LOOP ${entity.name}: transformations took ${Date.now() - postLoopStartTime}ms`);
1635
1738
  /**
1636
1739
  * Recursively process a file's imports to create transitive copies with server-only stripped.
1637
1740
  * This handles chains of arbitrary depth: A -> B -> C -> D where each needs server-only removed.
@@ -1645,12 +1748,14 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1645
1748
  */
1646
1749
  async function processTransitiveImportsRecursively(content, sourceFilePath, targetFilePath, visitedPaths = new Set(), depth = 0, startTime = Date.now()) {
1647
1750
  // Global timeout for entire transitive processing
1648
- const GLOBAL_TIMEOUT_MS = 60000; // 1 minute max for all transitive processing
1751
+ const GLOBAL_TIMEOUT_MS = 180000; // 3 minutes max for all transitive processing (complex components need more time)
1649
1752
  const elapsed = Date.now() - startTime;
1650
1753
  if (elapsed > GLOBAL_TIMEOUT_MS) {
1651
1754
  throw new Error(`processTransitiveImportsRecursively exceeded ${GLOBAL_TIMEOUT_MS}ms (elapsed: ${elapsed}ms) at depth=${depth} for ${sourceFilePath}`);
1652
1755
  }
1653
1756
  const importPaths = extractInternalImportPaths(content);
1757
+ // Always log to help debug timeout issues
1758
+ console.log(`[TransitiveImports] depth=${depth} file=${path.basename(sourceFilePath)} imports=${importPaths.length} visited=${visitedPaths.size} elapsed=${Date.now() - startTime}ms`);
1654
1759
  debugLog(`processTransitiveImportsRecursively depth=${depth}`, {
1655
1760
  sourceFilePath,
1656
1761
  importCount: importPaths.length,
@@ -1687,8 +1792,10 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1687
1792
  const basePath = safeFolder(importFile.path.split('/').slice(0, -1).join('/'));
1688
1793
  const extension = importFile.name.split('.').pop();
1689
1794
  const isIndex = isIndexPath(importFile.path);
1690
- const pathHash = safeFileName(importFile.path);
1691
- const transitiveFilePath = `${PROJECT_RELATIVE_PATH}/${basePath}/${pathHash}_${isIndex ? 'index_' : ''}transitive_${safeFileName(scenario.name)}.${extension}`;
1795
+ // Limit pathHash length to prevent ENAMETOOLONG errors on macOS (255 char limit)
1796
+ const pathHash = safeFileName(importFile.path, { maxLength: 80 });
1797
+ const scenarioSlug = safeFileName(scenario.name, { maxLength: 60 });
1798
+ const transitiveFilePath = `${PROJECT_RELATIVE_PATH}/${basePath}/${pathHash}_${isIndex ? 'index_' : ''}transitive_${scenarioSlug}.${extension}`;
1692
1799
  // Check if this is a circular import (we're already processing this file)
1693
1800
  const isCircularImport = visitedPaths.has(resolvedPath);
1694
1801
  // Check if already processed
@@ -1766,6 +1873,7 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1766
1873
  debugLog(`Returning from processTransitiveImportsRecursively depth=${depth}`);
1767
1874
  return modifiedContent;
1768
1875
  }
1876
+ console.log(`[WriteScenario] POST-LOOP ${entity.name}: before remaining imports ${Date.now() - postLoopStartTime}ms`);
1769
1877
  // Process remaining internal imports that weren't in importedExports
1770
1878
  // This handles transitive dependencies: when the file content includes code (e.g., from
1771
1879
  // other functions in the same file) that imports from files with "server-only"
@@ -1823,8 +1931,10 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1823
1931
  const targetFileBasePath = safeFolder(targetFile.path.split('/').slice(0, -1).join('/'));
1824
1932
  const targetFileExtension = targetFile.name.split('.').pop();
1825
1933
  const targetFileIsIndex = isIndexPath(targetFile.path);
1826
- const filePathHash = safeFileName(targetFile.path);
1827
- const transformedFilePath = `${PROJECT_RELATIVE_PATH}/${targetFileBasePath}/${filePathHash}_${targetFileIsIndex ? 'index_' : ''}transitive_${safeFileName(scenario.name)}.${targetFileExtension}`;
1934
+ // Limit path hash length to prevent ENAMETOOLONG errors
1935
+ const filePathHash = safeFileName(targetFile.path, { maxLength: 80 });
1936
+ const targetScenarioSlug = safeFileName(scenario.name, { maxLength: 60 });
1937
+ const transformedFilePath = `${PROJECT_RELATIVE_PATH}/${targetFileBasePath}/${filePathHash}_${targetFileIsIndex ? 'index_' : ''}transitive_${targetScenarioSlug}.${targetFileExtension}`;
1828
1938
  // Check if we've already processed this file as a transitive copy
1829
1939
  // Note: __data_file_written__ is for entity-specific scenario files with different naming,
1830
1940
  // but we still need transitive copies for server-only stripping. Data entity files may
@@ -1863,8 +1973,12 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1863
1973
  const nestedBasePath = safeFolder(nestedFile.path.split('/').slice(0, -1).join('/'));
1864
1974
  const nestedExtension = nestedFile.name.split('.').pop();
1865
1975
  const nestedIsIndex = isIndexPath(nestedFile.path);
1866
- const nestedPathHash = safeFileName(nestedFile.path);
1867
- const nestedTransformedPath = `${PROJECT_RELATIVE_PATH}/${nestedBasePath}/${nestedPathHash}_${nestedIsIndex ? 'index_' : ''}transitive_${safeFileName(scenario.name)}.${nestedExtension}`;
1976
+ // Limit path hash length to prevent ENAMETOOLONG errors
1977
+ const nestedPathHash = safeFileName(nestedFile.path, { maxLength: 80 });
1978
+ const nestedScenarioSlug = safeFileName(scenario.name, {
1979
+ maxLength: 60,
1980
+ });
1981
+ const nestedTransformedPath = `${PROJECT_RELATIVE_PATH}/${nestedBasePath}/${nestedPathHash}_${nestedIsIndex ? 'index_' : ''}transitive_${nestedScenarioSlug}.${nestedExtension}`;
1868
1982
  // Check if already processed as a transitive file (we can rewrite to point to it)
1869
1983
  // Note: __data_file_written__ is for entity-specific scenario files with different naming,
1870
1984
  // but we still need transitive copies for server-only stripping in the import chain
@@ -1930,6 +2044,7 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1930
2044
  const importRegex = new RegExp(`(from\\s*["'])${escapedImportPath}(["'])`, 'g');
1931
2045
  fileContent = fileContent.replace(importRegex, `$1${safeRelativePath}$2`);
1932
2046
  }
2047
+ console.log(`[WriteScenario] POST-LOOP ${entity.name}: remaining imports loop took ${Date.now() - postLoopStartTime}ms`);
1933
2048
  const scenarioComponentComment = `// This file is auto-generated by CodeYam. Do not edit this file manually.
1934
2049
  // This file contains content for a scenario component:
1935
2050
  // Analyses being written: ${JSON.stringify(fileAnalyses?.map((a) => ({ id: a.id, entityName: a.entityName })))}
@@ -1940,6 +2055,23 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1940
2055
  // Entity: ${rootAnalysis.entitySha} ${rootAnalysis.entityName}
1941
2056
  // Scenario: ${scenario.id} - ${scenario.name}
1942
2057
  `;
2058
+ // Final pass: Rename any namespace imports (import * as X from '...') that have
2059
+ // corresponding mock code using ...X__cyOriginal spread pattern.
2060
+ // This handles cases where:
2061
+ // 1. The import path was rewritten by transitive import handling
2062
+ // 2. The import wasn't caught by the earlier renaming logic
2063
+ // We scan for all __cyOriginal references in the mock code and ensure the imports are renamed.
2064
+ const cyOriginalReferences = fileContent.match(/\.\.\.(\w+)__cyOriginal/g);
2065
+ if (cyOriginalReferences) {
2066
+ const uniqueNames = [
2067
+ ...new Set(cyOriginalReferences.map((ref) => ref.replace('...', '').replace('__cyOriginal', ''))),
2068
+ ];
2069
+ for (const name of uniqueNames) {
2070
+ // Match namespace imports for this name that haven't been renamed yet
2071
+ const namespaceImportRegex = new RegExp(`(import\\s+\\*\\s+as\\s+)${escapeRegExp(name)}(\\s+from\\s+['"][^'"]*['"])`, 'g');
2072
+ fileContent = fileContent.replace(namespaceImportRegex, `$1${name}__cyOriginal$2`);
2073
+ }
2074
+ }
1943
2075
  // Use the directive that was extracted at the beginning of processing
1944
2076
  // This ensures it stays at the very top even after imports are prepended
1945
2077
  // NOTE: We only preserve "use client" directives, NOT "use server" directives.
@@ -1960,6 +2092,7 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1960
2092
  await writeFile(scenarioComponentPath, finalContent);
1961
2093
  debugLog('Successfully wrote scenario file');
1962
2094
  scenarioComponentPaths.push(scenarioComponentPath);
2095
+ console.log(`[WriteScenario] POST-LOOP ${entity.name}: COMPLETE total=${Date.now() - postLoopStartTime}ms`);
1963
2096
  return { scenarioComponentPaths, writtenScenarioComponents };
1964
2097
  }
1965
2098
  //# sourceMappingURL=writeScenarioComponents.js.map