@codeyam/codeyam-cli 0.1.0-staging.596f0eb → 0.1.0-staging.5fba2e4

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 (1351) 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 +32 -28
  5. package/analyzer-template/packages/ai/index.ts +21 -5
  6. package/analyzer-template/packages/ai/package.json +4 -4
  7. package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
  8. package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +228 -24
  9. package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
  10. package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +239 -13
  11. package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
  12. package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +181 -23
  13. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
  14. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
  15. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +38 -1
  16. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
  17. package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +1619 -125
  18. package/analyzer-template/packages/ai/src/lib/astScopes/sharedPatterns.ts +28 -0
  19. package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +324 -5
  20. package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
  21. package/analyzer-template/packages/ai/src/lib/completionCall.ts +247 -66
  22. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +2762 -387
  23. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +7 -2
  24. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +976 -0
  25. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +243 -77
  26. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.ts +16 -3
  27. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +6 -4
  28. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +71 -2
  29. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +161 -19
  30. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
  31. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coercePrimitivesToArraysBySchema.ts +62 -0
  32. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +163 -14
  33. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
  34. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +179 -0
  35. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.ts +40 -30
  36. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +422 -86
  37. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
  38. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/stripNullableMarkers.ts +35 -0
  39. package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +183 -0
  40. package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
  41. package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
  42. package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
  43. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +74 -7
  44. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +89 -112
  45. package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +63 -2
  46. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1497 -92
  47. package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +216 -109
  48. package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +677 -0
  49. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
  50. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +2484 -0
  51. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
  52. package/analyzer-template/packages/ai/src/lib/getConditionalUsagesFromCode.ts +143 -31
  53. package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +8 -2
  54. package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +328 -7
  55. package/analyzer-template/packages/ai/src/lib/mergeJsonTypeDefinitions.ts +5 -0
  56. package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +111 -87
  57. package/analyzer-template/packages/ai/src/lib/promptGenerators/collapseNullableObjects.ts +118 -0
  58. package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +17 -7
  59. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
  60. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -102
  61. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
  62. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
  63. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +110 -6
  64. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -53
  65. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
  66. package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +28 -2
  67. package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
  68. package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +824 -0
  69. package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
  70. package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
  71. package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +127 -3
  72. package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +121 -2
  73. package/analyzer-template/packages/analyze/index.ts +2 -0
  74. package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +79 -59
  75. package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +132 -33
  76. package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
  77. package/analyzer-template/packages/analyze/src/lib/asts/index.ts +7 -2
  78. package/analyzer-template/packages/analyze/src/lib/asts/nodes/getNodeType.ts +1 -0
  79. package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +1 -0
  80. package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
  81. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.ts +19 -0
  82. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.ts +19 -0
  83. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +11 -0
  84. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.ts +8 -0
  85. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.ts +49 -1
  86. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.ts +2 -1
  87. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +540 -272
  88. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +42 -1
  89. package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +15 -0
  90. package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
  91. package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -10
  92. package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +31 -15
  93. package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
  94. package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
  95. package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
  96. package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
  97. package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +14 -12
  98. package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1352 -0
  99. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +313 -0
  100. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
  101. package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +675 -77
  102. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
  103. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
  104. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +633 -137
  105. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +166 -0
  106. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +78 -83
  107. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +4 -8
  108. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +1031 -148
  109. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
  110. package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
  111. package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
  112. package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
  113. package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
  114. package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
  115. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
  116. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
  117. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
  118. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
  119. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
  120. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
  121. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
  122. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
  123. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
  124. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
  125. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
  126. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
  127. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts +15 -0
  128. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts.map +1 -0
  129. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js +31 -0
  130. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js.map +1 -0
  131. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
  132. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
  133. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
  134. package/analyzer-template/packages/aws/package.json +10 -10
  135. package/analyzer-template/packages/aws/s3/index.ts +1 -0
  136. package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
  137. package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
  138. package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
  139. package/analyzer-template/packages/aws/src/lib/s3/checkS3ObjectExists.ts +47 -0
  140. package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
  141. package/analyzer-template/packages/database/index.ts +1 -0
  142. package/analyzer-template/packages/database/package.json +4 -4
  143. package/analyzer-template/packages/database/src/lib/analysisBranchToDb.ts +1 -1
  144. package/analyzer-template/packages/database/src/lib/analysisToDb.ts +1 -1
  145. package/analyzer-template/packages/database/src/lib/branchToDb.ts +1 -1
  146. package/analyzer-template/packages/database/src/lib/commitBranchToDb.ts +1 -1
  147. package/analyzer-template/packages/database/src/lib/commitToDb.ts +1 -1
  148. package/analyzer-template/packages/database/src/lib/fileToDb.ts +1 -1
  149. package/analyzer-template/packages/database/src/lib/kysely/db.ts +26 -5
  150. package/analyzer-template/packages/database/src/lib/kysely/tableRelations.ts +2 -2
  151. package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
  152. package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +36 -9
  153. package/analyzer-template/packages/database/src/lib/kysely/tables/editorScenariosTable.ts +82 -0
  154. package/analyzer-template/packages/database/src/lib/kysely/tables/labsRequestsTable.ts +52 -0
  155. package/analyzer-template/packages/database/src/lib/loadAnalyses.ts +58 -1
  156. package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +13 -0
  157. package/analyzer-template/packages/database/src/lib/loadBranch.ts +16 -1
  158. package/analyzer-template/packages/database/src/lib/loadCommit.ts +11 -0
  159. package/analyzer-template/packages/database/src/lib/loadCommits.ts +58 -19
  160. package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -3
  161. package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
  162. package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +5 -6
  163. package/analyzer-template/packages/database/src/lib/projectToDb.ts +1 -1
  164. package/analyzer-template/packages/database/src/lib/saveFiles.ts +1 -1
  165. package/analyzer-template/packages/database/src/lib/scenarioToDb.ts +1 -1
  166. package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +153 -144
  167. package/analyzer-template/packages/database/src/lib/updateFreshAnalysisStatus.ts +58 -42
  168. package/analyzer-template/packages/database/src/lib/updateFreshAnalysisStatusWithScenarios.ts +81 -65
  169. package/analyzer-template/packages/database/src/lib/userScenarioToDb.ts +1 -1
  170. package/analyzer-template/packages/generate/index.ts +3 -0
  171. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +17 -1
  172. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +221 -0
  173. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
  174. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +42 -9
  175. package/analyzer-template/packages/generate/src/lib/deepMerge.ts +26 -1
  176. package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
  177. package/analyzer-template/packages/github/dist/database/index.d.ts +1 -0
  178. package/analyzer-template/packages/github/dist/database/index.d.ts.map +1 -1
  179. package/analyzer-template/packages/github/dist/database/index.js +1 -0
  180. package/analyzer-template/packages/github/dist/database/index.js.map +1 -1
  181. package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js +1 -1
  182. package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js.map +1 -1
  183. package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js +1 -1
  184. package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js.map +1 -1
  185. package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js +1 -1
  186. package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js.map +1 -1
  187. package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js +1 -1
  188. package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js.map +1 -1
  189. package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js +1 -1
  190. package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js.map +1 -1
  191. package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js +1 -1
  192. package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js.map +1 -1
  193. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +6 -2
  194. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
  195. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +18 -3
  196. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
  197. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tableRelations.d.ts +2 -2
  198. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +1 -11
  199. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
  200. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts +1 -0
  201. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts.map +1 -1
  202. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js +3 -0
  203. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
  204. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +30 -7
  205. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
  206. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
  207. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  208. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts +24 -0
  209. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts.map +1 -0
  210. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js +65 -0
  211. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -0
  212. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
  213. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
  214. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts +23 -0
  215. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts.map +1 -0
  216. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
  217. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
  218. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +7 -6
  219. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
  220. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts +2 -0
  221. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts.map +1 -1
  222. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js +45 -2
  223. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js.map +1 -1
  224. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
  225. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +8 -0
  226. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
  227. package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js +11 -1
  228. package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js.map +1 -1
  229. package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.d.ts.map +1 -1
  230. package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js +7 -0
  231. package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js.map +1 -1
  232. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts +3 -1
  233. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts.map +1 -1
  234. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +45 -14
  235. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js.map +1 -1
  236. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts +3 -1
  237. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
  238. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +23 -4
  239. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
  240. package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.d.ts.map +1 -1
  241. package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js +9 -0
  242. package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js.map +1 -1
  243. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
  244. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +5 -5
  245. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  246. package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js +1 -1
  247. package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js.map +1 -1
  248. package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js +1 -1
  249. package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js.map +1 -1
  250. package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js +1 -1
  251. package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js.map +1 -1
  252. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts +2 -2
  253. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
  254. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +100 -88
  255. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
  256. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatus.d.ts.map +1 -1
  257. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatus.js +41 -30
  258. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatus.js.map +1 -1
  259. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatusWithScenarios.d.ts.map +1 -1
  260. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatusWithScenarios.js +68 -57
  261. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatusWithScenarios.js.map +1 -1
  262. package/analyzer-template/packages/github/dist/generate/index.d.ts +3 -0
  263. package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
  264. package/analyzer-template/packages/github/dist/generate/index.js +3 -0
  265. package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
  266. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
  267. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
  268. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  269. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
  270. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
  271. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +217 -0
  272. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
  273. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
  274. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
  275. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
  276. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
  277. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
  278. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +41 -9
  279. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  280. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.d.ts.map +1 -1
  281. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js +27 -1
  282. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js.map +1 -1
  283. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
  284. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
  285. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
  286. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
  287. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
  288. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
  289. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
  290. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
  291. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
  292. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
  293. package/analyzer-template/packages/github/dist/types/index.d.ts +2 -2
  294. package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
  295. package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
  296. package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.d.ts +2 -0
  297. package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.d.ts.map +1 -1
  298. package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.js +2 -0
  299. package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.js.map +1 -1
  300. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +87 -13
  301. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
  302. package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts +2 -0
  303. package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts.map +1 -1
  304. package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
  305. package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
  306. package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +8 -0
  307. package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
  308. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +21 -6
  309. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
  310. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +199 -3
  311. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  312. package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
  313. package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
  314. package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts +2 -0
  315. package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts.map +1 -1
  316. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
  317. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
  318. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  319. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
  320. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
  321. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
  322. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
  323. package/analyzer-template/packages/github/package.json +2 -2
  324. package/analyzer-template/packages/github/src/lib/loadOrCreateCommit.ts +14 -0
  325. package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
  326. package/analyzer-template/packages/process/index.ts +2 -0
  327. package/analyzer-template/packages/process/package.json +12 -0
  328. package/analyzer-template/packages/process/tsconfig.json +8 -0
  329. package/analyzer-template/packages/types/index.ts +5 -0
  330. package/analyzer-template/packages/types/src/enums/ProjectFramework.ts +2 -0
  331. package/analyzer-template/packages/types/src/types/Analysis.ts +104 -13
  332. package/analyzer-template/packages/types/src/types/Commit.ts +2 -0
  333. package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
  334. package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +8 -0
  335. package/analyzer-template/packages/types/src/types/Scenario.ts +21 -10
  336. package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +228 -3
  337. package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
  338. package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
  339. package/analyzer-template/packages/ui-components/package.json +1 -1
  340. package/analyzer-template/packages/ui-components/src/components/ScenarioDetailInteractiveView.tsx +23 -7
  341. package/analyzer-template/packages/utils/dist/types/index.d.ts +2 -2
  342. package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
  343. package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
  344. package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.d.ts +2 -0
  345. package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.d.ts.map +1 -1
  346. package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.js +2 -0
  347. package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.js.map +1 -1
  348. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +87 -13
  349. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
  350. package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts +2 -0
  351. package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts.map +1 -1
  352. package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
  353. package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
  354. package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +8 -0
  355. package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
  356. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +21 -6
  357. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
  358. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +199 -3
  359. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  360. package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
  361. package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
  362. package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
  363. package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts.map +1 -1
  364. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts.map +1 -1
  365. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js +98 -3
  366. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js.map +1 -1
  367. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
  368. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
  369. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  370. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
  371. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
  372. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
  373. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
  374. package/analyzer-template/packages/utils/src/lib/fs/rsyncCopy.ts +121 -3
  375. package/analyzer-template/packages/utils/src/lib/lightweightEntityExtractor.ts +27 -0
  376. package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
  377. package/analyzer-template/playwright/capture.ts +57 -26
  378. package/analyzer-template/playwright/captureFromUrl.ts +89 -82
  379. package/analyzer-template/playwright/captureStatic.ts +1 -1
  380. package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
  381. package/analyzer-template/playwright/takeElementScreenshot.ts +26 -11
  382. package/analyzer-template/playwright/takeScreenshot.ts +9 -7
  383. package/analyzer-template/playwright/waitForServer.ts +21 -6
  384. package/analyzer-template/project/analyzeBaselineCommit.ts +9 -0
  385. package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
  386. package/analyzer-template/project/analyzeFileEntities.ts +4 -0
  387. package/analyzer-template/project/analyzeRegularCommit.ts +9 -0
  388. package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
  389. package/analyzer-template/project/constructMockCode.ts +1410 -189
  390. package/analyzer-template/project/controller/startController.ts +16 -1
  391. package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
  392. package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
  393. package/analyzer-template/project/loadReadyToBeCaptured.ts +65 -41
  394. package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
  395. package/analyzer-template/project/orchestrateCapture/AwsCaptureTaskRunner.ts +12 -4
  396. package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +3 -6
  397. package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +93 -42
  398. package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
  399. package/analyzer-template/project/orchestrateCapture.ts +85 -10
  400. package/analyzer-template/project/reconcileMockDataKeys.ts +251 -3
  401. package/analyzer-template/project/runAnalysis.ts +11 -0
  402. package/analyzer-template/project/runMultiScenarioServer.ts +11 -10
  403. package/analyzer-template/project/serverOnlyModules.ts +194 -21
  404. package/analyzer-template/project/start.ts +64 -15
  405. package/analyzer-template/project/startScenarioCapture.ts +88 -41
  406. package/analyzer-template/project/writeClientLogRoute.ts +125 -0
  407. package/analyzer-template/project/writeMockDataTsx.ts +430 -65
  408. package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
  409. package/analyzer-template/project/writeScenarioComponents.ts +969 -197
  410. package/analyzer-template/project/writeScenarioFiles.ts +26 -0
  411. package/analyzer-template/project/writeSimpleRoot.ts +31 -23
  412. package/analyzer-template/scripts/comboWorkerLoop.cjs +99 -50
  413. package/analyzer-template/scripts/defaultCmd.sh +9 -0
  414. package/analyzer-template/tsconfig.json +14 -1
  415. package/background/src/lib/local/createLocalAnalyzer.js +2 -30
  416. package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
  417. package/background/src/lib/local/execAsync.js +1 -1
  418. package/background/src/lib/local/execAsync.js.map +1 -1
  419. package/background/src/lib/virtualized/common/execAsync.js +1 -1
  420. package/background/src/lib/virtualized/common/execAsync.js.map +1 -1
  421. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +7 -1
  422. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
  423. package/background/src/lib/virtualized/project/analyzeBranchCommit.js +2 -1
  424. package/background/src/lib/virtualized/project/analyzeBranchCommit.js.map +1 -1
  425. package/background/src/lib/virtualized/project/analyzeFileEntities.js +2 -1
  426. package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
  427. package/background/src/lib/virtualized/project/analyzeRegularCommit.js +7 -1
  428. package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
  429. package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js +3 -3
  430. package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js.map +1 -1
  431. package/background/src/lib/virtualized/project/constructMockCode.js +1245 -141
  432. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  433. package/background/src/lib/virtualized/project/controller/startController.js +11 -1
  434. package/background/src/lib/virtualized/project/controller/startController.js.map +1 -1
  435. package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js +73 -1
  436. package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js.map +1 -1
  437. package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js +6 -3
  438. package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js.map +1 -1
  439. package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js +19 -8
  440. package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js.map +1 -1
  441. package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js +7 -7
  442. package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js.map +1 -1
  443. package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js +2 -2
  444. package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js.map +1 -1
  445. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +3 -2
  446. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
  447. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +73 -36
  448. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
  449. package/background/src/lib/virtualized/project/orchestrateCapture.js +69 -11
  450. package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
  451. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +211 -3
  452. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
  453. package/background/src/lib/virtualized/project/runAnalysis.js +9 -0
  454. package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
  455. package/background/src/lib/virtualized/project/runMultiScenarioServer.js +11 -9
  456. package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
  457. package/background/src/lib/virtualized/project/serverOnlyModules.js +163 -23
  458. package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
  459. package/background/src/lib/virtualized/project/start.js +55 -15
  460. package/background/src/lib/virtualized/project/start.js.map +1 -1
  461. package/background/src/lib/virtualized/project/startScenarioCapture.js +66 -31
  462. package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
  463. package/background/src/lib/virtualized/project/writeClientLogRoute.js +110 -0
  464. package/background/src/lib/virtualized/project/writeClientLogRoute.js.map +1 -0
  465. package/background/src/lib/virtualized/project/writeMockDataTsx.js +373 -54
  466. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  467. package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js +15 -0
  468. package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js.map +1 -0
  469. package/background/src/lib/virtualized/project/writeScenarioComponents.js +705 -137
  470. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  471. package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
  472. package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
  473. package/background/src/lib/virtualized/project/writeSimpleRoot.js +31 -21
  474. package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
  475. package/codeyam-cli/scripts/apply-setup.js +386 -9
  476. package/codeyam-cli/scripts/apply-setup.js.map +1 -1
  477. package/codeyam-cli/src/__tests__/memory-scripts/filter-session.test.js +196 -0
  478. package/codeyam-cli/src/__tests__/memory-scripts/filter-session.test.js.map +1 -0
  479. package/codeyam-cli/src/__tests__/memory-scripts/read-json-field.test.js +114 -0
  480. package/codeyam-cli/src/__tests__/memory-scripts/read-json-field.test.js.map +1 -0
  481. package/codeyam-cli/src/__tests__/memory-scripts/ripgrep-fallback.test.js +149 -0
  482. package/codeyam-cli/src/__tests__/memory-scripts/ripgrep-fallback.test.js.map +1 -0
  483. package/codeyam-cli/src/cli.js +39 -22
  484. package/codeyam-cli/src/cli.js.map +1 -1
  485. package/codeyam-cli/src/codeyam-cli.js +18 -2
  486. package/codeyam-cli/src/codeyam-cli.js.map +1 -1
  487. package/codeyam-cli/src/commands/analyze.js +22 -10
  488. package/codeyam-cli/src/commands/analyze.js.map +1 -1
  489. package/codeyam-cli/src/commands/baseline.js +176 -0
  490. package/codeyam-cli/src/commands/baseline.js.map +1 -0
  491. package/codeyam-cli/src/commands/debug.js +44 -18
  492. package/codeyam-cli/src/commands/debug.js.map +1 -1
  493. package/codeyam-cli/src/commands/default.js +43 -35
  494. package/codeyam-cli/src/commands/default.js.map +1 -1
  495. package/codeyam-cli/src/commands/editor.js +2769 -0
  496. package/codeyam-cli/src/commands/editor.js.map +1 -0
  497. package/codeyam-cli/src/commands/init.js +81 -260
  498. package/codeyam-cli/src/commands/init.js.map +1 -1
  499. package/codeyam-cli/src/commands/memory.js +278 -0
  500. package/codeyam-cli/src/commands/memory.js.map +1 -0
  501. package/codeyam-cli/src/commands/recapture.js +228 -0
  502. package/codeyam-cli/src/commands/recapture.js.map +1 -0
  503. package/codeyam-cli/src/commands/report.js +72 -24
  504. package/codeyam-cli/src/commands/report.js.map +1 -1
  505. package/codeyam-cli/src/commands/setup-sandbox.js +2 -0
  506. package/codeyam-cli/src/commands/setup-sandbox.js.map +1 -1
  507. package/codeyam-cli/src/commands/setup-simulations.js +284 -0
  508. package/codeyam-cli/src/commands/setup-simulations.js.map +1 -0
  509. package/codeyam-cli/src/commands/start.js +8 -12
  510. package/codeyam-cli/src/commands/start.js.map +1 -1
  511. package/codeyam-cli/src/commands/status.js +23 -1
  512. package/codeyam-cli/src/commands/status.js.map +1 -1
  513. package/codeyam-cli/src/commands/test-startup.js +3 -1
  514. package/codeyam-cli/src/commands/test-startup.js.map +1 -1
  515. package/codeyam-cli/src/commands/verify.js +14 -2
  516. package/codeyam-cli/src/commands/verify.js.map +1 -1
  517. package/codeyam-cli/src/commands/wipe.js +108 -0
  518. package/codeyam-cli/src/commands/wipe.js.map +1 -0
  519. package/codeyam-cli/src/data/techStacks.js +77 -0
  520. package/codeyam-cli/src/data/techStacks.js.map +1 -0
  521. package/codeyam-cli/src/utils/__tests__/devServerState.test.js +134 -0
  522. package/codeyam-cli/src/utils/__tests__/devServerState.test.js.map +1 -0
  523. package/codeyam-cli/src/utils/__tests__/editorApi.test.js +127 -0
  524. package/codeyam-cli/src/utils/__tests__/editorApi.test.js.map +1 -0
  525. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +635 -0
  526. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -0
  527. package/codeyam-cli/src/utils/__tests__/editorCapture.test.js +93 -0
  528. package/codeyam-cli/src/utils/__tests__/editorCapture.test.js.map +1 -0
  529. package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js +304 -0
  530. package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js.map +1 -0
  531. package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js +121 -0
  532. package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js.map +1 -0
  533. package/codeyam-cli/src/utils/__tests__/editorImageVerifier.test.js +294 -0
  534. package/codeyam-cli/src/utils/__tests__/editorImageVerifier.test.js.map +1 -0
  535. package/codeyam-cli/src/utils/__tests__/editorJournal.test.js +542 -0
  536. package/codeyam-cli/src/utils/__tests__/editorJournal.test.js.map +1 -0
  537. package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js +393 -0
  538. package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js.map +1 -0
  539. package/codeyam-cli/src/utils/__tests__/editorMockState.test.js +270 -0
  540. package/codeyam-cli/src/utils/__tests__/editorMockState.test.js.map +1 -0
  541. package/codeyam-cli/src/utils/__tests__/editorPreloadHelpers.test.js +217 -0
  542. package/codeyam-cli/src/utils/__tests__/editorPreloadHelpers.test.js.map +1 -0
  543. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +266 -0
  544. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -0
  545. package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js +107 -0
  546. package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js.map +1 -0
  547. package/codeyam-cli/src/utils/__tests__/editorScenarioLookup.test.js +139 -0
  548. package/codeyam-cli/src/utils/__tests__/editorScenarioLookup.test.js.map +1 -0
  549. package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js +221 -0
  550. package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js.map +1 -0
  551. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +275 -0
  552. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -0
  553. package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js +213 -0
  554. package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js.map +1 -0
  555. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +1737 -0
  556. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -0
  557. package/codeyam-cli/src/utils/__tests__/git.editor.test.js +134 -0
  558. package/codeyam-cli/src/utils/__tests__/git.editor.test.js.map +1 -0
  559. package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js +107 -0
  560. package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js.map +1 -0
  561. package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js +185 -0
  562. package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js.map +1 -0
  563. package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js +101 -0
  564. package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js.map +1 -0
  565. package/codeyam-cli/src/utils/__tests__/pathIgnoring.test.js +9 -0
  566. package/codeyam-cli/src/utils/__tests__/pathIgnoring.test.js.map +1 -1
  567. package/codeyam-cli/src/utils/__tests__/project.test.js +65 -0
  568. package/codeyam-cli/src/utils/__tests__/project.test.js.map +1 -0
  569. package/codeyam-cli/src/utils/__tests__/scenarioMarkers.test.js +121 -0
  570. package/codeyam-cli/src/utils/__tests__/scenarioMarkers.test.js.map +1 -0
  571. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js +246 -0
  572. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js.map +1 -0
  573. package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js +81 -0
  574. package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js.map +1 -0
  575. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +174 -82
  576. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
  577. package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js +51 -0
  578. package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js.map +1 -0
  579. package/codeyam-cli/src/utils/__tests__/webappDetection.test.js +142 -0
  580. package/codeyam-cli/src/utils/__tests__/webappDetection.test.js.map +1 -0
  581. package/codeyam-cli/src/utils/analysisRunner.js +29 -15
  582. package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
  583. package/codeyam-cli/src/utils/analyzer.js +7 -0
  584. package/codeyam-cli/src/utils/analyzer.js.map +1 -1
  585. package/codeyam-cli/src/utils/backgroundServer.js +235 -29
  586. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  587. package/codeyam-cli/src/utils/buildFlags.js +4 -0
  588. package/codeyam-cli/src/utils/buildFlags.js.map +1 -0
  589. package/codeyam-cli/src/utils/database.js +91 -5
  590. package/codeyam-cli/src/utils/database.js.map +1 -1
  591. package/codeyam-cli/src/utils/devModeEvents.js +40 -0
  592. package/codeyam-cli/src/utils/devModeEvents.js.map +1 -0
  593. package/codeyam-cli/src/utils/devServerState.js +71 -0
  594. package/codeyam-cli/src/utils/devServerState.js.map +1 -0
  595. package/codeyam-cli/src/utils/editorApi.js +73 -0
  596. package/codeyam-cli/src/utils/editorApi.js.map +1 -0
  597. package/codeyam-cli/src/utils/editorAudit.js +159 -0
  598. package/codeyam-cli/src/utils/editorAudit.js.map +1 -0
  599. package/codeyam-cli/src/utils/editorCapture.js +102 -0
  600. package/codeyam-cli/src/utils/editorCapture.js.map +1 -0
  601. package/codeyam-cli/src/utils/editorDevServer.js +197 -0
  602. package/codeyam-cli/src/utils/editorDevServer.js.map +1 -0
  603. package/codeyam-cli/src/utils/editorEntityChangeStatus.js +44 -0
  604. package/codeyam-cli/src/utils/editorEntityChangeStatus.js.map +1 -0
  605. package/codeyam-cli/src/utils/editorImageVerifier.js +155 -0
  606. package/codeyam-cli/src/utils/editorImageVerifier.js.map +1 -0
  607. package/codeyam-cli/src/utils/editorJournal.js +225 -0
  608. package/codeyam-cli/src/utils/editorJournal.js.map +1 -0
  609. package/codeyam-cli/src/utils/editorLoaderHelpers.js +81 -0
  610. package/codeyam-cli/src/utils/editorLoaderHelpers.js.map +1 -0
  611. package/codeyam-cli/src/utils/editorMockState.js +248 -0
  612. package/codeyam-cli/src/utils/editorMockState.js.map +1 -0
  613. package/codeyam-cli/src/utils/editorPreloadHelpers.js +135 -0
  614. package/codeyam-cli/src/utils/editorPreloadHelpers.js.map +1 -0
  615. package/codeyam-cli/src/utils/editorPreview.js +106 -0
  616. package/codeyam-cli/src/utils/editorPreview.js.map +1 -0
  617. package/codeyam-cli/src/utils/editorScenarioSwitch.js +112 -0
  618. package/codeyam-cli/src/utils/editorScenarioSwitch.js.map +1 -0
  619. package/codeyam-cli/src/utils/editorScenarios.js +126 -0
  620. package/codeyam-cli/src/utils/editorScenarios.js.map +1 -0
  621. package/codeyam-cli/src/utils/editorSeedAdapter.js +173 -0
  622. package/codeyam-cli/src/utils/editorSeedAdapter.js.map +1 -0
  623. package/codeyam-cli/src/utils/entityChangeStatus.js +347 -0
  624. package/codeyam-cli/src/utils/entityChangeStatus.js.map +1 -0
  625. package/codeyam-cli/src/utils/entityChangeStatus.server.js +158 -0
  626. package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -0
  627. package/codeyam-cli/src/utils/fileMetadata.js +5 -0
  628. package/codeyam-cli/src/utils/fileMetadata.js.map +1 -1
  629. package/codeyam-cli/src/utils/fileWatcher.js +25 -9
  630. package/codeyam-cli/src/utils/fileWatcher.js.map +1 -1
  631. package/codeyam-cli/src/utils/generateReport.js +253 -106
  632. package/codeyam-cli/src/utils/generateReport.js.map +1 -1
  633. package/codeyam-cli/src/utils/git.js +182 -0
  634. package/codeyam-cli/src/utils/git.js.map +1 -0
  635. package/codeyam-cli/src/utils/install-skills.js +120 -39
  636. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  637. package/codeyam-cli/src/utils/interactiveSyncWatcher.js +126 -0
  638. package/codeyam-cli/src/utils/interactiveSyncWatcher.js.map +1 -0
  639. package/codeyam-cli/src/utils/labsAutoCheck.js +19 -0
  640. package/codeyam-cli/src/utils/labsAutoCheck.js.map +1 -0
  641. package/codeyam-cli/src/utils/npmVersionCheck.js +76 -0
  642. package/codeyam-cli/src/utils/npmVersionCheck.js.map +1 -0
  643. package/codeyam-cli/src/utils/parseRegisterArg.js +31 -0
  644. package/codeyam-cli/src/utils/parseRegisterArg.js.map +1 -0
  645. package/codeyam-cli/src/utils/pathIgnoring.js +19 -7
  646. package/codeyam-cli/src/utils/pathIgnoring.js.map +1 -1
  647. package/codeyam-cli/src/utils/progress.js +7 -0
  648. package/codeyam-cli/src/utils/progress.js.map +1 -1
  649. package/codeyam-cli/src/utils/project.js +15 -5
  650. package/codeyam-cli/src/utils/project.js.map +1 -1
  651. package/codeyam-cli/src/utils/queue/__tests__/heartbeat.test.js +11 -11
  652. package/codeyam-cli/src/utils/queue/__tests__/heartbeat.test.js.map +1 -1
  653. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +60 -0
  654. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
  655. package/codeyam-cli/src/utils/queue/heartbeat.js +13 -5
  656. package/codeyam-cli/src/utils/queue/heartbeat.js.map +1 -1
  657. package/codeyam-cli/src/utils/queue/job.js +319 -17
  658. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  659. package/codeyam-cli/src/utils/queue/manager.js +26 -7
  660. package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
  661. package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
  662. package/codeyam-cli/src/utils/requireSimulations.js +10 -0
  663. package/codeyam-cli/src/utils/requireSimulations.js.map +1 -0
  664. package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js +82 -0
  665. package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
  666. package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +229 -0
  667. package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
  668. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
  669. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
  670. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
  671. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
  672. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
  673. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
  674. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
  675. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
  676. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +74 -0
  677. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
  678. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +376 -0
  679. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
  680. package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +113 -0
  681. package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -0
  682. package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js +127 -0
  683. package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js.map +1 -0
  684. package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js +50 -0
  685. package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js.map +1 -0
  686. package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +116 -0
  687. package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -0
  688. package/codeyam-cli/src/utils/ruleReflection/index.js +5 -0
  689. package/codeyam-cli/src/utils/ruleReflection/index.js.map +1 -0
  690. package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js +44 -0
  691. package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js.map +1 -0
  692. package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js +85 -0
  693. package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js.map +1 -0
  694. package/codeyam-cli/src/utils/ruleReflection/types.js +5 -0
  695. package/codeyam-cli/src/utils/ruleReflection/types.js.map +1 -0
  696. package/codeyam-cli/src/utils/rules/__tests__/parser.test.js +83 -0
  697. package/codeyam-cli/src/utils/rules/__tests__/parser.test.js.map +1 -0
  698. package/codeyam-cli/src/utils/rules/__tests__/pathMatcher.test.js +118 -0
  699. package/codeyam-cli/src/utils/rules/__tests__/pathMatcher.test.js.map +1 -0
  700. package/codeyam-cli/src/utils/rules/__tests__/rulePlacement.test.js +72 -0
  701. package/codeyam-cli/src/utils/rules/__tests__/rulePlacement.test.js.map +1 -0
  702. package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +293 -0
  703. package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
  704. package/codeyam-cli/src/utils/rules/__tests__/sourceFiles.test.js +76 -0
  705. package/codeyam-cli/src/utils/rules/__tests__/sourceFiles.test.js.map +1 -0
  706. package/codeyam-cli/src/utils/rules/index.js +7 -0
  707. package/codeyam-cli/src/utils/rules/index.js.map +1 -0
  708. package/codeyam-cli/src/utils/rules/parser.js +93 -0
  709. package/codeyam-cli/src/utils/rules/parser.js.map +1 -0
  710. package/codeyam-cli/src/utils/rules/pathMatcher.js +49 -0
  711. package/codeyam-cli/src/utils/rules/pathMatcher.js.map +1 -0
  712. package/codeyam-cli/src/utils/rules/rulePlacement.js +65 -0
  713. package/codeyam-cli/src/utils/rules/rulePlacement.js.map +1 -0
  714. package/codeyam-cli/src/utils/rules/ruleState.js +150 -0
  715. package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
  716. package/codeyam-cli/src/utils/rules/sourceFiles.js +43 -0
  717. package/codeyam-cli/src/utils/rules/sourceFiles.js.map +1 -0
  718. package/codeyam-cli/src/utils/rules/staleness.js +137 -0
  719. package/codeyam-cli/src/utils/rules/staleness.js.map +1 -0
  720. package/codeyam-cli/src/utils/scenarioMarkers.js +134 -0
  721. package/codeyam-cli/src/utils/scenarioMarkers.js.map +1 -0
  722. package/codeyam-cli/src/utils/scenariosManifest.js +112 -0
  723. package/codeyam-cli/src/utils/scenariosManifest.js.map +1 -0
  724. package/codeyam-cli/src/utils/serverState.js +64 -12
  725. package/codeyam-cli/src/utils/serverState.js.map +1 -1
  726. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +95 -45
  727. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
  728. package/codeyam-cli/src/utils/simulationGateMiddleware.js +159 -0
  729. package/codeyam-cli/src/utils/simulationGateMiddleware.js.map +1 -0
  730. package/codeyam-cli/src/utils/syncMocksMiddleware.js +5 -24
  731. package/codeyam-cli/src/utils/syncMocksMiddleware.js.map +1 -1
  732. package/codeyam-cli/src/utils/testRunner.js +158 -0
  733. package/codeyam-cli/src/utils/testRunner.js.map +1 -0
  734. package/codeyam-cli/src/utils/transcriptPruning.js +67 -0
  735. package/codeyam-cli/src/utils/transcriptPruning.js.map +1 -0
  736. package/codeyam-cli/src/utils/versionInfo.js +67 -15
  737. package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
  738. package/codeyam-cli/src/utils/webappDetection.js +35 -2
  739. package/codeyam-cli/src/utils/webappDetection.js.map +1 -1
  740. package/codeyam-cli/src/utils/wipe.js +128 -0
  741. package/codeyam-cli/src/utils/wipe.js.map +1 -0
  742. package/codeyam-cli/src/webserver/__tests__/dependency-smoke.test.js +66 -0
  743. package/codeyam-cli/src/webserver/__tests__/dependency-smoke.test.js.map +1 -0
  744. package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js +410 -0
  745. package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js.map +1 -0
  746. package/codeyam-cli/src/webserver/app/lib/database.js +159 -33
  747. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  748. package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
  749. package/codeyam-cli/src/webserver/app/lib/git.js +396 -0
  750. package/codeyam-cli/src/webserver/app/lib/git.js.map +1 -0
  751. package/codeyam-cli/src/webserver/backgroundServer.js +171 -26
  752. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  753. package/codeyam-cli/src/webserver/bootstrap.js +60 -0
  754. package/codeyam-cli/src/webserver/bootstrap.js.map +1 -0
  755. package/codeyam-cli/src/webserver/build/client/assets/CopyButton-BPXZwM4t.js +1 -0
  756. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-BcgbViKV.js +11 -0
  757. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-efWKDYMr.js → EntityTypeBadge-g3saevPb.js} +1 -1
  758. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-CQIG2qda.js +41 -0
  759. package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-Bu6c6aDe.js +1 -0
  760. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-DYFW3lDD.js +25 -0
  761. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-DLeucoVX.js +3 -0
  762. package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-BU_OAEMP.js +6 -0
  763. package/codeyam-cli/src/webserver/build/client/assets/LogViewer-ceAyBX-H.js +3 -0
  764. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-BzHcG7SE.js +11 -0
  765. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BED4B6sP.js +1 -0
  766. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-0DY_NKil.js +10 -0
  767. package/codeyam-cli/src/webserver/build/client/assets/Spinner-Bb5uFQ5V.js +34 -0
  768. package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-COPstp9J.js → TruncatedFilePath-C8OKAR5x.js} +1 -1
  769. package/codeyam-cli/src/webserver/build/client/assets/ViewportInspectBar-oAf2Kqsf.js +1 -0
  770. package/codeyam-cli/src/webserver/build/client/assets/_index-DLxKhri3.js +11 -0
  771. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BcY3q6nt.js +27 -0
  772. package/codeyam-cli/src/webserver/build/client/assets/addon-canvas-DpzMmAy5.js +1 -0
  773. package/codeyam-cli/src/webserver/build/client/assets/addon-fit-YJmn1quW.js +12 -0
  774. package/codeyam-cli/src/webserver/build/client/assets/addon-web-links-Duc5hnl7.js +1 -0
  775. package/codeyam-cli/src/webserver/build/client/assets/addon-webgl-DI8QOUvO.js +58 -0
  776. package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-Bni3iiUj.js +22 -0
  777. package/codeyam-cli/src/webserver/build/client/assets/api.agent-transcripts-l0sNRNKZ.js +1 -0
  778. package/codeyam-cli/src/webserver/build/client/assets/api.dev-mode-events-l0sNRNKZ.js +1 -0
  779. package/codeyam-cli/src/webserver/build/client/assets/api.editor-audit-l0sNRNKZ.js +1 -0
  780. package/codeyam-cli/src/webserver/build/client/assets/api.editor-capture-scenario-l0sNRNKZ.js +1 -0
  781. package/codeyam-cli/src/webserver/build/client/assets/api.editor-client-errors-l0sNRNKZ.js +1 -0
  782. package/codeyam-cli/src/webserver/build/client/assets/api.editor-commit-l0sNRNKZ.js +1 -0
  783. package/codeyam-cli/src/webserver/build/client/assets/api.editor-dev-server-l0sNRNKZ.js +1 -0
  784. package/codeyam-cli/src/webserver/build/client/assets/api.editor-entity-status-l0sNRNKZ.js +1 -0
  785. package/codeyam-cli/src/webserver/build/client/assets/api.editor-file-diff-l0sNRNKZ.js +1 -0
  786. package/codeyam-cli/src/webserver/build/client/assets/api.editor-file-l0sNRNKZ.js +1 -0
  787. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-entry-l0sNRNKZ.js +1 -0
  788. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-image._-l0sNRNKZ.js +1 -0
  789. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-l0sNRNKZ.js +1 -0
  790. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-screenshot-l0sNRNKZ.js +1 -0
  791. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-update-l0sNRNKZ.js +1 -0
  792. package/codeyam-cli/src/webserver/build/client/assets/api.editor-load-commit-l0sNRNKZ.js +1 -0
  793. package/codeyam-cli/src/webserver/build/client/assets/api.editor-project-info-l0sNRNKZ.js +1 -0
  794. package/codeyam-cli/src/webserver/build/client/assets/api.editor-refresh-l0sNRNKZ.js +1 -0
  795. package/codeyam-cli/src/webserver/build/client/assets/api.editor-register-scenario-l0sNRNKZ.js +1 -0
  796. package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-data-l0sNRNKZ.js +1 -0
  797. package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-image._-l0sNRNKZ.js +1 -0
  798. package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenarios-l0sNRNKZ.js +1 -0
  799. package/codeyam-cli/src/webserver/build/client/assets/api.editor-switch-scenario-l0sNRNKZ.js +1 -0
  800. package/codeyam-cli/src/webserver/build/client/assets/api.editor-test-results-l0sNRNKZ.js +1 -0
  801. package/codeyam-cli/src/webserver/build/client/assets/api.health-l0sNRNKZ.js +1 -0
  802. package/codeyam-cli/src/webserver/build/client/assets/api.labs-unlock-l0sNRNKZ.js +1 -0
  803. package/codeyam-cli/src/webserver/build/client/assets/api.memory-profile-l0sNRNKZ.js +1 -0
  804. package/codeyam-cli/src/webserver/build/client/assets/api.restart-server-l0sNRNKZ.js +1 -0
  805. package/codeyam-cli/src/webserver/build/client/assets/api.rule-path-l0sNRNKZ.js +1 -0
  806. package/codeyam-cli/src/webserver/build/client/assets/api.save-fixture-l0sNRNKZ.js +1 -0
  807. package/codeyam-cli/src/webserver/build/client/assets/book-open-BYOypzCa.js +6 -0
  808. package/codeyam-cli/src/webserver/build/client/assets/chevron-down-C_Pmso5S.js +6 -0
  809. package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-C4pqxYJB.js +51 -0
  810. package/codeyam-cli/src/webserver/build/client/assets/circle-check-BVMi9VA5.js +6 -0
  811. package/codeyam-cli/src/webserver/build/client/assets/copy-n2FB0_Sw.js +11 -0
  812. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-CC6AbExI.js +41 -0
  813. package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
  814. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
  815. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-Csi0_PMl.js +1 -0
  816. package/codeyam-cli/src/webserver/build/client/assets/editor-pyT-NAuu.js +10 -0
  817. package/codeyam-cli/src/webserver/build/client/assets/editorPreview-BLQMSKZa.js +41 -0
  818. package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-BF4oLwaE.js +23 -0
  819. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-C7YX6r3H.js +6 -0
  820. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-CF164ouH.js +6 -0
  821. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-p9hhkjJM.js +6 -0
  822. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-BMvVHNXU.js +5 -0
  823. package/codeyam-cli/src/webserver/build/client/assets/entry.client-DTvKq3TY.js +29 -0
  824. package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
  825. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-cPo8LiG3.js +1 -0
  826. package/codeyam-cli/src/webserver/build/client/assets/files-BZrlFE1F.js +1 -0
  827. package/codeyam-cli/src/webserver/build/client/assets/git-DdZcvjGh.js +1 -0
  828. package/codeyam-cli/src/webserver/build/client/assets/globals-BkWJ_UNc.css +1 -0
  829. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-fmIEn3Bc.js +9 -0
  830. package/codeyam-cli/src/webserver/build/client/assets/index-10oVnAAH.js +9 -0
  831. package/codeyam-cli/src/webserver/build/client/assets/index-BcvgDzbZ.js +3 -0
  832. package/codeyam-cli/src/webserver/build/client/assets/index-yHOVb4rc.js +15 -0
  833. package/codeyam-cli/src/webserver/build/client/assets/labs-Zk7ryIM1.js +1 -0
  834. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-DaAZ_H2w.js +6 -0
  835. package/codeyam-cli/src/webserver/build/client/assets/manifest-753dd058.js +1 -0
  836. package/codeyam-cli/src/webserver/build/client/assets/memory-Bl2rpw8u.js +96 -0
  837. package/codeyam-cli/src/webserver/build/client/assets/pause-f5-1lKBt.js +11 -0
  838. package/codeyam-cli/src/webserver/build/client/assets/preload-helper-ckwbz45p.js +1 -0
  839. package/codeyam-cli/src/webserver/build/client/assets/root-B_X8HS1x.js +67 -0
  840. package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
  841. package/codeyam-cli/src/webserver/build/client/assets/search-Di64LWVb.js +6 -0
  842. package/codeyam-cli/src/webserver/build/client/assets/settings-0OrEMU6J.js +1 -0
  843. package/codeyam-cli/src/webserver/build/client/assets/simulations-DWT-CvLy.js +1 -0
  844. package/codeyam-cli/src/webserver/build/client/assets/terminal-Br7MOqts.js +11 -0
  845. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-BLdiCuG-.js +6 -0
  846. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-CrAK28Bc.js +1 -0
  847. package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-C14nCb1q.js +2 -0
  848. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-O-jkvSPx.js +1 -0
  849. package/codeyam-cli/src/webserver/build/client/assets/{useToast-DEyawJ8r.js → useToast-9FIWuYfK.js} +1 -1
  850. package/codeyam-cli/src/webserver/build/client/assets/xterm-BqvuqXEL.js +27 -0
  851. package/codeyam-cli/src/webserver/build/server/assets/index-Bt1_4UUt.js +1 -0
  852. package/codeyam-cli/src/webserver/build/server/assets/server-build-1u5XIyLw.js +416 -0
  853. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  854. package/codeyam-cli/src/webserver/build-info.json +5 -5
  855. package/codeyam-cli/src/webserver/devServer.js +40 -8
  856. package/codeyam-cli/src/webserver/devServer.js.map +1 -1
  857. package/codeyam-cli/src/webserver/editorProxy.js +779 -0
  858. package/codeyam-cli/src/webserver/editorProxy.js.map +1 -0
  859. package/codeyam-cli/src/webserver/scripts/codeyam-preload.mjs +414 -0
  860. package/codeyam-cli/src/webserver/scripts/journalCapture.ts +230 -0
  861. package/codeyam-cli/src/webserver/server.js +293 -26
  862. package/codeyam-cli/src/webserver/server.js.map +1 -1
  863. package/codeyam-cli/src/webserver/terminalServer.js +726 -0
  864. package/codeyam-cli/src/webserver/terminalServer.js.map +1 -0
  865. package/codeyam-cli/templates/chrome-extension-react/EXTENSION_SETUP.md +75 -0
  866. package/codeyam-cli/templates/chrome-extension-react/gitignore +15 -0
  867. package/codeyam-cli/templates/chrome-extension-react/index.html +12 -0
  868. package/codeyam-cli/templates/chrome-extension-react/package.json +26 -0
  869. package/codeyam-cli/templates/chrome-extension-react/popup.html +12 -0
  870. package/codeyam-cli/templates/chrome-extension-react/public/manifest.json +15 -0
  871. package/codeyam-cli/templates/chrome-extension-react/src/background/service-worker.ts +7 -0
  872. package/codeyam-cli/templates/chrome-extension-react/src/globals.css +6 -0
  873. package/codeyam-cli/templates/chrome-extension-react/src/lib/storage.ts +37 -0
  874. package/codeyam-cli/templates/chrome-extension-react/src/popup/App.tsx +12 -0
  875. package/codeyam-cli/templates/chrome-extension-react/src/popup/main.tsx +10 -0
  876. package/codeyam-cli/templates/chrome-extension-react/tsconfig.json +24 -0
  877. package/codeyam-cli/templates/chrome-extension-react/vite.config.ts +41 -0
  878. package/codeyam-cli/templates/codeyam-editor-claude.md +68 -0
  879. package/codeyam-cli/templates/codeyam-memory-hook.sh +199 -0
  880. package/codeyam-cli/templates/commands/codeyam-diagnose.md +481 -0
  881. package/codeyam-cli/templates/editor-step-hook.py +231 -0
  882. package/codeyam-cli/templates/expo-react-native/MOBILE_SETUP.md +89 -0
  883. package/codeyam-cli/templates/expo-react-native/app/(tabs)/_layout.tsx +33 -0
  884. package/codeyam-cli/templates/expo-react-native/app/(tabs)/index.tsx +12 -0
  885. package/codeyam-cli/templates/expo-react-native/app/(tabs)/settings.tsx +12 -0
  886. package/codeyam-cli/templates/expo-react-native/app/_layout.tsx +12 -0
  887. package/codeyam-cli/templates/expo-react-native/app.json +18 -0
  888. package/codeyam-cli/templates/expo-react-native/babel.config.js +9 -0
  889. package/codeyam-cli/templates/expo-react-native/gitignore +12 -0
  890. package/codeyam-cli/templates/expo-react-native/global.css +3 -0
  891. package/codeyam-cli/templates/expo-react-native/lib/storage.ts +32 -0
  892. package/codeyam-cli/templates/expo-react-native/metro.config.js +6 -0
  893. package/codeyam-cli/templates/expo-react-native/nativewind-env.d.ts +1 -0
  894. package/codeyam-cli/templates/expo-react-native/package.json +37 -0
  895. package/codeyam-cli/templates/expo-react-native/tailwind.config.js +10 -0
  896. package/codeyam-cli/templates/expo-react-native/tsconfig.json +10 -0
  897. package/codeyam-cli/templates/hooks/staleness-check.sh +43 -0
  898. package/codeyam-cli/templates/isolation-route/next-app.tsx.template +80 -0
  899. package/codeyam-cli/templates/isolation-route/next-pages.tsx.template +79 -0
  900. package/codeyam-cli/templates/isolation-route/vite-react.tsx.template +78 -0
  901. package/codeyam-cli/templates/msw/browser-setup.ts.template +47 -0
  902. package/codeyam-cli/templates/msw/handler-router.ts.template +47 -0
  903. package/codeyam-cli/templates/msw/server-setup.ts.template +52 -0
  904. package/codeyam-cli/templates/nextjs-prisma-sqlite/AUTH_PATTERNS.md +308 -0
  905. package/codeyam-cli/templates/nextjs-prisma-sqlite/AUTH_UPGRADE.md +304 -0
  906. package/codeyam-cli/templates/nextjs-prisma-sqlite/DATABASE.md +112 -0
  907. package/codeyam-cli/templates/nextjs-prisma-sqlite/FEATURE_PATTERNS.md +37 -0
  908. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/api/todos/route.ts +17 -0
  909. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/codeyam-isolate/layout.tsx +12 -0
  910. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/globals.css +26 -0
  911. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/layout.tsx +34 -0
  912. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/lib/prisma.ts +24 -0
  913. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/page.tsx +10 -0
  914. package/codeyam-cli/templates/nextjs-prisma-sqlite/env +4 -0
  915. package/codeyam-cli/templates/nextjs-prisma-sqlite/eslint.config.mjs +11 -0
  916. package/codeyam-cli/templates/nextjs-prisma-sqlite/gitignore +64 -0
  917. package/codeyam-cli/templates/nextjs-prisma-sqlite/next.config.ts +14 -0
  918. package/codeyam-cli/templates/nextjs-prisma-sqlite/package.json +38 -0
  919. package/codeyam-cli/templates/nextjs-prisma-sqlite/postcss.config.mjs +7 -0
  920. package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma/schema.prisma +27 -0
  921. package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma/seed.ts +40 -0
  922. package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma.config.ts +12 -0
  923. package/codeyam-cli/templates/nextjs-prisma-sqlite/seed-adapter.ts +92 -0
  924. package/codeyam-cli/templates/nextjs-prisma-sqlite/tsconfig.json +34 -0
  925. package/codeyam-cli/templates/nextjs-prisma-sqlite/vitest.config.ts +13 -0
  926. package/codeyam-cli/templates/nextjs-prisma-supabase/SUPABASE_SETUP.md +104 -0
  927. package/codeyam-cli/templates/nextjs-prisma-supabase/app/api/todos/route.ts +17 -0
  928. package/codeyam-cli/templates/nextjs-prisma-supabase/app/globals.css +26 -0
  929. package/codeyam-cli/templates/nextjs-prisma-supabase/app/layout.tsx +34 -0
  930. package/codeyam-cli/templates/nextjs-prisma-supabase/app/lib/prisma.ts +20 -0
  931. package/codeyam-cli/templates/nextjs-prisma-supabase/app/lib/supabase.ts +12 -0
  932. package/codeyam-cli/templates/nextjs-prisma-supabase/app/page.tsx +10 -0
  933. package/codeyam-cli/templates/nextjs-prisma-supabase/env +9 -0
  934. package/codeyam-cli/templates/nextjs-prisma-supabase/eslint.config.mjs +11 -0
  935. package/codeyam-cli/templates/nextjs-prisma-supabase/gitignore +40 -0
  936. package/codeyam-cli/templates/nextjs-prisma-supabase/next.config.ts +11 -0
  937. package/codeyam-cli/templates/nextjs-prisma-supabase/package.json +36 -0
  938. package/codeyam-cli/templates/nextjs-prisma-supabase/postcss.config.mjs +7 -0
  939. package/codeyam-cli/templates/nextjs-prisma-supabase/prisma/schema.prisma +27 -0
  940. package/codeyam-cli/templates/nextjs-prisma-supabase/prisma/seed.ts +39 -0
  941. package/codeyam-cli/templates/nextjs-prisma-supabase/prisma.config.ts +12 -0
  942. package/codeyam-cli/templates/nextjs-prisma-supabase/tsconfig.json +34 -0
  943. package/codeyam-cli/templates/prompts/conversation-guidance.txt +44 -0
  944. package/codeyam-cli/templates/prompts/conversation-prompt.txt +28 -0
  945. package/codeyam-cli/templates/prompts/interruption-prompt.txt +31 -0
  946. package/codeyam-cli/templates/prompts/stale-rules-prompt.txt +24 -0
  947. package/codeyam-cli/templates/rule-notification-hook.py +83 -0
  948. package/codeyam-cli/templates/rule-reflection-hook.py +647 -0
  949. package/codeyam-cli/templates/rules-instructions.md +78 -0
  950. package/codeyam-cli/templates/{codeyam-debug-skill.md → skills/codeyam-debug/SKILL.md} +48 -4
  951. package/codeyam-cli/templates/skills/codeyam-dev-mode/SKILL.md +237 -0
  952. package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +145 -0
  953. package/codeyam-cli/templates/skills/codeyam-memory/SKILL.md +611 -0
  954. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/deprecated-prompt.md +100 -0
  955. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/detect-deprecated-patterns.mjs +139 -0
  956. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/find-exports.mjs +52 -0
  957. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/misleading-api-prompt.md +117 -0
  958. package/codeyam-cli/templates/skills/codeyam-memory/scripts/lib/read-json-field.mjs +61 -0
  959. package/codeyam-cli/templates/skills/codeyam-memory/scripts/lib/ripgrep-fallback.mjs +155 -0
  960. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/analyze-prompt.md +46 -0
  961. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/cleanup.mjs +13 -0
  962. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/filter-session.mjs +95 -0
  963. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/preprocess.mjs +160 -0
  964. package/codeyam-cli/templates/skills/codeyam-new-rule/SKILL.md +11 -0
  965. package/codeyam-cli/templates/{codeyam-setup-skill.md → skills/codeyam-setup/SKILL.md} +151 -4
  966. package/codeyam-cli/templates/{codeyam-sim-skill.md → skills/codeyam-sim/SKILL.md} +1 -1
  967. package/codeyam-cli/templates/{codeyam-test-skill.md → skills/codeyam-test/SKILL.md} +1 -1
  968. package/codeyam-cli/templates/{codeyam-verify-skill.md → skills/codeyam-verify/SKILL.md} +1 -1
  969. package/package.json +39 -29
  970. package/packages/ai/index.js +8 -6
  971. package/packages/ai/index.js.map +1 -1
  972. package/packages/ai/src/lib/analyzeScope.js +181 -13
  973. package/packages/ai/src/lib/analyzeScope.js.map +1 -1
  974. package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
  975. package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
  976. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +176 -13
  977. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
  978. package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
  979. package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
  980. package/packages/ai/src/lib/astScopes/methodSemantics.js +138 -23
  981. package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
  982. package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js +10 -14
  983. package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js.map +1 -1
  984. package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js +8 -0
  985. package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
  986. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +23 -0
  987. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
  988. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +138 -1
  989. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
  990. package/packages/ai/src/lib/astScopes/processExpression.js +1235 -104
  991. package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
  992. package/packages/ai/src/lib/astScopes/sharedPatterns.js +25 -0
  993. package/packages/ai/src/lib/astScopes/sharedPatterns.js.map +1 -1
  994. package/packages/ai/src/lib/checkAllAttributes.js +24 -9
  995. package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
  996. package/packages/ai/src/lib/completionCall.js +188 -38
  997. package/packages/ai/src/lib/completionCall.js.map +1 -1
  998. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +2174 -222
  999. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  1000. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +7 -2
  1001. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
  1002. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +661 -0
  1003. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -0
  1004. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +180 -56
  1005. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
  1006. package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +13 -3
  1007. package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -1
  1008. package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +6 -4
  1009. package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -1
  1010. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +66 -2
  1011. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
  1012. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +139 -13
  1013. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
  1014. package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
  1015. package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
  1016. package/packages/ai/src/lib/dataStructure/helpers/coercePrimitivesToArraysBySchema.js +54 -0
  1017. package/packages/ai/src/lib/dataStructure/helpers/coercePrimitivesToArraysBySchema.js.map +1 -0
  1018. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +142 -12
  1019. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
  1020. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js +86 -0
  1021. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js.map +1 -0
  1022. package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +173 -0
  1023. package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -0
  1024. package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js +37 -20
  1025. package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js.map +1 -1
  1026. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +355 -77
  1027. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
  1028. package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
  1029. package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
  1030. package/packages/ai/src/lib/dataStructure/helpers/stripNullableMarkers.js +34 -0
  1031. package/packages/ai/src/lib/dataStructure/helpers/stripNullableMarkers.js.map +1 -0
  1032. package/packages/ai/src/lib/dataStructureChunking.js +130 -0
  1033. package/packages/ai/src/lib/dataStructureChunking.js.map +1 -0
  1034. package/packages/ai/src/lib/deepEqual.js +32 -0
  1035. package/packages/ai/src/lib/deepEqual.js.map +1 -0
  1036. package/packages/ai/src/lib/e2eDataTracking.js +241 -0
  1037. package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
  1038. package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
  1039. package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
  1040. package/packages/ai/src/lib/generateChangesEntityScenarioData.js +62 -5
  1041. package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
  1042. package/packages/ai/src/lib/generateChangesEntityScenarios.js +81 -90
  1043. package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
  1044. package/packages/ai/src/lib/generateEntityDataStructure.js +50 -1
  1045. package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
  1046. package/packages/ai/src/lib/generateEntityScenarioData.js +1183 -85
  1047. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  1048. package/packages/ai/src/lib/generateEntityScenarios.js +193 -83
  1049. package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
  1050. package/packages/ai/src/lib/generateExecutionFlows.js +484 -0
  1051. package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -0
  1052. package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js +380 -0
  1053. package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js.map +1 -0
  1054. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +1807 -0
  1055. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -0
  1056. package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
  1057. package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
  1058. package/packages/ai/src/lib/getConditionalUsagesFromCode.js +84 -14
  1059. package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
  1060. package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -1
  1061. package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
  1062. package/packages/ai/src/lib/isolateScopes.js +270 -7
  1063. package/packages/ai/src/lib/isolateScopes.js.map +1 -1
  1064. package/packages/ai/src/lib/mergeJsonTypeDefinitions.js +5 -0
  1065. package/packages/ai/src/lib/mergeJsonTypeDefinitions.js.map +1 -1
  1066. package/packages/ai/src/lib/mergeStatements.js +88 -46
  1067. package/packages/ai/src/lib/mergeStatements.js.map +1 -1
  1068. package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js +97 -0
  1069. package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js.map +1 -0
  1070. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +16 -4
  1071. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
  1072. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +1 -1
  1073. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
  1074. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -64
  1075. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
  1076. package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
  1077. package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
  1078. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +83 -6
  1079. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
  1080. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -34
  1081. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
  1082. package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
  1083. package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
  1084. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +16 -3
  1085. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
  1086. package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
  1087. package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
  1088. package/packages/ai/src/lib/resolvePathToControllable.js +677 -0
  1089. package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
  1090. package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
  1091. package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
  1092. package/packages/ai/src/lib/worker/SerializableDataStructure.js +29 -0
  1093. package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
  1094. package/packages/ai/src/lib/worker/analyzeScopeWorker.js +98 -1
  1095. package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
  1096. package/packages/analyze/index.js +1 -0
  1097. package/packages/analyze/index.js.map +1 -1
  1098. package/packages/analyze/src/lib/FileAnalyzer.js +75 -36
  1099. package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
  1100. package/packages/analyze/src/lib/ProjectAnalyzer.js +109 -30
  1101. package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
  1102. package/packages/analyze/src/lib/analysisContext.js +30 -5
  1103. package/packages/analyze/src/lib/analysisContext.js.map +1 -1
  1104. package/packages/analyze/src/lib/asts/index.js +4 -2
  1105. package/packages/analyze/src/lib/asts/index.js.map +1 -1
  1106. package/packages/analyze/src/lib/asts/nodes/getNodeType.js +1 -0
  1107. package/packages/analyze/src/lib/asts/nodes/getNodeType.js.map +1 -1
  1108. package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
  1109. package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
  1110. package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
  1111. package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
  1112. package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js +14 -0
  1113. package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -1
  1114. package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js +14 -0
  1115. package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js.map +1 -1
  1116. package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +6 -0
  1117. package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
  1118. package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js +6 -0
  1119. package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js.map +1 -1
  1120. package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js +39 -1
  1121. package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js.map +1 -1
  1122. package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js +2 -1
  1123. package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js.map +1 -1
  1124. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +278 -52
  1125. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  1126. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +31 -1
  1127. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  1128. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +11 -0
  1129. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
  1130. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +2 -1
  1131. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
  1132. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -10
  1133. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
  1134. package/packages/analyze/src/lib/files/analyzeChange.js +21 -11
  1135. package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
  1136. package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
  1137. package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
  1138. package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
  1139. package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
  1140. package/packages/analyze/src/lib/files/analyzeRemixRoute.js +3 -2
  1141. package/packages/analyze/src/lib/files/analyzeRemixRoute.js.map +1 -1
  1142. package/packages/analyze/src/lib/files/enums/steps.js +1 -1
  1143. package/packages/analyze/src/lib/files/enums/steps.js.map +1 -1
  1144. package/packages/analyze/src/lib/files/getImportedExports.js +11 -7
  1145. package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
  1146. package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +907 -0
  1147. package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
  1148. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +255 -0
  1149. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -0
  1150. package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
  1151. package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
  1152. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +525 -61
  1153. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
  1154. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
  1155. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
  1156. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
  1157. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
  1158. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +469 -85
  1159. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  1160. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +104 -0
  1161. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
  1162. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +56 -69
  1163. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
  1164. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +4 -8
  1165. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
  1166. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +847 -126
  1167. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  1168. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
  1169. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
  1170. package/packages/analyze/src/lib/files/setImportedExports.js +2 -1
  1171. package/packages/analyze/src/lib/files/setImportedExports.js.map +1 -1
  1172. package/packages/analyze/src/lib/index.js +1 -0
  1173. package/packages/analyze/src/lib/index.js.map +1 -1
  1174. package/packages/analyze/src/lib/utils/getFileByPath.js +12 -0
  1175. package/packages/analyze/src/lib/utils/getFileByPath.js.map +1 -0
  1176. package/packages/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
  1177. package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
  1178. package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
  1179. package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
  1180. package/packages/database/index.js +1 -0
  1181. package/packages/database/index.js.map +1 -1
  1182. package/packages/database/src/lib/analysisBranchToDb.js +1 -1
  1183. package/packages/database/src/lib/analysisBranchToDb.js.map +1 -1
  1184. package/packages/database/src/lib/analysisToDb.js +1 -1
  1185. package/packages/database/src/lib/analysisToDb.js.map +1 -1
  1186. package/packages/database/src/lib/branchToDb.js +1 -1
  1187. package/packages/database/src/lib/branchToDb.js.map +1 -1
  1188. package/packages/database/src/lib/commitBranchToDb.js +1 -1
  1189. package/packages/database/src/lib/commitBranchToDb.js.map +1 -1
  1190. package/packages/database/src/lib/commitToDb.js +1 -1
  1191. package/packages/database/src/lib/commitToDb.js.map +1 -1
  1192. package/packages/database/src/lib/fileToDb.js +1 -1
  1193. package/packages/database/src/lib/fileToDb.js.map +1 -1
  1194. package/packages/database/src/lib/kysely/db.js +18 -3
  1195. package/packages/database/src/lib/kysely/db.js.map +1 -1
  1196. package/packages/database/src/lib/kysely/tables/commitsTable.js +3 -0
  1197. package/packages/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
  1198. package/packages/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
  1199. package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  1200. package/packages/database/src/lib/kysely/tables/editorScenariosTable.js +65 -0
  1201. package/packages/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -0
  1202. package/packages/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
  1203. package/packages/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
  1204. package/packages/database/src/lib/loadAnalyses.js +45 -2
  1205. package/packages/database/src/lib/loadAnalyses.js.map +1 -1
  1206. package/packages/database/src/lib/loadAnalysis.js +8 -0
  1207. package/packages/database/src/lib/loadAnalysis.js.map +1 -1
  1208. package/packages/database/src/lib/loadBranch.js +11 -1
  1209. package/packages/database/src/lib/loadBranch.js.map +1 -1
  1210. package/packages/database/src/lib/loadCommit.js +7 -0
  1211. package/packages/database/src/lib/loadCommit.js.map +1 -1
  1212. package/packages/database/src/lib/loadCommits.js +45 -14
  1213. package/packages/database/src/lib/loadCommits.js.map +1 -1
  1214. package/packages/database/src/lib/loadEntities.js +23 -4
  1215. package/packages/database/src/lib/loadEntities.js.map +1 -1
  1216. package/packages/database/src/lib/loadEntityBranches.js +9 -0
  1217. package/packages/database/src/lib/loadEntityBranches.js.map +1 -1
  1218. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +5 -5
  1219. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  1220. package/packages/database/src/lib/projectToDb.js +1 -1
  1221. package/packages/database/src/lib/projectToDb.js.map +1 -1
  1222. package/packages/database/src/lib/saveFiles.js +1 -1
  1223. package/packages/database/src/lib/saveFiles.js.map +1 -1
  1224. package/packages/database/src/lib/scenarioToDb.js +1 -1
  1225. package/packages/database/src/lib/scenarioToDb.js.map +1 -1
  1226. package/packages/database/src/lib/updateCommitMetadata.js +100 -88
  1227. package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
  1228. package/packages/database/src/lib/updateFreshAnalysisStatus.js +41 -30
  1229. package/packages/database/src/lib/updateFreshAnalysisStatus.js.map +1 -1
  1230. package/packages/database/src/lib/updateFreshAnalysisStatusWithScenarios.js +68 -57
  1231. package/packages/database/src/lib/updateFreshAnalysisStatusWithScenarios.js.map +1 -1
  1232. package/packages/generate/index.js +3 -0
  1233. package/packages/generate/index.js.map +1 -1
  1234. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
  1235. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  1236. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +217 -0
  1237. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
  1238. package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
  1239. package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
  1240. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +41 -9
  1241. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  1242. package/packages/generate/src/lib/deepMerge.js +27 -1
  1243. package/packages/generate/src/lib/deepMerge.js.map +1 -1
  1244. package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
  1245. package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
  1246. package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
  1247. package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
  1248. package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
  1249. package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
  1250. package/packages/process/index.js +3 -0
  1251. package/packages/process/index.js.map +1 -0
  1252. package/packages/process/src/GlobalProcessManager.js.map +1 -0
  1253. package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
  1254. package/packages/process/src/ProcessManager.js.map +1 -0
  1255. package/packages/process/src/index.js.map +1 -0
  1256. package/packages/process/src/managedExecAsync.js.map +1 -0
  1257. package/packages/types/index.js.map +1 -1
  1258. package/packages/types/src/enums/ProjectFramework.js +2 -0
  1259. package/packages/types/src/enums/ProjectFramework.js.map +1 -1
  1260. package/packages/utils/src/lib/fs/rsyncCopy.js +98 -3
  1261. package/packages/utils/src/lib/fs/rsyncCopy.js.map +1 -1
  1262. package/packages/utils/src/lib/lightweightEntityExtractor.js +25 -0
  1263. package/packages/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  1264. package/packages/utils/src/lib/safeFileName.js +29 -3
  1265. package/packages/utils/src/lib/safeFileName.js.map +1 -1
  1266. package/scripts/npm-post-install.cjs +34 -0
  1267. package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
  1268. package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -197
  1269. package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -271
  1270. package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -294
  1271. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
  1272. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -115
  1273. package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
  1274. package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
  1275. package/analyzer-template/process/README.md +0 -507
  1276. package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
  1277. package/background/src/lib/process/ProcessManager.js.map +0 -1
  1278. package/background/src/lib/process/index.js.map +0 -1
  1279. package/background/src/lib/process/managedExecAsync.js.map +0 -1
  1280. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
  1281. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
  1282. package/codeyam-cli/src/commands/detect-universal-mocks.js +0 -118
  1283. package/codeyam-cli/src/commands/detect-universal-mocks.js.map +0 -1
  1284. package/codeyam-cli/src/commands/list.js +0 -31
  1285. package/codeyam-cli/src/commands/list.js.map +0 -1
  1286. package/codeyam-cli/src/commands/webapp-info.js +0 -146
  1287. package/codeyam-cli/src/commands/webapp-info.js.map +0 -1
  1288. package/codeyam-cli/src/utils/universal-mocks.js +0 -152
  1289. package/codeyam-cli/src/utils/universal-mocks.js.map +0 -1
  1290. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-CVbSvOjo.js +0 -1
  1291. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-DcwcHyl5.js +0 -1
  1292. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-WgwC1GfJ.js +0 -26
  1293. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-IEKom9O2.js +0 -3
  1294. package/codeyam-cli/src/webserver/build/client/assets/LogViewer-BYnfxbUG.js +0 -3
  1295. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-_lBPJCzG.js +0 -1
  1296. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-lHVhvsu_.js +0 -1
  1297. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-d_TBk4GQ.js +0 -5
  1298. package/codeyam-cli/src/webserver/build/client/assets/_index-kGT7VUqj.js +0 -1
  1299. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-DDGmhu7P.js +0 -7
  1300. package/codeyam-cli/src/webserver/build/client/assets/chevron-down-n_HPRfM_.js +0 -1
  1301. package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-CbVoyx1U.js +0 -26
  1302. package/codeyam-cli/src/webserver/build/client/assets/circle-check-D1VOYveA.js +0 -1
  1303. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-YR8jjAlu.js +0 -1
  1304. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-B8vP3V_s.js +0 -1
  1305. package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-CN6aLCT1.js +0 -16
  1306. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DA5Jeu2P.js +0 -1
  1307. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-BTeitalf.js +0 -5
  1308. package/codeyam-cli/src/webserver/build/client/assets/entry.client-du6UEYD-.js +0 -13
  1309. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-BpjkhMoi.js +0 -1
  1310. package/codeyam-cli/src/webserver/build/client/assets/files-BQGvk4lJ.js +0 -1
  1311. package/codeyam-cli/src/webserver/build/client/assets/git-DVdYRT-I.js +0 -12
  1312. package/codeyam-cli/src/webserver/build/client/assets/globals-CO-U8Bpo.css +0 -1
  1313. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +0 -5
  1314. package/codeyam-cli/src/webserver/build/client/assets/index-DCG-vks0.js +0 -1
  1315. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-GazdNeLl.js +0 -1
  1316. package/codeyam-cli/src/webserver/build/client/assets/manifest-0b694d28.js +0 -1
  1317. package/codeyam-cli/src/webserver/build/client/assets/root-D3tQP7hx.js +0 -16
  1318. package/codeyam-cli/src/webserver/build/client/assets/search-CIY6XmtE.js +0 -1
  1319. package/codeyam-cli/src/webserver/build/client/assets/server-build-CMKNK2uU.css +0 -1
  1320. package/codeyam-cli/src/webserver/build/client/assets/settings-CoMDgElu.js +0 -1
  1321. package/codeyam-cli/src/webserver/build/client/assets/simulations-agkniXp2.js +0 -1
  1322. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-B2VUcygF.js +0 -1
  1323. package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-3pmpUQB-.js +0 -2
  1324. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-EvdK-zXP.js +0 -1
  1325. package/codeyam-cli/src/webserver/build/server/assets/index-DGVHQEXD.js +0 -1
  1326. package/codeyam-cli/src/webserver/build/server/assets/server-build-CghkTkIL.js +0 -166
  1327. package/codeyam-cli/templates/codeyam-stop-hook.sh +0 -284
  1328. package/codeyam-cli/templates/debug-command.md +0 -303
  1329. package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
  1330. package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
  1331. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -136
  1332. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
  1333. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -220
  1334. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
  1335. package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -241
  1336. package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
  1337. package/packages/ai/src/lib/isFrontend.js +0 -5
  1338. package/packages/ai/src/lib/isFrontend.js.map +0 -1
  1339. package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
  1340. package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
  1341. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -72
  1342. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
  1343. package/scripts/finalize-analyzer.cjs +0 -79
  1344. /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
  1345. /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
  1346. /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
  1347. /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
  1348. /package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-CMKNK2uU.css → styles-CMKNK2uU.css} +0 -0
  1349. /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
  1350. /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
  1351. /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
@@ -8,6 +8,51 @@ import * as fs from 'fs';
8
8
  import * as path from 'path';
9
9
  import ts from 'typescript';
10
10
  import { applyServerOnlyMocks } from "./serverOnlyModules.js";
11
+ // Debug timing helper for tracking where time is spent
12
+ const DEBUG_TIMING = process.env.DEBUG_WRITE_SCENARIO === 'true';
13
+ let debugStartTime;
14
+ let debugLastTime;
15
+ // Timeout protection to prevent infinite hangs
16
+ const WRITE_SCENARIO_TIMEOUT_MS = parseInt(process.env.WRITE_SCENARIO_TIMEOUT_MS || '300000', // Default 5 minutes
17
+ 10);
18
+ class WriteScenarioTimeoutError extends Error {
19
+ constructor(operation, timeoutMs) {
20
+ super(`WriteScenarioComponents timed out after ${timeoutMs}ms during: ${operation}`);
21
+ this.name = 'WriteScenarioTimeoutError';
22
+ }
23
+ }
24
+ async function withTimeout(operation, promise, timeoutMs = WRITE_SCENARIO_TIMEOUT_MS) {
25
+ let timeoutId;
26
+ const timeoutPromise = new Promise((_, reject) => {
27
+ timeoutId = setTimeout(() => {
28
+ reject(new WriteScenarioTimeoutError(operation, timeoutMs));
29
+ }, timeoutMs);
30
+ });
31
+ try {
32
+ return await Promise.race([promise, timeoutPromise]);
33
+ }
34
+ finally {
35
+ if (timeoutId)
36
+ clearTimeout(timeoutId);
37
+ }
38
+ }
39
+ function debugLog(message, extra) {
40
+ if (!DEBUG_TIMING)
41
+ return;
42
+ const now = Date.now();
43
+ if (!debugStartTime) {
44
+ debugStartTime = now;
45
+ debugLastTime = now;
46
+ }
47
+ const elapsed = now - debugStartTime;
48
+ const delta = now - debugLastTime;
49
+ debugLastTime = now;
50
+ console.log(`[WriteScenario +${elapsed}ms Δ${delta}ms] ${message}`, extra ? JSON.stringify(extra, null, 2) : '');
51
+ }
52
+ function resetDebugTiming() {
53
+ debugStartTime = 0;
54
+ debugLastTime = 0;
55
+ }
11
56
  /**
12
57
  * Find the end position of the last import/export-from statement using TypeScript AST.
13
58
  * This is more reliable than regex for handling multiline imports, comments, etc.
@@ -17,7 +62,10 @@ import { applyServerOnlyMocks } from "./serverOnlyModules.js";
17
62
  */
18
63
  function findEndOfImports(content) {
19
64
  try {
20
- 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);
21
69
  let lastImportEnd = 0;
22
70
  // Visit all top-level statements to find import/export declarations
23
71
  for (const statement of sourceFile.statements) {
@@ -46,6 +94,106 @@ function findEndOfImports(content) {
46
94
  function escapeRegExp(str) {
47
95
  return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
48
96
  }
97
+ /**
98
+ * Remove a named import from file content using TypeScript AST.
99
+ * Handles both regular imports (`EntityName`) and type-only imports (`type EntityName`).
100
+ *
101
+ * @param fileContent - The file content to modify
102
+ * @param entityName - The name of the entity to remove from imports
103
+ * @returns The modified file content with the entity removed from imports
104
+ */
105
+ function removeNamedImportAst(fileContent, entityName) {
106
+ try {
107
+ const sourceFile = ts.createSourceFile('temp.tsx', fileContent, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
108
+ const replacements = [];
109
+ for (const statement of sourceFile.statements) {
110
+ if (!ts.isImportDeclaration(statement))
111
+ continue;
112
+ if (!statement.importClause?.namedBindings)
113
+ continue;
114
+ if (!ts.isNamedImports(statement.importClause.namedBindings))
115
+ continue;
116
+ const namedImports = statement.importClause.namedBindings;
117
+ const elements = namedImports.elements;
118
+ // Find the element that matches our entity name
119
+ const matchingIndex = elements.findIndex((el) => el.name.text === entityName);
120
+ if (matchingIndex === -1)
121
+ continue;
122
+ // Check if there's a default import (e.g., `import DefaultName, { NamedImport } from '...'`)
123
+ const hasDefaultImport = !!statement.importClause.name;
124
+ // If this is the only named import AND there's no default import, remove the entire statement
125
+ if (elements.length === 1 && !hasDefaultImport) {
126
+ // Find the end including any trailing newline
127
+ let end = statement.getEnd();
128
+ const afterStatement = fileContent.slice(end);
129
+ const trailingNewline = afterStatement.match(/^\r?\n/);
130
+ if (trailingNewline) {
131
+ end += trailingNewline[0].length;
132
+ }
133
+ replacements.push({
134
+ start: statement.getStart(sourceFile),
135
+ end,
136
+ replacement: '',
137
+ });
138
+ continue;
139
+ }
140
+ // Otherwise, rebuild the import without this element
141
+ const remainingElements = elements.filter((_, i) => i !== matchingIndex);
142
+ // Get the module specifier
143
+ const moduleSpecifier = statement.moduleSpecifier;
144
+ if (!ts.isStringLiteral(moduleSpecifier))
145
+ continue;
146
+ // Preserve import type modifier if present
147
+ const importTypePrefix = statement.importClause.isTypeOnly ? 'type ' : '';
148
+ // Get the default import name if present
149
+ const defaultImportName = statement.importClause.name?.text;
150
+ let newImport;
151
+ if (remainingElements.length === 0) {
152
+ // All named imports were removed, but there's a default import to preserve
153
+ // (we only get here when hasDefaultImport is true, because otherwise we'd have
154
+ // removed the whole statement at the elements.length === 1 check above)
155
+ newImport = `import ${defaultImportName} from ${moduleSpecifier.getText(sourceFile)};`;
156
+ }
157
+ else {
158
+ // Build the new named imports string
159
+ const newNamedImports = remainingElements
160
+ .map((el) => {
161
+ const isTypeOnly = el.isTypeOnly;
162
+ const name = el.name.text;
163
+ const propertyName = el.propertyName?.text;
164
+ if (propertyName) {
165
+ return isTypeOnly
166
+ ? `type ${propertyName} as ${name}`
167
+ : `${propertyName} as ${name}`;
168
+ }
169
+ return isTypeOnly ? `type ${name}` : name;
170
+ })
171
+ .join(', ');
172
+ // Build the new import statement, preserving default import if present
173
+ const defaultImportPrefix = defaultImportName
174
+ ? `${defaultImportName}, `
175
+ : '';
176
+ newImport = `import ${importTypePrefix}${defaultImportPrefix}{ ${newNamedImports} } from ${moduleSpecifier.getText(sourceFile)};`;
177
+ }
178
+ replacements.push({
179
+ start: statement.getStart(sourceFile),
180
+ end: statement.getEnd(),
181
+ replacement: newImport,
182
+ });
183
+ }
184
+ // Apply replacements in reverse order to preserve positions
185
+ let result = fileContent;
186
+ replacements.sort((a, b) => b.start - a.start);
187
+ for (const { start, end, replacement } of replacements) {
188
+ result = result.slice(0, start) + replacement + result.slice(end);
189
+ }
190
+ return result;
191
+ }
192
+ catch (error) {
193
+ console.warn('[removeNamedImportAst] Failed to parse file:', error);
194
+ return fileContent; // Return original content on error
195
+ }
196
+ }
49
197
  /**
50
198
  * Map nested dist paths to src paths.
51
199
  * Some build tools create nested structures like:
@@ -321,22 +469,37 @@ function stripServerOnlyImport(fileContent) {
321
469
  * Excludes node_modules imports (bare specifiers like 'react', '@prisma/client').
322
470
  */
323
471
  function extractInternalImportPaths(fileContent) {
472
+ // Always use AST parsing - regex with nested quantifiers can cause catastrophic
473
+ // backtracking that hangs on a single .exec() call (before iteration limits kick in)
474
+ return extractInternalImportPathsAst(fileContent);
475
+ }
476
+ /**
477
+ * Extract internal import paths using TypeScript AST - more reliable for large files
478
+ */
479
+ function extractInternalImportPathsAst(fileContent) {
324
480
  const importPaths = [];
325
- // Match import statements with their paths
326
- // Handles: import x from "path", import { x } from "path", import * as x from "path"
327
- const importRegex = /import\s+(?:(?:\{[^}]*\}|\*\s+as\s+\w+|\w+)\s*,?\s*)*\s*from\s*["']([^"']+)["']/g;
328
- let match;
329
- while ((match = importRegex.exec(fileContent)) !== null) {
330
- const importPath = match[1];
331
- // Skip node_modules imports (bare specifiers)
332
- // Internal imports start with '.', '@/', '~/' or similar path aliases
333
- if (importPath.startsWith('.') ||
334
- importPath.startsWith('@/') ||
335
- importPath.startsWith('~/') ||
336
- importPath.startsWith('#')) {
337
- importPaths.push(importPath);
481
+ try {
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);
484
+ for (const statement of sourceFile.statements) {
485
+ if (ts.isImportDeclaration(statement) && statement.moduleSpecifier) {
486
+ const moduleSpecifier = statement.moduleSpecifier;
487
+ if (ts.isStringLiteral(moduleSpecifier)) {
488
+ const importPath = moduleSpecifier.text;
489
+ // Skip node_modules imports (bare specifiers)
490
+ if (importPath.startsWith('.') ||
491
+ importPath.startsWith('@/') ||
492
+ importPath.startsWith('~/') ||
493
+ importPath.startsWith('#')) {
494
+ importPaths.push(importPath);
495
+ }
496
+ }
497
+ }
338
498
  }
339
499
  }
500
+ catch (error) {
501
+ console.warn('[extractInternalImportPathsAst] Failed to parse file:', error);
502
+ }
340
503
  return importPaths;
341
504
  }
342
505
  /**
@@ -433,46 +596,106 @@ function addMockToContent(fileContent, importedExport, fileAnalyses, rootAnalysi
433
596
  }
434
597
  // Check if we have multiple calls with different variable names
435
598
  // This requires generating separate mock functions for each call site
436
- const hasMultipleCallsWithVariables = importedExport.calls &&
437
- 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 &&
438
625
  importedExport.callVariableNames &&
439
- 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;
440
631
  let mockCode;
441
632
  const variableMockCodes = [];
442
633
  if (hasMultipleCallsWithVariables) {
443
634
  // Generate separate mock functions for each variable-qualified call
444
- // Track variable name occurrences to disambiguate when same variable is reused
445
- // (mirrors the logic in gatherDataForMocks)
635
+ // Look up canonical keys from dataForMocks and track variable names for function naming
636
+ // Get all call signature keys for this hook from dataForMocks
637
+ const dataForMocks = rootAnalysis.metadata?.scenariosDataStructure?.dataForMocks;
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;
644
+ })
645
+ : [];
646
+ // Track variable name occurrences for unique function naming
446
647
  const variableNameCounts = {};
447
- 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++) {
448
652
  const variableName = importedExport.callVariableNames[i];
449
653
  if (!variableName)
450
654
  continue;
451
655
  // Calculate the occurrence index for this variable name
452
656
  const occurrence = variableNameCounts[variableName] ?? 0;
453
657
  variableNameCounts[variableName] = occurrence + 1;
454
- // If this is a reused variable name (occurrence > 0), append index
455
- // e.g., "fetcher[1] <- useFetcher" for the second usage of "fetcher"
658
+ // Build indexed variable name for function naming
456
659
  const indexedVariableName = occurrence > 0 ? `${variableName}[${occurrence}]` : variableName;
457
- // Generate mock code for this specific call using variable-qualified name
458
- // Format: "variableName <- functionName" (reads as "variableName receives from functionName")
459
- const qualifiedName = `${indexedVariableName} <- ${importedExport.name}`;
460
- const variableMockCode = constructMockCode(qualifiedName, dependencySchemas, importedExport.entityType);
660
+ // Use safe function name with underscores instead of brackets
661
+ // e.g., fetcher[1] -> fetcher_1
662
+ const safeFunctionName = indexedVariableName.replace(/\[(\d+)\]/g, '_$1');
663
+ // Compute unique mock function name for call site replacement
664
+ // e.g., useFetcher_entityDiffFetcher, useFetcher_reportFetcher
665
+ const mockFunctionName = `${importedExport.name}_${safeFunctionName}`;
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
670
+ // This prevents "symbol already declared" errors when multiple calls exist
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
+ });
461
681
  if (variableMockCode) {
462
682
  variableMockCodes.push(variableMockCode);
463
683
  // Replace the call site with the variable-specific mock function
464
684
  // e.g., useFetcher<BranchEntityDiffResult>() -> useFetcher_entityDiffFetcher()
465
685
  // e.g., useFetcher() -> useFetcher_reportFetcher()
466
- // For indexed variables: useFetcher() -> useFetcher_fetcher_1()
467
- const callSignature = importedExport.calls[i];
468
686
  // Escape special regex characters in the call signature
469
687
  const escapedCallSignature = callSignature.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
470
- // Create regex that matches the call (with optional whitespace variations)
471
- const callRegex = new RegExp(escapedCallSignature.replace(/\s+/g, '\\s*'), 'g');
472
- // Use safe function name with underscores instead of brackets
473
- // e.g., fetcher[1] -> fetcher_1
474
- const safeFunctionName = indexedVariableName.replace(/\[(\d+)\]/g, '_$1');
475
- const mockFunctionName = `${importedExport.name}_${safeFunctionName}`;
688
+ // Create regex that matches the call (with optional whitespace variations).
689
+ // TypeScript formatters commonly break type parameters across lines, e.g.:
690
+ // useLoaderData<
691
+ // typeof loader
692
+ // >()
693
+ // So we allow optional whitespace around < and > delimiters, not just
694
+ // where whitespace already exists in the call signature string.
695
+ const callRegex = new RegExp(escapedCallSignature
696
+ .replace(/\s+/g, '\\s*')
697
+ .replace(/</g, '\\s*<\\s*')
698
+ .replace(/>/g, '\\s*>\\s*'), 'gs');
476
699
  fileContent = fileContent.replace(callRegex, `${mockFunctionName}()`);
477
700
  }
478
701
  }
@@ -487,66 +710,152 @@ function addMockToContent(fileContent, importedExport, fileAnalyses, rootAnalysi
487
710
  ? importedExport.callVariableNames[0]
488
711
  : undefined;
489
712
  if (singleCallVariableName) {
490
- // For single variable assignments, use the variable-qualified key for data lookup
491
- // Use constructMockCode to generate proper dispatch functions for nested function calls
492
- // (e.g., useTranslation returns { t } where t() needs to dispatch based on translation key)
493
- const qualifiedKey = `${singleCallVariableName} <- ${importedExport.name}`;
494
- // Keep the original function name since there's only one call - no need for unique names
495
- mockCode = constructMockCode(qualifiedKey, dependencySchemas, importedExport.entityType, { keepOriginalFunctionName: true });
713
+ // For single variable assignments, use the call signature directly from dataForMocks
714
+ const dataForMocks = rootAnalysis.metadata?.scenariosDataStructure?.dataForMocks;
715
+ // Find matching call signature key in dataForMocks
716
+ // IMPORTANT: First try exact match with type parameters (e.g., "useLoaderData<LoaderData>()")
717
+ // to avoid picking the wrong variant (e.g., "useLoaderData<typeof loader>()" which may
718
+ // have different properties). Fall back to base name matching only if exact match fails.
719
+ const hookBaseName = importedExport.name.split(/[<(]/)[0];
720
+ const expectedKey = importedExport.calls?.[0];
721
+ let callSignatureKey;
722
+ if (dataForMocks) {
723
+ const keys = Object.keys(dataForMocks);
724
+ // First try exact match with the expected call signature
725
+ if (expectedKey && keys.includes(expectedKey)) {
726
+ callSignatureKey = expectedKey;
727
+ }
728
+ else {
729
+ // Fall back to base name matching
730
+ callSignatureKey = keys.find((key) => {
731
+ // Split on ., <, or ( to get the true base name
732
+ // This handles both "useFlags()" -> "useFlags" and "trpc.useUtils()" -> "trpc"
733
+ const keyBaseName = key.split(/[.<(]/)[0];
734
+ return keyBaseName === hookBaseName;
735
+ });
736
+ }
737
+ }
738
+ // Use the call signature if found, otherwise construct it
739
+ const dataKey = callSignatureKey ??
740
+ importedExport.calls?.[0] ??
741
+ `${importedExport.name}()`;
742
+ // IMPORTANT: If the dataKey is a method chain (e.g., "trpc.useUtils()"), we should
743
+ // use the base name (e.g., "trpc") when calling constructMockCode. This ensures
744
+ // constructMockCode generates a complete nested mock from the schema without
745
+ // referencing __cyOriginal variables.
746
+ // NOTE: Only check for dots BEFORE the first open paren. Function calls with
747
+ // dotted arguments like "getSurveyWithMetadata(params.surveyId)" have dots
748
+ // INSIDE parens — these are NOT method chains and should keep the full signature.
749
+ const dataKeyBaseName = dataKey.split(/[.<(]/)[0];
750
+ const firstParenIndex = dataKey.indexOf('(');
751
+ const partBeforeFirstParen = firstParenIndex >= 0 ? dataKey.substring(0, firstParenIndex) : dataKey;
752
+ const isMethodChainDataKey = dataKeyBaseName === importedExport.name &&
753
+ dataKey !== importedExport.name &&
754
+ partBeforeFirstParen.includes('.');
755
+ const mockNameToUse = isMethodChainDataKey
756
+ ? importedExport.name
757
+ : dataKey;
758
+ // Keep the original function name since there's only one call
759
+ // Check if this is a package import that won't have scenario copies
760
+ const isPackageImportForSingleCall = importPath?.startsWith('@');
761
+ mockCode = constructMockCode(mockNameToUse, dependencySchemas, importedExport.entityType, undefined, {
762
+ keepOriginalFunctionName: true,
763
+ // For node_modules or package imports, skip spreading from __cyOriginal
764
+ // since those packages/files don't export *__cyOriginal variants
765
+ skipOriginalSpread: importedExport.isNodeModule || isPackageImportForSingleCall,
766
+ });
496
767
  // If constructMockCode didn't generate code, fall back to simple return
768
+ // IMPORTANT: We inline scenarios().data() inside the function rather than
769
+ // storing in a const - see comment in constructMockCode.ts for why.
497
770
  if (!mockCode) {
498
- mockCode = `const ${importedExport.name}ReturnValue = scenarios().data()?.["${qualifiedKey}"];
499
-
500
- function ${importedExport.name}() {
501
- return ${importedExport.name}ReturnValue;
771
+ mockCode = `// PATCHED: memoize to return stable reference (prevents infinite useEffect re-triggers)
772
+ const _${importedExport.name}Ref = {
773
+ current: null,
774
+ };
775
+ function ${importedExport.name}(...args) {
776
+ if (!_${importedExport.name}Ref.current) {
777
+ _${importedExport.name}Ref.current = scenarios().data()?.["${dataKey}"];
778
+ }
779
+ return _${importedExport.name}Ref.current;
502
780
  }`;
503
781
  }
504
782
  }
505
783
  else {
506
- // Check if any analysis (fileAnalyses or rootAnalysis) has this function's data
507
- // under a variable-qualified key. The entity that CALLS the function (e.g., FileTableRow)
508
- // has the dataForMocks with the variable-qualified key, not the root analysis (e.g., GitView).
509
- let variableQualifiedKey;
510
- // First check fileAnalyses (the analyses for the entity being written)
511
- for (const analysis of fileAnalyses) {
512
- const dataForMocks = analysis.metadata?.scenariosDataStructure?.dataForMocks;
513
- if (dataForMocks) {
514
- variableQualifiedKey = Object.keys(dataForMocks).find((key) => {
515
- const match = key.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\s*<-\s*(.+)$/);
516
- return match && match[2] === importedExport.name;
517
- });
518
- if (variableQualifiedKey) {
519
- break;
520
- }
784
+ // Helper to find matching call signature key from dataForMocks
785
+ // IMPORTANT: First try exact match with type parameters (e.g., "useLoaderData<LoaderData>()")
786
+ // to avoid picking the wrong variant. Fall back to base name matching only if needed.
787
+ const hookBaseName = importedExport.name.split(/[<(]/)[0];
788
+ const expectedKey = importedExport.calls?.[0];
789
+ const findMatchingKey = (dataForMocks) => {
790
+ if (!dataForMocks)
791
+ return undefined;
792
+ const keys = Object.keys(dataForMocks);
793
+ // First try exact match with the expected call signature
794
+ if (expectedKey && keys.includes(expectedKey)) {
795
+ return expectedKey;
521
796
  }
522
- }
523
- // If not found in fileAnalyses, fall back to rootAnalysis
524
- if (!variableQualifiedKey) {
525
- const dataForMocks = rootAnalysis.metadata?.scenariosDataStructure?.dataForMocks;
526
- if (dataForMocks) {
527
- variableQualifiedKey = Object.keys(dataForMocks).find((key) => {
528
- const match = key.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\s*<-\s*(.+)$/);
529
- return match && match[2] === importedExport.name;
530
- });
797
+ // Fall back to base name matching
798
+ return keys.find((key) => {
799
+ // Split on ., <, or ( to get the true base name
800
+ // This handles both "useFlags()" -> "useFlags" and "trpc.useUtils()" -> "trpc"
801
+ const keyBaseName = key.split(/[.<(]/)[0];
802
+ return keyBaseName === hookBaseName;
803
+ });
804
+ };
805
+ // Check rootAnalysis FIRST for matching keys.
806
+ // The mock DATA is generated from rootAnalysis, so the mock CODE must
807
+ // also use rootAnalysis keys to ensure the lookup succeeds.
808
+ let dataKey = findMatchingKey(rootAnalysis.metadata?.scenariosDataStructure?.dataForMocks);
809
+ // If not found in rootAnalysis, fall back to fileAnalyses
810
+ if (!dataKey) {
811
+ for (const analysis of fileAnalyses) {
812
+ dataKey = findMatchingKey(analysis.metadata?.scenariosDataStructure?.dataForMocks);
813
+ if (dataKey)
814
+ break;
531
815
  }
532
816
  }
533
- if (variableQualifiedKey) {
534
- // Use the variable-qualified key found in the analysis
535
- // Use constructMockCode to generate proper dispatch functions for nested function calls
536
- // Keep the original function name since there's only one call - no need for unique names
537
- mockCode = constructMockCode(variableQualifiedKey, dependencySchemas, importedExport.entityType, { keepOriginalFunctionName: true });
538
- // If constructMockCode didn't generate code, fall back to simple return
539
- if (!mockCode) {
540
- mockCode = `const ${importedExport.name}ReturnValue = scenarios().data()?.["${variableQualifiedKey}"];
541
-
542
- function ${importedExport.name}() {
543
- return ${importedExport.name}ReturnValue;
817
+ // Use the data key if found, otherwise use call signature or function name.
818
+ // IMPORTANT: If the dataKey is a method chain (e.g., "trpc.useUtils()"), we should
819
+ // use the base name (e.g., "trpc") when calling constructMockCode. This ensures
820
+ // constructMockCode generates a complete nested mock from the schema without
821
+ // referencing __cyOriginal variables. The __cyOriginal pattern is only needed
822
+ // for partial mocking where we preserve some original methods, not for complete
823
+ // method-chain mocks where we provide all implementations.
824
+ // NOTE: Only check for dots BEFORE the first open paren. Function calls with
825
+ // dotted arguments like "getSurveyWithMetadata(params.surveyId)" have dots
826
+ // INSIDE parens — these are NOT method chains and should keep the full signature.
827
+ const dataKeyBaseName = dataKey?.split(/[.<(]/)[0];
828
+ const elseFirstParenIndex = dataKey?.indexOf('(') ?? -1;
829
+ const elsePartBeforeFirstParen = dataKey && elseFirstParenIndex >= 0
830
+ ? dataKey.substring(0, elseFirstParenIndex)
831
+ : dataKey;
832
+ const isMethodChainDataKey = dataKey &&
833
+ dataKeyBaseName === importedExport.name &&
834
+ dataKey !== importedExport.name &&
835
+ (elsePartBeforeFirstParen?.includes('.') ?? false);
836
+ const mockNameToUse = isMethodChainDataKey
837
+ ? importedExport.name
838
+ : (dataKey ?? importedExport.calls?.[0] ?? `${importedExport.name}()`);
839
+ mockCode = constructMockCode(mockNameToUse, dependencySchemas, importedExport.entityType, undefined, {
840
+ keepOriginalFunctionName: true,
841
+ // For node_modules or package imports, skip spreading from __cyOriginal
842
+ // since those packages/files don't export *__cyOriginal variants
843
+ skipOriginalSpread: importedExport.isNodeModule || importPath?.startsWith('@'),
844
+ });
845
+ // If constructMockCode didn't generate code, fall back to simple return
846
+ // IMPORTANT: We inline scenarios().data() inside the function rather than
847
+ // storing in a const - see comment in constructMockCode.ts for why.
848
+ if (!mockCode && dataKey) {
849
+ mockCode = `// PATCHED: memoize to return stable reference (prevents infinite useEffect re-triggers)
850
+ const _${importedExport.name}Ref = {
851
+ current: null,
852
+ };
853
+ function ${importedExport.name}(...args) {
854
+ if (!_${importedExport.name}Ref.current) {
855
+ _${importedExport.name}Ref.current = scenarios().data()?.["${dataKey}"];
856
+ }
857
+ return _${importedExport.name}Ref.current;
544
858
  }`;
545
- }
546
- }
547
- else {
548
- // Original behavior for calls without variable names
549
- mockCode = constructMockCode(importedExport.name, dependencySchemas, importedExport.entityType);
550
859
  }
551
860
  }
552
861
  }
@@ -565,13 +874,44 @@ function ${importedExport.name}() {
565
874
  else {
566
875
  // Escape regex special characters in importPath (e.g., brackets in [environmentId])
567
876
  const escapedImportPath = importPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
568
- const importRegExp = new RegExp(`(import(?:(?!${firstPart}|from|import)[\\s\\S])*?)${firstPart}(?:,\\s*)?((?:(?!import)[\\s\\S])*?from\\s+['"]${escapedImportPath}['"])`, 'm');
569
- if (importedExportNameParts.length > 1) {
877
+ // Use a simpler, more robust regex pattern that matches the fallback path.
878
+ // Key improvements:
879
+ // 1. Uses escapeRegExp(firstPart) to handle special characters in function names
880
+ // 2. Uses word boundaries (\b) to prevent partial matches
881
+ // 3. Handles comma BEFORE or AFTER the name: (?:,\s*|\s*,)?
882
+ // 4. Matches specific import path (escapedImportPath)
883
+ const importRegExp = new RegExp(`(import\\s*\\{[^}]*?)\\b${escapeRegExp(firstPart)}\\b(?:,\\s*|\\s*,)?((?:[^}]*\\}\\s*from\\s*['"]${escapedImportPath}['"];?))`, 'm');
884
+ // Check if any call signature has multiple parts (e.g., "logger.error(error)")
885
+ // If so, the mock code will spread from __cyOriginal, so we need to rename the import
886
+ // EXCEPT:
887
+ // 1. For node_module imports, the __cyOriginal pattern doesn't work because
888
+ // the original package doesn't export *__cyOriginal variants.
889
+ // 2. For package imports (starting with @), the __cyOriginal pattern doesn't work
890
+ // because scenario copies aren't created for package files - they keep the
891
+ // original import path which doesn't export *__cyOriginal.
892
+ const anyCallHasMultipleParts = importedExport.calls?.some((call) => {
893
+ const callParts = splitOutsideParenthesesAndArrays(call);
894
+ return callParts.length > 1;
895
+ });
896
+ // Package imports (starting with @) don't get scenario copies, so __cyOriginal won't exist
897
+ const isPackageImport = importPath.startsWith('@');
898
+ const shouldRenameToOriginal = !importedExport.isNodeModule &&
899
+ !isPackageImport &&
900
+ (importedExportNameParts.length > 1 || anyCallHasMultipleParts);
901
+ if (shouldRenameToOriginal) {
570
902
  fileContent = fileContent.replace(importRegExp, `$1${firstPart}__cyOriginal$2`);
571
903
  }
572
904
  else {
573
905
  fileContent = fileContent.replace(importRegExp, '$1$2');
574
906
  }
907
+ // Also handle namespace imports (import * as foo from '...')
908
+ // These need to be renamed to foo__cyOriginal when the mock code spreads from the original.
909
+ // Note: We match any path (not just escapedImportPath) because the import path may have
910
+ // been rewritten by transitive import handling before this code runs.
911
+ if (shouldRenameToOriginal) {
912
+ const namespaceImportRegExp = new RegExp(`(import\\s+\\*\\s+as\\s+)${escapeRegExp(firstPart)}(\\s+from\\s+['"][^'"]*['"])`, 'm');
913
+ fileContent = fileContent.replace(namespaceImportRegExp, `$1${firstPart}__cyOriginal$2`);
914
+ }
575
915
  // Remove empty imports entirely to avoid partial commenting issues with multiline imports
576
916
  // This handles both single-line and multiline empty imports
577
917
  fileContent = fileContent.replace(/import\s*\{\s*\}\s*from\s+['"][^'"]*['"];?\s*\n?/g, '');
@@ -587,7 +927,17 @@ function ${importedExport.name}() {
587
927
  // This handles imports like: import { useEnvironment, otherThing } from "any/path"
588
928
  // Removes useEnvironment but keeps otherThing
589
929
  const namedImportRegExp = new RegExp(`(import\\s*\\{[^}]*?)\\b${escapeRegExp(firstPart)}\\b(?:,\\s*|\\s*,)?((?:[^}]*\\}\\s*from\\s*['"][^'"]*['"];?))`, 'm');
590
- if (importedExportNameParts.length > 1) {
930
+ // Check if any call signature has multiple parts (e.g., "logger.error(error)")
931
+ // If so, the mock code will spread from __cyOriginal, so we need to rename the import
932
+ // EXCEPT: For node_module imports, the __cyOriginal pattern doesn't work because
933
+ // the original package doesn't export *__cyOriginal variants.
934
+ const anyCallHasMultipleParts = importedExport.calls?.some((call) => {
935
+ const callParts = splitOutsideParenthesesAndArrays(call);
936
+ return callParts.length > 1;
937
+ });
938
+ const shouldRenameToOriginal = !importedExport.isNodeModule &&
939
+ (importedExportNameParts.length > 1 || anyCallHasMultipleParts);
940
+ if (shouldRenameToOriginal) {
591
941
  // Rename the import instead of removing (for destructured access patterns)
592
942
  fileContent = fileContent.replace(namedImportRegExp, `$1${firstPart}__cyOriginal$2`);
593
943
  }
@@ -764,6 +1114,14 @@ function captureArgumentsForTesting(args) {
764
1114
  }
765
1115
  export default async function writeScenarioComponents({ project, file, entity, rootAnalysis, scenario, context, projectAnalyzer, framework, mocksDir, rootFile, namespaceMocks, writtenScenarioComponents = {}, fileStore, exportAsNamed, }) {
766
1116
  var _a;
1117
+ // Reset debug timing for this invocation
1118
+ resetDebugTiming();
1119
+ debugLog('START writeScenarioComponents', {
1120
+ filePath: file.path,
1121
+ entityName: entity.name,
1122
+ scenarioName: scenario.name,
1123
+ isRootFile: !rootFile || rootFile === file,
1124
+ });
767
1125
  // Capture arguments for testing if debug mode is enabled
768
1126
  captureArgumentsForTesting({
769
1127
  project,
@@ -907,7 +1265,23 @@ export default async function writeScenarioComponents({ project, file, entity, r
907
1265
  return 1;
908
1266
  return 0;
909
1267
  });
1268
+ debugLog('Starting main importedExports loop', {
1269
+ count: sortedImportedExports.length,
1270
+ fileContentLength: fileContent.length,
1271
+ });
1272
+ let importedExportIndex = 0;
1273
+ const loopStartTime = Date.now();
1274
+ console.log(`[WriteScenario] Starting import loop for ${entity.name}: ${sortedImportedExports.length} imports`);
910
1275
  for (const importedExport of sortedImportedExports) {
1276
+ importedExportIndex++;
1277
+ if (importedExportIndex % 5 === 0 || importedExportIndex === 1) {
1278
+ console.log(`[WriteScenario] ${entity.name} import ${importedExportIndex}/${sortedImportedExports.length}: ${importedExport.name} elapsed=${Date.now() - loopStartTime}ms`);
1279
+ debugLog(`Processing importedExport ${importedExportIndex}/${sortedImportedExports.length}`, {
1280
+ name: importedExport.name,
1281
+ filePath: importedExport.filePath,
1282
+ isMocked: importedExport.isMocked,
1283
+ });
1284
+ }
911
1285
  // IMPORTANT: The import mapping keys may be either absolute or relative paths
912
1286
  // depending on how they were created by the file analyzer. We try multiple formats.
913
1287
  // Also need to normalize paths to handle /tmp vs /private/tmp on macOS
@@ -1007,6 +1381,12 @@ export default async function writeScenarioComponents({ project, file, entity, r
1007
1381
  // Strip server-only imports - these break when imported by client components
1008
1382
  dataFileContent = stripServerOnlyImport(dataFileContent);
1009
1383
  dataFileContent = applyServerOnlyMocks(dataFileContent);
1384
+ // Process transitive imports: if the data entity file imports from files
1385
+ // that have `import "server-only"`, rewrite those imports to transitive
1386
+ // copies with server-only stripped. Without this, data entity files that
1387
+ // end up in a client bundle (e.g., via a stripped "use server" boundary)
1388
+ // would pull in server-only code and cause build failures.
1389
+ dataFileContent = await processTransitiveImportsRecursively(dataFileContent, fileNotMocked.path, dataScenarioPath);
1010
1390
  // Write the transformed data entity file
1011
1391
  await writeFile(dataScenarioPath, dataFileContent);
1012
1392
  scenarioComponentPaths.push(dataScenarioPath);
@@ -1023,9 +1403,9 @@ export default async function writeScenarioComponents({ project, file, entity, r
1023
1403
  writtenScenarioComponents[importedExportFilePath] = [];
1024
1404
  }
1025
1405
  writtenScenarioComponents[importedExportFilePath].push(importedExport.name);
1026
- // Don't recurse - data entities don't need their dependencies processed
1027
- // The import rewriting will happen later in this same loop iteration
1028
- // (at lines ~1590-1702) to point imports to this transformed file
1406
+ // Don't recurse into full writeScenarioComponents - data entities don't
1407
+ // need mock generation for their dependencies. Transitive server-only
1408
+ // import processing is already handled above via processTransitiveImportsRecursively.
1029
1409
  }
1030
1410
  else {
1031
1411
  // For visual/library entities, recurse to process their dependencies
@@ -1034,7 +1414,13 @@ export default async function writeScenarioComponents({ project, file, entity, r
1034
1414
  // e.g., if file has `export default X` but parent does `import { X } from '...'`
1035
1415
  const needsNamedReExport = importedExport.resolvedIsDefault === true &&
1036
1416
  importedExport.isDefault === false;
1037
- const { scenarioComponentPaths: newScenarioComponentPaths, writtenScenarioComponents: updatedWrittenScenarioComponents, } = await writeScenarioComponents({
1417
+ console.log(`[WriteScenario] RECURSE START: ${entity.name} -> ${importedExportEntity.name}`);
1418
+ const recurseStartTime = Date.now();
1419
+ debugLog(`Recursing into writeScenarioComponents for ${importedExportEntity.name}`, {
1420
+ entityName: importedExportEntity.name,
1421
+ filePath: fileNotMocked.path,
1422
+ });
1423
+ const { scenarioComponentPaths: newScenarioComponentPaths, writtenScenarioComponents: updatedWrittenScenarioComponents, } = await withTimeout(`recursive writeScenarioComponents for ${importedExportEntity.name}`, writeScenarioComponents({
1038
1424
  project,
1039
1425
  file: fileNotMocked,
1040
1426
  entity: importedExportEntity,
@@ -1052,7 +1438,9 @@ export default async function writeScenarioComponents({ project, file, entity, r
1052
1438
  exportAsNamed: needsNamedReExport
1053
1439
  ? importedExport.name
1054
1440
  : undefined,
1055
- });
1441
+ }), 180000);
1442
+ console.log(`[WriteScenario] RECURSE END: ${entity.name} -> ${importedExportEntity.name} took ${Date.now() - recurseStartTime}ms`);
1443
+ debugLog(`Completed recursive writeScenarioComponents for ${importedExportEntity.name}`);
1056
1444
  writtenScenarioComponents = updatedWrittenScenarioComponents;
1057
1445
  scenarioComponentPaths.push(...newScenarioComponentPaths);
1058
1446
  }
@@ -1070,13 +1458,22 @@ export default async function writeScenarioComponents({ project, file, entity, r
1070
1458
  // Data and type entities should be preserved - they're not callable and may have methods
1071
1459
  // that stubbing would break (e.g., Zod schemas with .superRefine())
1072
1460
  const isDataEntity = entityType === 'data' || entityType === 'type';
1073
- // Heuristic: Zod schemas are often misclassified as 'library' but should be preserved
1074
- // Detect by: name starts with Z + uppercase letter, AND has Zod method calls
1075
- const looksLikeZodSchema = entityType === 'library' &&
1076
- /^Z[A-Z]/.test(importedExport.name) &&
1077
- importedExport.calls?.some((call) => /\.(superRefine|refine|transform|default|optional|nullable|array|object|string|number|boolean|parse|safeParse)\s*\(/.test(call));
1078
- // Callable entities can be safely stubbed (but not Zod schemas)
1079
- const isCallable = !isDataEntity && !looksLikeZodSchema && entityType !== undefined;
1461
+ // If calls data shows the entity is only accessed via properties/methods
1462
+ // (e.g., formValidator.validate(), schema.superRefine()) and never directly
1463
+ // invoked (e.g., getInitialProps()), it's used as an object and should be
1464
+ // preserved rather than replaced with a Proxy stub.
1465
+ const onlyPropertyAccessed = importedExport.calls?.length > 0 &&
1466
+ !importedExport.calls.some((call) => {
1467
+ const afterName = call.slice(importedExport.name.length);
1468
+ return afterName.startsWith('(') || afterName.startsWith('<');
1469
+ });
1470
+ // Callable entities can be safely stubbed. Entities that are only
1471
+ // property-accessed should be preserved (their methods need to work).
1472
+ // 'other' entities are unknown types — safer to preserve than stub.
1473
+ const isCallable = !isDataEntity &&
1474
+ !onlyPropertyAccessed &&
1475
+ entityType !== undefined &&
1476
+ entityType !== 'other';
1080
1477
  // Determine what action to take
1081
1478
  const shouldStripAndReplace = hasMock;
1082
1479
  const shouldStripAndStub = !hasMock && importedExport.isMocked && isCallable;
@@ -1286,9 +1683,7 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1286
1683
  : `import { ${entityImportName} } from '${path}';`;
1287
1684
  // First, try to remove this entity from the already-rewritten grouped import
1288
1685
  // This prevents duplicate/conflicting imports
1289
- // IMPORTANT: Only remove from import statements, NOT from the entire file!
1290
- // The global patterns used previously would also match type annotations like:
1291
- // "param: MyType," in function signatures, corrupting the syntax.
1686
+ // Use AST-based removal to properly handle type-only imports like `type EntityName`
1292
1687
  const escapedEntityName = escapeRegExp(entityImportName);
1293
1688
  // For default imports: remove "DefaultName, " from "import DefaultName, { ... }"
1294
1689
  // This handles the case where a default export is being split out
@@ -1296,27 +1691,12 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1296
1691
  const defaultImportPattern = new RegExp(`(import\\s+)${escapedEntityName}\\s*,\\s*(\\{)`, 'gm');
1297
1692
  fileContent = fileContent.replace(defaultImportPattern, '$1$2');
1298
1693
  }
1299
- // Match import statements that contain this entity and remove just the entity
1300
- // Pattern: import { ... EntityName, ... } from '...'
1301
- // We match the full import and use a replacer function to remove the entity name
1302
- const importWithEntityPattern = new RegExp(`(import\\s*\\{)([^}]*\\b${escapedEntityName}\\b[^}]*)(\\}\\s*from\\s*['"][^'"]*['"];?)`, 'gm');
1303
- fileContent = fileContent.replace(importWithEntityPattern, (match, prefix, namedImports, suffix) => {
1304
- // Remove the entity name from the named imports
1305
- let cleaned = namedImports
1306
- .replace(new RegExp(`\\b${escapedEntityName}\\s*,\\s*`), '') // "EntityName, "
1307
- .replace(new RegExp(`\\s*,\\s*${escapedEntityName}\\b`), '') // ", EntityName"
1308
- .replace(new RegExp(`\\b${escapedEntityName}\\b`), ''); // "EntityName" (only one)
1309
- // Clean up any double commas or leading/trailing commas
1310
- cleaned = cleaned
1311
- .replace(/,\s*,/g, ',')
1312
- .replace(/^\s*,\s*/, '')
1313
- .replace(/\s*,\s*$/, '');
1314
- // If no imports left, remove the entire import statement
1315
- if (cleaned.trim() === '') {
1316
- return '';
1317
- }
1318
- return prefix + cleaned + suffix;
1319
- });
1694
+ // Remove the named import using AST parsing
1695
+ // This properly handles:
1696
+ // - Regular imports: `import { EntityName } from '...'`
1697
+ // - Type-only imports: `import { type EntityName } from '...'`
1698
+ // - Mixed imports: `import { type EntityName, OtherName } from '...'`
1699
+ fileContent = removeNamedImportAst(fileContent, entityImportName);
1320
1700
  // Add the new import at the beginning of fileContent
1321
1701
  // Note: The header comment (// Scenario:) doesn't exist yet - it's prepended at writeFile time
1322
1702
  // So prepending here puts the import right after the header in the final output
@@ -1330,17 +1710,30 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1330
1710
  }
1331
1711
  }
1332
1712
  }
1713
+ // Track post-import-loop timing
1714
+ const postLoopStartTime = Date.now();
1715
+ console.log(`[WriteScenario] POST-LOOP START: ${entity.name}`);
1716
+ // Collect universal mocks BEFORE processing nodeModuleImports
1717
+ // This is needed to check if a node module import is handled by a universal mock
1718
+ const universalMocks = project.metadata?.universalMocks ?? [];
1719
+ const nodeModuleUniversalMocks = universalMocks.filter((mock) => mock.nodeModule && mock.content);
1720
+ // Create a set of import paths that have universal mocks for quick lookup
1721
+ const universalMockPaths = new Set(nodeModuleUniversalMocks.map((mock) => mock.filePath));
1333
1722
  for (const nodeModuleImport of nodeModuleImports) {
1334
1723
  if (!nodeModuleImport.isMocked)
1335
1724
  continue;
1725
+ // Skip generating local mock functions for imports that have universal mocks.
1726
+ // Universal mocks provide the exports via rewritten import paths (handled below).
1727
+ // Generating a local mock function would cause "name defined multiple times" errors.
1728
+ if (universalMockPaths.has(nodeModuleImport.filePath)) {
1729
+ continue;
1730
+ }
1336
1731
  fileContent = addMockToContent(fileContent, nodeModuleImport, fileAnalyses, rootAnalysis, relativeMocksDir, scenario.name, importMapping[nodeModuleImport.filePath] ?? nodeModuleImport.filePath);
1337
1732
  }
1338
1733
  // Rewrite node_module imports that have universal mocks
1339
1734
  // Universal mocks create mock files at __codeyamMocks__/{safeFileName}.tsx
1340
1735
  // We need to rewrite imports like `import { logger } from "@formbricks/logger"`
1341
1736
  // to `import { logger } from "../__codeyamMocks__/_formbricks_logger.js"`
1342
- const universalMocks = project.metadata?.universalMocks ?? [];
1343
- const nodeModuleUniversalMocks = universalMocks.filter((mock) => mock.nodeModule && mock.content);
1344
1737
  for (const universalMock of nodeModuleUniversalMocks) {
1345
1738
  const originalPath = universalMock.filePath;
1346
1739
  // Create the mock file name using the same safeFileName function as writeUniversalMocks
@@ -1353,6 +1746,7 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1353
1746
  const importRegex = new RegExp(`(import\\s+(?:\\{[^}]*\\}|\\*\\s+as\\s+\\w+|\\w+)\\s+from\\s+)['"]${originalPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}['"]`, 'g');
1354
1747
  fileContent = fileContent.replace(importRegex, `$1'${mockFileRelativePath}'`);
1355
1748
  }
1749
+ console.log(`[WriteScenario] POST-LOOP ${entity.name}: node+universal mocks took ${Date.now() - postLoopStartTime}ms`);
1356
1750
  if (rootAnalysis.entitySha === entity.sha &&
1357
1751
  entity.metadata?.notExported &&
1358
1752
  entity.name !== 'default') {
@@ -1388,20 +1782,31 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1388
1782
  scenario,
1389
1783
  });
1390
1784
  }
1785
+ debugLog('Route path computed', { scenarioComponentPath });
1391
1786
  // Strip <html> and <body> tags from root layout files for Next.js
1392
1787
  // These tags cause hydration errors when the scenario layout is nested under the real root
1788
+ debugLog('Starting stripHtmlBodyTags');
1393
1789
  fileContent = stripHtmlBodyTags(fileContent, file.path, framework);
1790
+ debugLog('Completed stripHtmlBodyTags');
1394
1791
  // Strip "server-only" imports for Next.js
1395
1792
  // These cause errors when the scenario component is rendered client-side
1793
+ debugLog('Starting stripServerOnlyImport');
1396
1794
  fileContent = stripServerOnlyImport(fileContent);
1795
+ debugLog('Starting applyServerOnlyMocks');
1397
1796
  fileContent = applyServerOnlyMocks(fileContent);
1797
+ debugLog('Completed server-only processing');
1398
1798
  // Rewrite asset imports (CSS, images, fonts, etc.) to correct relative paths
1399
1799
  // The original file path is relative to PROJECT_RELATIVE_PATH, the new path is scenarioComponentPath
1800
+ debugLog('Starting rewriteAssetImports');
1400
1801
  fileContent = rewriteAssetImports(fileContent, `${PROJECT_RELATIVE_PATH}/${file.path}`, scenarioComponentPath);
1802
+ debugLog('Completed rewriteAssetImports');
1401
1803
  // Rewrite relative TypeScript/JavaScript module imports to correct relative paths
1402
1804
  // This handles cases where the file is moved (e.g., from [environmentId]/ to _environmentId_/)
1403
1805
  // and relative imports like "./lib/organization" need to be rewritten
1806
+ debugLog('Starting rewriteRelativeModuleImports');
1404
1807
  fileContent = rewriteRelativeModuleImports(fileContent, `${PROJECT_RELATIVE_PATH}/${file.path}`, scenarioComponentPath);
1808
+ debugLog('Completed rewriteRelativeModuleImports');
1809
+ console.log(`[WriteScenario] POST-LOOP ${entity.name}: transformations took ${Date.now() - postLoopStartTime}ms`);
1405
1810
  /**
1406
1811
  * Recursively process a file's imports to create transitive copies with server-only stripped.
1407
1812
  * This handles chains of arbitrary depth: A -> B -> C -> D where each needs server-only removed.
@@ -1413,24 +1818,56 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1413
1818
  * @param visitedPaths - Set of file paths currently being processed (for cycle detection)
1414
1819
  * @returns The modified content with imports rewritten to point to transitive copies
1415
1820
  */
1416
- async function processTransitiveImportsRecursively(content, sourceFilePath, targetFilePath, visitedPaths = new Set()) {
1821
+ async function processTransitiveImportsRecursively(content, sourceFilePath, targetFilePath, visitedPaths = new Set(), depth = 0, startTime = Date.now()) {
1822
+ // Global timeout for entire transitive processing
1823
+ const GLOBAL_TIMEOUT_MS = 180000; // 3 minutes max for all transitive processing (complex components need more time)
1824
+ const elapsed = Date.now() - startTime;
1825
+ if (elapsed > GLOBAL_TIMEOUT_MS) {
1826
+ throw new Error(`processTransitiveImportsRecursively exceeded ${GLOBAL_TIMEOUT_MS}ms (elapsed: ${elapsed}ms) at depth=${depth} for ${sourceFilePath}`);
1827
+ }
1417
1828
  const importPaths = extractInternalImportPaths(content);
1829
+ // Always log to help debug timeout issues
1830
+ console.log(`[TransitiveImports] depth=${depth} file=${path.basename(sourceFilePath)} imports=${importPaths.length} visited=${visitedPaths.size} elapsed=${Date.now() - startTime}ms`);
1831
+ debugLog(`processTransitiveImportsRecursively depth=${depth}`, {
1832
+ sourceFilePath,
1833
+ importCount: importPaths.length,
1834
+ visitedCount: visitedPaths.size,
1835
+ });
1418
1836
  let modifiedContent = content;
1419
- for (const importPath of importPaths) {
1837
+ // Safety check: limit iterations to prevent infinite loops
1838
+ const MAX_IMPORTS_PER_FILE = 100;
1839
+ if (importPaths.length > MAX_IMPORTS_PER_FILE) {
1840
+ console.warn(`[WriteScenario] WARNING: File ${sourceFilePath} has ${importPaths.length} imports (> ${MAX_IMPORTS_PER_FILE}), limiting processing`);
1841
+ }
1842
+ let importIndex = 0;
1843
+ debugLog(`Starting import loop at depth=${depth}, ${importPaths.length} imports to process`);
1844
+ const slicedImports = importPaths.slice(0, MAX_IMPORTS_PER_FILE);
1845
+ for (const importPath of slicedImports) {
1846
+ if (!importPath) {
1847
+ continue;
1848
+ }
1849
+ importIndex++;
1850
+ debugLog(`[LOOP] depth=${depth} import ${importIndex}/${Math.min(importPaths.length, MAX_IMPORTS_PER_FILE)}: ${importPath}`);
1851
+ debugLog(`[LOOP] Calling resolveImportPath...`);
1420
1852
  const resolvedPath = resolveImportPath(importPath, sourceFilePath, project);
1853
+ debugLog(`[LOOP] resolveImportPath returned: ${resolvedPath?.slice(0, 80) ?? 'null'}`);
1421
1854
  if (!resolvedPath)
1422
1855
  continue;
1856
+ debugLog(`[LOOP] Looking up importFile...`);
1423
1857
  let importFile = fileStore
1424
1858
  ? fileStore.getByPath(resolvedPath)
1425
1859
  : project.files?.find((f) => f.path === resolvedPath);
1860
+ debugLog(`[LOOP] importFile lookup result: ${importFile ? 'found' : 'not found'}`);
1426
1861
  if (!importFile)
1427
1862
  continue;
1428
1863
  // Build the transitive file path (needed for import rewriting even if we skip creating)
1429
1864
  const basePath = safeFolder(importFile.path.split('/').slice(0, -1).join('/'));
1430
1865
  const extension = importFile.name.split('.').pop();
1431
1866
  const isIndex = isIndexPath(importFile.path);
1432
- const pathHash = safeFileName(importFile.path);
1433
- const transitiveFilePath = `${PROJECT_RELATIVE_PATH}/${basePath}/${pathHash}_${isIndex ? 'index_' : ''}transitive_${safeFileName(scenario.name)}.${extension}`;
1867
+ // Limit pathHash length to prevent ENAMETOOLONG errors on macOS (255 char limit)
1868
+ const pathHash = safeFileName(importFile.path, { maxLength: 80 });
1869
+ const scenarioSlug = safeFileName(scenario.name, { maxLength: 60 });
1870
+ const transitiveFilePath = `${PROJECT_RELATIVE_PATH}/${basePath}/${pathHash}_${isIndex ? 'index_' : ''}transitive_${scenarioSlug}.${extension}`;
1434
1871
  // Check if this is a circular import (we're already processing this file)
1435
1872
  const isCircularImport = visitedPaths.has(resolvedPath);
1436
1873
  // Check if already processed
@@ -1450,8 +1887,17 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1450
1887
  // Strip server-only and mock server-only packages, then recursively process imports
1451
1888
  let transitiveContent = stripServerOnlyImport(importFile.content);
1452
1889
  transitiveContent = applyServerOnlyMocks(transitiveContent);
1453
- transitiveContent = await processTransitiveImportsRecursively(transitiveContent, importFile.path, transitiveFilePath, visitedPaths);
1890
+ debugLog(`processTransitiveImportsRecursively depth=${depth} for ${importFile.path}`);
1891
+ debugLog(`Calling processTransitiveImportsRecursively depth=${depth + 1} for ${importFile.path}`);
1892
+ transitiveContent = await withTimeout(`processTransitiveImportsRecursively depth=${depth} for ${path.basename(importFile.path)}`, processTransitiveImportsRecursively(transitiveContent, importFile.path, transitiveFilePath, visitedPaths, depth + 1, startTime), 30000);
1893
+ debugLog(`withTimeout returned for depth=${depth}, transitiveContent length=${transitiveContent.length}`);
1894
+ debugLog(`Completed processTransitiveImportsRecursively depth=${depth} for ${importFile.path}`);
1895
+ debugLog(`Writing transitive file depth=${depth}`, {
1896
+ transitiveFilePath: path.basename(transitiveFilePath),
1897
+ contentLength: transitiveContent.length,
1898
+ });
1454
1899
  await writeFile(transitiveFilePath, transitiveContent);
1900
+ debugLog(`Wrote transitive file depth=${depth}`);
1455
1901
  scenarioComponentPaths.push(transitiveFilePath);
1456
1902
  if (!writtenScenarioComponents[resolvedPath]) {
1457
1903
  writtenScenarioComponents[resolvedPath] = [];
@@ -1461,22 +1907,74 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1461
1907
  }
1462
1908
  // ALWAYS rewrite the import to point to the transitive copy
1463
1909
  // (even for circular imports or already-processed files)
1910
+ debugLog(`Rewriting import path depth=${depth}`, {
1911
+ importPath,
1912
+ resolvedPath,
1913
+ });
1464
1914
  const relativePath = getRelativePath(targetFilePath, transitiveFilePath);
1465
1915
  const relativePathWithoutExt = relativePath.replace(/\.(ts|tsx|js|jsx)$/, '');
1466
1916
  const safeRelativePath = safeFolder(relativePathWithoutExt);
1467
1917
  const escapedImportPath = importPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1468
- const importRegex = new RegExp(`(from\\s*["'])${escapedImportPath}(["'])`, 'g');
1469
- modifiedContent = modifiedContent.replace(importRegex, `$1${safeRelativePath}$2`);
1918
+ debugLog(`Applying regex depth=${depth}`, {
1919
+ escapedImportPath,
1920
+ contentLength: modifiedContent.length,
1921
+ });
1922
+ // Quick check if the import path even exists in content
1923
+ const simpleCheck = modifiedContent.includes(importPath);
1924
+ debugLog(`Simple check: importPath "${importPath}" exists: ${simpleCheck}`);
1925
+ if (!simpleCheck) {
1926
+ debugLog(`Skipping regex - import path not found in content`);
1927
+ }
1928
+ else {
1929
+ const regexPattern = `(from\\s*["'])${escapedImportPath}(["'])`;
1930
+ debugLog(`Regex pattern: ${regexPattern.slice(0, 100)}`);
1931
+ const importRegex = new RegExp(regexPattern, 'g');
1932
+ debugLog(`About to call replace...`);
1933
+ // Timing for regex replace to detect slow operations
1934
+ const replaceStart = Date.now();
1935
+ modifiedContent = modifiedContent.replace(importRegex, `$1${safeRelativePath}$2`);
1936
+ const replaceTime = Date.now() - replaceStart;
1937
+ if (replaceTime > 100) {
1938
+ console.warn(`[WriteScenario] SLOW regex replace: ${replaceTime}ms for pattern ${regexPattern.slice(0, 50)} on ${modifiedContent.length} bytes`);
1939
+ }
1940
+ debugLog(`Regex applied depth=${depth} in ${replaceTime}ms`);
1941
+ }
1942
+ debugLog(`[LOOP END] depth=${depth} import ${importIndex} completed`);
1470
1943
  }
1944
+ debugLog(`[LOOP DONE] Exiting import loop at depth=${depth}`);
1945
+ debugLog(`Returning from processTransitiveImportsRecursively depth=${depth}`);
1471
1946
  return modifiedContent;
1472
1947
  }
1948
+ console.log(`[WriteScenario] POST-LOOP ${entity.name}: before remaining imports ${Date.now() - postLoopStartTime}ms`);
1473
1949
  // Process remaining internal imports that weren't in importedExports
1474
1950
  // This handles transitive dependencies: when the file content includes code (e.g., from
1475
1951
  // other functions in the same file) that imports from files with "server-only"
1952
+ debugLog('Extracting remaining import paths');
1476
1953
  const remainingImportPaths = extractInternalImportPaths(fileContent);
1954
+ debugLog('Found remaining import paths', {
1955
+ count: remainingImportPaths.length,
1956
+ });
1477
1957
  // Get all file paths that are in importedExports - these are handled by main processing
1478
1958
  const importedExportFilePaths = new Set(allImportedExports.map((ie) => ie.resolvedFilePath || ie.filePath));
1959
+ debugLog('Starting remaining imports loop', {
1960
+ remainingCount: remainingImportPaths.length,
1961
+ importedExportCount: importedExportFilePaths.size,
1962
+ });
1963
+ let remainingImportIndex = 0;
1964
+ debugLog(`[REMAINING] Starting remaining imports loop, ${remainingImportPaths.length} imports`);
1479
1965
  for (const importPath of remainingImportPaths) {
1966
+ remainingImportIndex++;
1967
+ debugLog(`[REMAINING LOOP] import ${remainingImportIndex}/${remainingImportPaths.length}: ${importPath}`);
1968
+ // Skip imports that point to generated CodeYam files (same skip logic as
1969
+ // rewriteRelativeModuleImports). Without this, MockData files from earlier
1970
+ // captures that get discovered by the TypeScript compiler would be treated as
1971
+ // regular imports, creating transitive copies with stale content.
1972
+ const scenarioFilePattern = /[a-f0-9]{64}_\w+_[A-Z]\w*$/;
1973
+ const mockDataPattern = /__codeyamMocks__\//;
1974
+ if (scenarioFilePattern.test(importPath) ||
1975
+ mockDataPattern.test(importPath)) {
1976
+ continue;
1977
+ }
1480
1978
  // Resolve the import path to a project file path
1481
1979
  const resolvedFilePath = resolveImportPath(importPath, file.path, project);
1482
1980
  if (!resolvedFilePath) {
@@ -1515,8 +2013,10 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1515
2013
  const targetFileBasePath = safeFolder(targetFile.path.split('/').slice(0, -1).join('/'));
1516
2014
  const targetFileExtension = targetFile.name.split('.').pop();
1517
2015
  const targetFileIsIndex = isIndexPath(targetFile.path);
1518
- const filePathHash = safeFileName(targetFile.path);
1519
- const transformedFilePath = `${PROJECT_RELATIVE_PATH}/${targetFileBasePath}/${filePathHash}_${targetFileIsIndex ? 'index_' : ''}transitive_${safeFileName(scenario.name)}.${targetFileExtension}`;
2016
+ // Limit path hash length to prevent ENAMETOOLONG errors
2017
+ const filePathHash = safeFileName(targetFile.path, { maxLength: 80 });
2018
+ const targetScenarioSlug = safeFileName(scenario.name, { maxLength: 60 });
2019
+ const transformedFilePath = `${PROJECT_RELATIVE_PATH}/${targetFileBasePath}/${filePathHash}_${targetFileIsIndex ? 'index_' : ''}transitive_${targetScenarioSlug}.${targetFileExtension}`;
1520
2020
  // Check if we've already processed this file as a transitive copy
1521
2021
  // Note: __data_file_written__ is for entity-specific scenario files with different naming,
1522
2022
  // but we still need transitive copies for server-only stripping. Data entity files may
@@ -1537,7 +2037,11 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1537
2037
  // Recursively process this transitive file's imports
1538
2038
  // This handles the nested case: service.ts → brevo.ts → constants.ts
1539
2039
  const nestedImportPaths = extractInternalImportPaths(transformedContent);
2040
+ debugLog(`[NESTED] Processing ${nestedImportPaths.length} nested imports for ${targetFile.path}`);
2041
+ let nestedIndex = 0;
1540
2042
  for (const nestedImportPath of nestedImportPaths) {
2043
+ nestedIndex++;
2044
+ debugLog(`[NESTED LOOP] import ${nestedIndex}/${nestedImportPaths.length}: ${nestedImportPath}`);
1541
2045
  const nestedResolvedPath = resolveImportPath(nestedImportPath, targetFile.path, project);
1542
2046
  if (!nestedResolvedPath)
1543
2047
  continue;
@@ -1551,8 +2055,12 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1551
2055
  const nestedBasePath = safeFolder(nestedFile.path.split('/').slice(0, -1).join('/'));
1552
2056
  const nestedExtension = nestedFile.name.split('.').pop();
1553
2057
  const nestedIsIndex = isIndexPath(nestedFile.path);
1554
- const nestedPathHash = safeFileName(nestedFile.path);
1555
- const nestedTransformedPath = `${PROJECT_RELATIVE_PATH}/${nestedBasePath}/${nestedPathHash}_${nestedIsIndex ? 'index_' : ''}transitive_${safeFileName(scenario.name)}.${nestedExtension}`;
2058
+ // Limit path hash length to prevent ENAMETOOLONG errors
2059
+ const nestedPathHash = safeFileName(nestedFile.path, { maxLength: 80 });
2060
+ const nestedScenarioSlug = safeFileName(scenario.name, {
2061
+ maxLength: 60,
2062
+ });
2063
+ const nestedTransformedPath = `${PROJECT_RELATIVE_PATH}/${nestedBasePath}/${nestedPathHash}_${nestedIsIndex ? 'index_' : ''}transitive_${nestedScenarioSlug}.${nestedExtension}`;
1556
2064
  // Check if already processed as a transitive file (we can rewrite to point to it)
1557
2065
  // Note: __data_file_written__ is for entity-specific scenario files with different naming,
1558
2066
  // but we still need transitive copies for server-only stripping in the import chain
@@ -1568,7 +2076,9 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1568
2076
  // This handles chains of any depth: A -> B -> C -> D
1569
2077
  let nestedContent = stripServerOnlyImport(nestedFile.content);
1570
2078
  nestedContent = applyServerOnlyMocks(nestedContent);
1571
- nestedContent = await processTransitiveImportsRecursively(nestedContent, nestedFile.path, nestedTransformedPath);
2079
+ debugLog(`processTransitiveImportsRecursively (nested) for ${nestedFile.path}`);
2080
+ nestedContent = await withTimeout(`processTransitiveImportsRecursively (nested) for ${path.basename(nestedFile.path)}`, processTransitiveImportsRecursively(nestedContent, nestedFile.path, nestedTransformedPath), 30000);
2081
+ debugLog(`Completed processTransitiveImportsRecursively (nested) for ${nestedFile.path}`);
1572
2082
  await writeFile(nestedTransformedPath, nestedContent);
1573
2083
  scenarioComponentPaths.push(nestedTransformedPath);
1574
2084
  // Mark as written
@@ -1616,6 +2126,7 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1616
2126
  const importRegex = new RegExp(`(from\\s*["'])${escapedImportPath}(["'])`, 'g');
1617
2127
  fileContent = fileContent.replace(importRegex, `$1${safeRelativePath}$2`);
1618
2128
  }
2129
+ console.log(`[WriteScenario] POST-LOOP ${entity.name}: remaining imports loop took ${Date.now() - postLoopStartTime}ms`);
1619
2130
  const scenarioComponentComment = `// This file is auto-generated by CodeYam. Do not edit this file manually.
1620
2131
  // This file contains content for a scenario component:
1621
2132
  // Analyses being written: ${JSON.stringify(fileAnalyses?.map((a) => ({ id: a.id, entityName: a.entityName })))}
@@ -1626,6 +2137,57 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1626
2137
  // Entity: ${rootAnalysis.entitySha} ${rootAnalysis.entityName}
1627
2138
  // Scenario: ${scenario.id} - ${scenario.name}
1628
2139
  `;
2140
+ // Final pass: Rename any namespace imports (import * as X from '...') that have
2141
+ // corresponding mock code using ...X__cyOriginal spread pattern.
2142
+ // This handles cases where:
2143
+ // 1. The import path was rewritten by transitive import handling
2144
+ // 2. The import wasn't caught by the earlier renaming logic
2145
+ // We scan for all __cyOriginal references in the mock code and ensure the imports are renamed.
2146
+ const cyOriginalReferences = fileContent.match(/\.\.\.(\w+)__cyOriginal/g);
2147
+ if (cyOriginalReferences) {
2148
+ const uniqueNames = [
2149
+ ...new Set(cyOriginalReferences.map((ref) => ref.replace('...', '').replace('__cyOriginal', ''))),
2150
+ ];
2151
+ for (const name of uniqueNames) {
2152
+ // Match namespace imports for this name that haven't been renamed yet
2153
+ const namespaceImportRegex = new RegExp(`(import\\s+\\*\\s+as\\s+)${escapeRegExp(name)}(\\s+from\\s+['"][^'"]*['"])`, 'g');
2154
+ fileContent = fileContent.replace(namespaceImportRegex, `$1${name}__cyOriginal$2`);
2155
+ }
2156
+ }
2157
+ // For route components (page.tsx, layout.tsx), the component IS the Next.js page.
2158
+ // There's no wrapper page to inject argumentsData as props (unlike non-route components
2159
+ // which get a scenarioComponent wrapper). We need to wrap the default export so that
2160
+ // the scenario's argumentsData is passed as props to the component.
2161
+ if (isFrameworkRoute(file, entity, framework, file === rootFile) &&
2162
+ rootAnalysis.metadata?.scenariosDataStructure?.arguments?.length > 0) {
2163
+ const positionalArguments = rootAnalysis.metadata.scenariosDataStructure.arguments;
2164
+ const hasNamedArgs = positionalArguments.length === 1 &&
2165
+ typeof positionalArguments[0] === 'object';
2166
+ if (hasNamedArgs) {
2167
+ // Match: export default function Name(
2168
+ // Also: export default async function Name(
2169
+ const defaultExportMatch = fileContent.match(/export\s+default\s+(async\s+)?function\s+(\w+)\s*\(/);
2170
+ if (defaultExportMatch) {
2171
+ const funcName = defaultExportMatch[2];
2172
+ // Remove "export default" from the original function declaration
2173
+ fileContent = fileContent.replace(/export\s+default\s+(async\s+)?function\s+(\w+)\s*\(/, '$1function $2(');
2174
+ // Ensure scenarios import is present
2175
+ const mockDataPath = `${relativeMocksDir}/MockData_${safeFileName(scenario.name)}`;
2176
+ if (fileContent.indexOf('import { scenarios } from') === -1) {
2177
+ fileContent = `import { scenarios } from "${mockDataPath}";\n\n${fileContent}`;
2178
+ }
2179
+ // Add wrapper default export that injects argumentsData as props.
2180
+ // Filter null values: the LLM uses null to mean "don't pass this prop"
2181
+ // but spreading { prop: null } explicitly passes null, which differs from
2182
+ // undefined (absent) and crashes components that check `prop !== undefined`.
2183
+ fileContent += `\n\nexport default function _CYRouteWrapper(props: any) {
2184
+ const _cyArgs = scenarios().data()?.['arguments']?.[0] ?? {};
2185
+ const _cyCleanArgs = Object.fromEntries(Object.entries(_cyArgs).filter(([_, v]) => v !== null));
2186
+ return <${funcName} {...props} {..._cyCleanArgs} />;
2187
+ }\n`;
2188
+ }
2189
+ }
2190
+ }
1629
2191
  // Use the directive that was extracted at the beginning of processing
1630
2192
  // This ensures it stays at the very top even after imports are prepended
1631
2193
  // NOTE: We only preserve "use client" directives, NOT "use server" directives.
@@ -1639,8 +2201,14 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
1639
2201
  else {
1640
2202
  finalContent = `${scenarioComponentComment}\n\n${fileContent}`;
1641
2203
  }
2204
+ debugLog('About to write final scenario file', {
2205
+ scenarioComponentPath,
2206
+ contentLength: finalContent.length,
2207
+ });
1642
2208
  await writeFile(scenarioComponentPath, finalContent);
2209
+ debugLog('Successfully wrote scenario file');
1643
2210
  scenarioComponentPaths.push(scenarioComponentPath);
2211
+ console.log(`[WriteScenario] POST-LOOP ${entity.name}: COMPLETE total=${Date.now() - postLoopStartTime}ms`);
1644
2212
  return { scenarioComponentPaths, writtenScenarioComponents };
1645
2213
  }
1646
2214
  //# sourceMappingURL=writeScenarioComponents.js.map