@codeyam/codeyam-cli 0.1.0-staging.1669d45 → 0.1.0-staging.1a2737b

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 (654) hide show
  1. package/analyzer-template/.build-info.json +8 -8
  2. package/analyzer-template/log.txt +3 -3
  3. package/analyzer-template/package.json +19 -19
  4. package/analyzer-template/packages/ai/index.ts +16 -2
  5. package/analyzer-template/packages/ai/package.json +2 -2
  6. package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +110 -52
  7. package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
  8. package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +98 -9
  9. package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +139 -23
  10. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
  11. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +6 -126
  12. package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +656 -28
  13. package/analyzer-template/packages/ai/src/lib/astScopes/sharedPatterns.ts +28 -0
  14. package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +94 -7
  15. package/analyzer-template/packages/ai/src/lib/completionCall.ts +198 -34
  16. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +1331 -254
  17. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +5 -1
  18. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +205 -0
  19. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +10 -2
  20. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.ts +16 -3
  21. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +6 -4
  22. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +54 -3
  23. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +124 -17
  24. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
  25. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +140 -14
  26. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +179 -0
  27. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.ts +40 -30
  28. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +393 -97
  29. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
  30. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/stripNullableMarkers.ts +35 -0
  31. package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +183 -0
  32. package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
  33. package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
  34. package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +58 -3
  35. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +936 -7
  36. package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +35 -6
  37. package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +515 -6
  38. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +1 -1
  39. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +1540 -75
  40. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
  41. package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +51 -3
  42. package/analyzer-template/packages/ai/src/lib/mergeJsonTypeDefinitions.ts +5 -0
  43. package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +90 -96
  44. package/analyzer-template/packages/ai/src/lib/promptGenerators/collapseNullableObjects.ts +118 -0
  45. package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +10 -7
  46. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
  47. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
  48. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +44 -7
  49. package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
  50. package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +179 -45
  51. package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +26 -4
  52. package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +114 -2
  53. package/analyzer-template/packages/analyze/index.ts +2 -0
  54. package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +65 -59
  55. package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +113 -26
  56. package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
  57. package/analyzer-template/packages/analyze/src/lib/asts/nodes/getNodeType.ts +1 -0
  58. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.ts +19 -0
  59. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.ts +19 -0
  60. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +11 -0
  61. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.ts +8 -0
  62. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.ts +49 -1
  63. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.ts +2 -1
  64. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +99 -22
  65. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +19 -4
  66. package/analyzer-template/packages/analyze/src/lib/files/analyze/dependencyResolver.ts +6 -0
  67. package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
  68. package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -10
  69. package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
  70. package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +14 -12
  71. package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1315 -0
  72. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +193 -76
  73. package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +87 -25
  74. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +269 -22
  75. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +118 -10
  76. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +647 -73
  77. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
  78. package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
  79. package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
  80. package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
  81. package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
  82. package/analyzer-template/packages/aws/package.json +10 -10
  83. package/analyzer-template/packages/database/package.json +1 -1
  84. package/analyzer-template/packages/database/src/lib/analysisBranchToDb.ts +1 -1
  85. package/analyzer-template/packages/database/src/lib/analysisToDb.ts +1 -1
  86. package/analyzer-template/packages/database/src/lib/branchToDb.ts +1 -1
  87. package/analyzer-template/packages/database/src/lib/commitBranchToDb.ts +1 -1
  88. package/analyzer-template/packages/database/src/lib/commitToDb.ts +1 -1
  89. package/analyzer-template/packages/database/src/lib/fileToDb.ts +1 -1
  90. package/analyzer-template/packages/database/src/lib/kysely/db.ts +14 -1
  91. package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
  92. package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +1 -1
  93. package/analyzer-template/packages/database/src/lib/kysely/tables/labsRequestsTable.ts +52 -0
  94. package/analyzer-template/packages/database/src/lib/loadAnalyses.ts +58 -1
  95. package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +13 -0
  96. package/analyzer-template/packages/database/src/lib/loadBranch.ts +16 -1
  97. package/analyzer-template/packages/database/src/lib/loadCommit.ts +11 -0
  98. package/analyzer-template/packages/database/src/lib/loadCommits.ts +28 -0
  99. package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -3
  100. package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
  101. package/analyzer-template/packages/database/src/lib/projectToDb.ts +1 -1
  102. package/analyzer-template/packages/database/src/lib/saveFiles.ts +1 -1
  103. package/analyzer-template/packages/database/src/lib/scenarioToDb.ts +1 -1
  104. package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +7 -14
  105. package/analyzer-template/packages/database/src/lib/userScenarioToDb.ts +1 -1
  106. package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js +1 -1
  107. package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js.map +1 -1
  108. package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js +1 -1
  109. package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js.map +1 -1
  110. package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js +1 -1
  111. package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js.map +1 -1
  112. package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js +1 -1
  113. package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js.map +1 -1
  114. package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js +1 -1
  115. package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js.map +1 -1
  116. package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js +1 -1
  117. package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js.map +1 -1
  118. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -0
  119. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
  120. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +11 -1
  121. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
  122. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
  123. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts +1 -0
  124. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts.map +1 -1
  125. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js +3 -0
  126. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
  127. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +1 -1
  128. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts +23 -0
  129. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts.map +1 -0
  130. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
  131. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
  132. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts +2 -0
  133. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts.map +1 -1
  134. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js +45 -2
  135. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js.map +1 -1
  136. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
  137. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +8 -0
  138. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
  139. package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js +11 -1
  140. package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js.map +1 -1
  141. package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.d.ts.map +1 -1
  142. package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js +7 -0
  143. package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js.map +1 -1
  144. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts +3 -1
  145. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts.map +1 -1
  146. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +22 -1
  147. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js.map +1 -1
  148. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts +3 -1
  149. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
  150. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +23 -4
  151. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
  152. package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.d.ts.map +1 -1
  153. package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js +9 -0
  154. package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js.map +1 -1
  155. package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js +1 -1
  156. package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js.map +1 -1
  157. package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js +1 -1
  158. package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js.map +1 -1
  159. package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js +1 -1
  160. package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js.map +1 -1
  161. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts +2 -2
  162. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
  163. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +5 -4
  164. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
  165. package/analyzer-template/packages/github/dist/types/index.d.ts +1 -1
  166. package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
  167. package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
  168. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +25 -1
  169. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
  170. package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts +2 -0
  171. package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts.map +1 -1
  172. package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +7 -0
  173. package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
  174. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +56 -6
  175. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  176. package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
  177. package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
  178. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
  179. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
  180. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
  181. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
  182. package/analyzer-template/packages/github/package.json +1 -1
  183. package/analyzer-template/packages/types/index.ts +1 -0
  184. package/analyzer-template/packages/types/src/types/Analysis.ts +25 -0
  185. package/analyzer-template/packages/types/src/types/Commit.ts +2 -0
  186. package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +7 -0
  187. package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +70 -6
  188. package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
  189. package/analyzer-template/packages/utils/dist/types/index.d.ts +1 -1
  190. package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
  191. package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
  192. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +25 -1
  193. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
  194. package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts +2 -0
  195. package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts.map +1 -1
  196. package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +7 -0
  197. package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
  198. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +56 -6
  199. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  200. package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
  201. package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
  202. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts.map +1 -1
  203. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js +93 -2
  204. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js.map +1 -1
  205. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
  206. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
  207. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
  208. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
  209. package/analyzer-template/packages/utils/src/lib/fs/rsyncCopy.ts +108 -2
  210. package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
  211. package/analyzer-template/playwright/capture.ts +20 -8
  212. package/analyzer-template/playwright/captureStatic.ts +1 -1
  213. package/analyzer-template/project/analyzeBaselineCommit.ts +5 -0
  214. package/analyzer-template/project/analyzeRegularCommit.ts +5 -0
  215. package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
  216. package/analyzer-template/project/constructMockCode.ts +436 -44
  217. package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
  218. package/analyzer-template/project/loadReadyToBeCaptured.ts +65 -41
  219. package/analyzer-template/project/orchestrateCapture/AwsCaptureTaskRunner.ts +12 -4
  220. package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +18 -7
  221. package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
  222. package/analyzer-template/project/orchestrateCapture.ts +75 -7
  223. package/analyzer-template/project/reconcileMockDataKeys.ts +152 -9
  224. package/analyzer-template/project/runAnalysis.ts +4 -0
  225. package/analyzer-template/project/start.ts +35 -11
  226. package/analyzer-template/project/writeMockDataTsx.ts +295 -10
  227. package/analyzer-template/project/writeScenarioComponents.ts +237 -32
  228. package/analyzer-template/project/writeSimpleRoot.ts +21 -11
  229. package/analyzer-template/scripts/comboWorkerLoop.cjs +98 -50
  230. package/background/src/lib/local/createLocalAnalyzer.js +1 -1
  231. package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
  232. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +5 -0
  233. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
  234. package/background/src/lib/virtualized/project/analyzeRegularCommit.js +5 -0
  235. package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
  236. package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js +3 -3
  237. package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js.map +1 -1
  238. package/background/src/lib/virtualized/project/constructMockCode.js +359 -14
  239. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  240. package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js +73 -1
  241. package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js.map +1 -1
  242. package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js +19 -8
  243. package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js.map +1 -1
  244. package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js +2 -2
  245. package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js.map +1 -1
  246. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +7 -5
  247. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
  248. package/background/src/lib/virtualized/project/orchestrateCapture.js +62 -7
  249. package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
  250. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +126 -9
  251. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
  252. package/background/src/lib/virtualized/project/runAnalysis.js +3 -0
  253. package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
  254. package/background/src/lib/virtualized/project/start.js +32 -11
  255. package/background/src/lib/virtualized/project/start.js.map +1 -1
  256. package/background/src/lib/virtualized/project/writeMockDataTsx.js +251 -6
  257. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  258. package/background/src/lib/virtualized/project/writeScenarioComponents.js +173 -30
  259. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  260. package/background/src/lib/virtualized/project/writeSimpleRoot.js +21 -11
  261. package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
  262. package/codeyam-cli/scripts/apply-setup.js +180 -0
  263. package/codeyam-cli/scripts/apply-setup.js.map +1 -1
  264. package/codeyam-cli/src/cli.js +32 -18
  265. package/codeyam-cli/src/cli.js.map +1 -1
  266. package/codeyam-cli/src/codeyam-cli.js +18 -2
  267. package/codeyam-cli/src/codeyam-cli.js.map +1 -1
  268. package/codeyam-cli/src/commands/analyze.js +4 -2
  269. package/codeyam-cli/src/commands/analyze.js.map +1 -1
  270. package/codeyam-cli/src/commands/baseline.js +2 -0
  271. package/codeyam-cli/src/commands/baseline.js.map +1 -1
  272. package/codeyam-cli/src/commands/debug.js +9 -5
  273. package/codeyam-cli/src/commands/debug.js.map +1 -1
  274. package/codeyam-cli/src/commands/default.js +31 -20
  275. package/codeyam-cli/src/commands/default.js.map +1 -1
  276. package/codeyam-cli/src/commands/detect-universal-mocks.js +2 -0
  277. package/codeyam-cli/src/commands/detect-universal-mocks.js.map +1 -1
  278. package/codeyam-cli/src/commands/init.js +49 -257
  279. package/codeyam-cli/src/commands/init.js.map +1 -1
  280. package/codeyam-cli/src/commands/memory.js +307 -0
  281. package/codeyam-cli/src/commands/memory.js.map +1 -0
  282. package/codeyam-cli/src/commands/recapture.js +2 -0
  283. package/codeyam-cli/src/commands/recapture.js.map +1 -1
  284. package/codeyam-cli/src/commands/setup-sandbox.js +2 -0
  285. package/codeyam-cli/src/commands/setup-sandbox.js.map +1 -1
  286. package/codeyam-cli/src/commands/setup-simulations.js +284 -0
  287. package/codeyam-cli/src/commands/setup-simulations.js.map +1 -0
  288. package/codeyam-cli/src/commands/test-startup.js +2 -0
  289. package/codeyam-cli/src/commands/test-startup.js.map +1 -1
  290. package/codeyam-cli/src/commands/verify.js +14 -2
  291. package/codeyam-cli/src/commands/verify.js.map +1 -1
  292. package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js +179 -0
  293. package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js.map +1 -0
  294. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +128 -82
  295. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
  296. package/codeyam-cli/src/utils/analysisRunner.js +21 -2
  297. package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
  298. package/codeyam-cli/src/utils/analyzer.js +7 -0
  299. package/codeyam-cli/src/utils/analyzer.js.map +1 -1
  300. package/codeyam-cli/src/utils/backgroundServer.js +90 -19
  301. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  302. package/codeyam-cli/src/utils/generateReport.js +2 -2
  303. package/codeyam-cli/src/utils/install-skills.js +77 -38
  304. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  305. package/codeyam-cli/src/utils/labsAutoCheck.js +19 -0
  306. package/codeyam-cli/src/utils/labsAutoCheck.js.map +1 -0
  307. package/codeyam-cli/src/utils/npmVersionCheck.js +76 -0
  308. package/codeyam-cli/src/utils/npmVersionCheck.js.map +1 -0
  309. package/codeyam-cli/src/utils/progress.js +7 -0
  310. package/codeyam-cli/src/utils/progress.js.map +1 -1
  311. package/codeyam-cli/src/utils/queue/job.js +5 -0
  312. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  313. package/codeyam-cli/src/utils/queue/manager.js +6 -0
  314. package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
  315. package/codeyam-cli/src/utils/requireSimulations.js +10 -0
  316. package/codeyam-cli/src/utils/requireSimulations.js.map +1 -0
  317. package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js +82 -0
  318. package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
  319. package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +230 -0
  320. package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
  321. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
  322. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
  323. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
  324. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
  325. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
  326. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
  327. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
  328. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
  329. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +74 -0
  330. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
  331. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +376 -0
  332. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
  333. package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +116 -0
  334. package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -0
  335. package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js +127 -0
  336. package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js.map +1 -0
  337. package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js +50 -0
  338. package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js.map +1 -0
  339. package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +116 -0
  340. package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -0
  341. package/codeyam-cli/src/utils/ruleReflection/index.js +5 -0
  342. package/codeyam-cli/src/utils/ruleReflection/index.js.map +1 -0
  343. package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js +44 -0
  344. package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js.map +1 -0
  345. package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js +85 -0
  346. package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js.map +1 -0
  347. package/codeyam-cli/src/utils/ruleReflection/types.js +5 -0
  348. package/codeyam-cli/src/utils/ruleReflection/types.js.map +1 -0
  349. package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +293 -0
  350. package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
  351. package/codeyam-cli/src/utils/rules/index.js +6 -0
  352. package/codeyam-cli/src/utils/rules/index.js.map +1 -0
  353. package/codeyam-cli/src/utils/rules/parser.js +83 -0
  354. package/codeyam-cli/src/utils/rules/parser.js.map +1 -0
  355. package/codeyam-cli/src/utils/rules/pathMatcher.js +18 -0
  356. package/codeyam-cli/src/utils/rules/pathMatcher.js.map +1 -0
  357. package/codeyam-cli/src/utils/rules/ruleState.js +150 -0
  358. package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
  359. package/codeyam-cli/src/utils/rules/staleness.js +137 -0
  360. package/codeyam-cli/src/utils/rules/staleness.js.map +1 -0
  361. package/codeyam-cli/src/utils/serverState.js +37 -10
  362. package/codeyam-cli/src/utils/serverState.js.map +1 -1
  363. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +21 -42
  364. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
  365. package/codeyam-cli/src/utils/simulationGateMiddleware.js +138 -0
  366. package/codeyam-cli/src/utils/simulationGateMiddleware.js.map +1 -0
  367. package/codeyam-cli/src/utils/syncMocksMiddleware.js +5 -24
  368. package/codeyam-cli/src/utils/syncMocksMiddleware.js.map +1 -1
  369. package/codeyam-cli/src/utils/versionInfo.js +25 -0
  370. package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
  371. package/codeyam-cli/src/webserver/__tests__/dependency-smoke.test.js +66 -0
  372. package/codeyam-cli/src/webserver/__tests__/dependency-smoke.test.js.map +1 -0
  373. package/codeyam-cli/src/webserver/app/lib/database.js +22 -6
  374. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  375. package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
  376. package/codeyam-cli/src/webserver/backgroundServer.js +50 -0
  377. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  378. package/codeyam-cli/src/webserver/bootstrap.js +51 -0
  379. package/codeyam-cli/src/webserver/bootstrap.js.map +1 -1
  380. package/codeyam-cli/src/webserver/build/client/assets/CopyButton-jNYXRRNI.js +1 -0
  381. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-bwuHPyTa.js +11 -0
  382. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-COi5OvsN.js → EntityTypeBadge-CvzqMxcu.js} +1 -1
  383. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-BwdQv49w.js → EntityTypeIcon-BH0XDim7.js} +1 -1
  384. package/codeyam-cli/src/webserver/build/client/assets/{InlineSpinner-CEleMv_j.js → InlineSpinner-EhOseatT.js} +1 -1
  385. package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-D68KarMg.js → InteractivePreview-yjIHlOGa.js} +2 -2
  386. package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-L75Wvqgw.js → LibraryFunctionPreview-Cq5o8jL4.js} +1 -1
  387. package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-C53WM8qn.js → LoadingDots-BvMu2i-g.js} +1 -1
  388. package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-CrNkmy4i.js → LogViewer-kgBTLoJD.js} +1 -1
  389. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-BzPgx-xO.js +11 -0
  390. package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-CQifa1n-.js → SafeScreenshot-CwZrv-Ok.js} +1 -1
  391. package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-CyaBFX7l.js → ScenarioViewer-BX2Ny2Qj.js} +3 -13
  392. package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-D36O1rzU.js → TruncatedFilePath-CDpEprKa.js} +1 -1
  393. package/codeyam-cli/src/webserver/build/client/assets/_index-BRx8ZGZo.js +11 -0
  394. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-4S4yPfFw.js +27 -0
  395. package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-DHKuQSmR.js +17 -0
  396. package/codeyam-cli/src/webserver/build/client/assets/api.agent-transcripts-l0sNRNKZ.js +1 -0
  397. package/codeyam-cli/src/webserver/build/client/assets/api.health-l0sNRNKZ.js +1 -0
  398. package/codeyam-cli/src/webserver/build/client/assets/api.labs-unlock-l0sNRNKZ.js +1 -0
  399. package/codeyam-cli/src/webserver/build/client/assets/api.memory-profile-l0sNRNKZ.js +1 -0
  400. package/codeyam-cli/src/webserver/build/client/assets/api.restart-server-l0sNRNKZ.js +1 -0
  401. package/codeyam-cli/src/webserver/build/client/assets/api.save-fixture-l0sNRNKZ.js +1 -0
  402. package/codeyam-cli/src/webserver/build/client/assets/book-open-D4IPYH_y.js +6 -0
  403. package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-DgTPh8H-.js → chevron-down-CG65viiV.js} +1 -1
  404. package/codeyam-cli/src/webserver/build/client/assets/{chunk-EPOLDU6W-DdQKK6on.js → chunk-JZWAC4HX-DB3aFuEO.js} +12 -12
  405. package/codeyam-cli/src/webserver/build/client/assets/{circle-check-Dmr2bb1R.js → circle-check-igfMr5DY.js} +1 -1
  406. package/codeyam-cli/src/webserver/build/client/assets/copy-Coc4o_8c.js +11 -0
  407. package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-Do4ZLUYa.js → createLucideIcon-D1zB-pYc.js} +1 -1
  408. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-JTAjQ54M.js +1 -0
  409. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-CbdFyxZh.js → entity._sha._-B0h9AqE6.js} +12 -12
  410. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-B4iCfs5M.js → entity._sha.scenarios._scenarioId.fullscreen-DjLxr2JB.js} +1 -1
  411. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-wDWZZO1W.js → entity._sha_.create-scenario-CtYowLOt.js} +1 -1
  412. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-BMbl7MeQ.js → entity._sha_.edit._scenarioId-PePWg17F.js} +1 -1
  413. package/codeyam-cli/src/webserver/build/client/assets/{entry.client-5wRKRIH9.js → entry.client-I-Wo99C_.js} +1 -1
  414. package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DD3SDH7t.js → fileTableUtils-9sMMAiWJ.js} +1 -1
  415. package/codeyam-cli/src/webserver/build/client/assets/files-Co65J0s3.js +1 -0
  416. package/codeyam-cli/src/webserver/build/client/assets/{git-zXjT7J0G.js → git-BdHOxVfg.js} +8 -8
  417. package/codeyam-cli/src/webserver/build/client/assets/globals-BSZfYCkU.css +1 -0
  418. package/codeyam-cli/src/webserver/build/client/assets/{index-DLbXwndH.js → index-CUM5iXwc.js} +1 -1
  419. package/codeyam-cli/src/webserver/build/client/assets/{index-gPZ-lad1.js → index-_417gcQW.js} +1 -1
  420. package/codeyam-cli/src/webserver/build/client/assets/labs-BK0C1H1T.js +1 -0
  421. package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-BsPXJ81F.js → loader-circle-TzRHMVog.js} +1 -1
  422. package/codeyam-cli/src/webserver/build/client/assets/manifest-040dab1c.js +1 -0
  423. package/codeyam-cli/src/webserver/build/client/assets/memory-UIDVz141.js +92 -0
  424. package/codeyam-cli/src/webserver/build/client/assets/pause-hjzB7t2z.js +11 -0
  425. package/codeyam-cli/src/webserver/build/client/assets/root-D1WadSdf.js +62 -0
  426. package/codeyam-cli/src/webserver/build/client/assets/{search-P2FKIUql.js → search-DcAwD_Ln.js} +1 -1
  427. package/codeyam-cli/src/webserver/build/client/assets/settings-CclxrcPK.js +1 -0
  428. package/codeyam-cli/src/webserver/build/client/assets/{simulations-L18M6-kN.js → simulations-DVNJVQgD.js} +1 -1
  429. package/codeyam-cli/src/webserver/build/client/assets/terminal-DbEAHMbA.js +11 -0
  430. package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-BDz7kbVA.js → triangle-alert-CAD5b1o_.js} +1 -1
  431. package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-29dDmbH8.js → useCustomSizes-BqgrAzs3.js} +1 -1
  432. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-BUm0UVJm.js → useLastLogLine-DAFqfEDH.js} +1 -1
  433. package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-CkIOKTrZ.js → useReportContext-DZlYx2c4.js} +1 -1
  434. package/codeyam-cli/src/webserver/build/client/assets/{useToast-KKw5kTn-.js → useToast-ihdMtlf6.js} +1 -1
  435. package/codeyam-cli/src/webserver/build/server/assets/index-B3dE0r28.js +1 -0
  436. package/codeyam-cli/src/webserver/build/server/assets/server-build-DYbfdxa3.js +273 -0
  437. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  438. package/codeyam-cli/src/webserver/build-info.json +5 -5
  439. package/codeyam-cli/templates/{codeyam:debug.md → codeyam-debug.md} +48 -4
  440. package/codeyam-cli/templates/codeyam-diagnose.md +481 -0
  441. package/codeyam-cli/templates/codeyam-memory-hook.sh +199 -0
  442. package/codeyam-cli/templates/codeyam-memory.md +396 -0
  443. package/codeyam-cli/templates/codeyam-new-rule.md +13 -0
  444. package/codeyam-cli/templates/{codeyam:setup.md → codeyam-setup.md} +13 -1
  445. package/codeyam-cli/templates/{codeyam:sim.md → codeyam-sim.md} +1 -1
  446. package/codeyam-cli/templates/{codeyam:test.md → codeyam-test.md} +1 -1
  447. package/codeyam-cli/templates/{codeyam:verify.md → codeyam-verify.md} +1 -1
  448. package/codeyam-cli/templates/rule-notification-hook.py +56 -0
  449. package/codeyam-cli/templates/rule-reflection-hook.py +627 -0
  450. package/codeyam-cli/templates/rules-instructions.md +132 -0
  451. package/package.json +18 -15
  452. package/packages/ai/index.js +7 -3
  453. package/packages/ai/index.js.map +1 -1
  454. package/packages/ai/src/lib/analyzeScope.js +91 -30
  455. package/packages/ai/src/lib/analyzeScope.js.map +1 -1
  456. package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
  457. package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
  458. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +78 -8
  459. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
  460. package/packages/ai/src/lib/astScopes/methodSemantics.js +109 -23
  461. package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
  462. package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js +10 -14
  463. package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js.map +1 -1
  464. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +1 -102
  465. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
  466. package/packages/ai/src/lib/astScopes/processExpression.js +518 -28
  467. package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
  468. package/packages/ai/src/lib/astScopes/sharedPatterns.js +25 -0
  469. package/packages/ai/src/lib/astScopes/sharedPatterns.js.map +1 -1
  470. package/packages/ai/src/lib/completionCall.js +161 -30
  471. package/packages/ai/src/lib/completionCall.js.map +1 -1
  472. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1061 -174
  473. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  474. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +5 -1
  475. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
  476. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +179 -0
  477. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -1
  478. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +7 -1
  479. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
  480. package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +13 -3
  481. package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -1
  482. package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +6 -4
  483. package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -1
  484. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +52 -3
  485. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
  486. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +106 -13
  487. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
  488. package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
  489. package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
  490. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +122 -12
  491. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
  492. package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +173 -0
  493. package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -0
  494. package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js +37 -20
  495. package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js.map +1 -1
  496. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +333 -86
  497. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
  498. package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
  499. package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
  500. package/packages/ai/src/lib/dataStructureChunking.js +130 -0
  501. package/packages/ai/src/lib/dataStructureChunking.js.map +1 -0
  502. package/packages/ai/src/lib/e2eDataTracking.js +241 -0
  503. package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
  504. package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
  505. package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
  506. package/packages/ai/src/lib/generateEntityDataStructure.js +46 -2
  507. package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
  508. package/packages/ai/src/lib/generateEntityScenarioData.js +734 -8
  509. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  510. package/packages/ai/src/lib/generateEntityScenarios.js +26 -2
  511. package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
  512. package/packages/ai/src/lib/generateExecutionFlows.js +376 -4
  513. package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
  514. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +1124 -59
  515. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -1
  516. package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
  517. package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
  518. package/packages/ai/src/lib/isolateScopes.js +39 -3
  519. package/packages/ai/src/lib/isolateScopes.js.map +1 -1
  520. package/packages/ai/src/lib/mergeJsonTypeDefinitions.js +5 -0
  521. package/packages/ai/src/lib/mergeJsonTypeDefinitions.js.map +1 -1
  522. package/packages/ai/src/lib/mergeStatements.js +70 -51
  523. package/packages/ai/src/lib/mergeStatements.js.map +1 -1
  524. package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js +97 -0
  525. package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js.map +1 -0
  526. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +10 -4
  527. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
  528. package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
  529. package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
  530. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +30 -7
  531. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
  532. package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
  533. package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
  534. package/packages/ai/src/lib/resolvePathToControllable.js +155 -41
  535. package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -1
  536. package/packages/ai/src/lib/worker/SerializableDataStructure.js +7 -0
  537. package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
  538. package/packages/ai/src/lib/worker/analyzeScopeWorker.js +94 -1
  539. package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
  540. package/packages/analyze/index.js +1 -0
  541. package/packages/analyze/index.js.map +1 -1
  542. package/packages/analyze/src/lib/FileAnalyzer.js +60 -36
  543. package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
  544. package/packages/analyze/src/lib/ProjectAnalyzer.js +96 -26
  545. package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
  546. package/packages/analyze/src/lib/analysisContext.js +30 -5
  547. package/packages/analyze/src/lib/analysisContext.js.map +1 -1
  548. package/packages/analyze/src/lib/asts/nodes/getNodeType.js +1 -0
  549. package/packages/analyze/src/lib/asts/nodes/getNodeType.js.map +1 -1
  550. package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js +14 -0
  551. package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -1
  552. package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js +14 -0
  553. package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js.map +1 -1
  554. package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +6 -0
  555. package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
  556. package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js +6 -0
  557. package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js.map +1 -1
  558. package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js +39 -1
  559. package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js.map +1 -1
  560. package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js +2 -1
  561. package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js.map +1 -1
  562. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +72 -10
  563. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  564. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +17 -4
  565. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  566. package/packages/analyze/src/lib/files/analyze/dependencyResolver.js +5 -0
  567. package/packages/analyze/src/lib/files/analyze/dependencyResolver.js.map +1 -1
  568. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +2 -1
  569. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
  570. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -10
  571. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
  572. package/packages/analyze/src/lib/files/analyzeRemixRoute.js +3 -2
  573. package/packages/analyze/src/lib/files/analyzeRemixRoute.js.map +1 -1
  574. package/packages/analyze/src/lib/files/getImportedExports.js +11 -7
  575. package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
  576. package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +880 -0
  577. package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
  578. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +164 -68
  579. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
  580. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +75 -21
  581. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
  582. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +185 -20
  583. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  584. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +57 -9
  585. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -1
  586. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +542 -53
  587. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  588. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
  589. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
  590. package/packages/analyze/src/lib/files/setImportedExports.js +2 -1
  591. package/packages/analyze/src/lib/files/setImportedExports.js.map +1 -1
  592. package/packages/analyze/src/lib/index.js +1 -0
  593. package/packages/analyze/src/lib/index.js.map +1 -1
  594. package/packages/analyze/src/lib/utils/getFileByPath.js +12 -0
  595. package/packages/analyze/src/lib/utils/getFileByPath.js.map +1 -0
  596. package/packages/database/src/lib/analysisBranchToDb.js +1 -1
  597. package/packages/database/src/lib/analysisBranchToDb.js.map +1 -1
  598. package/packages/database/src/lib/analysisToDb.js +1 -1
  599. package/packages/database/src/lib/analysisToDb.js.map +1 -1
  600. package/packages/database/src/lib/branchToDb.js +1 -1
  601. package/packages/database/src/lib/branchToDb.js.map +1 -1
  602. package/packages/database/src/lib/commitBranchToDb.js +1 -1
  603. package/packages/database/src/lib/commitBranchToDb.js.map +1 -1
  604. package/packages/database/src/lib/commitToDb.js +1 -1
  605. package/packages/database/src/lib/commitToDb.js.map +1 -1
  606. package/packages/database/src/lib/fileToDb.js +1 -1
  607. package/packages/database/src/lib/fileToDb.js.map +1 -1
  608. package/packages/database/src/lib/kysely/db.js +11 -1
  609. package/packages/database/src/lib/kysely/db.js.map +1 -1
  610. package/packages/database/src/lib/kysely/tables/commitsTable.js +3 -0
  611. package/packages/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
  612. package/packages/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
  613. package/packages/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
  614. package/packages/database/src/lib/loadAnalyses.js +45 -2
  615. package/packages/database/src/lib/loadAnalyses.js.map +1 -1
  616. package/packages/database/src/lib/loadAnalysis.js +8 -0
  617. package/packages/database/src/lib/loadAnalysis.js.map +1 -1
  618. package/packages/database/src/lib/loadBranch.js +11 -1
  619. package/packages/database/src/lib/loadBranch.js.map +1 -1
  620. package/packages/database/src/lib/loadCommit.js +7 -0
  621. package/packages/database/src/lib/loadCommit.js.map +1 -1
  622. package/packages/database/src/lib/loadCommits.js +22 -1
  623. package/packages/database/src/lib/loadCommits.js.map +1 -1
  624. package/packages/database/src/lib/loadEntities.js +23 -4
  625. package/packages/database/src/lib/loadEntities.js.map +1 -1
  626. package/packages/database/src/lib/loadEntityBranches.js +9 -0
  627. package/packages/database/src/lib/loadEntityBranches.js.map +1 -1
  628. package/packages/database/src/lib/projectToDb.js +1 -1
  629. package/packages/database/src/lib/projectToDb.js.map +1 -1
  630. package/packages/database/src/lib/saveFiles.js +1 -1
  631. package/packages/database/src/lib/saveFiles.js.map +1 -1
  632. package/packages/database/src/lib/scenarioToDb.js +1 -1
  633. package/packages/database/src/lib/scenarioToDb.js.map +1 -1
  634. package/packages/database/src/lib/updateCommitMetadata.js +5 -4
  635. package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
  636. package/packages/types/index.js.map +1 -1
  637. package/packages/utils/src/lib/fs/rsyncCopy.js +93 -2
  638. package/packages/utils/src/lib/fs/rsyncCopy.js.map +1 -1
  639. package/packages/utils/src/lib/safeFileName.js +29 -3
  640. package/packages/utils/src/lib/safeFileName.js.map +1 -1
  641. package/scripts/finalize-analyzer.cjs +8 -76
  642. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-vauWK972.js +0 -1
  643. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-DzJRkCkr.js +0 -11
  644. package/codeyam-cli/src/webserver/build/client/assets/_index-Be83mo_j.js +0 -11
  645. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BN6wu6Y-.js +0 -37
  646. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-Bn6aCAy_.js +0 -1
  647. package/codeyam-cli/src/webserver/build/client/assets/files-DKyMFI90.js +0 -1
  648. package/codeyam-cli/src/webserver/build/client/assets/globals-DTTQ3gY7.css +0 -1
  649. package/codeyam-cli/src/webserver/build/client/assets/manifest-22590fcf.js +0 -1
  650. package/codeyam-cli/src/webserver/build/client/assets/root-BsAarjAM.js +0 -57
  651. package/codeyam-cli/src/webserver/build/client/assets/settings-B2eDuBj8.js +0 -1
  652. package/codeyam-cli/src/webserver/build/server/assets/index-BND5I5fv.js +0 -1
  653. package/codeyam-cli/src/webserver/build/server/assets/server-build-CFXnd7MG.js +0 -228
  654. package/codeyam-cli/templates/codeyam:diagnose.md +0 -625
@@ -1,11 +1,18 @@
1
1
  import completionCall from "./completionCall.js";
2
2
  import generateEntityScenarioDataGenerator from "./promptGenerators/generateEntityScenarioDataGenerator.js";
3
3
  import generateMissingKeysPrompt from "./promptGenerators/generateMissingKeysPrompt.js";
4
+ import generateChunkPrompt from "./promptGenerators/generateChunkPrompt.js";
4
5
  import { saveLlmCall } from "../../../../packages/aws/dynamodb/index.js";
6
+ import { trackDataSnapshot } from "./e2eDataTracking.js";
5
7
  import validateJson from "./validateJson.js";
6
8
  import { awsLog, awsLogDebugLevel } from "../../../../packages/utils/index.js";
7
9
  import { parseJsonSafe } from "../../../../packages/ai/index.js";
8
10
  import convertNullToUndefinedBySchema from "./dataStructure/helpers/convertNullToUndefinedBySchema.js";
11
+ import convertTypeAnnotationsToValues from "./dataStructure/helpers/convertTypeAnnotationsToValues.js";
12
+ import fixNullIdsBySchema from "./dataStructure/helpers/fixNullIdsBySchema.js";
13
+ import coerceObjectsToPrimitivesBySchema from "./dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js";
14
+ import { deepMerge } from "../../../../packages/generate/index.js";
15
+ import { chunkDataStructure, getRequiredValuesForChunk, } from "./dataStructureChunking.js";
9
16
  /**
10
17
  * Check if any of the scenario's covered flows require error data.
11
18
  * Returns true if any requiredValue has an error path with truthy comparison.
@@ -90,6 +97,418 @@ function deepMergeScenarioData(defaultData, scenarioData) {
90
97
  return result;
91
98
  }
92
99
  const DEFAULT_SCENARIO_NAME = 'Default Scenario';
100
+ /**
101
+ * Find the path to a key within a nested dataForMocks structure.
102
+ * Returns the path as an array of keys, or null if not found.
103
+ *
104
+ * @example
105
+ * // dataForMocks = { trpc: { fastener: { "useMutation()": { isLoading: "boolean" } } } }
106
+ * // findKeyPath("fastener", dataForMocks) returns ["trpc"]
107
+ */
108
+ function findKeyPath(targetKey, obj, currentPath = []) {
109
+ if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
110
+ return null;
111
+ }
112
+ for (const key of Object.keys(obj)) {
113
+ if (key === targetKey) {
114
+ return currentPath;
115
+ }
116
+ // Recursively search in nested objects
117
+ const nested = obj[key];
118
+ if (typeof nested === 'object' &&
119
+ nested !== null &&
120
+ !Array.isArray(nested)) {
121
+ const result = findKeyPath(targetKey, nested, [
122
+ ...currentPath,
123
+ key,
124
+ ]);
125
+ if (result !== null) {
126
+ return result;
127
+ }
128
+ }
129
+ }
130
+ return null;
131
+ }
132
+ /**
133
+ * Relocate misplaced nested keys in mockData to their correct position
134
+ * based on the dataForMocks structure.
135
+ *
136
+ * When the LLM returns mockData with keys at the wrong nesting level
137
+ * (e.g., { trpc: { quote: {...} }, fastener: {...} } when fastener should
138
+ * be inside trpc), this function moves them to the correct position.
139
+ *
140
+ * This function works recursively to handle nested misplacements, not just
141
+ * root-level ones. For example, if getQuote is at trpc.getQuote instead of
142
+ * trpc.quote.getQuote, it will be relocated.
143
+ *
144
+ * @example
145
+ * // dataForMocks: { trpc: { quote: {...}, fastener: {...} } }
146
+ * // mockData: { trpc: { quote: {...} }, fastener: {...} }
147
+ * // After: mockData: { trpc: { quote: {...}, fastener: {...} } }
148
+ *
149
+ * @example (nested case)
150
+ * // dataForMocks: { trpc: { quote: { getQuote: {...} } } }
151
+ * // mockData: { trpc: { quote: {...}, getQuote: {...} } }
152
+ * // After: mockData: { trpc: { quote: { getQuote: {...} } } }
153
+ */
154
+ function relocateMisplacedNestedKeys(mockData, dataForMocks, currentPathForLogging = []) {
155
+ if (typeof dataForMocks !== 'object' || dataForMocks === null) {
156
+ return;
157
+ }
158
+ const keysInSchema = Object.keys(dataForMocks);
159
+ const keysToRelocate = [];
160
+ // Find keys in mockData that are NOT at this level in dataForMocks
161
+ // but DO exist somewhere nested in dataForMocks
162
+ for (const key of Object.keys(mockData)) {
163
+ if (!keysInSchema.includes(key)) {
164
+ // This key is at this level in mockData but not at this level in dataForMocks
165
+ // Check if it exists somewhere nested in dataForMocks
166
+ const path = findKeyPath(key, dataForMocks);
167
+ if (path !== null && path.length > 0) {
168
+ keysToRelocate.push({ key, path });
169
+ }
170
+ }
171
+ }
172
+ // Relocate each misplaced key to its correct nested position
173
+ for (const { key, path } of keysToRelocate) {
174
+ const value = mockData[key];
175
+ // Navigate to the correct parent in mockData, creating nested objects if needed
176
+ let current = mockData;
177
+ for (const pathKey of path) {
178
+ if (current[pathKey] === undefined) {
179
+ current[pathKey] = {};
180
+ }
181
+ current = current[pathKey];
182
+ }
183
+ // Deep merge the value into the correct location
184
+ // Use deep merge to preserve existing data at that location
185
+ if (current[key] !== undefined && typeof current[key] === 'object') {
186
+ current[key] = deepMerge(current[key], value);
187
+ }
188
+ else {
189
+ current[key] = value;
190
+ }
191
+ // Remove the key from its current (wrong) level
192
+ delete mockData[key];
193
+ const fullPath = [...currentPathForLogging, ...path].join('.');
194
+ awsLog(`CodeYam: Relocated misplaced key "${key}" from [${currentPathForLogging.join('.')}] to [${fullPath}]`);
195
+ }
196
+ // Recursively process nested objects to handle deeply nested misplacements
197
+ for (const key of Object.keys(mockData)) {
198
+ const mockValue = mockData[key];
199
+ const schemaValue = dataForMocks[key];
200
+ // Only recurse if both mockData and schema have nested objects at this key
201
+ if (typeof mockValue === 'object' &&
202
+ mockValue !== null &&
203
+ !Array.isArray(mockValue) &&
204
+ typeof schemaValue === 'object' &&
205
+ schemaValue !== null &&
206
+ !Array.isArray(schemaValue)) {
207
+ relocateMisplacedNestedKeys(mockValue, schemaValue, [...currentPathForLogging, key]);
208
+ }
209
+ }
210
+ }
211
+ /**
212
+ * Generate default mock data for a schema type.
213
+ * Returns reasonable default values based on the schema type string.
214
+ */
215
+ function generateDefaultForSchemaType(schemaType) {
216
+ if (typeof schemaType === 'string') {
217
+ // Handle common type strings
218
+ if (schemaType === 'function')
219
+ return () => { };
220
+ if (schemaType === 'promise')
221
+ return Promise.resolve();
222
+ if (schemaType === 'boolean')
223
+ return false;
224
+ if (schemaType === 'string')
225
+ return '';
226
+ if (schemaType === 'number')
227
+ return 0;
228
+ if (schemaType.includes('number | undefined'))
229
+ return undefined;
230
+ if (schemaType.includes('string | undefined'))
231
+ return undefined;
232
+ if (schemaType.includes('boolean | undefined'))
233
+ return undefined;
234
+ if (schemaType.includes('| undefined'))
235
+ return undefined;
236
+ if (schemaType.includes('| null'))
237
+ return null;
238
+ return schemaType; // Return the type as a string placeholder
239
+ }
240
+ if (Array.isArray(schemaType)) {
241
+ if (schemaType.length === 0)
242
+ return [];
243
+ // Generate a single default element based on the first element's schema
244
+ const elementDefault = generateDefaultForSchemaType(schemaType[0]);
245
+ return elementDefault !== undefined ? [elementDefault] : [];
246
+ }
247
+ if (typeof schemaType === 'object' && schemaType !== null) {
248
+ // Recursively generate defaults for nested objects
249
+ const result = {};
250
+ for (const [key, value] of Object.entries(schemaType)) {
251
+ result[key] = generateDefaultForSchemaType(value);
252
+ }
253
+ return result;
254
+ }
255
+ return undefined;
256
+ }
257
+ /**
258
+ * Detect if a string should be converted to an array.
259
+ * Returns the array if the field appears to be an array field, or null if it should remain a string.
260
+ *
261
+ * This handles two cases:
262
+ * 1. Comma-separated values: "color,size" -> ["color", "size"]
263
+ * 2. Single values for array-named fields: "Finish" -> ["Finish"]
264
+ */
265
+ function parseCommaSeparatedStringAsArray(value, key) {
266
+ // Heuristic: if the key name suggests it's an array field, convert it
267
+ // Common patterns: *_attributes, *_ids, *_items, *_tags, *_values, plural names
268
+ // Check this FIRST because array-named fields should be converted regardless
269
+ // of whether they contain commas (single values become single-element arrays).
270
+ const arrayFieldPatterns = [
271
+ /_attributes$/i,
272
+ /_ids$/i,
273
+ /_items$/i,
274
+ /_tags$/i,
275
+ /_values$/i,
276
+ /_types$/i,
277
+ /_names$/i,
278
+ /_keys$/i,
279
+ /^attributes$/i,
280
+ /^items$/i,
281
+ /^tags$/i,
282
+ /^values$/i,
283
+ ];
284
+ const looksLikeArrayField = arrayFieldPatterns.some((pattern) => pattern.test(key));
285
+ if (looksLikeArrayField) {
286
+ // Skip newlines check - multiline values shouldn't be split
287
+ if (value.includes('\n')) {
288
+ return null;
289
+ }
290
+ // Split by comma and trim whitespace
291
+ const parts = value.split(',').map((s) => s.trim());
292
+ // Filter out empty strings - this handles both "Finish" -> ["Finish"]
293
+ // and "" -> []
294
+ return parts.filter((s) => s.length > 0);
295
+ }
296
+ // For non-array-named fields, only convert if there are commas
297
+ if (!value.includes(',')) {
298
+ return null;
299
+ }
300
+ // For non-array-named fields, apply stricter sentence detection
301
+ // Skip if it looks like a sentence (comma followed by space and lowercase)
302
+ if (/,\s+[a-z]/.test(value)) {
303
+ return null;
304
+ }
305
+ // Skip if it contains newlines (likely formatted text)
306
+ if (value.includes('\n')) {
307
+ return null;
308
+ }
309
+ return null;
310
+ }
311
+ /**
312
+ * Convert comma-separated string values to arrays when they look like array data.
313
+ * This handles cases where the LLM generates strings like "color,size" instead
314
+ * of arrays like ["color", "size"] due to schema type misdetection.
315
+ */
316
+ function convertCommaSeparatedStringsToArrays(mockData) {
317
+ for (const [key, value] of Object.entries(mockData)) {
318
+ if (typeof value === 'string') {
319
+ const asArray = parseCommaSeparatedStringAsArray(value, key);
320
+ if (asArray !== null) {
321
+ mockData[key] = asArray;
322
+ awsLog(`CodeYam: Converted comma-separated string to array for key "${key}": "${value}" -> [${asArray.map((s) => `"${s}"`).join(', ')}]`);
323
+ }
324
+ }
325
+ else if (value !== null &&
326
+ typeof value === 'object' &&
327
+ !Array.isArray(value)) {
328
+ // Recursively process nested objects
329
+ convertCommaSeparatedStringsToArrays(value);
330
+ }
331
+ else if (Array.isArray(value)) {
332
+ // Recursively process arrays (each element could be an object)
333
+ for (const item of value) {
334
+ if (item !== null && typeof item === 'object' && !Array.isArray(item)) {
335
+ convertCommaSeparatedStringsToArrays(item);
336
+ }
337
+ }
338
+ }
339
+ }
340
+ }
341
+ /**
342
+ * Ensure all keys from dataForMocks have corresponding data in mockData.
343
+ * For missing keys, generate default values based on the schema.
344
+ * Recursively checks nested objects to fill in any missing nested fields.
345
+ */
346
+ function fillMissingMockDataKeysWithDefaults(mockData, dataForMocks, pathPrefix = '') {
347
+ if (typeof dataForMocks !== 'object' || dataForMocks === null) {
348
+ return;
349
+ }
350
+ const missingKeys = [];
351
+ for (const key of Object.keys(dataForMocks)) {
352
+ if (key === '_nullable')
353
+ continue; // Internal marker, not a data key
354
+ const fullPath = pathPrefix ? `${pathPrefix}.${key}` : key;
355
+ if (mockData[key] === undefined) {
356
+ missingKeys.push(fullPath);
357
+ // Generate default data based on schema
358
+ const schemaForKey = dataForMocks[key];
359
+ mockData[key] = generateDefaultForSchemaType(schemaForKey);
360
+ }
361
+ else {
362
+ // Key exists, but if both are objects, recursively check for missing nested keys
363
+ const schemaValue = dataForMocks[key];
364
+ const mockValue = mockData[key];
365
+ if (typeof schemaValue === 'object' &&
366
+ schemaValue !== null &&
367
+ !Array.isArray(schemaValue) &&
368
+ typeof mockValue === 'object' &&
369
+ mockValue !== null &&
370
+ !Array.isArray(mockValue)) {
371
+ fillMissingMockDataKeysWithDefaults(mockValue, schemaValue, fullPath);
372
+ }
373
+ }
374
+ }
375
+ if (missingKeys.length > 0) {
376
+ awsLog(`CodeYam: Generated default mock data for ${missingKeys.length} missing key(s): ${missingKeys.slice(0, 10).join(', ')}${missingKeys.length > 10 ? '...' : ''}`);
377
+ }
378
+ }
379
+ /**
380
+ * Enforce execution flow requiredValues by setting falsy paths to null.
381
+ *
382
+ * The LLM doesn't reliably generate null for `comparison: 'falsy'` requirements.
383
+ * For example, a flow like "diffView: falsy" should hide a modal, but the LLM
384
+ * might generate a truthy object, causing the modal to show in all screenshots.
385
+ *
386
+ * This function:
387
+ * 1. Gets requiredValues from covered flows
388
+ * 2. For 'falsy' comparisons: sets the value to null
389
+ * 3. For 'truthy' comparisons with falsy values: generates a default truthy value
390
+ */
391
+ function enforceRequiredValues(mockData, coveredFlowIds, executionFlows) {
392
+ if (!coveredFlowIds.length || !executionFlows.length) {
393
+ return;
394
+ }
395
+ // Get all requiredValues from covered flows
396
+ const coveredFlows = executionFlows.filter((flow) => coveredFlowIds.includes(flow.id));
397
+ for (const flow of coveredFlows) {
398
+ if (!flow.requiredValues)
399
+ continue;
400
+ for (const rv of flow.requiredValues) {
401
+ if (!rv.attributePath)
402
+ continue;
403
+ // Find the value in mockData - the path could be nested
404
+ // e.g., attributePath: "diffView" could be at mockData['useDiffModal()'].diffView
405
+ const result = findAndSetValueInMockData(mockData, rv.attributePath, rv.comparison, rv.valueType);
406
+ if (result.found) {
407
+ awsLog(`CodeYam: Enforced ${rv.comparison} for ${rv.attributePath} (set to ${result.newValue === null ? 'null' : typeof result.newValue})`);
408
+ }
409
+ }
410
+ }
411
+ }
412
+ /**
413
+ * Find a value in mockData by attributePath and enforce the comparison.
414
+ * The attributePath could be a simple key or a nested path.
415
+ *
416
+ * Returns { found: boolean, newValue: unknown }
417
+ */
418
+ function findAndSetValueInMockData(mockData, attributePath, comparison, valueType) {
419
+ // Try to find the path at various nesting levels
420
+ // The attributePath might be "diffView" but the actual location is
421
+ // mockData['useDiffModal()'].diffView
422
+ // Strategy 1: Direct path (e.g., mockData[attributePath])
423
+ if (attributePath in mockData) {
424
+ const currentValue = mockData[attributePath];
425
+ const { shouldChange, newValue } = getEnforcedValue(currentValue, comparison, valueType);
426
+ if (shouldChange) {
427
+ mockData[attributePath] = newValue;
428
+ return { found: true, newValue };
429
+ }
430
+ return { found: true, newValue: currentValue };
431
+ }
432
+ // Strategy 2: Search in nested objects
433
+ for (const [key, value] of Object.entries(mockData)) {
434
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
435
+ const nestedObj = value;
436
+ // Check if attributePath exists in this nested object
437
+ if (attributePath in nestedObj) {
438
+ const currentValue = nestedObj[attributePath];
439
+ const { shouldChange, newValue } = getEnforcedValue(currentValue, comparison, valueType);
440
+ if (shouldChange) {
441
+ nestedObj[attributePath] = newValue;
442
+ return { found: true, newValue };
443
+ }
444
+ return { found: true, newValue: currentValue };
445
+ }
446
+ // Also check dot-notation paths (e.g., "diffView.type")
447
+ if (attributePath.includes('.')) {
448
+ const parts = attributePath.split('.');
449
+ const firstPart = parts[0];
450
+ if (firstPart in nestedObj) {
451
+ // Recurse with the rest of the path
452
+ const result = findAndSetValueInMockData(nestedObj, attributePath, comparison, valueType);
453
+ if (result.found)
454
+ return result;
455
+ }
456
+ }
457
+ // Recursively search deeper
458
+ const result = findAndSetValueInMockData(nestedObj, attributePath, comparison, valueType);
459
+ if (result.found)
460
+ return result;
461
+ }
462
+ }
463
+ return { found: false };
464
+ }
465
+ /**
466
+ * Determine if a value should be changed to match a comparison requirement.
467
+ *
468
+ * For 'falsy' comparison: truthy values should become null
469
+ * For 'truthy' comparison: falsy values should become a default truthy value
470
+ */
471
+ function getEnforcedValue(currentValue, comparison, valueType) {
472
+ const isTruthy = Boolean(currentValue);
473
+ if (comparison === 'falsy') {
474
+ // Value should be falsy
475
+ if (isTruthy) {
476
+ return { shouldChange: true, newValue: null };
477
+ }
478
+ return { shouldChange: false, newValue: currentValue };
479
+ }
480
+ if (comparison === 'truthy') {
481
+ // Value should be truthy
482
+ if (!isTruthy) {
483
+ // Generate a default truthy value based on valueType
484
+ const defaultValue = generateDefaultTruthyValue(valueType);
485
+ return { shouldChange: true, newValue: defaultValue };
486
+ }
487
+ return { shouldChange: false, newValue: currentValue };
488
+ }
489
+ // For other comparisons (equals, exists, etc.), don't auto-enforce
490
+ return { shouldChange: false, newValue: currentValue };
491
+ }
492
+ /**
493
+ * Generate a default truthy value for a given type.
494
+ */
495
+ function generateDefaultTruthyValue(valueType) {
496
+ if (!valueType)
497
+ return { _placeholder: true };
498
+ switch (valueType.toLowerCase()) {
499
+ case 'string':
500
+ return 'default-value';
501
+ case 'number':
502
+ return 1;
503
+ case 'boolean':
504
+ return true;
505
+ case 'array':
506
+ return [{ _placeholder: true }];
507
+ case 'object':
508
+ default:
509
+ return { _placeholder: true };
510
+ }
511
+ }
93
512
  /**
94
513
  * For Default Scenario only: detect missing mockData keys and make a follow-up
95
514
  * LLM call to fill them in. This handles cases where the LLM completes normally
@@ -144,8 +563,81 @@ async function fillMissingMockDataKeys({ structure, scenario, executionFlows, fu
144
563
  }
145
564
  }
146
565
  export async function generateDataForScenario({ entity, structure, scenario, executionFlows, defaultScenarioData, incompleteResponse, analysis, model, }) {
566
+ var _a;
147
567
  awsLogDebugLevel(1, `Generating data for ${entity.name}: ${scenario.name}`);
148
- const prompt = generateEntityScenarioDataGenerator(structure, scenario, executionFlows, defaultScenarioData, incompleteResponse);
568
+ // Check if we should chunk the data structure for focused processing
569
+ let chunkedMockData;
570
+ const coveredFlowIds = scenario.metadata?.coveredFlows || [];
571
+ if (structure.dataForMocks &&
572
+ !incompleteResponse // Don't do chunked calls on continuation
573
+ ) {
574
+ const chunks = chunkDataStructure(structure.dataForMocks);
575
+ // If we have multiple chunks, process each one with a focused call
576
+ if (chunks.length > 1) {
577
+ awsLog(`Data structure has ${Object.keys(structure.dataForMocks).length} keys, splitting into ${chunks.length} chunks for focused processing`);
578
+ chunkedMockData = {};
579
+ for (let i = 0; i < chunks.length; i++) {
580
+ const chunk = chunks[i];
581
+ const chunkKeys = Object.keys(chunk || {});
582
+ // Get relevant requiredValues for this chunk
583
+ const relevantRequiredValues = getRequiredValuesForChunk(chunk, executionFlows || [], coveredFlowIds);
584
+ awsLog(`Processing chunk ${i + 1}/${chunks.length}: ${chunkKeys.join(', ')}`);
585
+ const chunkPrompt = generateChunkPrompt({
586
+ scenario,
587
+ chunk,
588
+ chunkIndex: i,
589
+ totalChunks: chunks.length,
590
+ relevantRequiredValues,
591
+ });
592
+ const chunkResponse = await completionCall({
593
+ type: 'generateChunkMockData',
594
+ systemMessage: generateChunkSystemMessage(scenario.name),
595
+ prompt: chunkPrompt,
596
+ model,
597
+ });
598
+ // Save chunk call to LLM log for replay support
599
+ await saveLlmCall({
600
+ object_type: 'analysis',
601
+ object_id: analysis.id,
602
+ propsJson: {
603
+ entity: { name: entity.name, filePath: entity.filePath },
604
+ scenario: { name: scenario.name },
605
+ chunkIndex: i,
606
+ totalChunks: chunks.length,
607
+ },
608
+ ...chunkResponse.stats,
609
+ });
610
+ if (chunkResponse.completion) {
611
+ const validJson = validateJson(chunkResponse.completion);
612
+ const parsed = parseJsonSafe(validJson);
613
+ if (parsed && typeof parsed === 'object' && 'mockData' in parsed) {
614
+ const chunkMockData = parsed.mockData;
615
+ if (chunkMockData && typeof chunkMockData === 'object') {
616
+ Object.assign(chunkedMockData, chunkMockData);
617
+ awsLog(`Chunk ${i + 1} generated data for: ${Object.keys(chunkMockData).join(', ')}`);
618
+ }
619
+ }
620
+ }
621
+ }
622
+ // Detect keys that were lost from failed or partial chunk responses
623
+ // and fill them with schema-based defaults so they aren't permanently lost.
624
+ const allChunkedKeys = chunks.flatMap((c) => Object.keys(c || {}));
625
+ const returnedKeys = new Set(Object.keys(chunkedMockData));
626
+ const missingChunkKeys = allChunkedKeys.filter((k) => !returnedKeys.has(k));
627
+ if (missingChunkKeys.length > 0) {
628
+ awsLog(`Chunked processing: ${missingChunkKeys.length} key(s) missing from chunk results, filling with defaults: ${missingChunkKeys.join(', ')}`);
629
+ const dataForMocksRecord = structure.dataForMocks;
630
+ for (const key of missingChunkKeys) {
631
+ chunkedMockData[key] = generateDefaultForSchemaType(dataForMocksRecord[key]);
632
+ }
633
+ }
634
+ awsLog(`Chunked processing complete. Generated ${Object.keys(chunkedMockData).length} keys total`);
635
+ }
636
+ }
637
+ // When we have chunked mock data with actual content, tell the main prompt to skip mockData generation
638
+ // Important: Check for actual keys, not just truthy object, because {} would skip generation incorrectly
639
+ const hasChunkedData = chunkedMockData && Object.keys(chunkedMockData).length > 0;
640
+ const prompt = generateEntityScenarioDataGenerator(structure, scenario, executionFlows, defaultScenarioData, incompleteResponse, { mockDataAlreadyGenerated: hasChunkedData });
149
641
  const isDefault = scenario.name === DEFAULT_SCENARIO_NAME;
150
642
  const response = await completionCall({
151
643
  type: 'generateEntityScenarioData',
@@ -267,13 +759,37 @@ export async function generateDataForScenario({ entity, structure, scenario, exe
267
759
  }
268
760
  }
269
761
  }
270
- if (structure.dataForMocks && !fullScenarioData.data.mockData) {
271
- fullScenarioData.data.mockData = {};
272
- for (const propKey of Object.keys(structure.arguments)) {
273
- const dataAsAny = fullScenarioData.data;
274
- fullScenarioData.data.mockData[propKey] = dataAsAny[propKey];
762
+ // Merge flat-level mock data into mockData.
763
+ // Sometimes the LLM returns some data inside data.mockData but other data at the flat
764
+ // data level (e.g., data.useRouter() instead of data.mockData.useRouter()).
765
+ // This code ensures all dataForMocks keys end up in mockData.
766
+ if (structure.dataForMocks) {
767
+ (_a = fullScenarioData.data).mockData || (_a.mockData = {});
768
+ const dataAsAny = fullScenarioData.data;
769
+ for (const propKey of Object.keys(structure.dataForMocks)) {
770
+ // Only copy if it exists at flat level and not already in mockData
771
+ if (dataAsAny[propKey] !== undefined &&
772
+ !fullScenarioData.data.mockData[propKey]) {
773
+ fullScenarioData.data.mockData[propKey] = dataAsAny[propKey];
774
+ }
275
775
  }
276
776
  }
777
+ // Merge chunked mock data from focused calls (takes priority over main call's data)
778
+ // This ensures keys processed with focused attention are correctly generated.
779
+ if (chunkedMockData && fullScenarioData.data.mockData) {
780
+ for (const [key, value] of Object.entries(chunkedMockData)) {
781
+ // Chunked data takes priority - overwrite main call's potentially wrong data
782
+ fullScenarioData.data.mockData[key] = value;
783
+ }
784
+ awsLog(`Merged chunked mock data for keys: ${Object.keys(chunkedMockData).join(', ')}`);
785
+ }
786
+ // Relocate misplaced nested keys to their correct position.
787
+ // The LLM sometimes places nested keys at root level instead of inside their
788
+ // parent object (e.g., 'fastener' at root instead of inside 'trpc').
789
+ // This ensures the mockData structure matches the dataForMocks schema.
790
+ if (structure.dataForMocks && fullScenarioData.data.mockData) {
791
+ relocateMisplacedNestedKeys(fullScenarioData.data.mockData, structure.dataForMocks);
792
+ }
277
793
  // Convert null values to undefined based on schema type constraints.
278
794
  // LLM uses null for "no value" (JSON doesn't support undefined), but TypeScript
279
795
  // types like "string | undefined" don't accept null. This converts null→undefined
@@ -281,6 +797,46 @@ export async function generateDataForScenario({ entity, structure, scenario, exe
281
797
  if (structure.dataForMocks && fullScenarioData.data.mockData) {
282
798
  convertNullToUndefinedBySchema(fullScenarioData.data.mockData, structure.dataForMocks);
283
799
  }
800
+ // Coerce objects/arrays to primitives when the schema expects a primitive type.
801
+ // The LLM sometimes generates an object where the schema expects "string",
802
+ // e.g., { body: { "env": "production" } } instead of { body: "some string" }.
803
+ // This causes runtime errors like "TypeError: body.match is not a function".
804
+ // Must run BEFORE convertCommaSeparatedStringsToArrays, which intentionally
805
+ // overrides schema types for array-like field names.
806
+ if (structure.dataForMocks && fullScenarioData.data.mockData) {
807
+ coerceObjectsToPrimitivesBySchema(fullScenarioData.data.mockData, structure.dataForMocks);
808
+ }
809
+ // Convert comma-separated strings to arrays when appropriate.
810
+ // The LLM sometimes generates strings like "color,size" instead of arrays
811
+ // like ["color", "size"] when the schema type is incorrectly inferred as
812
+ // 'string' instead of 'string[]'. This causes runtime errors when code
813
+ // calls array methods like .map() on the value.
814
+ if (fullScenarioData.data.mockData) {
815
+ convertCommaSeparatedStringsToArrays(fullScenarioData.data.mockData);
816
+ }
817
+ // Convert type annotation strings that appear as values to actual values.
818
+ // The LLM sometimes echoes the schema type annotation as the value.
819
+ // For example, if the schema says { filePath: "string | undefined" },
820
+ // the LLM might return { filePath: "string | undefined" } instead of
821
+ // generating an actual value. This converts those type strings to
822
+ // appropriate default values (e.g., "string | undefined" → undefined).
823
+ if (fullScenarioData.data.mockData) {
824
+ convertTypeAnnotationsToValues(fullScenarioData.data.mockData);
825
+ }
826
+ // Fix null values for ID fields when the schema indicates they should be non-null.
827
+ // The LLM sometimes generates `null` for ID fields (e.g., `"id": null`) when
828
+ // the schema type is `"number"`. This causes runtime issues when code checks
829
+ // `if (!data?.id)` expecting a truthy value.
830
+ if (structure.dataForMocks && fullScenarioData.data.mockData) {
831
+ fixNullIdsBySchema(fullScenarioData.data.mockData, structure.dataForMocks);
832
+ }
833
+ // Enforce execution flow requiredValues by setting falsy paths to null.
834
+ // The LLM doesn't reliably generate null for falsy requirements (e.g., diffView: falsy
835
+ // to hide a modal). This post-processing ensures that scenarios match their
836
+ // covered flows' requiredValues.
837
+ if (fullScenarioData.data.mockData && executionFlows) {
838
+ enforceRequiredValues(fullScenarioData.data.mockData, scenario.metadata?.coveredFlows || [], executionFlows);
839
+ }
284
840
  if (structure.arguments && fullScenarioData.data.argumentsData) {
285
841
  for (let i = 0; i < fullScenarioData.data.argumentsData.length; i++) {
286
842
  if (structure.arguments[i]) {
@@ -288,7 +844,8 @@ export async function generateDataForScenario({ entity, structure, scenario, exe
288
844
  }
289
845
  }
290
846
  }
291
- // For Default Scenario only: check for missing keys and make follow-up call if needed
847
+ // For Default Scenario only: check for missing keys and make follow-up call if needed.
848
+ // This tries to get better-quality data via LLM before falling back to defaults.
292
849
  if (isDefault) {
293
850
  await fillMissingMockDataKeys({
294
851
  structure,
@@ -298,6 +855,21 @@ export async function generateDataForScenario({ entity, structure, scenario, exe
298
855
  model,
299
856
  });
300
857
  }
858
+ // Fill in missing mock data keys with default values (after trying LLM follow-up).
859
+ // The LLM sometimes doesn't generate data for all keys in large schemas.
860
+ // This ensures all dataForMocks keys have corresponding data to prevent
861
+ // runtime errors like "Cannot read properties of undefined".
862
+ // Only run for Default Scenario - non-default scenarios will get missing
863
+ // data filled in from the merge with default scenario data.
864
+ if (isDefault && structure.dataForMocks && fullScenarioData.data.mockData) {
865
+ fillMissingMockDataKeysWithDefaults(fullScenarioData.data.mockData, structure.dataForMocks);
866
+ }
867
+ // Track the final scenario data for E2E debugging
868
+ trackDataSnapshot('generateDataForScenario_result', {
869
+ scenarioName: scenario.name,
870
+ mockData: fullScenarioData.data.mockData,
871
+ argumentsData: fullScenarioData.data.argumentsData,
872
+ }, entity.name, scenario.name);
301
873
  return {
302
874
  scenarioData: fullScenarioData,
303
875
  llmCall: { name: scenario.name, id: llmCall.id },
@@ -394,6 +966,46 @@ export default async function generateEntityScenarioData({ entity, structure, sc
394
966
  scenarioData.data.argumentsData =
395
967
  defaultScenarioData.data.argumentsData.map((arg) => ({ ...arg }));
396
968
  }
969
+ // Enforce requiredValues AFTER merge for non-default scenarios
970
+ // This ensures that if a non-default scenario doesn't cover a certain flow,
971
+ // it inherits the enforcement from the default scenario
972
+ if (scenarioData.data?.mockData && executionFlows) {
973
+ // Get the flows covered by this scenario
974
+ const scenarioCoveredFlows = nonDefaultScenarios.find((s) => s.name === result.scenarioData.scenarioDescription)?.metadata?.coveredFlows || [];
975
+ // Get the paths that the scenario's flows affect
976
+ const scenarioAffectedPaths = new Set();
977
+ for (const flowId of scenarioCoveredFlows) {
978
+ const flow = executionFlows.find((f) => f.id === flowId);
979
+ if (flow?.requiredValues) {
980
+ for (const rv of flow.requiredValues) {
981
+ if (rv.attributePath) {
982
+ // Extract base path (e.g., "diffView" from "diffView.type")
983
+ const basePath = rv.attributePath.split('.')[0];
984
+ scenarioAffectedPaths.add(basePath);
985
+ }
986
+ }
987
+ }
988
+ }
989
+ // Get the default scenario's flows
990
+ const defaultCoveredFlows = defaultScenario.metadata?.coveredFlows || [];
991
+ // For paths NOT affected by the scenario, apply default's enforcement
992
+ const defaultFlowsForUnaffectedPaths = defaultCoveredFlows.filter((flowId) => {
993
+ const flow = executionFlows.find((f) => f.id === flowId);
994
+ if (!flow?.requiredValues)
995
+ return false;
996
+ // Check if this flow affects a path that the scenario doesn't cover
997
+ return flow.requiredValues.some((rv) => {
998
+ if (!rv.attributePath)
999
+ return false;
1000
+ const basePath = rv.attributePath.split('.')[0];
1001
+ return !scenarioAffectedPaths.has(basePath);
1002
+ });
1003
+ });
1004
+ // Apply enforcement from default scenario for unaffected paths
1005
+ if (defaultFlowsForUnaffectedPaths.length > 0) {
1006
+ enforceRequiredValues(scenarioData.data.mockData, defaultFlowsForUnaffectedPaths, executionFlows);
1007
+ }
1008
+ }
397
1009
  return scenarioData;
398
1010
  });
399
1011
  scenarioDatas.push(...mergedScenarioDatas);
@@ -417,7 +1029,8 @@ Generate COMPLETE, robust data for the entire data structure.
417
1029
  : `## Non-Default Scenario
418
1030
  Generate ONLY the differences from the default scenario.
419
1031
  - Include only fields that need to change
420
- - Set to \`null\` to remove data
1032
+ - For object/scalar fields: set to \`null\` to remove/unset the data
1033
+ - For array fields: use \`[]\` for empty arrays (not \`null\`) unless the schema type explicitly includes \`| null\`
421
1034
  - Omit unchanged fields—they merge from default`;
422
1035
  // Only include the "NO ERROR DATA" instruction when the scenario doesn't require error data
423
1036
  const noErrorDataInstruction = requiresErrorData
@@ -448,6 +1061,17 @@ For example, if a flow requires:
448
1061
  \`\`\`
449
1062
  Then set \`isLoading: false\` in the mockData.
450
1063
 
1064
+ ### Array Length Requirements (length< and length>)
1065
+ For array size variation flows:
1066
+ - \`comparison: "length<"\` with \`value: "0"\` → generate EMPTY array \`[]\`
1067
+ - \`comparison: "length<"\` with \`value: "3"\` → generate 1-2 items (few items)
1068
+ - \`comparison: "length>"\` with \`value: "10"\` → generate 12+ items (many items)
1069
+
1070
+ ### String Length Requirements (normal vs long)
1071
+ For text length variation flows:
1072
+ - \`value: "normal"\` with \`valueType: "string"\` → generate normal length text (10-50 chars)
1073
+ - \`value: "long"\` with \`valueType: "string"\` → generate LONG text (200+ chars) to test overflow/truncation
1074
+
451
1075
  ## CRITICAL: Blocking Flows to Avoid
452
1076
  If the scenario includes \`blockingFlowsToAvoid\`, these are flows (like modals, overlays) that would BLOCK the expected UI.
453
1077
  You MUST generate mock data that PREVENTS these flows from triggering:
@@ -488,6 +1112,7 @@ Use simple elements only (\`<div>\`, \`<span>\`). No custom components.
488
1112
  - Arrays should have many items (at least 4) unless specified otherwise
489
1113
  - Each item must follow the exact structure provided
490
1114
  - In general we want robust data, not minimal data unless specified otherwise
1115
+ - For empty arrays, use \`[]\` (not \`null\`) unless the schema type explicitly includes \`| null\` and the scenario requires the attribute be removed
491
1116
 
492
1117
  ## CRITICAL: Preserve Exact Structure
493
1118
  Your response MUST mirror the EXACT nested structure provided in mockData Structure.
@@ -542,6 +1167,8 @@ export const generateMissingKeysSystemMessage = () => `You are completing mock d
542
1167
 
543
1168
  Generate data ONLY for the missing keys provided in the prompt. Do not skip any of them.
544
1169
 
1170
+ - Scenario name must match exactly: "Default Scenario"
1171
+
545
1172
  ## Special Markers
546
1173
 
547
1174
  ### Dynamic Dates (\`~~codeyam-code~~\`)
@@ -559,6 +1186,7 @@ Use simple elements only (\`<div>\`, \`<span>\`). No custom components.
559
1186
  ### Arrays
560
1187
  - Arrays should have many items (at least 4) unless specified otherwise
561
1188
  - Each item must follow the exact structure provided
1189
+ - For empty arrays, use \`[]\` (not \`null\`) unless the schema type explicitly includes \`| null\` and the scenario requires the attribute be removed
562
1190
 
563
1191
  ## CRITICAL: Preserve Exact Structure
564
1192
  Your response MUST mirror the EXACT nested structure provided for the missing keys.
@@ -585,4 +1213,102 @@ NEVER include "error" fields in responses. Skip them entirely.
585
1213
  - No \`undefined\`—use \`null\` or omit
586
1214
  - No data references (can't use \`posts[0]\` elsewhere — duplicate the value)
587
1215
  `;
1216
+ /**
1217
+ * System message for focused calls to generate critical mockData keys.
1218
+ * These are keys referenced by the scenario's execution flow requiredValues.
1219
+ */
1220
+ export const generateCriticalKeysSystemMessage = (scenarioName) => `You are generating mock data for CRITICAL keys that control scenario behavior.
1221
+
1222
+ These keys are referenced by the execution flow's requiredValues - they directly determine
1223
+ what the component renders. Pay EXTRA attention to matching the exact structure and values.
1224
+
1225
+ - Scenario name must match exactly: "${scenarioName}"
1226
+
1227
+ ## CRITICAL: Special Characters in Keys
1228
+ Keys like \`*\` are LITERAL string keys, NOT wildcards or patterns.
1229
+ - If the schema shows \`{ "*": "string" }\`, generate \`{ "*": "some value" }\`
1230
+ - Do NOT interpret \`*\` as "any key" - use it as an actual key name
1231
+
1232
+ ## CRITICAL: Preserve Exact Structure
1233
+ Your response MUST mirror the EXACT nested structure provided.
1234
+ - Copy key strings EXACTLY as shown (including special characters)
1235
+ - Only change leaf VALUES (replacing type descriptions with actual data)
1236
+ - Do NOT modify keys, type parameters, or add extra keys
1237
+
1238
+ ## Matching requiredValues
1239
+ When the prompt shows requiredValues like:
1240
+ - \`attributePath: "useParams().functionCallReturnValue.*"\`
1241
+ - \`value: "scenarios"\`
1242
+
1243
+ This means set the \`*\` key to include "scenarios". For URL paths split by \`/\`,
1244
+ generate a path like \`"scenarios/id/mode"\` where segments match requirements.
1245
+
1246
+ ## Response Format
1247
+ \`\`\`json
1248
+ {
1249
+ "scenarioData": {
1250
+ "scenarioName": "${scenarioName}",
1251
+ "data": {
1252
+ "mockData": {
1253
+ // generate data for ONLY the critical keys
1254
+ }
1255
+ }
1256
+ }
1257
+ }
1258
+ \`\`\`
1259
+
1260
+ ## Rules
1261
+ - Valid JSON only
1262
+ - No \`undefined\`—use \`null\` or omit
1263
+ - Match the exact schema structure provided
1264
+ `;
1265
+ /**
1266
+ * System message for focused calls to generate mock data for a chunk of keys.
1267
+ * Used when data structures are large and need to be processed in smaller pieces.
1268
+ */
1269
+ export const generateChunkSystemMessage = (scenarioName) => `You are generating mock data for a SUBSET of keys from a larger data structure.
1270
+
1271
+ This chunk contains fewer keys so you can focus on generating HIGH QUALITY data for each one.
1272
+ Pay EXTRA attention to matching the exact structure and values for each key.
1273
+
1274
+ - Scenario name must match exactly: "${scenarioName}"
1275
+
1276
+ ## CRITICAL: Special Characters in Keys
1277
+ Keys like \`*\` are LITERAL string keys, NOT wildcards or patterns.
1278
+ - If the schema shows \`{ "*": "string" }\`, generate \`{ "*": "some value" }\`
1279
+ - Do NOT interpret \`*\` as "any key" - use it as an actual key name
1280
+
1281
+ ## CRITICAL: Preserve Exact Structure
1282
+ Your response MUST mirror the EXACT nested structure provided.
1283
+ - Copy key strings EXACTLY as shown (including special characters)
1284
+ - Only change leaf VALUES (replacing type descriptions with actual data)
1285
+ - Do NOT modify keys, type parameters, or add extra keys
1286
+
1287
+ ## Matching requiredValues
1288
+ If the prompt includes requiredValues, these are specific values that MUST be set:
1289
+ - For \`attributePath: "useParams().functionCallReturnValue.*"\` with \`value: "scenarios"\`
1290
+ → Set the \`*\` key to include "scenarios" (e.g., "scenarios/id/mode")
1291
+ - For URL paths, generate realistic paths that satisfy the requirements
1292
+
1293
+ ## CRITICAL: NO ERROR DATA
1294
+ NEVER include "error" fields in responses. Skip them entirely.
1295
+ - If structure has \`{ data: {...}, error: {...} }\`, only fill \`data\`
1296
+ - Leave out any attribute named "error"—do not set to null, omit entirely
1297
+
1298
+ ## Response Format
1299
+ \`\`\`json
1300
+ {
1301
+ "mockData": {
1302
+ // generate data for ONLY the keys in this chunk
1303
+ }
1304
+ }
1305
+ \`\`\`
1306
+
1307
+ ## Rules
1308
+ - Valid JSON only
1309
+ - No \`undefined\`—use \`null\` or omit
1310
+ - Generate data for ALL keys in the chunk (don't skip any)
1311
+ - Arrays should have many items (at least 4) unless specified otherwise
1312
+ - For empty arrays, use \`[]\` (not \`null\`) unless the schema type explicitly includes \`| null\` and the scenario requires the attribute be removed
1313
+ `;
588
1314
  //# sourceMappingURL=generateEntityScenarioData.js.map