@codeyam/codeyam-cli 0.1.0-staging.596f0eb → 0.1.0-staging.62d4615

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 (914) 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 +16 -12
  5. package/analyzer-template/packages/ai/index.ts +20 -5
  6. package/analyzer-template/packages/ai/package.json +3 -3
  7. package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
  8. package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +214 -24
  9. package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
  10. package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +205 -10
  11. package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
  12. package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +181 -23
  13. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
  14. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
  15. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +38 -1
  16. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
  17. package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +1518 -125
  18. package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +318 -5
  19. package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
  20. package/analyzer-template/packages/ai/src/lib/completionCall.ts +216 -36
  21. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +2301 -348
  22. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +7 -2
  23. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +976 -0
  24. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +243 -77
  25. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.ts +16 -3
  26. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +6 -4
  27. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +71 -2
  28. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +161 -19
  29. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
  30. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +93 -1
  31. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
  32. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +179 -0
  33. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.ts +40 -30
  34. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +422 -86
  35. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
  36. package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +156 -0
  37. package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
  38. package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
  39. package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
  40. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +74 -7
  41. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +89 -112
  42. package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +63 -2
  43. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1394 -92
  44. package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +216 -109
  45. package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +578 -0
  46. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
  47. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +2267 -0
  48. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
  49. package/analyzer-template/packages/ai/src/lib/getConditionalUsagesFromCode.ts +143 -31
  50. package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +8 -2
  51. package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +328 -7
  52. package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +111 -87
  53. package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +17 -7
  54. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
  55. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -102
  56. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
  57. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
  58. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +90 -6
  59. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -53
  60. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
  61. package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +28 -2
  62. package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
  63. package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +824 -0
  64. package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
  65. package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
  66. package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +127 -3
  67. package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +121 -2
  68. package/analyzer-template/packages/analyze/index.ts +2 -0
  69. package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +79 -59
  70. package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +113 -26
  71. package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
  72. package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +1 -0
  73. package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
  74. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.ts +19 -0
  75. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.ts +19 -0
  76. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +11 -0
  77. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.ts +8 -0
  78. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.ts +49 -1
  79. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.ts +2 -1
  80. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +522 -272
  81. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +34 -1
  82. package/analyzer-template/packages/analyze/src/lib/files/analyze/dependencyResolver.ts +6 -0
  83. package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -0
  84. package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
  85. package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -10
  86. package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +31 -15
  87. package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
  88. package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
  89. package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
  90. package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
  91. package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +14 -12
  92. package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1315 -0
  93. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +313 -0
  94. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
  95. package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +625 -52
  96. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
  97. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
  98. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +550 -137
  99. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +264 -0
  100. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +78 -83
  101. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +4 -8
  102. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +917 -130
  103. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
  104. package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
  105. package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
  106. package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
  107. package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
  108. package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
  109. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
  110. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
  111. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
  112. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
  113. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
  114. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
  115. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
  116. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
  117. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
  118. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
  119. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
  120. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
  121. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts +15 -0
  122. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts.map +1 -0
  123. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js +31 -0
  124. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js.map +1 -0
  125. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
  126. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
  127. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
  128. package/analyzer-template/packages/aws/package.json +3 -3
  129. package/analyzer-template/packages/aws/s3/index.ts +1 -0
  130. package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
  131. package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
  132. package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
  133. package/analyzer-template/packages/aws/src/lib/s3/checkS3ObjectExists.ts +47 -0
  134. package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
  135. package/analyzer-template/packages/database/package.json +1 -1
  136. package/analyzer-template/packages/database/src/lib/kysely/db.ts +12 -5
  137. package/analyzer-template/packages/database/src/lib/kysely/tableRelations.ts +2 -2
  138. package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
  139. package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +36 -9
  140. package/analyzer-template/packages/database/src/lib/loadAnalyses.ts +58 -1
  141. package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +13 -0
  142. package/analyzer-template/packages/database/src/lib/loadBranch.ts +16 -1
  143. package/analyzer-template/packages/database/src/lib/loadCommit.ts +11 -0
  144. package/analyzer-template/packages/database/src/lib/loadCommits.ts +28 -0
  145. package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -3
  146. package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
  147. package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +7 -3
  148. package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +7 -14
  149. package/analyzer-template/packages/generate/index.ts +3 -0
  150. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +17 -1
  151. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +193 -0
  152. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
  153. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +9 -4
  154. package/analyzer-template/packages/generate/src/lib/deepMerge.ts +26 -1
  155. package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
  156. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -2
  157. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
  158. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +10 -3
  159. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
  160. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tableRelations.d.ts +2 -2
  161. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +1 -11
  162. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
  163. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts +1 -0
  164. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts.map +1 -1
  165. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js +3 -0
  166. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
  167. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +30 -7
  168. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
  169. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
  170. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  171. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
  172. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
  173. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +2 -6
  174. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
  175. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts +2 -0
  176. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts.map +1 -1
  177. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js +45 -2
  178. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js.map +1 -1
  179. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
  180. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +8 -0
  181. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
  182. package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js +11 -1
  183. package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js.map +1 -1
  184. package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.d.ts.map +1 -1
  185. package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js +7 -0
  186. package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js.map +1 -1
  187. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts +3 -1
  188. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts.map +1 -1
  189. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +22 -1
  190. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js.map +1 -1
  191. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts +3 -1
  192. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
  193. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +23 -4
  194. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
  195. package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.d.ts.map +1 -1
  196. package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js +9 -0
  197. package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js.map +1 -1
  198. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
  199. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
  200. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  201. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts +2 -2
  202. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
  203. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +5 -4
  204. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
  205. package/analyzer-template/packages/github/dist/generate/index.d.ts +3 -0
  206. package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
  207. package/analyzer-template/packages/github/dist/generate/index.js +3 -0
  208. package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
  209. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
  210. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
  211. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  212. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
  213. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
  214. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
  215. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
  216. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
  217. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
  218. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
  219. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
  220. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
  221. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
  222. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  223. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.d.ts.map +1 -1
  224. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js +27 -1
  225. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js.map +1 -1
  226. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
  227. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
  228. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
  229. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
  230. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
  231. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
  232. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
  233. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
  234. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
  235. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
  236. package/analyzer-template/packages/github/dist/types/index.d.ts +2 -2
  237. package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
  238. package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
  239. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +87 -13
  240. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
  241. package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts +2 -0
  242. package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts.map +1 -1
  243. package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
  244. package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
  245. package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +3 -0
  246. package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
  247. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +11 -6
  248. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
  249. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +199 -3
  250. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  251. package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
  252. package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
  253. package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts +2 -0
  254. package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts.map +1 -1
  255. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
  256. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
  257. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  258. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
  259. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
  260. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
  261. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
  262. package/analyzer-template/packages/github/package.json +1 -1
  263. package/analyzer-template/packages/github/src/lib/loadOrCreateCommit.ts +14 -0
  264. package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
  265. package/analyzer-template/packages/process/index.ts +2 -0
  266. package/analyzer-template/packages/process/package.json +12 -0
  267. package/analyzer-template/packages/process/tsconfig.json +8 -0
  268. package/analyzer-template/packages/types/index.ts +5 -0
  269. package/analyzer-template/packages/types/src/types/Analysis.ts +104 -13
  270. package/analyzer-template/packages/types/src/types/Commit.ts +2 -0
  271. package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
  272. package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +1 -0
  273. package/analyzer-template/packages/types/src/types/Scenario.ts +11 -10
  274. package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +228 -3
  275. package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
  276. package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
  277. package/analyzer-template/packages/ui-components/src/components/ScenarioDetailInteractiveView.tsx +23 -7
  278. package/analyzer-template/packages/utils/dist/types/index.d.ts +2 -2
  279. package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
  280. package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
  281. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +87 -13
  282. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
  283. package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts +2 -0
  284. package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts.map +1 -1
  285. package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
  286. package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
  287. package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +3 -0
  288. package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
  289. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +11 -6
  290. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
  291. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +199 -3
  292. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  293. package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
  294. package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
  295. package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
  296. package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts.map +1 -1
  297. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
  298. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
  299. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  300. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
  301. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
  302. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
  303. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
  304. package/analyzer-template/packages/utils/src/lib/lightweightEntityExtractor.ts +27 -0
  305. package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
  306. package/analyzer-template/playwright/capture.ts +57 -26
  307. package/analyzer-template/playwright/captureStatic.ts +1 -1
  308. package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
  309. package/analyzer-template/playwright/takeElementScreenshot.ts +26 -11
  310. package/analyzer-template/playwright/takeScreenshot.ts +9 -7
  311. package/analyzer-template/playwright/waitForServer.ts +21 -6
  312. package/analyzer-template/project/analyzeBaselineCommit.ts +9 -0
  313. package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
  314. package/analyzer-template/project/analyzeFileEntities.ts +4 -0
  315. package/analyzer-template/project/analyzeRegularCommit.ts +9 -0
  316. package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
  317. package/analyzer-template/project/constructMockCode.ts +1268 -167
  318. package/analyzer-template/project/controller/startController.ts +16 -1
  319. package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
  320. package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
  321. package/analyzer-template/project/loadReadyToBeCaptured.ts +65 -41
  322. package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
  323. package/analyzer-template/project/orchestrateCapture/AwsCaptureTaskRunner.ts +12 -4
  324. package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +3 -6
  325. package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +93 -42
  326. package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
  327. package/analyzer-template/project/orchestrateCapture.ts +81 -9
  328. package/analyzer-template/project/reconcileMockDataKeys.ts +245 -2
  329. package/analyzer-template/project/runAnalysis.ts +11 -0
  330. package/analyzer-template/project/runMultiScenarioServer.ts +11 -10
  331. package/analyzer-template/project/serverOnlyModules.ts +194 -21
  332. package/analyzer-template/project/start.ts +61 -15
  333. package/analyzer-template/project/startScenarioCapture.ts +79 -41
  334. package/analyzer-template/project/writeMockDataTsx.ts +405 -65
  335. package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
  336. package/analyzer-template/project/writeScenarioComponents.ts +862 -183
  337. package/analyzer-template/project/writeScenarioFiles.ts +26 -0
  338. package/analyzer-template/project/writeSimpleRoot.ts +31 -23
  339. package/analyzer-template/scripts/comboWorkerLoop.cjs +99 -50
  340. package/analyzer-template/scripts/defaultCmd.sh +9 -0
  341. package/analyzer-template/tsconfig.json +2 -1
  342. package/background/src/lib/local/createLocalAnalyzer.js +1 -29
  343. package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
  344. package/background/src/lib/local/execAsync.js +1 -1
  345. package/background/src/lib/local/execAsync.js.map +1 -1
  346. package/background/src/lib/virtualized/common/execAsync.js +1 -1
  347. package/background/src/lib/virtualized/common/execAsync.js.map +1 -1
  348. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +7 -1
  349. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
  350. package/background/src/lib/virtualized/project/analyzeBranchCommit.js +2 -1
  351. package/background/src/lib/virtualized/project/analyzeBranchCommit.js.map +1 -1
  352. package/background/src/lib/virtualized/project/analyzeFileEntities.js +2 -1
  353. package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
  354. package/background/src/lib/virtualized/project/analyzeRegularCommit.js +7 -1
  355. package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
  356. package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js +3 -3
  357. package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js.map +1 -1
  358. package/background/src/lib/virtualized/project/constructMockCode.js +1126 -126
  359. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  360. package/background/src/lib/virtualized/project/controller/startController.js +11 -1
  361. package/background/src/lib/virtualized/project/controller/startController.js.map +1 -1
  362. package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js +73 -1
  363. package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js.map +1 -1
  364. package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js +6 -3
  365. package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js.map +1 -1
  366. package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js +19 -8
  367. package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js.map +1 -1
  368. package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js +7 -7
  369. package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js.map +1 -1
  370. package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js +2 -2
  371. package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js.map +1 -1
  372. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +3 -2
  373. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
  374. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +73 -36
  375. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
  376. package/background/src/lib/virtualized/project/orchestrateCapture.js +65 -10
  377. package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
  378. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +204 -2
  379. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
  380. package/background/src/lib/virtualized/project/runAnalysis.js +9 -0
  381. package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
  382. package/background/src/lib/virtualized/project/runMultiScenarioServer.js +11 -9
  383. package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
  384. package/background/src/lib/virtualized/project/serverOnlyModules.js +163 -23
  385. package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
  386. package/background/src/lib/virtualized/project/start.js +53 -15
  387. package/background/src/lib/virtualized/project/start.js.map +1 -1
  388. package/background/src/lib/virtualized/project/startScenarioCapture.js +61 -31
  389. package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
  390. package/background/src/lib/virtualized/project/writeMockDataTsx.js +354 -54
  391. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  392. package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js +15 -0
  393. package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js.map +1 -0
  394. package/background/src/lib/virtualized/project/writeScenarioComponents.js +624 -127
  395. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  396. package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
  397. package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
  398. package/background/src/lib/virtualized/project/writeSimpleRoot.js +31 -21
  399. package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
  400. package/codeyam-cli/scripts/apply-setup.js +180 -0
  401. package/codeyam-cli/scripts/apply-setup.js.map +1 -1
  402. package/codeyam-cli/src/cli.js +9 -1
  403. package/codeyam-cli/src/cli.js.map +1 -1
  404. package/codeyam-cli/src/commands/analyze.js +1 -1
  405. package/codeyam-cli/src/commands/analyze.js.map +1 -1
  406. package/codeyam-cli/src/commands/baseline.js +174 -0
  407. package/codeyam-cli/src/commands/baseline.js.map +1 -0
  408. package/codeyam-cli/src/commands/debug.js +42 -18
  409. package/codeyam-cli/src/commands/debug.js.map +1 -1
  410. package/codeyam-cli/src/commands/default.js +0 -15
  411. package/codeyam-cli/src/commands/default.js.map +1 -1
  412. package/codeyam-cli/src/commands/memory.js +264 -0
  413. package/codeyam-cli/src/commands/memory.js.map +1 -0
  414. package/codeyam-cli/src/commands/recapture.js +226 -0
  415. package/codeyam-cli/src/commands/recapture.js.map +1 -0
  416. package/codeyam-cli/src/commands/report.js +72 -24
  417. package/codeyam-cli/src/commands/report.js.map +1 -1
  418. package/codeyam-cli/src/commands/start.js +8 -12
  419. package/codeyam-cli/src/commands/start.js.map +1 -1
  420. package/codeyam-cli/src/commands/status.js +23 -1
  421. package/codeyam-cli/src/commands/status.js.map +1 -1
  422. package/codeyam-cli/src/commands/test-startup.js +1 -1
  423. package/codeyam-cli/src/commands/test-startup.js.map +1 -1
  424. package/codeyam-cli/src/commands/wipe.js +108 -0
  425. package/codeyam-cli/src/commands/wipe.js.map +1 -0
  426. package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js +81 -0
  427. package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js.map +1 -0
  428. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +31 -27
  429. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
  430. package/codeyam-cli/src/utils/analysisRunner.js +29 -15
  431. package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
  432. package/codeyam-cli/src/utils/backgroundServer.js +18 -4
  433. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  434. package/codeyam-cli/src/utils/database.js +91 -5
  435. package/codeyam-cli/src/utils/database.js.map +1 -1
  436. package/codeyam-cli/src/utils/generateReport.js +253 -106
  437. package/codeyam-cli/src/utils/generateReport.js.map +1 -1
  438. package/codeyam-cli/src/utils/git.js +79 -0
  439. package/codeyam-cli/src/utils/git.js.map +1 -0
  440. package/codeyam-cli/src/utils/install-skills.js +76 -17
  441. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  442. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +38 -0
  443. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
  444. package/codeyam-cli/src/utils/queue/job.js +249 -16
  445. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  446. package/codeyam-cli/src/utils/queue/manager.js +25 -7
  447. package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
  448. package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
  449. package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js +82 -0
  450. package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
  451. package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +128 -0
  452. package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
  453. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
  454. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
  455. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
  456. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
  457. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
  458. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
  459. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
  460. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
  461. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +75 -0
  462. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
  463. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +285 -0
  464. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
  465. package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +83 -0
  466. package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -0
  467. package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js +127 -0
  468. package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js.map +1 -0
  469. package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js +50 -0
  470. package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js.map +1 -0
  471. package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +96 -0
  472. package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -0
  473. package/codeyam-cli/src/utils/ruleReflection/index.js +5 -0
  474. package/codeyam-cli/src/utils/ruleReflection/index.js.map +1 -0
  475. package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js +33 -0
  476. package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js.map +1 -0
  477. package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js +85 -0
  478. package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js.map +1 -0
  479. package/codeyam-cli/src/utils/ruleReflection/types.js +5 -0
  480. package/codeyam-cli/src/utils/ruleReflection/types.js.map +1 -0
  481. package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +293 -0
  482. package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
  483. package/codeyam-cli/src/utils/rules/index.js +6 -0
  484. package/codeyam-cli/src/utils/rules/index.js.map +1 -0
  485. package/codeyam-cli/src/utils/rules/parser.js +78 -0
  486. package/codeyam-cli/src/utils/rules/parser.js.map +1 -0
  487. package/codeyam-cli/src/utils/rules/pathMatcher.js +18 -0
  488. package/codeyam-cli/src/utils/rules/pathMatcher.js.map +1 -0
  489. package/codeyam-cli/src/utils/rules/ruleState.js +150 -0
  490. package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
  491. package/codeyam-cli/src/utils/rules/staleness.js +137 -0
  492. package/codeyam-cli/src/utils/rules/staleness.js.map +1 -0
  493. package/codeyam-cli/src/utils/serverState.js.map +1 -1
  494. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +7 -5
  495. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
  496. package/codeyam-cli/src/utils/versionInfo.js +25 -19
  497. package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
  498. package/codeyam-cli/src/utils/wipe.js +128 -0
  499. package/codeyam-cli/src/utils/wipe.js.map +1 -0
  500. package/codeyam-cli/src/webserver/app/lib/database.js +104 -3
  501. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  502. package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
  503. package/codeyam-cli/src/webserver/backgroundServer.js +5 -10
  504. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  505. package/codeyam-cli/src/webserver/bootstrap.js +49 -0
  506. package/codeyam-cli/src/webserver/bootstrap.js.map +1 -0
  507. package/codeyam-cli/src/webserver/build/client/assets/CopyButton-CA3JxPb7.js +1 -0
  508. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-B86KKU7e.js +11 -0
  509. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-efWKDYMr.js → EntityTypeBadge-B5ctlSYt.js} +1 -1
  510. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-BqY8gDAW.js +41 -0
  511. package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-ClaLpuOo.js +34 -0
  512. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-BDhPilK7.js +25 -0
  513. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-VeqEBv9v.js +3 -0
  514. package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-Bs7Nn1Jr.js +6 -0
  515. package/codeyam-cli/src/webserver/build/client/assets/LogViewer-Bm3PmcCz.js +3 -0
  516. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-C6PKeMYR.js +11 -0
  517. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-Gq3Ocjo6.js +1 -0
  518. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-BNLaXBHR.js +10 -0
  519. package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-COPstp9J.js → TruncatedFilePath-CiwXDxLh.js} +1 -1
  520. package/codeyam-cli/src/webserver/build/client/assets/_index-B3TDXxnk.js +11 -0
  521. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-DD1r_QU0.js +27 -0
  522. package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-DfKzxuoe.js +11 -0
  523. package/codeyam-cli/src/webserver/build/client/assets/api.agent-transcripts-l0sNRNKZ.js +1 -0
  524. package/codeyam-cli/src/webserver/build/client/assets/api.health-l0sNRNKZ.js +1 -0
  525. package/codeyam-cli/src/webserver/build/client/assets/api.memory-profile-l0sNRNKZ.js +1 -0
  526. package/codeyam-cli/src/webserver/build/client/assets/api.restart-server-l0sNRNKZ.js +1 -0
  527. package/codeyam-cli/src/webserver/build/client/assets/api.save-fixture-l0sNRNKZ.js +1 -0
  528. package/codeyam-cli/src/webserver/build/client/assets/book-open-PttOB2SF.js +6 -0
  529. package/codeyam-cli/src/webserver/build/client/assets/chevron-down-TJp6ofnp.js +6 -0
  530. package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-JE9ZIoBl.js +51 -0
  531. package/codeyam-cli/src/webserver/build/client/assets/circle-check-CXhHQYrI.js +6 -0
  532. package/codeyam-cli/src/webserver/build/client/assets/copy-6y9ALfGT.js +11 -0
  533. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-Ca9fAY46.js +21 -0
  534. package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
  535. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
  536. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-C5lqplTC.js +1 -0
  537. package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-n38keI1k.js +23 -0
  538. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-CBoafmVs.js +6 -0
  539. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DGgZjdFg.js +6 -0
  540. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-38yPijoD.js +5 -0
  541. package/codeyam-cli/src/webserver/build/client/assets/entry.client-BSHEfydn.js +29 -0
  542. package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
  543. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-DCPhhSMo.js +1 -0
  544. package/codeyam-cli/src/webserver/build/client/assets/files-Dk8wkAS7.js +1 -0
  545. package/codeyam-cli/src/webserver/build/client/assets/git-DXnyr8uP.js +15 -0
  546. package/codeyam-cli/src/webserver/build/client/assets/globals-Bh6jH0cL.css +1 -0
  547. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-fmIEn3Bc.js +9 -0
  548. package/codeyam-cli/src/webserver/build/client/assets/index-CcsFv748.js +3 -0
  549. package/codeyam-cli/src/webserver/build/client/assets/index-ChN9-fAY.js +9 -0
  550. package/codeyam-cli/src/webserver/build/client/assets/labs-BUvfJMNR.js +1 -0
  551. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-CTqLEAGU.js +6 -0
  552. package/codeyam-cli/src/webserver/build/client/assets/manifest-d4e77269.js +1 -0
  553. package/codeyam-cli/src/webserver/build/client/assets/memory-DCHBwHou.js +76 -0
  554. package/codeyam-cli/src/webserver/build/client/assets/pause-D6vreykR.js +11 -0
  555. package/codeyam-cli/src/webserver/build/client/assets/preload-helper-ckwbz45p.js +1 -0
  556. package/codeyam-cli/src/webserver/build/client/assets/root-D6oziHts.js +62 -0
  557. package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
  558. package/codeyam-cli/src/webserver/build/client/assets/search-B8VUL8nl.js +6 -0
  559. package/codeyam-cli/src/webserver/build/client/assets/settings-B2X7lJgQ.js +1 -0
  560. package/codeyam-cli/src/webserver/build/client/assets/simulations-CPoAg7Zo.js +1 -0
  561. package/codeyam-cli/src/webserver/build/client/assets/terminal-BrCP7uQo.js +11 -0
  562. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-BZz2NjYa.js +6 -0
  563. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-DNwUduNu.js +1 -0
  564. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-3pmpUQB-.js → useLastLogLine-COky1GVF.js} +1 -1
  565. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-CpZgwliL.js +1 -0
  566. package/codeyam-cli/src/webserver/build/client/assets/{useToast-DEyawJ8r.js → useToast-Bv9JFvUO.js} +1 -1
  567. package/codeyam-cli/src/webserver/build/server/assets/index-C0KrUQp-.js +1 -0
  568. package/codeyam-cli/src/webserver/build/server/assets/server-build-C2h1v1XD.js +260 -0
  569. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  570. package/codeyam-cli/src/webserver/build-info.json +5 -5
  571. package/codeyam-cli/src/webserver/devServer.js +1 -3
  572. package/codeyam-cli/src/webserver/devServer.js.map +1 -1
  573. package/codeyam-cli/src/webserver/server.js +35 -25
  574. package/codeyam-cli/src/webserver/server.js.map +1 -1
  575. package/codeyam-cli/templates/codeyam-memory-hook.sh +199 -0
  576. package/codeyam-cli/templates/{codeyam-debug-skill.md → codeyam:debug.md} +48 -4
  577. package/codeyam-cli/templates/codeyam:diagnose.md +803 -0
  578. package/codeyam-cli/templates/codeyam:memory.md +404 -0
  579. package/codeyam-cli/templates/codeyam:new-rule.md +13 -0
  580. package/codeyam-cli/templates/{codeyam-setup-skill.md → codeyam:setup.md} +139 -4
  581. package/codeyam-cli/templates/{codeyam-sim-skill.md → codeyam:sim.md} +1 -1
  582. package/codeyam-cli/templates/{codeyam-test-skill.md → codeyam:test.md} +1 -1
  583. package/codeyam-cli/templates/{codeyam-verify-skill.md → codeyam:verify.md} +1 -1
  584. package/codeyam-cli/templates/rule-notification-hook.py +54 -0
  585. package/codeyam-cli/templates/rule-reflection-hook.py +428 -0
  586. package/codeyam-cli/templates/rules-instructions.md +123 -0
  587. package/package.json +22 -19
  588. package/packages/ai/index.js +8 -6
  589. package/packages/ai/index.js.map +1 -1
  590. package/packages/ai/src/lib/analyzeScope.js +167 -13
  591. package/packages/ai/src/lib/analyzeScope.js.map +1 -1
  592. package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
  593. package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
  594. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +154 -9
  595. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
  596. package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
  597. package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
  598. package/packages/ai/src/lib/astScopes/methodSemantics.js +138 -23
  599. package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
  600. package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js +10 -14
  601. package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js.map +1 -1
  602. package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js +8 -0
  603. package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
  604. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +23 -0
  605. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
  606. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +138 -1
  607. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
  608. package/packages/ai/src/lib/astScopes/processExpression.js +1157 -103
  609. package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
  610. package/packages/ai/src/lib/checkAllAttributes.js +24 -9
  611. package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
  612. package/packages/ai/src/lib/completionCall.js +178 -31
  613. package/packages/ai/src/lib/completionCall.js.map +1 -1
  614. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1816 -216
  615. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  616. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +7 -2
  617. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
  618. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +661 -0
  619. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -0
  620. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +180 -56
  621. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
  622. package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +13 -3
  623. package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -1
  624. package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +6 -4
  625. package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -1
  626. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +66 -2
  627. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
  628. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +139 -13
  629. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
  630. package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
  631. package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
  632. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +83 -1
  633. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
  634. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js +86 -0
  635. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js.map +1 -0
  636. package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +173 -0
  637. package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -0
  638. package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js +37 -20
  639. package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js.map +1 -1
  640. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +355 -77
  641. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
  642. package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
  643. package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
  644. package/packages/ai/src/lib/dataStructureChunking.js +111 -0
  645. package/packages/ai/src/lib/dataStructureChunking.js.map +1 -0
  646. package/packages/ai/src/lib/deepEqual.js +32 -0
  647. package/packages/ai/src/lib/deepEqual.js.map +1 -0
  648. package/packages/ai/src/lib/e2eDataTracking.js +241 -0
  649. package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
  650. package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
  651. package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
  652. package/packages/ai/src/lib/generateChangesEntityScenarioData.js +62 -5
  653. package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
  654. package/packages/ai/src/lib/generateChangesEntityScenarios.js +81 -90
  655. package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
  656. package/packages/ai/src/lib/generateEntityDataStructure.js +50 -1
  657. package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
  658. package/packages/ai/src/lib/generateEntityScenarioData.js +1109 -85
  659. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  660. package/packages/ai/src/lib/generateEntityScenarios.js +193 -83
  661. package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
  662. package/packages/ai/src/lib/generateExecutionFlows.js +400 -0
  663. package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -0
  664. package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js +380 -0
  665. package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js.map +1 -0
  666. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +1646 -0
  667. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -0
  668. package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
  669. package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
  670. package/packages/ai/src/lib/getConditionalUsagesFromCode.js +84 -14
  671. package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
  672. package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -1
  673. package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
  674. package/packages/ai/src/lib/isolateScopes.js +270 -7
  675. package/packages/ai/src/lib/isolateScopes.js.map +1 -1
  676. package/packages/ai/src/lib/mergeStatements.js +88 -46
  677. package/packages/ai/src/lib/mergeStatements.js.map +1 -1
  678. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +16 -4
  679. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
  680. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +1 -1
  681. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
  682. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -64
  683. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
  684. package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
  685. package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
  686. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +68 -6
  687. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
  688. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -34
  689. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
  690. package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
  691. package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
  692. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +16 -3
  693. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
  694. package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
  695. package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
  696. package/packages/ai/src/lib/resolvePathToControllable.js +677 -0
  697. package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
  698. package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
  699. package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
  700. package/packages/ai/src/lib/worker/SerializableDataStructure.js +29 -0
  701. package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
  702. package/packages/ai/src/lib/worker/analyzeScopeWorker.js +98 -1
  703. package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
  704. package/packages/analyze/index.js +1 -0
  705. package/packages/analyze/index.js.map +1 -1
  706. package/packages/analyze/src/lib/FileAnalyzer.js +75 -36
  707. package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
  708. package/packages/analyze/src/lib/ProjectAnalyzer.js +96 -26
  709. package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
  710. package/packages/analyze/src/lib/analysisContext.js +30 -5
  711. package/packages/analyze/src/lib/analysisContext.js.map +1 -1
  712. package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
  713. package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
  714. package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
  715. package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
  716. package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js +14 -0
  717. package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -1
  718. package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js +14 -0
  719. package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js.map +1 -1
  720. package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +6 -0
  721. package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
  722. package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js +6 -0
  723. package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js.map +1 -1
  724. package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js +39 -1
  725. package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js.map +1 -1
  726. package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js +2 -1
  727. package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js.map +1 -1
  728. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +268 -52
  729. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  730. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +24 -1
  731. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  732. package/packages/analyze/src/lib/files/analyze/dependencyResolver.js +5 -0
  733. package/packages/analyze/src/lib/files/analyze/dependencyResolver.js.map +1 -1
  734. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +2 -0
  735. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
  736. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +2 -1
  737. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
  738. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -10
  739. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
  740. package/packages/analyze/src/lib/files/analyzeChange.js +21 -11
  741. package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
  742. package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
  743. package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
  744. package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
  745. package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
  746. package/packages/analyze/src/lib/files/analyzeRemixRoute.js +3 -2
  747. package/packages/analyze/src/lib/files/analyzeRemixRoute.js.map +1 -1
  748. package/packages/analyze/src/lib/files/enums/steps.js +1 -1
  749. package/packages/analyze/src/lib/files/enums/steps.js.map +1 -1
  750. package/packages/analyze/src/lib/files/getImportedExports.js +11 -7
  751. package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
  752. package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +880 -0
  753. package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
  754. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +255 -0
  755. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -0
  756. package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
  757. package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
  758. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +483 -48
  759. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
  760. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
  761. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
  762. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
  763. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
  764. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +404 -85
  765. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  766. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +144 -0
  767. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
  768. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +56 -69
  769. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
  770. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +4 -8
  771. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
  772. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +768 -117
  773. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  774. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
  775. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
  776. package/packages/analyze/src/lib/files/setImportedExports.js +2 -1
  777. package/packages/analyze/src/lib/files/setImportedExports.js.map +1 -1
  778. package/packages/analyze/src/lib/index.js +1 -0
  779. package/packages/analyze/src/lib/index.js.map +1 -1
  780. package/packages/analyze/src/lib/utils/getFileByPath.js +12 -0
  781. package/packages/analyze/src/lib/utils/getFileByPath.js.map +1 -0
  782. package/packages/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
  783. package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
  784. package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
  785. package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
  786. package/packages/database/src/lib/kysely/db.js +10 -3
  787. package/packages/database/src/lib/kysely/db.js.map +1 -1
  788. package/packages/database/src/lib/kysely/tables/commitsTable.js +3 -0
  789. package/packages/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
  790. package/packages/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
  791. package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  792. package/packages/database/src/lib/loadAnalyses.js +45 -2
  793. package/packages/database/src/lib/loadAnalyses.js.map +1 -1
  794. package/packages/database/src/lib/loadAnalysis.js +8 -0
  795. package/packages/database/src/lib/loadAnalysis.js.map +1 -1
  796. package/packages/database/src/lib/loadBranch.js +11 -1
  797. package/packages/database/src/lib/loadBranch.js.map +1 -1
  798. package/packages/database/src/lib/loadCommit.js +7 -0
  799. package/packages/database/src/lib/loadCommit.js.map +1 -1
  800. package/packages/database/src/lib/loadCommits.js +22 -1
  801. package/packages/database/src/lib/loadCommits.js.map +1 -1
  802. package/packages/database/src/lib/loadEntities.js +23 -4
  803. package/packages/database/src/lib/loadEntities.js.map +1 -1
  804. package/packages/database/src/lib/loadEntityBranches.js +9 -0
  805. package/packages/database/src/lib/loadEntityBranches.js.map +1 -1
  806. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
  807. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  808. package/packages/database/src/lib/updateCommitMetadata.js +5 -4
  809. package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
  810. package/packages/generate/index.js +3 -0
  811. package/packages/generate/index.js.map +1 -1
  812. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
  813. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  814. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
  815. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
  816. package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
  817. package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
  818. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
  819. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  820. package/packages/generate/src/lib/deepMerge.js +27 -1
  821. package/packages/generate/src/lib/deepMerge.js.map +1 -1
  822. package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
  823. package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
  824. package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
  825. package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
  826. package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
  827. package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
  828. package/packages/process/index.js +3 -0
  829. package/packages/process/index.js.map +1 -0
  830. package/packages/process/src/GlobalProcessManager.js.map +1 -0
  831. package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
  832. package/packages/process/src/ProcessManager.js.map +1 -0
  833. package/packages/process/src/index.js.map +1 -0
  834. package/packages/process/src/managedExecAsync.js.map +1 -0
  835. package/packages/types/index.js.map +1 -1
  836. package/packages/utils/src/lib/lightweightEntityExtractor.js +25 -0
  837. package/packages/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  838. package/packages/utils/src/lib/safeFileName.js +29 -3
  839. package/packages/utils/src/lib/safeFileName.js.map +1 -1
  840. package/scripts/finalize-analyzer.cjs +6 -4
  841. package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
  842. package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -197
  843. package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -271
  844. package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -294
  845. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
  846. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -115
  847. package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
  848. package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
  849. package/analyzer-template/process/README.md +0 -507
  850. package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
  851. package/background/src/lib/process/ProcessManager.js.map +0 -1
  852. package/background/src/lib/process/index.js.map +0 -1
  853. package/background/src/lib/process/managedExecAsync.js.map +0 -1
  854. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
  855. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
  856. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-CVbSvOjo.js +0 -1
  857. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-DcwcHyl5.js +0 -1
  858. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-WgwC1GfJ.js +0 -26
  859. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-IEKom9O2.js +0 -3
  860. package/codeyam-cli/src/webserver/build/client/assets/LogViewer-BYnfxbUG.js +0 -3
  861. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-_lBPJCzG.js +0 -1
  862. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-lHVhvsu_.js +0 -1
  863. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-d_TBk4GQ.js +0 -5
  864. package/codeyam-cli/src/webserver/build/client/assets/_index-kGT7VUqj.js +0 -1
  865. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-DDGmhu7P.js +0 -7
  866. package/codeyam-cli/src/webserver/build/client/assets/chevron-down-n_HPRfM_.js +0 -1
  867. package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-CbVoyx1U.js +0 -26
  868. package/codeyam-cli/src/webserver/build/client/assets/circle-check-D1VOYveA.js +0 -1
  869. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-YR8jjAlu.js +0 -1
  870. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-B8vP3V_s.js +0 -1
  871. package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-CN6aLCT1.js +0 -16
  872. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DA5Jeu2P.js +0 -1
  873. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-BTeitalf.js +0 -5
  874. package/codeyam-cli/src/webserver/build/client/assets/entry.client-du6UEYD-.js +0 -13
  875. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-BpjkhMoi.js +0 -1
  876. package/codeyam-cli/src/webserver/build/client/assets/files-BQGvk4lJ.js +0 -1
  877. package/codeyam-cli/src/webserver/build/client/assets/git-DVdYRT-I.js +0 -12
  878. package/codeyam-cli/src/webserver/build/client/assets/globals-CO-U8Bpo.css +0 -1
  879. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +0 -5
  880. package/codeyam-cli/src/webserver/build/client/assets/index-DCG-vks0.js +0 -1
  881. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-GazdNeLl.js +0 -1
  882. package/codeyam-cli/src/webserver/build/client/assets/manifest-0b694d28.js +0 -1
  883. package/codeyam-cli/src/webserver/build/client/assets/root-D3tQP7hx.js +0 -16
  884. package/codeyam-cli/src/webserver/build/client/assets/search-CIY6XmtE.js +0 -1
  885. package/codeyam-cli/src/webserver/build/client/assets/server-build-CMKNK2uU.css +0 -1
  886. package/codeyam-cli/src/webserver/build/client/assets/settings-CoMDgElu.js +0 -1
  887. package/codeyam-cli/src/webserver/build/client/assets/simulations-agkniXp2.js +0 -1
  888. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-B2VUcygF.js +0 -1
  889. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-EvdK-zXP.js +0 -1
  890. package/codeyam-cli/src/webserver/build/server/assets/index-DGVHQEXD.js +0 -1
  891. package/codeyam-cli/src/webserver/build/server/assets/server-build-CghkTkIL.js +0 -166
  892. package/codeyam-cli/templates/debug-command.md +0 -303
  893. package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
  894. package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
  895. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -136
  896. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
  897. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -220
  898. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
  899. package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -241
  900. package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
  901. package/packages/ai/src/lib/isFrontend.js +0 -5
  902. package/packages/ai/src/lib/isFrontend.js.map +0 -1
  903. package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
  904. package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
  905. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -72
  906. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
  907. /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
  908. /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
  909. /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
  910. /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
  911. /package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-CMKNK2uU.css → styles-CMKNK2uU.css} +0 -0
  912. /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
  913. /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
  914. /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,646 @@ 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 convertTypeAnnotationsToValues from './dataStructure/helpers/convertTypeAnnotationsToValues';
20
+ import fixNullIdsBySchema from './dataStructure/helpers/fixNullIdsBySchema';
21
+ import coerceObjectsToPrimitivesBySchema from './dataStructure/helpers/coerceObjectsToPrimitivesBySchema';
22
+ import { JsonTypeDefinition } from '~codeyam/types';
23
+ import { deepMerge } from '~codeyam/generate';
24
+ import {
25
+ chunkDataStructure,
26
+ getRequiredValuesForChunk,
27
+ } from './dataStructureChunking';
28
+
29
+ /**
30
+ * Check if any of the scenario's covered flows require error data.
31
+ * Returns true if any requiredValue has an error path with truthy comparison.
32
+ */
33
+ function scenarioRequiresErrorData(
34
+ scenario: Scenario,
35
+ executionFlows: ExecutionFlow[] | undefined,
36
+ ): boolean {
37
+ const coveredFlowIds = scenario.metadata?.coveredFlows || [];
38
+ for (const flowId of coveredFlowIds) {
39
+ const flow = executionFlows?.find((f) => f.id === flowId);
40
+ if (!flow?.requiredValues) continue;
41
+ for (const rv of flow.requiredValues) {
42
+ // Check if any requiredValue has an error path and requires it to be truthy
43
+ if (
44
+ rv.attributePath?.toLowerCase().includes('.error') &&
45
+ rv.comparison === 'truthy'
46
+ ) {
47
+ return true;
48
+ }
49
+ }
50
+ }
51
+ return false;
52
+ }
53
+
54
+ /**
55
+ * Deep merge scenario data with default scenario data.
56
+ * The scenario-specific data takes precedence, with default filling in missing fields.
57
+ *
58
+ * IMPORTANT: null values are PRESERVED (not removed) in the result.
59
+ * This is critical because writeMockDataTsx.ts does another deepMerge with default data,
60
+ * and it needs null values to prevent defaults from being filled back in.
61
+ * If we removed null here, the second merge would restore the defaults,
62
+ * making scenarios identical to the default scenario.
63
+ */
64
+ function deepMergeScenarioData(
65
+ defaultData: Record<string, any>,
66
+ scenarioData: Record<string, any>,
67
+ ): Record<string, any> {
68
+ // Guard against non-object inputs (LLM sometimes returns primitives)
69
+ if (
70
+ typeof scenarioData !== 'object' ||
71
+ scenarioData === null ||
72
+ Array.isArray(scenarioData)
73
+ ) {
74
+ // Return scenario value directly if it's not a mergeable object
75
+ return scenarioData;
76
+ }
77
+ if (
78
+ typeof defaultData !== 'object' ||
79
+ defaultData === null ||
80
+ Array.isArray(defaultData)
81
+ ) {
82
+ // Return scenario value if default isn't mergeable
83
+ return scenarioData;
84
+ }
85
+
86
+ const result: Record<string, any> = {};
87
+
88
+ // Start with all keys from default
89
+ for (const key of Object.keys(defaultData)) {
90
+ if (key in scenarioData) {
91
+ const scenarioValue = scenarioData[key];
92
+ const defaultValue = defaultData[key];
93
+
94
+ // null means explicitly override with null (falsy value)
95
+ // IMPORTANT: We preserve null instead of removing the key
96
+ // This ensures writeMockDataTsx's deepMerge won't fill in defaults
97
+ if (scenarioValue === null) {
98
+ result[key] = null;
99
+ continue;
100
+ }
101
+
102
+ // Deep merge objects (but not arrays)
103
+ if (
104
+ typeof scenarioValue === 'object' &&
105
+ !Array.isArray(scenarioValue) &&
106
+ typeof defaultValue === 'object' &&
107
+ !Array.isArray(defaultValue) &&
108
+ defaultValue !== null
109
+ ) {
110
+ result[key] = deepMergeScenarioData(defaultValue, scenarioValue);
111
+ } else {
112
+ // Use scenario value (overrides default)
113
+ result[key] = scenarioValue;
114
+ }
115
+ } else {
116
+ // Key not in scenario, use default
117
+ result[key] = defaultData[key];
118
+ }
119
+ }
120
+
121
+ // Add any keys that are only in scenario data (including null values)
122
+ for (const key of Object.keys(scenarioData)) {
123
+ if (!(key in defaultData)) {
124
+ result[key] = scenarioData[key];
125
+ }
126
+ }
127
+
128
+ return result;
129
+ }
14
130
 
15
131
  const DEFAULT_SCENARIO_NAME = 'Default Scenario';
16
132
 
133
+ /**
134
+ * Find the path to a key within a nested dataForMocks structure.
135
+ * Returns the path as an array of keys, or null if not found.
136
+ *
137
+ * @example
138
+ * // dataForMocks = { trpc: { fastener: { "useMutation()": { isLoading: "boolean" } } } }
139
+ * // findKeyPath("fastener", dataForMocks) returns ["trpc"]
140
+ */
141
+ function findKeyPath(
142
+ targetKey: string,
143
+ obj: JsonTypeDefinition,
144
+ currentPath: string[] = [],
145
+ ): string[] | null {
146
+ if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
147
+ return null;
148
+ }
149
+
150
+ for (const key of Object.keys(obj)) {
151
+ if (key === targetKey) {
152
+ return currentPath;
153
+ }
154
+
155
+ // Recursively search in nested objects
156
+ const nested = obj[key];
157
+ if (
158
+ typeof nested === 'object' &&
159
+ nested !== null &&
160
+ !Array.isArray(nested)
161
+ ) {
162
+ const result = findKeyPath(targetKey, nested as JsonTypeDefinition, [
163
+ ...currentPath,
164
+ key,
165
+ ]);
166
+ if (result !== null) {
167
+ return result;
168
+ }
169
+ }
170
+ }
171
+
172
+ return null;
173
+ }
174
+
175
+ /**
176
+ * Relocate misplaced nested keys in mockData to their correct position
177
+ * based on the dataForMocks structure.
178
+ *
179
+ * When the LLM returns mockData with keys at the wrong nesting level
180
+ * (e.g., { trpc: { quote: {...} }, fastener: {...} } when fastener should
181
+ * be inside trpc), this function moves them to the correct position.
182
+ *
183
+ * This function works recursively to handle nested misplacements, not just
184
+ * root-level ones. For example, if getQuote is at trpc.getQuote instead of
185
+ * trpc.quote.getQuote, it will be relocated.
186
+ *
187
+ * @example
188
+ * // dataForMocks: { trpc: { quote: {...}, fastener: {...} } }
189
+ * // mockData: { trpc: { quote: {...} }, fastener: {...} }
190
+ * // After: mockData: { trpc: { quote: {...}, fastener: {...} } }
191
+ *
192
+ * @example (nested case)
193
+ * // dataForMocks: { trpc: { quote: { getQuote: {...} } } }
194
+ * // mockData: { trpc: { quote: {...}, getQuote: {...} } }
195
+ * // After: mockData: { trpc: { quote: { getQuote: {...} } } }
196
+ */
197
+ function relocateMisplacedNestedKeys(
198
+ mockData: Record<string, unknown>,
199
+ dataForMocks: JsonTypeDefinition,
200
+ currentPathForLogging: string[] = [],
201
+ ): void {
202
+ if (typeof dataForMocks !== 'object' || dataForMocks === null) {
203
+ return;
204
+ }
205
+
206
+ const keysInSchema = Object.keys(dataForMocks);
207
+ const keysToRelocate: { key: string; path: string[] }[] = [];
208
+
209
+ // Find keys in mockData that are NOT at this level in dataForMocks
210
+ // but DO exist somewhere nested in dataForMocks
211
+ for (const key of Object.keys(mockData)) {
212
+ if (!keysInSchema.includes(key)) {
213
+ // This key is at this level in mockData but not at this level in dataForMocks
214
+ // Check if it exists somewhere nested in dataForMocks
215
+ const path = findKeyPath(key, dataForMocks);
216
+ if (path !== null && path.length > 0) {
217
+ keysToRelocate.push({ key, path });
218
+ }
219
+ }
220
+ }
221
+
222
+ // Relocate each misplaced key to its correct nested position
223
+ for (const { key, path } of keysToRelocate) {
224
+ const value = mockData[key];
225
+
226
+ // Navigate to the correct parent in mockData, creating nested objects if needed
227
+ let current: Record<string, unknown> = mockData;
228
+ for (const pathKey of path) {
229
+ if (current[pathKey] === undefined) {
230
+ current[pathKey] = {};
231
+ }
232
+ current = current[pathKey] as Record<string, unknown>;
233
+ }
234
+
235
+ // Deep merge the value into the correct location
236
+ // Use deep merge to preserve existing data at that location
237
+ if (current[key] !== undefined && typeof current[key] === 'object') {
238
+ current[key] = deepMerge(
239
+ current[key] as Record<string, unknown>,
240
+ value as Record<string, unknown>,
241
+ );
242
+ } else {
243
+ current[key] = value;
244
+ }
245
+
246
+ // Remove the key from its current (wrong) level
247
+ delete mockData[key];
248
+
249
+ const fullPath = [...currentPathForLogging, ...path].join('.');
250
+ awsLog(
251
+ `CodeYam: Relocated misplaced key "${key}" from [${currentPathForLogging.join('.')}] to [${fullPath}]`,
252
+ );
253
+ }
254
+
255
+ // Recursively process nested objects to handle deeply nested misplacements
256
+ for (const key of Object.keys(mockData)) {
257
+ const mockValue = mockData[key];
258
+ const schemaValue = dataForMocks[key];
259
+
260
+ // Only recurse if both mockData and schema have nested objects at this key
261
+ if (
262
+ typeof mockValue === 'object' &&
263
+ mockValue !== null &&
264
+ !Array.isArray(mockValue) &&
265
+ typeof schemaValue === 'object' &&
266
+ schemaValue !== null &&
267
+ !Array.isArray(schemaValue)
268
+ ) {
269
+ relocateMisplacedNestedKeys(
270
+ mockValue as Record<string, unknown>,
271
+ schemaValue as JsonTypeDefinition,
272
+ [...currentPathForLogging, key],
273
+ );
274
+ }
275
+ }
276
+ }
277
+
278
+ /**
279
+ * Generate default mock data for a schema type.
280
+ * Returns reasonable default values based on the schema type string.
281
+ */
282
+ function generateDefaultForSchemaType(schemaType: unknown): unknown {
283
+ if (typeof schemaType === 'string') {
284
+ // Handle common type strings
285
+ if (schemaType === 'function') return () => {};
286
+ if (schemaType === 'promise') return Promise.resolve();
287
+ if (schemaType === 'boolean') return false;
288
+ if (schemaType === 'string') return '';
289
+ if (schemaType === 'number') return 0;
290
+ if (schemaType.includes('number | undefined')) return undefined;
291
+ if (schemaType.includes('string | undefined')) return undefined;
292
+ if (schemaType.includes('boolean | undefined')) return undefined;
293
+ if (schemaType.includes('| undefined')) return undefined;
294
+ if (schemaType.includes('| null')) return null;
295
+ return schemaType; // Return the type as a string placeholder
296
+ }
297
+ if (
298
+ typeof schemaType === 'object' &&
299
+ schemaType !== null &&
300
+ !Array.isArray(schemaType)
301
+ ) {
302
+ // Recursively generate defaults for nested objects
303
+ const result: Record<string, unknown> = {};
304
+ for (const [key, value] of Object.entries(schemaType)) {
305
+ result[key] = generateDefaultForSchemaType(value);
306
+ }
307
+ return result;
308
+ }
309
+ return undefined;
310
+ }
311
+
312
+ /**
313
+ * Detect if a string should be converted to an array.
314
+ * Returns the array if the field appears to be an array field, or null if it should remain a string.
315
+ *
316
+ * This handles two cases:
317
+ * 1. Comma-separated values: "color,size" -> ["color", "size"]
318
+ * 2. Single values for array-named fields: "Finish" -> ["Finish"]
319
+ */
320
+ function parseCommaSeparatedStringAsArray(
321
+ value: string,
322
+ key: string,
323
+ ): string[] | null {
324
+ // Heuristic: if the key name suggests it's an array field, convert it
325
+ // Common patterns: *_attributes, *_ids, *_items, *_tags, *_values, plural names
326
+ // Check this FIRST because array-named fields should be converted regardless
327
+ // of whether they contain commas (single values become single-element arrays).
328
+ const arrayFieldPatterns = [
329
+ /_attributes$/i,
330
+ /_ids$/i,
331
+ /_items$/i,
332
+ /_tags$/i,
333
+ /_values$/i,
334
+ /_types$/i,
335
+ /_names$/i,
336
+ /_keys$/i,
337
+ /^attributes$/i,
338
+ /^items$/i,
339
+ /^tags$/i,
340
+ /^values$/i,
341
+ ];
342
+
343
+ const looksLikeArrayField = arrayFieldPatterns.some((pattern) =>
344
+ pattern.test(key),
345
+ );
346
+
347
+ if (looksLikeArrayField) {
348
+ // Skip newlines check - multiline values shouldn't be split
349
+ if (value.includes('\n')) {
350
+ return null;
351
+ }
352
+ // Split by comma and trim whitespace
353
+ const parts = value.split(',').map((s) => s.trim());
354
+ // Filter out empty strings - this handles both "Finish" -> ["Finish"]
355
+ // and "" -> []
356
+ return parts.filter((s) => s.length > 0);
357
+ }
358
+
359
+ // For non-array-named fields, only convert if there are commas
360
+ if (!value.includes(',')) {
361
+ return null;
362
+ }
363
+
364
+ // For non-array-named fields, apply stricter sentence detection
365
+ // Skip if it looks like a sentence (comma followed by space and lowercase)
366
+ if (/,\s+[a-z]/.test(value)) {
367
+ return null;
368
+ }
369
+ // Skip if it contains newlines (likely formatted text)
370
+ if (value.includes('\n')) {
371
+ return null;
372
+ }
373
+
374
+ return null;
375
+ }
376
+
377
+ /**
378
+ * Convert comma-separated string values to arrays when they look like array data.
379
+ * This handles cases where the LLM generates strings like "color,size" instead
380
+ * of arrays like ["color", "size"] due to schema type misdetection.
381
+ */
382
+ function convertCommaSeparatedStringsToArrays(
383
+ mockData: Record<string, unknown>,
384
+ ): void {
385
+ for (const [key, value] of Object.entries(mockData)) {
386
+ if (typeof value === 'string') {
387
+ const asArray = parseCommaSeparatedStringAsArray(value, key);
388
+ if (asArray !== null) {
389
+ mockData[key] = asArray;
390
+ awsLog(
391
+ `CodeYam: Converted comma-separated string to array for key "${key}": "${value}" -> [${asArray.map((s) => `"${s}"`).join(', ')}]`,
392
+ );
393
+ }
394
+ } else if (
395
+ value !== null &&
396
+ typeof value === 'object' &&
397
+ !Array.isArray(value)
398
+ ) {
399
+ // Recursively process nested objects
400
+ convertCommaSeparatedStringsToArrays(value as Record<string, unknown>);
401
+ } else if (Array.isArray(value)) {
402
+ // Recursively process arrays (each element could be an object)
403
+ for (const item of value) {
404
+ if (item !== null && typeof item === 'object' && !Array.isArray(item)) {
405
+ convertCommaSeparatedStringsToArrays(item as Record<string, unknown>);
406
+ }
407
+ }
408
+ }
409
+ }
410
+ }
411
+
412
+ /**
413
+ * Ensure all keys from dataForMocks have corresponding data in mockData.
414
+ * For missing keys, generate default values based on the schema.
415
+ * Recursively checks nested objects to fill in any missing nested fields.
416
+ */
417
+ function fillMissingMockDataKeysWithDefaults(
418
+ mockData: Record<string, unknown>,
419
+ dataForMocks: JsonTypeDefinition,
420
+ pathPrefix: string = '',
421
+ ): void {
422
+ if (typeof dataForMocks !== 'object' || dataForMocks === null) {
423
+ return;
424
+ }
425
+
426
+ const missingKeys: string[] = [];
427
+
428
+ for (const key of Object.keys(dataForMocks)) {
429
+ const fullPath = pathPrefix ? `${pathPrefix}.${key}` : key;
430
+
431
+ if (mockData[key] === undefined) {
432
+ missingKeys.push(fullPath);
433
+ // Generate default data based on schema
434
+ const schemaForKey = dataForMocks[key];
435
+ mockData[key] = generateDefaultForSchemaType(schemaForKey);
436
+ } else {
437
+ // Key exists, but if both are objects, recursively check for missing nested keys
438
+ const schemaValue = dataForMocks[key];
439
+ const mockValue = mockData[key];
440
+ if (
441
+ typeof schemaValue === 'object' &&
442
+ schemaValue !== null &&
443
+ !Array.isArray(schemaValue) &&
444
+ typeof mockValue === 'object' &&
445
+ mockValue !== null &&
446
+ !Array.isArray(mockValue)
447
+ ) {
448
+ fillMissingMockDataKeysWithDefaults(
449
+ mockValue as Record<string, unknown>,
450
+ schemaValue as JsonTypeDefinition,
451
+ fullPath,
452
+ );
453
+ }
454
+ }
455
+ }
456
+
457
+ if (missingKeys.length > 0) {
458
+ awsLog(
459
+ `CodeYam: Generated default mock data for ${missingKeys.length} missing key(s): ${missingKeys.slice(0, 10).join(', ')}${missingKeys.length > 10 ? '...' : ''}`,
460
+ );
461
+ }
462
+ }
463
+
464
+ /**
465
+ * Enforce execution flow requiredValues by setting falsy paths to null.
466
+ *
467
+ * The LLM doesn't reliably generate null for `comparison: 'falsy'` requirements.
468
+ * For example, a flow like "diffView: falsy" should hide a modal, but the LLM
469
+ * might generate a truthy object, causing the modal to show in all screenshots.
470
+ *
471
+ * This function:
472
+ * 1. Gets requiredValues from covered flows
473
+ * 2. For 'falsy' comparisons: sets the value to null
474
+ * 3. For 'truthy' comparisons with falsy values: generates a default truthy value
475
+ */
476
+ function enforceRequiredValues(
477
+ mockData: Record<string, unknown>,
478
+ coveredFlowIds: string[],
479
+ executionFlows: ExecutionFlow[],
480
+ ): void {
481
+ if (!coveredFlowIds.length || !executionFlows.length) {
482
+ return;
483
+ }
484
+
485
+ // Get all requiredValues from covered flows
486
+ const coveredFlows = executionFlows.filter((flow) =>
487
+ coveredFlowIds.includes(flow.id),
488
+ );
489
+
490
+ for (const flow of coveredFlows) {
491
+ if (!flow.requiredValues) continue;
492
+
493
+ for (const rv of flow.requiredValues) {
494
+ if (!rv.attributePath) continue;
495
+
496
+ // Find the value in mockData - the path could be nested
497
+ // e.g., attributePath: "diffView" could be at mockData['useDiffModal()'].diffView
498
+ const result = findAndSetValueInMockData(
499
+ mockData,
500
+ rv.attributePath,
501
+ rv.comparison,
502
+ rv.valueType,
503
+ );
504
+
505
+ if (result.found) {
506
+ awsLog(
507
+ `CodeYam: Enforced ${rv.comparison} for ${rv.attributePath} (set to ${result.newValue === null ? 'null' : typeof result.newValue})`,
508
+ );
509
+ }
510
+ }
511
+ }
512
+ }
513
+
514
+ /**
515
+ * Find a value in mockData by attributePath and enforce the comparison.
516
+ * The attributePath could be a simple key or a nested path.
517
+ *
518
+ * Returns { found: boolean, newValue: unknown }
519
+ */
520
+ function findAndSetValueInMockData(
521
+ mockData: Record<string, unknown>,
522
+ attributePath: string,
523
+ comparison: string,
524
+ valueType?: string,
525
+ ): { found: boolean; newValue?: unknown } {
526
+ // Try to find the path at various nesting levels
527
+ // The attributePath might be "diffView" but the actual location is
528
+ // mockData['useDiffModal()'].diffView
529
+
530
+ // Strategy 1: Direct path (e.g., mockData[attributePath])
531
+ if (attributePath in mockData) {
532
+ const currentValue = mockData[attributePath];
533
+ const { shouldChange, newValue } = getEnforcedValue(
534
+ currentValue,
535
+ comparison,
536
+ valueType,
537
+ );
538
+ if (shouldChange) {
539
+ mockData[attributePath] = newValue;
540
+ return { found: true, newValue };
541
+ }
542
+ return { found: true, newValue: currentValue };
543
+ }
544
+
545
+ // Strategy 2: Search in nested objects
546
+ for (const [key, value] of Object.entries(mockData)) {
547
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
548
+ const nestedObj = value as Record<string, unknown>;
549
+
550
+ // Check if attributePath exists in this nested object
551
+ if (attributePath in nestedObj) {
552
+ const currentValue = nestedObj[attributePath];
553
+ const { shouldChange, newValue } = getEnforcedValue(
554
+ currentValue,
555
+ comparison,
556
+ valueType,
557
+ );
558
+ if (shouldChange) {
559
+ nestedObj[attributePath] = newValue;
560
+ return { found: true, newValue };
561
+ }
562
+ return { found: true, newValue: currentValue };
563
+ }
564
+
565
+ // Also check dot-notation paths (e.g., "diffView.type")
566
+ if (attributePath.includes('.')) {
567
+ const parts = attributePath.split('.');
568
+ const firstPart = parts[0];
569
+ if (firstPart in nestedObj) {
570
+ // Recurse with the rest of the path
571
+ const result = findAndSetValueInMockData(
572
+ nestedObj,
573
+ attributePath,
574
+ comparison,
575
+ valueType,
576
+ );
577
+ if (result.found) return result;
578
+ }
579
+ }
580
+
581
+ // Recursively search deeper
582
+ const result = findAndSetValueInMockData(
583
+ nestedObj,
584
+ attributePath,
585
+ comparison,
586
+ valueType,
587
+ );
588
+ if (result.found) return result;
589
+ }
590
+ }
591
+
592
+ return { found: false };
593
+ }
594
+
595
+ /**
596
+ * Determine if a value should be changed to match a comparison requirement.
597
+ *
598
+ * For 'falsy' comparison: truthy values should become null
599
+ * For 'truthy' comparison: falsy values should become a default truthy value
600
+ */
601
+ function getEnforcedValue(
602
+ currentValue: unknown,
603
+ comparison: string,
604
+ valueType?: string,
605
+ ): { shouldChange: boolean; newValue: unknown } {
606
+ const isTruthy = Boolean(currentValue);
607
+
608
+ if (comparison === 'falsy') {
609
+ // Value should be falsy
610
+ if (isTruthy) {
611
+ return { shouldChange: true, newValue: null };
612
+ }
613
+ return { shouldChange: false, newValue: currentValue };
614
+ }
615
+
616
+ if (comparison === 'truthy') {
617
+ // Value should be truthy
618
+ if (!isTruthy) {
619
+ // Generate a default truthy value based on valueType
620
+ const defaultValue = generateDefaultTruthyValue(valueType);
621
+ return { shouldChange: true, newValue: defaultValue };
622
+ }
623
+ return { shouldChange: false, newValue: currentValue };
624
+ }
625
+
626
+ // For other comparisons (equals, exists, etc.), don't auto-enforce
627
+ return { shouldChange: false, newValue: currentValue };
628
+ }
629
+
630
+ /**
631
+ * Generate a default truthy value for a given type.
632
+ */
633
+ function generateDefaultTruthyValue(valueType?: string): unknown {
634
+ if (!valueType) return { _placeholder: true };
635
+
636
+ switch (valueType.toLowerCase()) {
637
+ case 'string':
638
+ return 'default-value';
639
+ case 'number':
640
+ return 1;
641
+ case 'boolean':
642
+ return true;
643
+ case 'array':
644
+ return [{ _placeholder: true }];
645
+ case 'object':
646
+ default:
647
+ return { _placeholder: true };
648
+ }
649
+ }
650
+
17
651
  type ScenarioDataWithoutDescription = Omit<ScenarioData, 'scenarioDescription'>;
18
652
 
19
653
  interface GenerateEntityScenarioDataArgs {
20
654
  entity: Pick<Entity, 'name' | 'filePath' | 'metadata'>;
21
655
  structure: ScenariosDataStructure;
22
656
  scenarios: Scenario[];
657
+ executionFlows?: ExecutionFlow[];
23
658
  incompleteResponse?: string;
24
659
  analysis: Analysis;
25
660
  model?: AI.Model;
@@ -33,10 +668,96 @@ type GenerateDataForScenarioArgs = Omit<
33
668
  defaultScenarioData?: ScenarioData;
34
669
  };
35
670
 
671
+ interface FillMissingMockDataKeysArgs {
672
+ structure: ScenariosDataStructure;
673
+ scenario: Scenario;
674
+ executionFlows: ExecutionFlow[] | undefined;
675
+ fullScenarioData: ScenarioData;
676
+ model: AI.Model | undefined;
677
+ }
678
+
679
+ /**
680
+ * For Default Scenario only: detect missing mockData keys and make a follow-up
681
+ * LLM call to fill them in. This handles cases where the LLM completes normally
682
+ * but misses some keys (often small/simple ones when the schema is large).
683
+ */
684
+ async function fillMissingMockDataKeys({
685
+ structure,
686
+ scenario,
687
+ executionFlows,
688
+ fullScenarioData,
689
+ model,
690
+ }: FillMissingMockDataKeysArgs): Promise<void> {
691
+ if (
692
+ !structure.dataForMocks ||
693
+ typeof structure.dataForMocks !== 'object' ||
694
+ Array.isArray(structure.dataForMocks)
695
+ ) {
696
+ return;
697
+ }
698
+
699
+ const expectedKeys = Object.keys(structure.dataForMocks);
700
+ const generatedKeys = Object.keys(fullScenarioData.data.mockData || {});
701
+ const missingKeys = expectedKeys.filter((k) => !generatedKeys.includes(k));
702
+
703
+ if (missingKeys.length === 0) {
704
+ return;
705
+ }
706
+
707
+ awsLog(
708
+ `Default Scenario missing ${missingKeys.length} keys, making follow-up call`,
709
+ { missingKeys },
710
+ );
711
+
712
+ // Build subset schema with only missing keys
713
+ const missingSchema: Record<string, any> = {};
714
+ for (const key of missingKeys) {
715
+ missingSchema[key] = (structure.dataForMocks as Record<string, any>)[key];
716
+ }
717
+
718
+ const followUpPrompt = generateMissingKeysPrompt({
719
+ scenario,
720
+ executionFlows,
721
+ generatedMockData: fullScenarioData.data.mockData || {},
722
+ missingSchema,
723
+ });
724
+
725
+ const followUpResponse = await completionCall({
726
+ type: 'generateMissingMockData',
727
+ systemMessage: generateMissingKeysSystemMessage(),
728
+ prompt: followUpPrompt,
729
+ model,
730
+ });
731
+
732
+ if (!followUpResponse.completion) {
733
+ return;
734
+ }
735
+
736
+ const followUpJson = validateJson(followUpResponse.completion);
737
+ const followUpParsed = parseJsonSafe(followUpJson);
738
+
739
+ if (
740
+ !followUpParsed ||
741
+ typeof followUpParsed !== 'object' ||
742
+ !('mockData' in followUpParsed)
743
+ ) {
744
+ return;
745
+ }
746
+
747
+ const followUpMockData = (followUpParsed as any).mockData;
748
+ if (followUpMockData && typeof followUpMockData === 'object') {
749
+ fullScenarioData.data.mockData = {
750
+ ...fullScenarioData.data.mockData,
751
+ ...followUpMockData,
752
+ };
753
+ }
754
+ }
755
+
36
756
  export async function generateDataForScenario({
37
757
  entity,
38
758
  structure,
39
759
  scenario,
760
+ executionFlows,
40
761
  defaultScenarioData,
41
762
  incompleteResponse,
42
763
  analysis,
@@ -44,11 +765,99 @@ export async function generateDataForScenario({
44
765
  }: GenerateDataForScenarioArgs) {
45
766
  awsLogDebugLevel(1, `Generating data for ${entity.name}: ${scenario.name}`);
46
767
 
768
+ // Check if we should chunk the data structure for focused processing
769
+ let chunkedMockData: Record<string, unknown> | undefined;
770
+ const coveredFlowIds = scenario.metadata?.coveredFlows || [];
771
+
772
+ if (
773
+ structure.dataForMocks &&
774
+ !incompleteResponse // Don't do chunked calls on continuation
775
+ ) {
776
+ const chunks = chunkDataStructure(structure.dataForMocks);
777
+
778
+ // If we have multiple chunks, process each one with a focused call
779
+ if (chunks.length > 1) {
780
+ awsLog(
781
+ `Data structure has ${Object.keys(structure.dataForMocks).length} keys, splitting into ${chunks.length} chunks for focused processing`,
782
+ );
783
+
784
+ chunkedMockData = {};
785
+
786
+ for (let i = 0; i < chunks.length; i++) {
787
+ const chunk = chunks[i];
788
+ const chunkKeys = Object.keys(chunk || {});
789
+
790
+ // Get relevant requiredValues for this chunk
791
+ const relevantRequiredValues = getRequiredValuesForChunk(
792
+ chunk,
793
+ executionFlows || [],
794
+ coveredFlowIds,
795
+ );
796
+
797
+ awsLog(
798
+ `Processing chunk ${i + 1}/${chunks.length}: ${chunkKeys.join(', ')}`,
799
+ );
800
+
801
+ const chunkPrompt = generateChunkPrompt({
802
+ scenario,
803
+ chunk,
804
+ chunkIndex: i,
805
+ totalChunks: chunks.length,
806
+ relevantRequiredValues,
807
+ });
808
+
809
+ const chunkResponse = await completionCall({
810
+ type: 'generateChunkMockData',
811
+ systemMessage: generateChunkSystemMessage(scenario.name),
812
+ prompt: chunkPrompt,
813
+ model,
814
+ });
815
+
816
+ // Save chunk call to LLM log for replay support
817
+ await saveLlmCall({
818
+ object_type: 'analysis',
819
+ object_id: analysis.id,
820
+ propsJson: {
821
+ entity: { name: entity.name, filePath: entity.filePath },
822
+ scenario: { name: scenario.name },
823
+ chunkIndex: i,
824
+ totalChunks: chunks.length,
825
+ },
826
+ ...chunkResponse.stats,
827
+ });
828
+
829
+ if (chunkResponse.completion) {
830
+ const validJson = validateJson(chunkResponse.completion);
831
+ const parsed = parseJsonSafe(validJson);
832
+ if (parsed && typeof parsed === 'object' && 'mockData' in parsed) {
833
+ const chunkMockData = (parsed as any).mockData;
834
+ if (chunkMockData && typeof chunkMockData === 'object') {
835
+ Object.assign(chunkedMockData, chunkMockData);
836
+ awsLog(
837
+ `Chunk ${i + 1} generated data for: ${Object.keys(chunkMockData).join(', ')}`,
838
+ );
839
+ }
840
+ }
841
+ }
842
+ }
843
+
844
+ awsLog(
845
+ `Chunked processing complete. Generated ${Object.keys(chunkedMockData).length} keys total`,
846
+ );
847
+ }
848
+ }
849
+
850
+ // When we have chunked mock data with actual content, tell the main prompt to skip mockData generation
851
+ // Important: Check for actual keys, not just truthy object, because {} would skip generation incorrectly
852
+ const hasChunkedData =
853
+ chunkedMockData && Object.keys(chunkedMockData).length > 0;
47
854
  const prompt = generateEntityScenarioDataGenerator(
48
855
  structure,
49
856
  scenario,
857
+ executionFlows,
50
858
  defaultScenarioData,
51
859
  incompleteResponse,
860
+ { mockDataAlreadyGenerated: hasChunkedData },
52
861
  );
53
862
 
54
863
  const isDefault = scenario.name === DEFAULT_SCENARIO_NAME;
@@ -91,7 +900,7 @@ export async function generateDataForScenario({
91
900
  ...response.stats,
92
901
  });
93
902
 
94
- const { completion, finishReason } = response;
903
+ let { completion, finishReason } = response;
95
904
 
96
905
  if (!completion) {
97
906
  console.log(
@@ -100,42 +909,80 @@ export async function generateDataForScenario({
100
909
  return null;
101
910
  }
102
911
 
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
- },
912
+ awsLogDebugLevel(
913
+ 1,
914
+ `LLMCall ${llmCall ? llmCall.id : 'N/A'}: ${entity.filePath} ${entity.metadata?.exportAlias ?? entity.name} finishReason: ${finishReason}`,
109
915
  );
110
916
 
917
+ // If response was truncated due to token limit, make a continuation call
918
+ if (finishReason === 'length') {
919
+ awsLogDebugLevel(1, 'Response truncated, making continuation call');
920
+
921
+ const continuationResponse = await completionCall({
922
+ type: 'generateEntityScenarioData',
923
+ systemMessage: generateIncompleteSystemMessage(scenario.name, isDefault),
924
+ prompt: completion, // Pass the incomplete response as the prompt
925
+ model,
926
+ });
927
+
928
+ if (continuationResponse.completion) {
929
+ completion = completion + continuationResponse.completion;
930
+ finishReason = continuationResponse.finishReason;
931
+ }
932
+ }
933
+
111
934
  const validJson = validateJson(completion);
112
935
 
113
936
  const parsed = parseJsonSafe(validJson);
114
937
  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
- });
938
+ awsLog(`Failed to parse scenario data for ${entity.name}/${scenario.name}`);
123
939
  return null;
124
940
  }
125
941
 
126
- const { scenarioData: scenarioDataWithoutDescription } = parsed as {
942
+ let { scenarioData: scenarioDataWithoutDescription } = parsed as {
127
943
  scenarioData: ScenarioDataWithoutDescription;
128
944
  };
129
945
 
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
- });
946
+ // FIX: LLM sometimes puts mock data keys directly under scenarioData instead of
947
+ // under scenarioData.data.mockData. Detect and fix this structural issue.
948
+ if (structure.dataForMocks) {
949
+ const scenarioDataAsAny = scenarioDataWithoutDescription as any;
950
+ const reservedKeys = new Set([
951
+ 'scenarioName',
952
+ 'data',
953
+ 'scenarioDescription',
954
+ ]);
955
+ const misplacedKeys: string[] = [];
956
+
957
+ // Find keys that are directly under scenarioData but should be in mockData
958
+ for (const key of Object.keys(scenarioDataAsAny)) {
959
+ if (reservedKeys.has(key)) continue;
960
+ // If this key exists in the dataForMocks schema, it's misplaced
961
+ if (key in structure.dataForMocks) {
962
+ misplacedKeys.push(key);
963
+ }
964
+ }
965
+
966
+ if (misplacedKeys.length > 0) {
967
+ // Ensure data.mockData exists
968
+ if (!scenarioDataAsAny.data) {
969
+ scenarioDataAsAny.data = {};
970
+ }
971
+ if (!scenarioDataAsAny.data.mockData) {
972
+ scenarioDataAsAny.data.mockData = {};
973
+ }
974
+
975
+ // Move misplaced keys to mockData
976
+ for (const key of misplacedKeys) {
977
+ scenarioDataAsAny.data.mockData[key] = scenarioDataAsAny[key];
978
+ delete scenarioDataAsAny[key];
979
+ }
980
+
981
+ // Update the reference
982
+ scenarioDataWithoutDescription =
983
+ scenarioDataAsAny as ScenarioDataWithoutDescription;
984
+ }
985
+ }
139
986
 
140
987
  const fullScenarioData: ScenarioData = {
141
988
  ...scenarioDataWithoutDescription,
@@ -144,8 +991,9 @@ export async function generateDataForScenario({
144
991
 
145
992
  if (structure.dataForMocks && !fullScenarioData.data.argumentsData) {
146
993
  fullScenarioData.data.argumentsData = [];
147
- if (structure.arguments && !fullScenarioData.data.argumentsData) {
148
- fullScenarioData.data.argumentsData = [];
994
+ // Populate argumentsData from structure.arguments using top-level data values
995
+ // Bug fix: removed redundant !argumentsData check that was always false after setting to []
996
+ if (structure.arguments) {
149
997
  for (let i = 0; i < structure.arguments.length; ++i) {
150
998
  if (!fullScenarioData.data.argumentsData[i]) {
151
999
  fullScenarioData.data.argumentsData[i] = {};
@@ -158,14 +1006,158 @@ export async function generateDataForScenario({
158
1006
  }
159
1007
  }
160
1008
 
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];
1009
+ // Merge flat-level mock data into mockData.
1010
+ // Sometimes the LLM returns some data inside data.mockData but other data at the flat
1011
+ // data level (e.g., data.useRouter() instead of data.mockData.useRouter()).
1012
+ // This code ensures all dataForMocks keys end up in mockData.
1013
+ if (structure.dataForMocks) {
1014
+ fullScenarioData.data.mockData ||= {};
1015
+ const dataAsAny = fullScenarioData.data as any;
1016
+ for (const propKey of Object.keys(structure.dataForMocks)) {
1017
+ // Only copy if it exists at flat level and not already in mockData
1018
+ if (
1019
+ dataAsAny[propKey] !== undefined &&
1020
+ !fullScenarioData.data.mockData[propKey]
1021
+ ) {
1022
+ fullScenarioData.data.mockData[propKey] = dataAsAny[propKey];
1023
+ }
1024
+ }
1025
+ }
1026
+
1027
+ // Merge chunked mock data from focused calls (takes priority over main call's data)
1028
+ // This ensures keys processed with focused attention are correctly generated.
1029
+ if (chunkedMockData && fullScenarioData.data.mockData) {
1030
+ for (const [key, value] of Object.entries(chunkedMockData)) {
1031
+ // Chunked data takes priority - overwrite main call's potentially wrong data
1032
+ fullScenarioData.data.mockData[key] = value;
1033
+ }
1034
+ awsLog(
1035
+ `Merged chunked mock data for keys: ${Object.keys(chunkedMockData).join(', ')}`,
1036
+ );
1037
+ }
1038
+
1039
+ // Relocate misplaced nested keys to their correct position.
1040
+ // The LLM sometimes places nested keys at root level instead of inside their
1041
+ // parent object (e.g., 'fastener' at root instead of inside 'trpc').
1042
+ // This ensures the mockData structure matches the dataForMocks schema.
1043
+ if (structure.dataForMocks && fullScenarioData.data.mockData) {
1044
+ relocateMisplacedNestedKeys(
1045
+ fullScenarioData.data.mockData,
1046
+ structure.dataForMocks,
1047
+ );
1048
+ }
1049
+
1050
+ // Convert null values to undefined based on schema type constraints.
1051
+ // LLM uses null for "no value" (JSON doesn't support undefined), but TypeScript
1052
+ // types like "string | undefined" don't accept null. This converts null→undefined
1053
+ // for fields typed as "T | undefined" (but preserves null for "T | null").
1054
+ if (structure.dataForMocks && fullScenarioData.data.mockData) {
1055
+ convertNullToUndefinedBySchema(
1056
+ fullScenarioData.data.mockData,
1057
+ structure.dataForMocks,
1058
+ );
1059
+ }
1060
+
1061
+ // Coerce objects/arrays to primitives when the schema expects a primitive type.
1062
+ // The LLM sometimes generates an object where the schema expects "string",
1063
+ // e.g., { body: { "env": "production" } } instead of { body: "some string" }.
1064
+ // This causes runtime errors like "TypeError: body.match is not a function".
1065
+ // Must run BEFORE convertCommaSeparatedStringsToArrays, which intentionally
1066
+ // overrides schema types for array-like field names.
1067
+ if (structure.dataForMocks && fullScenarioData.data.mockData) {
1068
+ coerceObjectsToPrimitivesBySchema(
1069
+ fullScenarioData.data.mockData,
1070
+ structure.dataForMocks,
1071
+ );
1072
+ }
1073
+
1074
+ // Convert comma-separated strings to arrays when appropriate.
1075
+ // The LLM sometimes generates strings like "color,size" instead of arrays
1076
+ // like ["color", "size"] when the schema type is incorrectly inferred as
1077
+ // 'string' instead of 'string[]'. This causes runtime errors when code
1078
+ // calls array methods like .map() on the value.
1079
+ if (fullScenarioData.data.mockData) {
1080
+ convertCommaSeparatedStringsToArrays(fullScenarioData.data.mockData);
1081
+ }
1082
+
1083
+ // Convert type annotation strings that appear as values to actual values.
1084
+ // The LLM sometimes echoes the schema type annotation as the value.
1085
+ // For example, if the schema says { filePath: "string | undefined" },
1086
+ // the LLM might return { filePath: "string | undefined" } instead of
1087
+ // generating an actual value. This converts those type strings to
1088
+ // appropriate default values (e.g., "string | undefined" → undefined).
1089
+ if (fullScenarioData.data.mockData) {
1090
+ convertTypeAnnotationsToValues(fullScenarioData.data.mockData);
1091
+ }
1092
+
1093
+ // Fix null values for ID fields when the schema indicates they should be non-null.
1094
+ // The LLM sometimes generates `null` for ID fields (e.g., `"id": null`) when
1095
+ // the schema type is `"number"`. This causes runtime issues when code checks
1096
+ // `if (!data?.id)` expecting a truthy value.
1097
+ if (structure.dataForMocks && fullScenarioData.data.mockData) {
1098
+ fixNullIdsBySchema(fullScenarioData.data.mockData, structure.dataForMocks);
1099
+ }
1100
+
1101
+ // Enforce execution flow requiredValues by setting falsy paths to null.
1102
+ // The LLM doesn't reliably generate null for falsy requirements (e.g., diffView: falsy
1103
+ // to hide a modal). This post-processing ensures that scenarios match their
1104
+ // covered flows' requiredValues.
1105
+ if (fullScenarioData.data.mockData && executionFlows) {
1106
+ enforceRequiredValues(
1107
+ fullScenarioData.data.mockData,
1108
+ scenario.metadata?.coveredFlows || [],
1109
+ executionFlows,
1110
+ );
1111
+ }
1112
+
1113
+ if (structure.arguments && fullScenarioData.data.argumentsData) {
1114
+ for (let i = 0; i < fullScenarioData.data.argumentsData.length; i++) {
1115
+ if (structure.arguments[i]) {
1116
+ convertNullToUndefinedBySchema(
1117
+ fullScenarioData.data.argumentsData[i],
1118
+ structure.arguments[i],
1119
+ );
1120
+ }
166
1121
  }
167
1122
  }
168
1123
 
1124
+ // For Default Scenario only: check for missing keys and make follow-up call if needed.
1125
+ // This tries to get better-quality data via LLM before falling back to defaults.
1126
+ if (isDefault) {
1127
+ await fillMissingMockDataKeys({
1128
+ structure,
1129
+ scenario,
1130
+ executionFlows,
1131
+ fullScenarioData,
1132
+ model,
1133
+ });
1134
+ }
1135
+
1136
+ // Fill in missing mock data keys with default values (after trying LLM follow-up).
1137
+ // The LLM sometimes doesn't generate data for all keys in large schemas.
1138
+ // This ensures all dataForMocks keys have corresponding data to prevent
1139
+ // runtime errors like "Cannot read properties of undefined".
1140
+ // Only run for Default Scenario - non-default scenarios will get missing
1141
+ // data filled in from the merge with default scenario data.
1142
+ if (isDefault && structure.dataForMocks && fullScenarioData.data.mockData) {
1143
+ fillMissingMockDataKeysWithDefaults(
1144
+ fullScenarioData.data.mockData,
1145
+ structure.dataForMocks,
1146
+ );
1147
+ }
1148
+
1149
+ // Track the final scenario data for E2E debugging
1150
+ trackDataSnapshot(
1151
+ 'generateDataForScenario_result',
1152
+ {
1153
+ scenarioName: scenario.name,
1154
+ mockData: fullScenarioData.data.mockData,
1155
+ argumentsData: fullScenarioData.data.argumentsData,
1156
+ },
1157
+ entity.name,
1158
+ scenario.name,
1159
+ );
1160
+
169
1161
  return {
170
1162
  scenarioData: fullScenarioData,
171
1163
  llmCall: { name: scenario.name, id: llmCall.id },
@@ -176,6 +1168,7 @@ export default async function generateEntityScenarioData({
176
1168
  entity,
177
1169
  structure,
178
1170
  scenarios,
1171
+ executionFlows,
179
1172
  incompleteResponse,
180
1173
  analysis,
181
1174
  model,
@@ -196,6 +1189,7 @@ export default async function generateEntityScenarioData({
196
1189
  entity,
197
1190
  structure,
198
1191
  scenario: defaultScenario,
1192
+ executionFlows,
199
1193
  incompleteResponse,
200
1194
  analysis,
201
1195
  model,
@@ -218,6 +1212,7 @@ export default async function generateEntityScenarioData({
218
1212
  entity,
219
1213
  structure,
220
1214
  scenario,
1215
+ executionFlows,
221
1216
  defaultScenarioData,
222
1217
  incompleteResponse,
223
1218
  analysis,
@@ -238,37 +1233,131 @@ export default async function generateEntityScenarioData({
238
1233
  );
239
1234
  }
240
1235
 
241
- scenarioDatas.push(...validResults.map((result) => result.scenarioData));
242
- llmCalls.push(...validResults.map((result) => result.llmCall));
1236
+ // Merge non-default scenario data with default scenario data
1237
+ // The LLM generates partial data (only differences), we need to merge with default
1238
+ const mergedScenarioDatas = validResults.map((result) => {
1239
+ const scenarioData = result.scenarioData;
1240
+
1241
+ // Merge mockData with default mockData
1242
+ if (defaultScenarioData.data?.mockData && scenarioData.data?.mockData) {
1243
+ scenarioData.data.mockData = deepMergeScenarioData(
1244
+ defaultScenarioData.data.mockData,
1245
+ scenarioData.data.mockData,
1246
+ );
1247
+ } else if (
1248
+ defaultScenarioData.data?.mockData &&
1249
+ !scenarioData.data?.mockData
1250
+ ) {
1251
+ // Use default mockData if scenario has none
1252
+ scenarioData.data.mockData = { ...defaultScenarioData.data.mockData };
1253
+ }
1254
+
1255
+ // Merge argumentsData with default argumentsData
1256
+ if (
1257
+ defaultScenarioData.data?.argumentsData &&
1258
+ Array.isArray(defaultScenarioData.data.argumentsData) &&
1259
+ scenarioData.data?.argumentsData &&
1260
+ Array.isArray(scenarioData.data.argumentsData)
1261
+ ) {
1262
+ for (
1263
+ let i = 0;
1264
+ i < defaultScenarioData.data.argumentsData.length;
1265
+ i++
1266
+ ) {
1267
+ const scenarioArg = scenarioData.data.argumentsData[i];
1268
+ const defaultArg = defaultScenarioData.data.argumentsData[i];
1269
+
1270
+ // Only merge if both are objects (LLM sometimes returns primitives)
1271
+ if (
1272
+ scenarioArg &&
1273
+ typeof scenarioArg === 'object' &&
1274
+ !Array.isArray(scenarioArg) &&
1275
+ defaultArg &&
1276
+ typeof defaultArg === 'object' &&
1277
+ !Array.isArray(defaultArg)
1278
+ ) {
1279
+ scenarioData.data.argumentsData[i] = deepMergeScenarioData(
1280
+ defaultArg,
1281
+ scenarioArg,
1282
+ );
1283
+ } else if (scenarioArg !== undefined) {
1284
+ // Keep the scenario value as-is (even if primitive)
1285
+ scenarioData.data.argumentsData[i] = scenarioArg;
1286
+ } else if (defaultArg && typeof defaultArg === 'object') {
1287
+ // Use default if scenario is undefined and default is an object
1288
+ scenarioData.data.argumentsData[i] = { ...defaultArg };
1289
+ } else {
1290
+ scenarioData.data.argumentsData[i] = defaultArg;
1291
+ }
1292
+ }
1293
+ } else if (
1294
+ defaultScenarioData.data?.argumentsData &&
1295
+ !scenarioData.data?.argumentsData
1296
+ ) {
1297
+ // Use default argumentsData if scenario has none
1298
+ scenarioData.data.argumentsData =
1299
+ defaultScenarioData.data.argumentsData.map((arg) => ({ ...arg }));
1300
+ }
1301
+
1302
+ // Enforce requiredValues AFTER merge for non-default scenarios
1303
+ // This ensures that if a non-default scenario doesn't cover a certain flow,
1304
+ // it inherits the enforcement from the default scenario
1305
+ if (scenarioData.data?.mockData && executionFlows) {
1306
+ // Get the flows covered by this scenario
1307
+ const scenarioCoveredFlows =
1308
+ nonDefaultScenarios.find(
1309
+ (s) => s.name === result.scenarioData.scenarioDescription,
1310
+ )?.metadata?.coveredFlows || [];
1311
+
1312
+ // Get the paths that the scenario's flows affect
1313
+ const scenarioAffectedPaths = new Set<string>();
1314
+ for (const flowId of scenarioCoveredFlows) {
1315
+ const flow = executionFlows.find((f) => f.id === flowId);
1316
+ if (flow?.requiredValues) {
1317
+ for (const rv of flow.requiredValues) {
1318
+ if (rv.attributePath) {
1319
+ // Extract base path (e.g., "diffView" from "diffView.type")
1320
+ const basePath = rv.attributePath.split('.')[0];
1321
+ scenarioAffectedPaths.add(basePath);
1322
+ }
1323
+ }
1324
+ }
1325
+ }
1326
+
1327
+ // Get the default scenario's flows
1328
+ const defaultCoveredFlows =
1329
+ defaultScenario.metadata?.coveredFlows || [];
1330
+
1331
+ // For paths NOT affected by the scenario, apply default's enforcement
1332
+ const defaultFlowsForUnaffectedPaths = defaultCoveredFlows.filter(
1333
+ (flowId) => {
1334
+ const flow = executionFlows.find((f) => f.id === flowId);
1335
+ if (!flow?.requiredValues) return false;
243
1336
 
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,
1337
+ // Check if this flow affects a path that the scenario doesn't cover
1338
+ return flow.requiredValues.some((rv) => {
1339
+ if (!rv.attributePath) return false;
1340
+ const basePath = rv.attributePath.split('.')[0];
1341
+ return !scenarioAffectedPaths.has(basePath);
1342
+ });
1343
+ },
1344
+ );
1345
+
1346
+ // Apply enforcement from default scenario for unaffected paths
1347
+ if (defaultFlowsForUnaffectedPaths.length > 0) {
1348
+ enforceRequiredValues(
1349
+ scenarioData.data.mockData,
1350
+ defaultFlowsForUnaffectedPaths,
1351
+ executionFlows,
1352
+ );
1353
+ }
1354
+ }
1355
+
1356
+ return scenarioData;
254
1357
  });
255
1358
 
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
- );
1359
+ scenarioDatas.push(...mergedScenarioDatas);
1360
+ llmCalls.push(...validResults.map((result) => result.llmCall));
272
1361
 
273
1362
  return { scenarioDatas, llmCalls };
274
1363
  } catch (error) {
@@ -280,28 +1369,85 @@ export default async function generateEntityScenarioData({
280
1369
  export const generateSystemMessage = (
281
1370
  scenarioName: string,
282
1371
  defaultScenario: boolean,
1372
+ requiresErrorData: boolean = false,
283
1373
  ) => {
284
1374
  const scenarioType = defaultScenario
285
1375
  ? `## Default Scenario
286
1376
  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
1377
+ - Fill ALL fields with realistic values (except error attributes)
1378
+ - Do not skip any keys, even simple or small entries
1379
+ - Arrays should have 3-5 items to provide realistic test data variety
1380
+ - Don't skip nested attributes unless the execution flow requirements specify a parent attribute should be null or undefined
290
1381
  - This provides the baseline data for all other scenarios`
291
1382
  : `## Non-Default Scenario
292
1383
  Generate ONLY the differences from the default scenario.
293
1384
  - Include only fields that need to change
294
- - Set to \`null\` to remove data
1385
+ - For object/scalar fields: set to \`null\` to remove/unset the data
1386
+ - For array fields: use \`[]\` for empty arrays (not \`null\`) unless the schema type explicitly includes \`| null\`
295
1387
  - Omit unchanged fields—they merge from default`;
296
1388
 
1389
+ // Only include the "NO ERROR DATA" instruction when the scenario doesn't require error data
1390
+ const noErrorDataInstruction = requiresErrorData
1391
+ ? `## IMPORTANT: ERROR DATA REQUIRED
1392
+ This scenario tests error handling. You MUST include "error" fields with realistic error messages.
1393
+ - Set error fields to truthy values (e.g., "Error: Operation failed" or "Something went wrong")
1394
+ - The error data is REQUIRED to trigger the correct error UI state`
1395
+ : `## CRITICAL: NO ERROR DATA
1396
+ NEVER include "error" fields in responses. Skip them entirely.
1397
+ - If structure has \`{ data: {...}, error: {...} }\`, only fill \`data\`
1398
+ - Leave out any attribute named "error"—do not set to null, omit entirely`;
1399
+
297
1400
  return `You are a test data generator. Create mock data matching a data structure and scenario requirements.
298
1401
 
1402
+ ## Execution Flow Requirements
1403
+ Each scenario has \`coveredFlows\` which lists the execution flows (distinct outcomes/behaviors) this scenario should demonstrate.
1404
+ Each flow has \`requiredValues\` - the attribute values that MUST be set to produce that outcome.
1405
+
1406
+ **Your job**: Generate mock data that satisfies ALL the requiredValues from ALL coveredFlows.
1407
+
1408
+ For example, if a flow requires:
1409
+ \`\`\`json
1410
+ {
1411
+ "attributePath": "signature[0].isLoading",
1412
+ "value": "false",
1413
+ "comparison": "equals",
1414
+ "valueType": "boolean"
1415
+ }
1416
+ \`\`\`
1417
+ Then set \`isLoading: false\` in the mockData.
1418
+
1419
+ ### Array Length Requirements (length< and length>)
1420
+ For array size variation flows:
1421
+ - \`comparison: "length<"\` with \`value: "0"\` → generate EMPTY array \`[]\`
1422
+ - \`comparison: "length<"\` with \`value: "3"\` → generate 1-2 items (few items)
1423
+ - \`comparison: "length>"\` with \`value: "10"\` → generate 12+ items (many items)
1424
+
1425
+ ### String Length Requirements (normal vs long)
1426
+ For text length variation flows:
1427
+ - \`value: "normal"\` with \`valueType: "string"\` → generate normal length text (10-50 chars)
1428
+ - \`value: "long"\` with \`valueType: "string"\` → generate LONG text (200+ chars) to test overflow/truncation
1429
+
1430
+ ## CRITICAL: Blocking Flows to Avoid
1431
+ If the scenario includes \`blockingFlowsToAvoid\`, these are flows (like modals, overlays) that would BLOCK the expected UI.
1432
+ You MUST generate mock data that PREVENTS these flows from triggering:
1433
+
1434
+ - For \`comparison: "truthy"\` requirements → set the value to \`false\`, \`null\`, \`undefined\`, or \`0\`
1435
+ - For \`comparison: "exists"\` requirements → set the value to \`null\` or omit it entirely
1436
+ - For \`comparison: "equals"\` requirements → set a DIFFERENT value than what's required
1437
+
1438
+ For example, if a blocking flow has:
1439
+ \`\`\`json
1440
+ {
1441
+ "attributePath": "useFetcher().data.success",
1442
+ "value": "true",
1443
+ "comparison": "truthy"
1444
+ }
1445
+ \`\`\`
1446
+ Then you MUST set \`useFetcher().data\` to \`null\` or \`{ success: false }\` to prevent the modal from appearing.
1447
+
299
1448
  ${scenarioType}
300
1449
 
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
1450
+ ${noErrorDataInstruction}
305
1451
 
306
1452
  ## Special Markers
307
1453
 
@@ -317,30 +1463,20 @@ Use for relative dates. Code runs in Node (no browser APIs, no external librarie
317
1463
  \`\`\`
318
1464
  Use simple elements only (\`<div>\`, \`<span>\`). No custom components.
319
1465
 
320
- ## Mock Data Keys
321
- Preserve keys exactly as written in the structure. There are two formats:
1466
+ ### Arrays
1467
+ - Arrays should have many items (at least 4) unless specified otherwise
1468
+ - Each item must follow the exact structure provided
1469
+ - In general we want robust data, not minimal data unless specified otherwise
1470
+ - For empty arrays, use \`[]\` (not \`null\`) unless the schema type explicitly includes \`| null\` and the scenario requires the attribute be removed
322
1471
 
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.
1472
+ ## CRITICAL: Preserve Exact Structure
1473
+ Your response MUST mirror the EXACT nested structure provided in mockData Structure.
1474
+ - Do NOT reorganize, split, or create duplicate keys
1475
+ - The hierarchy of nested objects must match exactly what was provided unless overridden by scenario rules
1476
+ - Only change the leaf VALUES (replacing type descriptions like "string" with actual data like "hello")
1477
+ - Copy the key strings EXACTLY from the structure
1478
+ - Do NOT modify type parameters, arguments, or any part of the key
1479
+ - The keys preserve the exact function call as written in the original code
344
1480
 
345
1481
  ## Response Format
346
1482
  \`\`\`json
@@ -358,9 +1494,15 @@ This reads as "entityDiffFetcher receives from useFetcher". Each variable gets i
358
1494
  ## Rules
359
1495
  - Valid JSON only—no raw code outside markers
360
1496
  - No \`undefined\`—use \`null\` or omit
361
- - No data references (can't use \`posts[0]\` elsewhere—duplicate the value)
1497
+ - No data references (can't use \`posts[0]\` elsewhere duplicate the value)
362
1498
  - Scenario name must match exactly: "${scenarioName}"
363
1499
  - Empty mockData: \`{}\`, empty argumentsData: \`[]\`
1500
+
1501
+ ## IMPORTANT: Avoid Identifier Collisions
1502
+ When generating identifier values (SHA hashes, entity IDs, etc.):
1503
+ - Use DISTINCT values for different identifier fields
1504
+ - Avoid matching: if \`entity.sha\` is "abc123", arrays like \`jobs[].entityShas\` or \`currentlyExecuting.entityShas\` should NOT contain "abc123"
1505
+ - This prevents accidental blocking of UI conditionals that check if IDs are in/not-in arrays
364
1506
  `;
365
1507
  };
366
1508
 
@@ -376,3 +1518,163 @@ Here is the original system message as well:
376
1518
  ${generateSystemMessage(scenarioName, isDefault)}
377
1519
  \`\`\`
378
1520
  `;
1521
+
1522
+ /**
1523
+ * System message for follow-up calls to generate missing mockData keys.
1524
+ * Includes the same rules as the main system message but with a simpler response format.
1525
+ */
1526
+ export const generateMissingKeysSystemMessage =
1527
+ () => `You are completing mock data generation for the Default Scenario. The initial response was missing some keys.
1528
+
1529
+ Generate data ONLY for the missing keys provided in the prompt. Do not skip any of them.
1530
+
1531
+ - Scenario name must match exactly: "Default Scenario"
1532
+
1533
+ ## Special Markers
1534
+
1535
+ ### Dynamic Dates (\`~~codeyam-code~~\`)
1536
+ \`\`\`json
1537
+ { "createdAt": { "~~codeyam-code~~": "new Date(Date.now() - 24*60*60*1000)" } }
1538
+ \`\`\`
1539
+ Use for relative dates. Code runs in Node (no browser APIs, no external libraries).
1540
+
1541
+ ### JSX Children (\`~~codeyam-jsx~~\`)
1542
+ \`\`\`json
1543
+ { "children": { "~~codeyam-jsx~~": "<div>Hello</div>" } }
1544
+ \`\`\`
1545
+ Use simple elements only (\`<div>\`, \`<span>\`). No custom components.
1546
+
1547
+ ### Arrays
1548
+ - Arrays should have many items (at least 4) unless specified otherwise
1549
+ - Each item must follow the exact structure provided
1550
+ - For empty arrays, use \`[]\` (not \`null\`) unless the schema type explicitly includes \`| null\` and the scenario requires the attribute be removed
1551
+
1552
+ ## CRITICAL: Preserve Exact Structure
1553
+ Your response MUST mirror the EXACT nested structure provided for the missing keys.
1554
+ - Only change the leaf VALUES (replacing type descriptions like "string" with actual data)
1555
+ - Copy the key strings EXACTLY from the structure
1556
+ - Do NOT modify type parameters, arguments, or any part of the key
1557
+
1558
+ ## CRITICAL: NO ERROR DATA
1559
+ NEVER include "error" fields in responses. Skip them entirely.
1560
+ - If structure has \`{ data: {...}, error: {...} }\`, only fill \`data\`
1561
+ - Leave out any attribute named "error"—do not set to null, omit entirely
1562
+
1563
+ ## Response Format
1564
+ \`\`\`json
1565
+ {
1566
+ "mockData": {
1567
+ // fill in ONLY the missing keys
1568
+ }
1569
+ }
1570
+ \`\`\`
1571
+
1572
+ ## Rules
1573
+ - Valid JSON only—no raw code outside markers
1574
+ - No \`undefined\`—use \`null\` or omit
1575
+ - No data references (can't use \`posts[0]\` elsewhere — duplicate the value)
1576
+ `;
1577
+
1578
+ /**
1579
+ * System message for focused calls to generate critical mockData keys.
1580
+ * These are keys referenced by the scenario's execution flow requiredValues.
1581
+ */
1582
+ export const generateCriticalKeysSystemMessage = (
1583
+ scenarioName: string,
1584
+ ) => `You are generating mock data for CRITICAL keys that control scenario behavior.
1585
+
1586
+ These keys are referenced by the execution flow's requiredValues - they directly determine
1587
+ what the component renders. Pay EXTRA attention to matching the exact structure and values.
1588
+
1589
+ - Scenario name must match exactly: "${scenarioName}"
1590
+
1591
+ ## CRITICAL: Special Characters in Keys
1592
+ Keys like \`*\` are LITERAL string keys, NOT wildcards or patterns.
1593
+ - If the schema shows \`{ "*": "string" }\`, generate \`{ "*": "some value" }\`
1594
+ - Do NOT interpret \`*\` as "any key" - use it as an actual key name
1595
+
1596
+ ## CRITICAL: Preserve Exact Structure
1597
+ Your response MUST mirror the EXACT nested structure provided.
1598
+ - Copy key strings EXACTLY as shown (including special characters)
1599
+ - Only change leaf VALUES (replacing type descriptions with actual data)
1600
+ - Do NOT modify keys, type parameters, or add extra keys
1601
+
1602
+ ## Matching requiredValues
1603
+ When the prompt shows requiredValues like:
1604
+ - \`attributePath: "useParams().functionCallReturnValue.*"\`
1605
+ - \`value: "scenarios"\`
1606
+
1607
+ This means set the \`*\` key to include "scenarios". For URL paths split by \`/\`,
1608
+ generate a path like \`"scenarios/id/mode"\` where segments match requirements.
1609
+
1610
+ ## Response Format
1611
+ \`\`\`json
1612
+ {
1613
+ "scenarioData": {
1614
+ "scenarioName": "${scenarioName}",
1615
+ "data": {
1616
+ "mockData": {
1617
+ // generate data for ONLY the critical keys
1618
+ }
1619
+ }
1620
+ }
1621
+ }
1622
+ \`\`\`
1623
+
1624
+ ## Rules
1625
+ - Valid JSON only
1626
+ - No \`undefined\`—use \`null\` or omit
1627
+ - Match the exact schema structure provided
1628
+ `;
1629
+
1630
+ /**
1631
+ * System message for focused calls to generate mock data for a chunk of keys.
1632
+ * Used when data structures are large and need to be processed in smaller pieces.
1633
+ */
1634
+ export const generateChunkSystemMessage = (
1635
+ scenarioName: string,
1636
+ ) => `You are generating mock data for a SUBSET of keys from a larger data structure.
1637
+
1638
+ This chunk contains fewer keys so you can focus on generating HIGH QUALITY data for each one.
1639
+ Pay EXTRA attention to matching the exact structure and values for each key.
1640
+
1641
+ - Scenario name must match exactly: "${scenarioName}"
1642
+
1643
+ ## CRITICAL: Special Characters in Keys
1644
+ Keys like \`*\` are LITERAL string keys, NOT wildcards or patterns.
1645
+ - If the schema shows \`{ "*": "string" }\`, generate \`{ "*": "some value" }\`
1646
+ - Do NOT interpret \`*\` as "any key" - use it as an actual key name
1647
+
1648
+ ## CRITICAL: Preserve Exact Structure
1649
+ Your response MUST mirror the EXACT nested structure provided.
1650
+ - Copy key strings EXACTLY as shown (including special characters)
1651
+ - Only change leaf VALUES (replacing type descriptions with actual data)
1652
+ - Do NOT modify keys, type parameters, or add extra keys
1653
+
1654
+ ## Matching requiredValues
1655
+ If the prompt includes requiredValues, these are specific values that MUST be set:
1656
+ - For \`attributePath: "useParams().functionCallReturnValue.*"\` with \`value: "scenarios"\`
1657
+ → Set the \`*\` key to include "scenarios" (e.g., "scenarios/id/mode")
1658
+ - For URL paths, generate realistic paths that satisfy the requirements
1659
+
1660
+ ## CRITICAL: NO ERROR DATA
1661
+ NEVER include "error" fields in responses. Skip them entirely.
1662
+ - If structure has \`{ data: {...}, error: {...} }\`, only fill \`data\`
1663
+ - Leave out any attribute named "error"—do not set to null, omit entirely
1664
+
1665
+ ## Response Format
1666
+ \`\`\`json
1667
+ {
1668
+ "mockData": {
1669
+ // generate data for ONLY the keys in this chunk
1670
+ }
1671
+ }
1672
+ \`\`\`
1673
+
1674
+ ## Rules
1675
+ - Valid JSON only
1676
+ - No \`undefined\`—use \`null\` or omit
1677
+ - Generate data for ALL keys in the chunk (don't skip any)
1678
+ - Arrays should have many items (at least 4) unless specified otherwise
1679
+ - For empty arrays, use \`[]\` (not \`null\`) unless the schema type explicitly includes \`| null\` and the scenario requires the attribute be removed
1680
+ `;