@codeyam/codeyam-cli 0.1.0-staging.596f0eb → 0.1.0-staging.6e699e5

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 (696) 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 +10 -6
  5. package/analyzer-template/packages/ai/index.ts +10 -3
  6. package/analyzer-template/packages/ai/package.json +1 -1
  7. package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
  8. package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +128 -6
  9. package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
  10. package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +138 -1
  11. package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
  12. package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +140 -6
  13. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
  14. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +38 -1
  15. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
  16. package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +1239 -104
  17. package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +304 -0
  18. package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
  19. package/analyzer-template/packages/ai/src/lib/completionCall.ts +216 -36
  20. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +1501 -138
  21. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +2 -1
  22. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +976 -0
  23. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +243 -77
  24. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +19 -1
  25. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +103 -6
  26. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +23 -0
  27. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
  28. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +42 -2
  29. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
  30. package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +156 -0
  31. package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
  32. package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
  33. package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
  34. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +74 -7
  35. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +89 -112
  36. package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +6 -0
  37. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1111 -91
  38. package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +207 -104
  39. package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +570 -0
  40. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
  41. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +1977 -0
  42. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
  43. package/analyzer-template/packages/ai/src/lib/getConditionalUsagesFromCode.ts +143 -31
  44. package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +8 -2
  45. package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +276 -3
  46. package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +33 -3
  47. package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +7 -0
  48. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
  49. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -102
  50. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
  51. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
  52. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +90 -6
  53. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -53
  54. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
  55. package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +28 -2
  56. package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
  57. package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +812 -0
  58. package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
  59. package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
  60. package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +123 -0
  61. package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +8 -1
  62. package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +14 -0
  63. package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
  64. package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +1 -0
  65. package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
  66. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +455 -267
  67. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +18 -0
  68. package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -0
  69. package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -7
  70. package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +31 -15
  71. package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
  72. package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
  73. package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
  74. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +265 -0
  75. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
  76. package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +588 -52
  77. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
  78. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
  79. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +336 -133
  80. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +156 -0
  81. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +78 -83
  82. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +4 -8
  83. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +461 -94
  84. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
  85. package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
  86. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
  87. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
  88. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
  89. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
  90. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
  91. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
  92. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
  93. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
  94. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
  95. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
  96. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
  97. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
  98. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts +15 -0
  99. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts.map +1 -0
  100. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js +31 -0
  101. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js.map +1 -0
  102. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
  103. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
  104. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
  105. package/analyzer-template/packages/aws/package.json +3 -3
  106. package/analyzer-template/packages/aws/s3/index.ts +1 -0
  107. package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
  108. package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
  109. package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
  110. package/analyzer-template/packages/aws/src/lib/s3/checkS3ObjectExists.ts +47 -0
  111. package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
  112. package/analyzer-template/packages/database/src/lib/kysely/db.ts +4 -4
  113. package/analyzer-template/packages/database/src/lib/kysely/tableRelations.ts +2 -2
  114. package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +36 -9
  115. package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +7 -3
  116. package/analyzer-template/packages/generate/index.ts +3 -0
  117. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +17 -1
  118. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +193 -0
  119. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
  120. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +9 -4
  121. package/analyzer-template/packages/generate/src/lib/deepMerge.ts +26 -1
  122. package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
  123. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -2
  124. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +2 -2
  125. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tableRelations.d.ts +2 -2
  126. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +1 -11
  127. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
  128. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +30 -7
  129. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
  130. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
  131. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  132. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
  133. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
  134. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +2 -6
  135. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
  136. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
  137. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
  138. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  139. package/analyzer-template/packages/github/dist/generate/index.d.ts +3 -0
  140. package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
  141. package/analyzer-template/packages/github/dist/generate/index.js +3 -0
  142. package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
  143. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
  144. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
  145. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  146. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
  147. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
  148. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
  149. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
  150. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
  151. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
  152. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
  153. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
  154. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
  155. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
  156. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  157. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.d.ts.map +1 -1
  158. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js +27 -1
  159. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js.map +1 -1
  160. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
  161. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
  162. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
  163. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
  164. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
  165. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
  166. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
  167. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
  168. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
  169. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
  170. package/analyzer-template/packages/github/dist/types/index.d.ts +2 -2
  171. package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
  172. package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
  173. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +87 -13
  174. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
  175. package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
  176. package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
  177. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +11 -6
  178. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
  179. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +196 -0
  180. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  181. package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts +2 -0
  182. package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts.map +1 -1
  183. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
  184. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
  185. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  186. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
  187. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
  188. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
  189. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
  190. package/analyzer-template/packages/github/src/lib/loadOrCreateCommit.ts +14 -0
  191. package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
  192. package/analyzer-template/packages/process/index.ts +2 -0
  193. package/analyzer-template/packages/process/package.json +12 -0
  194. package/analyzer-template/packages/process/tsconfig.json +8 -0
  195. package/analyzer-template/packages/types/index.ts +5 -0
  196. package/analyzer-template/packages/types/src/types/Analysis.ts +104 -13
  197. package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
  198. package/analyzer-template/packages/types/src/types/Scenario.ts +11 -10
  199. package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +224 -0
  200. package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
  201. package/analyzer-template/packages/ui-components/src/components/ScenarioDetailInteractiveView.tsx +23 -7
  202. package/analyzer-template/packages/utils/dist/types/index.d.ts +2 -2
  203. package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
  204. package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
  205. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +87 -13
  206. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
  207. package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
  208. package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
  209. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +11 -6
  210. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
  211. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +196 -0
  212. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  213. package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
  214. package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts.map +1 -1
  215. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
  216. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
  217. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  218. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
  219. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
  220. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
  221. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
  222. package/analyzer-template/packages/utils/src/lib/lightweightEntityExtractor.ts +27 -0
  223. package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
  224. package/analyzer-template/playwright/capture.ts +37 -18
  225. package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
  226. package/analyzer-template/playwright/takeElementScreenshot.ts +26 -11
  227. package/analyzer-template/playwright/takeScreenshot.ts +9 -7
  228. package/analyzer-template/playwright/waitForServer.ts +21 -6
  229. package/analyzer-template/project/analyzeBaselineCommit.ts +4 -0
  230. package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
  231. package/analyzer-template/project/analyzeFileEntities.ts +4 -0
  232. package/analyzer-template/project/analyzeRegularCommit.ts +4 -0
  233. package/analyzer-template/project/constructMockCode.ts +1181 -160
  234. package/analyzer-template/project/controller/startController.ts +16 -1
  235. package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
  236. package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
  237. package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +3 -6
  238. package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +82 -36
  239. package/analyzer-template/project/orchestrateCapture.ts +36 -3
  240. package/analyzer-template/project/reconcileMockDataKeys.ts +245 -2
  241. package/analyzer-template/project/runAnalysis.ts +11 -0
  242. package/analyzer-template/project/runMultiScenarioServer.ts +11 -10
  243. package/analyzer-template/project/serverOnlyModules.ts +194 -21
  244. package/analyzer-template/project/start.ts +26 -4
  245. package/analyzer-template/project/startScenarioCapture.ts +79 -41
  246. package/analyzer-template/project/writeMockDataTsx.ts +232 -57
  247. package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
  248. package/analyzer-template/project/writeScenarioComponents.ts +769 -181
  249. package/analyzer-template/project/writeScenarioFiles.ts +26 -0
  250. package/analyzer-template/project/writeSimpleRoot.ts +13 -15
  251. package/analyzer-template/scripts/comboWorkerLoop.cjs +1 -0
  252. package/analyzer-template/scripts/defaultCmd.sh +9 -0
  253. package/analyzer-template/tsconfig.json +2 -1
  254. package/background/src/lib/local/createLocalAnalyzer.js +1 -29
  255. package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
  256. package/background/src/lib/local/execAsync.js +1 -1
  257. package/background/src/lib/local/execAsync.js.map +1 -1
  258. package/background/src/lib/virtualized/common/execAsync.js +1 -1
  259. package/background/src/lib/virtualized/common/execAsync.js.map +1 -1
  260. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +2 -1
  261. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
  262. package/background/src/lib/virtualized/project/analyzeBranchCommit.js +2 -1
  263. package/background/src/lib/virtualized/project/analyzeBranchCommit.js.map +1 -1
  264. package/background/src/lib/virtualized/project/analyzeFileEntities.js +2 -1
  265. package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
  266. package/background/src/lib/virtualized/project/analyzeRegularCommit.js +2 -1
  267. package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
  268. package/background/src/lib/virtualized/project/constructMockCode.js +1053 -124
  269. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  270. package/background/src/lib/virtualized/project/controller/startController.js +11 -1
  271. package/background/src/lib/virtualized/project/controller/startController.js.map +1 -1
  272. package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js +6 -3
  273. package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js.map +1 -1
  274. package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js +7 -7
  275. package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js.map +1 -1
  276. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +3 -2
  277. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
  278. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +69 -32
  279. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
  280. package/background/src/lib/virtualized/project/orchestrateCapture.js +27 -4
  281. package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
  282. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +204 -2
  283. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
  284. package/background/src/lib/virtualized/project/runAnalysis.js +9 -0
  285. package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
  286. package/background/src/lib/virtualized/project/runMultiScenarioServer.js +11 -9
  287. package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
  288. package/background/src/lib/virtualized/project/serverOnlyModules.js +163 -23
  289. package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
  290. package/background/src/lib/virtualized/project/start.js +21 -4
  291. package/background/src/lib/virtualized/project/start.js.map +1 -1
  292. package/background/src/lib/virtualized/project/startScenarioCapture.js +61 -31
  293. package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
  294. package/background/src/lib/virtualized/project/writeMockDataTsx.js +199 -50
  295. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  296. package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js +15 -0
  297. package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js.map +1 -0
  298. package/background/src/lib/virtualized/project/writeScenarioComponents.js +552 -125
  299. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  300. package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
  301. package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
  302. package/background/src/lib/virtualized/project/writeSimpleRoot.js +13 -13
  303. package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
  304. package/codeyam-cli/src/cli.js +7 -1
  305. package/codeyam-cli/src/cli.js.map +1 -1
  306. package/codeyam-cli/src/commands/analyze.js +1 -1
  307. package/codeyam-cli/src/commands/analyze.js.map +1 -1
  308. package/codeyam-cli/src/commands/baseline.js +174 -0
  309. package/codeyam-cli/src/commands/baseline.js.map +1 -0
  310. package/codeyam-cli/src/commands/debug.js +40 -18
  311. package/codeyam-cli/src/commands/debug.js.map +1 -1
  312. package/codeyam-cli/src/commands/default.js +0 -15
  313. package/codeyam-cli/src/commands/default.js.map +1 -1
  314. package/codeyam-cli/src/commands/recapture.js +226 -0
  315. package/codeyam-cli/src/commands/recapture.js.map +1 -0
  316. package/codeyam-cli/src/commands/report.js +72 -24
  317. package/codeyam-cli/src/commands/report.js.map +1 -1
  318. package/codeyam-cli/src/commands/start.js +8 -12
  319. package/codeyam-cli/src/commands/start.js.map +1 -1
  320. package/codeyam-cli/src/commands/status.js +23 -1
  321. package/codeyam-cli/src/commands/status.js.map +1 -1
  322. package/codeyam-cli/src/commands/test-startup.js +1 -1
  323. package/codeyam-cli/src/commands/test-startup.js.map +1 -1
  324. package/codeyam-cli/src/commands/wipe.js +108 -0
  325. package/codeyam-cli/src/commands/wipe.js.map +1 -0
  326. package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js +81 -0
  327. package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js.map +1 -0
  328. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +31 -27
  329. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
  330. package/codeyam-cli/src/utils/analysisRunner.js +8 -13
  331. package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
  332. package/codeyam-cli/src/utils/backgroundServer.js +14 -4
  333. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  334. package/codeyam-cli/src/utils/database.js +91 -5
  335. package/codeyam-cli/src/utils/database.js.map +1 -1
  336. package/codeyam-cli/src/utils/generateReport.js +253 -106
  337. package/codeyam-cli/src/utils/generateReport.js.map +1 -1
  338. package/codeyam-cli/src/utils/git.js +79 -0
  339. package/codeyam-cli/src/utils/git.js.map +1 -0
  340. package/codeyam-cli/src/utils/install-skills.js +31 -17
  341. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  342. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +38 -0
  343. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
  344. package/codeyam-cli/src/utils/queue/job.js +245 -16
  345. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  346. package/codeyam-cli/src/utils/queue/manager.js +25 -7
  347. package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
  348. package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
  349. package/codeyam-cli/src/utils/serverState.js.map +1 -1
  350. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +7 -5
  351. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
  352. package/codeyam-cli/src/utils/versionInfo.js +25 -19
  353. package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
  354. package/codeyam-cli/src/utils/wipe.js +128 -0
  355. package/codeyam-cli/src/utils/wipe.js.map +1 -0
  356. package/codeyam-cli/src/webserver/app/lib/database.js +98 -1
  357. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  358. package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
  359. package/codeyam-cli/src/webserver/backgroundServer.js +5 -10
  360. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  361. package/codeyam-cli/src/webserver/bootstrap.js +49 -0
  362. package/codeyam-cli/src/webserver/bootstrap.js.map +1 -0
  363. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-BXhEawa3.js +1 -0
  364. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-efWKDYMr.js → EntityTypeBadge-DLqD3qNt.js} +1 -1
  365. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-Ba2JVPzP.js +41 -0
  366. package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-C8lyxW9k.js +34 -0
  367. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-aht4aafF.js +25 -0
  368. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-CVtiBnY5.js +3 -0
  369. package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-B0GLXMsr.js +6 -0
  370. package/codeyam-cli/src/webserver/build/client/assets/LogViewer-xgeCVgSM.js +3 -0
  371. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-D4TZhLuw.js +21 -0
  372. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-DuDvi0jm.js +1 -0
  373. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-DEx02QDa.js +10 -0
  374. package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-COPstp9J.js → TruncatedFilePath-DyFZkK0l.js} +1 -1
  375. package/codeyam-cli/src/webserver/build/client/assets/_index-BwqWJOgH.js +11 -0
  376. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-DoLIqZX2.js +37 -0
  377. package/codeyam-cli/src/webserver/build/client/assets/api.health-l0sNRNKZ.js +1 -0
  378. package/codeyam-cli/src/webserver/build/client/assets/api.restart-server-l0sNRNKZ.js +1 -0
  379. package/codeyam-cli/src/webserver/build/client/assets/api.rules-l0sNRNKZ.js +1 -0
  380. package/codeyam-cli/src/webserver/build/client/assets/chevron-down-Cx24_aWc.js +6 -0
  381. package/codeyam-cli/src/webserver/build/client/assets/chunk-EPOLDU6W-CXRTFQ3F.js +51 -0
  382. package/codeyam-cli/src/webserver/build/client/assets/circle-check-BOARzkeR.js +6 -0
  383. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-BdhJEx6B.js +21 -0
  384. package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
  385. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
  386. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-BRb-0kQl.js +1 -0
  387. package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-C2N4Op8e.js +23 -0
  388. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DavjRmOY.js +6 -0
  389. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-D1T4TGjf.js +6 -0
  390. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-CTBG2mmz.js +5 -0
  391. package/codeyam-cli/src/webserver/build/client/assets/entry.client-CS2cb_eZ.js +29 -0
  392. package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
  393. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-DMJ7zii9.js +1 -0
  394. package/codeyam-cli/src/webserver/build/client/assets/files-Cs4MdYtv.js +1 -0
  395. package/codeyam-cli/src/webserver/build/client/assets/git-B4RJRvYB.js +15 -0
  396. package/codeyam-cli/src/webserver/build/client/assets/git-commit-horizontal-CysbcZxi.js +6 -0
  397. package/codeyam-cli/src/webserver/build/client/assets/globals-DMUaGAqV.css +1 -0
  398. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-fmIEn3Bc.js +9 -0
  399. package/codeyam-cli/src/webserver/build/client/assets/index-B1h680n5.js +9 -0
  400. package/codeyam-cli/src/webserver/build/client/assets/index-lzqtyFU8.js +3 -0
  401. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-B7B9V-bu.js +6 -0
  402. package/codeyam-cli/src/webserver/build/client/assets/manifest-f874c610.js +1 -0
  403. package/codeyam-cli/src/webserver/build/client/assets/preload-helper-ckwbz45p.js +1 -0
  404. package/codeyam-cli/src/webserver/build/client/assets/root-Bz5TunQg.js +57 -0
  405. package/codeyam-cli/src/webserver/build/client/assets/rules-hEkvVw2-.js +97 -0
  406. package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
  407. package/codeyam-cli/src/webserver/build/client/assets/search-CxXUmBSd.js +6 -0
  408. package/codeyam-cli/src/webserver/build/client/assets/settings-CS5f3WzT.js +1 -0
  409. package/codeyam-cli/src/webserver/build/client/assets/simulations-DwFIBT09.js +1 -0
  410. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-B6LgvRJg.js +6 -0
  411. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-C1v1PQzo.js +1 -0
  412. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-3pmpUQB-.js → useLastLogLine-aSv48UbS.js} +1 -1
  413. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DYxHZQuP.js +1 -0
  414. package/codeyam-cli/src/webserver/build/client/assets/{useToast-DEyawJ8r.js → useToast-mBRpZPiu.js} +1 -1
  415. package/codeyam-cli/src/webserver/build/server/assets/index-967OuJoF.js +1 -0
  416. package/codeyam-cli/src/webserver/build/server/assets/server-build-DRTmerg9.js +257 -0
  417. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  418. package/codeyam-cli/src/webserver/build-info.json +5 -5
  419. package/codeyam-cli/src/webserver/devServer.js +1 -3
  420. package/codeyam-cli/src/webserver/devServer.js.map +1 -1
  421. package/codeyam-cli/src/webserver/server.js +35 -25
  422. package/codeyam-cli/src/webserver/server.js.map +1 -1
  423. package/codeyam-cli/templates/codeyam-power-rules-hook.sh +200 -0
  424. package/codeyam-cli/templates/{codeyam-debug-skill.md → codeyam:debug.md} +48 -4
  425. package/codeyam-cli/templates/codeyam:diagnose.md +650 -0
  426. package/codeyam-cli/templates/codeyam:new-rule.md +13 -0
  427. package/codeyam-cli/templates/codeyam:power-rules.md +447 -0
  428. package/codeyam-cli/templates/{codeyam-setup-skill.md → codeyam:setup.md} +139 -4
  429. package/codeyam-cli/templates/{codeyam-sim-skill.md → codeyam:sim.md} +1 -1
  430. package/codeyam-cli/templates/{codeyam-test-skill.md → codeyam:test.md} +1 -1
  431. package/codeyam-cli/templates/{codeyam-verify-skill.md → codeyam:verify.md} +1 -1
  432. package/package.json +17 -16
  433. package/packages/ai/index.js +5 -4
  434. package/packages/ai/index.js.map +1 -1
  435. package/packages/ai/src/lib/analyzeScope.js +99 -0
  436. package/packages/ai/src/lib/analyzeScope.js.map +1 -1
  437. package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
  438. package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
  439. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +100 -1
  440. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
  441. package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
  442. package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
  443. package/packages/ai/src/lib/astScopes/methodSemantics.js +97 -6
  444. package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
  445. package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js +8 -0
  446. package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
  447. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +23 -0
  448. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
  449. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +138 -1
  450. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
  451. package/packages/ai/src/lib/astScopes/processExpression.js +945 -87
  452. package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
  453. package/packages/ai/src/lib/checkAllAttributes.js +24 -9
  454. package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
  455. package/packages/ai/src/lib/completionCall.js +178 -31
  456. package/packages/ai/src/lib/completionCall.js.map +1 -1
  457. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1198 -82
  458. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  459. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +2 -1
  460. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
  461. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +661 -0
  462. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -0
  463. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +180 -56
  464. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
  465. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +16 -1
  466. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
  467. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +86 -4
  468. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
  469. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +20 -0
  470. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
  471. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js +86 -0
  472. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js.map +1 -0
  473. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +34 -3
  474. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
  475. package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
  476. package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
  477. package/packages/ai/src/lib/dataStructureChunking.js +111 -0
  478. package/packages/ai/src/lib/dataStructureChunking.js.map +1 -0
  479. package/packages/ai/src/lib/deepEqual.js +32 -0
  480. package/packages/ai/src/lib/deepEqual.js.map +1 -0
  481. package/packages/ai/src/lib/e2eDataTracking.js +241 -0
  482. package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
  483. package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
  484. package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
  485. package/packages/ai/src/lib/generateChangesEntityScenarioData.js +62 -5
  486. package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
  487. package/packages/ai/src/lib/generateChangesEntityScenarios.js +81 -90
  488. package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
  489. package/packages/ai/src/lib/generateEntityDataStructure.js +5 -0
  490. package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
  491. package/packages/ai/src/lib/generateEntityScenarioData.js +904 -84
  492. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  493. package/packages/ai/src/lib/generateEntityScenarios.js +186 -82
  494. package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
  495. package/packages/ai/src/lib/generateExecutionFlows.js +392 -0
  496. package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -0
  497. package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js +380 -0
  498. package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js.map +1 -0
  499. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +1440 -0
  500. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -0
  501. package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
  502. package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
  503. package/packages/ai/src/lib/getConditionalUsagesFromCode.js +84 -14
  504. package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
  505. package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -1
  506. package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
  507. package/packages/ai/src/lib/isolateScopes.js +231 -4
  508. package/packages/ai/src/lib/isolateScopes.js.map +1 -1
  509. package/packages/ai/src/lib/mergeStatements.js +26 -3
  510. package/packages/ai/src/lib/mergeStatements.js.map +1 -1
  511. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +6 -0
  512. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
  513. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +1 -1
  514. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
  515. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -64
  516. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
  517. package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
  518. package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
  519. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +68 -6
  520. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
  521. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -34
  522. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
  523. package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
  524. package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
  525. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +16 -3
  526. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
  527. package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
  528. package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
  529. package/packages/ai/src/lib/resolvePathToControllable.js +667 -0
  530. package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
  531. package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
  532. package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
  533. package/packages/ai/src/lib/worker/SerializableDataStructure.js +29 -0
  534. package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
  535. package/packages/ai/src/lib/worker/analyzeScopeWorker.js +4 -0
  536. package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
  537. package/packages/analyze/src/lib/FileAnalyzer.js +15 -0
  538. package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
  539. package/packages/analyze/src/lib/analysisContext.js +30 -5
  540. package/packages/analyze/src/lib/analysisContext.js.map +1 -1
  541. package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
  542. package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
  543. package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
  544. package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
  545. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +218 -50
  546. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  547. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +10 -0
  548. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  549. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +2 -0
  550. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
  551. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -7
  552. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
  553. package/packages/analyze/src/lib/files/analyzeChange.js +21 -11
  554. package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
  555. package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
  556. package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
  557. package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
  558. package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
  559. package/packages/analyze/src/lib/files/enums/steps.js +1 -1
  560. package/packages/analyze/src/lib/files/enums/steps.js.map +1 -1
  561. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +209 -0
  562. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -0
  563. package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
  564. package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
  565. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +458 -48
  566. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
  567. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
  568. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
  569. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
  570. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
  571. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +264 -78
  572. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  573. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +96 -0
  574. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
  575. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +56 -69
  576. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
  577. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +4 -8
  578. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
  579. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +372 -89
  580. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  581. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
  582. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
  583. package/packages/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
  584. package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
  585. package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
  586. package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
  587. package/packages/database/src/lib/kysely/db.js +2 -2
  588. package/packages/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
  589. package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  590. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
  591. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  592. package/packages/generate/index.js +3 -0
  593. package/packages/generate/index.js.map +1 -1
  594. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
  595. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  596. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
  597. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
  598. package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
  599. package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
  600. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
  601. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  602. package/packages/generate/src/lib/deepMerge.js +27 -1
  603. package/packages/generate/src/lib/deepMerge.js.map +1 -1
  604. package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
  605. package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
  606. package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
  607. package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
  608. package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
  609. package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
  610. package/packages/process/index.js +3 -0
  611. package/packages/process/index.js.map +1 -0
  612. package/packages/process/src/GlobalProcessManager.js.map +1 -0
  613. package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
  614. package/packages/process/src/ProcessManager.js.map +1 -0
  615. package/packages/process/src/index.js.map +1 -0
  616. package/packages/process/src/managedExecAsync.js.map +1 -0
  617. package/packages/types/index.js.map +1 -1
  618. package/packages/utils/src/lib/lightweightEntityExtractor.js +25 -0
  619. package/packages/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  620. package/packages/utils/src/lib/safeFileName.js +29 -3
  621. package/packages/utils/src/lib/safeFileName.js.map +1 -1
  622. package/scripts/finalize-analyzer.cjs +6 -4
  623. package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
  624. package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -197
  625. package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -271
  626. package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -294
  627. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
  628. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -115
  629. package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
  630. package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
  631. package/analyzer-template/process/README.md +0 -507
  632. package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
  633. package/background/src/lib/process/ProcessManager.js.map +0 -1
  634. package/background/src/lib/process/index.js.map +0 -1
  635. package/background/src/lib/process/managedExecAsync.js.map +0 -1
  636. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
  637. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
  638. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-CVbSvOjo.js +0 -1
  639. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-DcwcHyl5.js +0 -1
  640. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-WgwC1GfJ.js +0 -26
  641. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-IEKom9O2.js +0 -3
  642. package/codeyam-cli/src/webserver/build/client/assets/LogViewer-BYnfxbUG.js +0 -3
  643. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-_lBPJCzG.js +0 -1
  644. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-lHVhvsu_.js +0 -1
  645. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-d_TBk4GQ.js +0 -5
  646. package/codeyam-cli/src/webserver/build/client/assets/_index-kGT7VUqj.js +0 -1
  647. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-DDGmhu7P.js +0 -7
  648. package/codeyam-cli/src/webserver/build/client/assets/chevron-down-n_HPRfM_.js +0 -1
  649. package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-CbVoyx1U.js +0 -26
  650. package/codeyam-cli/src/webserver/build/client/assets/circle-check-D1VOYveA.js +0 -1
  651. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-YR8jjAlu.js +0 -1
  652. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-B8vP3V_s.js +0 -1
  653. package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-CN6aLCT1.js +0 -16
  654. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DA5Jeu2P.js +0 -1
  655. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-BTeitalf.js +0 -5
  656. package/codeyam-cli/src/webserver/build/client/assets/entry.client-du6UEYD-.js +0 -13
  657. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-BpjkhMoi.js +0 -1
  658. package/codeyam-cli/src/webserver/build/client/assets/files-BQGvk4lJ.js +0 -1
  659. package/codeyam-cli/src/webserver/build/client/assets/git-DVdYRT-I.js +0 -12
  660. package/codeyam-cli/src/webserver/build/client/assets/globals-CO-U8Bpo.css +0 -1
  661. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +0 -5
  662. package/codeyam-cli/src/webserver/build/client/assets/index-DCG-vks0.js +0 -1
  663. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-GazdNeLl.js +0 -1
  664. package/codeyam-cli/src/webserver/build/client/assets/manifest-0b694d28.js +0 -1
  665. package/codeyam-cli/src/webserver/build/client/assets/root-D3tQP7hx.js +0 -16
  666. package/codeyam-cli/src/webserver/build/client/assets/search-CIY6XmtE.js +0 -1
  667. package/codeyam-cli/src/webserver/build/client/assets/server-build-CMKNK2uU.css +0 -1
  668. package/codeyam-cli/src/webserver/build/client/assets/settings-CoMDgElu.js +0 -1
  669. package/codeyam-cli/src/webserver/build/client/assets/simulations-agkniXp2.js +0 -1
  670. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-B2VUcygF.js +0 -1
  671. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-EvdK-zXP.js +0 -1
  672. package/codeyam-cli/src/webserver/build/server/assets/index-DGVHQEXD.js +0 -1
  673. package/codeyam-cli/src/webserver/build/server/assets/server-build-CghkTkIL.js +0 -166
  674. package/codeyam-cli/templates/debug-command.md +0 -303
  675. package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
  676. package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
  677. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -136
  678. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
  679. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -220
  680. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
  681. package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -241
  682. package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
  683. package/packages/ai/src/lib/isFrontend.js +0 -5
  684. package/packages/ai/src/lib/isFrontend.js.map +0 -1
  685. package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
  686. package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
  687. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -72
  688. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
  689. /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
  690. /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
  691. /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
  692. /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
  693. /package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-CMKNK2uU.css → styles-CMKNK2uU.css} +0 -0
  694. /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
  695. /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
  696. /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
@@ -1,9 +1,13 @@
1
1
  import completionCall from './completionCall';
2
2
  import generateEntityScenarioDataGenerator from './promptGenerators/generateEntityScenarioDataGenerator';
3
+ import generateMissingKeysPrompt from './promptGenerators/generateMissingKeysPrompt';
4
+ import generateChunkPrompt from './promptGenerators/generateChunkPrompt';
3
5
  import { saveLlmCall } from '~codeyam/aws/dynamodb';
6
+ import { trackDataSnapshot } from './e2eDataTracking';
4
7
  import type {
5
8
  Analysis,
6
9
  Entity,
10
+ ExecutionFlow,
7
11
  Scenario,
8
12
  ScenarioData,
9
13
  ScenariosDataStructure,
@@ -11,15 +15,457 @@ import type {
11
15
  import validateJson from './validateJson';
12
16
  import { awsLog, awsLogDebugLevel } from '~codeyam/utils';
13
17
  import { AI, parseJsonSafe } from '~codeyam/ai';
18
+ import convertNullToUndefinedBySchema from './dataStructure/helpers/convertNullToUndefinedBySchema';
19
+ import fixNullIdsBySchema from './dataStructure/helpers/fixNullIdsBySchema';
20
+ import { JsonTypeDefinition } from '~codeyam/types';
21
+ import { deepMerge } from '~codeyam/generate';
22
+ import {
23
+ chunkDataStructure,
24
+ getRequiredValuesForChunk,
25
+ } from './dataStructureChunking';
26
+
27
+ /**
28
+ * Check if any of the scenario's covered flows require error data.
29
+ * Returns true if any requiredValue has an error path with truthy comparison.
30
+ */
31
+ function scenarioRequiresErrorData(
32
+ scenario: Scenario,
33
+ executionFlows: ExecutionFlow[] | undefined,
34
+ ): boolean {
35
+ const coveredFlowIds = scenario.metadata?.coveredFlows || [];
36
+ for (const flowId of coveredFlowIds) {
37
+ const flow = executionFlows?.find((f) => f.id === flowId);
38
+ if (!flow?.requiredValues) continue;
39
+ for (const rv of flow.requiredValues) {
40
+ // Check if any requiredValue has an error path and requires it to be truthy
41
+ if (
42
+ rv.attributePath?.toLowerCase().includes('.error') &&
43
+ rv.comparison === 'truthy'
44
+ ) {
45
+ return true;
46
+ }
47
+ }
48
+ }
49
+ return false;
50
+ }
51
+
52
+ /**
53
+ * Deep merge scenario data with default scenario data.
54
+ * The scenario-specific data takes precedence, with default filling in missing fields.
55
+ *
56
+ * IMPORTANT: null values are PRESERVED (not removed) in the result.
57
+ * This is critical because writeMockDataTsx.ts does another deepMerge with default data,
58
+ * and it needs null values to prevent defaults from being filled back in.
59
+ * If we removed null here, the second merge would restore the defaults,
60
+ * making scenarios identical to the default scenario.
61
+ */
62
+ function deepMergeScenarioData(
63
+ defaultData: Record<string, any>,
64
+ scenarioData: Record<string, any>,
65
+ ): Record<string, any> {
66
+ // Guard against non-object inputs (LLM sometimes returns primitives)
67
+ if (
68
+ typeof scenarioData !== 'object' ||
69
+ scenarioData === null ||
70
+ Array.isArray(scenarioData)
71
+ ) {
72
+ // Return scenario value directly if it's not a mergeable object
73
+ return scenarioData;
74
+ }
75
+ if (
76
+ typeof defaultData !== 'object' ||
77
+ defaultData === null ||
78
+ Array.isArray(defaultData)
79
+ ) {
80
+ // Return scenario value if default isn't mergeable
81
+ return scenarioData;
82
+ }
83
+
84
+ const result: Record<string, any> = {};
85
+
86
+ // Start with all keys from default
87
+ for (const key of Object.keys(defaultData)) {
88
+ if (key in scenarioData) {
89
+ const scenarioValue = scenarioData[key];
90
+ const defaultValue = defaultData[key];
91
+
92
+ // null means explicitly override with null (falsy value)
93
+ // IMPORTANT: We preserve null instead of removing the key
94
+ // This ensures writeMockDataTsx's deepMerge won't fill in defaults
95
+ if (scenarioValue === null) {
96
+ result[key] = null;
97
+ continue;
98
+ }
99
+
100
+ // Deep merge objects (but not arrays)
101
+ if (
102
+ typeof scenarioValue === 'object' &&
103
+ !Array.isArray(scenarioValue) &&
104
+ typeof defaultValue === 'object' &&
105
+ !Array.isArray(defaultValue) &&
106
+ defaultValue !== null
107
+ ) {
108
+ result[key] = deepMergeScenarioData(defaultValue, scenarioValue);
109
+ } else {
110
+ // Use scenario value (overrides default)
111
+ result[key] = scenarioValue;
112
+ }
113
+ } else {
114
+ // Key not in scenario, use default
115
+ result[key] = defaultData[key];
116
+ }
117
+ }
118
+
119
+ // Add any keys that are only in scenario data (including null values)
120
+ for (const key of Object.keys(scenarioData)) {
121
+ if (!(key in defaultData)) {
122
+ result[key] = scenarioData[key];
123
+ }
124
+ }
125
+
126
+ return result;
127
+ }
14
128
 
15
129
  const DEFAULT_SCENARIO_NAME = 'Default Scenario';
16
130
 
131
+ /**
132
+ * Find the path to a key within a nested dataForMocks structure.
133
+ * Returns the path as an array of keys, or null if not found.
134
+ *
135
+ * @example
136
+ * // dataForMocks = { trpc: { fastener: { "useMutation()": { isLoading: "boolean" } } } }
137
+ * // findKeyPath("fastener", dataForMocks) returns ["trpc"]
138
+ */
139
+ function findKeyPath(
140
+ targetKey: string,
141
+ obj: JsonTypeDefinition,
142
+ currentPath: string[] = [],
143
+ ): string[] | null {
144
+ if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
145
+ return null;
146
+ }
147
+
148
+ for (const key of Object.keys(obj)) {
149
+ if (key === targetKey) {
150
+ return currentPath;
151
+ }
152
+
153
+ // Recursively search in nested objects
154
+ const nested = obj[key];
155
+ if (
156
+ typeof nested === 'object' &&
157
+ nested !== null &&
158
+ !Array.isArray(nested)
159
+ ) {
160
+ const result = findKeyPath(targetKey, nested as JsonTypeDefinition, [
161
+ ...currentPath,
162
+ key,
163
+ ]);
164
+ if (result !== null) {
165
+ return result;
166
+ }
167
+ }
168
+ }
169
+
170
+ return null;
171
+ }
172
+
173
+ /**
174
+ * Relocate misplaced nested keys in mockData to their correct position
175
+ * based on the dataForMocks structure.
176
+ *
177
+ * When the LLM returns mockData with keys at the wrong nesting level
178
+ * (e.g., { trpc: { quote: {...} }, fastener: {...} } when fastener should
179
+ * be inside trpc), this function moves them to the correct position.
180
+ *
181
+ * This function works recursively to handle nested misplacements, not just
182
+ * root-level ones. For example, if getQuote is at trpc.getQuote instead of
183
+ * trpc.quote.getQuote, it will be relocated.
184
+ *
185
+ * @example
186
+ * // dataForMocks: { trpc: { quote: {...}, fastener: {...} } }
187
+ * // mockData: { trpc: { quote: {...} }, fastener: {...} }
188
+ * // After: mockData: { trpc: { quote: {...}, fastener: {...} } }
189
+ *
190
+ * @example (nested case)
191
+ * // dataForMocks: { trpc: { quote: { getQuote: {...} } } }
192
+ * // mockData: { trpc: { quote: {...}, getQuote: {...} } }
193
+ * // After: mockData: { trpc: { quote: { getQuote: {...} } } }
194
+ */
195
+ function relocateMisplacedNestedKeys(
196
+ mockData: Record<string, unknown>,
197
+ dataForMocks: JsonTypeDefinition,
198
+ currentPathForLogging: string[] = [],
199
+ ): void {
200
+ if (typeof dataForMocks !== 'object' || dataForMocks === null) {
201
+ return;
202
+ }
203
+
204
+ const keysInSchema = Object.keys(dataForMocks);
205
+ const keysToRelocate: { key: string; path: string[] }[] = [];
206
+
207
+ // Find keys in mockData that are NOT at this level in dataForMocks
208
+ // but DO exist somewhere nested in dataForMocks
209
+ for (const key of Object.keys(mockData)) {
210
+ if (!keysInSchema.includes(key)) {
211
+ // This key is at this level in mockData but not at this level in dataForMocks
212
+ // Check if it exists somewhere nested in dataForMocks
213
+ const path = findKeyPath(key, dataForMocks);
214
+ if (path !== null && path.length > 0) {
215
+ keysToRelocate.push({ key, path });
216
+ }
217
+ }
218
+ }
219
+
220
+ // Relocate each misplaced key to its correct nested position
221
+ for (const { key, path } of keysToRelocate) {
222
+ const value = mockData[key];
223
+
224
+ // Navigate to the correct parent in mockData, creating nested objects if needed
225
+ let current: Record<string, unknown> = mockData;
226
+ for (const pathKey of path) {
227
+ if (current[pathKey] === undefined) {
228
+ current[pathKey] = {};
229
+ }
230
+ current = current[pathKey] as Record<string, unknown>;
231
+ }
232
+
233
+ // Deep merge the value into the correct location
234
+ // Use deep merge to preserve existing data at that location
235
+ if (current[key] !== undefined && typeof current[key] === 'object') {
236
+ current[key] = deepMerge(
237
+ current[key] as Record<string, unknown>,
238
+ value as Record<string, unknown>,
239
+ );
240
+ } else {
241
+ current[key] = value;
242
+ }
243
+
244
+ // Remove the key from its current (wrong) level
245
+ delete mockData[key];
246
+
247
+ const fullPath = [...currentPathForLogging, ...path].join('.');
248
+ awsLog(
249
+ `CodeYam: Relocated misplaced key "${key}" from [${currentPathForLogging.join('.')}] to [${fullPath}]`,
250
+ );
251
+ }
252
+
253
+ // Recursively process nested objects to handle deeply nested misplacements
254
+ for (const key of Object.keys(mockData)) {
255
+ const mockValue = mockData[key];
256
+ const schemaValue = dataForMocks[key];
257
+
258
+ // Only recurse if both mockData and schema have nested objects at this key
259
+ if (
260
+ typeof mockValue === 'object' &&
261
+ mockValue !== null &&
262
+ !Array.isArray(mockValue) &&
263
+ typeof schemaValue === 'object' &&
264
+ schemaValue !== null &&
265
+ !Array.isArray(schemaValue)
266
+ ) {
267
+ relocateMisplacedNestedKeys(
268
+ mockValue as Record<string, unknown>,
269
+ schemaValue as JsonTypeDefinition,
270
+ [...currentPathForLogging, key],
271
+ );
272
+ }
273
+ }
274
+ }
275
+
276
+ /**
277
+ * Generate default mock data for a schema type.
278
+ * Returns reasonable default values based on the schema type string.
279
+ */
280
+ function generateDefaultForSchemaType(schemaType: unknown): unknown {
281
+ if (typeof schemaType === 'string') {
282
+ // Handle common type strings
283
+ if (schemaType === 'function') return () => {};
284
+ if (schemaType === 'promise') return Promise.resolve();
285
+ if (schemaType === 'boolean') return false;
286
+ if (schemaType === 'string') return '';
287
+ if (schemaType === 'number') return 0;
288
+ if (schemaType.includes('number | undefined')) return undefined;
289
+ if (schemaType.includes('string | undefined')) return undefined;
290
+ if (schemaType.includes('boolean | undefined')) return undefined;
291
+ if (schemaType.includes('| undefined')) return undefined;
292
+ if (schemaType.includes('| null')) return null;
293
+ return schemaType; // Return the type as a string placeholder
294
+ }
295
+ if (
296
+ typeof schemaType === 'object' &&
297
+ schemaType !== null &&
298
+ !Array.isArray(schemaType)
299
+ ) {
300
+ // Recursively generate defaults for nested objects
301
+ const result: Record<string, unknown> = {};
302
+ for (const [key, value] of Object.entries(schemaType)) {
303
+ result[key] = generateDefaultForSchemaType(value);
304
+ }
305
+ return result;
306
+ }
307
+ return undefined;
308
+ }
309
+
310
+ /**
311
+ * Detect if a string should be converted to an array.
312
+ * Returns the array if the field appears to be an array field, or null if it should remain a string.
313
+ *
314
+ * This handles two cases:
315
+ * 1. Comma-separated values: "color,size" -> ["color", "size"]
316
+ * 2. Single values for array-named fields: "Finish" -> ["Finish"]
317
+ */
318
+ function parseCommaSeparatedStringAsArray(
319
+ value: string,
320
+ key: string,
321
+ ): string[] | null {
322
+ // Heuristic: if the key name suggests it's an array field, convert it
323
+ // Common patterns: *_attributes, *_ids, *_items, *_tags, *_values, plural names
324
+ // Check this FIRST because array-named fields should be converted regardless
325
+ // of whether they contain commas (single values become single-element arrays).
326
+ const arrayFieldPatterns = [
327
+ /_attributes$/i,
328
+ /_ids$/i,
329
+ /_items$/i,
330
+ /_tags$/i,
331
+ /_values$/i,
332
+ /_types$/i,
333
+ /_names$/i,
334
+ /_keys$/i,
335
+ /^attributes$/i,
336
+ /^items$/i,
337
+ /^tags$/i,
338
+ /^values$/i,
339
+ ];
340
+
341
+ const looksLikeArrayField = arrayFieldPatterns.some((pattern) =>
342
+ pattern.test(key),
343
+ );
344
+
345
+ if (looksLikeArrayField) {
346
+ // Skip newlines check - multiline values shouldn't be split
347
+ if (value.includes('\n')) {
348
+ return null;
349
+ }
350
+ // Split by comma and trim whitespace
351
+ const parts = value.split(',').map((s) => s.trim());
352
+ // Filter out empty strings - this handles both "Finish" -> ["Finish"]
353
+ // and "" -> []
354
+ return parts.filter((s) => s.length > 0);
355
+ }
356
+
357
+ // For non-array-named fields, only convert if there are commas
358
+ if (!value.includes(',')) {
359
+ return null;
360
+ }
361
+
362
+ // For non-array-named fields, apply stricter sentence detection
363
+ // Skip if it looks like a sentence (comma followed by space and lowercase)
364
+ if (/,\s+[a-z]/.test(value)) {
365
+ return null;
366
+ }
367
+ // Skip if it contains newlines (likely formatted text)
368
+ if (value.includes('\n')) {
369
+ return null;
370
+ }
371
+
372
+ return null;
373
+ }
374
+
375
+ /**
376
+ * Convert comma-separated string values to arrays when they look like array data.
377
+ * This handles cases where the LLM generates strings like "color,size" instead
378
+ * of arrays like ["color", "size"] due to schema type misdetection.
379
+ */
380
+ function convertCommaSeparatedStringsToArrays(
381
+ mockData: Record<string, unknown>,
382
+ ): void {
383
+ for (const [key, value] of Object.entries(mockData)) {
384
+ if (typeof value === 'string') {
385
+ const asArray = parseCommaSeparatedStringAsArray(value, key);
386
+ if (asArray !== null) {
387
+ mockData[key] = asArray;
388
+ awsLog(
389
+ `CodeYam: Converted comma-separated string to array for key "${key}": "${value}" -> [${asArray.map((s) => `"${s}"`).join(', ')}]`,
390
+ );
391
+ }
392
+ } else if (
393
+ value !== null &&
394
+ typeof value === 'object' &&
395
+ !Array.isArray(value)
396
+ ) {
397
+ // Recursively process nested objects
398
+ convertCommaSeparatedStringsToArrays(value as Record<string, unknown>);
399
+ } else if (Array.isArray(value)) {
400
+ // Recursively process arrays (each element could be an object)
401
+ for (const item of value) {
402
+ if (item !== null && typeof item === 'object' && !Array.isArray(item)) {
403
+ convertCommaSeparatedStringsToArrays(item as Record<string, unknown>);
404
+ }
405
+ }
406
+ }
407
+ }
408
+ }
409
+
410
+ /**
411
+ * Ensure all keys from dataForMocks have corresponding data in mockData.
412
+ * For missing keys, generate default values based on the schema.
413
+ * Recursively checks nested objects to fill in any missing nested fields.
414
+ */
415
+ function fillMissingMockDataKeysWithDefaults(
416
+ mockData: Record<string, unknown>,
417
+ dataForMocks: JsonTypeDefinition,
418
+ pathPrefix: string = '',
419
+ ): void {
420
+ if (typeof dataForMocks !== 'object' || dataForMocks === null) {
421
+ return;
422
+ }
423
+
424
+ const missingKeys: string[] = [];
425
+
426
+ for (const key of Object.keys(dataForMocks)) {
427
+ const fullPath = pathPrefix ? `${pathPrefix}.${key}` : key;
428
+
429
+ if (mockData[key] === undefined) {
430
+ missingKeys.push(fullPath);
431
+ // Generate default data based on schema
432
+ const schemaForKey = dataForMocks[key];
433
+ mockData[key] = generateDefaultForSchemaType(schemaForKey);
434
+ } else {
435
+ // Key exists, but if both are objects, recursively check for missing nested keys
436
+ const schemaValue = dataForMocks[key];
437
+ const mockValue = mockData[key];
438
+ if (
439
+ typeof schemaValue === 'object' &&
440
+ schemaValue !== null &&
441
+ !Array.isArray(schemaValue) &&
442
+ typeof mockValue === 'object' &&
443
+ mockValue !== null &&
444
+ !Array.isArray(mockValue)
445
+ ) {
446
+ fillMissingMockDataKeysWithDefaults(
447
+ mockValue as Record<string, unknown>,
448
+ schemaValue as JsonTypeDefinition,
449
+ fullPath,
450
+ );
451
+ }
452
+ }
453
+ }
454
+
455
+ if (missingKeys.length > 0) {
456
+ awsLog(
457
+ `CodeYam: Generated default mock data for ${missingKeys.length} missing key(s): ${missingKeys.slice(0, 10).join(', ')}${missingKeys.length > 10 ? '...' : ''}`,
458
+ );
459
+ }
460
+ }
461
+
17
462
  type ScenarioDataWithoutDescription = Omit<ScenarioData, 'scenarioDescription'>;
18
463
 
19
464
  interface GenerateEntityScenarioDataArgs {
20
465
  entity: Pick<Entity, 'name' | 'filePath' | 'metadata'>;
21
466
  structure: ScenariosDataStructure;
22
467
  scenarios: Scenario[];
468
+ executionFlows?: ExecutionFlow[];
23
469
  incompleteResponse?: string;
24
470
  analysis: Analysis;
25
471
  model?: AI.Model;
@@ -33,10 +479,96 @@ type GenerateDataForScenarioArgs = Omit<
33
479
  defaultScenarioData?: ScenarioData;
34
480
  };
35
481
 
482
+ interface FillMissingMockDataKeysArgs {
483
+ structure: ScenariosDataStructure;
484
+ scenario: Scenario;
485
+ executionFlows: ExecutionFlow[] | undefined;
486
+ fullScenarioData: ScenarioData;
487
+ model: AI.Model | undefined;
488
+ }
489
+
490
+ /**
491
+ * For Default Scenario only: detect missing mockData keys and make a follow-up
492
+ * LLM call to fill them in. This handles cases where the LLM completes normally
493
+ * but misses some keys (often small/simple ones when the schema is large).
494
+ */
495
+ async function fillMissingMockDataKeys({
496
+ structure,
497
+ scenario,
498
+ executionFlows,
499
+ fullScenarioData,
500
+ model,
501
+ }: FillMissingMockDataKeysArgs): Promise<void> {
502
+ if (
503
+ !structure.dataForMocks ||
504
+ typeof structure.dataForMocks !== 'object' ||
505
+ Array.isArray(structure.dataForMocks)
506
+ ) {
507
+ return;
508
+ }
509
+
510
+ const expectedKeys = Object.keys(structure.dataForMocks);
511
+ const generatedKeys = Object.keys(fullScenarioData.data.mockData || {});
512
+ const missingKeys = expectedKeys.filter((k) => !generatedKeys.includes(k));
513
+
514
+ if (missingKeys.length === 0) {
515
+ return;
516
+ }
517
+
518
+ awsLog(
519
+ `Default Scenario missing ${missingKeys.length} keys, making follow-up call`,
520
+ { missingKeys },
521
+ );
522
+
523
+ // Build subset schema with only missing keys
524
+ const missingSchema: Record<string, any> = {};
525
+ for (const key of missingKeys) {
526
+ missingSchema[key] = (structure.dataForMocks as Record<string, any>)[key];
527
+ }
528
+
529
+ const followUpPrompt = generateMissingKeysPrompt({
530
+ scenario,
531
+ executionFlows,
532
+ generatedMockData: fullScenarioData.data.mockData || {},
533
+ missingSchema,
534
+ });
535
+
536
+ const followUpResponse = await completionCall({
537
+ type: 'generateMissingMockData',
538
+ systemMessage: generateMissingKeysSystemMessage(),
539
+ prompt: followUpPrompt,
540
+ model,
541
+ });
542
+
543
+ if (!followUpResponse.completion) {
544
+ return;
545
+ }
546
+
547
+ const followUpJson = validateJson(followUpResponse.completion);
548
+ const followUpParsed = parseJsonSafe(followUpJson);
549
+
550
+ if (
551
+ !followUpParsed ||
552
+ typeof followUpParsed !== 'object' ||
553
+ !('mockData' in followUpParsed)
554
+ ) {
555
+ return;
556
+ }
557
+
558
+ const followUpMockData = (followUpParsed as any).mockData;
559
+ if (followUpMockData && typeof followUpMockData === 'object') {
560
+ fullScenarioData.data.mockData = {
561
+ ...fullScenarioData.data.mockData,
562
+ ...followUpMockData,
563
+ };
564
+ }
565
+ }
566
+
36
567
  export async function generateDataForScenario({
37
568
  entity,
38
569
  structure,
39
570
  scenario,
571
+ executionFlows,
40
572
  defaultScenarioData,
41
573
  incompleteResponse,
42
574
  analysis,
@@ -44,11 +576,99 @@ export async function generateDataForScenario({
44
576
  }: GenerateDataForScenarioArgs) {
45
577
  awsLogDebugLevel(1, `Generating data for ${entity.name}: ${scenario.name}`);
46
578
 
579
+ // Check if we should chunk the data structure for focused processing
580
+ let chunkedMockData: Record<string, unknown> | undefined;
581
+ const coveredFlowIds = scenario.metadata?.coveredFlows || [];
582
+
583
+ if (
584
+ structure.dataForMocks &&
585
+ !incompleteResponse // Don't do chunked calls on continuation
586
+ ) {
587
+ const chunks = chunkDataStructure(structure.dataForMocks);
588
+
589
+ // If we have multiple chunks, process each one with a focused call
590
+ if (chunks.length > 1) {
591
+ awsLog(
592
+ `Data structure has ${Object.keys(structure.dataForMocks).length} keys, splitting into ${chunks.length} chunks for focused processing`,
593
+ );
594
+
595
+ chunkedMockData = {};
596
+
597
+ for (let i = 0; i < chunks.length; i++) {
598
+ const chunk = chunks[i];
599
+ const chunkKeys = Object.keys(chunk || {});
600
+
601
+ // Get relevant requiredValues for this chunk
602
+ const relevantRequiredValues = getRequiredValuesForChunk(
603
+ chunk,
604
+ executionFlows || [],
605
+ coveredFlowIds,
606
+ );
607
+
608
+ awsLog(
609
+ `Processing chunk ${i + 1}/${chunks.length}: ${chunkKeys.join(', ')}`,
610
+ );
611
+
612
+ const chunkPrompt = generateChunkPrompt({
613
+ scenario,
614
+ chunk,
615
+ chunkIndex: i,
616
+ totalChunks: chunks.length,
617
+ relevantRequiredValues,
618
+ });
619
+
620
+ const chunkResponse = await completionCall({
621
+ type: 'generateChunkMockData',
622
+ systemMessage: generateChunkSystemMessage(scenario.name),
623
+ prompt: chunkPrompt,
624
+ model,
625
+ });
626
+
627
+ // Save chunk call to LLM log for replay support
628
+ await saveLlmCall({
629
+ object_type: 'analysis',
630
+ object_id: analysis.id,
631
+ propsJson: {
632
+ entity: { name: entity.name, filePath: entity.filePath },
633
+ scenario: { name: scenario.name },
634
+ chunkIndex: i,
635
+ totalChunks: chunks.length,
636
+ },
637
+ ...chunkResponse.stats,
638
+ });
639
+
640
+ if (chunkResponse.completion) {
641
+ const validJson = validateJson(chunkResponse.completion);
642
+ const parsed = parseJsonSafe(validJson);
643
+ if (parsed && typeof parsed === 'object' && 'mockData' in parsed) {
644
+ const chunkMockData = (parsed as any).mockData;
645
+ if (chunkMockData && typeof chunkMockData === 'object') {
646
+ Object.assign(chunkedMockData, chunkMockData);
647
+ awsLog(
648
+ `Chunk ${i + 1} generated data for: ${Object.keys(chunkMockData).join(', ')}`,
649
+ );
650
+ }
651
+ }
652
+ }
653
+ }
654
+
655
+ awsLog(
656
+ `Chunked processing complete. Generated ${Object.keys(chunkedMockData).length} keys total`,
657
+ );
658
+ }
659
+ }
660
+
661
+ // When we have chunked mock data with actual content, tell the main prompt to skip mockData generation
662
+ // Important: Check for actual keys, not just truthy object, because {} would skip generation incorrectly
663
+ const hasChunkedData =
664
+ chunkedMockData && Object.keys(chunkedMockData).length > 0;
47
665
  const prompt = generateEntityScenarioDataGenerator(
48
666
  structure,
49
667
  scenario,
668
+ executionFlows,
50
669
  defaultScenarioData,
51
670
  incompleteResponse,
671
+ { mockDataAlreadyGenerated: hasChunkedData },
52
672
  );
53
673
 
54
674
  const isDefault = scenario.name === DEFAULT_SCENARIO_NAME;
@@ -91,7 +711,7 @@ export async function generateDataForScenario({
91
711
  ...response.stats,
92
712
  });
93
713
 
94
- const { completion, finishReason } = response;
714
+ let { completion, finishReason } = response;
95
715
 
96
716
  if (!completion) {
97
717
  console.log(
@@ -100,42 +720,80 @@ export async function generateDataForScenario({
100
720
  return null;
101
721
  }
102
722
 
103
- awsLog(
104
- `LLMCall ${llmCall ? llmCall.id : 'N/A'}: ${entity.filePath} ${entity.metadata?.exportAlias ?? entity.name} scenario data completion :>> Finish reason:`,
105
- {
106
- finishReason,
107
- completion,
108
- },
723
+ awsLogDebugLevel(
724
+ 1,
725
+ `LLMCall ${llmCall ? llmCall.id : 'N/A'}: ${entity.filePath} ${entity.metadata?.exportAlias ?? entity.name} finishReason: ${finishReason}`,
109
726
  );
110
727
 
728
+ // If response was truncated due to token limit, make a continuation call
729
+ if (finishReason === 'length') {
730
+ awsLogDebugLevel(1, 'Response truncated, making continuation call');
731
+
732
+ const continuationResponse = await completionCall({
733
+ type: 'generateEntityScenarioData',
734
+ systemMessage: generateIncompleteSystemMessage(scenario.name, isDefault),
735
+ prompt: completion, // Pass the incomplete response as the prompt
736
+ model,
737
+ });
738
+
739
+ if (continuationResponse.completion) {
740
+ completion = completion + continuationResponse.completion;
741
+ finishReason = continuationResponse.finishReason;
742
+ }
743
+ }
744
+
111
745
  const validJson = validateJson(completion);
112
746
 
113
747
  const parsed = parseJsonSafe(validJson);
114
748
  if (!parsed || typeof parsed !== 'object' || !('scenarioData' in parsed)) {
115
- console.log('CodeYam Debug: generateDataForScenario failed to parse', {
116
- entityName: entity.name,
117
- scenarioName: scenario.name,
118
- hasParsed: !!parsed,
119
- parsedType: typeof parsed,
120
- hasScenarioData: parsed && 'scenarioData' in parsed,
121
- completionPreview: completion.substring(0, 200),
122
- });
749
+ awsLog(`Failed to parse scenario data for ${entity.name}/${scenario.name}`);
123
750
  return null;
124
751
  }
125
752
 
126
- const { scenarioData: scenarioDataWithoutDescription } = parsed as {
753
+ let { scenarioData: scenarioDataWithoutDescription } = parsed as {
127
754
  scenarioData: ScenarioDataWithoutDescription;
128
755
  };
129
756
 
130
- console.log('CodeYam Debug: generateDataForScenario parsed successfully', {
131
- entityName: entity.name,
132
- scenarioName: scenario.name,
133
- parsedScenarioName: scenarioDataWithoutDescription.scenarioName,
134
- hasData: !!scenarioDataWithoutDescription.data,
135
- dataKeys: scenarioDataWithoutDescription.data
136
- ? Object.keys(scenarioDataWithoutDescription.data)
137
- : [],
138
- });
757
+ // FIX: LLM sometimes puts mock data keys directly under scenarioData instead of
758
+ // under scenarioData.data.mockData. Detect and fix this structural issue.
759
+ if (structure.dataForMocks) {
760
+ const scenarioDataAsAny = scenarioDataWithoutDescription as any;
761
+ const reservedKeys = new Set([
762
+ 'scenarioName',
763
+ 'data',
764
+ 'scenarioDescription',
765
+ ]);
766
+ const misplacedKeys: string[] = [];
767
+
768
+ // Find keys that are directly under scenarioData but should be in mockData
769
+ for (const key of Object.keys(scenarioDataAsAny)) {
770
+ if (reservedKeys.has(key)) continue;
771
+ // If this key exists in the dataForMocks schema, it's misplaced
772
+ if (key in structure.dataForMocks) {
773
+ misplacedKeys.push(key);
774
+ }
775
+ }
776
+
777
+ if (misplacedKeys.length > 0) {
778
+ // Ensure data.mockData exists
779
+ if (!scenarioDataAsAny.data) {
780
+ scenarioDataAsAny.data = {};
781
+ }
782
+ if (!scenarioDataAsAny.data.mockData) {
783
+ scenarioDataAsAny.data.mockData = {};
784
+ }
785
+
786
+ // Move misplaced keys to mockData
787
+ for (const key of misplacedKeys) {
788
+ scenarioDataAsAny.data.mockData[key] = scenarioDataAsAny[key];
789
+ delete scenarioDataAsAny[key];
790
+ }
791
+
792
+ // Update the reference
793
+ scenarioDataWithoutDescription =
794
+ scenarioDataAsAny as ScenarioDataWithoutDescription;
795
+ }
796
+ }
139
797
 
140
798
  const fullScenarioData: ScenarioData = {
141
799
  ...scenarioDataWithoutDescription,
@@ -144,8 +802,9 @@ export async function generateDataForScenario({
144
802
 
145
803
  if (structure.dataForMocks && !fullScenarioData.data.argumentsData) {
146
804
  fullScenarioData.data.argumentsData = [];
147
- if (structure.arguments && !fullScenarioData.data.argumentsData) {
148
- fullScenarioData.data.argumentsData = [];
805
+ // Populate argumentsData from structure.arguments using top-level data values
806
+ // Bug fix: removed redundant !argumentsData check that was always false after setting to []
807
+ if (structure.arguments) {
149
808
  for (let i = 0; i < structure.arguments.length; ++i) {
150
809
  if (!fullScenarioData.data.argumentsData[i]) {
151
810
  fullScenarioData.data.argumentsData[i] = {};
@@ -158,14 +817,123 @@ export async function generateDataForScenario({
158
817
  }
159
818
  }
160
819
 
161
- if (structure.dataForMocks && !fullScenarioData.data.mockData) {
162
- fullScenarioData.data.mockData = {};
163
- for (const propKey of Object.keys(structure.arguments)) {
164
- const dataAsAny = fullScenarioData.data as any;
165
- fullScenarioData.data.mockData[propKey] = dataAsAny[propKey];
820
+ // Merge flat-level mock data into mockData.
821
+ // Sometimes the LLM returns some data inside data.mockData but other data at the flat
822
+ // data level (e.g., data.useRouter() instead of data.mockData.useRouter()).
823
+ // This code ensures all dataForMocks keys end up in mockData.
824
+ if (structure.dataForMocks) {
825
+ fullScenarioData.data.mockData ||= {};
826
+ const dataAsAny = fullScenarioData.data as any;
827
+ for (const propKey of Object.keys(structure.dataForMocks)) {
828
+ // Only copy if it exists at flat level and not already in mockData
829
+ if (
830
+ dataAsAny[propKey] !== undefined &&
831
+ !fullScenarioData.data.mockData[propKey]
832
+ ) {
833
+ fullScenarioData.data.mockData[propKey] = dataAsAny[propKey];
834
+ }
835
+ }
836
+ }
837
+
838
+ // Merge chunked mock data from focused calls (takes priority over main call's data)
839
+ // This ensures keys processed with focused attention are correctly generated.
840
+ if (chunkedMockData && fullScenarioData.data.mockData) {
841
+ for (const [key, value] of Object.entries(chunkedMockData)) {
842
+ // Chunked data takes priority - overwrite main call's potentially wrong data
843
+ fullScenarioData.data.mockData[key] = value;
844
+ }
845
+ awsLog(
846
+ `Merged chunked mock data for keys: ${Object.keys(chunkedMockData).join(', ')}`,
847
+ );
848
+ }
849
+
850
+ // Relocate misplaced nested keys to their correct position.
851
+ // The LLM sometimes places nested keys at root level instead of inside their
852
+ // parent object (e.g., 'fastener' at root instead of inside 'trpc').
853
+ // This ensures the mockData structure matches the dataForMocks schema.
854
+ if (structure.dataForMocks && fullScenarioData.data.mockData) {
855
+ relocateMisplacedNestedKeys(
856
+ fullScenarioData.data.mockData,
857
+ structure.dataForMocks,
858
+ );
859
+ }
860
+
861
+ // Convert null values to undefined based on schema type constraints.
862
+ // LLM uses null for "no value" (JSON doesn't support undefined), but TypeScript
863
+ // types like "string | undefined" don't accept null. This converts null→undefined
864
+ // for fields typed as "T | undefined" (but preserves null for "T | null").
865
+ if (structure.dataForMocks && fullScenarioData.data.mockData) {
866
+ convertNullToUndefinedBySchema(
867
+ fullScenarioData.data.mockData,
868
+ structure.dataForMocks,
869
+ );
870
+ }
871
+
872
+ // Convert comma-separated strings to arrays when appropriate.
873
+ // The LLM sometimes generates strings like "color,size" instead of arrays
874
+ // like ["color", "size"] when the schema type is incorrectly inferred as
875
+ // 'string' instead of 'string[]'. This causes runtime errors when code
876
+ // calls array methods like .map() on the value.
877
+ if (fullScenarioData.data.mockData) {
878
+ convertCommaSeparatedStringsToArrays(fullScenarioData.data.mockData);
879
+ }
880
+
881
+ // Fix null values for ID fields when the schema indicates they should be non-null.
882
+ // The LLM sometimes generates `null` for ID fields (e.g., `"id": null`) when
883
+ // the schema type is `"number"`. This causes runtime issues when code checks
884
+ // `if (!data?.id)` expecting a truthy value.
885
+ if (structure.dataForMocks && fullScenarioData.data.mockData) {
886
+ fixNullIdsBySchema(fullScenarioData.data.mockData, structure.dataForMocks);
887
+ }
888
+
889
+ if (structure.arguments && fullScenarioData.data.argumentsData) {
890
+ for (let i = 0; i < fullScenarioData.data.argumentsData.length; i++) {
891
+ if (structure.arguments[i]) {
892
+ convertNullToUndefinedBySchema(
893
+ fullScenarioData.data.argumentsData[i],
894
+ structure.arguments[i],
895
+ );
896
+ }
166
897
  }
167
898
  }
168
899
 
900
+ // For Default Scenario only: check for missing keys and make follow-up call if needed.
901
+ // This tries to get better-quality data via LLM before falling back to defaults.
902
+ if (isDefault) {
903
+ await fillMissingMockDataKeys({
904
+ structure,
905
+ scenario,
906
+ executionFlows,
907
+ fullScenarioData,
908
+ model,
909
+ });
910
+ }
911
+
912
+ // Fill in missing mock data keys with default values (after trying LLM follow-up).
913
+ // The LLM sometimes doesn't generate data for all keys in large schemas.
914
+ // This ensures all dataForMocks keys have corresponding data to prevent
915
+ // runtime errors like "Cannot read properties of undefined".
916
+ // Only run for Default Scenario - non-default scenarios will get missing
917
+ // data filled in from the merge with default scenario data.
918
+ if (isDefault && structure.dataForMocks && fullScenarioData.data.mockData) {
919
+ fillMissingMockDataKeysWithDefaults(
920
+ fullScenarioData.data.mockData,
921
+ structure.dataForMocks,
922
+ );
923
+ }
924
+
925
+ // Track the final scenario data for E2E debugging
926
+ trackDataSnapshot(
927
+ 'generateDataForScenario_result',
928
+ {
929
+ scenarioName: scenario.name,
930
+ mockData: fullScenarioData.data.mockData,
931
+ argumentsData: fullScenarioData.data.argumentsData,
932
+ },
933
+ entity.name,
934
+ scenario.name,
935
+ );
936
+
169
937
  return {
170
938
  scenarioData: fullScenarioData,
171
939
  llmCall: { name: scenario.name, id: llmCall.id },
@@ -176,6 +944,7 @@ export default async function generateEntityScenarioData({
176
944
  entity,
177
945
  structure,
178
946
  scenarios,
947
+ executionFlows,
179
948
  incompleteResponse,
180
949
  analysis,
181
950
  model,
@@ -196,6 +965,7 @@ export default async function generateEntityScenarioData({
196
965
  entity,
197
966
  structure,
198
967
  scenario: defaultScenario,
968
+ executionFlows,
199
969
  incompleteResponse,
200
970
  analysis,
201
971
  model,
@@ -218,6 +988,7 @@ export default async function generateEntityScenarioData({
218
988
  entity,
219
989
  structure,
220
990
  scenario,
991
+ executionFlows,
221
992
  defaultScenarioData,
222
993
  incompleteResponse,
223
994
  analysis,
@@ -238,37 +1009,77 @@ export default async function generateEntityScenarioData({
238
1009
  );
239
1010
  }
240
1011
 
241
- scenarioDatas.push(...validResults.map((result) => result.scenarioData));
242
- llmCalls.push(...validResults.map((result) => result.llmCall));
1012
+ // Merge non-default scenario data with default scenario data
1013
+ // The LLM generates partial data (only differences), we need to merge with default
1014
+ const mergedScenarioDatas = validResults.map((result) => {
1015
+ const scenarioData = result.scenarioData;
1016
+
1017
+ // Merge mockData with default mockData
1018
+ if (defaultScenarioData.data?.mockData && scenarioData.data?.mockData) {
1019
+ scenarioData.data.mockData = deepMergeScenarioData(
1020
+ defaultScenarioData.data.mockData,
1021
+ scenarioData.data.mockData,
1022
+ );
1023
+ } else if (
1024
+ defaultScenarioData.data?.mockData &&
1025
+ !scenarioData.data?.mockData
1026
+ ) {
1027
+ // Use default mockData if scenario has none
1028
+ scenarioData.data.mockData = { ...defaultScenarioData.data.mockData };
1029
+ }
243
1030
 
244
- console.log('CodeYam Debug: generateEntityScenarioData results', {
245
- filePath: entity.filePath,
246
- entityName: entity.name,
247
- totalScenarios: scenarios.length,
248
- defaultScenarioGenerated: !!defaultScenarioResult,
249
- otherScenariosRequested: scenarios.length - 1,
250
- otherScenariosResults: results.length,
251
- nullResults: results.filter((r) => r === null).length,
252
- validResults: validResults.length,
253
- finalScenarioDatasCount: scenarioDatas.length,
1031
+ // Merge argumentsData with default argumentsData
1032
+ if (
1033
+ defaultScenarioData.data?.argumentsData &&
1034
+ Array.isArray(defaultScenarioData.data.argumentsData) &&
1035
+ scenarioData.data?.argumentsData &&
1036
+ Array.isArray(scenarioData.data.argumentsData)
1037
+ ) {
1038
+ for (
1039
+ let i = 0;
1040
+ i < defaultScenarioData.data.argumentsData.length;
1041
+ i++
1042
+ ) {
1043
+ const scenarioArg = scenarioData.data.argumentsData[i];
1044
+ const defaultArg = defaultScenarioData.data.argumentsData[i];
1045
+
1046
+ // Only merge if both are objects (LLM sometimes returns primitives)
1047
+ if (
1048
+ scenarioArg &&
1049
+ typeof scenarioArg === 'object' &&
1050
+ !Array.isArray(scenarioArg) &&
1051
+ defaultArg &&
1052
+ typeof defaultArg === 'object' &&
1053
+ !Array.isArray(defaultArg)
1054
+ ) {
1055
+ scenarioData.data.argumentsData[i] = deepMergeScenarioData(
1056
+ defaultArg,
1057
+ scenarioArg,
1058
+ );
1059
+ } else if (scenarioArg !== undefined) {
1060
+ // Keep the scenario value as-is (even if primitive)
1061
+ scenarioData.data.argumentsData[i] = scenarioArg;
1062
+ } else if (defaultArg && typeof defaultArg === 'object') {
1063
+ // Use default if scenario is undefined and default is an object
1064
+ scenarioData.data.argumentsData[i] = { ...defaultArg };
1065
+ } else {
1066
+ scenarioData.data.argumentsData[i] = defaultArg;
1067
+ }
1068
+ }
1069
+ } else if (
1070
+ defaultScenarioData.data?.argumentsData &&
1071
+ !scenarioData.data?.argumentsData
1072
+ ) {
1073
+ // Use default argumentsData if scenario has none
1074
+ scenarioData.data.argumentsData =
1075
+ defaultScenarioData.data.argumentsData.map((arg) => ({ ...arg }));
1076
+ }
1077
+
1078
+ return scenarioData;
254
1079
  });
255
1080
 
256
- awsLog(
257
- 'CodeYam: scenarioDatas :>> ',
258
- JSON.stringify(
259
- {
260
- filePath: entity.filePath,
261
- entityName: entity.name,
262
- scenarioDatas: scenarioDatas.map((sd) => ({
263
- scenarioName: sd.scenarioName,
264
- hasData: !!sd.data,
265
- dataKeys: sd.data ? Object.keys(sd.data) : [],
266
- })),
267
- },
268
- null,
269
- 2,
270
- ),
271
- );
1081
+ scenarioDatas.push(...mergedScenarioDatas);
1082
+ llmCalls.push(...validResults.map((result) => result.llmCall));
272
1083
 
273
1084
  return { scenarioDatas, llmCalls };
274
1085
  } catch (error) {
@@ -280,13 +1091,15 @@ export default async function generateEntityScenarioData({
280
1091
  export const generateSystemMessage = (
281
1092
  scenarioName: string,
282
1093
  defaultScenario: boolean,
1094
+ requiresErrorData: boolean = false,
283
1095
  ) => {
284
1096
  const scenarioType = defaultScenario
285
1097
  ? `## Default Scenario
286
1098
  Generate COMPLETE, robust data for the entire data structure.
287
- - Fill ALL fields with realistic values (except error attributes and key attributes set to null or undefined)
288
- - Arrays should have 2-3 items
289
- - Don't skip nested attributes unless the key attributes specify a parent attribute should be null or undefined
1099
+ - Fill ALL fields with realistic values (except error attributes)
1100
+ - Do not skip any keys, even simple or small entries
1101
+ - Arrays should have 3-5 items to provide realistic test data variety
1102
+ - Don't skip nested attributes unless the execution flow requirements specify a parent attribute should be null or undefined
290
1103
  - This provides the baseline data for all other scenarios`
291
1104
  : `## Non-Default Scenario
292
1105
  Generate ONLY the differences from the default scenario.
@@ -294,14 +1107,68 @@ Generate ONLY the differences from the default scenario.
294
1107
  - Set to \`null\` to remove data
295
1108
  - Omit unchanged fields—they merge from default`;
296
1109
 
1110
+ // Only include the "NO ERROR DATA" instruction when the scenario doesn't require error data
1111
+ const noErrorDataInstruction = requiresErrorData
1112
+ ? `## IMPORTANT: ERROR DATA REQUIRED
1113
+ This scenario tests error handling. You MUST include "error" fields with realistic error messages.
1114
+ - Set error fields to truthy values (e.g., "Error: Operation failed" or "Something went wrong")
1115
+ - The error data is REQUIRED to trigger the correct error UI state`
1116
+ : `## CRITICAL: NO ERROR DATA
1117
+ NEVER include "error" fields in responses. Skip them entirely.
1118
+ - If structure has \`{ data: {...}, error: {...} }\`, only fill \`data\`
1119
+ - Leave out any attribute named "error"—do not set to null, omit entirely`;
1120
+
297
1121
  return `You are a test data generator. Create mock data matching a data structure and scenario requirements.
298
1122
 
1123
+ ## Execution Flow Requirements
1124
+ Each scenario has \`coveredFlows\` which lists the execution flows (distinct outcomes/behaviors) this scenario should demonstrate.
1125
+ Each flow has \`requiredValues\` - the attribute values that MUST be set to produce that outcome.
1126
+
1127
+ **Your job**: Generate mock data that satisfies ALL the requiredValues from ALL coveredFlows.
1128
+
1129
+ For example, if a flow requires:
1130
+ \`\`\`json
1131
+ {
1132
+ "attributePath": "signature[0].isLoading",
1133
+ "value": "false",
1134
+ "comparison": "equals",
1135
+ "valueType": "boolean"
1136
+ }
1137
+ \`\`\`
1138
+ Then set \`isLoading: false\` in the mockData.
1139
+
1140
+ ### Array Length Requirements (length< and length>)
1141
+ For array size variation flows:
1142
+ - \`comparison: "length<"\` with \`value: "0"\` → generate EMPTY array \`[]\`
1143
+ - \`comparison: "length<"\` with \`value: "3"\` → generate 1-2 items (few items)
1144
+ - \`comparison: "length>"\` with \`value: "10"\` → generate 12+ items (many items)
1145
+
1146
+ ### String Length Requirements (normal vs long)
1147
+ For text length variation flows:
1148
+ - \`value: "normal"\` with \`valueType: "string"\` → generate normal length text (10-50 chars)
1149
+ - \`value: "long"\` with \`valueType: "string"\` → generate LONG text (200+ chars) to test overflow/truncation
1150
+
1151
+ ## CRITICAL: Blocking Flows to Avoid
1152
+ If the scenario includes \`blockingFlowsToAvoid\`, these are flows (like modals, overlays) that would BLOCK the expected UI.
1153
+ You MUST generate mock data that PREVENTS these flows from triggering:
1154
+
1155
+ - For \`comparison: "truthy"\` requirements → set the value to \`false\`, \`null\`, \`undefined\`, or \`0\`
1156
+ - For \`comparison: "exists"\` requirements → set the value to \`null\` or omit it entirely
1157
+ - For \`comparison: "equals"\` requirements → set a DIFFERENT value than what's required
1158
+
1159
+ For example, if a blocking flow has:
1160
+ \`\`\`json
1161
+ {
1162
+ "attributePath": "useFetcher().data.success",
1163
+ "value": "true",
1164
+ "comparison": "truthy"
1165
+ }
1166
+ \`\`\`
1167
+ Then you MUST set \`useFetcher().data\` to \`null\` or \`{ success: false }\` to prevent the modal from appearing.
1168
+
299
1169
  ${scenarioType}
300
1170
 
301
- ## CRITICAL: NO ERROR DATA
302
- NEVER include "error" fields in responses. Skip them entirely.
303
- - If structure has \`{ data: {...}, error: {...} }\`, only fill \`data\`
304
- - Leave out any attribute named "error"—do not set to null, omit entirely
1171
+ ${noErrorDataInstruction}
305
1172
 
306
1173
  ## Special Markers
307
1174
 
@@ -317,30 +1184,19 @@ Use for relative dates. Code runs in Node (no browser APIs, no external librarie
317
1184
  \`\`\`
318
1185
  Use simple elements only (\`<div>\`, \`<span>\`). No custom components.
319
1186
 
320
- ## Mock Data Keys
321
- Preserve keys exactly as written in the structure. There are two formats:
1187
+ ### Arrays
1188
+ - Arrays should have many items (at least 4) unless specified otherwise
1189
+ - Each item must follow the exact structure provided
1190
+ - In general we want robust data, not minimal data unless specified otherwise
322
1191
 
323
- ### Standard function calls
324
- \`\`\`json
325
- {
326
- "mockData": {
327
- "useUser()": { "user": { "name": "John" } },
328
- "from().select()": [{ "id": "1" }]
329
- }
330
- }
331
- \`\`\`
332
-
333
- ### Variable-qualified calls (for multiple calls to the same function)
334
- When the same function is called multiple times with results stored in different variables, keys use the format \`variableName <- functionName\`:
335
- \`\`\`json
336
- {
337
- "mockData": {
338
- "entityDiffFetcher <- useFetcher": { "data": null, "state": "idle" },
339
- "reportFetcher <- useFetcher": { "data": { "reportId": "abc123" }, "state": "idle" }
340
- }
341
- }
342
- \`\`\`
343
- This reads as "entityDiffFetcher receives from useFetcher". Each variable gets its own distinct mock data.
1192
+ ## CRITICAL: Preserve Exact Structure
1193
+ Your response MUST mirror the EXACT nested structure provided in mockData Structure.
1194
+ - Do NOT reorganize, split, or create duplicate keys
1195
+ - The hierarchy of nested objects must match exactly what was provided unless overridden by scenario rules
1196
+ - Only change the leaf VALUES (replacing type descriptions like "string" with actual data like "hello")
1197
+ - Copy the key strings EXACTLY from the structure
1198
+ - Do NOT modify type parameters, arguments, or any part of the key
1199
+ - The keys preserve the exact function call as written in the original code
344
1200
 
345
1201
  ## Response Format
346
1202
  \`\`\`json
@@ -358,9 +1214,15 @@ This reads as "entityDiffFetcher receives from useFetcher". Each variable gets i
358
1214
  ## Rules
359
1215
  - Valid JSON only—no raw code outside markers
360
1216
  - No \`undefined\`—use \`null\` or omit
361
- - No data references (can't use \`posts[0]\` elsewhere—duplicate the value)
1217
+ - No data references (can't use \`posts[0]\` elsewhere duplicate the value)
362
1218
  - Scenario name must match exactly: "${scenarioName}"
363
1219
  - Empty mockData: \`{}\`, empty argumentsData: \`[]\`
1220
+
1221
+ ## IMPORTANT: Avoid Identifier Collisions
1222
+ When generating identifier values (SHA hashes, entity IDs, etc.):
1223
+ - Use DISTINCT values for different identifier fields
1224
+ - Avoid matching: if \`entity.sha\` is "abc123", arrays like \`jobs[].entityShas\` or \`currentlyExecuting.entityShas\` should NOT contain "abc123"
1225
+ - This prevents accidental blocking of UI conditionals that check if IDs are in/not-in arrays
364
1226
  `;
365
1227
  };
366
1228
 
@@ -376,3 +1238,161 @@ Here is the original system message as well:
376
1238
  ${generateSystemMessage(scenarioName, isDefault)}
377
1239
  \`\`\`
378
1240
  `;
1241
+
1242
+ /**
1243
+ * System message for follow-up calls to generate missing mockData keys.
1244
+ * Includes the same rules as the main system message but with a simpler response format.
1245
+ */
1246
+ export const generateMissingKeysSystemMessage =
1247
+ () => `You are completing mock data generation for the Default Scenario. The initial response was missing some keys.
1248
+
1249
+ Generate data ONLY for the missing keys provided in the prompt. Do not skip any of them.
1250
+
1251
+ - Scenario name must match exactly: "Default Scenario"
1252
+
1253
+ ## Special Markers
1254
+
1255
+ ### Dynamic Dates (\`~~codeyam-code~~\`)
1256
+ \`\`\`json
1257
+ { "createdAt": { "~~codeyam-code~~": "new Date(Date.now() - 24*60*60*1000)" } }
1258
+ \`\`\`
1259
+ Use for relative dates. Code runs in Node (no browser APIs, no external libraries).
1260
+
1261
+ ### JSX Children (\`~~codeyam-jsx~~\`)
1262
+ \`\`\`json
1263
+ { "children": { "~~codeyam-jsx~~": "<div>Hello</div>" } }
1264
+ \`\`\`
1265
+ Use simple elements only (\`<div>\`, \`<span>\`). No custom components.
1266
+
1267
+ ### Arrays
1268
+ - Arrays should have many items (at least 4) unless specified otherwise
1269
+ - Each item must follow the exact structure provided
1270
+
1271
+ ## CRITICAL: Preserve Exact Structure
1272
+ Your response MUST mirror the EXACT nested structure provided for the missing keys.
1273
+ - Only change the leaf VALUES (replacing type descriptions like "string" with actual data)
1274
+ - Copy the key strings EXACTLY from the structure
1275
+ - Do NOT modify type parameters, arguments, or any part of the key
1276
+
1277
+ ## CRITICAL: NO ERROR DATA
1278
+ NEVER include "error" fields in responses. Skip them entirely.
1279
+ - If structure has \`{ data: {...}, error: {...} }\`, only fill \`data\`
1280
+ - Leave out any attribute named "error"—do not set to null, omit entirely
1281
+
1282
+ ## Response Format
1283
+ \`\`\`json
1284
+ {
1285
+ "mockData": {
1286
+ // fill in ONLY the missing keys
1287
+ }
1288
+ }
1289
+ \`\`\`
1290
+
1291
+ ## Rules
1292
+ - Valid JSON only—no raw code outside markers
1293
+ - No \`undefined\`—use \`null\` or omit
1294
+ - No data references (can't use \`posts[0]\` elsewhere — duplicate the value)
1295
+ `;
1296
+
1297
+ /**
1298
+ * System message for focused calls to generate critical mockData keys.
1299
+ * These are keys referenced by the scenario's execution flow requiredValues.
1300
+ */
1301
+ export const generateCriticalKeysSystemMessage = (
1302
+ scenarioName: string,
1303
+ ) => `You are generating mock data for CRITICAL keys that control scenario behavior.
1304
+
1305
+ These keys are referenced by the execution flow's requiredValues - they directly determine
1306
+ what the component renders. Pay EXTRA attention to matching the exact structure and values.
1307
+
1308
+ - Scenario name must match exactly: "${scenarioName}"
1309
+
1310
+ ## CRITICAL: Special Characters in Keys
1311
+ Keys like \`*\` are LITERAL string keys, NOT wildcards or patterns.
1312
+ - If the schema shows \`{ "*": "string" }\`, generate \`{ "*": "some value" }\`
1313
+ - Do NOT interpret \`*\` as "any key" - use it as an actual key name
1314
+
1315
+ ## CRITICAL: Preserve Exact Structure
1316
+ Your response MUST mirror the EXACT nested structure provided.
1317
+ - Copy key strings EXACTLY as shown (including special characters)
1318
+ - Only change leaf VALUES (replacing type descriptions with actual data)
1319
+ - Do NOT modify keys, type parameters, or add extra keys
1320
+
1321
+ ## Matching requiredValues
1322
+ When the prompt shows requiredValues like:
1323
+ - \`attributePath: "useParams().functionCallReturnValue.*"\`
1324
+ - \`value: "scenarios"\`
1325
+
1326
+ This means set the \`*\` key to include "scenarios". For URL paths split by \`/\`,
1327
+ generate a path like \`"scenarios/id/mode"\` where segments match requirements.
1328
+
1329
+ ## Response Format
1330
+ \`\`\`json
1331
+ {
1332
+ "scenarioData": {
1333
+ "scenarioName": "${scenarioName}",
1334
+ "data": {
1335
+ "mockData": {
1336
+ // generate data for ONLY the critical keys
1337
+ }
1338
+ }
1339
+ }
1340
+ }
1341
+ \`\`\`
1342
+
1343
+ ## Rules
1344
+ - Valid JSON only
1345
+ - No \`undefined\`—use \`null\` or omit
1346
+ - Match the exact schema structure provided
1347
+ `;
1348
+
1349
+ /**
1350
+ * System message for focused calls to generate mock data for a chunk of keys.
1351
+ * Used when data structures are large and need to be processed in smaller pieces.
1352
+ */
1353
+ export const generateChunkSystemMessage = (
1354
+ scenarioName: string,
1355
+ ) => `You are generating mock data for a SUBSET of keys from a larger data structure.
1356
+
1357
+ This chunk contains fewer keys so you can focus on generating HIGH QUALITY data for each one.
1358
+ Pay EXTRA attention to matching the exact structure and values for each key.
1359
+
1360
+ - Scenario name must match exactly: "${scenarioName}"
1361
+
1362
+ ## CRITICAL: Special Characters in Keys
1363
+ Keys like \`*\` are LITERAL string keys, NOT wildcards or patterns.
1364
+ - If the schema shows \`{ "*": "string" }\`, generate \`{ "*": "some value" }\`
1365
+ - Do NOT interpret \`*\` as "any key" - use it as an actual key name
1366
+
1367
+ ## CRITICAL: Preserve Exact Structure
1368
+ Your response MUST mirror the EXACT nested structure provided.
1369
+ - Copy key strings EXACTLY as shown (including special characters)
1370
+ - Only change leaf VALUES (replacing type descriptions with actual data)
1371
+ - Do NOT modify keys, type parameters, or add extra keys
1372
+
1373
+ ## Matching requiredValues
1374
+ If the prompt includes requiredValues, these are specific values that MUST be set:
1375
+ - For \`attributePath: "useParams().functionCallReturnValue.*"\` with \`value: "scenarios"\`
1376
+ → Set the \`*\` key to include "scenarios" (e.g., "scenarios/id/mode")
1377
+ - For URL paths, generate realistic paths that satisfy the requirements
1378
+
1379
+ ## CRITICAL: NO ERROR DATA
1380
+ NEVER include "error" fields in responses. Skip them entirely.
1381
+ - If structure has \`{ data: {...}, error: {...} }\`, only fill \`data\`
1382
+ - Leave out any attribute named "error"—do not set to null, omit entirely
1383
+
1384
+ ## Response Format
1385
+ \`\`\`json
1386
+ {
1387
+ "mockData": {
1388
+ // generate data for ONLY the keys in this chunk
1389
+ }
1390
+ }
1391
+ \`\`\`
1392
+
1393
+ ## Rules
1394
+ - Valid JSON only
1395
+ - No \`undefined\`—use \`null\` or omit
1396
+ - Generate data for ALL keys in the chunk (don't skip any)
1397
+ - Arrays should have many items (at least 4) unless specified otherwise
1398
+ `;