@codeyam/codeyam-cli 0.1.0-staging.1669d45 → 0.1.0-staging.323686

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 (362) 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 +3 -3
  4. package/analyzer-template/packages/ai/index.ts +9 -1
  5. package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +48 -34
  6. package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
  7. package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +31 -0
  8. package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +139 -23
  9. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +6 -126
  10. package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +277 -8
  11. package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +73 -1
  12. package/analyzer-template/packages/ai/src/lib/completionCall.ts +198 -34
  13. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +108 -1
  14. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +205 -0
  15. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +10 -2
  16. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +23 -0
  17. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +87 -2
  18. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +32 -7
  19. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
  20. package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +156 -0
  21. package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
  22. package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
  23. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +626 -6
  24. package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +26 -1
  25. package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +375 -6
  26. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +1003 -45
  27. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
  28. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
  29. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
  30. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +23 -6
  31. package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
  32. package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +154 -32
  33. package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +22 -1
  34. package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +114 -2
  35. package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
  36. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +10 -13
  37. package/analyzer-template/packages/analyze/src/lib/files/analyze/dependencyResolver.ts +6 -0
  38. package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -7
  39. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +142 -73
  40. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +42 -5
  41. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +1 -1
  42. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +77 -0
  43. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
  44. package/analyzer-template/packages/aws/package.json +1 -1
  45. package/analyzer-template/packages/database/src/lib/kysely/db.ts +8 -1
  46. package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
  47. package/analyzer-template/packages/database/src/lib/loadAnalyses.ts +58 -1
  48. package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +13 -0
  49. package/analyzer-template/packages/database/src/lib/loadBranch.ts +16 -1
  50. package/analyzer-template/packages/database/src/lib/loadCommit.ts +11 -0
  51. package/analyzer-template/packages/database/src/lib/loadCommits.ts +28 -0
  52. package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -3
  53. package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
  54. package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +7 -14
  55. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
  56. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +8 -1
  57. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
  58. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
  59. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts +1 -0
  60. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts.map +1 -1
  61. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js +3 -0
  62. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
  63. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts +2 -0
  64. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts.map +1 -1
  65. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js +45 -2
  66. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js.map +1 -1
  67. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
  68. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +8 -0
  69. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
  70. package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js +11 -1
  71. package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js.map +1 -1
  72. package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.d.ts.map +1 -1
  73. package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js +7 -0
  74. package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js.map +1 -1
  75. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts +3 -1
  76. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts.map +1 -1
  77. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +22 -1
  78. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js.map +1 -1
  79. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts +3 -1
  80. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
  81. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +23 -4
  82. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
  83. package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.d.ts.map +1 -1
  84. package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js +9 -0
  85. package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js.map +1 -1
  86. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts +2 -2
  87. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
  88. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +5 -4
  89. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
  90. package/analyzer-template/packages/github/dist/types/index.d.ts +1 -1
  91. package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
  92. package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
  93. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +25 -1
  94. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
  95. package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts +2 -0
  96. package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts.map +1 -1
  97. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +51 -1
  98. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  99. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
  100. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
  101. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
  102. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
  103. package/analyzer-template/packages/types/index.ts +1 -0
  104. package/analyzer-template/packages/types/src/types/Analysis.ts +25 -0
  105. package/analyzer-template/packages/types/src/types/Commit.ts +2 -0
  106. package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +64 -1
  107. package/analyzer-template/packages/utils/dist/types/index.d.ts +1 -1
  108. package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
  109. package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
  110. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +25 -1
  111. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
  112. package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts +2 -0
  113. package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts.map +1 -1
  114. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +51 -1
  115. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  116. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
  117. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
  118. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
  119. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
  120. package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
  121. package/analyzer-template/playwright/capture.ts +20 -8
  122. package/analyzer-template/playwright/captureStatic.ts +1 -1
  123. package/analyzer-template/project/analyzeBaselineCommit.ts +5 -0
  124. package/analyzer-template/project/analyzeRegularCommit.ts +5 -0
  125. package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
  126. package/analyzer-template/project/constructMockCode.ts +314 -29
  127. package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
  128. package/analyzer-template/project/loadReadyToBeCaptured.ts +65 -41
  129. package/analyzer-template/project/orchestrateCapture/AwsCaptureTaskRunner.ts +12 -4
  130. package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +18 -7
  131. package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
  132. package/analyzer-template/project/orchestrateCapture.ts +71 -6
  133. package/analyzer-template/project/reconcileMockDataKeys.ts +152 -9
  134. package/analyzer-template/project/runAnalysis.ts +4 -0
  135. package/analyzer-template/project/start.ts +35 -11
  136. package/analyzer-template/project/writeMockDataTsx.ts +114 -2
  137. package/analyzer-template/project/writeScenarioComponents.ts +101 -8
  138. package/analyzer-template/scripts/comboWorkerLoop.cjs +98 -50
  139. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +5 -0
  140. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
  141. package/background/src/lib/virtualized/project/analyzeRegularCommit.js +5 -0
  142. package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
  143. package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js +3 -3
  144. package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js.map +1 -1
  145. package/background/src/lib/virtualized/project/constructMockCode.js +255 -4
  146. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  147. package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js +73 -1
  148. package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js.map +1 -1
  149. package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js +19 -8
  150. package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js.map +1 -1
  151. package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js +2 -2
  152. package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js.map +1 -1
  153. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +7 -5
  154. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
  155. package/background/src/lib/virtualized/project/orchestrateCapture.js +58 -6
  156. package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
  157. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +126 -9
  158. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
  159. package/background/src/lib/virtualized/project/runAnalysis.js +3 -0
  160. package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
  161. package/background/src/lib/virtualized/project/start.js +32 -11
  162. package/background/src/lib/virtualized/project/start.js.map +1 -1
  163. package/background/src/lib/virtualized/project/writeMockDataTsx.js +89 -2
  164. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  165. package/background/src/lib/virtualized/project/writeScenarioComponents.js +57 -8
  166. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  167. package/codeyam-cli/src/cli.js +2 -0
  168. package/codeyam-cli/src/cli.js.map +1 -1
  169. package/codeyam-cli/src/commands/memory.js +273 -0
  170. package/codeyam-cli/src/commands/memory.js.map +1 -0
  171. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +4 -0
  172. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
  173. package/codeyam-cli/src/utils/analysisRunner.js +21 -2
  174. package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
  175. package/codeyam-cli/src/utils/install-skills.js +20 -6
  176. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  177. package/codeyam-cli/src/utils/queue/job.js +1 -0
  178. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  179. package/codeyam-cli/src/utils/queue/manager.js +6 -0
  180. package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
  181. package/codeyam-cli/src/utils/rules/index.js +5 -0
  182. package/codeyam-cli/src/utils/rules/index.js.map +1 -0
  183. package/codeyam-cli/src/utils/rules/parser.js +106 -0
  184. package/codeyam-cli/src/utils/rules/parser.js.map +1 -0
  185. package/codeyam-cli/src/utils/rules/pathMatcher.js +18 -0
  186. package/codeyam-cli/src/utils/rules/pathMatcher.js.map +1 -0
  187. package/codeyam-cli/src/utils/rules/staleness.js +132 -0
  188. package/codeyam-cli/src/utils/rules/staleness.js.map +1 -0
  189. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +2 -0
  190. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
  191. package/codeyam-cli/src/webserver/app/lib/database.js +7 -3
  192. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  193. package/codeyam-cli/src/webserver/bootstrap.js +40 -0
  194. package/codeyam-cli/src/webserver/bootstrap.js.map +1 -1
  195. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-DsN1wKrm.js +11 -0
  196. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-COi5OvsN.js → EntityTypeBadge-DLqD3qNt.js} +1 -1
  197. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-BwdQv49w.js → EntityTypeIcon-Ba2JVPzP.js} +1 -1
  198. package/codeyam-cli/src/webserver/build/client/assets/{InlineSpinner-CEleMv_j.js → InlineSpinner-C8lyxW9k.js} +1 -1
  199. package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-D68KarMg.js → InteractivePreview-aht4aafF.js} +2 -2
  200. package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-L75Wvqgw.js → LibraryFunctionPreview-CVtiBnY5.js} +1 -1
  201. package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-C53WM8qn.js → LoadingDots-B0GLXMsr.js} +1 -1
  202. package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-CrNkmy4i.js → LogViewer-xgeCVgSM.js} +1 -1
  203. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-OApQuNyq.js +16 -0
  204. package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-CQifa1n-.js → SafeScreenshot-DuDvi0jm.js} +1 -1
  205. package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-CyaBFX7l.js → ScenarioViewer-DzccYyI8.js} +3 -13
  206. package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-D36O1rzU.js → TruncatedFilePath-DyFZkK0l.js} +1 -1
  207. package/codeyam-cli/src/webserver/build/client/assets/_index-BwqWJOgH.js +11 -0
  208. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BwavGCpm.js +32 -0
  209. package/codeyam-cli/src/webserver/build/client/assets/api.health-l0sNRNKZ.js +1 -0
  210. package/codeyam-cli/src/webserver/build/client/assets/api.memory-profile-l0sNRNKZ.js +1 -0
  211. package/codeyam-cli/src/webserver/build/client/assets/api.restart-server-l0sNRNKZ.js +1 -0
  212. package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-DgTPh8H-.js → chevron-down-Cx24_aWc.js} +1 -1
  213. package/codeyam-cli/src/webserver/build/client/assets/{chunk-EPOLDU6W-DdQKK6on.js → chunk-EPOLDU6W-CXRTFQ3F.js} +1 -1
  214. package/codeyam-cli/src/webserver/build/client/assets/{circle-check-Dmr2bb1R.js → circle-check-BOARzkeR.js} +1 -1
  215. package/codeyam-cli/src/webserver/build/client/assets/copy-Bb-80kDT.js +6 -0
  216. package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-Do4ZLUYa.js → createLucideIcon-BdhJEx6B.js} +1 -1
  217. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-BBnGWYga.js +1 -0
  218. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-CbdFyxZh.js → entity._sha._-BJUiQqZF.js} +12 -12
  219. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-B4iCfs5M.js → entity._sha.scenarios._scenarioId.fullscreen-DavjRmOY.js} +1 -1
  220. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-wDWZZO1W.js → entity._sha_.create-scenario-D1T4TGjf.js} +1 -1
  221. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-BMbl7MeQ.js → entity._sha_.edit._scenarioId-CTBG2mmz.js} +1 -1
  222. package/codeyam-cli/src/webserver/build/client/assets/{entry.client-5wRKRIH9.js → entry.client-CS2cb_eZ.js} +1 -1
  223. package/codeyam-cli/src/webserver/build/client/assets/file-code-Dhef1kWN.js +6 -0
  224. package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DD3SDH7t.js → fileTableUtils-DMJ7zii9.js} +1 -1
  225. package/codeyam-cli/src/webserver/build/client/assets/files-CJ6lTdTA.js +1 -0
  226. package/codeyam-cli/src/webserver/build/client/assets/{git-zXjT7J0G.js → git-CPTZZ-JZ.js} +8 -8
  227. package/codeyam-cli/src/webserver/build/client/assets/globals-D3yhhV8x.css +1 -0
  228. package/codeyam-cli/src/webserver/build/client/assets/{index-DLbXwndH.js → index-B1h680n5.js} +1 -1
  229. package/codeyam-cli/src/webserver/build/client/assets/{index-gPZ-lad1.js → index-lzqtyFU8.js} +1 -1
  230. package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-BsPXJ81F.js → loader-circle-B7B9V-bu.js} +1 -1
  231. package/codeyam-cli/src/webserver/build/client/assets/manifest-7522edd4.js +1 -0
  232. package/codeyam-cli/src/webserver/build/client/assets/memory-yxFcrxBX.js +92 -0
  233. package/codeyam-cli/src/webserver/build/client/assets/root-eVAaavTS.js +62 -0
  234. package/codeyam-cli/src/webserver/build/client/assets/{search-P2FKIUql.js → search-CxXUmBSd.js} +1 -1
  235. package/codeyam-cli/src/webserver/build/client/assets/{settings-B2eDuBj8.js → settings-CS5f3WzT.js} +1 -1
  236. package/codeyam-cli/src/webserver/build/client/assets/{simulations-L18M6-kN.js → simulations-DwFIBT09.js} +1 -1
  237. package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-BDz7kbVA.js → triangle-alert-B6LgvRJg.js} +1 -1
  238. package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-29dDmbH8.js → useCustomSizes-C1v1PQzo.js} +1 -1
  239. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-BUm0UVJm.js → useLastLogLine-aSv48UbS.js} +1 -1
  240. package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-CkIOKTrZ.js → useReportContext-DYxHZQuP.js} +1 -1
  241. package/codeyam-cli/src/webserver/build/client/assets/{useToast-KKw5kTn-.js → useToast-mBRpZPiu.js} +1 -1
  242. package/codeyam-cli/src/webserver/build/server/assets/index-DVzYx8PN.js +1 -0
  243. package/codeyam-cli/src/webserver/build/server/assets/server-build-4Cr0uToj.js +257 -0
  244. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  245. package/codeyam-cli/src/webserver/build-info.json +5 -5
  246. package/codeyam-cli/templates/codeyam-memory-hook.sh +200 -0
  247. package/codeyam-cli/templates/codeyam:debug.md +47 -3
  248. package/codeyam-cli/templates/codeyam:diagnose.md +203 -25
  249. package/codeyam-cli/templates/codeyam:memory.md +462 -0
  250. package/codeyam-cli/templates/codeyam:new-rule.md +13 -0
  251. package/package.json +8 -5
  252. package/packages/ai/index.js +5 -2
  253. package/packages/ai/index.js.map +1 -1
  254. package/packages/ai/src/lib/analyzeScope.js +41 -17
  255. package/packages/ai/src/lib/analyzeScope.js.map +1 -1
  256. package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
  257. package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
  258. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +24 -0
  259. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
  260. package/packages/ai/src/lib/astScopes/methodSemantics.js +109 -23
  261. package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
  262. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +1 -102
  263. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
  264. package/packages/ai/src/lib/astScopes/processExpression.js +228 -11
  265. package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
  266. package/packages/ai/src/lib/completionCall.js +161 -30
  267. package/packages/ai/src/lib/completionCall.js.map +1 -1
  268. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +86 -1
  269. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  270. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +179 -0
  271. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -1
  272. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +7 -1
  273. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
  274. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +19 -0
  275. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
  276. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +70 -2
  277. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
  278. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +29 -7
  279. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
  280. package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
  281. package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
  282. package/packages/ai/src/lib/dataStructureChunking.js +111 -0
  283. package/packages/ai/src/lib/dataStructureChunking.js.map +1 -0
  284. package/packages/ai/src/lib/e2eDataTracking.js +241 -0
  285. package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
  286. package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
  287. package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
  288. package/packages/ai/src/lib/generateEntityScenarioData.js +510 -7
  289. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  290. package/packages/ai/src/lib/generateEntityScenarios.js +19 -1
  291. package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
  292. package/packages/ai/src/lib/generateExecutionFlows.js +273 -4
  293. package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
  294. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +738 -40
  295. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -1
  296. package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
  297. package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
  298. package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
  299. package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
  300. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +15 -7
  301. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
  302. package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
  303. package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
  304. package/packages/ai/src/lib/resolvePathToControllable.js +131 -27
  305. package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -1
  306. package/packages/ai/src/lib/worker/SerializableDataStructure.js +7 -0
  307. package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
  308. package/packages/ai/src/lib/worker/analyzeScopeWorker.js +94 -1
  309. package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
  310. package/packages/analyze/src/lib/analysisContext.js +30 -5
  311. package/packages/analyze/src/lib/analysisContext.js.map +1 -1
  312. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +8 -4
  313. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  314. package/packages/analyze/src/lib/files/analyze/dependencyResolver.js +5 -0
  315. package/packages/analyze/src/lib/files/analyze/dependencyResolver.js.map +1 -1
  316. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -7
  317. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
  318. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +116 -66
  319. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
  320. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +37 -5
  321. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  322. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +1 -1
  323. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -1
  324. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +65 -0
  325. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  326. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
  327. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
  328. package/packages/database/src/lib/kysely/db.js +8 -1
  329. package/packages/database/src/lib/kysely/db.js.map +1 -1
  330. package/packages/database/src/lib/kysely/tables/commitsTable.js +3 -0
  331. package/packages/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
  332. package/packages/database/src/lib/loadAnalyses.js +45 -2
  333. package/packages/database/src/lib/loadAnalyses.js.map +1 -1
  334. package/packages/database/src/lib/loadAnalysis.js +8 -0
  335. package/packages/database/src/lib/loadAnalysis.js.map +1 -1
  336. package/packages/database/src/lib/loadBranch.js +11 -1
  337. package/packages/database/src/lib/loadBranch.js.map +1 -1
  338. package/packages/database/src/lib/loadCommit.js +7 -0
  339. package/packages/database/src/lib/loadCommit.js.map +1 -1
  340. package/packages/database/src/lib/loadCommits.js +22 -1
  341. package/packages/database/src/lib/loadCommits.js.map +1 -1
  342. package/packages/database/src/lib/loadEntities.js +23 -4
  343. package/packages/database/src/lib/loadEntities.js.map +1 -1
  344. package/packages/database/src/lib/loadEntityBranches.js +9 -0
  345. package/packages/database/src/lib/loadEntityBranches.js.map +1 -1
  346. package/packages/database/src/lib/updateCommitMetadata.js +5 -4
  347. package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
  348. package/packages/types/index.js.map +1 -1
  349. package/packages/utils/src/lib/safeFileName.js +29 -3
  350. package/packages/utils/src/lib/safeFileName.js.map +1 -1
  351. package/scripts/finalize-analyzer.cjs +3 -3
  352. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-vauWK972.js +0 -1
  353. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-DzJRkCkr.js +0 -11
  354. package/codeyam-cli/src/webserver/build/client/assets/_index-Be83mo_j.js +0 -11
  355. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BN6wu6Y-.js +0 -37
  356. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-Bn6aCAy_.js +0 -1
  357. package/codeyam-cli/src/webserver/build/client/assets/files-DKyMFI90.js +0 -1
  358. package/codeyam-cli/src/webserver/build/client/assets/globals-DTTQ3gY7.css +0 -1
  359. package/codeyam-cli/src/webserver/build/client/assets/manifest-22590fcf.js +0 -1
  360. package/codeyam-cli/src/webserver/build/client/assets/root-BsAarjAM.js +0 -57
  361. package/codeyam-cli/src/webserver/build/server/assets/index-BND5I5fv.js +0 -1
  362. package/codeyam-cli/src/webserver/build/server/assets/server-build-CFXnd7MG.js +0 -228
@@ -1,7 +1,9 @@
1
1
  import completionCall from './completionCall';
2
2
  import generateEntityScenarioDataGenerator from './promptGenerators/generateEntityScenarioDataGenerator';
3
3
  import generateMissingKeysPrompt from './promptGenerators/generateMissingKeysPrompt';
4
+ import generateChunkPrompt from './promptGenerators/generateChunkPrompt';
4
5
  import { saveLlmCall } from '~codeyam/aws/dynamodb';
6
+ import { trackDataSnapshot } from './e2eDataTracking';
5
7
  import type {
6
8
  Analysis,
7
9
  Entity,
@@ -14,6 +16,13 @@ import validateJson from './validateJson';
14
16
  import { awsLog, awsLogDebugLevel } from '~codeyam/utils';
15
17
  import { AI, parseJsonSafe } from '~codeyam/ai';
16
18
  import convertNullToUndefinedBySchema from './dataStructure/helpers/convertNullToUndefinedBySchema';
19
+ import fixNullIdsBySchema from './dataStructure/helpers/fixNullIdsBySchema';
20
+ import { JsonTypeDefinition } from '~codeyam/types';
21
+ import { deepMerge } from '~codeyam/generate';
22
+ import {
23
+ chunkDataStructure,
24
+ getRequiredValuesForChunk,
25
+ } from './dataStructureChunking';
17
26
 
18
27
  /**
19
28
  * Check if any of the scenario's covered flows require error data.
@@ -119,6 +128,337 @@ function deepMergeScenarioData(
119
128
 
120
129
  const DEFAULT_SCENARIO_NAME = 'Default Scenario';
121
130
 
131
+ /**
132
+ * Find the path to a key within a nested dataForMocks structure.
133
+ * Returns the path as an array of keys, or null if not found.
134
+ *
135
+ * @example
136
+ * // dataForMocks = { trpc: { fastener: { "useMutation()": { isLoading: "boolean" } } } }
137
+ * // findKeyPath("fastener", dataForMocks) returns ["trpc"]
138
+ */
139
+ function findKeyPath(
140
+ targetKey: string,
141
+ obj: JsonTypeDefinition,
142
+ currentPath: string[] = [],
143
+ ): string[] | null {
144
+ if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
145
+ return null;
146
+ }
147
+
148
+ for (const key of Object.keys(obj)) {
149
+ if (key === targetKey) {
150
+ return currentPath;
151
+ }
152
+
153
+ // Recursively search in nested objects
154
+ const nested = obj[key];
155
+ if (
156
+ typeof nested === 'object' &&
157
+ nested !== null &&
158
+ !Array.isArray(nested)
159
+ ) {
160
+ const result = findKeyPath(targetKey, nested as JsonTypeDefinition, [
161
+ ...currentPath,
162
+ key,
163
+ ]);
164
+ if (result !== null) {
165
+ return result;
166
+ }
167
+ }
168
+ }
169
+
170
+ return null;
171
+ }
172
+
173
+ /**
174
+ * Relocate misplaced nested keys in mockData to their correct position
175
+ * based on the dataForMocks structure.
176
+ *
177
+ * When the LLM returns mockData with keys at the wrong nesting level
178
+ * (e.g., { trpc: { quote: {...} }, fastener: {...} } when fastener should
179
+ * be inside trpc), this function moves them to the correct position.
180
+ *
181
+ * This function works recursively to handle nested misplacements, not just
182
+ * root-level ones. For example, if getQuote is at trpc.getQuote instead of
183
+ * trpc.quote.getQuote, it will be relocated.
184
+ *
185
+ * @example
186
+ * // dataForMocks: { trpc: { quote: {...}, fastener: {...} } }
187
+ * // mockData: { trpc: { quote: {...} }, fastener: {...} }
188
+ * // After: mockData: { trpc: { quote: {...}, fastener: {...} } }
189
+ *
190
+ * @example (nested case)
191
+ * // dataForMocks: { trpc: { quote: { getQuote: {...} } } }
192
+ * // mockData: { trpc: { quote: {...}, getQuote: {...} } }
193
+ * // After: mockData: { trpc: { quote: { getQuote: {...} } } }
194
+ */
195
+ function relocateMisplacedNestedKeys(
196
+ mockData: Record<string, unknown>,
197
+ dataForMocks: JsonTypeDefinition,
198
+ currentPathForLogging: string[] = [],
199
+ ): void {
200
+ if (typeof dataForMocks !== 'object' || dataForMocks === null) {
201
+ return;
202
+ }
203
+
204
+ const keysInSchema = Object.keys(dataForMocks);
205
+ const keysToRelocate: { key: string; path: string[] }[] = [];
206
+
207
+ // Find keys in mockData that are NOT at this level in dataForMocks
208
+ // but DO exist somewhere nested in dataForMocks
209
+ for (const key of Object.keys(mockData)) {
210
+ if (!keysInSchema.includes(key)) {
211
+ // This key is at this level in mockData but not at this level in dataForMocks
212
+ // Check if it exists somewhere nested in dataForMocks
213
+ const path = findKeyPath(key, dataForMocks);
214
+ if (path !== null && path.length > 0) {
215
+ keysToRelocate.push({ key, path });
216
+ }
217
+ }
218
+ }
219
+
220
+ // Relocate each misplaced key to its correct nested position
221
+ for (const { key, path } of keysToRelocate) {
222
+ const value = mockData[key];
223
+
224
+ // Navigate to the correct parent in mockData, creating nested objects if needed
225
+ let current: Record<string, unknown> = mockData;
226
+ for (const pathKey of path) {
227
+ if (current[pathKey] === undefined) {
228
+ current[pathKey] = {};
229
+ }
230
+ current = current[pathKey] as Record<string, unknown>;
231
+ }
232
+
233
+ // Deep merge the value into the correct location
234
+ // Use deep merge to preserve existing data at that location
235
+ if (current[key] !== undefined && typeof current[key] === 'object') {
236
+ current[key] = deepMerge(
237
+ current[key] as Record<string, unknown>,
238
+ value as Record<string, unknown>,
239
+ );
240
+ } else {
241
+ current[key] = value;
242
+ }
243
+
244
+ // Remove the key from its current (wrong) level
245
+ delete mockData[key];
246
+
247
+ const fullPath = [...currentPathForLogging, ...path].join('.');
248
+ awsLog(
249
+ `CodeYam: Relocated misplaced key "${key}" from [${currentPathForLogging.join('.')}] to [${fullPath}]`,
250
+ );
251
+ }
252
+
253
+ // Recursively process nested objects to handle deeply nested misplacements
254
+ for (const key of Object.keys(mockData)) {
255
+ const mockValue = mockData[key];
256
+ const schemaValue = dataForMocks[key];
257
+
258
+ // Only recurse if both mockData and schema have nested objects at this key
259
+ if (
260
+ typeof mockValue === 'object' &&
261
+ mockValue !== null &&
262
+ !Array.isArray(mockValue) &&
263
+ typeof schemaValue === 'object' &&
264
+ schemaValue !== null &&
265
+ !Array.isArray(schemaValue)
266
+ ) {
267
+ relocateMisplacedNestedKeys(
268
+ mockValue as Record<string, unknown>,
269
+ schemaValue as JsonTypeDefinition,
270
+ [...currentPathForLogging, key],
271
+ );
272
+ }
273
+ }
274
+ }
275
+
276
+ /**
277
+ * Generate default mock data for a schema type.
278
+ * Returns reasonable default values based on the schema type string.
279
+ */
280
+ function generateDefaultForSchemaType(schemaType: unknown): unknown {
281
+ if (typeof schemaType === 'string') {
282
+ // Handle common type strings
283
+ if (schemaType === 'function') return () => {};
284
+ if (schemaType === 'promise') return Promise.resolve();
285
+ if (schemaType === 'boolean') return false;
286
+ if (schemaType === 'string') return '';
287
+ if (schemaType === 'number') return 0;
288
+ if (schemaType.includes('number | undefined')) return undefined;
289
+ if (schemaType.includes('string | undefined')) return undefined;
290
+ if (schemaType.includes('boolean | undefined')) return undefined;
291
+ if (schemaType.includes('| undefined')) return undefined;
292
+ if (schemaType.includes('| null')) return null;
293
+ return schemaType; // Return the type as a string placeholder
294
+ }
295
+ if (
296
+ typeof schemaType === 'object' &&
297
+ schemaType !== null &&
298
+ !Array.isArray(schemaType)
299
+ ) {
300
+ // Recursively generate defaults for nested objects
301
+ const result: Record<string, unknown> = {};
302
+ for (const [key, value] of Object.entries(schemaType)) {
303
+ result[key] = generateDefaultForSchemaType(value);
304
+ }
305
+ return result;
306
+ }
307
+ return undefined;
308
+ }
309
+
310
+ /**
311
+ * Detect if a string should be converted to an array.
312
+ * Returns the array if the field appears to be an array field, or null if it should remain a string.
313
+ *
314
+ * This handles two cases:
315
+ * 1. Comma-separated values: "color,size" -> ["color", "size"]
316
+ * 2. Single values for array-named fields: "Finish" -> ["Finish"]
317
+ */
318
+ function parseCommaSeparatedStringAsArray(
319
+ value: string,
320
+ key: string,
321
+ ): string[] | null {
322
+ // Heuristic: if the key name suggests it's an array field, convert it
323
+ // Common patterns: *_attributes, *_ids, *_items, *_tags, *_values, plural names
324
+ // Check this FIRST because array-named fields should be converted regardless
325
+ // of whether they contain commas (single values become single-element arrays).
326
+ const arrayFieldPatterns = [
327
+ /_attributes$/i,
328
+ /_ids$/i,
329
+ /_items$/i,
330
+ /_tags$/i,
331
+ /_values$/i,
332
+ /_types$/i,
333
+ /_names$/i,
334
+ /_keys$/i,
335
+ /^attributes$/i,
336
+ /^items$/i,
337
+ /^tags$/i,
338
+ /^values$/i,
339
+ ];
340
+
341
+ const looksLikeArrayField = arrayFieldPatterns.some((pattern) =>
342
+ pattern.test(key),
343
+ );
344
+
345
+ if (looksLikeArrayField) {
346
+ // Skip newlines check - multiline values shouldn't be split
347
+ if (value.includes('\n')) {
348
+ return null;
349
+ }
350
+ // Split by comma and trim whitespace
351
+ const parts = value.split(',').map((s) => s.trim());
352
+ // Filter out empty strings - this handles both "Finish" -> ["Finish"]
353
+ // and "" -> []
354
+ return parts.filter((s) => s.length > 0);
355
+ }
356
+
357
+ // For non-array-named fields, only convert if there are commas
358
+ if (!value.includes(',')) {
359
+ return null;
360
+ }
361
+
362
+ // For non-array-named fields, apply stricter sentence detection
363
+ // Skip if it looks like a sentence (comma followed by space and lowercase)
364
+ if (/,\s+[a-z]/.test(value)) {
365
+ return null;
366
+ }
367
+ // Skip if it contains newlines (likely formatted text)
368
+ if (value.includes('\n')) {
369
+ return null;
370
+ }
371
+
372
+ return null;
373
+ }
374
+
375
+ /**
376
+ * Convert comma-separated string values to arrays when they look like array data.
377
+ * This handles cases where the LLM generates strings like "color,size" instead
378
+ * of arrays like ["color", "size"] due to schema type misdetection.
379
+ */
380
+ function convertCommaSeparatedStringsToArrays(
381
+ mockData: Record<string, unknown>,
382
+ ): void {
383
+ for (const [key, value] of Object.entries(mockData)) {
384
+ if (typeof value === 'string') {
385
+ const asArray = parseCommaSeparatedStringAsArray(value, key);
386
+ if (asArray !== null) {
387
+ mockData[key] = asArray;
388
+ awsLog(
389
+ `CodeYam: Converted comma-separated string to array for key "${key}": "${value}" -> [${asArray.map((s) => `"${s}"`).join(', ')}]`,
390
+ );
391
+ }
392
+ } else if (
393
+ value !== null &&
394
+ typeof value === 'object' &&
395
+ !Array.isArray(value)
396
+ ) {
397
+ // Recursively process nested objects
398
+ convertCommaSeparatedStringsToArrays(value as Record<string, unknown>);
399
+ } else if (Array.isArray(value)) {
400
+ // Recursively process arrays (each element could be an object)
401
+ for (const item of value) {
402
+ if (item !== null && typeof item === 'object' && !Array.isArray(item)) {
403
+ convertCommaSeparatedStringsToArrays(item as Record<string, unknown>);
404
+ }
405
+ }
406
+ }
407
+ }
408
+ }
409
+
410
+ /**
411
+ * Ensure all keys from dataForMocks have corresponding data in mockData.
412
+ * For missing keys, generate default values based on the schema.
413
+ * Recursively checks nested objects to fill in any missing nested fields.
414
+ */
415
+ function fillMissingMockDataKeysWithDefaults(
416
+ mockData: Record<string, unknown>,
417
+ dataForMocks: JsonTypeDefinition,
418
+ pathPrefix: string = '',
419
+ ): void {
420
+ if (typeof dataForMocks !== 'object' || dataForMocks === null) {
421
+ return;
422
+ }
423
+
424
+ const missingKeys: string[] = [];
425
+
426
+ for (const key of Object.keys(dataForMocks)) {
427
+ const fullPath = pathPrefix ? `${pathPrefix}.${key}` : key;
428
+
429
+ if (mockData[key] === undefined) {
430
+ missingKeys.push(fullPath);
431
+ // Generate default data based on schema
432
+ const schemaForKey = dataForMocks[key];
433
+ mockData[key] = generateDefaultForSchemaType(schemaForKey);
434
+ } else {
435
+ // Key exists, but if both are objects, recursively check for missing nested keys
436
+ const schemaValue = dataForMocks[key];
437
+ const mockValue = mockData[key];
438
+ if (
439
+ typeof schemaValue === 'object' &&
440
+ schemaValue !== null &&
441
+ !Array.isArray(schemaValue) &&
442
+ typeof mockValue === 'object' &&
443
+ mockValue !== null &&
444
+ !Array.isArray(mockValue)
445
+ ) {
446
+ fillMissingMockDataKeysWithDefaults(
447
+ mockValue as Record<string, unknown>,
448
+ schemaValue as JsonTypeDefinition,
449
+ fullPath,
450
+ );
451
+ }
452
+ }
453
+ }
454
+
455
+ if (missingKeys.length > 0) {
456
+ awsLog(
457
+ `CodeYam: Generated default mock data for ${missingKeys.length} missing key(s): ${missingKeys.slice(0, 10).join(', ')}${missingKeys.length > 10 ? '...' : ''}`,
458
+ );
459
+ }
460
+ }
461
+
122
462
  type ScenarioDataWithoutDescription = Omit<ScenarioData, 'scenarioDescription'>;
123
463
 
124
464
  interface GenerateEntityScenarioDataArgs {
@@ -236,12 +576,99 @@ export async function generateDataForScenario({
236
576
  }: GenerateDataForScenarioArgs) {
237
577
  awsLogDebugLevel(1, `Generating data for ${entity.name}: ${scenario.name}`);
238
578
 
579
+ // Check if we should chunk the data structure for focused processing
580
+ let chunkedMockData: Record<string, unknown> | undefined;
581
+ const coveredFlowIds = scenario.metadata?.coveredFlows || [];
582
+
583
+ if (
584
+ structure.dataForMocks &&
585
+ !incompleteResponse // Don't do chunked calls on continuation
586
+ ) {
587
+ const chunks = chunkDataStructure(structure.dataForMocks);
588
+
589
+ // If we have multiple chunks, process each one with a focused call
590
+ if (chunks.length > 1) {
591
+ awsLog(
592
+ `Data structure has ${Object.keys(structure.dataForMocks).length} keys, splitting into ${chunks.length} chunks for focused processing`,
593
+ );
594
+
595
+ chunkedMockData = {};
596
+
597
+ for (let i = 0; i < chunks.length; i++) {
598
+ const chunk = chunks[i];
599
+ const chunkKeys = Object.keys(chunk || {});
600
+
601
+ // Get relevant requiredValues for this chunk
602
+ const relevantRequiredValues = getRequiredValuesForChunk(
603
+ chunk,
604
+ executionFlows || [],
605
+ coveredFlowIds,
606
+ );
607
+
608
+ awsLog(
609
+ `Processing chunk ${i + 1}/${chunks.length}: ${chunkKeys.join(', ')}`,
610
+ );
611
+
612
+ const chunkPrompt = generateChunkPrompt({
613
+ scenario,
614
+ chunk,
615
+ chunkIndex: i,
616
+ totalChunks: chunks.length,
617
+ relevantRequiredValues,
618
+ });
619
+
620
+ const chunkResponse = await completionCall({
621
+ type: 'generateChunkMockData',
622
+ systemMessage: generateChunkSystemMessage(scenario.name),
623
+ prompt: chunkPrompt,
624
+ model,
625
+ });
626
+
627
+ // Save chunk call to LLM log for replay support
628
+ await saveLlmCall({
629
+ object_type: 'analysis',
630
+ object_id: analysis.id,
631
+ propsJson: {
632
+ entity: { name: entity.name, filePath: entity.filePath },
633
+ scenario: { name: scenario.name },
634
+ chunkIndex: i,
635
+ totalChunks: chunks.length,
636
+ },
637
+ ...chunkResponse.stats,
638
+ });
639
+
640
+ if (chunkResponse.completion) {
641
+ const validJson = validateJson(chunkResponse.completion);
642
+ const parsed = parseJsonSafe(validJson);
643
+ if (parsed && typeof parsed === 'object' && 'mockData' in parsed) {
644
+ const chunkMockData = (parsed as any).mockData;
645
+ if (chunkMockData && typeof chunkMockData === 'object') {
646
+ Object.assign(chunkedMockData, chunkMockData);
647
+ awsLog(
648
+ `Chunk ${i + 1} generated data for: ${Object.keys(chunkMockData).join(', ')}`,
649
+ );
650
+ }
651
+ }
652
+ }
653
+ }
654
+
655
+ awsLog(
656
+ `Chunked processing complete. Generated ${Object.keys(chunkedMockData).length} keys total`,
657
+ );
658
+ }
659
+ }
660
+
661
+ // When we have chunked mock data with actual content, tell the main prompt to skip mockData generation
662
+ // Important: Check for actual keys, not just truthy object, because {} would skip generation incorrectly
663
+ const hasChunkedData =
664
+ chunkedMockData && Object.keys(chunkedMockData).length > 0;
239
665
  const prompt = generateEntityScenarioDataGenerator(
240
666
  structure,
241
667
  scenario,
242
668
  executionFlows,
243
669
  defaultScenarioData,
244
670
  incompleteResponse,
671
+ { mockDataAlreadyGenerated: hasChunkedData },
245
672
  );
246
673
 
247
674
  const isDefault = scenario.name === DEFAULT_SCENARIO_NAME;
@@ -390,14 +817,47 @@ export async function generateDataForScenario({
390
817
  }
391
818
  }
392
819
 
393
- if (structure.dataForMocks && !fullScenarioData.data.mockData) {
394
- fullScenarioData.data.mockData = {};
395
- for (const propKey of Object.keys(structure.arguments)) {
396
- const dataAsAny = fullScenarioData.data as any;
397
- fullScenarioData.data.mockData[propKey] = dataAsAny[propKey];
820
+ // Merge flat-level mock data into mockData.
821
+ // Sometimes the LLM returns some data inside data.mockData but other data at the flat
822
+ // data level (e.g., data.useRouter() instead of data.mockData.useRouter()).
823
+ // This code ensures all dataForMocks keys end up in mockData.
824
+ if (structure.dataForMocks) {
825
+ fullScenarioData.data.mockData ||= {};
826
+ const dataAsAny = fullScenarioData.data as any;
827
+ for (const propKey of Object.keys(structure.dataForMocks)) {
828
+ // Only copy if it exists at flat level and not already in mockData
829
+ if (
830
+ dataAsAny[propKey] !== undefined &&
831
+ !fullScenarioData.data.mockData[propKey]
832
+ ) {
833
+ fullScenarioData.data.mockData[propKey] = dataAsAny[propKey];
834
+ }
398
835
  }
399
836
  }
400
837
 
838
+ // Merge chunked mock data from focused calls (takes priority over main call's data)
839
+ // This ensures keys processed with focused attention are correctly generated.
840
+ if (chunkedMockData && fullScenarioData.data.mockData) {
841
+ for (const [key, value] of Object.entries(chunkedMockData)) {
842
+ // Chunked data takes priority - overwrite main call's potentially wrong data
843
+ fullScenarioData.data.mockData[key] = value;
844
+ }
845
+ awsLog(
846
+ `Merged chunked mock data for keys: ${Object.keys(chunkedMockData).join(', ')}`,
847
+ );
848
+ }
849
+
850
+ // Relocate misplaced nested keys to their correct position.
851
+ // The LLM sometimes places nested keys at root level instead of inside their
852
+ // parent object (e.g., 'fastener' at root instead of inside 'trpc').
853
+ // This ensures the mockData structure matches the dataForMocks schema.
854
+ if (structure.dataForMocks && fullScenarioData.data.mockData) {
855
+ relocateMisplacedNestedKeys(
856
+ fullScenarioData.data.mockData,
857
+ structure.dataForMocks,
858
+ );
859
+ }
860
+
401
861
  // Convert null values to undefined based on schema type constraints.
402
862
  // LLM uses null for "no value" (JSON doesn't support undefined), but TypeScript
403
863
  // types like "string | undefined" don't accept null. This converts null→undefined
@@ -408,6 +868,24 @@ export async function generateDataForScenario({
408
868
  structure.dataForMocks,
409
869
  );
410
870
  }
871
+
872
+ // Convert comma-separated strings to arrays when appropriate.
873
+ // The LLM sometimes generates strings like "color,size" instead of arrays
874
+ // like ["color", "size"] when the schema type is incorrectly inferred as
875
+ // 'string' instead of 'string[]'. This causes runtime errors when code
876
+ // calls array methods like .map() on the value.
877
+ if (fullScenarioData.data.mockData) {
878
+ convertCommaSeparatedStringsToArrays(fullScenarioData.data.mockData);
879
+ }
880
+
881
+ // Fix null values for ID fields when the schema indicates they should be non-null.
882
+ // The LLM sometimes generates `null` for ID fields (e.g., `"id": null`) when
883
+ // the schema type is `"number"`. This causes runtime issues when code checks
884
+ // `if (!data?.id)` expecting a truthy value.
885
+ if (structure.dataForMocks && fullScenarioData.data.mockData) {
886
+ fixNullIdsBySchema(fullScenarioData.data.mockData, structure.dataForMocks);
887
+ }
888
+
411
889
  if (structure.arguments && fullScenarioData.data.argumentsData) {
412
890
  for (let i = 0; i < fullScenarioData.data.argumentsData.length; i++) {
413
891
  if (structure.arguments[i]) {
@@ -419,7 +897,8 @@ export async function generateDataForScenario({
419
897
  }
420
898
  }
421
899
 
422
- // For Default Scenario only: check for missing keys and make follow-up call if needed
900
+ // For Default Scenario only: check for missing keys and make follow-up call if needed.
901
+ // This tries to get better-quality data via LLM before falling back to defaults.
423
902
  if (isDefault) {
424
903
  await fillMissingMockDataKeys({
425
904
  structure,
@@ -430,6 +909,31 @@ export async function generateDataForScenario({
430
909
  });
431
910
  }
432
911
 
912
+ // Fill in missing mock data keys with default values (after trying LLM follow-up).
913
+ // The LLM sometimes doesn't generate data for all keys in large schemas.
914
+ // This ensures all dataForMocks keys have corresponding data to prevent
915
+ // runtime errors like "Cannot read properties of undefined".
916
+ // Only run for Default Scenario - non-default scenarios will get missing
917
+ // data filled in from the merge with default scenario data.
918
+ if (isDefault && structure.dataForMocks && fullScenarioData.data.mockData) {
919
+ fillMissingMockDataKeysWithDefaults(
920
+ fullScenarioData.data.mockData,
921
+ structure.dataForMocks,
922
+ );
923
+ }
924
+
925
+ // Track the final scenario data for E2E debugging
926
+ trackDataSnapshot(
927
+ 'generateDataForScenario_result',
928
+ {
929
+ scenarioName: scenario.name,
930
+ mockData: fullScenarioData.data.mockData,
931
+ argumentsData: fullScenarioData.data.argumentsData,
932
+ },
933
+ entity.name,
934
+ scenario.name,
935
+ );
936
+
433
937
  return {
434
938
  scenarioData: fullScenarioData,
435
939
  llmCall: { name: scenario.name, id: llmCall.id },
@@ -633,6 +1137,17 @@ For example, if a flow requires:
633
1137
  \`\`\`
634
1138
  Then set \`isLoading: false\` in the mockData.
635
1139
 
1140
+ ### Array Length Requirements (length< and length>)
1141
+ For array size variation flows:
1142
+ - \`comparison: "length<"\` with \`value: "0"\` → generate EMPTY array \`[]\`
1143
+ - \`comparison: "length<"\` with \`value: "3"\` → generate 1-2 items (few items)
1144
+ - \`comparison: "length>"\` with \`value: "10"\` → generate 12+ items (many items)
1145
+
1146
+ ### String Length Requirements (normal vs long)
1147
+ For text length variation flows:
1148
+ - \`value: "normal"\` with \`valueType: "string"\` → generate normal length text (10-50 chars)
1149
+ - \`value: "long"\` with \`valueType: "string"\` → generate LONG text (200+ chars) to test overflow/truncation
1150
+
636
1151
  ## CRITICAL: Blocking Flows to Avoid
637
1152
  If the scenario includes \`blockingFlowsToAvoid\`, these are flows (like modals, overlays) that would BLOCK the expected UI.
638
1153
  You MUST generate mock data that PREVENTS these flows from triggering:
@@ -733,6 +1248,8 @@ export const generateMissingKeysSystemMessage =
733
1248
 
734
1249
  Generate data ONLY for the missing keys provided in the prompt. Do not skip any of them.
735
1250
 
1251
+ - Scenario name must match exactly: "Default Scenario"
1252
+
736
1253
  ## Special Markers
737
1254
 
738
1255
  ### Dynamic Dates (\`~~codeyam-code~~\`)
@@ -776,3 +1293,106 @@ NEVER include "error" fields in responses. Skip them entirely.
776
1293
  - No \`undefined\`—use \`null\` or omit
777
1294
  - No data references (can't use \`posts[0]\` elsewhere — duplicate the value)
778
1295
  `;
1296
+
1297
+ /**
1298
+ * System message for focused calls to generate critical mockData keys.
1299
+ * These are keys referenced by the scenario's execution flow requiredValues.
1300
+ */
1301
+ export const generateCriticalKeysSystemMessage = (
1302
+ scenarioName: string,
1303
+ ) => `You are generating mock data for CRITICAL keys that control scenario behavior.
1304
+
1305
+ These keys are referenced by the execution flow's requiredValues - they directly determine
1306
+ what the component renders. Pay EXTRA attention to matching the exact structure and values.
1307
+
1308
+ - Scenario name must match exactly: "${scenarioName}"
1309
+
1310
+ ## CRITICAL: Special Characters in Keys
1311
+ Keys like \`*\` are LITERAL string keys, NOT wildcards or patterns.
1312
+ - If the schema shows \`{ "*": "string" }\`, generate \`{ "*": "some value" }\`
1313
+ - Do NOT interpret \`*\` as "any key" - use it as an actual key name
1314
+
1315
+ ## CRITICAL: Preserve Exact Structure
1316
+ Your response MUST mirror the EXACT nested structure provided.
1317
+ - Copy key strings EXACTLY as shown (including special characters)
1318
+ - Only change leaf VALUES (replacing type descriptions with actual data)
1319
+ - Do NOT modify keys, type parameters, or add extra keys
1320
+
1321
+ ## Matching requiredValues
1322
+ When the prompt shows requiredValues like:
1323
+ - \`attributePath: "useParams().functionCallReturnValue.*"\`
1324
+ - \`value: "scenarios"\`
1325
+
1326
+ This means set the \`*\` key to include "scenarios". For URL paths split by \`/\`,
1327
+ generate a path like \`"scenarios/id/mode"\` where segments match requirements.
1328
+
1329
+ ## Response Format
1330
+ \`\`\`json
1331
+ {
1332
+ "scenarioData": {
1333
+ "scenarioName": "${scenarioName}",
1334
+ "data": {
1335
+ "mockData": {
1336
+ // generate data for ONLY the critical keys
1337
+ }
1338
+ }
1339
+ }
1340
+ }
1341
+ \`\`\`
1342
+
1343
+ ## Rules
1344
+ - Valid JSON only
1345
+ - No \`undefined\`—use \`null\` or omit
1346
+ - Match the exact schema structure provided
1347
+ `;
1348
+
1349
+ /**
1350
+ * System message for focused calls to generate mock data for a chunk of keys.
1351
+ * Used when data structures are large and need to be processed in smaller pieces.
1352
+ */
1353
+ export const generateChunkSystemMessage = (
1354
+ scenarioName: string,
1355
+ ) => `You are generating mock data for a SUBSET of keys from a larger data structure.
1356
+
1357
+ This chunk contains fewer keys so you can focus on generating HIGH QUALITY data for each one.
1358
+ Pay EXTRA attention to matching the exact structure and values for each key.
1359
+
1360
+ - Scenario name must match exactly: "${scenarioName}"
1361
+
1362
+ ## CRITICAL: Special Characters in Keys
1363
+ Keys like \`*\` are LITERAL string keys, NOT wildcards or patterns.
1364
+ - If the schema shows \`{ "*": "string" }\`, generate \`{ "*": "some value" }\`
1365
+ - Do NOT interpret \`*\` as "any key" - use it as an actual key name
1366
+
1367
+ ## CRITICAL: Preserve Exact Structure
1368
+ Your response MUST mirror the EXACT nested structure provided.
1369
+ - Copy key strings EXACTLY as shown (including special characters)
1370
+ - Only change leaf VALUES (replacing type descriptions with actual data)
1371
+ - Do NOT modify keys, type parameters, or add extra keys
1372
+
1373
+ ## Matching requiredValues
1374
+ If the prompt includes requiredValues, these are specific values that MUST be set:
1375
+ - For \`attributePath: "useParams().functionCallReturnValue.*"\` with \`value: "scenarios"\`
1376
+ → Set the \`*\` key to include "scenarios" (e.g., "scenarios/id/mode")
1377
+ - For URL paths, generate realistic paths that satisfy the requirements
1378
+
1379
+ ## CRITICAL: NO ERROR DATA
1380
+ NEVER include "error" fields in responses. Skip them entirely.
1381
+ - If structure has \`{ data: {...}, error: {...} }\`, only fill \`data\`
1382
+ - Leave out any attribute named "error"—do not set to null, omit entirely
1383
+
1384
+ ## Response Format
1385
+ \`\`\`json
1386
+ {
1387
+ "mockData": {
1388
+ // generate data for ONLY the keys in this chunk
1389
+ }
1390
+ }
1391
+ \`\`\`
1392
+
1393
+ ## Rules
1394
+ - Valid JSON only
1395
+ - No \`undefined\`—use \`null\` or omit
1396
+ - Generate data for ALL keys in the chunk (don't skip any)
1397
+ - Arrays should have many items (at least 4) unless specified otherwise
1398
+ `;